Title: [175302] branches/safari-600.3-branch/Source
Revision
175302
Author
[email protected]
Date
2014-10-28 21:24:27 -0700 (Tue, 28 Oct 2014)

Log Message

Merge r174791. <rdar://problem/18753175>

Modified Paths

Added Paths

Diff

Modified: branches/safari-600.3-branch/Source/WebCore/ChangeLog (175301 => 175302)


--- branches/safari-600.3-branch/Source/WebCore/ChangeLog	2014-10-29 04:21:21 UTC (rev 175301)
+++ branches/safari-600.3-branch/Source/WebCore/ChangeLog	2014-10-29 04:24:27 UTC (rev 175302)
@@ -1,5 +1,27 @@
 2014-10-28  Dana Burkart  <[email protected]>
 
+        Merge r174791. <rdar://problem/18753175>
+
+    2014-10-16  Tim Horton  <[email protected]>
+    
+            Implement selection services menu for Legacy WebKit
+            https://bugs.webkit.org/show_bug.cgi?id=137582
+            <rdar://problem/18604241>
+    
+            Reviewed by Brady Eidson.
+    
+            * WebCore.exp.in:
+            * editing/Editor.h:
+            * editing/ios/EditorIOS.mm:
+            (WebCore::Editor::replaceSelectionWithAttributedString):
+            * editing/mac/EditorMac.mm:
+            (WebCore::Editor::replaceSelectionWithAttributedString):
+            Add replaceSelectionWithAttributedString, which replaces the selection
+            with the given attributed string (converting to plain text if the destination
+            is not richly editable).
+    
+2014-10-28  Dana Burkart  <[email protected]>
+
         Merge r174524. <rdar://problem/18640868>
 
     2014-10-09  Tim Horton  <[email protected]>

Modified: branches/safari-600.3-branch/Source/WebCore/WebCore.exp.in (175301 => 175302)


--- branches/safari-600.3-branch/Source/WebCore/WebCore.exp.in	2014-10-29 04:21:21 UTC (rev 175301)
+++ branches/safari-600.3-branch/Source/WebCore/WebCore.exp.in	2014-10-29 04:24:27 UTC (rev 175302)
@@ -1247,6 +1247,7 @@
 __ZN7WebCore6Editor34setMarkedTextMatchesAreHighlightedEb
 __ZN7WebCore6Editor35increaseSelectionListLevelUnorderedEv
 __ZN7WebCore6Editor35setIgnoreCompositionSelectionChangeEb
+__ZN7WebCore6Editor36replaceSelectionWithAttributedStringEP18NSAttributedStringNS_22MailBlockquoteHandlingE
 __ZN7WebCore6Editor38commandIsSupportedFromMenuOrKeyBindingERKN3WTF6StringE
 __ZN7WebCore6Editor39insertParagraphSeparatorInQuotedContentEv
 __ZN7WebCore6Editor3cutEv

Modified: branches/safari-600.3-branch/Source/WebCore/editing/Editor.h (175301 => 175302)


--- branches/safari-600.3-branch/Source/WebCore/editing/Editor.h	2014-10-29 04:21:21 UTC (rev 175301)
+++ branches/safari-600.3-branch/Source/WebCore/editing/Editor.h	2014-10-29 04:24:27 UTC (rev 175302)
@@ -441,6 +441,7 @@
     void replaceNodeFromPasteboard(Node*, const String& pasteboardName);
     PassRefPtr<SharedBuffer> dataSelectionForPasteboard(const String& pasteboardName);
 #endif // !PLATFORM(IOS)
+    void replaceSelectionWithAttributedString(NSAttributedString *, MailBlockquoteHandling = MailBlockquoteHandling::RespectBlockquote);
 #endif
 
 #if PLATFORM(COCOA) || PLATFORM(EFL)

Modified: branches/safari-600.3-branch/Source/WebCore/editing/ios/EditorIOS.mm (175301 => 175302)


--- branches/safari-600.3-branch/Source/WebCore/editing/ios/EditorIOS.mm	2014-10-29 04:21:21 UTC (rev 175301)
+++ branches/safari-600.3-branch/Source/WebCore/editing/ios/EditorIOS.mm	2014-10-29 04:24:27 UTC (rev 175302)
@@ -623,6 +623,22 @@
     return fragment.release();
 }
 
+void Editor::replaceSelectionWithAttributedString(NSAttributedString *attributedString, MailBlockquoteHandling mailBlockquoteHandling)
+{
+    if (m_frame.selection().isNone())
+        return;
+
+    if (m_frame.selection().selection().isContentRichlyEditable()) {
+        RefPtr<DocumentFragment> fragment = createFragmentAndAddResources(attributedString);
+        if (fragment && shouldInsertFragment(fragment, selectedRange(), EditorInsertActionPasted))
+            pasteAsFragment(fragment, false, false, mailBlockquoteHandling);
+    } else {
+        String text = [attributedString string];
+        if (shouldInsertText(text, selectedRange().get(), EditorInsertActionPasted))
+            pasteAsPlainText(text, false);
+    }
+}
+
 } // namespace WebCore
 
 #endif // PLATFORM(IOS)

Modified: branches/safari-600.3-branch/Source/WebCore/editing/mac/EditorMac.mm (175301 => 175302)


--- branches/safari-600.3-branch/Source/WebCore/editing/mac/EditorMac.mm	2014-10-29 04:21:21 UTC (rev 175301)
+++ branches/safari-600.3-branch/Source/WebCore/editing/mac/EditorMac.mm	2014-10-29 04:24:27 UTC (rev 175302)
@@ -668,4 +668,20 @@
     return fragment.release();
 }
 
+void Editor::replaceSelectionWithAttributedString(NSAttributedString *attributedString, MailBlockquoteHandling mailBlockquoteHandling)
+{
+    if (m_frame.selection().isNone())
+        return;
+
+    if (m_frame.selection().selection().isContentRichlyEditable()) {
+        RefPtr<DocumentFragment> fragment = createFragmentAndAddResources(attributedString);
+        if (fragment && shouldInsertFragment(fragment, selectedRange(), EditorInsertActionPasted))
+            pasteAsFragment(fragment, false, false, mailBlockquoteHandling);
+    } else {
+        String text = [attributedString string];
+        if (shouldInsertText(text, selectedRange().get(), EditorInsertActionPasted))
+            pasteAsPlainText(text, false);
+    }
+}
+
 } // namespace WebCore

Modified: branches/safari-600.3-branch/Source/WebKit/ChangeLog (175301 => 175302)


--- branches/safari-600.3-branch/Source/WebKit/ChangeLog	2014-10-29 04:21:21 UTC (rev 175301)
+++ branches/safari-600.3-branch/Source/WebKit/ChangeLog	2014-10-29 04:24:27 UTC (rev 175302)
@@ -1,5 +1,19 @@
 2014-10-28  Dana Burkart  <[email protected]>
 
+        Merge r174791. <rdar://problem/18753175>
+
+    2014-10-16  Tim Horton  <[email protected]>
+    
+            Implement selection services menu for Legacy WebKit
+            https://bugs.webkit.org/show_bug.cgi?id=137582
+            <rdar://problem/18604241>
+    
+            Reviewed by Brady Eidson.
+    
+            * WebKit.xcodeproj/project.pbxproj:
+    
+2014-10-28  Dana Burkart  <[email protected]>
+
         Merge r174368. <rdar://problem/18753175>
 
     2014-10-06  Brent Fulgham  <[email protected]>

Modified: branches/safari-600.3-branch/Source/WebKit/WebKit.xcodeproj/project.pbxproj (175301 => 175302)


--- branches/safari-600.3-branch/Source/WebKit/WebKit.xcodeproj/project.pbxproj	2014-10-29 04:21:21 UTC (rev 175301)
+++ branches/safari-600.3-branch/Source/WebKit/WebKit.xcodeproj/project.pbxproj	2014-10-29 04:24:27 UTC (rev 175302)
@@ -83,6 +83,8 @@
 		29AEF960134C76FB00FE5096 /* OutlookQuirksUserScript.js in Resources */ = {isa = PBXBuildFile; fileRef = 29AEF95D134C755400FE5096 /* OutlookQuirksUserScript.js */; };
 		2D25396618CE85C200270222 /* WebSharingServicePickerController.h in Headers */ = {isa = PBXBuildFile; fileRef = 2D25396418CE85C200270222 /* WebSharingServicePickerController.h */; };
 		2D25396718CE85C200270222 /* WebSharingServicePickerController.mm in Sources */ = {isa = PBXBuildFile; fileRef = 2D25396518CE85C200270222 /* WebSharingServicePickerController.mm */; };
+		2DD632C219E5D1F0002E9C7B /* WebSelectionServiceController.h in Headers */ = {isa = PBXBuildFile; fileRef = 2DD632C019E5D1F0002E9C7B /* WebSelectionServiceController.h */; };
+		2DD632C319E5D1F0002E9C7B /* WebSelectionServiceController.mm in Sources */ = {isa = PBXBuildFile; fileRef = 2DD632C119E5D1F0002E9C7B /* WebSelectionServiceController.mm */; };
 		312E2FE514E48182007CCA18 /* WebNotification.h in Headers */ = {isa = PBXBuildFile; fileRef = 312E2FE314E48182007CCA18 /* WebNotification.h */; settings = {ATTRIBUTES = (Private, ); }; };
 		312E2FE614E48182007CCA18 /* WebNotification.mm in Sources */ = {isa = PBXBuildFile; fileRef = 312E2FE414E48182007CCA18 /* WebNotification.mm */; };
 		312E2FE914E48215007CCA18 /* WebNotificationInternal.h in Headers */ = {isa = PBXBuildFile; fileRef = 312E2FE814E48215007CCA18 /* WebNotificationInternal.h */; };
@@ -465,7 +467,7 @@
 		0F30985D11ECFE4400F559DF /* WebRenderLayer.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WebRenderLayer.h; sourceTree = "<group>"; };
 		0F30985E11ECFE4500F559DF /* WebRenderLayer.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = WebRenderLayer.mm; sourceTree = "<group>"; };
 		14D8252D0AF955090004F057 /* WebChromeClient.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = WebChromeClient.h; sourceTree = "<group>"; };
-		14D8252E0AF955090004F057 /* WebChromeClient.mm */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.objcpp; path = WebChromeClient.mm; sourceTree = "<group>"; };
+		14D8252E0AF955090004F057 /* WebChromeClient.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = WebChromeClient.mm; sourceTree = "<group>"; };
 		1A2DBE9D0F251E3A0036F8A6 /* ProxyInstance.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ProxyInstance.h; sourceTree = "<group>"; };
 		1A2DBE9E0F251E3A0036F8A6 /* ProxyInstance.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = ProxyInstance.mm; sourceTree = "<group>"; };
 		1A4DF5200EC8C74D006BD4B4 /* WebNetscapePluginView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WebNetscapePluginView.h; sourceTree = "<group>"; };
@@ -535,6 +537,8 @@
 		2D36FD5E03F78F9E00A80166 /* WebFormDelegatePrivate.h */ = {isa = PBXFileReference; fileEncoding = 4; indentWidth = 4; lastKnownFileType = sourcecode.c.h; path = WebFormDelegatePrivate.h; sourceTree = "<group>"; tabWidth = 8; usesTabs = 0; };
 		2D81DAB203EB0B2D00A80166 /* WebFormDelegate.h */ = {isa = PBXFileReference; fileEncoding = 30; indentWidth = 4; lastKnownFileType = sourcecode.c.h; path = WebFormDelegate.h; sourceTree = "<group>"; tabWidth = 8; usesTabs = 0; };
 		2D81DAB303EB0B2D00A80166 /* WebFormDelegate.m */ = {isa = PBXFileReference; fileEncoding = 30; indentWidth = 4; lastKnownFileType = sourcecode.c.objc; path = WebFormDelegate.m; sourceTree = "<group>"; tabWidth = 8; usesTabs = 0; };
+		2DD632C019E5D1F0002E9C7B /* WebSelectionServiceController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WebSelectionServiceController.h; sourceTree = "<group>"; };
+		2DD632C119E5D1F0002E9C7B /* WebSelectionServiceController.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = WebSelectionServiceController.mm; sourceTree = "<group>"; };
 		312E2FE314E48182007CCA18 /* WebNotification.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WebNotification.h; sourceTree = "<group>"; };
 		312E2FE414E48182007CCA18 /* WebNotification.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = WebNotification.mm; sourceTree = "<group>"; };
 		312E2FE814E48215007CCA18 /* WebNotificationInternal.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WebNotificationInternal.h; sourceTree = "<group>"; };
@@ -1572,6 +1576,8 @@
 				A5DEFC0711D5331C00885273 /* WebSecurityOrigin.mm */,
 				A5DEFC0811D5331C00885273 /* WebSecurityOriginInternal.h */,
 				A5DEFC0911D5331C00885273 /* WebSecurityOriginPrivate.h */,
+				2DD632C019E5D1F0002E9C7B /* WebSelectionServiceController.h */,
+				2DD632C119E5D1F0002E9C7B /* WebSelectionServiceController.mm */,
 				93EB178E09F88D510091F8FF /* WebSystemInterface.h */,
 				93EB178C09F88D460091F8FF /* WebSystemInterface.mm */,
 				1AB1DAC018BC0232004B6A9F /* WebViewGroup.h */,
@@ -1693,6 +1699,7 @@
 				7C01CB87173435C900C5D807 /* SearchPopupMenuMac.h in Headers */,
 				A10C1D6F1820300E0036883A /* WebGeolocationInternal.h in Headers */,
 				CEDA12DC152CBE6800D9E08D /* WebAlternativeTextClient.h in Headers */,
+				2DD632C219E5D1F0002E9C7B /* WebSelectionServiceController.h in Headers */,
 				B6CE5C25100BC5F500219936 /* WebApplicationCache.h in Headers */,
 				A10C1D721820300E0036883A /* WebMIMETypeRegistry.h in Headers */,
 				A5DEFC1311D5344B00885273 /* WebApplicationCacheQuotaManager.h in Headers */,
@@ -2136,6 +2143,7 @@
 				1CCFFD130B1F81F2002EE926 /* OldWebAssertions.c in Sources */,
 				A10C1D8E1820305E0036883A /* WebPDFViewPlaceholder.mm in Sources */,
 				7C01CB86173435C900C5D807 /* PopupMenuMac.mm in Sources */,
+				2DD632C319E5D1F0002E9C7B /* WebSelectionServiceController.mm in Sources */,
 				A10C1D771820300E0036883A /* WebVisiblePosition.mm in Sources */,
 				1A2DBEA00F251E3A0036F8A6 /* ProxyInstance.mm in Sources */,
 				070F549C17F1E42B00169E04 /* WebUserMediaClient.mm in Sources */,

Modified: branches/safari-600.3-branch/Source/WebKit/mac/ChangeLog (175301 => 175302)


--- branches/safari-600.3-branch/Source/WebKit/mac/ChangeLog	2014-10-29 04:21:21 UTC (rev 175301)
+++ branches/safari-600.3-branch/Source/WebKit/mac/ChangeLog	2014-10-29 04:24:27 UTC (rev 175302)
@@ -1,5 +1,91 @@
 2014-10-28  Dana Burkart  <[email protected]>
 
+        Merge r174791. <rdar://problem/18753175>
+
+    2014-10-16  Tim Horton  <[email protected]>
+    
+            Implement selection services menu for Legacy WebKit
+            https://bugs.webkit.org/show_bug.cgi?id=137582
+            <rdar://problem/18604241>
+    
+            Reviewed by Brady Eidson.
+    
+            * Misc/WebSharingServicePickerController.h:
+            Move SPI into the header (in the near future it will be moved to a modern-style SPI header).
+            Add WebSharingServicePickerClient, which other classes can implement
+            instead of tying WebSharingServicePickerController strongly to WebContextMenuClient.
+            Make initWithData:... -> initWithItems:... instead, taking an array of NSItemProviders.
+    
+            * Misc/WebSharingServicePickerController.mm:
+            Pass in NSSharingServicePickerStyle, so that clients can specify the style.
+    
+            (-[WebSharingServicePickerController clear]):
+            (-[WebSharingServicePickerController didShareImageData:confirmDataIsValidTIFFData:]):
+            (-[WebSharingServicePickerController sharingServicePicker:didChooseSharingService:]):
+            (-[WebSharingServicePickerController sharingService:sourceFrameOnScreenForShareItem:]):
+            (-[WebSharingServicePickerController sharingService:transitionImageForShareItem:contentRect:]):
+            (-[WebSharingServicePickerController sharingService:sourceWindowForShareItems:sharingContentScope:]):
+            Make use of WebSharingServicePickerClient.
+    
+            (-[WebSharingServicePickerController sharingService:didShareItems:]):
+            If we're returned a NSAttributedString, paste it on top of the current selection,
+            similar to what the WebKit2 implementation currently does.
+            
+            * WebCoreSupport/WebChromeClient.h:
+            * WebCoreSupport/WebChromeClient.mm:
+            (WebChromeClient::handleTelephoneNumberClick):
+            (WebChromeClient::handleSelectionServiceClick):
+            (WebChromeClient::hasRelevantSelectionServices):
+            Override the services-related ChromeClient functions, forward them to WebSelectionServiceController.
+    
+            * WebCoreSupport/WebContextMenuClient.h:
+            * WebCoreSupport/WebContextMenuClient.mm:
+            (WebContextMenuClient::sharingServicePickerWillBeDestroyed):
+            (WebContextMenuClient::pageForSharingServicePicker):
+            (WebContextMenuClient::windowForSharingServicePicker):
+            (WebContextMenuClient::screenRectForCurrentSharingServicePickerItem):
+            (WebContextMenuClient::imageForCurrentSharingServicePickerItem):
+            (WebContextMenuClient::contextMenuForEvent):
+            (WebContextMenuClient::screenRectForHitTestNode): Deleted.
+            (WebContextMenuClient::renderedImageForControlledImage): Deleted.
+            (WebContextMenuClient::clearSharingServicePickerController): Deleted.
+            Have WebContextMenuClient implement WebSharingServicePickerClient to avoid
+            having WebSharingServicePickerController tightly bound to it.
+            Make an NSItemProvider array when instantiating WebSharingServicePickerController
+            instead of handing it data directly.
+    
+            * WebCoreSupport/WebSelectionServiceController.h: Copied from Source/WebKit/mac/WebCoreSupport/WebContextMenuClient.h.
+            * WebCoreSupport/WebSelectionServiceController.mm: Added.
+            (WebSelectionServiceController::WebSelectionServiceController):
+            Add WebSelectionServiceController, which will act as the WebSharingServicePickerClient
+            for selection services.
+    
+            (WebSelectionServiceController::handleSelectionServiceClick):
+            Create a WebSharingSericePickerController with the selection's attributed string, and show its menu.
+    
+            (hasCompatibleServicesForItems):
+            (WebSelectionServiceController::hasRelevantSelectionServices):
+            Determine whether or not services are available.
+    
+            (WebSelectionServiceController::sharingServicePickerWillBeDestroyed):
+            (WebSelectionServiceController::pageForSharingServicePicker):
+            (WebSelectionServiceController::windowForSharingServicePicker):
+            Implement the rest of the WebSharingServicePickerClient overrides.
+    
+            (WebSelectionServiceController::screenRectForCurrentSharingServicePickerItem):
+            (WebSelectionServiceController::imageForCurrentSharingServicePickerItem):
+            These are only useful for image sharing services, so we don't need to
+            implement them (WebContextMenuClient does, on the other hand).
+    
+            * WebView/WebView.mm:
+            (-[WebView _selectionServiceController]):
+            * WebView/WebViewData.h:
+            * WebView/WebViewData.mm:
+            * WebView/WebViewInternal.h:
+            Keep a WebSelectionServiceController.
+    
+2014-10-28  Dana Burkart  <[email protected]>
+
         Merge r174525. <rdar://problem/18640876>
 
     2014-10-09  Tim Horton  <[email protected]>

Modified: branches/safari-600.3-branch/Source/WebKit/mac/Misc/WebSharingServicePickerController.h (175301 => 175302)


--- branches/safari-600.3-branch/Source/WebKit/mac/Misc/WebSharingServicePickerController.h	2014-10-29 04:21:21 UTC (rev 175301)
+++ branches/safari-600.3-branch/Source/WebKit/mac/Misc/WebSharingServicePickerController.h	2014-10-29 04:24:27 UTC (rev 175302)
@@ -28,18 +28,55 @@
 #import <wtf/RetainPtr.h>
 
 @class NSSharingServicePicker;
+@class WebSharingServicePickerController;
 @protocol NSSharingServiceDelegate;
 @protocol NSSharingServicePickerDelegate;
 
+#if __has_include(<AppKit/NSSharingService_Private.h>)
+#import <AppKit/NSSharingService_Private.h>
+#else
+typedef NS_ENUM(NSInteger, NSSharingServicePickerStyle) {
+    NSSharingServicePickerStyleMenu = 0,
+    NSSharingServicePickerStyleRollover = 1,
+    NSSharingServicePickerStyleTextSelection = 2,
+    NSSharingServicePickerStyleDataDetector = 3
+} NS_ENUM_AVAILABLE_MAC(10_10);
+
+typedef NS_ENUM(NSInteger, NSSharingServiceType) {
+    NSSharingServiceTypeShare = 0,
+    NSSharingServiceTypeViewer = 1,
+    NSSharingServiceTypeEditor = 2
+} NS_ENUM_AVAILABLE_MAC(10_10);
+
+typedef NSUInteger NSSharingServiceMask;
+#endif
+
+namespace WebCore {
+class FloatRect;
+class Page;
+}
+
 class WebContextMenuClient;
 
+class WebSharingServicePickerClient {
+public:
+    virtual ~WebSharingServicePickerClient() { }
+
+    virtual void sharingServicePickerWillBeDestroyed(WebSharingServicePickerController &) = 0;
+    virtual WebCore::Page* pageForSharingServicePicker(WebSharingServicePickerController &) = 0;
+    virtual RetainPtr<NSWindow> windowForSharingServicePicker(WebSharingServicePickerController &) = 0;
+
+    virtual WebCore::FloatRect screenRectForCurrentSharingServicePickerItem(WebSharingServicePickerController &) = 0;
+    virtual RetainPtr<NSImage> imageForCurrentSharingServicePickerItem(WebSharingServicePickerController &) = 0;
+};
+
 @interface WebSharingServicePickerController : NSObject <NSSharingServiceDelegate, NSSharingServicePickerDelegate> {
-    WebContextMenuClient* _menuClient;
+    WebSharingServicePickerClient* _pickerClient;
     RetainPtr<NSSharingServicePicker> _picker;
     BOOL _includeEditorServices;
 }
 
-- (instancetype)initWithData:(NSData *)data includeEditorServices:(BOOL)includeEditorServices menuClient:(WebContextMenuClient*)menuClient;
+- (instancetype)initWithItems:(NSArray *)items includeEditorServices:(BOOL)includeEditorServices client:(WebSharingServicePickerClient*)pickerClient style:(NSSharingServicePickerStyle)style;
 - (NSMenu *)menu;
 - (void)didShareImageData:(NSData *)data confirmDataIsValidTIFFData:(BOOL)confirmData;
 - (void)clear;

Modified: branches/safari-600.3-branch/Source/WebKit/mac/Misc/WebSharingServicePickerController.mm (175301 => 175302)


--- branches/safari-600.3-branch/Source/WebKit/mac/Misc/WebSharingServicePickerController.mm	2014-10-29 04:21:21 UTC (rev 175301)
+++ branches/safari-600.3-branch/Source/WebKit/mac/Misc/WebSharingServicePickerController.mm	2014-10-29 04:24:27 UTC (rev 175302)
@@ -39,13 +39,6 @@
 #import <WebCore/ContextMenuController.h>
 #import <WebCore/Page.h>
 
-#if __has_include(<AppKit/NSSharingService_Private.h>)
-#import <AppKit/NSSharingService_Private.h>
-#else
-typedef enum {
-    NSSharingServicePickerStyleRollover = 1
-} NSSharingServicePickerStyle;
-
 @interface NSSharingServicePicker (Private)
 @property NSSharingServicePickerStyle style;
 - (NSMenu *)menu;
@@ -69,7 +62,7 @@
 
 @implementation WebSharingServicePickerController
 
-- (instancetype)initWithData:(NSData *)data includeEditorServices:(BOOL)includeEditorServices menuClient:(WebContextMenuClient*)menuClient
+- (instancetype)initWithItems:(NSArray *)items includeEditorServices:(BOOL)includeEditorServices client:(WebSharingServicePickerClient*)pickerClient style:(NSSharingServicePickerStyle)style
 {
 #ifndef __LP64__
     return nil;
@@ -77,14 +70,12 @@
     if (!(self = [super init]))
         return nil;
 
-    RetainPtr<NSItemProvider> itemProvider = adoptNS([[NSItemProvider alloc] initWithItem:data typeIdentifier:@"public.data"]);
-
-    _picker = adoptNS([[NSSharingServicePicker alloc] initWithItems:@[ itemProvider.get() ]]);
-    [_picker setStyle:NSSharingServicePickerStyleRollover];
+    _picker = adoptNS([[NSSharingServicePicker alloc] initWithItems:items]);
+    [_picker setStyle:style];
     [_picker setDelegate:self];
 
     _includeEditorServices = includeEditorServices;
-    _menuClient = menuClient;
+    _pickerClient = pickerClient;
 
     return self;
 #endif
@@ -95,11 +86,11 @@
     // Protect self from being dealloc'ed partway through this method.
     RetainPtr<WebSharingServicePickerController> protector(self);
 
-    if (_menuClient)
-        _menuClient->clearSharingServicePickerController();
+    if (_pickerClient)
+        _pickerClient->sharingServicePickerWillBeDestroyed(*self);
 
     _picker = nullptr;
-    _menuClient = nullptr;
+    _pickerClient = nullptr;
 }
 
 - (NSMenu *)menu
@@ -109,7 +100,7 @@
 
 - (void)didShareImageData:(NSData *)data confirmDataIsValidTIFFData:(BOOL)confirmData
 {
-    Page* page = [_menuClient->webView() page];
+    Page* page = _pickerClient->pageForSharingServicePicker(*self);
     if (!page)
         return;
 
@@ -160,13 +151,18 @@
 - (void)sharingServicePicker:(NSSharingServicePicker *)sharingServicePicker didChooseSharingService:(NSSharingService *)service
 {
     if (!service)
-        _menuClient->clearSharingServicePickerController();
+        _pickerClient->sharingServicePickerWillBeDestroyed(*self);
 }
 
 #pragma mark NSSharingServiceDelegate methods
 
 - (void)sharingService:(NSSharingService *)sharingService didShareItems:(NSArray *)items
 {
+    // We only care about what item was shared if we were interested in editor services
+    // (i.e., if we plan on replacing the selection with the returned item)
+    if (!_includeEditorServices)
+        return;
+
     // We only send one item, so we should only get one item back.
     if ([items count] != 1)
         return;
@@ -198,8 +194,11 @@
         }];
     }
 #endif
-    else
-        LOG_ERROR("sharingService:didShareItems: - Unknown item type returned");
+    else if ([item isKindOfClass:[NSAttributedString class]]) {
+        Frame& frame = _pickerClient->pageForSharingServicePicker(*self)->focusController().focusedOrMainFrame();
+        frame.editor().replaceSelectionWithAttributedString(item);
+    } else
+        LOG_ERROR("sharingService:didShareItems: - Unknown item type returned\n");
 }
 
 - (void)sharingService:(NSSharingService *)sharingService didFailToShareItems:(NSArray *)items error:(NSError *)error
@@ -209,25 +208,23 @@
 
 - (NSRect)sharingService:(NSSharingService *)sharingService sourceFrameOnScreenForShareItem:(id <NSPasteboardWriting>)item
 {
-    if (!_menuClient)
+    if (!_pickerClient)
         return NSZeroRect;
 
-    return _menuClient->screenRectForHitTestNode();
+    return _pickerClient->screenRectForCurrentSharingServicePickerItem(*self);
 }
 
 - (NSImage *)sharingService:(NSSharingService *)sharingService transitionImageForShareItem:(id <NSPasteboardWriting>)item contentRect:(NSRect *)contentRect
 {
-    if (!_menuClient)
+    if (!_pickerClient)
         return nil;
 
-    return _menuClient->renderedImageForControlledImage();
+    return _pickerClient->imageForCurrentSharingServicePickerItem(*self).get();
 }
 
 - (NSWindow *)sharingService:(NSSharingService *)sharingService sourceWindowForShareItems:(NSArray *)items sharingContentScope:(NSSharingContentScope *)sharingContentScope
 {
-    return [_menuClient->webView() window];
+    return _pickerClient->windowForSharingServicePicker(*self).get();
 }
 
 @end
-
-#endif

Modified: branches/safari-600.3-branch/Source/WebKit/mac/WebCoreSupport/WebChromeClient.h (175301 => 175302)


--- branches/safari-600.3-branch/Source/WebKit/mac/WebCoreSupport/WebChromeClient.h	2014-10-29 04:21:21 UTC (rev 175301)
+++ branches/safari-600.3-branch/Source/WebKit/mac/WebCoreSupport/WebChromeClient.h	2014-10-29 04:24:27 UTC (rev 175302)
@@ -205,6 +205,11 @@
     virtual bool unwrapCryptoKey(const Vector<uint8_t>&, Vector<uint8_t>&) const override;
 #endif
 
+#if ENABLE(SERVICE_CONTROLS)
+    virtual void handleSelectionServiceClick(WebCore::FrameSelection&, const Vector<String>& telephoneNumbers, const WebCore::IntPoint&) override;
+    virtual bool hasRelevantSelectionServices(bool isTextOnly) const override;
+#endif
+
 #if PLATFORM(IOS)
     WebView* webView() const { return m_webView; }
 #else
@@ -212,6 +217,5 @@
 #endif
 
 private:
-
     WebView *m_webView;
 };

Modified: branches/safari-600.3-branch/Source/WebKit/mac/WebCoreSupport/WebChromeClient.mm (175301 => 175302)


--- branches/safari-600.3-branch/Source/WebKit/mac/WebCoreSupport/WebChromeClient.mm	2014-10-29 04:21:21 UTC (rev 175301)
+++ branches/safari-600.3-branch/Source/WebKit/mac/WebCoreSupport/WebChromeClient.mm	2014-10-29 04:24:27 UTC (rev 175302)
@@ -49,6 +49,7 @@
 #import "WebPlugin.h"
 #import "WebQuotaManager.h"
 #import "WebSecurityOriginInternal.h"
+#import "WebSelectionServiceController.h"
 #import "WebUIDelegatePrivate.h"
 #import "WebView.h"
 #import "WebViewInternal.h"
@@ -1041,3 +1042,16 @@
     return unwrapSerializedCryptoKey(masterKey, wrappedKey, key);
 }
 #endif
+
+#if ENABLE(SERVICE_CONTROLS)
+void WebChromeClient::handleSelectionServiceClick(WebCore::FrameSelection& selection, const Vector<String>& telephoneNumbers, const WebCore::IntPoint& point)
+{
+    [m_webView _selectionServiceController].handleSelectionServiceClick(selection, telephoneNumbers, point);
+}
+
+bool WebChromeClient::hasRelevantSelectionServices(bool isTextOnly) const
+{
+    return [m_webView _selectionServiceController].hasRelevantSelectionServices(isTextOnly);
+}
+
+#endif

Modified: branches/safari-600.3-branch/Source/WebKit/mac/WebCoreSupport/WebContextMenuClient.h (175301 => 175302)


--- branches/safari-600.3-branch/Source/WebKit/mac/WebCoreSupport/WebContextMenuClient.h	2014-10-29 04:21:21 UTC (rev 175301)
+++ branches/safari-600.3-branch/Source/WebKit/mac/WebCoreSupport/WebContextMenuClient.h	2014-10-29 04:24:27 UTC (rev 175302)
@@ -26,6 +26,7 @@
  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
+#import "WebSharingServicePickerController.h"
 #import <WebCore/ContextMenuClient.h>
 #import <WebCore/IntRect.h>
 
@@ -36,10 +37,14 @@
 class Node;
 }
 
-class WebContextMenuClient : public WebCore::ContextMenuClient {
+class WebContextMenuClient : public WebCore::ContextMenuClient
+#if ENABLE(SERVICE_CONTROLS)
+, public WebSharingServicePickerClient
+#endif
+{
 public:
     WebContextMenuClient(WebView *webView);
-    ~WebContextMenuClient();
+    virtual ~WebContextMenuClient();
 
     virtual void contextMenuDestroyed() override;
     
@@ -55,11 +60,13 @@
     virtual void searchWithSpotlight() override;
     virtual void showContextMenu() override;
 
-    NSRect screenRectForHitTestNode() const;
-
 #if ENABLE(SERVICE_CONTROLS)
-    void clearSharingServicePickerController();
-    NSImage *renderedImageForControlledImage() const;
+    // WebSharingServicePickerClient
+    virtual void sharingServicePickerWillBeDestroyed(WebSharingServicePickerController &) override;
+    virtual WebCore::Page* pageForSharingServicePicker(WebSharingServicePickerController &) override;
+    virtual RetainPtr<NSWindow> windowForSharingServicePicker(WebSharingServicePickerController &) override;
+    virtual WebCore::FloatRect screenRectForCurrentSharingServicePickerItem(WebSharingServicePickerController &) override;
+    virtual RetainPtr<NSImage> imageForCurrentSharingServicePickerItem(WebSharingServicePickerController &) override;
 #endif
 
     WebView *webView() { return m_webView; }

Modified: branches/safari-600.3-branch/Source/WebKit/mac/WebCoreSupport/WebContextMenuClient.mm (175301 => 175302)


--- branches/safari-600.3-branch/Source/WebKit/mac/WebCoreSupport/WebContextMenuClient.mm	2014-10-29 04:21:21 UTC (rev 175301)
+++ branches/safari-600.3-branch/Source/WebKit/mac/WebCoreSupport/WebContextMenuClient.mm	2014-10-29 04:24:27 UTC (rev 175302)
@@ -387,8 +387,24 @@
     return true;
 }
 
-NSRect WebContextMenuClient::screenRectForHitTestNode() const
+#if ENABLE(SERVICE_CONTROLS)
+void WebContextMenuClient::sharingServicePickerWillBeDestroyed(WebSharingServicePickerController &)
 {
+    m_sharingServicePickerController = nil;
+}
+
+WebCore::Page* WebContextMenuClient::pageForSharingServicePicker(WebSharingServicePickerController &)
+{
+    return [m_webView page];
+}
+
+RetainPtr<NSWindow> WebContextMenuClient::windowForSharingServicePicker(WebSharingServicePickerController &)
+{
+    return [m_webView window];
+}
+
+WebCore::FloatRect WebContextMenuClient::screenRectForCurrentSharingServicePickerItem(WebSharingServicePickerController &)
+{
     Page* page = [m_webView page];
     if (!page)
         return NSZeroRect;
@@ -415,8 +431,7 @@
     return frameView->contentsToScreen(intRect);
 }
 
-#if ENABLE(SERVICE_CONTROLS)
-NSImage *WebContextMenuClient::renderedImageForControlledImage() const
+RetainPtr<NSImage> WebContextMenuClient::imageForCurrentSharingServicePickerItem(WebSharingServicePickerController &)
 {
     Page* page = [m_webView page];
     if (!page)
@@ -455,11 +470,10 @@
     frameView->setPaintBehavior(oldPaintBehavior);
 
     RefPtr<Image> image = buffer->copyImage(DontCopyBackingStore);
-    return [[image->getNSImage() retain] autorelease];
+    return image->getNSImage();
 }
 #endif
 
-
 NSMenu *WebContextMenuClient::contextMenuForEvent(NSEvent *event, NSView *view, bool& isServicesMenu)
 {
     isServicesMenu = false;
@@ -472,12 +486,10 @@
     if (Image* image = page->contextMenuController().context().controlledImage()) {
         ASSERT(page->contextMenuController().context().hitTestResult().innerNode());
 
-        RefPtr<SharedBuffer> data = ""
-        ASSERT(data);
-        RetainPtr<CFDataRef> cfData = data->createCFData();
+        RetainPtr<NSItemProvider> itemProvider = adoptNS([[NSItemProvider alloc] initWithItem:image->getNSImage() typeIdentifier:@"public.image"]);
 
         bool isContentEditable = page->contextMenuController().context().hitTestResult().innerNode()->isContentEditable();
-        m_sharingServicePickerController = adoptNS([[WebSharingServicePickerController alloc] initWithData:(NSData *)cfData.get() includeEditorServices:isContentEditable menuClient:this]);
+        m_sharingServicePickerController = adoptNS([[WebSharingServicePickerController alloc] initWithItems:@[ itemProvider.get() ] includeEditorServices:isContentEditable client:this style:NSSharingServicePickerStyleRollover]);
 
         isServicesMenu = true;
         return [m_sharingServicePickerController menu];
@@ -513,11 +525,4 @@
     }
 }
 
-#if ENABLE(SERVICE_CONTROLS)
-void WebContextMenuClient::clearSharingServicePickerController()
-{
-    m_sharingServicePickerController = nil;
-}
-#endif
-
 #endif // !PLATFORM(IOS)

Copied: branches/safari-600.3-branch/Source/WebKit/mac/WebCoreSupport/WebSelectionServiceController.h (from rev 174791, trunk/Source/WebKit/mac/WebCoreSupport/WebSelectionServiceController.h) (0 => 175302)


--- branches/safari-600.3-branch/Source/WebKit/mac/WebCoreSupport/WebSelectionServiceController.h	                        (rev 0)
+++ branches/safari-600.3-branch/Source/WebKit/mac/WebCoreSupport/WebSelectionServiceController.h	2014-10-29 04:24:27 UTC (rev 175302)
@@ -0,0 +1,67 @@
+/*
+ * Copyright (C) 2014 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef WebSelectionServiceController_h
+#define WebSelectionServiceController_h
+
+#if ENABLE(SERVICE_CONTROLS)
+
+#import "WebSharingServicePickerController.h"
+#import <wtf/RetainPtr.h>
+#import <wtf/Vector.h>
+#import <wtf/text/WTFString.h>
+
+OBJC_CLASS NSImage;
+OBJC_CLASS NSWindow;
+OBJC_CLASS WebView;
+
+namespace WebCore {
+class FrameSelection;
+class IntPoint;
+}
+
+class WebSelectionServiceController : public WebSharingServicePickerClient {
+public:
+    WebSelectionServiceController(WebView*);
+
+    void handleSelectionServiceClick(WebCore::FrameSelection&, const Vector<String>& telephoneNumbers, const WebCore::IntPoint&);
+    bool hasRelevantSelectionServices(bool isTextOnly) const;
+
+    // WebSharingServicePickerClient
+    virtual void sharingServicePickerWillBeDestroyed(WebSharingServicePickerController &) override;
+    virtual WebCore::Page* pageForSharingServicePicker(WebSharingServicePickerController &) override;
+    virtual RetainPtr<NSWindow> windowForSharingServicePicker(WebSharingServicePickerController &) override;
+    virtual WebCore::FloatRect screenRectForCurrentSharingServicePickerItem(WebSharingServicePickerController &) override;
+    virtual RetainPtr<NSImage> imageForCurrentSharingServicePickerItem(WebSharingServicePickerController &) override;
+
+private:
+    WebView *m_webView;
+
+    RetainPtr<WebSharingServicePickerController> m_sharingServicePickerController;
+};
+
+#endif // ENABLE(SERVICE_CONTROLS)
+
+#endif // WebSelectionServiceController_h

Copied: branches/safari-600.3-branch/Source/WebKit/mac/WebCoreSupport/WebSelectionServiceController.mm (from rev 174791, trunk/Source/WebKit/mac/WebCoreSupport/WebSelectionServiceController.mm) (0 => 175302)


--- branches/safari-600.3-branch/Source/WebKit/mac/WebCoreSupport/WebSelectionServiceController.mm	                        (rev 0)
+++ branches/safari-600.3-branch/Source/WebKit/mac/WebCoreSupport/WebSelectionServiceController.mm	2014-10-29 04:24:27 UTC (rev 175302)
@@ -0,0 +1,129 @@
+/*
+ * Copyright (C) 2014 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#import "WebSelectionServiceController.h"
+
+#if ENABLE(SERVICE_CONTROLS)
+
+#import "WebViewInternal.h"
+#import <WebCore/FrameSelection.h>
+#import <WebCore/HTMLConverter.h>
+#import <WebCore/Range.h>
+#import <wtf/NeverDestroyed.h>
+
+using namespace WebCore;
+
+#if __has_include(<AppKit/NSSharingService_Private.h>)
+#import <AppKit/NSSharingService_Private.h>
+#else
+typedef NS_ENUM(NSInteger, NSSharingServicePickerStyle) {
+    NSSharingServicePickerStyleMenu = 0,
+    NSSharingServicePickerStyleRollover = 1,
+    NSSharingServicePickerStyleTextSelection = 2,
+    NSSharingServicePickerStyleDataDetector = 3
+} NS_ENUM_AVAILABLE_MAC(10_10);
+#endif
+
+WebSelectionServiceController::WebSelectionServiceController(WebView *webView) 
+    : m_webView(webView)
+{
+}
+
+void WebSelectionServiceController::handleSelectionServiceClick(WebCore::FrameSelection& selection, const Vector<String>& telephoneNumbers, const WebCore::IntPoint& point)
+{
+    Page* page = [m_webView page];
+    if (!page)
+        return;
+
+    RefPtr<Range> range = selection.selection().firstRange();
+    if (!range)
+        return;
+
+    RetainPtr<NSAttributedString> attributedSelection = attributedStringFromRange(*range);
+    if (!attributedSelection)
+        return;
+
+    NSArray *items = @[ attributedSelection.get() ];
+
+    bool isEditable = selection.selection().isContentEditable();
+    m_sharingServicePickerController = adoptNS([[WebSharingServicePickerController alloc] initWithItems:items includeEditorServices:isEditable client:this style:NSSharingServicePickerStyleTextSelection]);
+
+    RetainPtr<NSMenu> menu = adoptNS([[m_sharingServicePickerController menu] copy]);
+
+    [menu setShowsStateColumn:YES];
+
+    [menu popUpMenuPositioningItem:nil atLocation:[m_webView convertPoint:point toView:nil] inView:m_webView];
+}
+
+static bool hasCompatibleServicesForItems(NSArray *items)
+{
+    return [NSSharingService sharingServicesForItems:items mask:NSSharingServiceMaskViewer | NSSharingServiceMaskEditor].count;
+}
+
+bool WebSelectionServiceController::hasRelevantSelectionServices(bool isTextOnly) const
+{
+    RetainPtr<NSAttributedString> attributedString = adoptNS([[NSAttributedString alloc] initWithString:@"a"]);
+
+    bool hasSelectionServices = hasCompatibleServicesForItems(@[ attributedString.get() ]);
+    if (isTextOnly && hasSelectionServices)
+        return true;
+
+    NSTextAttachment *attachment = [[NSTextAttachment alloc] init];
+    RetainPtr<NSImage> image = adoptNS([[NSImage alloc] init]);
+    NSTextAttachmentCell *cell = [[NSTextAttachmentCell alloc] initImageCell:image.get()];
+    [attachment setAttachmentCell:cell];
+    RetainPtr<NSMutableAttributedString> attributedStringWithRichContent = adoptNS((NSMutableAttributedString *)[NSMutableAttributedString attributedStringWithAttachment:attachment]);
+    [attributedStringWithRichContent appendAttributedString:attributedString.get()];
+
+    bool hasRichContentServices = hasCompatibleServicesForItems(@[ attributedStringWithRichContent.get() ]);
+    return hasRichContentServices;
+}
+
+void WebSelectionServiceController::sharingServicePickerWillBeDestroyed(WebSharingServicePickerController &)
+{
+    m_sharingServicePickerController = nil;
+}
+
+WebCore::Page* WebSelectionServiceController::pageForSharingServicePicker(WebSharingServicePickerController &)
+{
+    return [m_webView page];
+}
+
+RetainPtr<NSWindow> WebSelectionServiceController::windowForSharingServicePicker(WebSharingServicePickerController &)
+{
+    return [m_webView window];
+}
+
+FloatRect WebSelectionServiceController::screenRectForCurrentSharingServicePickerItem(WebSharingServicePickerController &)
+{
+    return FloatRect();
+}
+
+RetainPtr<NSImage> WebSelectionServiceController::imageForCurrentSharingServicePickerItem(WebSharingServicePickerController &)
+{
+    return nil;
+}
+
+#endif

Modified: branches/safari-600.3-branch/Source/WebKit/mac/WebView/WebView.mm (175301 => 175302)


--- branches/safari-600.3-branch/Source/WebKit/mac/WebView/WebView.mm	2014-10-29 04:21:21 UTC (rev 175301)
+++ branches/safari-600.3-branch/Source/WebKit/mac/WebView/WebView.mm	2014-10-29 04:24:27 UTC (rev 175302)
@@ -97,6 +97,7 @@
 #import "WebProgressTrackerClient.h"
 #import "WebScriptDebugDelegate.h"
 #import "WebScriptWorldInternal.h"
+#import "WebSelectionServiceController.h"
 #import "WebStorageManagerInternal.h"
 #import "WebSystemInterface.h"
 #import "WebTextCompletionController.h"
@@ -8518,6 +8519,15 @@
 }
 #endif
 
+#if ENABLE(SERVICE_CONTROLS)
+- (WebSelectionServiceController&)_selectionServiceController
+{
+    if (!_private->_selectionServiceController)
+        _private->_selectionServiceController = std::make_unique<WebSelectionServiceController>(self);
+    return *_private->_selectionServiceController;
+}
+#endif
+
 - (NSPoint)_convertPointFromRootView:(NSPoint)point
 {
     return NSMakePoint(point.x, [self bounds].size.height - point.y);

Modified: branches/safari-600.3-branch/Source/WebKit/mac/WebView/WebViewData.h (175301 => 175302)


--- branches/safari-600.3-branch/Source/WebKit/mac/WebView/WebViewData.h	2014-10-29 04:21:21 UTC (rev 175301)
+++ branches/safari-600.3-branch/Source/WebKit/mac/WebView/WebViewData.h	2014-10-29 04:24:27 UTC (rev 175302)
@@ -82,6 +82,7 @@
 
 class LayerFlushController;
 class WebViewGroup;
+class WebSelectionServiceController;
 
 class WebViewLayerFlushScheduler : public WebCore::LayerFlushScheduler {
 public:
@@ -270,6 +271,10 @@
     id<WebUserMediaClient> m_userMediaClient;
 #endif
 
+#if ENABLE(SERVICE_CONTROLS)
+    std::unique_ptr<WebSelectionServiceController> _selectionServiceController;
+#endif
+
     RefPtr<WebCore::HistoryItem> _globalHistoryItem;
 
     BOOL interactiveFormValidationEnabled;

Modified: branches/safari-600.3-branch/Source/WebKit/mac/WebView/WebViewData.mm (175301 => 175302)


--- branches/safari-600.3-branch/Source/WebKit/mac/WebView/WebViewData.mm	2014-10-29 04:21:21 UTC (rev 175301)
+++ branches/safari-600.3-branch/Source/WebKit/mac/WebView/WebViewData.mm	2014-10-29 04:24:27 UTC (rev 175302)
@@ -31,6 +31,7 @@
 
 #import "WebKitLogging.h"
 #import "WebPreferenceKeysPrivate.h"
+#import "WebSelectionServiceController.h"
 #import "WebViewGroup.h"
 #import <WebCore/AlternativeTextUIController.h>
 #import <WebCore/WebCoreObjCExtras.h>

Modified: branches/safari-600.3-branch/Source/WebKit/mac/WebView/WebViewInternal.h (175301 => 175302)


--- branches/safari-600.3-branch/Source/WebKit/mac/WebView/WebViewInternal.h	2014-10-29 04:21:21 UTC (rev 175301)
+++ branches/safari-600.3-branch/Source/WebKit/mac/WebView/WebViewInternal.h	2014-10-29 04:24:27 UTC (rev 175302)
@@ -56,6 +56,8 @@
 class Node;
 struct DictationAlternative;
 }
+
+class WebSelectionServiceController;
 #endif
 
 @class WebBasePluginPackage;
@@ -119,6 +121,10 @@
 - (Vector<String>)_dictationAlternatives:(uint64_t)dictationContext;
 #endif
 
+#if ENABLE(SERVICE_CONTROLS)
+- (WebSelectionServiceController&)_selectionServiceController;
+#endif
+
 @end
 
 #endif

Modified: branches/safari-600.3-branch/Source/WebKit2/ChangeLog (175301 => 175302)


--- branches/safari-600.3-branch/Source/WebKit2/ChangeLog	2014-10-29 04:21:21 UTC (rev 175301)
+++ branches/safari-600.3-branch/Source/WebKit2/ChangeLog	2014-10-29 04:24:27 UTC (rev 175302)
@@ -1,5 +1,25 @@
 2014-10-28  Dana Burkart  <[email protected]>
 
+        Merge r174791. <rdar://problem/18753175>
+
+    2014-10-16  Tim Horton  <[email protected]>
+    
+            Implement selection services menu for Legacy WebKit
+            https://bugs.webkit.org/show_bug.cgi?id=137582
+            <rdar://problem/18604241>
+    
+            Reviewed by Brady Eidson.
+    
+            * UIProcess/mac/WebContextMenuProxyMac.mm:
+            (-[WKSharingServicePickerDelegate sharingService:didShareItems:]):
+            Add a note that we should transition to using replaceSelectionWithAttributedString.
+    
+            * WebProcess/WebPage/mac/WebPageMac.mm:
+            (WebKit::WebPage::handleSelectionServiceClick):
+            Allow editor services in editable-but-not-rich-text areas, just like in WebKit1.
+    
+2014-10-28  Dana Burkart  <[email protected]>
+
         Merge r174524. <rdar://problem/18640868>
 
     2014-10-09  Tim Horton  <[email protected]>

Modified: branches/safari-600.3-branch/Source/WebKit2/UIProcess/mac/WebContextMenuProxyMac.mm (175301 => 175302)


--- branches/safari-600.3-branch/Source/WebKit2/UIProcess/mac/WebContextMenuProxyMac.mm	2014-10-29 04:21:21 UTC (rev 175301)
+++ branches/safari-600.3-branch/Source/WebKit2/UIProcess/mac/WebContextMenuProxyMac.mm	2014-10-29 04:24:27 UTC (rev 175302)
@@ -265,6 +265,7 @@
         return;
     }
 
+    // FIXME: We should adopt replaceSelectionWithAttributedString instead of bouncing through the (fake) pasteboard.
     _menuProxy->page().replaceSelectionWithPasteboardData(types, dataReference);
 }
 

Modified: branches/safari-600.3-branch/Source/WebKit2/WebProcess/WebPage/mac/WebPageMac.mm (175301 => 175302)


--- branches/safari-600.3-branch/Source/WebKit2/WebProcess/WebPage/mac/WebPageMac.mm	2014-10-29 04:21:21 UTC (rev 175301)
+++ branches/safari-600.3-branch/Source/WebKit2/WebProcess/WebPage/mac/WebPageMac.mm	2014-10-29 04:24:27 UTC (rev 175302)
@@ -1034,7 +1034,7 @@
 
     NSData *selectionData = [attributedSelection RTFDFromRange:NSMakeRange(0, [attributedSelection length]) documentAttributes:nil];
     IPC::DataReference data = "" uint8_t*>([selectionData bytes]), [selectionData length]);
-    bool isEditable = selection.selection().isContentRichlyEditable();
+    bool isEditable = selection.selection().isContentEditable();
 
     send(Messages::WebPageProxy::ShowSelectionServiceMenu(data, phoneNumbers, isEditable, point));
 }
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to