From 22fd0c3e5c5025fb7b9f58030c474d06b0c68c3f Mon Sep 17 00:00:00 2001 From: "darin@apple.com" Date: Fri, 27 Mar 2009 17:53:27 +0000 Subject: [PATCH] 2009-03-27 Darin Adler Reviewed by John Sullivan and Anders Carlsson. 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 | 21 +++++++++++++++++++++ WebKit/mac/WebView/WebHTMLView.mm | 23 ++++++++++++++++------- WebKit/mac/WebView/WebView.mm | 23 ++++++++++++++++++++--- WebKit/mac/WebView/WebViewInternal.h | 4 +++- WebKit/mac/WebView/WebViewPrivate.h | 3 +++ 5 files changed, 63 insertions(+), 11 deletions(-) diff --git a/WebKit/mac/ChangeLog b/WebKit/mac/ChangeLog index 9a088b4..883a05d 100644 --- a/WebKit/mac/ChangeLog +++ b/WebKit/mac/ChangeLog @@ -1,3 +1,24 @@ +2009-03-27 Darin Adler + + Reviewed by John Sullivan and Anders Carlsson. + + 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 Expose new DOM methods as public Objective-C API. diff --git a/WebKit/mac/WebView/WebHTMLView.mm b/WebKit/mac/WebView/WebHTMLView.mm index c4ca174..34445d8 100644 --- a/WebKit/mac/WebView/WebHTMLView.mm +++ b/WebKit/mac/WebView/WebHTMLView.mm @@ -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 diff --git a/WebKit/mac/WebView/WebView.mm b/WebKit/mac/WebView/WebView.mm index de3628a..8acb9f8 100644 --- a/WebKit/mac/WebView/WebView.mm +++ b/WebKit/mac/WebView/WebView.mm @@ -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 diff --git a/WebKit/mac/WebView/WebViewInternal.h b/WebKit/mac/WebView/WebViewInternal.h index ad4f19c..56e597b8 100644 --- a/WebKit/mac/WebView/WebViewInternal.h +++ b/WebKit/mac/WebView/WebViewInternal.h @@ -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 { diff --git a/WebKit/mac/WebView/WebViewPrivate.h b/WebKit/mac/WebView/WebViewPrivate.h index ada0e01..b5b1a2c 100644 --- a/WebKit/mac/WebView/WebViewPrivate.h +++ b/WebKit/mac/WebView/WebViewPrivate.h @@ -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) -- 1.8.3.1