Changeset 182242 in webkit


Ignore:
Timestamp:
Apr 1, 2015 11:30:39 AM (9 years ago)
Author:
Simon Fraser
Message:

Remove scrolling tree dependency on wheel event handler counts, and use fast scrolling even when there are wheel handlers
https://bugs.webkit.org/show_bug.cgi?id=143288
rdar://problem/16049624

Reviewed by Beth Dakin.

Remove the wheel event counting that Document does, and passes into the scrolling tree.
The ScrollingTree now just uses the non-fast scrollable region to determine when to
fast scroll on pages with wheel event handlers.

If a handler includes position:fixed renderers, we just cover the whole document
with the slow-scrolling region currently. This could be improved.

  • dom/Document.cpp:

(WebCore::Document::Document):
(WebCore::Document::didBecomeCurrentDocumentInFrame):
(WebCore::Document::wheelEventHandlersChanged):
(WebCore::Document::didAddWheelEventHandler):
(WebCore::Document::didRemoveWheelEventHandler):
(WebCore::Document::wheelEventHandlerCount):
(WebCore::Document::touchEventHandlerCount):
(WebCore::Document::absoluteRegionForEventTargets): Changed to return a pair<Region, bool>
where the bool indicates whether any handler includes position:fixed content.
(WebCore::pageWheelEventHandlerCountChanged): Deleted.
(WebCore::wheelEventHandlerCountChanged): Deleted.

  • dom/Document.h:

(WebCore::Document::wheelEventHandlerCount): Deleted.

  • loader/EmptyClients.h:
  • page/ChromeClient.h:
  • page/DebugPageOverlays.cpp:

(WebCore::MouseWheelRegionOverlay::updateRegion):

  • page/scrolling/AsyncScrollingCoordinator.cpp:

(WebCore::AsyncScrollingCoordinator::frameViewNonFastScrollableRegionChanged):
(WebCore::AsyncScrollingCoordinator::recomputeWheelEventHandlerCountForFrameView): Deleted.

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

(WebCore::ScrollingCoordinator::computeNonFastScrollableRegion):
(WebCore::ScrollingCoordinator::frameViewRootLayerDidChange):
(WebCore::ScrollingCoordinator::computeCurrentWheelEventHandlerCount): Deleted.
(WebCore::ScrollingCoordinator::frameViewWheelEventHandlerCountChanged): Deleted.

  • page/scrolling/ScrollingCoordinator.h:

(WebCore::ScrollingCoordinator::recomputeWheelEventHandlerCountForFrameView): Deleted.

  • page/scrolling/ScrollingStateFrameScrollingNode.cpp:

(WebCore::ScrollingStateFrameScrollingNode::ScrollingStateFrameScrollingNode):
(WebCore::ScrollingStateFrameScrollingNode::setWheelEventHandlerCount): Deleted.

  • page/scrolling/ScrollingStateFrameScrollingNode.h:
  • page/scrolling/ScrollingTree.cpp:

(WebCore::ScrollingTree::ScrollingTree):
(WebCore::ScrollingTree::shouldHandleWheelEventSynchronously):
(WebCore::ScrollingTree::commitNewTreeState):

  • page/scrolling/ScrollingTree.h:
  • page/scrolling/mac/ScrollingCoordinatorMac.mm:

(WebCore::ScrollingCoordinatorMac::updateTiledScrollingIndicator):

  • page/scrolling/mac/ScrollingTreeFrameScrollingNodeMac.mm:

(WebCore::ScrollingTreeFrameScrollingNodeMac::updateBeforeChildren):
(WebCore::logWheelEventHandlerCountChanged): Deleted.

  • testing/Internals.cpp:

(WebCore::Internals::touchEventHandlerCount):

Source/WebKit/mac:
Remove scrolling tree dependency on wheel event handler counts, and use fast scrolling even when there are wheel handlers
https://bugs.webkit.org/show_bug.cgi?id=143288

Reviewed by Beth Dakin.

Remove the wheel event counting that Document does, and passes into the scrolling tree.
The ScrollingTree now just uses the non-fast scrollable region to determine when to
fast scroll on pages with wheel event handlers.

  • WebCoreSupport/WebChromeClient.h:

Source/WebKit2:
Remove scrolling tree dependency on wheel event handler counts, and use fast scrolling even when there are wheel handlers
https://bugs.webkit.org/show_bug.cgi?id=143288
rdar://problem/16049624

Reviewed by Beth Dakin.

Remove the wheel event counting that Document does, and passes into the scrolling tree.
The ScrollingTree now just uses the non-fast scrollable region to determine when to
fast scroll on pages with wheel event handlers.

If a handler includes position:fixed renderers, we just cover the whole document
with the slow-scrolling region currently. This could be improved.

  • Shared/Scrolling/RemoteScrollingCoordinatorTransaction.cpp:

(ArgumentCoder<ScrollingStateFrameScrollingNode>::encode):
(ArgumentCoder<ScrollingStateFrameScrollingNode>::decode):
(WebKit::RemoteScrollingTreeTextStream::dump):

  • WebProcess/WebCoreSupport/WebChromeClient.cpp:

(WebKit::WebChromeClient::wheelEventHandlersChanged):
(WebKit::WebChromeClient::numWheelEventHandlersChanged): Deleted.

  • WebProcess/WebCoreSupport/WebChromeClient.h:
  • WebProcess/WebPage/WebPage.cpp:

(WebKit::WebPage::WebPage):
(WebKit::WebPage::wheelEventHandlersChanged):
(WebKit::WebPage::recomputeShortCircuitHorizontalWheelEventsState):
(WebKit::WebPage::numWheelEventHandlersChanged): Deleted.

  • WebProcess/WebPage/WebPage.h:

LayoutTests:
Make it possible to compute a region for elements on the page that have wheel event handlers
https://bugs.webkit.org/show_bug.cgi?id=142807

Reviewed by Beth Dakin.

Update results, since any handler with position:fixed now causes the region to cover the document.

  • platform/mac-wk2/tiled-drawing/scrolling/non-fast-region/wheel-handler-fixed-child-expected.txt:
  • platform/mac-wk2/tiled-drawing/scrolling/non-fast-region/wheel-handler-inside-fixed-expected.txt:
  • platform/mac-wk2/tiled-drawing/scrolling/non-fast-region/wheel-handler-on-fixed-expected.txt:
Location:
trunk
Files:
29 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r182241 r182242  
     12015-03-31  Simon Fraser  <simon.fraser@apple.com>
     2
     3        Make it possible to compute a region for elements on the page that have wheel event handlers
     4        https://bugs.webkit.org/show_bug.cgi?id=142807
     5
     6        Reviewed by Beth Dakin.
     7       
     8        Update results, since any handler with position:fixed now causes the region to cover the document.
     9
     10        * platform/mac-wk2/tiled-drawing/scrolling/non-fast-region/wheel-handler-fixed-child-expected.txt:
     11        * platform/mac-wk2/tiled-drawing/scrolling/non-fast-region/wheel-handler-inside-fixed-expected.txt:
     12        * platform/mac-wk2/tiled-drawing/scrolling/non-fast-region/wheel-handler-on-fixed-expected.txt:
     13
    1142015-04-01  David Hyatt  <hyatt@apple.com>
    215
  • trunk/LayoutTests/platform/mac-wk2/tiled-drawing/scrolling/non-fast-region/wheel-handler-fixed-child-expected.txt

    r182215 r182242  
    1 50, 50 - 150, 150
     10, 0 - 785, 628
  • trunk/LayoutTests/platform/mac-wk2/tiled-drawing/scrolling/non-fast-region/wheel-handler-inside-fixed-expected.txt

    r182215 r182242  
    1 60, 60 - 160, 160
     10, 0 - 800, 600
  • trunk/LayoutTests/platform/mac-wk2/tiled-drawing/scrolling/non-fast-region/wheel-handler-on-fixed-expected.txt

    r182215 r182242  
    1 10, 10 - 110, 110
     10, 0 - 800, 600
  • trunk/Source/WebCore/ChangeLog

    r182241 r182242  
     12015-03-31  Simon Fraser  <simon.fraser@apple.com>
     2
     3        Remove scrolling tree dependency on wheel event handler counts, and use fast scrolling even when there are wheel handlers
     4        https://bugs.webkit.org/show_bug.cgi?id=143288
     5        rdar://problem/16049624
     6
     7        Reviewed by Beth Dakin.
     8
     9        Remove the wheel event counting that Document does, and passes into the scrolling tree.
     10        The ScrollingTree now just uses the non-fast scrollable region to determine when to
     11        fast scroll on pages with wheel event handlers.
     12       
     13        If a handler includes position:fixed renderers, we just cover the whole document
     14        with the slow-scrolling region currently. This could be improved.
     15       
     16        * dom/Document.cpp:
     17        (WebCore::Document::Document):
     18        (WebCore::Document::didBecomeCurrentDocumentInFrame):
     19        (WebCore::Document::wheelEventHandlersChanged):
     20        (WebCore::Document::didAddWheelEventHandler):
     21        (WebCore::Document::didRemoveWheelEventHandler):
     22        (WebCore::Document::wheelEventHandlerCount):
     23        (WebCore::Document::touchEventHandlerCount):
     24        (WebCore::Document::absoluteRegionForEventTargets): Changed to return a pair<Region, bool>
     25        where the bool indicates whether any handler includes position:fixed content.
     26        (WebCore::pageWheelEventHandlerCountChanged): Deleted.
     27        (WebCore::wheelEventHandlerCountChanged): Deleted.
     28        * dom/Document.h:
     29        (WebCore::Document::wheelEventHandlerCount): Deleted.
     30        * loader/EmptyClients.h:
     31        * page/ChromeClient.h:
     32        * page/DebugPageOverlays.cpp:
     33        (WebCore::MouseWheelRegionOverlay::updateRegion):
     34        * page/scrolling/AsyncScrollingCoordinator.cpp:
     35        (WebCore::AsyncScrollingCoordinator::frameViewNonFastScrollableRegionChanged):
     36        (WebCore::AsyncScrollingCoordinator::recomputeWheelEventHandlerCountForFrameView): Deleted.
     37        * page/scrolling/AsyncScrollingCoordinator.h:
     38        * page/scrolling/ScrollingCoordinator.cpp:
     39        (WebCore::ScrollingCoordinator::computeNonFastScrollableRegion):
     40        (WebCore::ScrollingCoordinator::frameViewRootLayerDidChange):
     41        (WebCore::ScrollingCoordinator::computeCurrentWheelEventHandlerCount): Deleted.
     42        (WebCore::ScrollingCoordinator::frameViewWheelEventHandlerCountChanged): Deleted.
     43        * page/scrolling/ScrollingCoordinator.h:
     44        (WebCore::ScrollingCoordinator::recomputeWheelEventHandlerCountForFrameView): Deleted.
     45        * page/scrolling/ScrollingStateFrameScrollingNode.cpp:
     46        (WebCore::ScrollingStateFrameScrollingNode::ScrollingStateFrameScrollingNode):
     47        (WebCore::ScrollingStateFrameScrollingNode::setWheelEventHandlerCount): Deleted.
     48        * page/scrolling/ScrollingStateFrameScrollingNode.h:
     49        * page/scrolling/ScrollingTree.cpp:
     50        (WebCore::ScrollingTree::ScrollingTree):
     51        (WebCore::ScrollingTree::shouldHandleWheelEventSynchronously):
     52        (WebCore::ScrollingTree::commitNewTreeState):
     53        * page/scrolling/ScrollingTree.h:
     54        * page/scrolling/mac/ScrollingCoordinatorMac.mm:
     55        (WebCore::ScrollingCoordinatorMac::updateTiledScrollingIndicator):
     56        * page/scrolling/mac/ScrollingTreeFrameScrollingNodeMac.mm:
     57        (WebCore::ScrollingTreeFrameScrollingNodeMac::updateBeforeChildren):
     58        (WebCore::logWheelEventHandlerCountChanged): Deleted.
     59        * testing/Internals.cpp:
     60        (WebCore::Internals::touchEventHandlerCount):
     61
    1622015-04-01  David Hyatt  <hyatt@apple.com>
    263
  • trunk/Source/WebCore/dom/Document.cpp

    r182240 r182242  
    491491    , m_writeRecursionIsTooDeep(false)
    492492    , m_writeRecursionDepth(0)
    493     , m_wheelEventHandlerCount(0)
    494493    , m_lastHandledUserGestureTimestamp(0)
    495494#if PLATFORM(IOS)
     
    20992098}
    21002099
    2101 static void pageWheelEventHandlerCountChanged(Page& page)
    2102 {
    2103     unsigned count = 0;
    2104     for (const Frame* frame = &page.mainFrame(); frame; frame = frame->tree().traverseNext()) {
    2105         if (Document* document = frame->document())
    2106             count += document->wheelEventHandlerCount();
    2107     }
    2108     page.chrome().client().numWheelEventHandlersChanged(count);
    2109 }
    2110 
    21112100void Document::didBecomeCurrentDocumentInFrame()
    21122101{
     
    21292118    // unless the documents they are replacing had wheel event handlers.
    21302119    if (page() && m_frame->isMainFrame())
    2131         pageWheelEventHandlerCountChanged(*page());
     2120        wheelEventHandlersChanged();
    21322121
    21332122#if ENABLE(TOUCH_EVENTS)
     
    59835972#endif // !PLATFORM(IOS)
    59845973
    5985 static void wheelEventHandlerCountChanged(Document* document)
    5986 {
    5987     Page* page = document->page();
     5974void Document::wheelEventHandlersChanged()
     5975{
     5976    Page* page = this->page();
    59885977    if (!page)
    59895978        return;
    59905979
    5991     pageWheelEventHandlerCountChanged(*page);
    5992 
    5993     ScrollingCoordinator* scrollingCoordinator = page->scrollingCoordinator();
    5994     if (!scrollingCoordinator)
    5995         return;
    5996 
    5997     FrameView* frameView = document->view();
    5998     if (!frameView)
    5999         return;
    6000 
    6001     // FIXME: Why doesn't this need to be called in didBecomeCurrentDocumentInFrame?
    6002     scrollingCoordinator->frameViewWheelEventHandlerCountChanged(*frameView);
     5980    if (FrameView* frameView = view()) {
     5981        if (ScrollingCoordinator* scrollingCoordinator = page->scrollingCoordinator())
     5982            scrollingCoordinator->frameViewNonFastScrollableRegionChanged(*frameView);
     5983    }
     5984
     5985    bool haveHandlers = m_wheelEventTargets && !m_wheelEventTargets->isEmpty();
     5986    page->chrome().client().wheelEventHandlersChanged(haveHandlers);
    60035987}
    60045988
    60055989void Document::didAddWheelEventHandler(Node& node)
    60065990{
    6007     ++m_wheelEventHandlerCount;
    6008 
    60095991    if (!m_wheelEventTargets)
    60105992        m_wheelEventTargets = std::make_unique<EventTargetSet>();
     
    60175999    }
    60186000
    6019     wheelEventHandlerCountChanged(this);
     6001    wheelEventHandlersChanged();
    60206002
    60216003    if (Frame* frame = this->frame())
     
    60256007void Document::didRemoveWheelEventHandler(Node& node)
    60266008{
    6027     ASSERT(m_wheelEventHandlerCount > 0);
    6028     --m_wheelEventHandlerCount;
    6029 
    60306009    if (!m_wheelEventTargets)
    60316010        return;
     
    60396018    }
    60406019
    6041     wheelEventHandlerCountChanged(this);
     6020    wheelEventHandlersChanged();
    60426021
    60436022    if (Frame* frame = this->frame())
    60446023        DebugPageOverlays::didChangeEventHandlers(*frame);
     6024}
     6025
     6026unsigned Document::wheelEventHandlerCount() const
     6027{
     6028    if (!m_wheelEventTargets)
     6029        return 0;
     6030
     6031    unsigned count = 0;
     6032    for (auto& handler : *m_wheelEventTargets)
     6033        count += handler.value;
     6034
     6035    return count;
    60456036}
    60466037
     
    61156106}
    61166107
     6108unsigned Document::touchEventHandlerCount() const
     6109{
     6110#if ENABLE(TOUCH_EVENTS)
     6111    if (!m_touchEventTargets)
     6112        return 0;
     6113
     6114    unsigned count = 0;
     6115    for (auto& handler : *m_touchEventTargets)
     6116        count += handler.value;
     6117
     6118    return count;
     6119#else
     6120    return 0;
     6121#endif
     6122}
     6123
    61176124LayoutRect Document::absoluteEventHandlerBounds(bool& includesFixedPositionElements)
    61186125{
     
    61246131}
    61256132
    6126 Region Document::absoluteRegionForEventTargets(const EventTargetSet* targets)
     6133Document::RegionFixedPair Document::absoluteRegionForEventTargets(const EventTargetSet* targets)
    61276134{
    61286135    if (!targets)
    6129         return Region();
     6136        return RegionFixedPair(Region(), false);
    61306137
    61316138    Region targetRegion;
     
    61506157    }
    61516158
    6152     return targetRegion;
     6159    return RegionFixedPair(targetRegion, insideFixedPosition);
    61536160}
    61546161
  • trunk/Source/WebCore/dom/Document.h

    r182215 r182242  
    11231123    void initDNSPrefetch();
    11241124
    1125     unsigned wheelEventHandlerCount() const { return m_wheelEventHandlerCount; }
    11261125    void didAddWheelEventHandler(Node&);
    11271126    void didRemoveWheelEventHandler(Node&);
     
    11351134    bool hasTouchEventHandlers() const { return false; }
    11361135#endif
     1136
     1137    // Used for testing. Count handlers in the main document, and one per frame which contains handlers.
     1138    WEBCORE_EXPORT unsigned wheelEventHandlerCount() const;
     1139    WEBCORE_EXPORT unsigned touchEventHandlerCount() const;
    11371140
    11381141    void didAddTouchEventHandler(Node&);
     
    11521155    const EventTargetSet* wheelEventTargets() const { return m_wheelEventTargets.get(); }
    11531156
    1154     Region absoluteRegionForEventTargets(const EventTargetSet*);
     1157    typedef std::pair<Region, bool> RegionFixedPair;
     1158    RegionFixedPair absoluteRegionForEventTargets(const EventTargetSet*);
    11551159
    11561160    LayoutRect absoluteEventHandlerBounds(bool&) override final;
     
    13201324
    13211325    void didAssociateFormControlsTimerFired();
     1326
     1327    void wheelEventHandlersChanged();
    13221328
    13231329    // DOM Cookies caching.
     
    15651571    unsigned m_writeRecursionDepth;
    15661572   
    1567     unsigned m_wheelEventHandlerCount;
    15681573#if ENABLE(TOUCH_EVENTS)
    15691574    std::unique_ptr<EventTargetSet> m_touchEventTargets;
  • trunk/Source/WebCore/loader/EmptyClients.h

    r180517 r182242  
    228228#endif
    229229   
    230     virtual void numWheelEventHandlersChanged(unsigned) override { }
     230    virtual void wheelEventHandlersChanged(bool) override { }
    231231   
    232232    virtual bool isEmptyChromeClient() const override { return true; }
  • trunk/Source/WebCore/page/ChromeClient.h

    r181656 r182242  
    397397    virtual bool shouldRunModalDialogDuringPageDismissal(const DialogType&, const String& dialogMessage, FrameLoader::PageDismissalType) const { UNUSED_PARAM(dialogMessage); return true; }
    398398
    399     virtual void numWheelEventHandlersChanged(unsigned) = 0;
     399    virtual void wheelEventHandlersChanged(bool hasHandlers) = 0;
    400400       
    401401    virtual bool isSVGImageChromeClient() const { return false; }
  • trunk/Source/WebCore/page/DebugPageOverlays.cpp

    r182215 r182242  
    9191bool MouseWheelRegionOverlay::updateRegion()
    9292{
    93     std::unique_ptr<Region> region = std::make_unique<Region>(m_frame.document()->absoluteRegionForEventTargets(m_frame.document()->wheelEventTargets()));
     93    std::unique_ptr<Region> region = std::make_unique<Region>(m_frame.document()->absoluteRegionForEventTargets(m_frame.document()->wheelEventTargets()).first);
    9494
    9595    bool regionChanged = !m_region || !(*m_region == *region);
  • trunk/Source/WebCore/page/scrolling/AsyncScrollingCoordinator.cpp

    r182132 r182242  
    136136        return;
    137137
     138    // FIXME: computeNonFastScrollableRegion lazily.
    138139    m_scrollingStateTree->rootStateNode()->setNonFastScrollableRegion(computeNonFastScrollableRegion(m_page->mainFrame(), IntPoint()));
    139140}
     
    488489}
    489490
    490 void AsyncScrollingCoordinator::recomputeWheelEventHandlerCountForFrameView(FrameView& frameView)
    491 {
    492     ScrollingStateFrameScrollingNode* node = downcast<ScrollingStateFrameScrollingNode>(m_scrollingStateTree->stateNodeForID(frameView.scrollLayerID()));
    493     if (!node)
    494         return;
    495     node->setWheelEventHandlerCount(computeCurrentWheelEventHandlerCount());
    496 }
    497 
    498491bool AsyncScrollingCoordinator::isRubberBandInProgress() const
    499492{
  • trunk/Source/WebCore/page/scrolling/AsyncScrollingCoordinator.h

    r182132 r182242  
    9797    WEBCORE_EXPORT virtual void scrollableAreaScrollbarLayerDidChange(ScrollableArea&, ScrollbarOrientation) override;
    9898
    99     WEBCORE_EXPORT virtual void recomputeWheelEventHandlerCountForFrameView(FrameView&) override;
    10099    WEBCORE_EXPORT virtual void setSynchronousScrollingReasons(SynchronousScrollingReasons) override;
    101100
  • trunk/Source/WebCore/page/scrolling/ScrollingCoordinator.cpp

    r182215 r182242  
    155155
    156156    // Include wheel event handler region for the main frame.
    157     Region wheelHandlerRegion = frame.document()->absoluteRegionForEventTargets(frame.document()->wheelEventTargets());
    158     wheelHandlerRegion.translate(toIntSize(offset));
    159     nonFastScrollableRegion.unite(wheelHandlerRegion);
     157    Document::RegionFixedPair wheelHandlerRegion = frame.document()->absoluteRegionForEventTargets(frame.document()->wheelEventTargets());
     158    bool wheelHandlerInFixedContent = wheelHandlerRegion.second;
     159    if (wheelHandlerInFixedContent) {
     160        // FIXME: if a fixed element has a wheel event handler, for now just cover the entire document
     161        // with the slow-scrolling region. This could be improved.
     162        // FIXME: need to handle position:sticky here too.
     163        bool inFixed;
     164        wheelHandlerRegion.first.unite(enclosingIntRect(frame.document()->absoluteEventHandlerBounds(inFixed)));
     165    }
     166    wheelHandlerRegion.first.translate(toIntSize(offset));
     167    nonFastScrollableRegion.unite(wheelHandlerRegion.first);
    160168
    161169    return nonFastScrollableRegion;
     
    163171}
    164172
    165 unsigned ScrollingCoordinator::computeCurrentWheelEventHandlerCount()
    166 {
    167     unsigned wheelEventHandlerCount = 0;
    168 
    169     for (Frame* frame = &m_page->mainFrame(); frame; frame = frame->tree().traverseNext()) {
    170         if (frame->document())
    171             wheelEventHandlerCount += frame->document()->wheelEventHandlerCount();
    172     }
    173 
    174     return wheelEventHandlerCount;
    175 }
    176 
    177 void ScrollingCoordinator::frameViewWheelEventHandlerCountChanged(FrameView& frameView)
     173void ScrollingCoordinator::frameViewHasSlowRepaintObjectsDidChange(FrameView& frameView)
    178174{
    179175    ASSERT(isMainThread());
    180176    ASSERT(m_page);
    181177
    182     recomputeWheelEventHandlerCountForFrameView(frameView);
    183 }
    184 
    185 void ScrollingCoordinator::frameViewHasSlowRepaintObjectsDidChange(FrameView& frameView)
     178    if (!coordinatesScrollingForFrameView(frameView))
     179        return;
     180
     181    updateSynchronousScrollingReasons(frameView);
     182}
     183
     184void ScrollingCoordinator::frameViewFixedObjectsDidChange(FrameView& frameView)
    186185{
    187186    ASSERT(isMainThread());
     
    194193}
    195194
    196 void ScrollingCoordinator::frameViewFixedObjectsDidChange(FrameView& frameView)
     195GraphicsLayer* ScrollingCoordinator::scrollLayerForScrollableArea(ScrollableArea& scrollableArea)
     196{
     197    return scrollableArea.layerForScrolling();
     198}
     199
     200GraphicsLayer* ScrollingCoordinator::scrollLayerForFrameView(FrameView& frameView)
     201{
     202    if (RenderView* renderView = frameView.frame().contentRenderer())
     203        return renderView->compositor().scrollLayer();
     204    return nullptr;
     205}
     206
     207GraphicsLayer* ScrollingCoordinator::headerLayerForFrameView(FrameView& frameView)
     208{
     209#if ENABLE(RUBBER_BANDING)
     210    if (RenderView* renderView = frameView.frame().contentRenderer())
     211        return renderView->compositor().headerLayer();
     212    return nullptr;
     213#else
     214    UNUSED_PARAM(frameView);
     215    return nullptr;
     216#endif
     217}
     218
     219GraphicsLayer* ScrollingCoordinator::footerLayerForFrameView(FrameView& frameView)
     220{
     221#if ENABLE(RUBBER_BANDING)
     222    if (RenderView* renderView = frameView.frame().contentRenderer())
     223        return renderView->compositor().footerLayer();
     224    return nullptr;
     225#else
     226    UNUSED_PARAM(frameView);
     227    return nullptr;
     228#endif
     229}
     230
     231GraphicsLayer* ScrollingCoordinator::counterScrollingLayerForFrameView(FrameView& frameView)
     232{
     233    if (RenderView* renderView = frameView.frame().contentRenderer())
     234        return renderView->compositor().fixedRootBackgroundLayer();
     235    return nullptr;
     236}
     237
     238GraphicsLayer* ScrollingCoordinator::insetClipLayerForFrameView(FrameView& frameView)
     239{
     240    if (RenderView* renderView = frameView.frame().contentRenderer())
     241        return renderView->compositor().clipLayer();
     242    return nullptr;
     243}
     244
     245GraphicsLayer* ScrollingCoordinator::contentShadowLayerForFrameView(FrameView& frameView)
     246{
     247#if ENABLE(RUBBER_BANDING)
     248    if (RenderView* renderView = frameView.frame().contentRenderer())
     249        return renderView->compositor().layerForContentShadow();
     250   
     251    return nullptr;
     252#else
     253    UNUSED_PARAM(frameView);
     254    return nullptr;
     255#endif
     256}
     257
     258GraphicsLayer* ScrollingCoordinator::rootContentLayerForFrameView(FrameView& frameView)
     259{
     260    if (RenderView* renderView = frameView.frame().contentRenderer())
     261        return renderView->compositor().rootContentLayer();
     262    return nullptr;
     263}
     264
     265void ScrollingCoordinator::frameViewRootLayerDidChange(FrameView& frameView)
    197266{
    198267    ASSERT(isMainThread());
     
    202271        return;
    203272
    204     updateSynchronousScrollingReasons(frameView);
    205 }
    206 
    207 GraphicsLayer* ScrollingCoordinator::scrollLayerForScrollableArea(ScrollableArea& scrollableArea)
    208 {
    209     return scrollableArea.layerForScrolling();
    210 }
    211 
    212 GraphicsLayer* ScrollingCoordinator::scrollLayerForFrameView(FrameView& frameView)
    213 {
    214     if (RenderView* renderView = frameView.frame().contentRenderer())
    215         return renderView->compositor().scrollLayer();
    216     return nullptr;
    217 }
    218 
    219 GraphicsLayer* ScrollingCoordinator::headerLayerForFrameView(FrameView& frameView)
    220 {
    221 #if ENABLE(RUBBER_BANDING)
    222     if (RenderView* renderView = frameView.frame().contentRenderer())
    223         return renderView->compositor().headerLayer();
    224     return nullptr;
    225 #else
    226     UNUSED_PARAM(frameView);
    227     return nullptr;
    228 #endif
    229 }
    230 
    231 GraphicsLayer* ScrollingCoordinator::footerLayerForFrameView(FrameView& frameView)
    232 {
    233 #if ENABLE(RUBBER_BANDING)
    234     if (RenderView* renderView = frameView.frame().contentRenderer())
    235         return renderView->compositor().footerLayer();
    236     return nullptr;
    237 #else
    238     UNUSED_PARAM(frameView);
    239     return nullptr;
    240 #endif
    241 }
    242 
    243 GraphicsLayer* ScrollingCoordinator::counterScrollingLayerForFrameView(FrameView& frameView)
    244 {
    245     if (RenderView* renderView = frameView.frame().contentRenderer())
    246         return renderView->compositor().fixedRootBackgroundLayer();
    247     return nullptr;
    248 }
    249 
    250 GraphicsLayer* ScrollingCoordinator::insetClipLayerForFrameView(FrameView& frameView)
    251 {
    252     if (RenderView* renderView = frameView.frame().contentRenderer())
    253         return renderView->compositor().clipLayer();
    254     return nullptr;
    255 }
    256 
    257 GraphicsLayer* ScrollingCoordinator::contentShadowLayerForFrameView(FrameView& frameView)
    258 {
    259 #if ENABLE(RUBBER_BANDING)
    260     if (RenderView* renderView = frameView.frame().contentRenderer())
    261         return renderView->compositor().layerForContentShadow();
    262    
    263     return nullptr;
    264 #else
    265     UNUSED_PARAM(frameView);
    266     return nullptr;
    267 #endif
    268 }
    269 
    270 GraphicsLayer* ScrollingCoordinator::rootContentLayerForFrameView(FrameView& frameView)
    271 {
    272     if (RenderView* renderView = frameView.frame().contentRenderer())
    273         return renderView->compositor().rootContentLayer();
    274     return nullptr;
    275 }
    276 
    277 void ScrollingCoordinator::frameViewRootLayerDidChange(FrameView& frameView)
    278 {
    279     ASSERT(isMainThread());
    280     ASSERT(m_page);
    281 
    282     if (!coordinatesScrollingForFrameView(frameView))
    283         return;
    284 
    285273    frameViewLayoutUpdated(frameView);
    286     recomputeWheelEventHandlerCountForFrameView(frameView);
    287274    updateSynchronousScrollingReasons(frameView);
    288275}
  • trunk/Source/WebCore/page/scrolling/ScrollingCoordinator.h

    r182132 r182242  
    121121    virtual void frameViewLayoutUpdated(FrameView&) { }
    122122
    123     // Should be called whenever a wheel event handler is added or removed in the
    124     // frame view's underlying document.
    125     void frameViewWheelEventHandlerCountChanged(FrameView&);
    126 
    127123    // Should be called whenever the slow repaint objects counter changes between zero and one.
    128124    void frameViewHasSlowRepaintObjectsDidChange(FrameView&);
     
    211207    static GraphicsLayer* scrollLayerForScrollableArea(ScrollableArea&);
    212208
    213     unsigned computeCurrentWheelEventHandlerCount();
    214209    GraphicsLayer* scrollLayerForFrameView(FrameView&);
    215210    GraphicsLayer* counterScrollingLayerForFrameView(FrameView&);
     
    223218
    224219private:
    225     virtual void recomputeWheelEventHandlerCountForFrameView(FrameView&) { }
    226220    virtual void setSynchronousScrollingReasons(SynchronousScrollingReasons) { }
    227221
  • trunk/Source/WebCore/page/scrolling/ScrollingStateFrameScrollingNode.cpp

    r180493 r182242  
    4646#endif
    4747    , m_frameScaleFactor(1)
    48     , m_wheelEventHandlerCount(0)
    4948    , m_synchronousScrollingReasons(0)
    5049    , m_behaviorForFixed(StickToDocumentBounds)
     
    6463    , m_nonFastScrollableRegion(stateNode.nonFastScrollableRegion())
    6564    , m_frameScaleFactor(stateNode.frameScaleFactor())
    66     , m_wheelEventHandlerCount(stateNode.wheelEventHandlerCount())
    6765    , m_synchronousScrollingReasons(stateNode.synchronousScrollingReasons())
    6866    , m_behaviorForFixed(stateNode.scrollBehaviorForFixedElements())
     
    118116    m_nonFastScrollableRegion = nonFastScrollableRegion;
    119117    setPropertyChanged(NonFastScrollableRegion);
    120 }
    121 
    122 void ScrollingStateFrameScrollingNode::setWheelEventHandlerCount(unsigned wheelEventHandlerCount)
    123 {
    124     if (m_wheelEventHandlerCount == wheelEventHandlerCount)
    125         return;
    126 
    127     m_wheelEventHandlerCount = wheelEventHandlerCount;
    128     setPropertyChanged(WheelEventHandlerCount);
    129118}
    130119
  • trunk/Source/WebCore/page/scrolling/ScrollingStateFrameScrollingNode.h

    r176915 r182242  
    5050        FrameScaleFactor = NumScrollingStateNodeBits,
    5151        NonFastScrollableRegion,
    52         WheelEventHandlerCount,
    5352        ReasonsForSynchronousScrolling,
    5453        ScrolledContentsLayer,
     
    7069    const Region& nonFastScrollableRegion() const { return m_nonFastScrollableRegion; }
    7170    WEBCORE_EXPORT void setNonFastScrollableRegion(const Region&);
    72 
    73     unsigned wheelEventHandlerCount() const { return m_wheelEventHandlerCount; }
    74     WEBCORE_EXPORT void setWheelEventHandlerCount(unsigned);
    7571
    7672    SynchronousScrollingReasons synchronousScrollingReasons() const { return m_synchronousScrollingReasons; }
     
    140136    Region m_nonFastScrollableRegion;
    141137    float m_frameScaleFactor;
    142     unsigned m_wheelEventHandlerCount;
    143138    SynchronousScrollingReasons m_synchronousScrollingReasons;
    144139    ScrollBehaviorForFixedElements m_behaviorForFixed;
  • trunk/Source/WebCore/page/scrolling/ScrollingTree.cpp

    r177835 r182242  
    3939
    4040ScrollingTree::ScrollingTree()
    41     : m_hasWheelEventHandlers(false)
    42     , m_rubberBandsAtLeft(true)
     41    : m_rubberBandsAtLeft(true)
    4342    , m_rubberBandsAtRight(true)
    4443    , m_rubberBandsAtTop(true)
     
    6665    MutexLocker lock(m_mutex);
    6766
    68     if (m_hasWheelEventHandlers)
    69         return true;
    70 
    7167    bool shouldSetLatch = wheelEvent.shouldConsiderLatching();
    7268   
     
    130126    if (rootNode
    131127        && (rootStateNodeChanged
    132             || rootNode->hasChangedProperty(ScrollingStateFrameScrollingNode::WheelEventHandlerCount)
    133128            || rootNode->hasChangedProperty(ScrollingStateFrameScrollingNode::NonFastScrollableRegion)
    134129            || rootNode->hasChangedProperty(ScrollingStateNode::ScrollLayer))) {
     
    137132        if (rootStateNodeChanged || rootNode->hasChangedProperty(ScrollingStateNode::ScrollLayer))
    138133            m_mainFrameScrollPosition = FloatPoint();
    139         if (rootStateNodeChanged || rootNode->hasChangedProperty(ScrollingStateFrameScrollingNode::WheelEventHandlerCount))
    140             m_hasWheelEventHandlers = scrollingStateTree->rootStateNode()->wheelEventHandlerCount();
    141134        if (rootStateNodeChanged || rootNode->hasChangedProperty(ScrollingStateFrameScrollingNode::NonFastScrollableRegion))
    142135            m_nonFastScrollableRegion = scrollingStateTree->rootStateNode()->nonFastScrollableRegion();
  • trunk/Source/WebCore/page/scrolling/ScrollingTree.h

    r180493 r182242  
    157157    Region m_nonFastScrollableRegion;
    158158    FloatPoint m_mainFrameScrollPosition;
    159     bool m_hasWheelEventHandlers;
    160159
    161160    Mutex m_swipeStateMutex;
  • trunk/Source/WebCore/page/scrolling/mac/ScrollingCoordinatorMac.mm

    r182132 r182242  
    145145    if (shouldUpdateScrollLayerPositionSynchronously())
    146146        indicatorMode = SynchronousScrollingBecauseOfStyleIndication;
    147     else if (scrollingStateTree()->rootStateNode() && scrollingStateTree()->rootStateNode()->wheelEventHandlerCount())
    148         indicatorMode =  SynchronousScrollingBecauseOfEventHandlersIndication;
    149147    else
    150148        indicatorMode = AsyncScrollingIndication;
  • trunk/Source/WebCore/page/scrolling/mac/ScrollingTreeFrameScrollingNodeMac.mm

    r181813 r182242  
    4848
    4949static void logThreadedScrollingMode(unsigned synchronousScrollingReasons);
    50 static void logWheelEventHandlerCountChanged(unsigned);
    51 
    5250
    5351PassRefPtr<ScrollingTreeFrameScrollingNode> ScrollingTreeFrameScrollingNodeMac::create(ScrollingTree& scrollingTree, ScrollingNodeID nodeID)
     
    134132    }
    135133
    136     if (scrollingStateNode.hasChangedProperty(ScrollingStateFrameScrollingNode::WheelEventHandlerCount)) {
    137         if (scrollingTree().scrollingPerformanceLoggingEnabled())
    138             logWheelEventHandlerCountChanged(scrollingStateNode.wheelEventHandlerCount());
    139     }
    140 
    141134#if ENABLE(CSS_SCROLL_SNAP)
    142135    if (scrollingStateNode.hasChangedProperty(ScrollingStateFrameScrollingNode::HorizontalSnapOffsets))
     
    544537}
    545538
    546 void logWheelEventHandlerCountChanged(unsigned count)
    547 {
    548     WTFLogAlways("SCROLLING: Wheel event handler count changed. Time: %f Count: %u\n", WTF::monotonicallyIncreasingTime(), count);
    549 }
    550 
    551539#if ENABLE(CSS_SCROLL_SNAP) && PLATFORM(MAC)
    552540LayoutUnit ScrollingTreeFrameScrollingNodeMac::scrollOffsetOnAxis(ScrollEventAxis axis) const
  • trunk/Source/WebCore/testing/Internals.cpp

    r182152 r182242  
    12551255    }
    12561256
    1257     auto touchHandlers = document->touchEventTargets();
    1258     if (!touchHandlers)
    1259         return 0;
    1260 
    1261     unsigned count = 0;
    1262     for (auto& handler : *touchHandlers)
    1263         count += handler.value;
    1264 
    1265     return count;
     1257    return document->touchEventHandlerCount();
    12661258}
    12671259
  • trunk/Source/WebKit/mac/ChangeLog

    r182217 r182242  
     12015-03-31  Simon Fraser  <simon.fraser@apple.com>
     2
     3        Remove scrolling tree dependency on wheel event handler counts, and use fast scrolling even when there are wheel handlers
     4        https://bugs.webkit.org/show_bug.cgi?id=143288
     5
     6        Reviewed by Beth Dakin.
     7
     8        Remove the wheel event counting that Document does, and passes into the scrolling tree.
     9        The ScrollingTree now just uses the non-fast scrollable region to determine when to
     10        fast scroll on pages with wheel event handlers.
     11
     12        * WebCoreSupport/WebChromeClient.h:
     13
    1142015-03-31  Timothy Horton  <timothy_horton@apple.com>
    215
  • trunk/Source/WebKit/mac/WebCoreSupport/WebChromeClient.h

    r181838 r182242  
    196196    virtual PassRefPtr<WebCore::SearchPopupMenu> createSearchPopupMenu(WebCore::PopupMenuClient*) const override;
    197197
    198     virtual void numWheelEventHandlersChanged(unsigned) override { }
     198    virtual void wheelEventHandlersChanged(bool) override { }
    199199
    200200#if ENABLE(SUBTLE_CRYPTO)
  • trunk/Source/WebKit2/ChangeLog

    r182219 r182242  
     12015-03-31  Simon Fraser  <simon.fraser@apple.com>
     2
     3        Remove scrolling tree dependency on wheel event handler counts, and use fast scrolling even when there are wheel handlers
     4        https://bugs.webkit.org/show_bug.cgi?id=143288
     5        rdar://problem/16049624
     6
     7        Reviewed by Beth Dakin.
     8
     9        Remove the wheel event counting that Document does, and passes into the scrolling tree.
     10        The ScrollingTree now just uses the non-fast scrollable region to determine when to
     11        fast scroll on pages with wheel event handlers.
     12       
     13        If a handler includes position:fixed renderers, we just cover the whole document
     14        with the slow-scrolling region currently. This could be improved.
     15
     16        * Shared/Scrolling/RemoteScrollingCoordinatorTransaction.cpp:
     17        (ArgumentCoder<ScrollingStateFrameScrollingNode>::encode):
     18        (ArgumentCoder<ScrollingStateFrameScrollingNode>::decode):
     19        (WebKit::RemoteScrollingTreeTextStream::dump):
     20        * WebProcess/WebCoreSupport/WebChromeClient.cpp:
     21        (WebKit::WebChromeClient::wheelEventHandlersChanged):
     22        (WebKit::WebChromeClient::numWheelEventHandlersChanged): Deleted.
     23        * WebProcess/WebCoreSupport/WebChromeClient.h:
     24        * WebProcess/WebPage/WebPage.cpp:
     25        (WebKit::WebPage::WebPage):
     26        (WebKit::WebPage::wheelEventHandlersChanged):
     27        (WebKit::WebPage::recomputeShortCircuitHorizontalWheelEventsState):
     28        (WebKit::WebPage::numWheelEventHandlersChanged): Deleted.
     29        * WebProcess/WebPage/WebPage.h:
     30
    1312015-03-31  Dan Bernstein  <mitz@apple.com>
    232
  • trunk/Source/WebKit2/Shared/Scrolling/RemoteScrollingCoordinatorTransaction.cpp

    r177835 r182242  
    144144    SCROLLING_NODE_ENCODE(ScrollingStateFrameScrollingNode::FrameScaleFactor, frameScaleFactor)
    145145    SCROLLING_NODE_ENCODE(ScrollingStateFrameScrollingNode::NonFastScrollableRegion, nonFastScrollableRegion)
    146     SCROLLING_NODE_ENCODE(ScrollingStateFrameScrollingNode::WheelEventHandlerCount, wheelEventHandlerCount)
    147146    SCROLLING_NODE_ENCODE(ScrollingStateFrameScrollingNode::ReasonsForSynchronousScrolling, synchronousScrollingReasons)
    148147    SCROLLING_NODE_ENCODE_ENUM(ScrollingStateFrameScrollingNode::BehaviorForFixedElements, scrollBehaviorForFixedElements)
     
    226225    SCROLLING_NODE_DECODE(ScrollingStateFrameScrollingNode::FrameScaleFactor, float, setFrameScaleFactor);
    227226    SCROLLING_NODE_DECODE(ScrollingStateFrameScrollingNode::NonFastScrollableRegion, Region, setNonFastScrollableRegion);
    228     SCROLLING_NODE_DECODE(ScrollingStateFrameScrollingNode::WheelEventHandlerCount, int, setWheelEventHandlerCount);
    229227    SCROLLING_NODE_DECODE(ScrollingStateFrameScrollingNode::ReasonsForSynchronousScrolling, SynchronousScrollingReasons, setSynchronousScrollingReasons);
    230228    SCROLLING_NODE_DECODE_ENUM(ScrollingStateFrameScrollingNode::BehaviorForFixedElements, ScrollBehaviorForFixedElements, setScrollBehaviorForFixedElements);
     
    621619    }
    622620
    623     // FIXME: dump wheelEventHandlerCount
    624621    // FIXME: dump synchronousScrollingReasons
    625622    // FIXME: dump scrollableAreaParameters
  • trunk/Source/WebKit2/WebProcess/WebCoreSupport/WebChromeClient.cpp

    r181656 r182242  
    991991}
    992992
    993 void WebChromeClient::numWheelEventHandlersChanged(unsigned count)
    994 {
    995     m_page->numWheelEventHandlersChanged(count);
     993void WebChromeClient::wheelEventHandlersChanged(bool hasHandlers)
     994{
     995    m_page->wheelEventHandlersChanged(hasHandlers);
    996996}
    997997
  • trunk/Source/WebKit2/WebProcess/WebCoreSupport/WebChromeClient.h

    r181656 r182242  
    281281    virtual void pageExtendedBackgroundColorDidChange(WebCore::Color) const override;
    282282   
    283     virtual void numWheelEventHandlersChanged(unsigned) override;
     283    virtual void wheelEventHandlersChanged(bool) override;
    284284
    285285    virtual String plugInStartLabelTitle(const String& mimeType) const override;
  • trunk/Source/WebKit2/WebProcess/WebPage/WebPage.cpp

    r181986 r182242  
    305305    , m_cachedMainFrameIsPinnedToBottomSide(true)
    306306    , m_canShortCircuitHorizontalWheelEvents(false)
    307     , m_numWheelEventHandlers(0)
     307    , m_hasWheelEventHandlers(false)
    308308    , m_cachedPageCount(0)
    309309    , m_autoSizingShouldExpandToViewHeight(false)
     
    40564056}
    40574057
    4058 void WebPage::numWheelEventHandlersChanged(unsigned numWheelEventHandlers)
    4059 {
    4060     if (m_numWheelEventHandlers == numWheelEventHandlers)
    4061         return;
    4062 
    4063     m_numWheelEventHandlers = numWheelEventHandlers;
     4058void WebPage::wheelEventHandlersChanged(bool hasHandlers)
     4059{
     4060    if (m_hasWheelEventHandlers == hasHandlers)
     4061        return;
     4062
     4063    m_hasWheelEventHandlers = hasHandlers;
    40644064    recomputeShortCircuitHorizontalWheelEventsState();
    40654065}
     
    41044104void WebPage::recomputeShortCircuitHorizontalWheelEventsState()
    41054105{
    4106     bool canShortCircuitHorizontalWheelEvents = !m_numWheelEventHandlers;
     4106    bool canShortCircuitHorizontalWheelEvents = !m_hasWheelEventHandlers;
    41074107
    41084108    if (canShortCircuitHorizontalWheelEvents) {
  • trunk/Source/WebKit2/WebProcess/WebPage/WebPage.h

    r181972 r182242  
    761761    void wheelEvent(const WebWheelEvent&);
    762762
    763     void numWheelEventHandlersChanged(unsigned);
     763    void wheelEventHandlersChanged(bool);
    764764    void recomputeShortCircuitHorizontalWheelEventsState();
    765765
     
    12641264    bool m_cachedMainFrameIsPinnedToBottomSide;
    12651265    bool m_canShortCircuitHorizontalWheelEvents;
    1266     unsigned m_numWheelEventHandlers;
     1266    bool m_hasWheelEventHandlers;
    12671267
    12681268    unsigned m_cachedPageCount;
Note: See TracChangeset for help on using the changeset viewer.