Changeset 106690 in webkit


Ignore:
Timestamp:
Feb 3, 2012 1:25:44 PM (12 years ago)
Author:
andersca@apple.com
Message:

Update the tree state after layout and add a way to commit it
https://bugs.webkit.org/show_bug.cgi?id=77767

Reviewed by Andreas Kling.

  • page/FrameView.cpp:

(WebCore::FrameView::performPostLayoutTasks):
Call ScrollingCoordinator::frameViewLayoutUpdated if we have a scrolling coordinator.

  • page/scrolling/ScrollingCoordinator.cpp:

(WebCore::ScrollingCoordinator::ScrollingCoordinator):
Initialize m_scrollingTreeStateCommitterTimer.

(WebCore::ScrollingCoordinator::frameViewLayoutUpdated):
Update the viewport rect and contents size of the frame view.

(WebCore::ScrollingCoordinator::scheduleTreeStateCommit):
Schedule a tree state commit unless we've already scheduled one or there are no changed properties.

(WebCore::ScrollingCoordinator::scrollingTreeStateCommitterTimerFired):
Call commitTreeState().

(WebCore::ScrollingCoordinator::commitTreeStateIfNeeded):
Commit the tree state unless there are no changed properties.

(WebCore::ScrollingCoordinator::commitTreeState):
Commit the tree state. We currently don't do anything with the committed state yet.

  • page/scrolling/ScrollingCoordinator.h:

Add new member functions and the timer member variable.

  • page/scrolling/ScrollingTreeState.cpp:

(WebCore::ScrollingTreeState::commit):
Copy the current tree state and restore the changed properties on the original.

  • page/scrolling/ScrollingTreeState.h:

(WebCore::ScrollingTreeState::hasChangedProperties):
Return whether there are any changed properties in the tree state.

Location:
trunk/Source/WebCore
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r106685 r106690  
     12012-02-03  Anders Carlsson  <andersca@apple.com>
     2
     3        Update the tree state after layout and add a way to commit it
     4        https://bugs.webkit.org/show_bug.cgi?id=77767
     5
     6        Reviewed by Andreas Kling.
     7
     8        * page/FrameView.cpp:
     9        (WebCore::FrameView::performPostLayoutTasks):
     10        Call ScrollingCoordinator::frameViewLayoutUpdated if we have a scrolling coordinator.
     11
     12        * page/scrolling/ScrollingCoordinator.cpp:
     13        (WebCore::ScrollingCoordinator::ScrollingCoordinator):
     14        Initialize m_scrollingTreeStateCommitterTimer.
     15
     16        (WebCore::ScrollingCoordinator::frameViewLayoutUpdated):
     17        Update the viewport rect and contents size of the frame view.
     18
     19        (WebCore::ScrollingCoordinator::scheduleTreeStateCommit):
     20        Schedule a tree state commit unless we've already scheduled one or there are no changed properties.
     21
     22        (WebCore::ScrollingCoordinator::scrollingTreeStateCommitterTimerFired):
     23        Call commitTreeState().
     24
     25        (WebCore::ScrollingCoordinator::commitTreeStateIfNeeded):
     26        Commit the tree state unless there are no changed properties.
     27
     28        (WebCore::ScrollingCoordinator::commitTreeState):
     29        Commit the tree state. We currently don't do anything with the committed state yet.
     30
     31        * page/scrolling/ScrollingCoordinator.h:
     32        Add new member functions and the timer member variable.
     33
     34        * page/scrolling/ScrollingTreeState.cpp:
     35        (WebCore::ScrollingTreeState::commit):
     36        Copy the current tree state and restore the changed properties on the original.
     37
     38        * page/scrolling/ScrollingTreeState.h:
     39        (WebCore::ScrollingTreeState::hasChangedProperties):
     40        Return whether there are any changed properties in the tree state.
     41
    1422012-02-03  Andreas Kling  <awesomekling@apple.com>
    243
  • trunk/Source/WebCore/page/FrameView.cpp

    r106492 r106690  
    23062306    }
    23072307
     2308#if ENABLE(THREADED_SCROLLING)
     2309    if (Page* page = m_frame->page()) {
     2310        if (ScrollingCoordinator* scrollingCoordinator = page->scrollingCoordinator())
     2311            scrollingCoordinator->frameViewLayoutUpdated(this);
     2312    }
     2313#endif
     2314
    23082315    scrollToAnchor();
    23092316
  • trunk/Source/WebCore/page/scrolling/ScrollingCoordinator.cpp

    r106679 r106690  
    5454    , m_scrollingTree(ScrollingTree::create(this))
    5555    , m_scrollingTreeState(ScrollingTreeState::create())
     56    , m_scrollingTreeStateCommitterTimer(this, &ScrollingCoordinator::scrollingTreeStateCommitterTimerFired)
    5657    , m_didDispatchDidUpdateMainFrameScrollPosition(false)
    5758{
     
    8384
    8485    return true;
     86}
     87
     88void ScrollingCoordinator::frameViewLayoutUpdated(FrameView* frameView)
     89{
     90    ASSERT(isMainThread());
     91    ASSERT(m_page);
     92
     93    if (!coordinatesScrollingForFrameView(frameView))
     94        return;
     95
     96    m_scrollingTreeState->setViewportRect(IntRect(IntPoint(), frameView->visibleContentRect().size()));
     97    m_scrollingTreeState->setContentsSize(frameView->contentsSize());
     98    scheduleTreeStateCommit();
    8599}
    86100
     
    159173}
    160174
     175void ScrollingCoordinator::scheduleTreeStateCommit()
     176{
     177    if (m_scrollingTreeStateCommitterTimer.isActive())
     178        return;
     179
     180    if (!m_scrollingTreeState->hasChangedProperties())
     181        return;
     182
     183    m_scrollingTreeStateCommitterTimer.startOneShot(0);
     184}
     185
     186void ScrollingCoordinator::scrollingTreeStateCommitterTimerFired(Timer<ScrollingCoordinator>*)
     187{
     188    commitTreeState();
     189}
     190
     191void ScrollingCoordinator::commitTreeStateIfNeeded()
     192{
     193    if (!m_scrollingTreeState->hasChangedProperties())
     194        return;
     195
     196    commitTreeState();
     197    m_scrollingTreeStateCommitterTimer.stop();
     198}
     199
     200void ScrollingCoordinator::commitTreeState()
     201{
     202    printf("committing!\n");
     203    ASSERT(m_scrollingTreeState->hasChangedProperties());
     204
     205    OwnPtr<ScrollingTreeState> treeState = m_scrollingTreeState->commit();
     206
     207    // FIXME: Commit the tree state.
     208}
     209
    161210} // namespace WebCore
    162211
  • trunk/Source/WebCore/page/scrolling/ScrollingCoordinator.h

    r106679 r106690  
    3131#include "GraphicsLayer.h"
    3232#include "IntRect.h"
     33#include "Timer.h"
    3334#include <wtf/Forward.h>
    3435#include <wtf/ThreadSafeRefCounted.h>
     
    6162    // Return whether this scrolling coordinator handles scrolling for the given frame view.
    6263    bool coordinatesScrollingForFrameView(FrameView*) const;
     64
     65    // Should be called whenever the given frame view has been laid out.
     66    void frameViewLayoutUpdated(FrameView*);
    6367
    6468    // Should be called whenever the scroll layer for the given frame view changes.
     
    98102
    99103private:
     104    void scheduleTreeStateCommit();
     105    void scrollingTreeStateCommitterTimerFired(Timer<ScrollingCoordinator>*);
     106    void commitTreeStateIfNeeded();
     107    void commitTreeState();
     108
    100109    Page* m_page;
    101110    RefPtr<ScrollingTree> m_scrollingTree;
    102111
    103112    OwnPtr<ScrollingTreeState> m_scrollingTreeState;
     113    Timer<ScrollingCoordinator> m_scrollingTreeStateCommitterTimer;
    104114
    105115    Mutex m_mainFrameGeometryMutex;
  • trunk/Source/WebCore/page/scrolling/ScrollingTreeState.cpp

    r106679 r106690  
    6363}
    6464
     65PassOwnPtr<ScrollingTreeState> ScrollingTreeState::commit()
     66{
     67    OwnPtr<ScrollingTreeState> treeState = adoptPtr(new ScrollingTreeState(*this));
     68    m_changedProperties = 0;
     69
     70    return treeState.release();
     71}
     72
    6573} // namespace WebCore
    6674
  • trunk/Source/WebCore/page/scrolling/ScrollingTreeState.h

    r106683 r106690  
    5454    };
    5555
     56    bool hasChangedProperties() const { return m_changedProperties; }
     57
    5658    const IntRect& viewportRect() const { return m_viewportRect; }
    5759    void setViewportRect(const IntRect&);
     
    6264    PlatformLayer* platformScrollLayer() const;
    6365    void setScrollLayer(const GraphicsLayer*);
     66
     67    // Copies the current tree state and clears the changed properties mask in the original.
     68    PassOwnPtr<ScrollingTreeState> commit();
    6469
    6570private:
Note: See TracChangeset for help on using the changeset viewer.