Changeset 163516 in webkit


Ignore:
Timestamp:
Feb 5, 2014 10:55:20 PM (10 years ago)
Author:
Simon Fraser
Message:

Transfer the non-fast-scrollable region to the UI process for iOS
https://bugs.webkit.org/show_bug.cgi?id=128293

Reviewed by Benjamin Poulain.

Source/WebCore:

Two main changes to support sending the non-fast scrollable region
to the UI process for iOS:

  1. Add ScrollingCoordinator::frameViewNonFastScrollableRegionChanged(),

which is called when we've updated the touch event region (this can happen
independenly of layout). When called we just scheduled a scrolling tree
commit with the new region.

  1. Avoid thinking that we have a new root node with every remote scrolling

transaction. This was a side-effect of reconstructing the scrolling state
tree in the UI process, and caused us to try to grab a nonFastScrollableRegion
from a node which never had one set.

  • WebCore.exp.in:
  • page/scrolling/AsyncScrollingCoordinator.cpp:

(WebCore::AsyncScrollingCoordinator::frameViewNonFastScrollableRegionChanged):

  • page/scrolling/AsyncScrollingCoordinator.h:
  • page/scrolling/ScrollingCoordinator.cpp:

(WebCore::ScrollingCoordinator::computeNonFastScrollableRegion):

  • page/scrolling/ScrollingCoordinator.h:

(WebCore::ScrollingCoordinator::frameViewNonFastScrollableRegionChanged):

  • page/scrolling/ScrollingStateTree.h:

(WebCore::ScrollingStateTree::setHasNewRootStateNode):

  • page/scrolling/ScrollingTree.cpp:

(WebCore::ScrollingTree::commitNewTreeState):
(WebCore::ScrollingTree::isPointInNonFastScrollableRegion):

  • page/scrolling/ScrollingTree.h:

Source/WebKit2:

Two main changes to support sending the non-fast scrollable region
to the UI process for iOS:

  1. Add ScrollingCoordinator::frameViewNonFastScrollableRegionChanged(),

which is called when we've updated the touch event region (this can happen
independenly of layout). When called we just scheduled a scrolling tree
commit with the new region.

  1. Avoid thinking that we have a new root node with every remote scrolling

transaction. This was a side-effect of reconstructing the scrolling state
tree in the UI process, and caused us to try to grab a nonFastScrollableRegion
from a node which never had one set.

Now that we have the non-fast scrollable region in the UI process, we can
use it to avoid sending sync messages to the web process.

  • Shared/Scrolling/RemoteScrollingCoordinatorTransaction.cpp:

(ArgumentCoder<ScrollingStateScrollingNode>::encode): Encode hasNewRootNode.
(ArgumentCoder<ScrollingStateScrollingNode>::decode): Decode hasNewRootNode and set it on
the state tree.
(WebKit::RemoteScrollingCoordinatorTransaction::encode): Encode the nonFastScrollableRegion
now that we can encode Regions.
(WebKit::RemoteScrollingCoordinatorTransaction::decode): Decode the nonFastScrollableRegion
now that we can decode Regions.

  • UIProcess/Scrolling/RemoteScrollingCoordinatorProxy.cpp:

(WebKit::RemoteScrollingCoordinatorProxy::isPointInNonFastScrollableRegion):

  • UIProcess/Scrolling/RemoteScrollingCoordinatorProxy.h:
  • UIProcess/WebPageProxy.cpp:

(WebKit::WebPageProxy::handleTouchEvent): If we're not in the non-fast scrollable region,
don't both sending touch events to the web process.

Location:
trunk/Source
Files:
19 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r163515 r163516  
     12014-02-05  Simon Fraser  <simon.fraser@apple.com>
     2
     3        Transfer the non-fast-scrollable region to the UI process for iOS
     4        https://bugs.webkit.org/show_bug.cgi?id=128293
     5
     6        Reviewed by Benjamin Poulain.
     7
     8        Two main changes to support sending the non-fast scrollable region
     9        to the UI process for iOS:
     10       
     11        1. Add ScrollingCoordinator::frameViewNonFastScrollableRegionChanged(),
     12        which is called when we've updated the touch event region (this can happen
     13        independenly of layout). When called we just scheduled a scrolling tree
     14        commit with the new region.
     15       
     16        2. Avoid thinking that we have a new root node with every remote scrolling
     17        transaction. This was a side-effect of reconstructing the scrolling state
     18        tree in the UI process, and caused us to try to grab a nonFastScrollableRegion
     19        from a node which never had one set.
     20
     21        * WebCore.exp.in:
     22        * page/scrolling/AsyncScrollingCoordinator.cpp:
     23        (WebCore::AsyncScrollingCoordinator::frameViewNonFastScrollableRegionChanged):
     24        * page/scrolling/AsyncScrollingCoordinator.h:
     25        * page/scrolling/ScrollingCoordinator.cpp:
     26        (WebCore::ScrollingCoordinator::computeNonFastScrollableRegion):
     27        * page/scrolling/ScrollingCoordinator.h:
     28        (WebCore::ScrollingCoordinator::frameViewNonFastScrollableRegionChanged):
     29        * page/scrolling/ScrollingStateTree.h:
     30        (WebCore::ScrollingStateTree::setHasNewRootStateNode):
     31        * page/scrolling/ScrollingTree.cpp:
     32        (WebCore::ScrollingTree::commitNewTreeState):
     33        (WebCore::ScrollingTree::isPointInNonFastScrollableRegion):
     34        * page/scrolling/ScrollingTree.h:
     35
    1362014-02-05  Benjamin Poulain  <benjamin@webkit.org>
    237
  • trunk/Source/WebCore/WebCore.exp.in

    r163515 r163516  
    11301130__ZN7WebCore6Editor7outdentEv
    11311131__ZN7WebCore6JSNode6s_infoE
     1132__ZN7WebCore6Region21updateBoundsFromShapeEv
     1133__ZNK7WebCore6Region5Shape7isValidEv
    11321134__ZN7WebCore6Region5uniteERKS0_
    11331135__ZN7WebCore6Region8subtractERKS0_
     
    29942996__ZN7WebCore13ScrollingTree21setCanRubberBandStateEbbbb
    29952997__ZN7WebCore13ScrollingTree31willWheelEventStartSwipeGestureERKNS_18PlatformWheelEventE
     2998__ZN7WebCore13ScrollingTree32isPointInNonFastScrollableRegionENS_8IntPointE
    29962999__ZN7WebCore13ScrollingTree35shouldHandleWheelEventSynchronouslyERKNS_18PlatformWheelEventE
    29973000__ZN7WebCore13ScrollingTree37setScrollingPerformanceLoggingEnabledEb
     
    30273030__ZN7WebCore25AsyncScrollingCoordinator30setSynchronousScrollingReasonsEj
    30283031__ZN7WebCore25AsyncScrollingCoordinator37scrollableAreaScrollbarLayerDidChangeEPNS_14ScrollableAreaENS_20ScrollbarOrientationE
     3032__ZN7WebCore25AsyncScrollingCoordinator39frameViewNonFastScrollableRegionChangedEPNS_9FrameViewE
    30293033__ZN7WebCore25AsyncScrollingCoordinator43recomputeWheelEventHandlerCountForFrameViewEPNS_9FrameViewE
    30303034__ZN7WebCore25AsyncScrollingCoordinator44scheduleUpdateScrollPositionAfterAsyncScrollEyRKNS_10FloatPointEbNS_31SetOrSyncScrollingLayerPositionE
     
    30423046__ZN7WebCore27ScrollingStateScrollingNode24setCounterScrollingLayerERKNS_19LayerRepresentationE
    30433047__ZN7WebCore27ScrollingStateScrollingNode25setWheelEventHandlerCountEj
     3048__ZN7WebCore27ScrollingStateScrollingNode26setNonFastScrollableRegionERKNS_6RegionE
    30443049__ZN7WebCore27ScrollingStateScrollingNode27setScrollableAreaParametersERKNS_24ScrollableAreaParametersE
    30453050__ZN7WebCore27ScrollingStateScrollingNode30setSynchronousScrollingReasonsEj
  • trunk/Source/WebCore/page/scrolling/AsyncScrollingCoordinator.cpp

    r163231 r163516  
    106106}
    107107
     108void AsyncScrollingCoordinator::frameViewNonFastScrollableRegionChanged(FrameView*)
     109{
     110    if (!m_scrollingStateTree->rootStateNode())
     111        return;
     112
     113    Region nonFastScrollableRegion = computeNonFastScrollableRegion(&m_page->mainFrame(), IntPoint());
     114    setNonFastScrollableRegionForNode(nonFastScrollableRegion, m_scrollingStateTree->rootStateNode());
     115}
     116
    108117void AsyncScrollingCoordinator::frameViewRootLayerDidChange(FrameView* frameView)
    109118{
  • trunk/Source/WebCore/page/scrolling/AsyncScrollingCoordinator.h

    r163231 r163516  
    7979    virtual void frameViewLayoutUpdated(FrameView*) override;
    8080    virtual void frameViewRootLayerDidChange(FrameView*) override;
     81    virtual void frameViewNonFastScrollableRegionChanged(FrameView*) override;
    8182
    8283    virtual bool requestScrollPositionUpdate(FrameView*, const IntPoint&) override;
  • trunk/Source/WebCore/page/scrolling/ScrollingCoordinator.cpp

    r163079 r163516  
    9595Region ScrollingCoordinator::computeNonFastScrollableRegion(const Frame* frame, const IntPoint& frameLocation) const
    9696{
     97#if PLATFORM(IOS)
     98    // On iOS, we use nonFastScrollableRegion to represent the region covered by elements with touch event handlers.
     99    ASSERT(frame->isMainFrame());
     100    UNUSED_PARAM(frameLocation);
     101
     102    Document* document = frame->document();
     103    if (!document)
     104        return Region();
     105
     106    Vector<IntRect> touchRects;
     107    document->getTouchRects(touchRects);
     108   
     109    Region touchRegion;
     110    for (auto rect : touchRects)
     111        touchRegion.unite(rect);
     112
     113    return touchRegion;
     114#else
    97115    Region nonFastScrollableRegion;
    98116    FrameView* frameView = frame->view();
     
    127145
    128146    return nonFastScrollableRegion;
     147#endif
    129148}
    130149
  • trunk/Source/WebCore/page/scrolling/ScrollingCoordinator.h

    r163158 r163516  
    126126    void frameViewFixedObjectsDidChange(FrameView*);
    127127
     128    // Called whenever the non-fast scrollable region changes for reasons other than layout.
     129    virtual void frameViewNonFastScrollableRegionChanged(FrameView*) { }
     130
    128131    // Should be called whenever the root layer for the given frame view changes.
    129132    virtual void frameViewRootLayerDidChange(FrameView*);
  • trunk/Source/WebCore/page/scrolling/ScrollingStateTree.h

    r161315 r163516  
    6767
    6868    bool hasNewRootStateNode() const { return m_hasNewRootStateNode; }
     69    void setHasNewRootStateNode(bool hasNewRoot) { m_hasNewRootStateNode = hasNewRoot; }
    6970   
    7071    int nodeCount() const { return m_stateNodeMap.size(); }
  • trunk/Source/WebCore/page/scrolling/ScrollingTree.cpp

    r163231 r163516  
    255255}
    256256
     257bool ScrollingTree::isPointInNonFastScrollableRegion(IntPoint p)
     258{
     259    MutexLocker lock(m_mutex);
     260   
     261    return m_nonFastScrollableRegion.contains(p);
     262}
     263
    257264bool ScrollingTree::isRubberBandInProgress()
    258265{
  • trunk/Source/WebCore/page/scrolling/ScrollingTree.h

    r163231 r163516  
    7777    FloatPoint mainFrameScrollPosition();
    7878
     79    bool isPointInNonFastScrollableRegion(IntPoint);
     80   
    7981#if PLATFORM(MAC) && !PLATFORM(IOS)
    8082    virtual void handleWheelEventPhase(PlatformWheelEventPhase) = 0;
  • trunk/Source/WebKit2/ChangeLog

    r163515 r163516  
     12014-02-05  Simon Fraser  <simon.fraser@apple.com>
     2
     3        Transfer the non-fast-scrollable region to the UI process for iOS
     4        https://bugs.webkit.org/show_bug.cgi?id=128293
     5
     6        Reviewed by Benjamin Poulain.
     7
     8        Two main changes to support sending the non-fast scrollable region
     9        to the UI process for iOS:
     10       
     11        1. Add ScrollingCoordinator::frameViewNonFastScrollableRegionChanged(),
     12        which is called when we've updated the touch event region (this can happen
     13        independenly of layout). When called we just scheduled a scrolling tree
     14        commit with the new region.
     15       
     16        2. Avoid thinking that we have a new root node with every remote scrolling
     17        transaction. This was a side-effect of reconstructing the scrolling state
     18        tree in the UI process, and caused us to try to grab a nonFastScrollableRegion
     19        from a node which never had one set.
     20       
     21        Now that we have the non-fast scrollable region in the UI process, we can
     22        use it to avoid sending sync messages to the web process.
     23       
     24        * Shared/Scrolling/RemoteScrollingCoordinatorTransaction.cpp:
     25        (ArgumentCoder<ScrollingStateScrollingNode>::encode): Encode hasNewRootNode.
     26        (ArgumentCoder<ScrollingStateScrollingNode>::decode): Decode hasNewRootNode and set it on
     27        the state tree.
     28        (WebKit::RemoteScrollingCoordinatorTransaction::encode): Encode the nonFastScrollableRegion
     29        now that we can encode Regions.
     30        (WebKit::RemoteScrollingCoordinatorTransaction::decode): Decode the nonFastScrollableRegion
     31        now that we can decode Regions.
     32        * UIProcess/Scrolling/RemoteScrollingCoordinatorProxy.cpp:
     33        (WebKit::RemoteScrollingCoordinatorProxy::isPointInNonFastScrollableRegion):
     34        * UIProcess/Scrolling/RemoteScrollingCoordinatorProxy.h:
     35        * UIProcess/WebPageProxy.cpp:
     36        (WebKit::WebPageProxy::handleTouchEvent): If we're not in the non-fast scrollable region,
     37        don't both sending touch events to the web process.
     38
    1392014-02-05  Benjamin Poulain  <benjamin@webkit.org>
    240
  • trunk/Source/WebKit2/Shared/Scrolling/RemoteScrollingCoordinatorTransaction.cpp

    r163231 r163516  
    114114    SCROLLING_NODE_ENCODE(ScrollOrigin, scrollOrigin)
    115115    SCROLLING_NODE_ENCODE(FrameScaleFactor, frameScaleFactor)
    116 //    SCROLLING_NODE_ENCODE(NonFastScrollableRegion, nonFastScrollableRegion) // FIXME: no encoder support for Region
     116    SCROLLING_NODE_ENCODE(NonFastScrollableRegion, nonFastScrollableRegion)
    117117    SCROLLING_NODE_ENCODE(WheelEventHandlerCount, wheelEventHandlerCount)
    118118    SCROLLING_NODE_ENCODE(ReasonsForSynchronousScrolling, synchronousScrollingReasons)
     
    150150    SCROLLING_NODE_DECODE(ScrollOrigin, IntPoint, setScrollOrigin);
    151151    SCROLLING_NODE_DECODE(FrameScaleFactor, float, setFrameScaleFactor);
    152 //    SCROLLING_NODE_DECODE(NonFastScrollableRegion, Region, setNonFastScrollableRegion); // FIXME: no decoder support for Region.
     152    SCROLLING_NODE_DECODE(NonFastScrollableRegion, Region, setNonFastScrollableRegion);
    153153    SCROLLING_NODE_DECODE(WheelEventHandlerCount, int, setWheelEventHandlerCount);
    154154    SCROLLING_NODE_DECODE(ReasonsForSynchronousScrolling, SynchronousScrollingReasons, setSynchronousScrollingReasons);
     
    237237    int numNodes = m_scrollingStateTree ? m_scrollingStateTree->nodeCount() : 0;
    238238    encoder << numNodes;
     239   
     240    bool hasNewRootNode = m_scrollingStateTree ? m_scrollingStateTree->hasNewRootStateNode() : false;
     241    encoder << hasNewRootNode;
    239242
    240243    if (m_scrollingStateTree) {
     
    258261        return false;
    259262
     263    bool hasNewRootNode;
     264    if (!decoder.decode(hasNewRootNode))
     265        return false;
     266   
    260267    m_scrollingStateTree = ScrollingStateTree::create();
    261268   
     
    294301    }
    295302
     303    m_scrollingStateTree->setHasNewRootStateNode(hasNewRootNode);
     304
    296305    // Removed nodes
    297306    Vector<ScrollingNodeID> removedNodes;
  • trunk/Source/WebKit2/Shared/ios/NativeWebTouchEventIOS.mm

    r159724 r163516  
    4242        return WebEvent::TouchStart;
    4343    case UIWebTouchEventTouchChange:
    44         return WebEvent::TouchStart;
     44        return WebEvent::TouchMove;
    4545    case UIWebTouchEventTouchEnd:
    46         return WebEvent::TouchStart;
     46        return WebEvent::TouchEnd;
    4747    case UIWebTouchEventTouchCancel:
    48         return WebEvent::TouchStart;
     48        return WebEvent::TouchCancel;
    4949    }
    5050}
  • trunk/Source/WebKit2/UIProcess/Scrolling/RemoteScrollingCoordinatorProxy.cpp

    r162880 r163516  
    130130}
    131131
     132bool RemoteScrollingCoordinatorProxy::isPointInNonFastScrollableRegion(const WebCore::IntPoint& p) const
     133{
     134    return m_scrollingTree->isPointInNonFastScrollableRegion(p);
     135}
     136
    132137void RemoteScrollingCoordinatorProxy::scrollPositionChangedViaDelegatedScrolling(ScrollingNodeID nodeID, const IntPoint& offset)
    133138{
  • trunk/Source/WebKit2/UIProcess/Scrolling/RemoteScrollingCoordinatorProxy.h

    r162748 r163516  
    5555    void scrollPositionChanged(WebCore::ScrollingNodeID, const WebCore::FloatPoint& newScrollPosition);
    5656
     57    bool isPointInNonFastScrollableRegion(const WebCore::IntPoint&) const;
     58
    5759    // Called externally when native views move around.
    5860    void scrollPositionChangedViaDelegatedScrolling(WebCore::ScrollingNodeID, const WebCore::IntPoint&);
  • trunk/Source/WebKit2/UIProcess/WebPageProxy.cpp

    r163515 r163516  
    292292    , m_syncNavigationActionPolicyDownloadID(0)
    293293    , m_processingMouseMoveEvent(false)
    294 #if ENABLE(TOUCH_EVENTS)
    295     , m_needTouchEvents(false)
    296 #endif
    297294    , m_pageID(pageID)
    298295    , m_session(session)
     
    13771374
    13781375#if ENABLE(TOUCH_EVENTS)
     1376static bool anyTouchIsInNonFastScrollableRegion(RemoteScrollingCoordinatorProxy& scrollingCoordinator, const WebTouchEvent& event)
     1377{
     1378    for (auto touchPoint : event.touchPoints()) {
     1379        if (scrollingCoordinator.isPointInNonFastScrollableRegion(touchPoint.location()))
     1380            return true;
     1381    }
     1382
     1383    return false;
     1384}
     1385
    13791386void WebPageProxy::handleTouchEvent(const NativeWebTouchEvent& event)
    13801387{
     
    13851392    // and animation on the page itself (kinetic scrolling, tap to zoom) etc, then
    13861393    // we do not send any of the events to the page even if is has listeners.
    1387     if (m_needTouchEvents && !m_isPageSuspended) {
     1394    if (!m_isPageSuspended) {
     1395        // FIXME: we should only do this check for the start of a touch gesture.
     1396        if (!anyTouchIsInNonFastScrollableRegion(*m_scrollingCoordinatorProxy, event))
     1397            return;
     1398
    13881399        m_touchEventQueue.append(event);
    13891400        m_process->responsivenessTimer()->start();
     
    28822893#endif
    28832894
    2884 #if ENABLE(TOUCH_EVENTS)
    2885 void WebPageProxy::needTouchEvents(bool needTouchEvents)
    2886 {
    2887     m_needTouchEvents = needTouchEvents;
    2888 }
    2889 #endif
    2890 
    28912895#if ENABLE(INPUT_TYPE_COLOR)
    28922896void WebPageProxy::showColorPicker(const WebCore::Color& initialColor, const IntRect& elementRect)
     
    38803884
    38813885#if ENABLE(TOUCH_EVENTS)
    3882     m_needTouchEvents = false;
    38833886    m_touchEventQueue.clear();
    38843887#endif
  • trunk/Source/WebKit2/UIProcess/WebPageProxy.h

    r163515 r163516  
    13191319
    13201320#if ENABLE(TOUCH_EVENTS)
    1321     bool m_needTouchEvents;
    13221321    Deque<QueuedTouchEvents> m_touchEventQueue;
    13231322#endif
  • trunk/Source/WebKit2/UIProcess/WebPageProxy.messages.in

    r163515 r163516  
    9595#endif
    9696
    97 #if ENABLE(TOUCH_EVENTS)
    98     NeedTouchEvents(bool needTouchEvents)
    99 #endif
    100 
    10197#if ENABLE(INPUT_TYPE_COLOR)
    10298    ShowColorPicker(WebCore::Color initialColor, WebCore::IntRect elementRect);
  • trunk/Source/WebKit2/WebProcess/WebCoreSupport/WebChromeClient.cpp

    r163515 r163516  
    822822#endif
    823823
    824 #if ENABLE(TOUCH_EVENTS)
    825 void WebChromeClient::needTouchEvents(bool needTouchEvents)
    826 {
    827     m_page->send(Messages::WebPageProxy::NeedTouchEvents(needTouchEvents));
    828 }
    829 #endif
    830 
    831824#if ENABLE(FULLSCREEN_API)
    832825bool WebChromeClient::supportsFullScreenForElement(const WebCore::Element*, bool withKeyboard)
  • trunk/Source/WebKit2/WebProcess/WebCoreSupport/WebChromeClient.h

    r163079 r163516  
    231231
    232232#if ENABLE(TOUCH_EVENTS)
    233     virtual void needTouchEvents(bool) override;
     233    virtual void needTouchEvents(bool) override { }
    234234#endif
    235235
Note: See TracChangeset for help on using the changeset viewer.