Changeset 250780 in webkit


Ignore:
Timestamp:
Oct 7, 2019 11:48:48 AM (5 years ago)
Author:
dino@apple.com
Message:

Provide options for DTTZ to happen in more situations
https://bugs.webkit.org/show_bug.cgi?id=202634
<rdar://problem/55732762>

Reviewed by Antoine Quint.

Add two options that can be enabled to trigger double tap zooming
in more places.

Firstly, an option to keep listening for a double-tap-to-zoom if the
first tap found a click handler on the body or document element. The
tap will still be dispatched. This is probably the most common case
for disabling a DTTZ.

Secondly, an option to always keep listening for a double-tap-to-zoom,
even if there was a clickable (non-root) element under the first tap.

  • Shared/WebPreferences.yaml: Add ZoomOnDoubleTapWhenRoot and AlwaysZoomOnDoubleTap.
  • UIProcess/PageClient.h: The message from the WebProcess now tells the UIProcess if

the tapped element was a root-level (document or body).

  • UIProcess/WebPageProxy.h:
  • UIProcess/WebPageProxy.messages.in:
  • UIProcess/ios/PageClientImplIOS.h:
  • UIProcess/ios/PageClientImplIOS.mm:

(WebKit::PageClientImpl::handleSmartMagnificationInformationForPotentialTap):

  • UIProcess/ios/WKContentViewInteraction.h:
  • UIProcess/ios/WKContentViewInteraction.mm:

(-[WKContentView _endPotentialTapAndEnableDoubleTapGesturesIfNecessary]):
(-[WKContentView _handleSmartMagnificationInformationForPotentialTap:renderRect:fitEntireRect:viewportMinimumScale:viewportMaximumScale:nodeIsRootLevel:]):
Handle the two new options.

  • UIProcess/ios/WebPageProxyIOS.mm:

(WebKit::WebPageProxy::handleSmartMagnificationInformationForPotentialTap):

  • WebProcess/WebPage/ios/WebPageIOS.mm:

(WebKit::WebPage::potentialTapAtPosition): Check if the tap was on a root-level element.

Location:
trunk/Source/WebKit
Files:
11 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebKit/ChangeLog

    r250779 r250780  
     12019-10-07  Dean Jackson  <dino@apple.com>
     2
     3        Provide options for DTTZ to happen in more situations
     4        https://bugs.webkit.org/show_bug.cgi?id=202634
     5        <rdar://problem/55732762>
     6
     7        Reviewed by Antoine Quint.
     8
     9        Add two options that can be enabled to trigger double tap zooming
     10        in more places.
     11
     12        Firstly, an option to keep listening for a double-tap-to-zoom if the
     13        first tap found a click handler on the body or document element. The
     14        tap will still be dispatched. This is probably the most common case
     15        for disabling a DTTZ.
     16
     17        Secondly, an option to always keep listening for a double-tap-to-zoom,
     18        even if there was a clickable (non-root) element under the first tap.
     19
     20        * Shared/WebPreferences.yaml: Add ZoomOnDoubleTapWhenRoot and AlwaysZoomOnDoubleTap.
     21        * UIProcess/PageClient.h: The message from the WebProcess now tells the UIProcess if
     22        the tapped element was a root-level (document or body).
     23        * UIProcess/WebPageProxy.h:
     24        * UIProcess/WebPageProxy.messages.in:
     25        * UIProcess/ios/PageClientImplIOS.h:
     26        * UIProcess/ios/PageClientImplIOS.mm:
     27        (WebKit::PageClientImpl::handleSmartMagnificationInformationForPotentialTap):
     28        * UIProcess/ios/WKContentViewInteraction.h:
     29        * UIProcess/ios/WKContentViewInteraction.mm:
     30        (-[WKContentView _endPotentialTapAndEnableDoubleTapGesturesIfNecessary]):
     31        (-[WKContentView _handleSmartMagnificationInformationForPotentialTap:renderRect:fitEntireRect:viewportMinimumScale:viewportMaximumScale:nodeIsRootLevel:]):
     32        Handle the two new options.
     33
     34        * UIProcess/ios/WebPageProxyIOS.mm:
     35        (WebKit::WebPageProxy::handleSmartMagnificationInformationForPotentialTap):
     36        * WebProcess/WebPage/ios/WebPageIOS.mm:
     37        (WebKit::WebPage::potentialTapAtPosition): Check if the tap was on a root-level element.
     38
    1392019-10-07  Matt Mokary  <mmokary@apple.com>
    240
  • trunk/Source/WebKit/Shared/WebPreferences.yaml

    r250755 r250780  
    15731573  defaultValue: DEFAULT_PREFER_FASTER_CLICK_OVER_DOUBLE_TAP
    15741574  condition: PLATFORM(IOS_FAMILY)
    1575   humanReadableName: "Use fast clicks before double tap"
     1575  humanReadableName: "Fast clicks beat DTTZ"
    15761576  humanReadableDescription: "Prefer a faster click over a double tap"
     1577  webcoreBinding: none
     1578  category: internal
     1579
     1580ZoomOnDoubleTapWhenRoot:
     1581  type: bool
     1582  defaultValue: false
     1583  condition: PLATFORM(IOS_FAMILY)
     1584  humanReadableName: "DTTZ also when root"
     1585  humanReadableDescription: "Double taps zoom, even if we dispatched a click on the root nodes"
     1586  webcoreBinding: none
     1587  category: internal
     1588
     1589AlwaysZoomOnDoubleTap:
     1590  type: bool
     1591  defaultValue: false
     1592  condition: PLATFORM(IOS_FAMILY)
     1593  humanReadableName: "DTTZ always"
     1594  humanReadableDescription: "Double taps zoom, even if we dispatched a click anywhere"
    15771595  webcoreBinding: none
    15781596  category: internal
  • trunk/Source/WebKit/UIProcess/PageClient.h

    r250645 r250780  
    397397    virtual void showPlaybackTargetPicker(bool hasVideo, const WebCore::IntRect& elementRect, WebCore::RouteSharingPolicy, const String&) = 0;
    398398    virtual void disableDoubleTapGesturesDuringTapIfNecessary(uint64_t requestID) = 0;
    399     virtual void handleSmartMagnificationInformationForPotentialTap(uint64_t requestID, const WebCore::FloatRect& renderRect, bool fitEntireRect, double viewportMinimumScale, double viewportMaximumScale) = 0;
     399    virtual void handleSmartMagnificationInformationForPotentialTap(uint64_t requestID, const WebCore::FloatRect& renderRect, bool fitEntireRect, double viewportMinimumScale, double viewportMaximumScale, bool nodeIsRootLevel) = 0;
    400400    virtual double minimumZoomScale() const = 0;
    401401    virtual WebCore::FloatRect documentRect() const = 0;
  • trunk/Source/WebKit/UIProcess/WebPageProxy.h

    r250755 r250780  
    721721    void didCompleteSyntheticClick();
    722722    void disableDoubleTapGesturesDuringTapIfNecessary(uint64_t requestID);
    723     void handleSmartMagnificationInformationForPotentialTap(uint64_t requestID, const WebCore::FloatRect& renderRect, bool fitEntireRect, double viewportMinimumScale, double viewportMaximumScale);
     723    void handleSmartMagnificationInformationForPotentialTap(uint64_t requestID, const WebCore::FloatRect& renderRect, bool fitEntireRect, double viewportMinimumScale, double viewportMaximumScale, bool nodeIsRootLevel);
    724724    void contentSizeCategoryDidChange(const String& contentSizeCategory);
    725725    void getSelectionContext(WTF::Function<void(const String&, const String&, const String&, CallbackBase::Error)>&&);
  • trunk/Source/WebKit/UIProcess/WebPageProxy.messages.in

    r249739 r250780  
    196196    DidCompleteSyntheticClick()
    197197    DisableDoubleTapGesturesDuringTapIfNecessary(uint64_t requestID)
    198     HandleSmartMagnificationInformationForPotentialTap(uint64_t requestID, WebCore::FloatRect renderRect, bool fitEntireRect, double viewportMinimumScale, double viewportMaximumScale)
     198    HandleSmartMagnificationInformationForPotentialTap(uint64_t requestID, WebCore::FloatRect renderRect, bool fitEntireRect, double viewportMinimumScale, double viewportMaximumScale, bool nodeIsRootLevel)
    199199    SelectionRectsCallback(Vector<WebCore::SelectionRect> selectionRects, WebKit::CallbackID callbackID);
    200200#endif
  • trunk/Source/WebKit/UIProcess/ios/PageClientImplIOS.h

    r249051 r250780  
    165165   
    166166    void disableDoubleTapGesturesDuringTapIfNecessary(uint64_t requestID) override;
    167     void handleSmartMagnificationInformationForPotentialTap(uint64_t requestID, const WebCore::FloatRect& renderRect, bool fitEntireRect, double viewportMinimumScale, double viewportMaximumScale) override;
     167    void handleSmartMagnificationInformationForPotentialTap(uint64_t requestID, const WebCore::FloatRect& renderRect, bool fitEntireRect, double viewportMinimumScale, double viewportMaximumScale, bool nodeIsRootLevel) override;
    168168
    169169    double minimumZoomScale() const override;
  • trunk/Source/WebKit/UIProcess/ios/PageClientImplIOS.mm

    r250093 r250780  
    246246}
    247247
    248 void PageClientImpl::handleSmartMagnificationInformationForPotentialTap(uint64_t requestID, const WebCore::FloatRect& renderRect, bool fitEntireRect, double viewportMinimumScale, double viewportMaximumScale)
    249 {
    250     [m_contentView _handleSmartMagnificationInformationForPotentialTap:requestID renderRect:renderRect fitEntireRect:fitEntireRect viewportMinimumScale:viewportMinimumScale viewportMaximumScale:viewportMaximumScale];
     248void PageClientImpl::handleSmartMagnificationInformationForPotentialTap(uint64_t requestID, const WebCore::FloatRect& renderRect, bool fitEntireRect, double viewportMinimumScale, double viewportMaximumScale, bool nodeIsRootLevel)
     249{
     250    [m_contentView _handleSmartMagnificationInformationForPotentialTap:requestID renderRect:renderRect fitEntireRect:fitEntireRect viewportMinimumScale:viewportMinimumScale viewportMaximumScale:viewportMaximumScale nodeIsRootLevel:nodeIsRootLevel];
    251251}
    252252
  • trunk/Source/WebKit/UIProcess/ios/WKContentViewInteraction.h

    r250345 r250780  
    469469- (BOOL)_mayDisableDoubleTapGesturesDuringSingleTap;
    470470- (void)_disableDoubleTapGesturesDuringTapIfNecessary:(uint64_t)requestID;
    471 - (void)_handleSmartMagnificationInformationForPotentialTap:(uint64_t)requestID renderRect:(const WebCore::FloatRect&)renderRect fitEntireRect:(BOOL)fitEntireRect viewportMinimumScale:(double)viewportMinimumScale viewportMaximumScale:(double)viewportMaximumScale;
     471- (void)_handleSmartMagnificationInformationForPotentialTap:(uint64_t)requestID renderRect:(const WebCore::FloatRect&)renderRect fitEntireRect:(BOOL)fitEntireRect viewportMinimumScale:(double)viewportMinimumScale viewportMaximumScale:(double)viewportMaximumScale nodeIsRootLevel:(BOOL)nodeIsRootLevel;
    472472- (void)_elementDidFocus:(const WebKit::FocusedElementInformation&)information userIsInteracting:(BOOL)userIsInteracting blurPreviousNode:(BOOL)blurPreviousNode activityStateChanges:(OptionSet<WebCore::ActivityState::Flag>)activityStateChanges userObject:(NSObject <NSSecureCoding> *)userObject;
    473473- (void)_updateInputContextAfterBlurringAndRefocusingElement;
  • trunk/Source/WebKit/UIProcess/ios/WKContentViewInteraction.mm

    r250755 r250780  
    17231723}
    17241724
    1725 - (void)_handleSmartMagnificationInformationForPotentialTap:(uint64_t)requestID renderRect:(const WebCore::FloatRect&)renderRect fitEntireRect:(BOOL)fitEntireRect viewportMinimumScale:(double)viewportMinimumScale viewportMaximumScale:(double)viewportMaximumScale
    1726 {
    1727     ASSERT(_page->preferences().fasterClicksEnabled());
     1725- (void)_handleSmartMagnificationInformationForPotentialTap:(uint64_t)requestID renderRect:(const WebCore::FloatRect&)renderRect fitEntireRect:(BOOL)fitEntireRect viewportMinimumScale:(double)viewportMinimumScale viewportMaximumScale:(double)viewportMaximumScale nodeIsRootLevel:(BOOL)nodeIsRootLevel
     1726{
     1727    const auto& preferences = _page->preferences();
     1728
     1729    ASSERT(preferences.fasterClicksEnabled());
    17281730    if (!_potentialTapInProgress)
    17291731        return;
    17301732
    1731     if (_page->preferences().preferFasterClickOverDoubleTap() && _page->preferFasterClickOverDoubleTap()) {
     1733    // We check both the system preference and the page preference, because we only want this
     1734    // to apply in "desktop" mode.
     1735    if (preferences.preferFasterClickOverDoubleTap() && _page->preferFasterClickOverDoubleTap()) {
    17321736        RELEASE_LOG(ViewGestures, "Potential tap found an element and fast taps are preferred. Trigger click. (%p)", self);
     1737        if (preferences.zoomOnDoubleTapWhenRoot() && nodeIsRootLevel) {
     1738            RELEASE_LOG(ViewGestures, "The click handler was on a root-level element, so don't disable double-tap. (%p)", self);
     1739            return;
     1740        }
     1741
     1742        if (preferences.alwaysZoomOnDoubleTap()) {
     1743            RELEASE_LOG(ViewGestures, "DTTZ is forced on, so don't disable double-tap. (%p)", self);
     1744            return;
     1745        }
     1746
     1747        RELEASE_LOG(ViewGestures, "Give preference to click by disabling double-tap. (%p)", self);
    17331748        [self _setDoubleTapGesturesEnabled:NO];
    17341749        return;
     
    25362551- (void)_endPotentialTapAndEnableDoubleTapGesturesIfNecessary
    25372552{
    2538     if (_webView._allowsDoubleTapGestures)
     2553    if (_webView._allowsDoubleTapGestures) {
     2554        RELEASE_LOG(ViewGestures, "ending potential tap - double taps are back. (%p)", self);
     2555
    25392556        [self _setDoubleTapGesturesEnabled:YES];
     2557    }
     2558
     2559    RELEASE_LOG(ViewGestures, "Ending potential tap. (%p)", self);
    25402560
    25412561    _potentialTapInProgress = NO;
  • trunk/Source/WebKit/UIProcess/ios/WebPageProxyIOS.mm

    r250755 r250780  
    10831083}
    10841084
    1085 void WebPageProxy::handleSmartMagnificationInformationForPotentialTap(uint64_t requestID, const WebCore::FloatRect& renderRect, bool fitEntireRect, double viewportMinimumScale, double viewportMaximumScale)
    1086 {
    1087     pageClient().handleSmartMagnificationInformationForPotentialTap(requestID, renderRect, fitEntireRect, viewportMinimumScale, viewportMaximumScale);
     1085void WebPageProxy::handleSmartMagnificationInformationForPotentialTap(uint64_t requestID, const WebCore::FloatRect& renderRect, bool fitEntireRect, double viewportMinimumScale, double viewportMaximumScale, bool nodeIsRootLevel)
     1086{
     1087    pageClient().handleSmartMagnificationInformationForPotentialTap(requestID, renderRect, fitEntireRect, viewportMinimumScale, viewportMaximumScale, nodeIsRootLevel);
    10881088}
    10891089
  • trunk/Source/WebKit/WebProcess/WebPage/ios/WebPageIOS.mm

    r250642 r250780  
    10931093
    10941094        m_viewGestureGeometryCollector->computeZoomInformationForNode(*m_potentialTapNode, origin, renderRect, fitEntireRect, viewportMinimumScale, viewportMaximumScale);
    1095         send(Messages::WebPageProxy::HandleSmartMagnificationInformationForPotentialTap(requestID, renderRect, fitEntireRect, viewportMinimumScale, viewportMaximumScale));
     1095
     1096        bool nodeIsRootLevel = is<WebCore::Document>(*m_potentialTapNode) || is<WebCore::HTMLBodyElement>(*m_potentialTapNode);
     1097        send(Messages::WebPageProxy::HandleSmartMagnificationInformationForPotentialTap(requestID, renderRect, fitEntireRect, viewportMinimumScale, viewportMaximumScale, nodeIsRootLevel));
    10961098    }
    10971099
Note: See TracChangeset for help on using the changeset viewer.