2009-03-27 Darin Adler <darin@apple.com>
authordarin@apple.com <darin@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 27 Mar 2009 17:53:27 +0000 (17:53 +0000)
committerdarin@apple.com <darin@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 27 Mar 2009 17:53:27 +0000 (17:53 +0000)
        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

WebKit/mac/ChangeLog
WebKit/mac/WebView/WebHTMLView.mm
WebKit/mac/WebView/WebView.mm
WebKit/mac/WebView/WebViewInternal.h
WebKit/mac/WebView/WebViewPrivate.h

index 9a088b4..883a05d 100644 (file)
@@ -1,3 +1,24 @@
+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.
index c4ca174..34445d8 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * 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
@@ -780,20 +780,29 @@ static NSURL* uniqueURLWithRelativePart(NSString *relativePart)
 
 - (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
index de3628a..8acb9f8 100644 (file)
@@ -422,7 +422,9 @@ static const char webViewIsOpen[] = "At least one WebView is still open.";
     BOOL needsOneShotDrawingSynchronization;
     // Number of WebHTMLViews using accelerated compositing. Used to implement _isUsingAcceleratedCompositing.
     int acceleratedFramesCount;
-#endif    
+#endif
+
+    NSPasteboard *insertionPasteboard;
 }
 @end
 
@@ -539,7 +541,8 @@ static BOOL grammarCheckingEnabled;
 {    
     ASSERT(applicationIsTerminating || !page);
     ASSERT(applicationIsTerminating || !preferences);
-    
+    ASSERT(!insertionPasteboard);
+
     [applicationNameForUserAgent release];
     [backgroundColor release];
     
@@ -554,7 +557,7 @@ static BOOL grammarCheckingEnabled;
     [editingDelegateForwarder release];
     
     [mediaStyle release];
-    
+
     [super dealloc];
 }
 
@@ -562,6 +565,8 @@ static BOOL grammarCheckingEnabled;
 {
     ASSERT_MAIN_THREAD();
 
+    ASSERT(!insertionPasteboard);
+
     [super finalize];
 }
 
@@ -2147,6 +2152,7 @@ WebScriptDebugDelegateImplementationCache* WebViewGetScriptDebugDelegateImplemen
 }
 
 #if USE(ACCELERATED_COMPOSITING)
+
 - (BOOL)_needsOneShotDrawingSynchronization
 {
     return _private->needsOneShotDrawingSynchronization;
@@ -2178,6 +2184,7 @@ WebScriptDebugDelegateImplementationCache* WebViewGetScriptDebugDelegateImplemen
     if (leaving)
         [self didChangeValueForKey:UsingAcceleratedCompositingProperty];
 }
+
 #endif    
 
 - (BOOL)_isUsingAcceleratedCompositing
@@ -2189,6 +2196,11 @@ WebScriptDebugDelegateImplementationCache* WebViewGetScriptDebugDelegateImplemen
 #endif
 }
 
+- (NSPasteboard *)_insertionPasteboard
+{
+    return _private ? _private->insertionPasteboard : nil;
+}
+
 @end
 
 @implementation _WebSafeForwarder
@@ -5007,6 +5019,11 @@ static WebFrameView *containingFrameView(NSView *view)
     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
index ad4f19c..56e597b 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * 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
@@ -151,6 +151,8 @@ typedef WebCore::Page WebCorePage;
 - (void)_stoppedAcceleratedCompositingForFrame:(WebFrame*)webFrame;
 #endif
 
+- (void)_setInsertionPasteboard:(NSPasteboard *)pasteboard;
+
 @end
 
 typedef struct _WebResourceDelegateImplementationCache {
index ada0e01..b5b1a2c 100644 (file)
@@ -413,6 +413,9 @@ Could be worth adding to the API.
 // SPI for DumpRenderTree
 - (BOOL)_isUsingAcceleratedCompositing;
 
+// Which pasteboard text is coming from in editing delegate methods such as shouldInsertNode.
+- (NSPasteboard *)_insertionPasteboard;
+
 @end
 
 @interface WebView (WebViewPrintingPrivate)