Title: [177113] trunk/Source
Revision
177113
Author
[email protected]
Date
2014-12-10 16:14:21 -0800 (Wed, 10 Dec 2014)

Log Message

WK2: Add initial support for immediate actions
https://bugs.webkit.org/show_bug.cgi?id=139511

Reviewed by Tim Horton.

Source/WebCore:

SPI needed for immediate actions.
* WebCore.xcodeproj/project.pbxproj:
* platform/spi/mac/NSImmediateActionGestureRecognizerSPI.h: Added.

Source/WebKit2:

New enum to track immediate action types as we add them.
* Shared/API/c/WKImmediateActionTypes.h: Added.

Create an NSImmediateActionGestureRecognizer if possible and a controller.
* UIProcess/API/mac/WKView.mm:
(-[WKView dealloc]):
(-[WKView initWithFrame:context:configuration:webView:]):
(-[WKView _didPerformActionMenuHitTest:userData:]):

This basic implementation of the controller will use the delegate methods to 
perform an ActionMenuHitTest when relevant. Future patches will patch 
_updateImmediateActionItem to use the hit test result to determine if there is any 
immediate action that should be taken.
* UIProcess/mac/WKImmediateActionController.h: Added.
* UIProcess/mac/WKImmediateActionController.mm: Added.
(-[WKImmediateActionController willDestroyView:]):
(-[WKImmediateActionController _clearImmediateActionState]):
(-[WKImmediateActionController didPerformActionMenuHitTest:userData:]):

Does much of the work done in Action Menu’s prepareForMenu.
(-[WKImmediateActionController immediateActionRecognizerWillPrepare:]):

Does much of the work done in Action Menu’s menuNeedsUpdate.
(-[WKImmediateActionController immediateActionRecognizerWillBeginAnimation:]):

Does much of the work done in Action Menu’s didCloseMenu.
(-[WKImmediateActionController immediateActionRecognizerDidCancelAnimation:]):

Does much of the work done in Action Menu’s willOpenMenu.
(-[WKImmediateActionController immediateActionRecognizerDidCompleteAnimation:]):

To be filled in.
(-[WKImmediateActionController _updateImmediateActionItem]):
* WebKit2.xcodeproj/project.pbxproj:

Modified Paths

Added Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (177112 => 177113)


--- trunk/Source/WebCore/ChangeLog	2014-12-10 23:55:37 UTC (rev 177112)
+++ trunk/Source/WebCore/ChangeLog	2014-12-11 00:14:21 UTC (rev 177113)
@@ -1,3 +1,14 @@
+2014-12-10  Beth Dakin  <[email protected]>
+
+        WK2: Add initial support for immediate actions
+        https://bugs.webkit.org/show_bug.cgi?id=139511
+
+        Reviewed by Tim Horton.
+
+        SPI needed for immediate actions.
+        * WebCore.xcodeproj/project.pbxproj:
+        * platform/spi/mac/NSImmediateActionGestureRecognizerSPI.h: Added.
+
 2014-12-10  Martin Hock  <[email protected]>
 
         [iOS] Add setting to ignore viewport scaling constraints

Modified: trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj (177112 => 177113)


--- trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj	2014-12-10 23:55:37 UTC (rev 177112)
+++ trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj	2014-12-11 00:14:21 UTC (rev 177113)
@@ -3163,6 +3163,7 @@
 		931CBD10161A44E900E4C874 /* ScrollingStateTree.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 931CBD0A161A44E900E4C874 /* ScrollingStateTree.cpp */; };
 		931CBD11161A44E900E4C874 /* ScrollingStateTree.h in Headers */ = {isa = PBXBuildFile; fileRef = 931CBD0B161A44E900E4C874 /* ScrollingStateTree.h */; settings = {ATTRIBUTES = (Private, ); }; };
 		931D72F615FE695300C4C07E /* LayoutMilestones.h in Headers */ = {isa = PBXBuildFile; fileRef = 931D72F515FE695300C4C07E /* LayoutMilestones.h */; settings = {ATTRIBUTES = (Private, ); }; };
+		9321D5901A390704008052BE /* NSImmediateActionGestureRecognizerSPI.h in Headers */ = {isa = PBXBuildFile; fileRef = 9321D58F1A3906FA008052BE /* NSImmediateActionGestureRecognizerSPI.h */; settings = {ATTRIBUTES = (Private, ); }; };
 		9326DC0C09DAD5D600AFC847 /* CharsetData.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 656581AC09D14EE6000E61D7 /* CharsetData.cpp */; };
 		9327A94209968D1A0068A546 /* HTMLOptionsCollection.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 9327A94109968D1A0068A546 /* HTMLOptionsCollection.cpp */; };
 		932871C00B20DEB70049035A /* PlatformMenuDescription.h in Headers */ = {isa = PBXBuildFile; fileRef = 932871BF0B20DEB70049035A /* PlatformMenuDescription.h */; settings = {ATTRIBUTES = (Private, ); }; };
@@ -10339,6 +10340,7 @@
 		931CBD0A161A44E900E4C874 /* ScrollingStateTree.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ScrollingStateTree.cpp; sourceTree = "<group>"; };
 		931CBD0B161A44E900E4C874 /* ScrollingStateTree.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ScrollingStateTree.h; sourceTree = "<group>"; };
 		931D72F515FE695300C4C07E /* LayoutMilestones.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = LayoutMilestones.h; sourceTree = "<group>"; };
+		9321D58F1A3906FA008052BE /* NSImmediateActionGestureRecognizerSPI.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = NSImmediateActionGestureRecognizerSPI.h; sourceTree = "<group>"; };
 		9327A94109968D1A0068A546 /* HTMLOptionsCollection.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = HTMLOptionsCollection.cpp; sourceTree = "<group>"; };
 		932871BF0B20DEB70049035A /* PlatformMenuDescription.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = PlatformMenuDescription.h; sourceTree = "<group>"; };
 		932AD70317EFA2C30038F8FF /* MainFrame.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = MainFrame.cpp; sourceTree = "<group>"; };
@@ -17639,6 +17641,7 @@
 				2D59F1BE1A0044C6001F3D29 /* DataDetectorsSPI.h */,
 				2D413F601A187A3F0041A521 /* LookupSPI.h */,
 				1C6466271A12C3F90094603C /* NSFontSPI.h */,
+				9321D58F1A3906FA008052BE /* NSImmediateActionGestureRecognizerSPI.h */,
 				937F4CCD1A2D4B0100BB39F5 /* NSMenuSPI.h */,
 				2DCB837719F99BBA00A7FBE4 /* NSSharingServicePickerSPI.h */,
 				2DCB837819F99BBA00A7FBE4 /* NSSharingServiceSPI.h */,
@@ -25375,6 +25378,7 @@
 				1AE00D59182DAC8D00087DD7 /* KeyedCoding.h in Headers */,
 				A513B3D7114B1666001C429B /* KeyEventCocoa.h in Headers */,
 				265541391489811C000DFC5D /* KeyEventCodesIOS.h in Headers */,
+				9321D5901A390704008052BE /* NSImmediateActionGestureRecognizerSPI.h in Headers */,
 				316FE11A0E6E1DA700BF6088 /* KeyframeAnimation.h in Headers */,
 				BC5EBA110E823E4700B25965 /* KeyframeList.h in Headers */,
 				E15FF7D518C9553800FE4C87 /* KeypressCommand.h in Headers */,

Added: trunk/Source/WebCore/platform/spi/mac/NSImmediateActionGestureRecognizerSPI.h (0 => 177113)


--- trunk/Source/WebCore/platform/spi/mac/NSImmediateActionGestureRecognizerSPI.h	                        (rev 0)
+++ trunk/Source/WebCore/platform/spi/mac/NSImmediateActionGestureRecognizerSPI.h	2014-12-11 00:14:21 UTC (rev 177113)
@@ -0,0 +1,35 @@
+/*
+ * 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. ``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
+ * 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. 
+ */
+
+#if __has_include(<AppKit/NSImmediateActionGestureRecognizer.h>)
+
+#import <AppKit/NSImmediateActionGestureRecognizer.h>
+
+#else
+
+@interface NSImmediateActionGestureRecognizer : NSGestureRecognizer
+@end
+
+#endif

Modified: trunk/Source/WebKit2/ChangeLog (177112 => 177113)


--- trunk/Source/WebKit2/ChangeLog	2014-12-10 23:55:37 UTC (rev 177112)
+++ trunk/Source/WebKit2/ChangeLog	2014-12-11 00:14:21 UTC (rev 177113)
@@ -1,3 +1,45 @@
+2014-12-10  Beth Dakin  <[email protected]>
+
+        WK2: Add initial support for immediate actions
+        https://bugs.webkit.org/show_bug.cgi?id=139511
+
+        Reviewed by Tim Horton.
+
+        New enum to track immediate action types as we add them.
+        * Shared/API/c/WKImmediateActionTypes.h: Added.
+
+        Create an NSImmediateActionGestureRecognizer if possible and a controller.
+        * UIProcess/API/mac/WKView.mm:
+        (-[WKView dealloc]):
+        (-[WKView initWithFrame:context:configuration:webView:]):
+        (-[WKView _didPerformActionMenuHitTest:userData:]):
+
+        This basic implementation of the controller will use the delegate methods to 
+        perform an ActionMenuHitTest when relevant. Future patches will patch 
+        _updateImmediateActionItem to use the hit test result to determine if there is any 
+        immediate action that should be taken.
+        * UIProcess/mac/WKImmediateActionController.h: Added.
+        * UIProcess/mac/WKImmediateActionController.mm: Added.
+        (-[WKImmediateActionController willDestroyView:]):
+        (-[WKImmediateActionController _clearImmediateActionState]):
+        (-[WKImmediateActionController didPerformActionMenuHitTest:userData:]):
+
+        Does much of the work done in Action Menu’s prepareForMenu.
+        (-[WKImmediateActionController immediateActionRecognizerWillPrepare:]):
+
+        Does much of the work done in Action Menu’s menuNeedsUpdate.
+        (-[WKImmediateActionController immediateActionRecognizerWillBeginAnimation:]):
+
+        Does much of the work done in Action Menu’s didCloseMenu.
+        (-[WKImmediateActionController immediateActionRecognizerDidCancelAnimation:]):
+
+        Does much of the work done in Action Menu’s willOpenMenu.
+        (-[WKImmediateActionController immediateActionRecognizerDidCompleteAnimation:]):
+
+        To be filled in.
+        (-[WKImmediateActionController _updateImmediateActionItem]):
+        * WebKit2.xcodeproj/project.pbxproj:
+
 2014-12-10  Timothy Horton  <[email protected]>
 
         Should have copy and paste items in all text menus

Added: trunk/Source/WebKit2/Shared/API/c/WKImmediateActionTypes.h (0 => 177113)


--- trunk/Source/WebKit2/Shared/API/c/WKImmediateActionTypes.h	                        (rev 0)
+++ trunk/Source/WebKit2/Shared/API/c/WKImmediateActionTypes.h	2014-12-11 00:14:21 UTC (rev 177113)
@@ -0,0 +1,44 @@
+/*
+ * 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 WKImmediateActionTypes_h
+#define WKImmediateActionTypes_h
+
+#include <stdint.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+enum {
+    kWKImmediateActionNone = 0,
+};
+typedef uint32_t _WKImmediateActionType;
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* WKImmediateActionTypes_h */

Modified: trunk/Source/WebKit2/UIProcess/API/mac/WKView.mm (177112 => 177113)


--- trunk/Source/WebKit2/UIProcess/API/mac/WKView.mm	2014-12-10 23:55:37 UTC (rev 177112)
+++ trunk/Source/WebKit2/UIProcess/API/mac/WKView.mm	2014-12-11 00:14:21 UTC (rev 177113)
@@ -58,6 +58,7 @@
 #import "WKActionMenuController.h"
 #import "WKActionMenuItemTypes.h"
 #import "WKFullScreenWindowController.h"
+#import "WKImmediateActionController.h"
 #import "WKPrintingView.h"
 #import "WKProcessPoolInternal.h"
 #import "WKStringCF.h"
@@ -87,6 +88,7 @@
 #import <WebCore/KeyboardEvent.h>
 #import <WebCore/LocalizedStrings.h>
 #import <WebCore/LookupSPI.h>
+#import <WebCore/NSImmediateActionGestureRecognizerSPI.h>
 #import <WebCore/NSViewSPI.h>
 #import <WebCore/PlatformEventFactoryMac.h>
 #import <WebCore/PlatformScreen.h>
@@ -260,6 +262,7 @@
 #if __MAC_OS_X_VERSION_MIN_REQUIRED >= 101000
     BOOL _automaticallyAdjustsContentInsets;
     RetainPtr<WKActionMenuController> _actionMenuController;
+    RetainPtr<WKImmediateActionController> _immediateActionController;
 #endif
 
 #if WK_API_ENABLED
@@ -313,6 +316,7 @@
 {
 #if __MAC_OS_X_VERSION_MIN_REQUIRED >= 101000
     [_data->_actionMenuController willDestroyView:self];
+    [_data->_immediateActionController willDestroyView:self];
 #endif
 
     _data->_page->close();
@@ -3617,6 +3621,13 @@
         self.actionMenu.delegate = _data->_actionMenuController.get();
         self.actionMenu.autoenablesItems = NO;
     }
+
+    if (NSClassFromString(@"NSImmediateActionGestureRecognizer")) {
+        RetainPtr<NSImmediateActionGestureRecognizer> recognizer = adoptNS([[NSImmediateActionGestureRecognizer alloc] initWithTarget:nil action:NULL]);
+        _data->_immediateActionController = adoptNS([[WKImmediateActionController alloc] initWithPage:*_data->_page view:self]);
+        [recognizer setDelegate:_data->_immediateActionController.get()];
+        [self addGestureRecognizer:recognizer.get()];
+    }
 #endif
 
     return self;
@@ -3751,6 +3762,7 @@
 - (void)_didPerformActionMenuHitTest:(const ActionMenuHitTestResult&)hitTestResult userData:(API::Object*)userData
 {
     [_data->_actionMenuController didPerformActionMenuHitTest:hitTestResult userData:userData];
+    [_data->_immediateActionController didPerformActionMenuHitTest:hitTestResult userData:userData];
 }
 
 #endif // __MAC_OS_X_VERSION_MIN_REQUIRED >= 101000

Added: trunk/Source/WebKit2/UIProcess/mac/WKImmediateActionController.h (0 => 177113)


--- trunk/Source/WebKit2/UIProcess/mac/WKImmediateActionController.h	                        (rev 0)
+++ trunk/Source/WebKit2/UIProcess/mac/WKImmediateActionController.h	2014-12-11 00:14:21 UTC (rev 177113)
@@ -0,0 +1,68 @@
+/*
+ * 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 WKImmediateActionController_h
+#define WKImmediateActionController_h
+
+#if PLATFORM(MAC) && __MAC_OS_X_VERSION_MIN_REQUIRED >= 101000
+
+#import "ActionMenuHitTestResult.h"
+#import "WKImmediateActionTypes.h"
+#import <wtf/RetainPtr.h>
+
+namespace WebKit {
+class WebPageProxy;
+
+enum class ImmediateActionState {
+    None = 0,
+    Pending,
+    TimedOut,
+    Ready
+};
+}
+
+@class WKView;
+
+@interface WKImmediateActionController : NSObject <NSGestureRecognizerDelegate> {
+@private
+    WebKit::WebPageProxy *_page;
+    WKView *_wkView;
+
+    WebKit::ImmediateActionState _state;
+    WebKit::ActionMenuHitTestResult _hitTestResult;
+    _WKImmediateActionType _type;
+
+    NSPoint _eventLocationInView;
+}
+
+- (instancetype)initWithPage:(WebKit::WebPageProxy&)page view:(WKView *)wkView;
+- (void)willDestroyView:(WKView *)view;
+- (void)didPerformActionMenuHitTest:(const WebKit::ActionMenuHitTestResult&)hitTestResult userData:(API::Object*)userData;
+
+@end
+
+#endif // PLATFORM(MAC) && __MAC_OS_X_VERSION_MIN_REQUIRED >= 101000
+
+#endif // WKImmediateActionController_h

Added: trunk/Source/WebKit2/UIProcess/mac/WKImmediateActionController.mm (0 => 177113)


--- trunk/Source/WebKit2/UIProcess/mac/WKImmediateActionController.mm	                        (rev 0)
+++ trunk/Source/WebKit2/UIProcess/mac/WKImmediateActionController.mm	2014-12-11 00:14:21 UTC (rev 177113)
@@ -0,0 +1,140 @@
+/*
+ * 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 "config.h"
+#import "WKImmediateActionController.h"
+
+#if PLATFORM(MAC) && __MAC_OS_X_VERSION_MIN_REQUIRED >= 101000
+
+#import "WKViewInternal.h"
+#import "WebPageMessages.h"
+#import "WebPageProxy.h"
+#import "WebPageProxyMessages.h"
+#import "WebProcessProxy.h"
+#import <WebCore/NSImmediateActionGestureRecognizerSPI.h>
+
+using namespace WebCore;
+using namespace WebKit;
+
+@implementation WKImmediateActionController
+
+- (instancetype)initWithPage:(WebPageProxy&)page view:(WKView *)wkView
+{
+    self = [super init];
+
+    if (!self)
+        return nil;
+
+    _page = &page;
+    _wkView = wkView;
+    _type = kWKImmediateActionNone;
+
+    return self;
+}
+
+- (void)willDestroyView:(WKView *)view
+{
+    _page = nullptr;
+    _wkView = nil;
+    _hitTestResult = ActionMenuHitTestResult();
+}
+
+- (void)_clearImmediateActionState
+{
+    _state = ImmediateActionState::None;
+    _hitTestResult = ActionMenuHitTestResult();
+    _type = kWKImmediateActionNone;
+}
+
+- (void)didPerformActionMenuHitTest:(const ActionMenuHitTestResult&)hitTestResult userData:(API::Object*)userData
+{
+    // FIXME: This needs to use the WebKit2 callback mechanism to avoid out-of-order replies.
+    _state = ImmediateActionState::Ready;
+    _hitTestResult = hitTestResult;
+
+    [self _updateImmediateActionItem];
+}
+
+#pragma mark NSGestureRecognizerDelegate
+
+- (void)immediateActionRecognizerWillPrepare:(NSImmediateActionGestureRecognizer *)immediateActionRecognizer
+{
+    if (immediateActionRecognizer.view != _wkView)
+        return;
+
+    _eventLocationInView = [immediateActionRecognizer locationInView:immediateActionRecognizer.view];
+    _page->performActionMenuHitTestAtLocation(_eventLocationInView);
+
+    _state = ImmediateActionState::Pending;
+    [self _updateImmediateActionItem];
+}
+
+- (void)immediateActionRecognizerWillBeginAnimation:(NSImmediateActionGestureRecognizer *)immediateActionRecognizer
+{
+    if (immediateActionRecognizer.view != _wkView)
+        return;
+
+    ASSERT(_state != ImmediateActionState::None);
+
+    // FIXME: We need to be able to cancel this if the gesture recognizer goes away.
+    // FIXME: Connection can be null if the process is closed; we should clean up better in that case.
+    if (_state == ImmediateActionState::Pending) {
+        if (auto* connection = _page->process().connection()) {
+            bool receivedReply = connection->waitForAndDispatchImmediately<Messages::WebPageProxy::DidPerformActionMenuHitTest>(_page->pageID(), std::chrono::milliseconds(500));
+            if (!receivedReply)
+                _state = ImmediateActionState::TimedOut;
+        }
+    }
+
+    if (_state != ImmediateActionState::Ready)
+        [self _updateImmediateActionItem];
+}
+
+- (void)immediateActionRecognizerDidCancelAnimation:(NSImmediateActionGestureRecognizer *)immediateActionRecognizer
+{
+    if (immediateActionRecognizer.view != _wkView)
+        return;
+
+    [self _clearImmediateActionState];
+}
+
+- (void)immediateActionRecognizerDidCompleteAnimation:(NSImmediateActionGestureRecognizer *)immediateActionRecognizer
+{
+    if (immediateActionRecognizer.view != _wkView)
+        return;
+
+    // FIXME: Add support for the types of functionality provided in Action menu's willOpenMenu.
+}
+
+#pragma mark Immediate actions
+
+- (void)_updateImmediateActionItem
+{
+    // FIXME: Implement.
+}
+
+@end
+
+#endif // PLATFORM(MAC)

Modified: trunk/Source/WebKit2/WebKit2.xcodeproj/project.pbxproj (177112 => 177113)


--- trunk/Source/WebKit2/WebKit2.xcodeproj/project.pbxproj	2014-12-10 23:55:37 UTC (rev 177112)
+++ trunk/Source/WebKit2/WebKit2.xcodeproj/project.pbxproj	2014-12-11 00:14:21 UTC (rev 177113)
@@ -1092,6 +1092,9 @@
 		909854EC12BC4E17000AD080 /* WebMemorySampler.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 905620E812BC248B000799B6 /* WebMemorySampler.cpp */; };
 		909854ED12BC4E18000AD080 /* WebMemorySampler.h in Headers */ = {isa = PBXBuildFile; fileRef = 905620E912BC248B000799B6 /* WebMemorySampler.h */; };
 		909854EE12BC4E18000AD080 /* WebMemorySampler.mac.mm in Sources */ = {isa = PBXBuildFile; fileRef = 905620E512BC2476000799B6 /* WebMemorySampler.mac.mm */; };
+		9321D5861A38EE3C008052BE /* WKImmediateActionController.h in Headers */ = {isa = PBXBuildFile; fileRef = 9321D5851A38EE3C008052BE /* WKImmediateActionController.h */; };
+		9321D5881A38EE74008052BE /* WKImmediateActionController.mm in Sources */ = {isa = PBXBuildFile; fileRef = 9321D5871A38EE74008052BE /* WKImmediateActionController.mm */; };
+		9321D58A1A38F196008052BE /* WKImmediateActionTypes.h in Headers */ = {isa = PBXBuildFile; fileRef = 9321D5891A38F196008052BE /* WKImmediateActionTypes.h */; };
 		934B724419F5B9BE00AE96D6 /* WKActionMenuItemTypes.h in Headers */ = {isa = PBXBuildFile; fileRef = 934B724319F5B9BE00AE96D6 /* WKActionMenuItemTypes.h */; settings = {ATTRIBUTES = (Private, ); }; };
 		935EEB9B1277617C003322B8 /* WKBundleBackForwardListItem.h in Headers */ = {isa = PBXBuildFile; fileRef = 935EEB981277616D003322B8 /* WKBundleBackForwardListItem.h */; settings = {ATTRIBUTES = (Private, ); }; };
 		935EEB9E127761AC003322B8 /* WKBundleBackForwardList.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 935EEB951277616D003322B8 /* WKBundleBackForwardList.cpp */; };
@@ -3174,6 +3177,9 @@
 		905620E512BC2476000799B6 /* WebMemorySampler.mac.mm */ = {isa = PBXFileReference; fileEncoding = 4; indentWidth = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = WebMemorySampler.mac.mm; sourceTree = "<group>"; tabWidth = 8; usesTabs = 0; };
 		905620E812BC248B000799B6 /* WebMemorySampler.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = WebMemorySampler.cpp; sourceTree = "<group>"; };
 		905620E912BC248B000799B6 /* WebMemorySampler.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WebMemorySampler.h; sourceTree = "<group>"; };
+		9321D5851A38EE3C008052BE /* WKImmediateActionController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WKImmediateActionController.h; sourceTree = "<group>"; };
+		9321D5871A38EE74008052BE /* WKImmediateActionController.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = WKImmediateActionController.mm; sourceTree = "<group>"; };
+		9321D5891A38F196008052BE /* WKImmediateActionTypes.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WKImmediateActionTypes.h; sourceTree = "<group>"; };
 		934B724319F5B9BE00AE96D6 /* WKActionMenuItemTypes.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WKActionMenuItemTypes.h; sourceTree = "<group>"; };
 		935EEB8F1277615D003322B8 /* InjectedBundleBackForwardList.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = InjectedBundleBackForwardList.cpp; sourceTree = "<group>"; };
 		935EEB901277615D003322B8 /* InjectedBundleBackForwardList.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = InjectedBundleBackForwardList.h; sourceTree = "<group>"; };
@@ -6725,12 +6731,14 @@
 				51D130571382F10500351EDD /* WebProcessProxyMac.mm */,
 				868160CD18763D4B0021E79D /* WindowServerConnection.h */,
 				868160CF187645370021E79D /* WindowServerConnection.mm */,
+				2D0730A119F9C7DA00E9D9C4 /* WKActionMenuController.h */,
 				2D0730A019F9C7DA00E9D9C4 /* WKActionMenuController.mm */,
-				2D0730A119F9C7DA00E9D9C4 /* WKActionMenuController.h */,
 				E1AEA22D14687BDB00804569 /* WKFullKeyboardAccessWatcher.h */,
 				E1AEA22E14687BDB00804569 /* WKFullKeyboardAccessWatcher.mm */,
 				CDCA85C7132ABA4E00E961DF /* WKFullScreenWindowController.h */,
 				CDCA85C6132ABA4E00E961DF /* WKFullScreenWindowController.mm */,
+				9321D5851A38EE3C008052BE /* WKImmediateActionController.h */,
+				9321D5871A38EE74008052BE /* WKImmediateActionController.mm */,
 				0FCB4E5C18BBE3D9000FCFC9 /* WKPrintingView.h */,
 				0FCB4E5D18BBE3D9000FCFC9 /* WKPrintingView.mm */,
 				0FCB4E5E18BBE3D9000FCFC9 /* WKTextInputWindowController.h */,
@@ -6789,6 +6797,7 @@
 				BCC8B373125FB69000DE46A4 /* WKGeometry.h */,
 				BCCF6AC012C91F34008F9C35 /* WKImage.cpp */,
 				BCCF6AC112C91F34008F9C35 /* WKImage.h */,
+				9321D5891A38F196008052BE /* WKImmediateActionTypes.h */,
 				BC4075E1124FF0270068F20A /* WKMutableArray.cpp */,
 				BC4075E2124FF0270068F20A /* WKMutableArray.h */,
 				BC4075E3124FF0270068F20A /* WKMutableDictionary.cpp */,
@@ -7383,6 +7392,7 @@
 				E152551B17011819003D7ADB /* NetworkResourceLoaderMessages.h in Headers */,
 				51CBBA10165219B6005BE8FD /* NetworkResourceLoadParameters.h in Headers */,
 				A1DF631318E0B7C8003A3E2A /* DownloadClient.h in Headers */,
+				9321D58A1A38F196008052BE /* WKImmediateActionTypes.h in Headers */,
 				7C85FD7C193415A8000177C4 /* WebPreferencesDefinitions.h in Headers */,
 				51829DA61637C70C000953D6 /* NetworkResourceLoadScheduler.h in Headers */,
 				31A2EC5614899C0900810D71 /* NotificationPermissionRequest.h in Headers */,
@@ -7701,6 +7711,7 @@
 				BC5744F012638FB3006F0F12 /* WebPopupItem.h in Headers */,
 				4A3CC18D19B0641900D14AEF /* UserMediaPermissionRequestProxy.h in Headers */,
 				D3B9484711FF4B6500032B39 /* WebPopupMenu.h in Headers */,
+				9321D5861A38EE3C008052BE /* WKImmediateActionController.h in Headers */,
 				BC574E631267D080006F0F12 /* WebPopupMenuProxy.h in Headers */,
 				7C8EB11718DB6A19007917C2 /* WKPreferencesPrivate.h in Headers */,
 				C58CDF2A1887548B00871536 /* InteractionInformationAtPosition.h in Headers */,
@@ -9405,6 +9416,7 @@
 				BC111AE4112F5C2600337BAB /* WebProcess.cpp in Sources */,
 				1A043A0A124D11A900FFBFB5 /* WebProcessConnection.cpp in Sources */,
 				1A043F6912514D8B00FFBFB5 /* WebProcessConnectionMessageReceiver.cpp in Sources */,
+				9321D5881A38EE74008052BE /* WKImmediateActionController.mm in Sources */,
 				1A002D48196B345D00B9AD44 /* SessionStateCoding.mm in Sources */,
 				BC306825125A6B9400E71278 /* WebProcessCreationParameters.cpp in Sources */,
 				1F7506B01859162C00EC0FF7 /* WKWebProcessPlugInScriptWorld.mm in Sources */,
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to