Title: [233546] trunk/Source/WebKit
Revision
233546
Author
[email protected]
Date
2018-07-05 15:28:17 -0700 (Thu, 05 Jul 2018)

Log Message

Upstream hover gesture implementation
https://bugs.webkit.org/show_bug.cgi?id=187366

Reviewed by Wenson Hsieh.

* UIProcess/ios/WKContentViewInteraction.h:
* UIProcess/ios/WKContentViewInteraction.mm:
(-[WKContentView setupInteraction]):
(-[WKContentView cleanupInteraction]):
(-[WKContentView _removeDefaultGestureRecognizers]):
(-[WKContentView _addDefaultGestureRecognizers]):
(-[WKContentView _hoverGestureRecognizerChanged:]):

Modified Paths

Diff

Modified: trunk/Source/WebKit/ChangeLog (233545 => 233546)


--- trunk/Source/WebKit/ChangeLog	2018-07-05 22:20:39 UTC (rev 233545)
+++ trunk/Source/WebKit/ChangeLog	2018-07-05 22:28:17 UTC (rev 233546)
@@ -1,5 +1,20 @@
 2018-07-05  Tim Horton  <[email protected]>
 
+        Upstream hover gesture implementation
+        https://bugs.webkit.org/show_bug.cgi?id=187366
+
+        Reviewed by Wenson Hsieh.
+
+        * UIProcess/ios/WKContentViewInteraction.h:
+        * UIProcess/ios/WKContentViewInteraction.mm:
+        (-[WKContentView setupInteraction]):
+        (-[WKContentView cleanupInteraction]):
+        (-[WKContentView _removeDefaultGestureRecognizers]):
+        (-[WKContentView _addDefaultGestureRecognizers]):
+        (-[WKContentView _hoverGestureRecognizerChanged:]):
+
+2018-07-05  Tim Horton  <[email protected]>
+
         Fix some -Wdocumentation warnings in WebKit
         https://bugs.webkit.org/show_bug.cgi?id=187318
 

Modified: trunk/Source/WebKit/UIProcess/ios/WKContentViewInteraction.h (233545 => 233546)


--- trunk/Source/WebKit/UIProcess/ios/WKContentViewInteraction.h	2018-07-05 22:20:39 UTC (rev 233545)
+++ trunk/Source/WebKit/UIProcess/ios/WKContentViewInteraction.h	2018-07-05 22:28:17 UTC (rev 233546)
@@ -77,21 +77,15 @@
 class WebPageProxy;
 }
 
+@class _UIHighlightView;
+@class _UIWebHighlightLongPressGestureRecognizer;
+@class UIHoverGestureRecognizer;
+@class WebEvent;
 @class WKActionSheetAssistant;
+@class WKFocusedFormControlView;
 @class WKFormInputSession;
 @class WKInspectorNodeSearchGestureRecognizer;
-@class WebEvent;
-@class _UIHighlightView;
-@class _UIWebHighlightLongPressGestureRecognizer;
 
-#if USE(APPLE_INTERNAL_SDK)
-#import <WebKitAdditions/WKContentViewInteractionAdditionsBefore.h>
-#endif
-
-#if PLATFORM(WATCHOS)
-@class WKFocusedFormControlView;
-#endif
-
 typedef void (^UIWKAutocorrectionCompletionHandler)(UIWKAutocorrectionRects *rectsForInput);
 typedef void (^UIWKAutocorrectionContextHandler)(UIWKAutocorrectionContext *autocorrectionContext);
 typedef void (^UIWKDictationContextHandler)(NSString *selectedText, NSString *beforeText, NSString *afterText);
@@ -151,10 +145,6 @@
 
     BOOL _canSendTouchEventsAsynchronously;
 
-#if USE(APPLE_INTERNAL_SDK)
-#import <WebKitAdditions/WKContentViewInteractionAdditionsAfter.h>
-#endif
-
     RetainPtr<WKSyntheticClickTapGestureRecognizer> _singleTapGestureRecognizer;
     RetainPtr<_UIWebHighlightLongPressGestureRecognizer> _highlightLongPressGestureRecognizer;
     RetainPtr<UILongPressGestureRecognizer> _longPressGestureRecognizer;
@@ -164,6 +154,10 @@
     RetainPtr<UITapGestureRecognizer> _twoFingerSingleTapGestureRecognizer;
     RetainPtr<WKInspectorNodeSearchGestureRecognizer> _inspectorNodeSearchGestureRecognizer;
 
+#if PLATFORM(IOSMAC)
+    RetainPtr<UIHoverGestureRecognizer> _hoverGestureRecognizer;
+#endif
+
     RetainPtr<UIWKTextInteractionAssistant> _textSelectionAssistant;
     RetainPtr<UIWKSelectionAssistant> _webSelectionAssistant;
     BOOL _suppressAssistantSelectionView;

Modified: trunk/Source/WebKit/UIProcess/ios/WKContentViewInteraction.mm (233545 => 233546)


--- trunk/Source/WebKit/UIProcess/ios/WKContentViewInteraction.mm	2018-07-05 22:20:39 UTC (rev 233545)
+++ trunk/Source/WebKit/UIProcess/ios/WKContentViewInteraction.mm	2018-07-05 22:28:17 UTC (rev 233546)
@@ -105,8 +105,10 @@
 #import <WebCore/WebItemProviderPasteboard.h>
 #endif
 
-#if USE(APPLE_INTERNAL_SDK)
-#import <WebKitAdditions/WKContentViewInteractionAdditionsBefore.mm>
+#if PLATFORM(IOSMAC)
+#import "NativeWebMouseEvent.h"
+#import <UIKit/UIHoverGestureRecognizer.h>
+#import <pal/spi/ios/GraphicsServicesSPI.h>
 #endif
 
 @interface UIEvent(UIEventInternal)
@@ -617,8 +619,10 @@
     [_touchEventGestureRecognizer setDelegate:self];
     [self addGestureRecognizer:_touchEventGestureRecognizer.get()];
 
-#if USE(APPLE_INTERNAL_SDK)
-    [self _internalSetupInteraction];
+#if PLATFORM(IOSMAC)
+    _hoverGestureRecognizer = adoptNS([[UIHoverGestureRecognizer alloc] initWithTarget:self action:@selector(_hoverGestureRecognizerChanged:)]);
+    [_hoverGestureRecognizer setDelegate:self];
+    [self addGestureRecognizer:_hoverGestureRecognizer.get()];
 #endif
 
     _singleTapGestureRecognizer = adoptNS([[WKSyntheticClickTapGestureRecognizer alloc] initWithTarget:self action:@selector(_singleTapCommited:)]);
@@ -711,8 +715,9 @@
     [_touchEventGestureRecognizer setDelegate:nil];
     [self removeGestureRecognizer:_touchEventGestureRecognizer.get()];
 
-#if USE(APPLE_INTERNAL_SDK)
-    [self _internalCleanupInteraction];
+#if PLATFORM(IOSMAC)
+    [_hoverGestureRecognizer setDelegate:nil];
+    [self removeGestureRecognizer:_hoverGestureRecognizer.get()];
 #endif
 
     [_singleTapGestureRecognizer setDelegate:nil];
@@ -775,9 +780,8 @@
     [self removeGestureRecognizer:_nonBlockingDoubleTapGestureRecognizer.get()];
     [self removeGestureRecognizer:_twoFingerDoubleTapGestureRecognizer.get()];
     [self removeGestureRecognizer:_twoFingerSingleTapGestureRecognizer.get()];
-
-#if USE(APPLE_INTERNAL_SDK)
-    [self _internalRemoveDefaultGestureRecognizers];
+#if PLATFORM(IOSMAC)
+    [self removeGestureRecognizer:_hoverGestureRecognizer.get()];
 #endif
 }
 
@@ -790,9 +794,8 @@
     [self addGestureRecognizer:_nonBlockingDoubleTapGestureRecognizer.get()];
     [self addGestureRecognizer:_twoFingerDoubleTapGestureRecognizer.get()];
     [self addGestureRecognizer:_twoFingerSingleTapGestureRecognizer.get()];
-
-#if USE(APPLE_INTERNAL_SDK)
-    [self _internalAddDefaultGestureRecognizers];
+#if PLATFORM(IOSMAC)
+    [self addGestureRecognizer:_hoverGestureRecognizer.get()];
 #endif
 }
 
@@ -5657,8 +5660,31 @@
 
 #endif // PLATFORM(WATCHOS)
 
-#if USE(APPLE_INTERNAL_SDK)
-#import <WebKitAdditions/WKContentViewInteractionAdditionsAfter.mm>
+#if PLATFORM(IOSMAC)
+- (void)_hoverGestureRecognizerChanged:(UIGestureRecognizer *)gestureRecognizer
+{
+    if (!_page->isValid())
+        return;
+
+    // Make a timestamp that matches UITouch and UIEvent.
+    CFTimeInterval timestamp = GSCurrentEventTimestamp() / 1000000000.0;
+
+    CGPoint point;
+    switch (gestureRecognizer.state) {
+    case UIGestureRecognizerStateBegan:
+    case UIGestureRecognizerStateChanged:
+        point = [gestureRecognizer locationInView:self];
+        break;
+    case UIGestureRecognizerStateEnded:
+    case UIGestureRecognizerStateCancelled:
+    default:
+        point = CGPointMake(-1, -1);
+        break;
+    }
+
+    auto event = adoptNS([[::WebEvent alloc] initWithMouseEventType:WebEventMouseMoved timeStamp:timestamp location:point]);
+    _page->handleMouseEvent(NativeWebMouseEvent(event.get()));
+}
 #endif
 
 @end
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to