Changeset 209307 in webkit


Ignore:
Timestamp:
Dec 3, 2016 3:49:32 PM (7 years ago)
Author:
mitz@apple.com
Message:

[Cocoa] Expose InjectedBundlePageEditorClient via the Objective-C bundle SPI
https://bugs.webkit.org/show_bug.cgi?id=165276
<rdar://problem/29467040>

Reviewed by Darin Adler.

Source/WebCore:

  • platform/ios/PlatformPasteboardIOS.mm:

(WebCore::PlatformPasteboard::write): Make sure to put the client data on the pasteboard,

like we do on macOS.

Source/WebKit2:

Test: TestWebKitAPI/Tests/WebKit2Cocoa/BundleEditingDelegate.mm

  • Shared/Cocoa/APIObject.mm:

(API::Object::newObject): Wrap InjectedBundleRangeHandle in WKWebProcessPlugInRangeHandle.

  • WebKit2.xcodeproj/project.pbxproj: Added references to new files, making WKWebProcessPlugInEditingDelegate.h and WKWebProcessPlugInRangeHandle.h private headers.
  • WebProcess/InjectedBundle/API/APIInjectedBundleEditorClient.h: Added. An base class based on InjectedBundlePageEditorClient.

(API::InjectedBundle::EditorClient::~EditorClient):
(API::InjectedBundle::EditorClient::shouldBeginEditing):
(API::InjectedBundle::EditorClient::shouldEndEditing):
(API::InjectedBundle::EditorClient::shouldInsertNode):
(API::InjectedBundle::EditorClient::shouldInsertText):
(API::InjectedBundle::EditorClient::shouldDeleteRange):
(API::InjectedBundle::EditorClient::shouldChangeSelectedRange):
(API::InjectedBundle::EditorClient::shouldApplyStyle):
(API::InjectedBundle::EditorClient::didBeginEditing):
(API::InjectedBundle::EditorClient::didEndEditing):
(API::InjectedBundle::EditorClient::didChange):
(API::InjectedBundle::EditorClient::didChangeSelection):
(API::InjectedBundle::EditorClient::willWriteToPasteboard):
(API::InjectedBundle::EditorClient::getPasteboardDataForRange):
(API::InjectedBundle::EditorClient::didWriteToPasteboard):

  • WebProcess/InjectedBundle/API/Cocoa/WKWebProcessPlugInEditingDelegate.h: Added. Declares the new delegate protocol, currently comprising three methods corresponding to willWriteToPasteboard, getPasteboardDataForRange, and didWriteToPasteboard.
  • WebProcess/InjectedBundle/API/Cocoa/WKWebProcessPlugInFrame.h:
  • WebProcess/InjectedBundle/API/Cocoa/WKWebProcessPlugInFrame.mm:

(-[WKWebProcessPlugInFrame jsRangeForRangeHandle:inWorld:]): Added. Gets the JS wrapper for

the specified range handle.

  • WebProcess/InjectedBundle/API/Cocoa/WKWebProcessPlugInRangeHandle.h: Added.
  • WebProcess/InjectedBundle/API/Cocoa/WKWebProcessPlugInRangeHandle.mm: Added.

(-[WKWebProcessPlugInRangeHandle dealloc]): Call the InjectedBundleRangeHandle destructor.
(+[WKWebProcessPlugInRangeHandle rangeHandleWithJSValue:inContext:]): Get or create an

InjectedBundleRangeHandle for the specified object.

(-[WKWebProcessPlugInRangeHandle frame]): Return the range’s owner document’s frame.
(-[WKWebProcessPlugInRangeHandle _rangeHandle]): Return the InjectedBundleRangeHandle.
(-[WKWebProcessPlugInRangeHandle _apiObject]): Ditto.

  • WebProcess/InjectedBundle/API/Cocoa/WKWebProcessPlugInRangeHandleInternal.h: Added.

(WebKit::wrapper):

  • WebProcess/InjectedBundle/API/c/WKBundlePage.cpp:

(WKBundlePageSetEditorClient): Updated for WebPage change.

  • WebProcess/InjectedBundle/API/mac/WKWebProcessPlugInBrowserContextController.mm:

(-[WKWebProcessPlugInBrowserContextController _editingDelegate]): Added. Returns the

delegate.

(-[WKWebProcessPlugInBrowserContextController _setEditingDelegate:]): Added. Defines a

Client class, which derives from API::InjectedBundle::EditorClient, and invokes the
delegate methods. Instantiates a Client and sets it on the WebPage.

  • WebProcess/InjectedBundle/API/mac/WKWebProcessPlugInBrowserContextControllerPrivate.h: Declared new _editingDelegate property.
  • WebProcess/InjectedBundle/DOM/InjectedBundleRangeHandle.cpp:

(WebKit::InjectedBundleRangeHandle::document): Added. Returns an InjectedBundleNodeHandle

for the range’s owner document.

  • WebProcess/InjectedBundle/DOM/InjectedBundleRangeHandle.h:
  • WebProcess/InjectedBundle/InjectedBundlePageEditorClient.cpp:

(WebKit::InjectedBundlePageEditorClient::InjectedBundlePageEditorClient): Added. Calls

initialize().

(WebKit::InjectedBundlePageEditorClient::shouldBeginEditing): Updated for type change.
(WebKit::InjectedBundlePageEditorClient::shouldEndEditing): Ditto.
(WebKit::InjectedBundlePageEditorClient::shouldInsertNode): Ditto.
(WebKit::InjectedBundlePageEditorClient::shouldInsertText): Ditto.
(WebKit::InjectedBundlePageEditorClient::shouldDeleteRange): Ditto.
(WebKit::InjectedBundlePageEditorClient::shouldChangeSelectedRange): Ditto.
(WebKit::InjectedBundlePageEditorClient::shouldApplyStyle): Ditto.
(WebKit::InjectedBundlePageEditorClient::didBeginEditing): Ditto.
(WebKit::InjectedBundlePageEditorClient::didEndEditing): Ditto.
(WebKit::InjectedBundlePageEditorClient::didChange): Ditto.
(WebKit::InjectedBundlePageEditorClient::didChangeSelection): Ditto.
(WebKit::InjectedBundlePageEditorClient::willWriteToPasteboard): Ditto.
(WebKit::InjectedBundlePageEditorClient::getPasteboardDataForRange): Ditto.
(WebKit::InjectedBundlePageEditorClient::didWriteToPasteboard): Ditto.

  • WebProcess/InjectedBundle/InjectedBundlePageEditorClient.h: Now derives from API::InjectedBundle::EditorClient.
  • WebProcess/WebCoreSupport/WebEditorClient.cpp:

(WebKit::WebEditorClient::shouldDeleteRange): Ditto.
(WebKit::WebEditorClient::shouldBeginEditing): Ditto.
(WebKit::WebEditorClient::shouldEndEditing): Ditto.
(WebKit::WebEditorClient::shouldInsertNode): Ditto.
(WebKit::WebEditorClient::shouldInsertText): Ditto.
(WebKit::WebEditorClient::shouldChangeSelectedRange): Ditto.
(WebKit::WebEditorClient::shouldApplyStyle): Ditto.
(WebKit::WebEditorClient::didBeginEditing): Ditto.
(WebKit::WebEditorClient::respondToChangedContents): Ditto.
(WebKit::WebEditorClient::respondToChangedSelection): Ditto.
(WebKit::WebEditorClient::didEndEditing): Ditto.
(WebKit::WebEditorClient::didWriteSelectionToPasteboard): Ditto.
(WebKit::WebEditorClient::willWriteSelectionToPasteboard): Ditto.
(WebKit::WebEditorClient::getClientPasteboardDataForRange): Ditto.

  • WebProcess/WebPage/WebPage.cpp:

(WebKit::WebPage::WebPage): Initialize m_editorClient.
(WebKit::WebPage::setInjectedBundleEditorClient): Replaces

initializeInjectedBundleEditorClient and just sets m_editorClient.

(WebKit::WebPage::close): Resets m_editorClient.

  • WebProcess/WebPage/WebPage.h: Changed m_editorClient to a unique_ptr.

Tools:

  • TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj:
  • TestWebKitAPI/Tests/WebKit2Cocoa/BundleEditingDelegate.mm: Added.

(-[BundleEditingDelegateRemoteObject willWriteToPasteboard:]):
(-[BundleEditingDelegateRemoteObject didWriteToPasteboard]):
(TEST):

  • TestWebKitAPI/Tests/WebKit2Cocoa/BundleEditingDelegatePlugIn.mm: Added.

(-[BundleEditingDelegatePlugIn webProcessPlugIn:didCreateBrowserContextController:]):
(-[BundleEditingDelegatePlugIn _webProcessPlugInBrowserContextController:willWriteRangeToPasteboard:]):
(-[BundleEditingDelegatePlugIn _webProcessPlugInBrowserContextController:pasteboardDataForRange:]):
(-[BundleEditingDelegatePlugIn _webProcessPlugInBrowserContextControllerDidWriteToPasteboard:]):

  • TestWebKitAPI/Tests/WebKit2Cocoa/BundleEditingDelegateProtocol.h: Added.
Location:
trunk
Files:
8 added
19 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r209304 r209307  
     12016-12-03  Dan Bernstein  <mitz@apple.com>
     2
     3        [Cocoa] Expose InjectedBundlePageEditorClient via the Objective-C bundle SPI
     4        https://bugs.webkit.org/show_bug.cgi?id=165276
     5        <rdar://problem/29467040>
     6
     7        Reviewed by Darin Adler.
     8
     9        * platform/ios/PlatformPasteboardIOS.mm:
     10        (WebCore::PlatformPasteboard::write): Make sure to put the client data on the pasteboard,
     11          like we do on macOS.
     12
    1132016-12-03  Dave Hyatt  <hyatt@apple.com>
    214
  • trunk/Source/WebCore/platform/ios/PlatformPasteboardIOS.mm

    r205516 r209307  
    131131    RetainPtr<NSDictionary> representations = adoptNS([[NSMutableDictionary alloc] init]);
    132132
     133    ASSERT(content.clientTypes.size() == content.clientData.size());
     134    for (size_t i = 0, size = content.clientTypes.size(); i < size; ++i)
     135        [representations setValue:content.clientData[i]->createNSData().get() forKey:content.clientTypes[i]];
     136
    133137    if (content.dataInWebArchiveFormat) {
    134138        [representations setValue:(NSData *)content.dataInWebArchiveFormat->createNSData().get() forKey:WebArchivePboardType];
  • trunk/Source/WebKit2/ChangeLog

    r209294 r209307  
     12016-12-03  Dan Bernstein  <mitz@apple.com>
     2
     3        [Cocoa] Expose InjectedBundlePageEditorClient via the Objective-C bundle SPI
     4        https://bugs.webkit.org/show_bug.cgi?id=165276
     5        <rdar://problem/29467040>
     6
     7        Reviewed by Darin Adler.
     8
     9        Test: TestWebKitAPI/Tests/WebKit2Cocoa/BundleEditingDelegate.mm
     10
     11        * Shared/Cocoa/APIObject.mm:
     12        (API::Object::newObject): Wrap InjectedBundleRangeHandle in WKWebProcessPlugInRangeHandle.
     13
     14        * WebKit2.xcodeproj/project.pbxproj: Added references to new files, making
     15          WKWebProcessPlugInEditingDelegate.h and WKWebProcessPlugInRangeHandle.h private headers.
     16
     17        * WebProcess/InjectedBundle/API/APIInjectedBundleEditorClient.h: Added. An base class
     18          based on InjectedBundlePageEditorClient.
     19        (API::InjectedBundle::EditorClient::~EditorClient):
     20        (API::InjectedBundle::EditorClient::shouldBeginEditing):
     21        (API::InjectedBundle::EditorClient::shouldEndEditing):
     22        (API::InjectedBundle::EditorClient::shouldInsertNode):
     23        (API::InjectedBundle::EditorClient::shouldInsertText):
     24        (API::InjectedBundle::EditorClient::shouldDeleteRange):
     25        (API::InjectedBundle::EditorClient::shouldChangeSelectedRange):
     26        (API::InjectedBundle::EditorClient::shouldApplyStyle):
     27        (API::InjectedBundle::EditorClient::didBeginEditing):
     28        (API::InjectedBundle::EditorClient::didEndEditing):
     29        (API::InjectedBundle::EditorClient::didChange):
     30        (API::InjectedBundle::EditorClient::didChangeSelection):
     31        (API::InjectedBundle::EditorClient::willWriteToPasteboard):
     32        (API::InjectedBundle::EditorClient::getPasteboardDataForRange):
     33        (API::InjectedBundle::EditorClient::didWriteToPasteboard):
     34
     35        * WebProcess/InjectedBundle/API/Cocoa/WKWebProcessPlugInEditingDelegate.h: Added. Declares
     36          the new delegate protocol, currently comprising three methods corresponding to
     37          willWriteToPasteboard, getPasteboardDataForRange, and didWriteToPasteboard.
     38
     39        * WebProcess/InjectedBundle/API/Cocoa/WKWebProcessPlugInFrame.h:
     40        * WebProcess/InjectedBundle/API/Cocoa/WKWebProcessPlugInFrame.mm:
     41        (-[WKWebProcessPlugInFrame jsRangeForRangeHandle:inWorld:]): Added. Gets the JS wrapper for
     42          the specified range handle.
     43
     44        * WebProcess/InjectedBundle/API/Cocoa/WKWebProcessPlugInRangeHandle.h: Added.
     45        * WebProcess/InjectedBundle/API/Cocoa/WKWebProcessPlugInRangeHandle.mm: Added.
     46        (-[WKWebProcessPlugInRangeHandle dealloc]): Call the InjectedBundleRangeHandle destructor.
     47        (+[WKWebProcessPlugInRangeHandle rangeHandleWithJSValue:inContext:]): Get or create an
     48          InjectedBundleRangeHandle for the specified object.
     49        (-[WKWebProcessPlugInRangeHandle frame]): Return the range’s owner document’s frame.
     50        (-[WKWebProcessPlugInRangeHandle _rangeHandle]): Return the InjectedBundleRangeHandle.
     51        (-[WKWebProcessPlugInRangeHandle _apiObject]): Ditto.
     52
     53        * WebProcess/InjectedBundle/API/Cocoa/WKWebProcessPlugInRangeHandleInternal.h: Added.
     54        (WebKit::wrapper):
     55
     56        * WebProcess/InjectedBundle/API/c/WKBundlePage.cpp:
     57        (WKBundlePageSetEditorClient): Updated for WebPage change.
     58
     59        * WebProcess/InjectedBundle/API/mac/WKWebProcessPlugInBrowserContextController.mm:
     60        (-[WKWebProcessPlugInBrowserContextController _editingDelegate]): Added. Returns the
     61          delegate.
     62        (-[WKWebProcessPlugInBrowserContextController _setEditingDelegate:]): Added. Defines a
     63          Client class, which derives from API::InjectedBundle::EditorClient, and invokes the
     64          delegate methods. Instantiates a Client and sets it on the WebPage.
     65
     66        * WebProcess/InjectedBundle/API/mac/WKWebProcessPlugInBrowserContextControllerPrivate.h:
     67          Declared new _editingDelegate property.
     68
     69        * WebProcess/InjectedBundle/DOM/InjectedBundleRangeHandle.cpp:
     70        (WebKit::InjectedBundleRangeHandle::document): Added. Returns an InjectedBundleNodeHandle
     71          for the range’s owner document.
     72        * WebProcess/InjectedBundle/DOM/InjectedBundleRangeHandle.h:
     73
     74        * WebProcess/InjectedBundle/InjectedBundlePageEditorClient.cpp:
     75        (WebKit::InjectedBundlePageEditorClient::InjectedBundlePageEditorClient): Added. Calls
     76          initialize().
     77        (WebKit::InjectedBundlePageEditorClient::shouldBeginEditing): Updated for type change.
     78        (WebKit::InjectedBundlePageEditorClient::shouldEndEditing): Ditto.
     79        (WebKit::InjectedBundlePageEditorClient::shouldInsertNode): Ditto.
     80        (WebKit::InjectedBundlePageEditorClient::shouldInsertText): Ditto.
     81        (WebKit::InjectedBundlePageEditorClient::shouldDeleteRange): Ditto.
     82        (WebKit::InjectedBundlePageEditorClient::shouldChangeSelectedRange): Ditto.
     83        (WebKit::InjectedBundlePageEditorClient::shouldApplyStyle): Ditto.
     84        (WebKit::InjectedBundlePageEditorClient::didBeginEditing): Ditto.
     85        (WebKit::InjectedBundlePageEditorClient::didEndEditing): Ditto.
     86        (WebKit::InjectedBundlePageEditorClient::didChange): Ditto.
     87        (WebKit::InjectedBundlePageEditorClient::didChangeSelection): Ditto.
     88        (WebKit::InjectedBundlePageEditorClient::willWriteToPasteboard): Ditto.
     89        (WebKit::InjectedBundlePageEditorClient::getPasteboardDataForRange): Ditto.
     90        (WebKit::InjectedBundlePageEditorClient::didWriteToPasteboard): Ditto.
     91        * WebProcess/InjectedBundle/InjectedBundlePageEditorClient.h: Now derives from
     92          API::InjectedBundle::EditorClient.
     93
     94        * WebProcess/WebCoreSupport/WebEditorClient.cpp:
     95        (WebKit::WebEditorClient::shouldDeleteRange): Ditto.
     96        (WebKit::WebEditorClient::shouldBeginEditing): Ditto.
     97        (WebKit::WebEditorClient::shouldEndEditing): Ditto.
     98        (WebKit::WebEditorClient::shouldInsertNode): Ditto.
     99        (WebKit::WebEditorClient::shouldInsertText): Ditto.
     100        (WebKit::WebEditorClient::shouldChangeSelectedRange): Ditto.
     101        (WebKit::WebEditorClient::shouldApplyStyle): Ditto.
     102        (WebKit::WebEditorClient::didBeginEditing): Ditto.
     103        (WebKit::WebEditorClient::respondToChangedContents): Ditto.
     104        (WebKit::WebEditorClient::respondToChangedSelection): Ditto.
     105        (WebKit::WebEditorClient::didEndEditing): Ditto.
     106        (WebKit::WebEditorClient::didWriteSelectionToPasteboard): Ditto.
     107        (WebKit::WebEditorClient::willWriteSelectionToPasteboard): Ditto.
     108        (WebKit::WebEditorClient::getClientPasteboardDataForRange): Ditto.
     109
     110        * WebProcess/WebPage/WebPage.cpp:
     111        (WebKit::WebPage::WebPage): Initialize m_editorClient.
     112        (WebKit::WebPage::setInjectedBundleEditorClient): Replaces
     113          initializeInjectedBundleEditorClient and just sets m_editorClient.
     114        (WebKit::WebPage::close): Resets m_editorClient.
     115
     116        * WebProcess/WebPage/WebPage.h: Changed m_editorClient to a unique_ptr.
     117
    11182016-12-02  Said Abou-Hallawa  <sabouhallawa@apple.com>
    2119
  • trunk/Source/WebKit2/Shared/Cocoa/APIObject.mm

    r204614 r209307  
    6060#import "WKWebProcessPlugInNodeHandleInternal.h"
    6161#import "WKWebProcessPlugInPageGroupInternal.h"
     62#import "WKWebProcessPlugInRangeHandleInternal.h"
    6263#import "WKWebProcessPlugInScriptWorldInternal.h"
    6364#import "WKWebsiteDataRecordInternal.h"
     
    285286        break;
    286287
     288    case Type::BundleRangeHandle:
     289        wrapper = [WKWebProcessPlugInRangeHandle alloc];
     290        break;
     291
    287292    case Type::BundleScriptWorld:
    288293        wrapper = [WKWebProcessPlugInScriptWorld alloc];
  • trunk/Source/WebKit2/WebKit2.xcodeproj/project.pbxproj

    r209102 r209307  
    788788                3743925818BC4C60001C8675 /* WKUIDelegatePrivate.h in Headers */ = {isa = PBXBuildFile; fileRef = 3743925718BC4C60001C8675 /* WKUIDelegatePrivate.h */; settings = {ATTRIBUTES = (Private, ); }; };
    789789                374436881820E7240049579F /* WKObject.mm in Sources */ = {isa = PBXBuildFile; fileRef = 374436871820E7240049579F /* WKObject.mm */; };
     790                3749421A1DF1F9FF0033C19F /* WKWebProcessPlugInRangeHandle.mm in Sources */ = {isa = PBXBuildFile; fileRef = 374942181DF1F9FF0033C19F /* WKWebProcessPlugInRangeHandle.mm */; };
     791                3749421B1DF1F9FF0033C19F /* WKWebProcessPlugInRangeHandle.h in Headers */ = {isa = PBXBuildFile; fileRef = 374942191DF1F9FF0033C19F /* WKWebProcessPlugInRangeHandle.h */; settings = {ATTRIBUTES = (Private, ); }; };
     792                3749421D1DF1FAB90033C19F /* WKWebProcessPlugInRangeHandleInternal.h in Headers */ = {isa = PBXBuildFile; fileRef = 3749421C1DF1FAB90033C19F /* WKWebProcessPlugInRangeHandleInternal.h */; };
    790793                3754D5451B3A29FD003A4C7F /* NSInvocationSPI.h in Headers */ = {isa = PBXBuildFile; fileRef = 3754D5441B3A29FD003A4C7F /* NSInvocationSPI.h */; };
    791794                375E0E131D66432700EFEC2C /* WKNSNumber.mm in Sources */ = {isa = PBXBuildFile; fileRef = 375E0E111D66432700EFEC2C /* WKNSNumber.mm */; };
     
    805808                37716A5A195B910500EE8B1B /* ProcessAssertion.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 37716A59195B910500EE8B1B /* ProcessAssertion.cpp */; };
    806809                377216B81A4E6BE000DCA718 /* _WKRenderingProgressEvents.h in Headers */ = {isa = PBXBuildFile; fileRef = 377216B71A4E6BE000DCA718 /* _WKRenderingProgressEvents.h */; settings = {ATTRIBUTES = (Private, ); }; };
     810                3775122F1DF0DC8B008A351C /* WKWebProcessPlugInEditingDelegate.h in Headers */ = {isa = PBXBuildFile; fileRef = 3775122E1DF0DC8B008A351C /* WKWebProcessPlugInEditingDelegate.h */; settings = {ATTRIBUTES = (Private, ); }; };
     811                377512311DF0DEE2008A351C /* APIInjectedBundleEditorClient.h in Headers */ = {isa = PBXBuildFile; fileRef = 377512301DF0DEE2008A351C /* APIInjectedBundleEditorClient.h */; };
    807812                377EAD4517E2C51A002D193D /* WKDeclarationSpecifiers.h in Headers */ = {isa = PBXBuildFile; fileRef = 377EAD4417E2C51A002D193D /* WKDeclarationSpecifiers.h */; settings = {ATTRIBUTES = (Private, ); }; };
    808813                377EAD4817E2C77B002D193D /* WKUserContentInjectedFrames.h in Headers */ = {isa = PBXBuildFile; fileRef = 377EAD4617E2C77B002D193D /* WKUserContentInjectedFrames.h */; settings = {ATTRIBUTES = (Private, ); }; };
     
    28622867                3743925718BC4C60001C8675 /* WKUIDelegatePrivate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WKUIDelegatePrivate.h; sourceTree = "<group>"; };
    28632868                374436871820E7240049579F /* WKObject.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = WKObject.mm; sourceTree = "<group>"; };
     2869                374942181DF1F9FF0033C19F /* WKWebProcessPlugInRangeHandle.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = WKWebProcessPlugInRangeHandle.mm; sourceTree = "<group>"; };
     2870                374942191DF1F9FF0033C19F /* WKWebProcessPlugInRangeHandle.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WKWebProcessPlugInRangeHandle.h; sourceTree = "<group>"; };
     2871                3749421C1DF1FAB90033C19F /* WKWebProcessPlugInRangeHandleInternal.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WKWebProcessPlugInRangeHandleInternal.h; sourceTree = "<group>"; };
    28642872                3754D5441B3A29FD003A4C7F /* NSInvocationSPI.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = NSInvocationSPI.h; sourceTree = "<group>"; };
    28652873                375E0E111D66432700EFEC2C /* WKNSNumber.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = WKNSNumber.mm; sourceTree = "<group>"; };
     
    28762884                37716A59195B910500EE8B1B /* ProcessAssertion.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ProcessAssertion.cpp; sourceTree = "<group>"; };
    28772885                377216B71A4E6BE000DCA718 /* _WKRenderingProgressEvents.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = _WKRenderingProgressEvents.h; sourceTree = "<group>"; };
     2886                3775122E1DF0DC8B008A351C /* WKWebProcessPlugInEditingDelegate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WKWebProcessPlugInEditingDelegate.h; sourceTree = "<group>"; };
     2887                377512301DF0DEE2008A351C /* APIInjectedBundleEditorClient.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = APIInjectedBundleEditorClient.h; sourceTree = "<group>"; };
    28782888                377EAD4417E2C51A002D193D /* WKDeclarationSpecifiers.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WKDeclarationSpecifiers.h; sourceTree = "<group>"; };
    28792889                377EAD4617E2C77B002D193D /* WKUserContentInjectedFrames.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WKUserContentInjectedFrames.h; sourceTree = "<group>"; };
     
    49564966                                1AA2E56518D77508003814BD /* WKWebProcessBundleParameters.h */,
    49574967                                1AA2E56418D77508003814BD /* WKWebProcessBundleParameters.mm */,
     4968                                3775122E1DF0DC8B008A351C /* WKWebProcessPlugInEditingDelegate.h */,
    49584969                                3795789B18AD4F1100B9ED2E /* WKWebProcessPlugInFormDelegatePrivate.h */,
    49594970                                1F0181691858DC1500F92884 /* WKWebProcessPlugInFrame.h */,
     
    49714982                                1FB00AC5185F76460019142E /* WKWebProcessPlugInPageGroup.mm */,
    49724983                                1FB00AC6185F76460019142E /* WKWebProcessPlugInPageGroupInternal.h */,
     4984                                374942191DF1F9FF0033C19F /* WKWebProcessPlugInRangeHandle.h */,
     4985                                374942181DF1F9FF0033C19F /* WKWebProcessPlugInRangeHandle.mm */,
     4986                                3749421C1DF1FAB90033C19F /* WKWebProcessPlugInRangeHandleInternal.h */,
    49734987                                1F0181721858DC1600F92884 /* WKWebProcessPlugInScriptWorld.h */,
    49744988                                1F0181731858DC1600F92884 /* WKWebProcessPlugInScriptWorld.mm */,
     
    66616675                                1F0181681858DC1500F92884 /* Cocoa */,
    66626676                                BC989D4516181691000D46D3 /* mac */,
     6677                                377512301DF0DEE2008A351C /* APIInjectedBundleEditorClient.h */,
    66636678                                076E884F1A13CBC6005E90FC /* APIInjectedBundlePageContextMenuClient.h */,
    66646679                        );
     
    77907805                                832AE2521BE2E8CD00FAAE10 /* NetworkCacheSpeculativeLoadManager.h in Headers */,
    77917806                                834B25121A842C8700CFB150 /* NetworkCacheStatistics.h in Headers */,
     7807                                377512311DF0DEE2008A351C /* APIInjectedBundleEditorClient.h in Headers */,
    77927808                                E4436ECF1A0D040B00EAD204 /* NetworkCacheStorage.h in Headers */,
    77937809                                8310428B1BD6B66F00A715E4 /* NetworkCacheSubresourcesEntry.h in Headers */,
     
    80178033                                BC1BE1E012D54A410004A228 /* WebGeolocationClient.h in Headers */,
    80188034                                BC0E5FE512D697160012A72A /* WebGeolocationManager.h in Headers */,
     8035                                3749421B1DF1F9FF0033C19F /* WKWebProcessPlugInRangeHandle.h in Headers */,
    80198036                                BC0E606212D6BA910012A72A /* WebGeolocationManagerMessages.h in Headers */,
    80208037                                BC54CACB12D64291005C67B0 /* WebGeolocationManagerProxy.h in Headers */,
     
    80668083                                BC032D8F10F437A00058C15A /* WebPage.h in Headers */,
    80678084                                8372DB291A67562800C697C5 /* WebPageDiagnosticLoggingClient.h in Headers */,
     8085                                3775122F1DF0DC8B008A351C /* WKWebProcessPlugInEditingDelegate.h in Headers */,
    80688086                                BC7B6206129A0A6700D174A4 /* WebPageGroup.h in Headers */,
    80698087                                BC7B625212A43C9600D174A4 /* WebPageGroupData.h in Headers */,
     
    81268144                                51032F19180F73BB00961BB7 /* WebToDatabaseProcessConnection.h in Headers */,
    81278145                                BCA0EF7F12331E78007D3CFB /* WebUndoStep.h in Headers */,
     8146                                3749421D1DF1FAB90033C19F /* WKWebProcessPlugInRangeHandleInternal.h in Headers */,
    81288147                                1AAF08AE1926936700B6390C /* WebUserContentController.h in Headers */,
    81298148                                7C065F2C1C8CD95F00C2D950 /* WebUserContentControllerDataTypes.h in Headers */,
     
    97719790                                0FCB4E5118BBE044000FCFC9 /* WKGeolocationProviderIOSObjCSecurityOrigin.mm in Sources */,
    97729791                                0F174AA7142AAC610039250F /* WKGeometry.cpp in Sources */,
     9792                                3749421A1DF1F9FF0033C19F /* WKWebProcessPlugInRangeHandle.mm in Sources */,
    97739793                                B62E7310143047A60069EC35 /* WKHitTestResult.cpp in Sources */,
    97749794                                83EE575B1DB7D61100C74C50 /* WebValidationMessageClient.cpp in Sources */,
  • trunk/Source/WebKit2/WebProcess/InjectedBundle/API/Cocoa/WKWebProcessPlugInFrame.h

    r205559 r209307  
    3535@class WKWebProcessPlugInHitTestResult;
    3636@class WKWebProcessPlugInNodeHandle;
     37@class WKWebProcessPlugInRangeHandle;
    3738@class WKWebProcessPlugInScriptWorld;
    3839
     
    5455- (WKWebProcessPlugInHitTestResult *)hitTest:(CGPoint)point;
    5556- (JSValue *)jsNodeForNodeHandle:(WKWebProcessPlugInNodeHandle *)nodeHandle inWorld:(WKWebProcessPlugInScriptWorld *)world;
     57- (JSValue *)jsRangeForRangeHandle:(WKWebProcessPlugInRangeHandle *)rangeHandle inWorld:(WKWebProcessPlugInScriptWorld *)world WK_API_AVAILABLE(macosx(WK_MAC_TBA), ios(WK_IOS_TBA));
    5658
    5759@end
  • trunk/Source/WebKit2/WebProcess/InjectedBundle/API/Cocoa/WKWebProcessPlugInFrame.mm

    r202242 r209307  
    3434#import "WKWebProcessPlugInHitTestResultInternal.h"
    3535#import "WKWebProcessPlugInNodeHandleInternal.h"
     36#import "WKWebProcessPlugInRangeHandleInternal.h"
    3637#import "WKWebProcessPlugInScriptWorldInternal.h"
    3738#import "WebProcess.h"
     
    7980{
    8081    JSValueRef valueRef = _frame->jsWrapperForWorld(&[nodeHandle _nodeHandle], &[world _scriptWorld]);
     82    return [JSValue valueWithJSValueRef:valueRef inContext:[self jsContextForWorld:world]];
     83}
     84
     85- (JSValue *)jsRangeForRangeHandle:(WKWebProcessPlugInRangeHandle *)rangeHandle inWorld:(WKWebProcessPlugInScriptWorld *)world
     86{
     87    JSValueRef valueRef = _frame->jsWrapperForWorld(&[rangeHandle _rangeHandle], &[world _scriptWorld]);
    8188    return [JSValue valueWithJSValueRef:valueRef inContext:[self jsContextForWorld:world]];
    8289}
  • trunk/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundlePage.cpp

    r208985 r209307  
    3434#include "InjectedBundleBackForwardList.h"
    3535#include "InjectedBundleNodeHandle.h"
     36#include "InjectedBundlePageEditorClient.h"
    3637#include "InjectedBundlePageFormClient.h"
    3738#include "InjectedBundlePageUIClient.h"
     
    8485void WKBundlePageSetEditorClient(WKBundlePageRef pageRef, WKBundlePageEditorClientBase* wkClient)
    8586{
    86     toImpl(pageRef)->initializeInjectedBundleEditorClient(wkClient);
     87    toImpl(pageRef)->setInjectedBundleEditorClient(wkClient ? std::make_unique<InjectedBundlePageEditorClient>(*wkClient) : std::make_unique<API::InjectedBundle::EditorClient>());
    8788}
    8889
  • trunk/Source/WebKit2/WebProcess/InjectedBundle/API/mac/WKWebProcessPlugInBrowserContextController.mm

    r208431 r209307  
    4545#import "WKStringCF.h"
    4646#import "WKURLRequestNS.h"
     47#import "WKWebProcessPlugInEditingDelegate.h"
    4748#import "WKWebProcessPlugInFrameInternal.h"
    4849#import "WKWebProcessPlugInInternal.h"
     
    5152#import "WKWebProcessPlugInNodeHandleInternal.h"
    5253#import "WKWebProcessPlugInPageGroupInternal.h"
     54#import "WKWebProcessPlugInRangeHandleInternal.h"
    5355#import "WKWebProcessPlugInScriptWorldInternal.h"
    5456#import "WeakObjCPtr.h"
     
    7577    WeakObjCPtr<id <WKWebProcessPlugInLoadDelegate>> _loadDelegate;
    7678    WeakObjCPtr<id <WKWebProcessPlugInFormDelegatePrivate>> _formDelegate;
     79    WeakObjCPtr<id <WKWebProcessPlugInEditingDelegate>> _editingDelegate;
    7780   
    7881    RetainPtr<_WKRemoteObjectRegistry> _remoteObjectRegistry;
     
    566569}
    567570
     571- (id <WKWebProcessPlugInEditingDelegate>)_editingDelegate
     572{
     573    return _editingDelegate.getAutoreleased();
     574}
     575
     576- (void)_setEditingDelegate:(id <WKWebProcessPlugInEditingDelegate>)editingDelegate
     577{
     578    _editingDelegate = editingDelegate;
     579
     580    class Client final : public API::InjectedBundle::EditorClient {
     581    public:
     582        explicit Client(WKWebProcessPlugInBrowserContextController *controller)
     583            : m_controller { controller }
     584            , m_delegateMethods { m_controller->_editingDelegate.get() }
     585        {
     586        }
     587
     588    private:
     589        void willWriteToPasteboard(WebKit::WebPage&, WebCore::Range* range) final
     590        {
     591            if (!m_delegateMethods.willWriteToPasteboard)
     592                return;
     593
     594            [m_controller->_editingDelegate.get() _webProcessPlugInBrowserContextController:m_controller willWriteRangeToPasteboard:wrapper(*InjectedBundleRangeHandle::getOrCreate(range).get())];
     595        }
     596
     597        void getPasteboardDataForRange(WebKit::WebPage&, WebCore::Range* range, Vector<String>& pasteboardTypes, Vector<RefPtr<WebCore::SharedBuffer>>& pasteboardData) final
     598        {
     599            if (!m_delegateMethods.getPasteboardDataForRange)
     600                return;
     601
     602            auto dataByType = [m_controller->_editingDelegate.get() _webProcessPlugInBrowserContextController:m_controller pasteboardDataForRange:wrapper(*InjectedBundleRangeHandle::getOrCreate(range).get())];
     603            for (NSString *type in dataByType) {
     604                pasteboardTypes.append(type);
     605                pasteboardData.append(SharedBuffer::wrapNSData(dataByType[type]));
     606            };
     607        }
     608
     609        void didWriteToPasteboard(WebKit::WebPage&) final
     610        {
     611            if (!m_delegateMethods.didWriteToPasteboard)
     612                return;
     613
     614            [m_controller->_editingDelegate.get() _webProcessPlugInBrowserContextControllerDidWriteToPasteboard:m_controller];
     615        }
     616
     617        WKWebProcessPlugInBrowserContextController *m_controller;
     618        const struct DelegateMethods {
     619            DelegateMethods(RetainPtr<id <WKWebProcessPlugInEditingDelegate>> delegate)
     620                : willWriteToPasteboard([delegate respondsToSelector:@selector(_webProcessPlugInBrowserContextController:willWriteRangeToPasteboard:)])
     621                , getPasteboardDataForRange([delegate respondsToSelector:@selector(_webProcessPlugInBrowserContextController:pasteboardDataForRange:)])
     622                , didWriteToPasteboard([delegate respondsToSelector:@selector(_webProcessPlugInBrowserContextControllerDidWriteToPasteboard:)])
     623            {
     624            }
     625
     626            bool willWriteToPasteboard;
     627            bool getPasteboardDataForRange;
     628            bool didWriteToPasteboard;
     629        } m_delegateMethods;
     630    };
     631
     632    if (editingDelegate)
     633        _page->setInjectedBundleEditorClient(std::make_unique<Client>(self));
     634    else
     635        _page->setInjectedBundleEditorClient(nullptr);
     636}
     637
    568638- (BOOL)_defersLoading
    569639{
  • trunk/Source/WebKit2/WebProcess/InjectedBundle/API/mac/WKWebProcessPlugInBrowserContextControllerPrivate.h

    r168646 r209307  
    3232@class WKBrowsingContextHandle;
    3333@class _WKRemoteObjectRegistry;
     34@protocol WKWebProcessPlugInEditingDelegate;
    3435@protocol WKWebProcessPlugInFormDelegatePrivate;
    3536
     
    4344
    4445@property (weak, setter=_setFormDelegate:) id <WKWebProcessPlugInFormDelegatePrivate> _formDelegate;
     46@property (weak, setter=_setEditingDelegate:) id <WKWebProcessPlugInEditingDelegate> _editingDelegate WK_API_AVAILABLE(macosx(WK_MAC_TBA), ios(WK_IOS_TBA));
    4547
    4648@property (nonatomic, setter=_setDefersLoading:) BOOL _defersLoading;
  • trunk/Source/WebKit2/WebProcess/InjectedBundle/DOM/InjectedBundleRangeHandle.cpp

    r208371 r209307  
    2727#include "InjectedBundleRangeHandle.h"
    2828
     29#include "InjectedBundleNodeHandle.h"
    2930#include "ShareableBitmap.h"
    3031#include "WebImage.h"
     
    9798}
    9899
     100Ref<InjectedBundleNodeHandle> InjectedBundleRangeHandle::document()
     101{
     102    return InjectedBundleNodeHandle::getOrCreate(m_range->ownerDocument());
     103}
     104
    99105WebCore::IntRect InjectedBundleRangeHandle::boundingRectInWindowCoordinates() const
    100106{
  • trunk/Source/WebKit2/WebProcess/InjectedBundle/DOM/InjectedBundleRangeHandle.h

    r185637 r209307  
    4040namespace WebKit {
    4141
     42class InjectedBundleNodeHandle;
    4243class InjectedBundleScriptWorld;
    4344class WebImage;
     
    4950
    5051    virtual ~InjectedBundleRangeHandle();
     52
     53    Ref<InjectedBundleNodeHandle> document();
    5154
    5255    WebCore::IntRect boundingRectInWindowCoordinates() const;
  • trunk/Source/WebKit2/WebProcess/InjectedBundle/InjectedBundlePageEditorClient.cpp

    r177671 r209307  
    4242namespace WebKit {
    4343
    44 bool InjectedBundlePageEditorClient::shouldBeginEditing(WebPage* page, Range* range)
     44InjectedBundlePageEditorClient::InjectedBundlePageEditorClient(const WKBundlePageEditorClientBase& client)
     45{
     46    initialize(&client);
     47}
     48
     49bool InjectedBundlePageEditorClient::shouldBeginEditing(WebPage& page, Range* range)
    4550{
    4651    if (m_client.shouldBeginEditing) {
    4752        RefPtr<InjectedBundleRangeHandle> rangeHandle = InjectedBundleRangeHandle::getOrCreate(range);
    48         return m_client.shouldBeginEditing(toAPI(page), toAPI(rangeHandle.get()), m_client.base.clientInfo);
     53        return m_client.shouldBeginEditing(toAPI(&page), toAPI(rangeHandle.get()), m_client.base.clientInfo);
    4954    }
    5055    return true;
    5156}
    5257
    53 bool InjectedBundlePageEditorClient::shouldEndEditing(WebPage* page, Range* range)
     58bool InjectedBundlePageEditorClient::shouldEndEditing(WebPage& page, Range* range)
    5459{
    5560    if (m_client.shouldEndEditing) {
    5661        RefPtr<InjectedBundleRangeHandle> rangeHandle = InjectedBundleRangeHandle::getOrCreate(range);
    57         return m_client.shouldEndEditing(toAPI(page), toAPI(rangeHandle.get()), m_client.base.clientInfo);
     62        return m_client.shouldEndEditing(toAPI(&page), toAPI(rangeHandle.get()), m_client.base.clientInfo);
    5863    }
    5964    return true;
    6065}
    6166
    62 bool InjectedBundlePageEditorClient::shouldInsertNode(WebPage* page, Node* node, Range* rangeToReplace, EditorInsertAction action)
     67bool InjectedBundlePageEditorClient::shouldInsertNode(WebPage& page, Node* node, Range* rangeToReplace, EditorInsertAction action)
    6368{
    6469    if (m_client.shouldInsertNode) {
    6570        RefPtr<InjectedBundleNodeHandle> nodeHandle = InjectedBundleNodeHandle::getOrCreate(node);
    6671        RefPtr<InjectedBundleRangeHandle> rangeToReplaceHandle = InjectedBundleRangeHandle::getOrCreate(rangeToReplace);
    67         return m_client.shouldInsertNode(toAPI(page), toAPI(nodeHandle.get()), toAPI(rangeToReplaceHandle.get()), toAPI(action), m_client.base.clientInfo);
     72        return m_client.shouldInsertNode(toAPI(&page), toAPI(nodeHandle.get()), toAPI(rangeToReplaceHandle.get()), toAPI(action), m_client.base.clientInfo);
    6873    }
    6974    return true;
    7075}
    7176
    72 bool InjectedBundlePageEditorClient::shouldInsertText(WebPage* page, StringImpl* text, Range* rangeToReplace, EditorInsertAction action)
     77bool InjectedBundlePageEditorClient::shouldInsertText(WebPage& page, StringImpl* text, Range* rangeToReplace, EditorInsertAction action)
    7378{
    7479    if (m_client.shouldInsertText) {
    7580        RefPtr<InjectedBundleRangeHandle> rangeToReplaceHandle = InjectedBundleRangeHandle::getOrCreate(rangeToReplace);
    76         return m_client.shouldInsertText(toAPI(page), toAPI(text), toAPI(rangeToReplaceHandle.get()), toAPI(action), m_client.base.clientInfo);
     81        return m_client.shouldInsertText(toAPI(&page), toAPI(text), toAPI(rangeToReplaceHandle.get()), toAPI(action), m_client.base.clientInfo);
    7782    }
    7883    return true;
    7984}
    8085
    81 bool InjectedBundlePageEditorClient::shouldDeleteRange(WebPage* page, Range* range)
     86bool InjectedBundlePageEditorClient::shouldDeleteRange(WebPage& page, Range* range)
    8287{
    8388    if (m_client.shouldDeleteRange) {
    8489        RefPtr<InjectedBundleRangeHandle> rangeHandle = InjectedBundleRangeHandle::getOrCreate(range);
    85         return m_client.shouldDeleteRange(toAPI(page), toAPI(rangeHandle.get()), m_client.base.clientInfo);
     90        return m_client.shouldDeleteRange(toAPI(&page), toAPI(rangeHandle.get()), m_client.base.clientInfo);
    8691    }
    8792    return true;
    8893}
    8994
    90 bool InjectedBundlePageEditorClient::shouldChangeSelectedRange(WebPage* page, Range* fromRange, Range* toRange, EAffinity affinity, bool stillSelecting)
     95bool InjectedBundlePageEditorClient::shouldChangeSelectedRange(WebPage& page, Range* fromRange, Range* toRange, EAffinity affinity, bool stillSelecting)
    9196{
    9297    if (m_client.shouldChangeSelectedRange) {
    9398        RefPtr<InjectedBundleRangeHandle> fromRangeHandle = InjectedBundleRangeHandle::getOrCreate(fromRange);
    9499        RefPtr<InjectedBundleRangeHandle> toRangeHandle = InjectedBundleRangeHandle::getOrCreate(toRange);
    95         return m_client.shouldChangeSelectedRange(toAPI(page), toAPI(fromRangeHandle.get()), toAPI(toRangeHandle.get()), toAPI(affinity), stillSelecting, m_client.base.clientInfo);
     100        return m_client.shouldChangeSelectedRange(toAPI(&page), toAPI(fromRangeHandle.get()), toAPI(toRangeHandle.get()), toAPI(affinity), stillSelecting, m_client.base.clientInfo);
    96101    }
    97102    return true;
    98103}
    99104
    100 bool InjectedBundlePageEditorClient::shouldApplyStyle(WebPage* page, CSSStyleDeclaration* style, Range* range)
     105bool InjectedBundlePageEditorClient::shouldApplyStyle(WebPage& page, CSSStyleDeclaration* style, Range* range)
    101106{
    102107    if (m_client.shouldApplyStyle) {
    103108        RefPtr<InjectedBundleCSSStyleDeclarationHandle> styleHandle = InjectedBundleCSSStyleDeclarationHandle::getOrCreate(style);
    104109        RefPtr<InjectedBundleRangeHandle> rangeHandle = InjectedBundleRangeHandle::getOrCreate(range);
    105         return m_client.shouldApplyStyle(toAPI(page), toAPI(styleHandle.get()), toAPI(rangeHandle.get()), m_client.base.clientInfo);
     110        return m_client.shouldApplyStyle(toAPI(&page), toAPI(styleHandle.get()), toAPI(rangeHandle.get()), m_client.base.clientInfo);
    106111    }
    107112    return true;
    108113}
    109114
    110 void InjectedBundlePageEditorClient::didBeginEditing(WebPage* page, StringImpl* notificationName)
     115void InjectedBundlePageEditorClient::didBeginEditing(WebPage& page, StringImpl* notificationName)
    111116{
    112117    if (m_client.didBeginEditing)
    113         m_client.didBeginEditing(toAPI(page), toAPI(notificationName), m_client.base.clientInfo);
     118        m_client.didBeginEditing(toAPI(&page), toAPI(notificationName), m_client.base.clientInfo);
    114119}
    115120
    116 void InjectedBundlePageEditorClient::didEndEditing(WebPage* page, StringImpl* notificationName)
     121void InjectedBundlePageEditorClient::didEndEditing(WebPage& page, StringImpl* notificationName)
    117122{
    118123    if (m_client.didEndEditing)
    119         m_client.didEndEditing(toAPI(page), toAPI(notificationName), m_client.base.clientInfo);
     124        m_client.didEndEditing(toAPI(&page), toAPI(notificationName), m_client.base.clientInfo);
    120125}
    121126
    122 void InjectedBundlePageEditorClient::didChange(WebPage* page, StringImpl* notificationName)
     127void InjectedBundlePageEditorClient::didChange(WebPage& page, StringImpl* notificationName)
    123128{
    124129    if (m_client.didChange)
    125         m_client.didChange(toAPI(page), toAPI(notificationName), m_client.base.clientInfo);
     130        m_client.didChange(toAPI(&page), toAPI(notificationName), m_client.base.clientInfo);
    126131}
    127132
    128 void InjectedBundlePageEditorClient::didChangeSelection(WebPage* page, StringImpl* notificationName)
     133void InjectedBundlePageEditorClient::didChangeSelection(WebPage& page, StringImpl* notificationName)
    129134{
    130135    if (m_client.didChangeSelection)
    131         m_client.didChangeSelection(toAPI(page), toAPI(notificationName), m_client.base.clientInfo);
     136        m_client.didChangeSelection(toAPI(&page), toAPI(notificationName), m_client.base.clientInfo);
    132137}
    133138
    134 void InjectedBundlePageEditorClient::willWriteToPasteboard(WebPage* page, Range* range)
     139void InjectedBundlePageEditorClient::willWriteToPasteboard(WebPage& page, Range* range)
    135140{
    136141    if (m_client.willWriteToPasteboard) {
    137142        RefPtr<InjectedBundleRangeHandle> rangeHandle = InjectedBundleRangeHandle::getOrCreate(range);
    138         m_client.willWriteToPasteboard(toAPI(page), toAPI(rangeHandle.get()), m_client.base.clientInfo);
     143        m_client.willWriteToPasteboard(toAPI(&page), toAPI(rangeHandle.get()), m_client.base.clientInfo);
    139144    }
    140145}
    141146
    142 void InjectedBundlePageEditorClient::getPasteboardDataForRange(WebPage* page, Range* range, Vector<String>& pasteboardTypes, Vector<RefPtr<SharedBuffer>>& pasteboardData)
     147void InjectedBundlePageEditorClient::getPasteboardDataForRange(WebPage& page, Range* range, Vector<String>& pasteboardTypes, Vector<RefPtr<SharedBuffer>>& pasteboardData)
    143148{
    144149    if (m_client.getPasteboardDataForRange) {
     
    146151        WKArrayRef types = 0;
    147152        WKArrayRef data = 0;
    148         m_client.getPasteboardDataForRange(toAPI(page), toAPI(rangeHandle.get()), &types, &data, m_client.base.clientInfo);
     153        m_client.getPasteboardDataForRange(toAPI(&page), toAPI(rangeHandle.get()), &types, &data, m_client.base.clientInfo);
    149154        RefPtr<API::Array> typesArray = adoptRef(toImpl(types));
    150155        RefPtr<API::Array> dataArray = adoptRef(toImpl(data));
     
    168173}
    169174
    170 void InjectedBundlePageEditorClient::didWriteToPasteboard(WebPage* page)
     175void InjectedBundlePageEditorClient::didWriteToPasteboard(WebPage& page)
    171176{
    172177    if (m_client.didWriteToPasteboard)
    173         m_client.didWriteToPasteboard(toAPI(page), m_client.base.clientInfo);
     178        m_client.didWriteToPasteboard(toAPI(&page), m_client.base.clientInfo);
    174179}
    175180
  • trunk/Source/WebKit2/WebProcess/InjectedBundle/InjectedBundlePageEditorClient.h

    r171743 r209307  
    11/*
    2  * Copyright (C) 2010 Apple Inc. All rights reserved.
     2 * Copyright (C) 2010, 2016 Apple Inc. All rights reserved.
    33 *
    44 * Redistribution and use in source and binary forms, with or without
     
    2424 */
    2525
    26 #ifndef InjectedBundlePageEditorClient_h
    27 #define InjectedBundlePageEditorClient_h
     26#pragma once
    2827
    2928#include "APIClient.h"
    30 #include "WKBundlePage.h"
    31 #include <WebCore/EditorInsertAction.h>
    32 #include <WebCore/SharedBuffer.h>
    33 #include <WebCore/TextAffinity.h>
    34 #include <wtf/Forward.h>
     29#include "APIInjectedBundleEditorClient.h"
     30#include "WKBundlePageEditorClient.h"
    3531
    3632namespace API {
     
    5147class WebPage;
    5248
    53 class InjectedBundlePageEditorClient : public API::Client<WKBundlePageEditorClientBase> {
     49class InjectedBundlePageEditorClient final : public API::Client<WKBundlePageEditorClientBase>, public API::InjectedBundle::EditorClient {
    5450public:
    55     bool shouldBeginEditing(WebPage*, WebCore::Range*);
    56     bool shouldEndEditing(WebPage*, WebCore::Range*);
    57     bool shouldInsertNode(WebPage*, WebCore::Node*, WebCore::Range* rangeToReplace, WebCore::EditorInsertAction);
    58     bool shouldInsertText(WebPage*, StringImpl*, WebCore::Range* rangeToReplace, WebCore::EditorInsertAction);
    59     bool shouldDeleteRange(WebPage*, WebCore::Range*);
    60     bool shouldChangeSelectedRange(WebPage*, WebCore::Range* fromRange, WebCore::Range* toRange, WebCore::EAffinity affinity, bool stillSelecting);
    61     bool shouldApplyStyle(WebPage*, WebCore::CSSStyleDeclaration*, WebCore::Range*);
    62     void didBeginEditing(WebPage*, StringImpl* notificationName);
    63     void didEndEditing(WebPage*, StringImpl* notificationName);
    64     void didChange(WebPage*, StringImpl* notificationName);
    65     void didChangeSelection(WebPage*, StringImpl* notificationName);
    66     void willWriteToPasteboard(WebPage*, WebCore::Range*);
    67     void getPasteboardDataForRange(WebPage*, WebCore::Range*, Vector<String>& pasteboardTypes, Vector<RefPtr<WebCore::SharedBuffer>>& pasteboardData);
    68     void didWriteToPasteboard(WebPage*);
     51    explicit InjectedBundlePageEditorClient(const WKBundlePageEditorClientBase&);
     52
     53private:
     54    bool shouldBeginEditing(WebPage&, WebCore::Range*) final;
     55    bool shouldEndEditing(WebPage&, WebCore::Range*) final;
     56    bool shouldInsertNode(WebPage&, WebCore::Node*, WebCore::Range* rangeToReplace, WebCore::EditorInsertAction) final;
     57    bool shouldInsertText(WebPage&, StringImpl*, WebCore::Range* rangeToReplace, WebCore::EditorInsertAction) final;
     58    bool shouldDeleteRange(WebPage&, WebCore::Range*) final;
     59    bool shouldChangeSelectedRange(WebPage&, WebCore::Range* fromRange, WebCore::Range* toRange, WebCore::EAffinity, bool stillSelecting) final;
     60    bool shouldApplyStyle(WebPage&, WebCore::CSSStyleDeclaration*, WebCore::Range*) final;
     61    void didBeginEditing(WebPage&, StringImpl* notificationName) final;
     62    void didEndEditing(WebPage&, StringImpl* notificationName) final;
     63    void didChange(WebPage&, StringImpl* notificationName) final;
     64    void didChangeSelection(WebPage&, StringImpl* notificationName) final;
     65    void willWriteToPasteboard(WebPage&, WebCore::Range*) final;
     66    void getPasteboardDataForRange(WebPage&, WebCore::Range*, Vector<String>& pasteboardTypes, Vector<RefPtr<WebCore::SharedBuffer>>& pasteboardData) final;
     67    void didWriteToPasteboard(WebPage&) final;
    6968};
    7069
    7170} // namespace WebKit
    72 
    73 #endif // InjectedBundlePageEditorClient_h
  • trunk/Source/WebKit2/WebProcess/WebCoreSupport/WebEditorClient.cpp

    r208406 r209307  
    7373bool WebEditorClient::shouldDeleteRange(Range* range)
    7474{
    75     bool result = m_page->injectedBundleEditorClient().shouldDeleteRange(m_page, range);
     75    bool result = m_page->injectedBundleEditorClient().shouldDeleteRange(*m_page, range);
    7676    notImplemented();
    7777    return result;
     
    116116bool WebEditorClient::shouldBeginEditing(Range* range)
    117117{
    118     bool result = m_page->injectedBundleEditorClient().shouldBeginEditing(m_page, range);
     118    bool result = m_page->injectedBundleEditorClient().shouldBeginEditing(*m_page, range);
    119119    notImplemented();
    120120    return result;
     
    123123bool WebEditorClient::shouldEndEditing(Range* range)
    124124{
    125     bool result = m_page->injectedBundleEditorClient().shouldEndEditing(m_page, range);
     125    bool result = m_page->injectedBundleEditorClient().shouldEndEditing(*m_page, range);
    126126    notImplemented();
    127127    return result;
     
    130130bool WebEditorClient::shouldInsertNode(Node* node, Range* rangeToReplace, EditorInsertAction action)
    131131{
    132     bool result = m_page->injectedBundleEditorClient().shouldInsertNode(m_page, node, rangeToReplace, action);
     132    bool result = m_page->injectedBundleEditorClient().shouldInsertNode(*m_page, node, rangeToReplace, action);
    133133    notImplemented();
    134134    return result;
     
    137137bool WebEditorClient::shouldInsertText(const String& text, Range* rangeToReplace, EditorInsertAction action)
    138138{
    139     bool result = m_page->injectedBundleEditorClient().shouldInsertText(m_page, text.impl(), rangeToReplace, action);
     139    bool result = m_page->injectedBundleEditorClient().shouldInsertText(*m_page, text.impl(), rangeToReplace, action);
    140140    notImplemented();
    141141    return result;
     
    144144bool WebEditorClient::shouldChangeSelectedRange(Range* fromRange, Range* toRange, EAffinity affinity, bool stillSelecting)
    145145{
    146     bool result = m_page->injectedBundleEditorClient().shouldChangeSelectedRange(m_page, fromRange, toRange, affinity, stillSelecting);
     146    bool result = m_page->injectedBundleEditorClient().shouldChangeSelectedRange(*m_page, fromRange, toRange, affinity, stillSelecting);
    147147    notImplemented();
    148148    return result;
     
    152152{
    153153    Ref<MutableStyleProperties> mutableStyle(style->isMutable() ? Ref<MutableStyleProperties>(static_cast<MutableStyleProperties&>(*style)) : style->mutableCopy());
    154     bool result = m_page->injectedBundleEditorClient().shouldApplyStyle(m_page, mutableStyle->ensureCSSStyleDeclaration(), range);
     154    bool result = m_page->injectedBundleEditorClient().shouldApplyStyle(*m_page, mutableStyle->ensureCSSStyleDeclaration(), range);
    155155    notImplemented();
    156156    return result;
     
    172172    // FIXME: What good is a notification name, if it's always the same?
    173173    static NeverDestroyed<String> WebViewDidBeginEditingNotification(ASCIILiteral("WebViewDidBeginEditingNotification"));
    174     m_page->injectedBundleEditorClient().didBeginEditing(m_page, WebViewDidBeginEditingNotification.get().impl());
     174    m_page->injectedBundleEditorClient().didBeginEditing(*m_page, WebViewDidBeginEditingNotification.get().impl());
    175175    notImplemented();
    176176}
     
    179179{
    180180    static NeverDestroyed<String> WebViewDidChangeNotification(ASCIILiteral("WebViewDidChangeNotification"));
    181     m_page->injectedBundleEditorClient().didChange(m_page, WebViewDidChangeNotification.get().impl());
     181    m_page->injectedBundleEditorClient().didChange(*m_page, WebViewDidChangeNotification.get().impl());
    182182    notImplemented();
    183183}
     
    186186{
    187187    static NeverDestroyed<String> WebViewDidChangeSelectionNotification(ASCIILiteral("WebViewDidChangeSelectionNotification"));
    188     m_page->injectedBundleEditorClient().didChangeSelection(m_page, WebViewDidChangeSelectionNotification.get().impl());
     188    m_page->injectedBundleEditorClient().didChangeSelection(*m_page, WebViewDidChangeSelectionNotification.get().impl());
    189189    if (!frame)
    190190        return;
     
    220220{
    221221    static NeverDestroyed<String> WebViewDidEndEditingNotification(ASCIILiteral("WebViewDidEndEditingNotification"));
    222     m_page->injectedBundleEditorClient().didEndEditing(m_page, WebViewDidEndEditingNotification.get().impl());
     222    m_page->injectedBundleEditorClient().didEndEditing(*m_page, WebViewDidEndEditingNotification.get().impl());
    223223    notImplemented();
    224224}
     
    226226void WebEditorClient::didWriteSelectionToPasteboard()
    227227{
    228     m_page->injectedBundleEditorClient().didWriteToPasteboard(m_page);
     228    m_page->injectedBundleEditorClient().didWriteToPasteboard(*m_page);
    229229}
    230230
    231231void WebEditorClient::willWriteSelectionToPasteboard(Range* range)
    232232{
    233     m_page->injectedBundleEditorClient().willWriteToPasteboard(m_page, range);
     233    m_page->injectedBundleEditorClient().willWriteToPasteboard(*m_page, range);
    234234}
    235235
    236236void WebEditorClient::getClientPasteboardDataForRange(Range* range, Vector<String>& pasteboardTypes, Vector<RefPtr<SharedBuffer>>& pasteboardData)
    237237{
    238     m_page->injectedBundleEditorClient().getPasteboardDataForRange(m_page, range, pasteboardTypes, pasteboardData);
     238    m_page->injectedBundleEditorClient().getPasteboardDataForRange(*m_page, range, pasteboardTypes, pasteboardData);
    239239}
    240240
  • trunk/Source/WebKit2/WebProcess/WebPage/WebPage.cpp

    r209230 r209307  
    305305    , m_contextMenuClient(std::make_unique<API::InjectedBundle::PageContextMenuClient>())
    306306#endif
     307    , m_editorClient { std::make_unique<API::InjectedBundle::EditorClient>() }
    307308    , m_formClient(std::make_unique<API::InjectedBundle::FormClient>())
    308309    , m_uiClient(std::make_unique<API::InjectedBundle::PageUIClient>())
     
    620621#endif
    621622
    622 void WebPage::initializeInjectedBundleEditorClient(WKBundlePageEditorClientBase* client)
    623 {
    624     m_editorClient.initialize(client);
     623void WebPage::setInjectedBundleEditorClient(std::unique_ptr<API::InjectedBundle::EditorClient> editorClient)
     624{
     625    if (!editorClient) {
     626        m_editorClient = std::make_unique<API::InjectedBundle::EditorClient>();
     627        return;
     628    }
     629
     630    m_editorClient = WTFMove(editorClient);
    625631}
    626632
     
    10601066    m_contextMenuClient = std::make_unique<API::InjectedBundle::PageContextMenuClient>();
    10611067#endif
    1062     m_editorClient.initialize(0);
     1068    m_editorClient = std::make_unique<API::InjectedBundle::EditorClient>();
    10631069    m_formClient = std::make_unique<API::InjectedBundle::FormClient>();
    10641070    m_loaderClient.initialize(0);
  • trunk/Source/WebKit2/WebProcess/WebPage/WebPage.h

    r209102 r209307  
    2626#pragma once
    2727
     28#include "APIInjectedBundleEditorClient.h"
    2829#include "APIInjectedBundleFormClient.h"
    2930#include "APIInjectedBundlePageContextMenuClient.h"
     
    3637#include "ImageOptions.h"
    3738#include "InjectedBundlePageDiagnosticLoggingClient.h"
    38 #include "InjectedBundlePageEditorClient.h"
    3939#include "InjectedBundlePageFullScreenClient.h"
    4040#include "InjectedBundlePageLoaderClient.h"
     
    323323    void setInjectedBundleContextMenuClient(std::unique_ptr<API::InjectedBundle::PageContextMenuClient>);
    324324#endif
    325     void initializeInjectedBundleEditorClient(WKBundlePageEditorClientBase*);
     325    void setInjectedBundleEditorClient(std::unique_ptr<API::InjectedBundle::EditorClient>);
    326326    void setInjectedBundleFormClient(std::unique_ptr<API::InjectedBundle::FormClient>);
    327327    void initializeInjectedBundleLoaderClient(WKBundlePageLoaderClientBase*);
     
    337337    API::InjectedBundle::PageContextMenuClient& injectedBundleContextMenuClient() { return *m_contextMenuClient.get(); }
    338338#endif
    339     InjectedBundlePageEditorClient& injectedBundleEditorClient() { return m_editorClient; }
     339    API::InjectedBundle::EditorClient& injectedBundleEditorClient() { return *m_editorClient.get(); }
    340340    API::InjectedBundle::FormClient& injectedBundleFormClient() { return *m_formClient.get(); }
    341341    InjectedBundlePageLoaderClient& injectedBundleLoaderClient() { return m_loaderClient; }
     
    13381338    std::unique_ptr<API::InjectedBundle::PageContextMenuClient> m_contextMenuClient;
    13391339#endif
    1340     InjectedBundlePageEditorClient m_editorClient;
     1340    std::unique_ptr<API::InjectedBundle::EditorClient> m_editorClient;
    13411341    std::unique_ptr<API::InjectedBundle::FormClient> m_formClient;
    13421342    InjectedBundlePageLoaderClient m_loaderClient;
  • trunk/Tools/ChangeLog

    r209288 r209307  
     12016-12-03  Dan Bernstein  <mitz@apple.com>
     2
     3        [Cocoa] Expose InjectedBundlePageEditorClient via the Objective-C bundle SPI
     4        https://bugs.webkit.org/show_bug.cgi?id=165276
     5        <rdar://problem/29467040>
     6
     7        Reviewed by Darin Adler.
     8
     9        * TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj:
     10        * TestWebKitAPI/Tests/WebKit2Cocoa/BundleEditingDelegate.mm: Added.
     11        (-[BundleEditingDelegateRemoteObject willWriteToPasteboard:]):
     12        (-[BundleEditingDelegateRemoteObject didWriteToPasteboard]):
     13        (TEST):
     14        * TestWebKitAPI/Tests/WebKit2Cocoa/BundleEditingDelegatePlugIn.mm: Added.
     15        (-[BundleEditingDelegatePlugIn webProcessPlugIn:didCreateBrowserContextController:]):
     16        (-[BundleEditingDelegatePlugIn _webProcessPlugInBrowserContextController:willWriteRangeToPasteboard:]):
     17        (-[BundleEditingDelegatePlugIn _webProcessPlugInBrowserContextController:pasteboardDataForRange:]):
     18        (-[BundleEditingDelegatePlugIn _webProcessPlugInBrowserContextControllerDidWriteToPasteboard:]):
     19        * TestWebKitAPI/Tests/WebKit2Cocoa/BundleEditingDelegateProtocol.h: Added.
     20
    1212016-12-02  Andy Estes  <aestes@apple.com>
    222
  • trunk/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj

    r208963 r209307  
    9292                33DC89141419579F00747EF7 /* LoadCanceledNoServerRedirectCallback_Bundle.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 33DC89131419579F00747EF7 /* LoadCanceledNoServerRedirectCallback_Bundle.cpp */; };
    9393                33E79E06137B5FD900E32D99 /* mouse-move-listener.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = 33E79E05137B5FCE00E32D99 /* mouse-move-listener.html */; };
     94                374B7A601DF36EEE00ACCB6C /* BundleEditingDelegate.mm in Sources */ = {isa = PBXBuildFile; fileRef = 374B7A5E1DF36EEE00ACCB6C /* BundleEditingDelegate.mm */; };
     95                374B7A611DF371CF00ACCB6C /* BundleEditingDelegatePlugIn.mm in Sources */ = {isa = PBXBuildFile; fileRef = 374B7A5F1DF36EEE00ACCB6C /* BundleEditingDelegatePlugIn.mm */; };
    9496                375E0E171D66674400EFEC2C /* WKNSNumber.mm in Sources */ = {isa = PBXBuildFile; fileRef = 375E0E151D66674400EFEC2C /* WKNSNumber.mm */; };
    9597                376C8C061D6E197C007D2BB9 /* FrameHandle.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 376C8C041D6E197C007D2BB9 /* FrameHandle.cpp */; };
     
    859861                33E79E05137B5FCE00E32D99 /* mouse-move-listener.html */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.html; path = "mouse-move-listener.html"; sourceTree = "<group>"; };
    860862                3722C8681461E03E00C45D00 /* RenderedImageFromDOMRange.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = RenderedImageFromDOMRange.mm; sourceTree = "<group>"; };
     863                374B7A5E1DF36EEE00ACCB6C /* BundleEditingDelegate.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = BundleEditingDelegate.mm; sourceTree = "<group>"; };
     864                374B7A5F1DF36EEE00ACCB6C /* BundleEditingDelegatePlugIn.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = BundleEditingDelegatePlugIn.mm; sourceTree = "<group>"; };
     865                374B7A621DF3734C00ACCB6C /* BundleEditingDelegateProtocol.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = BundleEditingDelegateProtocol.h; sourceTree = "<group>"; };
    861866                3751AF7A169518F800764319 /* DOMNodeFromJSObject.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = DOMNodeFromJSObject.mm; sourceTree = "<group>"; };
    862867                375E0E151D66674400EFEC2C /* WKNSNumber.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = WKNSNumber.mm; sourceTree = "<group>"; };
     
    14141419                                2DE71AFD1D49C0BD00904094 /* AnimatedResize.mm */,
    14151420                                2DD355351BD08378005DF4A7 /* AutoLayoutIntegration.mm */,
     1421                                374B7A5E1DF36EEE00ACCB6C /* BundleEditingDelegate.mm */,
     1422                                374B7A5F1DF36EEE00ACCB6C /* BundleEditingDelegatePlugIn.mm */,
     1423                                374B7A621DF3734C00ACCB6C /* BundleEditingDelegateProtocol.h */,
    14161424                                A13EBBAC1B87436F00097110 /* BundleParameters.mm */,
    14171425                                A13EBBAE1B87436F00097110 /* BundleParametersPlugIn.mm */,
     
    23872395                                7CCE7EE41A411AE600447C4C /* AboutBlankLoad.cpp in Sources */,
    23882396                                7CCE7EB31A411A7E00447C4C /* AcceptsFirstMouse.mm in Sources */,
     2397                                374B7A601DF36EEE00ACCB6C /* BundleEditingDelegate.mm in Sources */,
    23892398                                5C0BF8951DD599CD00B00328 /* NavigatorLanguage.mm in Sources */,
    23902399                                A1DF74321C41B65800A2F4D0 /* AlwaysRevalidatedURLSchemes.mm in Sources */,
     
    26542663                                1A4F81CF1BDFFD53004E672E /* RemoteObjectRegistryPlugIn.mm in Sources */,
    26552664                                7C882E091C80C630006BF731 /* UserContentWorldPlugIn.mm in Sources */,
     2665                                374B7A611DF371CF00ACCB6C /* BundleEditingDelegatePlugIn.mm in Sources */,
    26562666                                7C83E03D1D0A60D600FEBCF3 /* UtilitiesCocoa.mm in Sources */,
    26572667                                A13EBBAA1B87428D00097110 /* WebProcessPlugIn.mm in Sources */,
Note: See TracChangeset for help on using the changeset viewer.