Changeset 148197 in webkit


Ignore:
Timestamp:
Apr 11, 2013 6:16:20 AM (11 years ago)
Author:
mikhail.pozdnyakov@intel.com
Message:

[CoordinatedGraphics] Use ScrollingStateTree to handle fixed elements positioning while scrolling
https://bugs.webkit.org/show_bug.cgi?id=114353

Reviewed by Noam Rosenthal.

ScrollingCoordinatorCoordinatedGraphics should implement threaded scrolling interface and
re-use threaded scrolling approach (ScrollingStateTree and ViewportConstraints) to handle
fixed/sticky elements positioning while scrolling. The rationals are below.

Before the change ScrollingCoordinatorCoordinatedGraphics was implementing Chromium-specific
interface which is going to be removed eventually as there is no ScrollingCoordinatorChromium
existing.

Tested by existing manual tests (fixed-position.html for example.

  • CMakeLists.txt:
  • Target.pri:

Included ScrollingStateTree files.

  • page/scrolling/ScrollingStateFixedNode.cpp:
  • page/scrolling/ScrollingStateFixedNode.h:
  • page/scrolling/ScrollingStateNode.cpp:
  • page/scrolling/ScrollingStateNode.h:
  • page/scrolling/ScrollingStateScrollingNode.cpp:
  • page/scrolling/ScrollingStateScrollingNode.h:
  • page/scrolling/ScrollingStateStickyNode.cpp:
  • page/scrolling/ScrollingStateStickyNode.h:
  • page/scrolling/ScrollingStateTree.cpp:
  • page/scrolling/ScrollingStateTree.h:

Removed ENABLE(THREADED_SCROLLING) code guards.

  • page/scrolling/coordinatedgraphics/ScrollingCoordinatorCoordinatedGraphics.cpp:

(WebCore::ScrollingCoordinatorCoordinatedGraphics::ScrollingCoordinatorCoordinatedGraphics):
(WebCore::ScrollingCoordinatorCoordinatedGraphics::~ScrollingCoordinatorCoordinatedGraphics):
(WebCore):
(WebCore::ScrollingCoordinatorCoordinatedGraphics::attachToStateTree):
(WebCore::ScrollingCoordinatorCoordinatedGraphics::detachFromStateTree):
(WebCore::ScrollingCoordinatorCoordinatedGraphics::clearStateTree):
(WebCore::ScrollingCoordinatorCoordinatedGraphics::updateViewportConstrainedNode):

  • page/scrolling/coordinatedgraphics/ScrollingCoordinatorCoordinatedGraphics.h:

ScrollingCoordinatorCoordinatedGraphics is using threaded scrolling approach to handle fixed
elements positioning while scrolling.

(WebCore):
(ScrollingCoordinatorCoordinatedGraphics):

  • page/scrolling/coordinatedgraphics/ScrollingStateNodeCoordinatedGraphics.cpp: Added.

(WebCore):
(WebCore::ScrollingStateNode::platformScrollLayer):
(WebCore::ScrollingStateNode::setScrollPlatformLayer):
(WebCore::ScrollingStateNode::setScrollLayer):

  • page/scrolling/coordinatedgraphics/ScrollingStateScrollingNodeCoordinatedGraphics.cpp: Added.

(WebCore):
(WebCore::ScrollingStateScrollingNode::counterScrollingPlatformLayer):
(WebCore::ScrollingStateScrollingNode::setCounterScrollingLayer):

Location:
trunk/Source/WebCore
Files:
2 added
15 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/CMakeLists.txt

    r147921 r148197  
    18231823    page/scrolling/ScrollingConstraints.cpp
    18241824    page/scrolling/ScrollingCoordinator.cpp
     1825    page/scrolling/ScrollingStateFixedNode.cpp
     1826    page/scrolling/ScrollingStateNode.cpp
     1827    page/scrolling/ScrollingStateScrollingNode.cpp
     1828    page/scrolling/ScrollingStateStickyNode.cpp
     1829    page/scrolling/ScrollingStateTree.cpp
    18251830    page/scrolling/coordinatedgraphics/ScrollingCoordinatorCoordinatedGraphics.cpp
     1831    page/scrolling/coordinatedgraphics/ScrollingStateNodeCoordinatedGraphics.cpp
     1832    page/scrolling/coordinatedgraphics/ScrollingStateScrollingNodeCoordinatedGraphics.cpp
    18261833
    18271834    platform/Arena.cpp
  • trunk/Source/WebCore/ChangeLog

    r148195 r148197  
     12013-04-11  Mikhail Pozdnyakov  <mikhail.pozdnyakov@intel.com>
     2
     3        [CoordinatedGraphics] Use ScrollingStateTree to handle fixed elements positioning while scrolling
     4        https://bugs.webkit.org/show_bug.cgi?id=114353
     5
     6        Reviewed by Noam Rosenthal.
     7       
     8        ScrollingCoordinatorCoordinatedGraphics should implement threaded scrolling interface and
     9        re-use threaded scrolling approach (ScrollingStateTree and ViewportConstraints) to handle
     10        fixed/sticky elements positioning while scrolling. The rationals are below.
     11
     12        Before the change ScrollingCoordinatorCoordinatedGraphics was implementing Chromium-specific
     13        interface which is going to be removed eventually as there is no ScrollingCoordinatorChromium
     14        existing.
     15
     16        Tested by existing manual tests (fixed-position.html for example.
     17
     18        * CMakeLists.txt:
     19        * Target.pri:
     20            Included ScrollingStateTree files.
     21
     22        * page/scrolling/ScrollingStateFixedNode.cpp:
     23        * page/scrolling/ScrollingStateFixedNode.h:
     24        * page/scrolling/ScrollingStateNode.cpp:
     25        * page/scrolling/ScrollingStateNode.h:
     26        * page/scrolling/ScrollingStateScrollingNode.cpp:
     27        * page/scrolling/ScrollingStateScrollingNode.h:
     28        * page/scrolling/ScrollingStateStickyNode.cpp:
     29        * page/scrolling/ScrollingStateStickyNode.h:
     30        * page/scrolling/ScrollingStateTree.cpp:
     31        * page/scrolling/ScrollingStateTree.h:
     32            Removed ENABLE(THREADED_SCROLLING) code guards.
     33
     34        * page/scrolling/coordinatedgraphics/ScrollingCoordinatorCoordinatedGraphics.cpp:
     35        (WebCore::ScrollingCoordinatorCoordinatedGraphics::ScrollingCoordinatorCoordinatedGraphics):
     36        (WebCore::ScrollingCoordinatorCoordinatedGraphics::~ScrollingCoordinatorCoordinatedGraphics):
     37        (WebCore):
     38        (WebCore::ScrollingCoordinatorCoordinatedGraphics::attachToStateTree):
     39        (WebCore::ScrollingCoordinatorCoordinatedGraphics::detachFromStateTree):
     40        (WebCore::ScrollingCoordinatorCoordinatedGraphics::clearStateTree):
     41        (WebCore::ScrollingCoordinatorCoordinatedGraphics::updateViewportConstrainedNode):
     42        * page/scrolling/coordinatedgraphics/ScrollingCoordinatorCoordinatedGraphics.h:
     43            ScrollingCoordinatorCoordinatedGraphics is using threaded scrolling approach to handle fixed
     44            elements positioning while scrolling.
     45
     46        (WebCore):
     47        (ScrollingCoordinatorCoordinatedGraphics):
     48        * page/scrolling/coordinatedgraphics/ScrollingStateNodeCoordinatedGraphics.cpp: Added.
     49        (WebCore):
     50        (WebCore::ScrollingStateNode::platformScrollLayer):
     51        (WebCore::ScrollingStateNode::setScrollPlatformLayer):
     52        (WebCore::ScrollingStateNode::setScrollLayer):
     53        * page/scrolling/coordinatedgraphics/ScrollingStateScrollingNodeCoordinatedGraphics.cpp: Added.
     54        (WebCore):
     55        (WebCore::ScrollingStateScrollingNode::counterScrollingPlatformLayer):
     56        (WebCore::ScrollingStateScrollingNode::setCounterScrollingLayer):
     57
    1582013-04-11  Allan Sandfeld Jensen  <allan.jensen@digia.com>
    259
  • trunk/Source/WebCore/Target.pri

    r147921 r148197  
    41434143use?(3D_GRAPHICS) {
    41444144    HEADERS += \
     4145        page/scrolling/ScrollingConstraints.h \
     4146        page/scrolling/ScrollingCoordinator.h \
     4147        page/scrolling/ScrollingStateFixedNode.h \
     4148        page/scrolling/ScrollingStateNode.h \
     4149        page/scrolling/ScrollingStateScrollingNode.h \
     4150        page/scrolling/ScrollingStateStickyNode.h \
     4151        page/scrolling/ScrollingStateTree.h \
    41454152        page/scrolling/coordinatedgraphics/ScrollingCoordinatorCoordinatedGraphics.h \
    41464153        platform/graphics/cpu/arm/GraphicsContext3DNEON.h \
     
    41684175
    41694176    SOURCES += \
     4177        page/scrolling/ScrollingConstraints.cpp \
     4178        page/scrolling/ScrollingCoordinator.cpp \
     4179        page/scrolling/ScrollingStateFixedNode.cpp \
     4180        page/scrolling/ScrollingStateNode.cpp \
     4181        page/scrolling/ScrollingStateScrollingNode.cpp \
     4182        page/scrolling/ScrollingStateStickyNode.cpp \
     4183        page/scrolling/ScrollingStateTree.cpp \
    41704184        page/scrolling/coordinatedgraphics/ScrollingCoordinatorCoordinatedGraphics.cpp \
     4185        page/scrolling/coordinatedgraphics/ScrollingStateNodeCoordinatedGraphics.cpp \
     4186        page/scrolling/coordinatedgraphics/ScrollingStateScrollingNodeCoordinatedGraphics.cpp \
    41714187        platform/graphics/ANGLEWebKitBridge.cpp \
    41724188        platform/graphics/GraphicsContext3D.cpp \
  • trunk/Source/WebCore/page/scrolling/ScrollingStateFixedNode.cpp

    r141704 r148197  
    3131#include "TextStream.h"
    3232#include <wtf/OwnPtr.h>
    33 
    34 #if ENABLE(THREADED_SCROLLING)
    3533
    3634namespace WebCore {
     
    113111
    114112} // namespace WebCore
    115 
    116 #endif // ENABLE(THREADED_SCROLLING)
  • trunk/Source/WebCore/page/scrolling/ScrollingStateFixedNode.h

    r141704 r148197  
    2626#ifndef ScrollingStateFixedNode_h
    2727#define ScrollingStateFixedNode_h
    28 
    29 #if ENABLE(THREADED_SCROLLING)
    3028
    3129#include "ScrollingConstraints.h"
     
    7775} // namespace WebCore
    7876
    79 #endif // ENABLE(THREADED_SCROLLING)
    80 
    8177#endif // ScrollingStateFixedNode_h
  • trunk/Source/WebCore/page/scrolling/ScrollingStateNode.cpp

    r141704 r148197  
    3232
    3333#include <wtf/text/WTFString.h>
    34 
    35 #if ENABLE(THREADED_SCROLLING)
    3634
    3735namespace WebCore {
     
    148146
    149147} // namespace WebCore
    150 
    151 #endif // ENABLE(THREADED_SCROLLING)
  • trunk/Source/WebCore/page/scrolling/ScrollingStateNode.h

    r142505 r148197  
    2626#ifndef ScrollingStateNode_h
    2727#define ScrollingStateNode_h
    28 
    29 #if ENABLE(THREADED_SCROLLING)
    3028
    3129#include "PlatformLayer.h"
     
    118116} // namespace WebCore
    119117
    120 #endif // ENABLE(THREADED_SCROLLING)
    121 
    122118#endif // ScrollingStateNode_h
  • trunk/Source/WebCore/page/scrolling/ScrollingStateScrollingNode.cpp

    r147471 r148197  
    3131#include <wtf/OwnPtr.h>
    3232
    33 #if ENABLE(THREADED_SCROLLING)
    34 
    3533namespace WebCore {
    3634
     
    285283
    286284} // namespace WebCore
    287 
    288 #endif // ENABLE(THREADED_SCROLLING)
  • trunk/Source/WebCore/page/scrolling/ScrollingStateScrollingNode.h

    r147471 r148197  
    2626#ifndef ScrollingStateScrollingNode_h
    2727#define ScrollingStateScrollingNode_h
    28 
    29 #if ENABLE(THREADED_SCROLLING)
    3028
    3129#include "IntRect.h"
     
    173171} // namespace WebCore
    174172
    175 #endif // ENABLE(THREADED_SCROLLING)
    176 
    177173#endif // ScrollingStateScrollingNode_h
  • trunk/Source/WebCore/page/scrolling/ScrollingStateStickyNode.cpp

    r141704 r148197  
    3131#include "TextStream.h"
    3232#include <wtf/OwnPtr.h>
    33 
    34 #if ENABLE(THREADED_SCROLLING)
    3533
    3634namespace WebCore {
     
    132130
    133131} // namespace WebCore
    134 
    135 #endif // ENABLE(THREADED_SCROLLING)
  • trunk/Source/WebCore/page/scrolling/ScrollingStateStickyNode.h

    r141704 r148197  
    2626#ifndef ScrollingStateStickyNode_h
    2727#define ScrollingStateStickyNode_h
    28 
    29 #if ENABLE(THREADED_SCROLLING)
    3028
    3129#include "ScrollingConstraints.h"
     
    7775} // namespace WebCore
    7876
    79 #endif // ENABLE(THREADED_SCROLLING)
    80 
    8177#endif // ScrollingStateStickyNode_h
  • trunk/Source/WebCore/page/scrolling/ScrollingStateTree.cpp

    r143074 r148197  
    2525 
    2626#include "config.h"
    27 
    28 #if ENABLE(THREADED_SCROLLING)
    2927
    3028#include "ScrollingStateTree.h"
     
    182180
    183181} // namespace WebCore
    184 
    185 #endif // ENABLE(THREADED_SCROLLING)
  • trunk/Source/WebCore/page/scrolling/ScrollingStateTree.h

    r142504 r148197  
    2626#ifndef ScrollingStateTree_h
    2727#define ScrollingStateTree_h
    28 
    29 #if ENABLE(THREADED_SCROLLING)
    3028
    3129#include "ScrollingStateScrollingNode.h"
     
    8078} // namespace WebCore
    8179
    82 #endif // ENABLE(THREADED_SCROLLING)
    83 
    8480#endif // ScrollingStateTree_h
  • trunk/Source/WebCore/page/scrolling/coordinatedgraphics/ScrollingCoordinatorCoordinatedGraphics.cpp

    r144907 r148197  
    3131
    3232#include "CoordinatedGraphicsLayer.h"
     33#include "FrameView.h"
    3334#include "Page.h"
     35#include "RenderLayer.h"
     36#include "RenderLayerBacking.h"
     37#include "ScrollingConstraints.h"
     38#include "ScrollingStateFixedNode.h"
     39#include "ScrollingStateScrollingNode.h"
     40#include "ScrollingStateStickyNode.h"
     41#include "ScrollingStateTree.h"
    3442#include "Settings.h"
    3543
     
    3846ScrollingCoordinatorCoordinatedGraphics::ScrollingCoordinatorCoordinatedGraphics(Page* page)
    3947    : ScrollingCoordinator(page)
     48    , m_scrollingStateTree(ScrollingStateTree::create())
    4049{
    4150}
    4251
    43 void ScrollingCoordinatorCoordinatedGraphics::setLayerIsFixedToContainerLayer(GraphicsLayer* layer, bool enable)
     52ScrollingCoordinatorCoordinatedGraphics::~ScrollingCoordinatorCoordinatedGraphics()
    4453{
    45     if (!m_page->settings()->acceleratedCompositingForFixedPositionEnabled())
     54}
     55
     56ScrollingNodeID ScrollingCoordinatorCoordinatedGraphics::attachToStateTree(ScrollingNodeType nodeType, ScrollingNodeID newNodeID, ScrollingNodeID parentID)
     57{
     58    return m_scrollingStateTree->attachNode(nodeType, newNodeID, parentID);
     59}
     60
     61void ScrollingCoordinatorCoordinatedGraphics::detachFromStateTree(ScrollingNodeID nodeID)
     62{
     63    ScrollingStateNode* node = m_scrollingStateTree->stateNodeForID(nodeID);
     64    if (node && node->isFixedNode())
     65        toCoordinatedGraphicsLayer(node->graphicsLayer())->setFixedToViewport(false);
     66
     67    m_scrollingStateTree->detachNode(nodeID);
     68}
     69
     70void ScrollingCoordinatorCoordinatedGraphics::clearStateTree()
     71{
     72    m_scrollingStateTree->clear();
     73}
     74
     75void ScrollingCoordinatorCoordinatedGraphics::updateViewportConstrainedNode(ScrollingNodeID nodeID, const ViewportConstraints& constraints, GraphicsLayer* graphicsLayer)
     76{
     77    ASSERT(supportsFixedPositionLayers());
     78
     79    ScrollingStateNode* node = m_scrollingStateTree->stateNodeForID(nodeID);
     80    if (!node)
    4681        return;
    47     toCoordinatedGraphicsLayer(layer)->setFixedToViewport(enable);
     82
     83    switch (constraints.constraintType()) {
     84    case ViewportConstraints::FixedPositionConstaint: {
     85        toCoordinatedGraphicsLayer(graphicsLayer)->setFixedToViewport(true); // FIXME : Use constraints!
     86        ScrollingStateFixedNode* fixedNode = toScrollingStateFixedNode(node);
     87        fixedNode->setScrollLayer(graphicsLayer);
     88        break;
     89    }
     90    case ViewportConstraints::StickyPositionConstraint:
     91        break; // FIXME : Support sticky elements.
     92    default:
     93        ASSERT_NOT_REACHED();
     94    }
    4895}
    4996
  • trunk/Source/WebCore/page/scrolling/coordinatedgraphics/ScrollingCoordinatorCoordinatedGraphics.h

    r144907 r148197  
    3333namespace WebCore {
    3434
     35class ScrollingStateTree;
     36
    3537class ScrollingCoordinatorCoordinatedGraphics : public ScrollingCoordinator {
    3638public:
    3739    explicit ScrollingCoordinatorCoordinatedGraphics(Page*);
     40    virtual ~ScrollingCoordinatorCoordinatedGraphics();
    3841
    39     virtual bool supportsFixedPositionLayers() const { return true; }
     42    virtual bool supportsFixedPositionLayers() const OVERRIDE { return true; }
    4043
    41     virtual void setLayerIsFixedToContainerLayer(GraphicsLayer*, bool);
    42     virtual void scrollableAreaScrollLayerDidChange(ScrollableArea*);
    43     virtual void willDestroyScrollableArea(ScrollableArea*);
     44    virtual ScrollingNodeID attachToStateTree(ScrollingNodeType, ScrollingNodeID newNodeID, ScrollingNodeID parentID) OVERRIDE;
     45    virtual void detachFromStateTree(ScrollingNodeID) OVERRIDE;
     46    virtual void clearStateTree() OVERRIDE;
     47
     48    virtual void updateViewportConstrainedNode(ScrollingNodeID, const ViewportConstraints&, GraphicsLayer*) OVERRIDE;
     49
     50    virtual void scrollableAreaScrollLayerDidChange(ScrollableArea*) OVERRIDE;
     51    virtual void willDestroyScrollableArea(ScrollableArea*) OVERRIDE;
     52
     53private:
     54    OwnPtr<ScrollingStateTree> m_scrollingStateTree;
    4455};
    4556
     
    4859#endif // USE(COORDINATED_GRAPHICS)
    4960
    50 #endif
     61#endif // ScrollingCoordinatorCoordinatedGraphics_h
Note: See TracChangeset for help on using the changeset viewer.