- Revision
- 261978
- Author
- [email protected]
- Date
- 2020-05-20 18:19:54 -0700 (Wed, 20 May 2020)
Log Message
WKMouseGestureRecognizer should be implemented without using UIKit internals
https://bugs.webkit.org/show_bug.cgi?id=212173
<rdar://problem/61163726>
Reviewed by Wenson Hsieh.
Source/WebKit:
* Platform/spi/ios/UIKitSPI.h:
* UIProcess/ios/WKContentViewInteraction.mm:
(-[WKContentView gestureRecognizer:shouldReceiveTouch:]):
* UIProcess/ios/WKMouseGestureRecognizer.h:
* UIProcess/ios/WKMouseGestureRecognizer.mm:
(-[WKMouseGestureRecognizer _hoverEntered:withEvent:]):
(-[WKMouseGestureRecognizer initWithTarget:action:]): Deleted.
(-[WKMouseGestureRecognizer setView:]): Deleted.
(-[WKMouseGestureRecognizer _wantsHoverEvents]): Deleted.
(-[WKMouseGestureRecognizer canPreventGestureRecognizer:]): Deleted.
(-[WKMouseGestureRecognizer canBePreventedByGestureRecognizer:]): Deleted.
Reimplement WKMouseGestureRecognizer as a UIHoverGestureRecognizer subclass,
so we can decouple ourselves a bit from UIKit internals.
Source/WTF:
* wtf/PlatformHave.h:
Modified Paths
Diff
Modified: trunk/Source/WTF/ChangeLog (261977 => 261978)
--- trunk/Source/WTF/ChangeLog 2020-05-21 00:52:35 UTC (rev 261977)
+++ trunk/Source/WTF/ChangeLog 2020-05-21 01:19:54 UTC (rev 261978)
@@ -1,3 +1,13 @@
+2020-05-20 Tim Horton <[email protected]>
+
+ WKMouseGestureRecognizer should be implemented without using UIKit internals
+ https://bugs.webkit.org/show_bug.cgi?id=212173
+ <rdar://problem/61163726>
+
+ Reviewed by Wenson Hsieh.
+
+ * wtf/PlatformHave.h:
+
2020-05-20 Alex Christensen <[email protected]>
Remove implicit URL->String conversion operators
Modified: trunk/Source/WTF/wtf/PlatformHave.h (261977 => 261978)
--- trunk/Source/WTF/wtf/PlatformHave.h 2020-05-21 00:52:35 UTC (rev 261977)
+++ trunk/Source/WTF/wtf/PlatformHave.h 2020-05-21 01:19:54 UTC (rev 261978)
@@ -440,6 +440,7 @@
#if (PLATFORM(IOS) && __IPHONE_OS_VERSION_MIN_REQUIRED >= 130400)
#define HAVE_UI_CURSOR_INTERACTION 1
+#define HAVE_UI_GESTURE_RECOGNIZER_MODIFIER_FLAGS 1
#endif
#if (PLATFORM(IOS) && __IPHONE_OS_VERSION_MIN_REQUIRED >= 130400) || PLATFORM(MACCATALYST)
Modified: trunk/Source/WebKit/ChangeLog (261977 => 261978)
--- trunk/Source/WebKit/ChangeLog 2020-05-21 00:52:35 UTC (rev 261977)
+++ trunk/Source/WebKit/ChangeLog 2020-05-21 01:19:54 UTC (rev 261978)
@@ -1,3 +1,25 @@
+2020-05-20 Tim Horton <[email protected]>
+
+ WKMouseGestureRecognizer should be implemented without using UIKit internals
+ https://bugs.webkit.org/show_bug.cgi?id=212173
+ <rdar://problem/61163726>
+
+ Reviewed by Wenson Hsieh.
+
+ * Platform/spi/ios/UIKitSPI.h:
+ * UIProcess/ios/WKContentViewInteraction.mm:
+ (-[WKContentView gestureRecognizer:shouldReceiveTouch:]):
+ * UIProcess/ios/WKMouseGestureRecognizer.h:
+ * UIProcess/ios/WKMouseGestureRecognizer.mm:
+ (-[WKMouseGestureRecognizer _hoverEntered:withEvent:]):
+ (-[WKMouseGestureRecognizer initWithTarget:action:]): Deleted.
+ (-[WKMouseGestureRecognizer setView:]): Deleted.
+ (-[WKMouseGestureRecognizer _wantsHoverEvents]): Deleted.
+ (-[WKMouseGestureRecognizer canPreventGestureRecognizer:]): Deleted.
+ (-[WKMouseGestureRecognizer canBePreventedByGestureRecognizer:]): Deleted.
+ Reimplement WKMouseGestureRecognizer as a UIHoverGestureRecognizer subclass,
+ so we can decouple ourselves a bit from UIKit internals.
+
2020-05-20 Per Arne Vollan <[email protected]>
[iOS] Fix message filter sandbox violation
Modified: trunk/Source/WebKit/Platform/spi/ios/UIKitSPI.h (261977 => 261978)
--- trunk/Source/WebKit/Platform/spi/ios/UIKitSPI.h 2020-05-21 00:52:35 UTC (rev 261977)
+++ trunk/Source/WebKit/Platform/spi/ios/UIKitSPI.h 2020-05-21 01:19:54 UTC (rev 261978)
@@ -133,13 +133,6 @@
#import <UIKit/_UICursorStyle_Private.h>
#endif
-#if __has_include(<UIKit/UIHoverEvent_Private.h>)
-#import <UIKit/UIHoverEvent_Private.h>
-#else
-@interface UIHoverEvent : UIEvent
-@end
-#endif
-
#else // USE(APPLE_INTERNAL_SDK)
#if ENABLE(DRAG_SUPPORT)
@@ -427,7 +420,9 @@
#if PLATFORM(IOS) && !defined(__IPHONE_13_4)
@property (nonatomic, readonly, getter=_modifierFlags) UIKeyModifierFlags modifierFlags;
#endif
+@end
+@protocol _UIHoverEventRespondable <NSObject>
- (void)_hoverEntered:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event;
- (void)_hoverMoved:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event;
- (void)_hoverExited:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event;
@@ -1214,13 +1209,6 @@
+ (instancetype)styleWithCursor:(_UICursor *)cursor constrainedAxes:(UIAxis)axes;
@end
-@interface UITouch ()
-- (BOOL)_isPointerTouch;
-@end
-
-@interface UIHoverEvent : UIEvent
-@end
-
#endif // USE(APPLE_INTERNAL_SDK)
#define UIWKDocumentRequestMarkedTextRects (1 << 5)
@@ -1295,25 +1283,6 @@
- (void)_updateSafeAreaInsets;
@end
-@interface UIGestureRecognizer (IPI)
-- (BOOL)_paused;
-@property (nonatomic) UIView *view;
-@property (nonatomic, assign, getter=_acceptsFailureRequirements, setter=_setAcceptsFailureRequiments:) BOOL _acceptsFailureRequirements;
-@property (nonatomic, readonly, getter=_modifierFlags) UIKeyModifierFlags modifierFlags;
-@end
-
-@interface UIHoverEvent (IPI)
-#if PLATFORM(IOS) && __IPHONE_OS_VERSION_MAX_ALLOWED < 140000 || PLATFORM(MACCATALYST)
-- (void)setNeedsHitTestReset;
-#else
-- (void)setNeedsHitTestResetForWindow:(UIWindow *)window;
-#endif
-@end
-
-@interface UIApplication (IPI)
-- (UIHoverEvent *)_hoverEventForWindow:(UIWindow *)window;
-@end
-
@interface UIScrollView (IPI)
- (CGFloat)_rubberBandOffsetForOffset:(CGFloat)newOffset maxOffset:(CGFloat)maxOffset minOffset:(CGFloat)minOffset range:(CGFloat)range outside:(BOOL *)outside;
- (void)_adjustForAutomaticKeyboardInfo:(NSDictionary *)info animated:(BOOL)animated lastAdjustment:(CGFloat*)lastAdjustment;
Modified: trunk/Source/WebKit/UIProcess/ios/WKContentViewInteraction.mm (261977 => 261978)
--- trunk/Source/WebKit/UIProcess/ios/WKContentViewInteraction.mm 2020-05-21 00:52:35 UTC (rev 261977)
+++ trunk/Source/WebKit/UIProcess/ios/WKContentViewInteraction.mm 2020-05-21 01:19:54 UTC (rev 261978)
@@ -1448,7 +1448,11 @@
inline static UIKeyModifierFlags gestureRecognizerModifierFlags(UIGestureRecognizer *recognizer)
{
+#if HAVE(UI_GESTURE_RECOGNIZER_MODIFIER_FLAGS)
+ return recognizer.modifierFlags;
+#else
return [recognizer respondsToSelector:@selector(_modifierFlags)] ? [recognizer _modifierFlags] : 0;
+#endif
}
- (void)_webTouchEventsRecognized:(UIWebTouchEventsGestureRecognizer *)gestureRecognizer
@@ -1531,7 +1535,7 @@
return NO;
if (gestureRecognizer == _doubleTapGestureRecognizer || gestureRecognizer == _nonBlockingDoubleTapGestureRecognizer)
- return !touch._isPointerTouch;
+ return touch.type != UITouchTypeIndirectPointer;
#endif
if (gestureRecognizer == _touchActionLeftSwipeGestureRecognizer || gestureRecognizer == _touchActionRightSwipeGestureRecognizer || gestureRecognizer == _touchActionUpSwipeGestureRecognizer || gestureRecognizer == _touchActionDownSwipeGestureRecognizer) {
Modified: trunk/Source/WebKit/UIProcess/ios/WKMouseGestureRecognizer.h (261977 => 261978)
--- trunk/Source/WebKit/UIProcess/ios/WKMouseGestureRecognizer.h 2020-05-21 00:52:35 UTC (rev 261977)
+++ trunk/Source/WebKit/UIProcess/ios/WKMouseGestureRecognizer.h 2020-05-21 01:19:54 UTC (rev 261978)
@@ -25,10 +25,10 @@
#if HAVE(UIKIT_WITH_MOUSE_SUPPORT)
-#import <UIKit/UIGestureRecognizer.h>
+#import <UIKit/UIHoverGestureRecognizer.h>
#import "NativeWebMouseEvent.h"
-@interface WKMouseGestureRecognizer : UIGestureRecognizer
+@interface WKMouseGestureRecognizer : UIHoverGestureRecognizer
- (WTF::Optional<CGPoint>)lastMouseLocation;
- (WebKit::NativeWebMouseEvent *)lastMouseEvent;
Modified: trunk/Source/WebKit/UIProcess/ios/WKMouseGestureRecognizer.mm (261977 => 261978)
--- trunk/Source/WebKit/UIProcess/ios/WKMouseGestureRecognizer.mm 2020-05-21 00:52:35 UTC (rev 261977)
+++ trunk/Source/WebKit/UIProcess/ios/WKMouseGestureRecognizer.mm 2020-05-21 01:19:54 UTC (rev 261978)
@@ -50,8 +50,11 @@
return modifiers;
}
+@interface UIHoverGestureRecognizer () <_UIHoverEventRespondable>
+@end
+
@implementation WKMouseGestureRecognizer {
- RetainPtr<UIHoverEvent> _currentHoverEvent;
+ RetainPtr<UIEvent> _currentHoverEvent;
RetainPtr<UITouch> _currentTouch;
BOOL _touching;
@@ -61,17 +64,6 @@
Optional<UIEventButtonMask> _pressedButtonMask;
}
-- (instancetype)initWithTarget:(id)target action:(SEL)action
-{
- self = [super initWithTarget:target action:action];
- if (!self)
- return nil;
-
- [self _setAcceptsFailureRequiments:NO];
-
- return self;
-}
-
- (void)setEnabled:(BOOL)enabled
{
[super setEnabled:enabled];
@@ -86,23 +78,6 @@
}
}
-- (void)setView:(UIView *)view
-{
- if (view == self.view)
- return;
-
- [super setView:view];
-
- if (view.window) {
- UIHoverEvent *hoverEvent = [UIApp _hoverEventForWindow:view.window];
-#if PLATFORM(IOS) && __IPHONE_OS_VERSION_MAX_ALLOWED < 140000 || PLATFORM(MACCATALYST)
- [hoverEvent setNeedsHitTestReset];
-#else
- [hoverEvent setNeedsHitTestResetForWindow:view.window];
-#endif
- }
-}
-
- (WebKit::NativeWebMouseEvent *)lastMouseEvent
{
return _lastEvent.get();
@@ -118,13 +93,6 @@
return _currentTouch.get();
}
-ALLOW_DEPRECATED_IMPLEMENTATIONS_BEGIN
-- (BOOL)_wantsHoverEvents
-{
- return YES;
-}
-ALLOW_DEPRECATED_IMPLEMENTATIONS_END
-
- (void)reset
{
[super reset];
@@ -211,7 +179,7 @@
_lastEvent = [self createMouseEventWithType:WebKit::WebEvent::MouseMove];
if (_currentHoverEvent == nil && touches.count == 1 && [event isKindOfClass:NSClassFromString(@"UIHoverEvent")]) {
- _currentHoverEvent = (UIHoverEvent *)event;
+ _currentHoverEvent = event;
_currentTouch = touches.anyObject;
_lastLocation = [self locationInView:self.view];
self.state = UIGestureRecognizerStateBegan;
@@ -263,16 +231,6 @@
return [_currentTouch locationInView:view];
}
-- (BOOL)canPreventGestureRecognizer:(UIGestureRecognizer *)preventedGestureRecognizer
-{
- return NO;
-}
-
-- (BOOL)canBePreventedByGestureRecognizer:(UIGestureRecognizer *)preventingGestureRecognizer
-{
- return NO;
-}
-
@end
#endif