Changeset 191452 in webkit


Ignore:
Timestamp:
Oct 22, 2015 6:54:55 AM (8 years ago)
Author:
Wenson Hsieh
Message:

Implement touch-action: manipulation; for iOS
https://bugs.webkit.org/show_bug.cgi?id=149854
<rdar://problem/23017145>

Reviewed by Benjamin Poulain.

Source/WebCore:

Implements the manipulation value for the CSS property touch-action. Adds support for
parsing the touch-action property and two of its values: auto and manipulation.

Tests: css3/touch-action/touch-action-computed-style.html

css3/touch-action/touch-action-manipulation-fast-clicks.html
css3/touch-action/touch-action-parsing.html

  • css/CSSComputedStyleDeclaration.cpp:

(WebCore::ComputedStyleExtractor::propertyValue):

  • css/CSSParser.cpp:

(WebCore::isValidKeywordPropertyAndValue):
(WebCore::isKeywordPropertyID):
(WebCore::CSSParser::parseValue):

  • css/CSSPrimitiveValueMappings.h:

(WebCore::CSSPrimitiveValue::CSSPrimitiveValue):
(WebCore::CSSPrimitiveValue::operator TouchAction):

  • css/CSSPropertyNames.in:
  • css/CSSValueKeywords.in:
  • dom/Element.cpp:

(WebCore::Element::allowsDoubleTapGesture): Here, we determine whether an element that resulted from

hit-testing a touch should allow double-tap gestures. To do this, we walk up the element's parents,
stopping when we detect an element that disallows double tap gestures by having a touch-action other
than auto or by hitting the root node.

  • dom/Element.h:
  • dom/Node.h:

(WebCore::Node::allowsDoubleTapGesture):

  • rendering/style/RenderStyle.h:
  • rendering/style/RenderStyleConstants.h:
  • rendering/style/StyleRareNonInheritedData.cpp:

(WebCore::StyleRareNonInheritedData::StyleRareNonInheritedData):
(WebCore::StyleRareNonInheritedData::operator==):

  • rendering/style/StyleRareNonInheritedData.h:

Source/WebKit2:

Implements the manipulation value for the CSS property touch-action. Performs hit-testing upon receiving a potential
tap to determine whether to disable double-tap gesture recognition over the duration of the tap. If so, sends a message
from the web process to the UI process indicating that double-tapping should be disabled, allowing single taps to
avoid the delay.

  • WebProcess/WebPage/ios/WebPageIOS.mm:

(WebKit::WebPage::potentialTapAtPosition):

LayoutTests:

Add tests to check that the manipulation and auto values of the touch-action property can be
properly parsed and can be obtained through computed style. Also tests that putting touch-action:
manipulation on an element and tapping repeatedly on it will fire clicks instead of recognizing
double taps and causing the viewport to zoom.

  • TestExpectations:
  • css3/touch-action/touch-action-computed-style-expected.txt: Added.
  • css3/touch-action/touch-action-computed-style.html: Added.
  • css3/touch-action/touch-action-manipulation-fast-clicks-expected.txt: Added.
  • css3/touch-action/touch-action-manipulation-fast-clicks.html: Added.
  • css3/touch-action/touch-action-parsing-expected.txt: Added.
  • css3/touch-action/touch-action-parsing.html: Added.
  • platform/ios-simulator-wk2/TestExpectations:
Location:
trunk
Files:
7 added
18 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r191446 r191452  
     12015-10-22  Wenson Hsieh  <wenson_hsieh@apple.com>
     2
     3        Implement touch-action: manipulation; for iOS
     4        https://bugs.webkit.org/show_bug.cgi?id=149854
     5        <rdar://problem/23017145>
     6
     7        Reviewed by Benjamin Poulain.
     8
     9        Add tests to check that the manipulation and auto values of the touch-action property can be
     10        properly parsed and can be obtained through computed style. Also tests that putting touch-action:
     11        manipulation on an element and tapping repeatedly on it will fire clicks instead of recognizing
     12        double taps and causing the viewport to zoom.
     13
     14        * TestExpectations:
     15        * css3/touch-action/touch-action-computed-style-expected.txt: Added.
     16        * css3/touch-action/touch-action-computed-style.html: Added.
     17        * css3/touch-action/touch-action-manipulation-fast-clicks-expected.txt: Added.
     18        * css3/touch-action/touch-action-manipulation-fast-clicks.html: Added.
     19        * css3/touch-action/touch-action-parsing-expected.txt: Added.
     20        * css3/touch-action/touch-action-parsing.html: Added.
     21        * platform/ios-simulator-wk2/TestExpectations:
     22
    1232015-10-22  Xabier Rodriguez Calvar  <calvaris@igalia.com>
    224
  • trunk/LayoutTests/TestExpectations

    r191384 r191452  
    77#//////////////////////////////////////////////////////////////////////////////////////////
    88
     9css3/touch-action [ Skip ]
    910accessibility/ios-simulator [ Skip ]
    1011accessibility/gtk [ Skip ]
  • trunk/LayoutTests/platform/ios-simulator-wk2/TestExpectations

    r190644 r191452  
    77#//////////////////////////////////////////////////////////////////////////////////////////
    88
     9css3/touch-action [ Pass ]
    910fast/harness/ui-side-scripts.html [ Pass ]
    1011fast/harness/concurrent-ui-side-scripts.html [ Pass ]
  • trunk/Source/WebCore/ChangeLog

    r191451 r191452  
     12015-10-22  Wenson Hsieh  <wenson_hsieh@apple.com>
     2
     3        Implement touch-action: manipulation; for iOS
     4        https://bugs.webkit.org/show_bug.cgi?id=149854
     5        <rdar://problem/23017145>
     6
     7        Reviewed by Benjamin Poulain.
     8
     9        Implements the manipulation value for the CSS property touch-action. Adds support for
     10        parsing the touch-action property and two of its values: auto and manipulation.
     11
     12        Tests: css3/touch-action/touch-action-computed-style.html
     13               css3/touch-action/touch-action-manipulation-fast-clicks.html
     14               css3/touch-action/touch-action-parsing.html
     15
     16        * css/CSSComputedStyleDeclaration.cpp:
     17        (WebCore::ComputedStyleExtractor::propertyValue):
     18        * css/CSSParser.cpp:
     19        (WebCore::isValidKeywordPropertyAndValue):
     20        (WebCore::isKeywordPropertyID):
     21        (WebCore::CSSParser::parseValue):
     22        * css/CSSPrimitiveValueMappings.h:
     23        (WebCore::CSSPrimitiveValue::CSSPrimitiveValue):
     24        (WebCore::CSSPrimitiveValue::operator TouchAction):
     25        * css/CSSPropertyNames.in:
     26        * css/CSSValueKeywords.in:
     27        * dom/Element.cpp:
     28        (WebCore::Element::allowsDoubleTapGesture): Here, we determine whether an element that resulted from
     29            hit-testing a touch should allow double-tap gestures. To do this, we walk up the element's parents,
     30            stopping when we detect an element that disallows double tap gestures by having a touch-action other
     31            than auto or by hitting the root node.
     32        * dom/Element.h:
     33        * dom/Node.h:
     34        (WebCore::Node::allowsDoubleTapGesture):
     35        * rendering/style/RenderStyle.h:
     36        * rendering/style/RenderStyleConstants.h:
     37        * rendering/style/StyleRareNonInheritedData.cpp:
     38        (WebCore::StyleRareNonInheritedData::StyleRareNonInheritedData):
     39        (WebCore::StyleRareNonInheritedData::operator==):
     40        * rendering/style/StyleRareNonInheritedData.h:
     41
    1422015-10-22  Ryosuke Niwa  <rniwa@webkit.org>
    243
  • trunk/Source/WebCore/css/CSSComputedStyleDeclaration.cpp

    r191178 r191452  
    31943194        case CSSPropertyWebkitTapHighlightColor:
    31953195            return currentColorOrValidColor(style.get(), style->tapHighlightColor());
     3196        case CSSPropertyTouchAction:
     3197            return cssValuePool.createValue(style->touchAction());
    31963198#endif
    31973199#if PLATFORM(IOS)
  • trunk/Source/WebCore/css/CSSParser.cpp

    r191252 r191452  
    755755            return true;
    756756        break;
     757#if ENABLE(TOUCH_EVENTS)
     758    case CSSPropertyTouchAction: // auto | manipulation
     759        if (valueID == CSSValueAuto || valueID == CSSValueManipulation)
     760            return true;
     761        break;
     762#endif
    757763#if ENABLE(CSS_SCROLL_SNAP)
    758764    case CSSPropertyWebkitScrollSnapType: // none | mandatory | proximity
     
    11771183    case CSSPropertyWordBreak:
    11781184    case CSSPropertyWordWrap:
     1185#if ENABLE(TOUCH_EVENTS)
     1186    case CSSPropertyTouchAction:
     1187#endif
    11791188#if ENABLE(CSS_SCROLL_SNAP)
    11801189    case CSSPropertyWebkitScrollSnapType:
     
    32683277    case CSSPropertyWordBreak:
    32693278    case CSSPropertyWordWrap:
     3279#if ENABLE(TOUCH_EVENTS)
     3280    case CSSPropertyTouchAction:
     3281#endif
    32703282#if ENABLE(CSS_SCROLL_SNAP)
    32713283    case CSSPropertyWebkitScrollSnapType:
  • trunk/Source/WebCore/css/CSSPrimitiveValueMappings.h

    r191014 r191452  
    52535253}
    52545254
     5255#if ENABLE(TOUCH_EVENTS)
     5256template<> inline CSSPrimitiveValue::CSSPrimitiveValue(TouchAction touchAction)
     5257    : CSSValue(PrimitiveClass)
     5258{
     5259    m_primitiveUnitType = CSS_VALUE_ID;
     5260    switch (touchAction) {
     5261    case TouchAction::Auto:
     5262        m_value.valueID = CSSValueAuto;
     5263        break;
     5264    case TouchAction::Manipulation:
     5265        m_value.valueID = CSSValueManipulation;
     5266        break;
     5267    }
     5268}
     5269
     5270template<> inline CSSPrimitiveValue::operator TouchAction() const
     5271{
     5272    ASSERT(isValueID());
     5273    switch (m_value.valueID) {
     5274    case CSSValueAuto:
     5275        return TouchAction::Auto;
     5276    case CSSValueManipulation:
     5277        return TouchAction::Manipulation;
     5278    default:
     5279        break;
     5280    }
     5281    ASSERT_NOT_REACHED();
     5282    return TouchAction::Auto;
     5283}
     5284#endif
     5285
    52555286#if ENABLE(CSS_SCROLL_SNAP)
    52565287template<> inline CSSPrimitiveValue::CSSPrimitiveValue(ScrollSnapType e)
  • trunk/Source/WebCore/css/CSSPropertyNames.in

    r191184 r191452  
    667667-webkit-overflow-scrolling [Inherited, NameForMethods=UseTouchOverflowScrolling, Converter=OverflowScrolling]
    668668#endif
     669#if defined(ENABLE_TOUCH_EVENTS) && ENABLE_TOUCH_EVENTS
     670touch-action
     671#endif
    669672#if defined(WTF_PLATFORM_IOS) && WTF_PLATFORM_IOS
    670673-webkit-touch-callout [Inherited, NameForMethods=TouchCalloutEnabled, Converter=TouchCallout]
  • trunk/Source/WebCore/css/CSSValueKeywords.in

    r191252 r191452  
    11731173scroll-position
    11741174contents
     1175
     1176#if defined(ENABLE_TOUCH_EVENTS) && ENABLE_TOUCH_EVENTS
     1177// touch-action
     1178manipulation
     1179#endif
  • trunk/Source/WebCore/dom/Element.cpp

    r191451 r191452  
    55 *           (C) 2001 Dirk Mueller (mueller@kde.org)
    66 *           (C) 2007 David Smith (catfish.man@gmail.com)
    7  * Copyright (C) 2004-2014 Apple Inc. All rights reserved.
     7 * Copyright (C) 2004-2015 Apple Inc. All rights reserved.
    88 *           (C) 2007 Eric Seidel (eric@webkit.org)
    99 *
     
    13821382}
    13831383
     1384#if ENABLE(TOUCH_EVENTS)
     1385bool Element::allowsDoubleTapGesture() const
     1386{
     1387    if (renderStyle() && renderStyle()->touchAction() != TouchAction::Auto)
     1388        return false;
     1389
     1390    Element* parent = parentElement();
     1391    return !parent || parent->allowsDoubleTapGesture();
     1392}
     1393#endif
     1394
    13841395StyleResolver& Element::styleResolver()
    13851396{
  • trunk/Source/WebCore/dom/Element.h

    r191451 r191452  
    488488    WEBCORE_EXPORT URL absoluteLinkURL() const;
    489489
     490#if ENABLE(TOUCH_EVENTS)
     491    virtual bool allowsDoubleTapGesture() const override;
     492#endif
     493
    490494    StyleResolver& styleResolver();
    491495    Ref<RenderStyle> resolveStyle(RenderStyle* parentStyle);
  • trunk/Source/WebCore/dom/Node.h

    r191327 r191452  
    530530    bool dispatchDOMActivateEvent(int detail, PassRefPtr<Event> underlyingEvent);
    531531
     532#if ENABLE(TOUCH_EVENTS)
     533    virtual bool allowsDoubleTapGesture() const { return true; }
     534#endif
     535
    532536#if ENABLE(TOUCH_EVENTS) && !PLATFORM(IOS)
    533537    bool dispatchTouchEvent(PassRefPtr<TouchEvent>);
  • trunk/Source/WebCore/rendering/style/RenderStyle.h

    r191128 r191452  
    11191119    int initialLetterDrop() const { return initialLetter().width(); }
    11201120    int initialLetterHeight() const { return initialLetter().height(); }
     1121
     1122#if ENABLE(TOUCH_EVENTS)
     1123    TouchAction touchAction() const { return static_cast<TouchAction>(rareNonInheritedData->m_touchAction); }
     1124#endif
    11211125
    11221126#if ENABLE(CSS_SCROLL_SNAP)
     
    16801684    void setInitialLetter(const IntSize& size) { SET_VAR(rareNonInheritedData, m_initialLetter, size); }
    16811685   
     1686#if ENABLE(TOUCH_EVENTS)
     1687    void setTouchAction(TouchAction touchAction) { SET_VAR(rareNonInheritedData, m_touchAction, static_cast<unsigned>(touchAction)); }
     1688#endif
     1689
    16821690#if ENABLE(CSS_SCROLL_SNAP)
    16831691    void setScrollSnapType(ScrollSnapType type) { SET_VAR(rareNonInheritedData, m_scrollSnapType, static_cast<unsigned>(type)); }
     
    20332041    static WillChangeData* initialWillChange() { return nullptr; }
    20342042
     2043#if ENABLE(TOUCH_EVENTS)
     2044    static TouchAction initialTouchAction() { return TouchAction::Auto; }
     2045#endif
     2046
    20352047#if ENABLE(CSS_SCROLL_SNAP)
    20362048    static ScrollSnapType initialScrollSnapType() { return ScrollSnapType::None; }
  • trunk/Source/WebCore/rendering/style/RenderStyleConstants.h

    r191310 r191452  
    644644enum CSSBoxType { BoxMissing = 0, MarginBox, BorderBox, PaddingBox, ContentBox, Fill, Stroke, ViewBox };
    645645
     646#if ENABLE(TOUCH_EVENTS)
     647enum class TouchAction {
     648    Auto,
     649    Manipulation
     650};
     651#endif
     652
    646653#if ENABLE(CSS_SCROLL_SNAP)
    647654enum class ScrollSnapType {
  • trunk/Source/WebCore/rendering/style/StyleRareNonInheritedData.cpp

    r191017 r191452  
    8080    , m_justifyItems(RenderStyle::initialSelfAlignment())
    8181    , m_justifySelf(RenderStyle::initialSelfAlignment())
     82#if ENABLE(TOUCH_EVENTS)
     83    , m_touchAction(static_cast<unsigned>(RenderStyle::initialTouchAction()))
     84#endif
    8285#if ENABLE(CSS_SCROLL_SNAP)
    8386    , m_scrollSnapType(static_cast<unsigned>(RenderStyle::initialScrollSnapType()))
     
    169172    , m_justifyItems(o.m_justifyItems)
    170173    , m_justifySelf(o.m_justifySelf)
     174#if ENABLE(TOUCH_EVENTS)
     175    , m_touchAction(o.m_touchAction)
     176#endif
    171177#if ENABLE(CSS_SCROLL_SNAP)
    172178    , m_scrollSnapType(o.m_scrollSnapType)
     
    283289        && m_textCombine == o.m_textCombine
    284290        && m_textDecorationStyle == o.m_textDecorationStyle
     291#if ENABLE(TOUCH_EVENTS)
     292        && m_touchAction == o.m_touchAction
     293#endif
    285294#if ENABLE(CSS_SCROLL_SNAP)
    286295        && m_scrollSnapType == o.m_scrollSnapType
  • trunk/Source/WebCore/rendering/style/StyleRareNonInheritedData.h

    r191017 r191452  
    185185    StyleSelfAlignmentData m_justifySelf;
    186186
     187#if ENABLE(TOUCH_EVENTS)
     188    unsigned m_touchAction : 1; // TouchAction
     189#endif
     190
    187191#if ENABLE(CSS_SCROLL_SNAP)
    188192    unsigned m_scrollSnapType : 2; // ScrollSnapType
  • trunk/Source/WebKit2/ChangeLog

    r191451 r191452  
     12015-10-22  Wenson Hsieh  <wenson_hsieh@apple.com>
     2
     3        Implement touch-action: manipulation; for iOS
     4        https://bugs.webkit.org/show_bug.cgi?id=149854
     5        <rdar://problem/23017145>
     6
     7        Reviewed by Benjamin Poulain.
     8
     9        Implements the manipulation value for the CSS property touch-action. Performs hit-testing upon receiving a potential
     10        tap to determine whether to disable double-tap gesture recognition over the duration of the tap. If so, sends a message
     11        from the web process to the UI process indicating that double-tapping should be disabled, allowing single taps to
     12        avoid the delay.
     13
     14        * WebProcess/WebPage/ios/WebPageIOS.mm:
     15        (WebKit::WebPage::potentialTapAtPosition):
     16
    1172015-10-22  Ryosuke Niwa  <rniwa@webkit.org>
    218
  • trunk/Source/WebKit2/WebProcess/WebPage/ios/WebPageIOS.mm

    r191381 r191452  
    11/*
    2  * Copyright (C) 2012-2014 Apple Inc. All rights reserved.
     2 * Copyright (C) 2012-2015 Apple Inc. All rights reserved.
    33 *
    44 * Redistribution and use in source and binary forms, with or without
     
    666666    sendTapHighlightForNodeIfNecessary(requestID, m_potentialTapNode.get());
    667667    if (m_potentialTapNode) {
     668#if ENABLE(TOUCH_EVENTS)
     669        if (!m_potentialTapNode->allowsDoubleTapGesture()) {
     670            send(Messages::WebPageProxy::DisableDoubleTapGesturesUntilTapIsFinishedIfNecessary(requestID, false, FloatRect(), false, 0, 0));
     671            return;
     672        }
     673#endif
    668674        FloatPoint origin = position;
    669675        FloatRect renderRect;
Note: See TracChangeset for help on using the changeset viewer.