Changeset 243126 in webkit


Ignore:
Timestamp:
Mar 18, 2019 7:05:23 PM (5 years ago)
Author:
Simon Fraser
Message:

Scrolling state nodes should hold references to GraphicsLayers
https://bugs.webkit.org/show_bug.cgi?id=195844
<rdar://problem/48949634>

Reviewed by Tim Horton.

GraphicsLayers are refcounted, and the scrolling tree keeps GraphicsLayer pointers,
so for safely the scrolling tree should store RefPtr<GraphicsLayer> instead.

I removed the union (since it would be weird with a RefPtr and raw pointer). This code
should probably use WTF::Variant<> in future.

  • page/scrolling/ScrollingStateNode.h:

(WebCore::LayerRepresentation::LayerRepresentation):
(WebCore::LayerRepresentation::operator GraphicsLayer* const):

Location:
trunk/Source/WebCore
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r243125 r243126  
     12019-03-18  Simon Fraser  <simon.fraser@apple.com>
     2
     3        Scrolling state nodes should hold references to GraphicsLayers
     4        https://bugs.webkit.org/show_bug.cgi?id=195844
     5        <rdar://problem/48949634>
     6
     7        Reviewed by Tim Horton.
     8
     9        GraphicsLayers are refcounted, and the scrolling tree keeps GraphicsLayer pointers,
     10        so for safely the scrolling tree should store RefPtr<GraphicsLayer> instead.
     11
     12        I removed the union (since it would be weird with a RefPtr and raw pointer). This code
     13        should probably use WTF::Variant<> in future.
     14
     15        * page/scrolling/ScrollingStateNode.h:
     16        (WebCore::LayerRepresentation::LayerRepresentation):
     17        (WebCore::LayerRepresentation::operator GraphicsLayer* const):
     18
    1192019-03-18  Commit Queue  <commit-queue@webkit.org>
    220
  • trunk/Source/WebCore/page/scrolling/ScrollingStateNode.h

    r242913 r243126  
    5959    };
    6060
    61     LayerRepresentation()
    62         : m_graphicsLayer(nullptr)
    63         , m_layerID(0)
    64         , m_representation(EmptyRepresentation)
    65     { }
     61    LayerRepresentation() = default;
    6662
    6763    LayerRepresentation(GraphicsLayer* graphicsLayer)
     
    7369    LayerRepresentation(PlatformLayer* platformLayer)
    7470        : m_typelessPlatformLayer(makePlatformLayerTypeless(platformLayer))
    75         , m_layerID(0)
    7671        , m_representation(PlatformLayerRepresentation)
    7772    {
     
    8075
    8176    LayerRepresentation(GraphicsLayer::PlatformLayerID layerID)
    82         : m_graphicsLayer(nullptr)
    83         , m_layerID(layerID)
     77        : m_layerID(layerID)
    8478        , m_representation(PlatformLayerIDRepresentation)
    8579    {
     
    10498    {
    10599        ASSERT(m_representation == GraphicsLayerRepresentation);
    106         return m_graphicsLayer;
     100        return m_graphicsLayer.get();
    107101    }
    108102
     
    180174    WEBCORE_EXPORT static void* makePlatformLayerTypeless(PlatformLayer*);
    181175
    182     union {
    183         GraphicsLayer* m_graphicsLayer;
    184         void* m_typelessPlatformLayer;
    185     };
    186 
    187     GraphicsLayer::PlatformLayerID m_layerID;
    188     Type m_representation;
     176    RefPtr<GraphicsLayer> m_graphicsLayer;
     177    void* m_typelessPlatformLayer { nullptr };
     178    GraphicsLayer::PlatformLayerID m_layerID { 0 };
     179    Type m_representation { EmptyRepresentation };
    189180};
    190181
Note: See TracChangeset for help on using the changeset viewer.