Changeset 238898 in webkit


Ignore:
Timestamp:
Dec 5, 2018 10:20:56 AM (5 years ago)
Author:
Simon Fraser
Message:

Minor refactoring of the scrolling code
https://bugs.webkit.org/show_bug.cgi?id=192398

Patch by Frederic Wang <fwang@igalia.com> on 2018-12-05
Reviewed by Simon Fraser.

Based on an earlier patch by Simon Fraser.

This patch performs some minor refactoring of the scrolling code:

  • Rename ScrollingCoordinator::uniqueScrollLayerID() to uniqueScrollingNodeID() since it is really a node id.
  • Inline ScrollingStateTree::setRootStateNode() so we only need to forward declare ScrollingStateFrameScrollingNode in headers.
  • Pass argument to ScrollingStateTree::addNode() as a reference rather than a pointer.
  • Initialize ScrollingStateTree::m_changedProperties and ScrollingStateTree::m_parent in the header file.
  • Remove obsolete comment about ScrollingCoordinatorMac.

No new tests, behavior unchanged.

  • page/scrolling/ScrollingCoordinator.cpp:

(WebCore::ScrollingCoordinator::uniqueScrollingNodeID):
(WebCore::ScrollingCoordinator::uniqueScrollLayerID): Deleted.

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

(WebCore::ScrollingStateNode::ScrollingStateNode):

  • page/scrolling/ScrollingStateNode.h:
  • page/scrolling/ScrollingStateTree.cpp:

(WebCore::ScrollingStateTree::attachNode):
(WebCore::ScrollingStateTree::setRootStateNode):
(WebCore::ScrollingStateTree::addNode):

  • page/scrolling/ScrollingStateTree.h:

(WebCore::ScrollingStateTree::setRootStateNode): Deleted.

  • page/scrolling/ScrollingTree.cpp:
  • page/scrolling/mac/ScrollingTreeFrameScrollingNodeMac.h:
  • rendering/RenderLayerCompositor.cpp:

(WebCore::RenderLayerCompositor::attachScrollingNode):

Location:
trunk/Source/WebCore
Files:
10 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r238894 r238898  
     12018-12-05  Frederic Wang  <fwang@igalia.com>
     2
     3        Minor refactoring of the scrolling code
     4        https://bugs.webkit.org/show_bug.cgi?id=192398
     5
     6        Reviewed by Simon Fraser.
     7
     8        Based on an earlier patch by Simon Fraser.
     9
     10        This patch performs some minor refactoring of the scrolling code:
     11        - Rename ScrollingCoordinator::uniqueScrollLayerID() to uniqueScrollingNodeID() since it
     12          is really a node id.
     13        - Inline ScrollingStateTree::setRootStateNode() so we only need to forward declare
     14          ScrollingStateFrameScrollingNode in headers.
     15        - Pass argument to ScrollingStateTree::addNode() as a reference rather than a pointer.
     16        - Initialize ScrollingStateTree::m_changedProperties and ScrollingStateTree::m_parent in
     17          the header file.
     18        - Remove obsolete comment about ScrollingCoordinatorMac.
     19
     20        No new tests, behavior unchanged.
     21
     22        * page/scrolling/ScrollingCoordinator.cpp:
     23        (WebCore::ScrollingCoordinator::uniqueScrollingNodeID):
     24        (WebCore::ScrollingCoordinator::uniqueScrollLayerID): Deleted.
     25        * page/scrolling/ScrollingCoordinator.h:
     26        * page/scrolling/ScrollingStateNode.cpp:
     27        (WebCore::ScrollingStateNode::ScrollingStateNode):
     28        * page/scrolling/ScrollingStateNode.h:
     29        * page/scrolling/ScrollingStateTree.cpp:
     30        (WebCore::ScrollingStateTree::attachNode):
     31        (WebCore::ScrollingStateTree::setRootStateNode):
     32        (WebCore::ScrollingStateTree::addNode):
     33        * page/scrolling/ScrollingStateTree.h:
     34        (WebCore::ScrollingStateTree::setRootStateNode): Deleted.
     35        * page/scrolling/ScrollingTree.cpp:
     36        * page/scrolling/mac/ScrollingTreeFrameScrollingNodeMac.h:
     37        * rendering/RenderLayerCompositor.cpp:
     38        (WebCore::RenderLayerCompositor::attachScrollingNode):
     39
    1402018-12-05  Wenson Hsieh  <wenson_hsieh@apple.com>
    241
  • trunk/Source/WebCore/page/scrolling/ScrollingCoordinator.cpp

    r230952 r238898  
    362362}
    363363
    364 ScrollingNodeID ScrollingCoordinator::uniqueScrollLayerID()
    365 {
    366     static ScrollingNodeID uniqueScrollLayerID = 1;
    367     return uniqueScrollLayerID++;
     364ScrollingNodeID ScrollingCoordinator::uniqueScrollingNodeID()
     365{
     366    static ScrollingNodeID uniqueScrollingNodeID = 1;
     367    return uniqueScrollingNodeID++;
    368368}
    369369
  • trunk/Source/WebCore/page/scrolling/ScrollingCoordinator.h

    r238885 r238898  
    162162
    163163    // These virtual functions are currently unique to the threaded scrolling architecture.
    164     // Their meaningful implementations are in ScrollingCoordinatorMac.
    165164    virtual void commitTreeStateIfNeeded() { }
    166165    virtual bool requestScrollPositionUpdate(FrameView&, const IntPoint&) { return false; }
     
    199198    virtual void setScrollPinningBehavior(ScrollPinningBehavior) { }
    200199
    201     // Generated a unique id for scroll layers.
    202     ScrollingNodeID uniqueScrollLayerID();
     200    // Generated a unique id for scrolling nodes.
     201    ScrollingNodeID uniqueScrollingNodeID();
    203202
    204203    enum MainThreadScrollingReasonFlags {
  • trunk/Source/WebCore/page/scrolling/ScrollingStateNode.cpp

    r227596 r238898  
    4040    : m_nodeType(nodeType)
    4141    , m_nodeID(nodeID)
    42     , m_changedProperties(0)
    4342    , m_scrollingStateTree(scrollingStateTree)
    44     , m_parent(nullptr)
    4543{
    4644}
     
    5351    , m_changedProperties(stateNode.changedProperties())
    5452    , m_scrollingStateTree(adoptiveTree)
    55     , m_parent(nullptr)
    5653{
    5754    if (hasChangedProperty(ScrollLayer))
    5855        setLayer(stateNode.layer().toRepresentation(adoptiveTree.preferredLayerRepresentation()));
    59     scrollingStateTree().addNode(this);
     56    scrollingStateTree().addNode(*this);
    6057}
    6158
  • trunk/Source/WebCore/page/scrolling/ScrollingStateNode.h

    r234348 r238898  
    249249
    250250    const ScrollingNodeType m_nodeType;
    251     ScrollingNodeID m_nodeID;
    252     ChangedProperties m_changedProperties;
     251    const ScrollingNodeID m_nodeID;
     252    ChangedProperties m_changedProperties { 0 };
    253253
    254254    ScrollingStateTree& m_scrollingStateTree;
    255255
    256     ScrollingStateNode* m_parent;
     256    ScrollingStateNode* m_parent { nullptr };
    257257    std::unique_ptr<Vector<RefPtr<ScrollingStateNode>>> m_children;
    258258
  • trunk/Source/WebCore/page/scrolling/ScrollingStateTree.cpp

    r228264 r238898  
    106106        // If the type has changed, we need to destroy and recreate the node with a new ID.
    107107        if (nodeType != node->nodeType())
    108             newNodeID = m_scrollingCoordinator->uniqueScrollLayerID();
     108            newNodeID = m_scrollingCoordinator->uniqueScrollingNodeID();
    109109#endif
    110110
     
    197197}
    198198
    199 void ScrollingStateTree::addNode(ScrollingStateNode* node)
    200 {
    201     m_stateNodeMap.add(node->scrollingNodeID(), node);
     199void ScrollingStateTree::setRootStateNode(Ref<ScrollingStateFrameScrollingNode>&& rootStateNode)
     200{
     201    m_rootStateNode = WTFMove(rootStateNode);
     202}
     203
     204void ScrollingStateTree::addNode(ScrollingStateNode& node)
     205{
     206    m_stateNodeMap.add(node.scrollingNodeID(), &node);
    202207}
    203208
  • trunk/Source/WebCore/page/scrolling/ScrollingStateTree.h

    r211033 r238898  
    2828#if ENABLE(ASYNC_SCROLLING) || USE(COORDINATED_GRAPHICS)
    2929
    30 #include "ScrollingStateFrameScrollingNode.h"
     30#include "ScrollingCoordinator.h"
     31#include "ScrollingStateNode.h"
    3132#include <wtf/RefPtr.h>
    3233 
     
    3435
    3536class AsyncScrollingCoordinator;
     37class ScrollingStateFrameScrollingNode;
    3638
    3739// The ScrollingStateTree is a tree that managed ScrollingStateNodes. The nodes keep track of the current
     
    7577
    7678private:
    77     void setRootStateNode(Ref<ScrollingStateFrameScrollingNode>&& rootStateNode) { m_rootStateNode = WTFMove(rootStateNode); }
    78     void addNode(ScrollingStateNode*);
     79    void setRootStateNode(Ref<ScrollingStateFrameScrollingNode>&&);
     80    void addNode(ScrollingStateNode&);
    7981
    8082    Ref<ScrollingStateNode> createNode(ScrollingNodeType, ScrollingNodeID);
  • trunk/Source/WebCore/page/scrolling/ScrollingTree.cpp

    r223728 r238898  
    3232#include "Logging.h"
    3333#include "PlatformWheelEvent.h"
     34#include "ScrollingStateFrameScrollingNode.h"
    3435#include "ScrollingStateTree.h"
    3536#include "ScrollingTreeFrameScrollingNode.h"
  • trunk/Source/WebCore/page/scrolling/mac/ScrollingTreeFrameScrollingNodeMac.h

    r228264 r238898  
    3030#include "ScrollController.h"
    3131#include "ScrollbarThemeMac.h"
     32#include "ScrollingStateFrameScrollingNode.h"
    3233#include "ScrollingTreeFrameScrollingNode.h"
    3334#include <wtf/RetainPtr.h>
  • trunk/Source/WebCore/rendering/RenderLayerCompositor.cpp

    r238885 r238898  
    38363836    ScrollingNodeID nodeID = backing->scrollingNodeIDForRole(role);
    38373837    if (!nodeID)
    3838         nodeID = scrollingCoordinator->uniqueScrollLayerID();
     3838        nodeID = scrollingCoordinator->uniqueScrollingNodeID();
    38393839
    38403840    nodeID = scrollingCoordinator->attachToStateTree(nodeType, nodeID, parentNodeID);
Note: See TracChangeset for help on using the changeset viewer.