Changeset 107467 in webkit


Ignore:
Timestamp:
Feb 10, 2012 6:33:17 PM (12 years ago)
Author:
andersca@apple.com
Message:

Always update the scroll position through the scrolling coordinator
https://bugs.webkit.org/show_bug.cgi?id=78403

Reviewed by Sam Weinig.

To get correct behavior, we always want to update the scrolling layer position
on the scrolling thread. Do this by allowing the scrolling coordinator to intercept
scroll position update requests and send them to the scrolling tree.

  • page/FrameView.cpp:

(WebCore::FrameView::requestScrollPositionUpdate):
Let the scrolling coordinator have a go at updating the scroll position for this frame view.

  • page/scrolling/ScrollingCoordinator.cpp:

(WebCore::ScrollingCoordinator::requestScrollPositionUpdate):
If it's a frame view we're coordinating scrolling for, tell the scrolling tree to update
the scroll position.

  • page/scrolling/ScrollingTree.cpp:

(WebCore::ScrollingTree::setMainFrameScrollPosition):
Call through to the scrolling tree node.

  • page/scrolling/ScrollingTreeNode.h:

Add a new pure virtual setScrollPosition member function.

(WebCore::ScrollingTreeNodeMac::setScrollPosition):
Move most of the code from scrollBy here.

(WebCore::ScrollingTreeNodeMac::setScrollLayerPosition):
Rename this member function from setScrollPosition to avoid conflicts.

(WebCore::ScrollingTreeNodeMac::scrollBy):
Just call setScsrollPosition.

  • platform/ScrollableArea.cpp:

(WebCore::ScrollableArea::setScrollOffsetFromAnimation):
Call requestScrollPositionUpdate, which allows subclasses of scrollable area to intercept
the scroll operation and call it asynchronously.

Location:
trunk/Source/WebCore
Files:
12 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r107466 r107467  
     12012-02-10  Anders Carlsson  <andersca@apple.com>
     2
     3        Always update the scroll position through the scrolling coordinator
     4        https://bugs.webkit.org/show_bug.cgi?id=78403
     5
     6        Reviewed by Sam Weinig.
     7
     8        To get correct behavior, we always want to update the scrolling layer position
     9        on the scrolling thread. Do this by allowing the scrolling coordinator to intercept
     10        scroll position update requests and send them to the scrolling tree.
     11
     12        * page/FrameView.cpp:
     13        (WebCore::FrameView::requestScrollPositionUpdate):
     14        Let the scrolling coordinator have a go at updating the scroll position for this frame view.
     15
     16        * page/scrolling/ScrollingCoordinator.cpp:
     17        (WebCore::ScrollingCoordinator::requestScrollPositionUpdate):
     18        If it's a frame view we're coordinating scrolling for, tell the scrolling tree to update
     19        the scroll position.
     20
     21        * page/scrolling/ScrollingTree.cpp:
     22        (WebCore::ScrollingTree::setMainFrameScrollPosition):
     23        Call through to the scrolling tree node.
     24
     25        * page/scrolling/ScrollingTreeNode.h:
     26        Add a new pure virtual setScrollPosition member function.
     27
     28        (WebCore::ScrollingTreeNodeMac::setScrollPosition):
     29        Move most of the code from scrollBy here.
     30
     31        (WebCore::ScrollingTreeNodeMac::setScrollLayerPosition):
     32        Rename this member function from setScrollPosition to avoid conflicts.
     33
     34        (WebCore::ScrollingTreeNodeMac::scrollBy):
     35        Just call setScsrollPosition.
     36
     37        * platform/ScrollableArea.cpp:
     38        (WebCore::ScrollableArea::setScrollOffsetFromAnimation):
     39        Call requestScrollPositionUpdate, which allows subclasses of scrollable area to intercept
     40        the scroll operation and call it asynchronously.
     41
    1422012-02-10  Anders Carlsson  <andersca@apple.com>
    243
  • trunk/Source/WebCore/page/FrameView.cpp

    r107461 r107467  
    17601760}
    17611761
     1762bool FrameView::requestScrollPositionUpdate(const IntPoint& position)
     1763{
     1764#if ENABLE(THREADED_SCROLLING)
     1765    if (Page* page = m_frame->page()) {
     1766        if (ScrollingCoordinator* scrollingCoordinator = page->scrollingCoordinator())
     1767            return scrollingCoordinator->requestScrollPositionUpdate(this, position);
     1768    }
     1769#endif
     1770
     1771    return false;
     1772}
     1773
    17621774HostWindow* FrameView::hostWindow() const
    17631775{
  • trunk/Source/WebCore/page/FrameView.h

    r107335 r107467  
    170170    virtual void repaintFixedElementsAfterScrolling();
    171171    virtual bool shouldRubberBandInDirection(ScrollDirection) const;
     172    virtual bool requestScrollPositionUpdate(const IntPoint&) OVERRIDE;
    172173
    173174    virtual void zoomAnimatorTransformChanged(float, float, float, ZoomAnimationState);
  • trunk/Source/WebCore/page/scrolling/ScrollingCoordinator.cpp

    r107466 r107467  
    159159}
    160160
     161bool ScrollingCoordinator::requestScrollPositionUpdate(FrameView* frameView, const IntPoint& scrollPosition)
     162{
     163    ASSERT(isMainThread());
     164    ASSERT(m_page);
     165
     166    if (!coordinatesScrollingForFrameView(frameView))
     167        return false;
     168
     169    ScrollingThread::dispatch(bind(&ScrollingTree::setMainFrameScrollPosition, m_scrollingTree.get(), scrollPosition));
     170    return true;
     171}
     172
    161173void ScrollingCoordinator::updateMainFrameScrollPosition(const IntPoint& scrollPosition)
    162174{
  • trunk/Source/WebCore/page/scrolling/ScrollingCoordinator.h

    r107335 r107467  
    8484    void frameViewVerticalScrollbarLayerDidChange(FrameView*, GraphicsLayer* verticalScrollbarLayer);
    8585
     86    // Requests that the scrolling coordinator updates the scroll position of the given frame view. If this function returns true, it means that the
     87    // position will be updated asynchronously. If it returns false, the caller should update the scrolling position itself.
     88    bool requestScrollPositionUpdate(FrameView*, const IntPoint&);
     89
    8690    // Dispatched by the scrolling tree whenever the main frame scroll position changes.
    8791    void updateMainFrameScrollPosition(const IntPoint&);
  • trunk/Source/WebCore/page/scrolling/ScrollingTree.cpp

    r107335 r107467  
    8383}
    8484
     85void ScrollingTree::setMainFrameScrollPosition(const IntPoint& scrollPosition)
     86{
     87    ASSERT(ScrollingThread::isCurrentThread());
     88
     89    m_rootNode->setScrollPosition(scrollPosition);
     90}
     91
    8592void ScrollingTree::invalidate()
    8693{
  • trunk/Source/WebCore/page/scrolling/ScrollingTree.h

    r107335 r107467  
    6161    void handleWheelEvent(const PlatformWheelEvent&);
    6262
     63    void setMainFrameScrollPosition(const IntPoint&);
     64
    6365    void invalidate();
    6466    void commitNewTreeState(PassOwnPtr<ScrollingTreeState>);
  • trunk/Source/WebCore/page/scrolling/ScrollingTreeNode.h

    r107335 r107467  
    4646    virtual void update(ScrollingTreeState*);
    4747    virtual void handleWheelEvent(const PlatformWheelEvent&) = 0;
     48    virtual void setScrollPosition(const IntPoint&) = 0;
    4849
    4950protected:
  • trunk/Source/WebCore/page/scrolling/mac/ScrollingTreeNodeMac.h

    r107285 r107467  
    4545    virtual void update(ScrollingTreeState*) OVERRIDE;
    4646    virtual void handleWheelEvent(const PlatformWheelEvent&) OVERRIDE;
     47    virtual void setScrollPosition(const IntPoint&) OVERRIDE;
    4748
    4849    // ScrollElasticityController member functions.
     
    6162
    6263    IntPoint scrollPosition() const;
    63     void setScrollPosition(const IntPoint&);
     64    void setScrollLayerPosition(const IntPoint&);
    6465
    6566    void scrollBy(const IntSize&);
  • trunk/Source/WebCore/page/scrolling/mac/ScrollingTreeNodeMac.mm

    r107335 r107467  
    5757    // FXIME: This needs to handle rubberbanding.
    5858    scrollBy(IntSize(-wheelEvent.deltaX(), -wheelEvent.deltaY()));
     59}
     60
     61void ScrollingTreeNodeMac::setScrollPosition(const IntPoint& scrollPosition)
     62{
     63    if (shouldUpdateScrollLayerPositionOnMainThread()) {
     64        scrollingTree()->updateMainFrameScrollPositionAndScrollLayerPosition(scrollPosition);
     65        return;
     66    }
     67
     68    setScrollLayerPosition(scrollPosition);
     69    scrollingTree()->updateMainFrameScrollPosition(scrollPosition);
    5970}
    6071
     
    133144}
    134145
    135 void ScrollingTreeNodeMac::setScrollPosition(const IntPoint& position)
     146void ScrollingTreeNodeMac::setScrollLayerPosition(const IntPoint& position)
    136147{
    137148    ASSERT(!shouldUpdateScrollLayerPositionOnMainThread());
     
    142153void ScrollingTreeNodeMac::scrollBy(const IntSize& offset)
    143154{
    144     IntPoint newScrollPosition = scrollPosition() + offset;
    145 
    146     if (shouldUpdateScrollLayerPositionOnMainThread()) {
    147         scrollingTree()->updateMainFrameScrollPositionAndScrollLayerPosition(newScrollPosition);
    148         return;
    149     }
    150 
    151     setScrollPosition(newScrollPosition);
    152     scrollingTree()->updateMainFrameScrollPosition(newScrollPosition);
     155    setScrollPosition(scrollPosition() + offset);
    153156}
    154157
  • trunk/Source/WebCore/platform/ScrollableArea.cpp

    r107466 r107467  
    177177void ScrollableArea::setScrollOffsetFromAnimation(const IntPoint& offset)
    178178{
     179    if (requestScrollPositionUpdate(offset))
     180        return;
     181
    179182    notifyScrollPositionChanged(offset);
    180183}
  • trunk/Source/WebCore/platform/ScrollableArea.h

    r107466 r107467  
    5353    void notifyScrollPositionChanged(const IntPoint&);
    5454
     55    // Allows subclasses to handle scroll position updates themselves. If this member function
     56    // returns true, the scrollable area won't actually update the scroll position and instead
     57    // expect it to happen sometime in the future.
     58    virtual bool requestScrollPositionUpdate(const IntPoint&) { return false; }
     59
    5560    virtual void zoomAnimatorTransformChanged(float, float, float, ZoomAnimationState);
    5661
Note: See TracChangeset for help on using the changeset viewer.