Reviewed by John Sullivan and Anders Carlsson.
<rdar://problem/5987442> Pasteboard not exposed to WebEditingDelegate for WebViewInsertActionPasted (needed for system services)
Added SPI to tell which pasteboard is currently being inserted.
I chose to put it on WebView to be forward-looking since we're migrating things
from WebHTMLView to WebView in the future.
* WebView/WebHTMLView.mm:
(-[WebHTMLView _pasteWithPasteboard:allowPlainText:]): Add calls to _setInsertionPasteboard.
(-[WebHTMLView _pasteAsPlainTextWithPasteboard:]): Ditto.
* WebView/WebView.mm:
(-[WebViewPrivate dealloc]): Assert the pasteboard is nil.
(-[WebViewPrivate finalize]): Ditto.
(-[WebView _insertionPasteboard]): Return the pastebaord.
(-[WebView _setInsertionPasteboard:]): Set the pasteboard.
* WebView/WebViewInternal.h: Added _setInsertionPasteboard.
* WebView/WebViewPrivate.h: Added _insertionPasteboard.
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@42041
268f45cc-cd09-0410-ab3c-
d52691b4dbfc
+2009-03-27 Darin Adler <darin@apple.com>
+
+ Reviewed by John Sullivan and Anders Carlsson.
+
+ <rdar://problem/5987442> Pasteboard not exposed to WebEditingDelegate for WebViewInsertActionPasted (needed for system services)
+
+ Added SPI to tell which pasteboard is currently being inserted.
+ I chose to put it on WebView to be forward-looking since we're migrating things
+ from WebHTMLView to WebView in the future.
+
+ * WebView/WebHTMLView.mm:
+ (-[WebHTMLView _pasteWithPasteboard:allowPlainText:]): Add calls to _setInsertionPasteboard.
+ (-[WebHTMLView _pasteAsPlainTextWithPasteboard:]): Ditto.
+ * WebView/WebView.mm:
+ (-[WebViewPrivate dealloc]): Assert the pasteboard is nil.
+ (-[WebViewPrivate finalize]): Ditto.
+ (-[WebView _insertionPasteboard]): Return the pastebaord.
+ (-[WebView _setInsertionPasteboard:]): Set the pasteboard.
+ * WebView/WebViewInternal.h: Added _setInsertionPasteboard.
+ * WebView/WebViewPrivate.h: Added _insertionPasteboard.
+
2009-03-25 Timothy Hatcher <timothy@apple.com>
Expose new DOM methods as public Objective-C API.
/*
- * Copyright (C) 2005, 2006, 2007, 2008 Apple Inc. All rights reserved.
+ * Copyright (C) 2005, 2006, 2007, 2008, 2009 Apple Inc. All rights reserved.
* (C) 2006, 2007 Graham Dennis (graham.dennis@gmail.com)
*
* Redistribution and use in source and binary forms, with or without
- (void)_pasteWithPasteboard:(NSPasteboard *)pasteboard allowPlainText:(BOOL)allowPlainText
{
+ WebView *webView = [[self _webView] retain];
+ [webView _setInsertionPasteboard:pasteboard];
+
DOMRange *range = [self _selectedRange];
- DOMDocumentFragment *fragment = [self _documentFragmentFromPasteboard:pasteboard
- inContext:range allowPlainText:allowPlainText];
- WebFrame *frame = [self _frame];
- if (fragment && [self _shouldInsertFragment:fragment replacingDOMRange:[self _selectedRange] givenAction:WebViewInsertActionPasted]) {
- [frame _replaceSelectionWithFragment:fragment selectReplacement:NO smartReplace:[self _canSmartReplaceWithPasteboard:pasteboard] matchStyle:NO];
- }
+ DOMDocumentFragment *fragment = [self _documentFragmentFromPasteboard:pasteboard inContext:range allowPlainText:allowPlainText];
+ if (fragment && [self _shouldInsertFragment:fragment replacingDOMRange:range givenAction:WebViewInsertActionPasted])
+ [[self _frame] _replaceSelectionWithFragment:fragment selectReplacement:NO smartReplace:[self _canSmartReplaceWithPasteboard:pasteboard] matchStyle:NO];
+
+ [webView _setInsertionPasteboard:nil];
+ [webView release];
}
- (void)_pasteAsPlainTextWithPasteboard:(NSPasteboard *)pasteboard
{
+ WebView *webView = [[self _webView] retain];
+ [webView _setInsertionPasteboard:pasteboard];
+
NSString *text = [self _plainTextFromPasteboard:pasteboard];
if ([self _shouldReplaceSelectionWithText:text givenAction:WebViewInsertActionPasted])
[[self _frame] _replaceSelectionWithText:text selectReplacement:NO smartReplace:[self _canSmartReplaceWithPasteboard:pasteboard]];
+
+ [webView _setInsertionPasteboard:nil];
+ [webView release];
}
- (void)_removeMouseMovedObserverUnconditionally
BOOL needsOneShotDrawingSynchronization;
// Number of WebHTMLViews using accelerated compositing. Used to implement _isUsingAcceleratedCompositing.
int acceleratedFramesCount;
-#endif
+#endif
+
+ NSPasteboard *insertionPasteboard;
}
@end
{
ASSERT(applicationIsTerminating || !page);
ASSERT(applicationIsTerminating || !preferences);
-
+ ASSERT(!insertionPasteboard);
+
[applicationNameForUserAgent release];
[backgroundColor release];
[editingDelegateForwarder release];
[mediaStyle release];
-
+
[super dealloc];
}
{
ASSERT_MAIN_THREAD();
+ ASSERT(!insertionPasteboard);
+
[super finalize];
}
}
#if USE(ACCELERATED_COMPOSITING)
+
- (BOOL)_needsOneShotDrawingSynchronization
{
return _private->needsOneShotDrawingSynchronization;
if (leaving)
[self didChangeValueForKey:UsingAcceleratedCompositingProperty];
}
+
#endif
- (BOOL)_isUsingAcceleratedCompositing
#endif
}
+- (NSPasteboard *)_insertionPasteboard
+{
+ return _private ? _private->insertionPasteboard : nil;
+}
+
@end
@implementation _WebSafeForwarder
return _private->_keyboardUIMode;
}
+- (void)_setInsertionPasteboard:(NSPasteboard *)pasteboard
+{
+ _private->insertionPasteboard = pasteboard;
+}
+
@end
// We use these functions to call the delegates and block exceptions. These functions are
/*
- * Copyright (C) 2005, 2006, 2007, 2008 Apple Inc. All rights reserved.
+ * Copyright (C) 2005, 2006, 2007, 2008, 2009 Apple Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
- (void)_stoppedAcceleratedCompositingForFrame:(WebFrame*)webFrame;
#endif
+- (void)_setInsertionPasteboard:(NSPasteboard *)pasteboard;
+
@end
typedef struct _WebResourceDelegateImplementationCache {
// SPI for DumpRenderTree
- (BOOL)_isUsingAcceleratedCompositing;
+// Which pasteboard text is coming from in editing delegate methods such as shouldInsertNode.
+- (NSPasteboard *)_insertionPasteboard;
+
@end
@interface WebView (WebViewPrintingPrivate)