Title: [218504] trunk/Source/WebKit2
Revision
218504
Author
wenson_hs...@apple.com
Date
2017-06-19 13:25:50 -0700 (Mon, 19 Jun 2017)

Log Message

[iOS DnD] [WK2] Add an internal hook to change the drag lift delay
https://bugs.webkit.org/show_bug.cgi?id=173523
<rdar://problem/32224510>

Reviewed by Tim Horton.

Add a new private property on WKWebViewConfiguration, _dragLiftDelay, for changing the UIDragInteraction's lift
delay to one of three values: short, medium or long. The short setting simply uses UIKit's default drag lift
delay (at the time of writing, this is 325ms); medium and long are 500ms and 650ms, respectively.

In combination with an internal switch to toggle between lift delays, the purpose of this change is to make it
easier to choose a drag lift delay for web content that doesn't easily cause unintended dragging while panning.

* UIProcess/API/Cocoa/WKWebViewConfiguration.mm:
(toDragLiftDelay):

Converts an integer (e.g. retrieved from user defaults) to a drag lift delay type.

(-[WKWebViewConfiguration init]):
(-[WKWebViewConfiguration encodeWithCoder:]):
(-[WKWebViewConfiguration initWithCoder:]):
(-[WKWebViewConfiguration copyWithZone:]):
(-[WKWebViewConfiguration _dragLiftDelay]):

Add boilerplate plumbing for the _dragLiftDelay setting.

(-[WKWebViewConfiguration _setDragLiftDelay:]):
* UIProcess/API/Cocoa/WKWebViewConfigurationPrivate.h:

Add _dragLiftDelay to as a private property of WKWebViewConiguration.

* UIProcess/ios/WKContentViewInteraction.mm:
(-[WKContentView dragLiftDelay]):

Convert the web view configuration's _WKDragLiftDelay to an actual time interval.

(-[WKContentView setupDataInteractionDelegates]):

Modified Paths

Diff

Modified: trunk/Source/WebKit2/ChangeLog (218503 => 218504)


--- trunk/Source/WebKit2/ChangeLog	2017-06-19 20:14:54 UTC (rev 218503)
+++ trunk/Source/WebKit2/ChangeLog	2017-06-19 20:25:50 UTC (rev 218504)
@@ -1,3 +1,43 @@
+2017-06-19  Wenson Hsieh  <wenson_hs...@apple.com>
+
+        [iOS DnD] [WK2] Add an internal hook to change the drag lift delay
+        https://bugs.webkit.org/show_bug.cgi?id=173523
+        <rdar://problem/32224510>
+
+        Reviewed by Tim Horton.
+
+        Add a new private property on WKWebViewConfiguration, _dragLiftDelay, for changing the UIDragInteraction's lift
+        delay to one of three values: short, medium or long. The short setting simply uses UIKit's default drag lift
+        delay (at the time of writing, this is 325ms); medium and long are 500ms and 650ms, respectively.
+
+        In combination with an internal switch to toggle between lift delays, the purpose of this change is to make it
+        easier to choose a drag lift delay for web content that doesn't easily cause unintended dragging while panning.
+
+        * UIProcess/API/Cocoa/WKWebViewConfiguration.mm:
+        (toDragLiftDelay):
+
+        Converts an integer (e.g. retrieved from user defaults) to a drag lift delay type.
+
+        (-[WKWebViewConfiguration init]):
+        (-[WKWebViewConfiguration encodeWithCoder:]):
+        (-[WKWebViewConfiguration initWithCoder:]):
+        (-[WKWebViewConfiguration copyWithZone:]):
+        (-[WKWebViewConfiguration _dragLiftDelay]):
+
+        Add boilerplate plumbing for the _dragLiftDelay setting.
+
+        (-[WKWebViewConfiguration _setDragLiftDelay:]):
+        * UIProcess/API/Cocoa/WKWebViewConfigurationPrivate.h:
+
+        Add _dragLiftDelay to as a private property of WKWebViewConiguration.
+
+        * UIProcess/ios/WKContentViewInteraction.mm:
+        (-[WKContentView dragLiftDelay]):
+
+        Convert the web view configuration's _WKDragLiftDelay to an actual time interval.
+
+        (-[WKContentView setupDataInteractionDelegates]):
+
 2017-06-19  Konstantin Tokarev  <annu...@yandex.ru>
 
         Removed unused lambda captures from WebKit2

Modified: trunk/Source/WebKit2/UIProcess/API/Cocoa/WKWebViewConfiguration.mm (218503 => 218504)


--- trunk/Source/WebKit2/UIProcess/API/Cocoa/WKWebViewConfiguration.mm	2017-06-19 20:14:54 UTC (rev 218503)
+++ trunk/Source/WebKit2/UIProcess/API/Cocoa/WKWebViewConfiguration.mm	2017-06-19 20:25:50 UTC (rev 218504)
@@ -88,6 +88,19 @@
     T m_value;
 };
 
+#if PLATFORM(IOS)
+
+static _WKDragLiftDelay toDragLiftDelay(NSUInteger value)
+{
+    if (value == _WKDragLiftDelayMedium)
+        return _WKDragLiftDelayMedium;
+    if (value == _WKDragLiftDelayLong)
+        return _WKDragLiftDelayLong;
+    return _WKDragLiftDelayShort;
+}
+
+#endif
+
 @implementation WKWebViewConfiguration {
     LazyInitialized<RetainPtr<WKProcessPool>> _processPool;
     LazyInitialized<RetainPtr<WKPreferences>> _preferences;
@@ -115,6 +128,7 @@
     BOOL _inlineMediaPlaybackRequiresPlaysInlineAttribute;
     BOOL _allowsInlineMediaPlaybackAfterFullscreen;
     BOOL _allowsBlockSelection;
+    _WKDragLiftDelay _dragLiftDelay;
 #endif
 
     BOOL _invisibleAutoplayNotPermitted;
@@ -199,6 +213,7 @@
 #if PLATFORM(IOS)
     _selectionGranularity = WKSelectionGranularityDynamic;
     _allowsBlockSelection = [[NSUserDefaults standardUserDefaults] boolForKey:@"WebKitDebugAllowBlockSelection"];
+    _dragLiftDelay = toDragLiftDelay([[NSUserDefaults standardUserDefaults] integerForKey:@"WebKitDebugDragLiftDelay"]);
 #endif
 
     _mediaContentTypesRequiringHardwareSupport = Settings::defaultMediaContentTypesRequiringHardwareSupport();
@@ -232,6 +247,7 @@
     [coder encodeInteger:self.selectionGranularity forKey:@"selectionGranularity"];
     [coder encodeBool:self.allowsPictureInPictureMediaPlayback forKey:@"allowsPictureInPictureMediaPlayback"];
     [coder encodeBool:self.ignoresViewportScaleLimits forKey:@"ignoresViewportScaleLimits"];
+    [coder encodeInteger:self._dragLiftDelay forKey:@"dragLiftDelay"];
 #else
     [coder encodeInteger:self.userInterfaceDirectionPolicy forKey:@"userInterfaceDirectionPolicy"];
 #endif
@@ -259,6 +275,7 @@
     self.selectionGranularity = static_cast<WKSelectionGranularity>([coder decodeIntegerForKey:@"selectionGranularity"]);
     self.allowsPictureInPictureMediaPlayback = [coder decodeBoolForKey:@"allowsPictureInPictureMediaPlayback"];
     self.ignoresViewportScaleLimits = [coder decodeBoolForKey:@"ignoresViewportScaleLimits"];
+    self._dragLiftDelay = toDragLiftDelay([coder decodeIntegerForKey:@"dragLiftDelay"]);
 #else
     auto userInterfaceDirectionPolicyCandidate = static_cast<WKUserInterfaceDirectionPolicy>([coder decodeIntegerForKey:@"userInterfaceDirectionPolicy"]);
     if (userInterfaceDirectionPolicyCandidate == WKUserInterfaceDirectionPolicyContent || userInterfaceDirectionPolicyCandidate == WKUserInterfaceDirectionPolicySystem)
@@ -313,6 +330,7 @@
     configuration->_selectionGranularity = self->_selectionGranularity;
     configuration->_allowsBlockSelection = self->_allowsBlockSelection;
     configuration->_ignoresViewportScaleLimits = self->_ignoresViewportScaleLimits;
+    configuration->_dragLiftDelay = self->_dragLiftDelay;
 #endif
 #if PLATFORM(MAC)
     configuration->_userInterfaceDirectionPolicy = self->_userInterfaceDirectionPolicy;
@@ -644,6 +662,16 @@
 {
     _allowsBlockSelection = allowsBlockSelection;
 }
+
+- (_WKDragLiftDelay)_dragLiftDelay
+{
+    return _dragLiftDelay;
+}
+
+- (void)_setDragLiftDelay:(_WKDragLiftDelay)dragLiftDelay
+{
+    _dragLiftDelay = dragLiftDelay;
+}
 #endif // PLATFORM(IOS)
 
 - (BOOL)_invisibleAutoplayNotPermitted

Modified: trunk/Source/WebKit2/UIProcess/API/Cocoa/WKWebViewConfigurationPrivate.h (218503 => 218504)


--- trunk/Source/WebKit2/UIProcess/API/Cocoa/WKWebViewConfigurationPrivate.h	2017-06-19 20:14:54 UTC (rev 218503)
+++ trunk/Source/WebKit2/UIProcess/API/Cocoa/WKWebViewConfigurationPrivate.h	2017-06-19 20:25:50 UTC (rev 218504)
@@ -27,6 +27,14 @@
 
 #if WK_API_ENABLED
 
+#if TARGET_OS_IPHONE
+typedef NS_ENUM(NSUInteger, _WKDragLiftDelay) {
+    _WKDragLiftDelayShort = 0,
+    _WKDragLiftDelayMedium,
+    _WKDragLiftDelayLong
+} WK_API_AVAILABLE(ios(WK_IOS_TBA));
+#endif
+
 @class WKWebView;
 @class _WKVisitedLinkStore;
 @class _WKWebsiteDataStore;
@@ -64,6 +72,7 @@
 @property (nonatomic, setter=_setInlineMediaPlaybackRequiresPlaysInlineAttribute:) BOOL _inlineMediaPlaybackRequiresPlaysInlineAttribute WK_API_AVAILABLE(ios(10.0));
 @property (nonatomic, setter=_setAllowsInlineMediaPlaybackAfterFullscreen:) BOOL _allowsInlineMediaPlaybackAfterFullscreen  WK_API_AVAILABLE(ios(10.0));
 @property (nonatomic, setter=_setAllowsBlockSelection:) BOOL _allowsBlockSelection WK_API_AVAILABLE(ios(WK_IOS_TBA));
+@property (nonatomic, setter=_setDragLiftDelay:) _WKDragLiftDelay _dragLiftDelay WK_API_AVAILABLE(ios(WK_IOS_TBA));
 #else
 @property (nonatomic, setter=_setShowsURLsInToolTips:) BOOL _showsURLsInToolTips WK_API_AVAILABLE(macosx(10.12));
 @property (nonatomic, setter=_setServiceControlsEnabled:) BOOL _serviceControlsEnabled WK_API_AVAILABLE(macosx(10.12));

Modified: trunk/Source/WebKit2/UIProcess/ios/WKContentViewInteraction.mm (218503 => 218504)


--- trunk/Source/WebKit2/UIProcess/ios/WKContentViewInteraction.mm	2017-06-19 20:14:54 UTC (rev 218503)
+++ trunk/Source/WebKit2/UIProcess/ios/WKContentViewInteraction.mm	2017-06-19 20:25:50 UTC (rev 218504)
@@ -50,6 +50,7 @@
 #import "WKPreviewElementInfoInternal.h"
 #import "WKUIDelegatePrivate.h"
 #import "WKWebViewConfiguration.h"
+#import "WKWebViewConfigurationPrivate.h"
 #import "WKWebViewInternal.h"
 #import "WKWebViewPrivate.h"
 #import "WebEvent.h"
@@ -4168,6 +4169,18 @@
 
 #if ENABLE(DRAG_SUPPORT)
 
+- (NSTimeInterval)dragLiftDelay
+{
+    static const NSTimeInterval mediumDragLiftDelay = 0.5;
+    static const NSTimeInterval longDragLiftDelay = 0.65;
+    auto dragLiftDelay = _webView.configuration._dragLiftDelay;
+    if (dragLiftDelay == _WKDragLiftDelayMedium)
+        return mediumDragLiftDelay;
+    if (dragLiftDelay == _WKDragLiftDelayLong)
+        return longDragLiftDelay;
+    return _UIDragInteractionDefaultLiftDelay();
+}
+
 static NSTimeInterval longPressActionDelayAfterLift()
 {
     return _UIDragInteractionDefaultCompetingLongPressDelay() - _UIDragInteractionDefaultLiftDelay();
@@ -4182,6 +4195,7 @@
 {
     _dataInteraction = adoptNS([[UIDragInteraction alloc] initWithDelegate:self]);
     _dataOperation = adoptNS([[UIDropInteraction alloc] initWithDelegate:self]);
+    [_dataInteraction _setLiftDelay:self.dragLiftDelay];
     [self addInteraction:_dataInteraction.get()];
     [self addInteraction:_dataOperation.get()];
 }
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to