Changeset 235953 in webkit


Ignore:
Timestamp:
Sep 12, 2018, 2:27:07 PM (7 years ago)
Author:
Simon Fraser
Message:

Make GraphicsLayers ref-counted, so their tree can persist when disconnected from RenderLayerBackings
https://bugs.webkit.org/show_bug.cgi?id=189521

Reviewed by Tim Horton.
Source/WebCore:

Make GraphicsLayer be RefCounted<GraphicsLayer>. GraphicsLayers own their children, via a Vector<Ref<GraphicsLayer>>.

RenderLayerBacking and other holders of GraphicsLayers use RefPtr<GraphicsLayer>.

All the other changes are just to adapt to the new ownership patterns.

I verified that no GraphicsLayers were leaked or abandoned after this change.

No behavior change.

  • page/PageOverlayController.cpp:

(WebCore::PageOverlayController::layerWithDocumentOverlays):
(WebCore::PageOverlayController::layerWithViewOverlays):
(WebCore::PageOverlayController::installPageOverlay):
(WebCore::PageOverlayController::uninstallPageOverlay):
(WebCore::PageOverlayController::setPageOverlayNeedsDisplay):
(WebCore::PageOverlayController::didChangeViewSize):
(WebCore::PageOverlayController::didChangeDocumentSize):
(WebCore::PageOverlayController::didChangeSettings):
(WebCore::PageOverlayController::paintContents):
(WebCore::PageOverlayController::didChangeOverlayFrame):
(WebCore::PageOverlayController::didChangeOverlayBackgroundColor):

  • page/PageOverlayController.h:
  • page/mac/ServicesOverlayController.h:

(WebCore::ServicesOverlayController::Highlight::layer const):

  • page/mac/ServicesOverlayController.mm:

(WebCore::ServicesOverlayController::Highlight::Highlight):
(WebCore::ServicesOverlayController::Highlight::invalidate):
(WebCore::ServicesOverlayController::Highlight::fadeIn):
(WebCore::ServicesOverlayController::Highlight::fadeOut):
(WebCore::ServicesOverlayController::Highlight::didFinishFadeOutAnimation):
(WebCore::ServicesOverlayController::determineActiveHighlight):

  • platform/graphics/GraphicsLayer.cpp:

(WebCore::GraphicsLayer::GraphicsLayer):
(WebCore::GraphicsLayer::willBeDestroyed):
(WebCore::GraphicsLayer::setChildren):
(WebCore::GraphicsLayer::addChild):
(WebCore::GraphicsLayer::addChildAtIndex):
(WebCore::GraphicsLayer::addChildBelow):
(WebCore::GraphicsLayer::addChildAbove):
(WebCore::GraphicsLayer::replaceChild):
(WebCore::GraphicsLayer::removeAllChildren):
(WebCore::GraphicsLayer::removeFromParent):
(WebCore::GraphicsLayer::setMaskLayer):
(WebCore::GraphicsLayer::noteDeviceOrPageScaleFactorChangedIncludingDescendants):
(WebCore::GraphicsLayer::distributeOpacity):
(WebCore::GraphicsLayer::traverse):
(WebCore::dumpChildren):

  • platform/graphics/GraphicsLayer.h:

(WebCore::GraphicsLayer::children const):
(WebCore::GraphicsLayer::children):
(WebCore::GraphicsLayer::maskLayer const):
(WebCore::GraphicsLayer::replicaLayer const):
(WebCore::GraphicsLayer::beingDestroyed const):
(WebCore::GraphicsLayer:: const): Deleted.

  • platform/graphics/GraphicsLayerFactory.h:
  • platform/graphics/ca/GraphicsLayerCA.cpp:

(WebCore::GraphicsLayer::create):
(WebCore::GraphicsLayerCA::setChildren):
(WebCore::GraphicsLayerCA::addChild):
(WebCore::GraphicsLayerCA::addChildAtIndex):
(WebCore::GraphicsLayerCA::addChildBelow):
(WebCore::GraphicsLayerCA::addChildAbove):
(WebCore::GraphicsLayerCA::replaceChild):
(WebCore::GraphicsLayerCA::setMaskLayer):
(WebCore::GraphicsLayerCA::recursiveVisibleRectChangeRequiresFlush const):
(WebCore::GraphicsLayerCA::recursiveCommitChanges):
(WebCore::GraphicsLayerCA::updateSublayerList):
(WebCore::GraphicsLayerCA::createTransformAnimationsFromKeyframes):

  • platform/graphics/ca/GraphicsLayerCA.h:
  • platform/graphics/texmap/GraphicsLayerTextureMapper.cpp:

(WebCore::GraphicsLayer::create):
(WebCore::GraphicsLayerTextureMapper::setChildren):
(WebCore::GraphicsLayerTextureMapper::addChild):
(WebCore::GraphicsLayerTextureMapper::addChildAtIndex):
(WebCore::GraphicsLayerTextureMapper::addChildAbove):
(WebCore::GraphicsLayerTextureMapper::addChildBelow):
(WebCore::GraphicsLayerTextureMapper::replaceChild):
(WebCore::GraphicsLayerTextureMapper::setMaskLayer):
(WebCore::GraphicsLayerTextureMapper::updateBackingStoreIncludingSubLayers):

  • platform/graphics/texmap/GraphicsLayerTextureMapper.h:
  • platform/graphics/texmap/coordinated/CoordinatedGraphicsLayer.cpp:

(WebCore::GraphicsLayer::create):
(WebCore::CoordinatedGraphicsLayer::setShouldUpdateVisibleRect):
(WebCore::CoordinatedGraphicsLayer::addChild):
(WebCore::CoordinatedGraphicsLayer::addChildAtIndex):
(WebCore::CoordinatedGraphicsLayer::addChildAbove):
(WebCore::CoordinatedGraphicsLayer::addChildBelow):
(WebCore::CoordinatedGraphicsLayer::replaceChild):
(WebCore::CoordinatedGraphicsLayer::setMaskLayer):
(WebCore::CoordinatedGraphicsLayer::syncPendingStateChangesIncludingSubLayers):
(WebCore::CoordinatedGraphicsLayer::updateContentBuffersIncludingSubLayers):
(WebCore::CoordinatedGraphicsLayer::setCoordinatorIncludingSubLayersIfNeeded):

  • platform/graphics/texmap/coordinated/CoordinatedGraphicsLayer.h:
  • platform/graphics/win/GraphicsLayerDirect2D.cpp:

(WebCore::GraphicsLayer::create):
(WebCore::GraphicsLayerDirect2D::GraphicsLayerDirect2D): Deleted.
(WebCore::GraphicsLayerDirect2D::initialize): Deleted.
(WebCore::GraphicsLayerDirect2D::~GraphicsLayerDirect2D): Deleted.
(WebCore::GraphicsLayerDirect2D::setNeedsDisplay): Deleted.
(WebCore::GraphicsLayerDirect2D::setNeedsDisplayInRect): Deleted.

  • rendering/RenderLayerBacking.cpp:

(WebCore::RenderLayerBacking::createGraphicsLayer):
(WebCore::RenderLayerBacking::createPrimaryGraphicsLayer):
(WebCore::RenderLayerBacking::updateConfiguration):
(WebCore::RenderLayerBacking::updateInternalHierarchy):
(WebCore::RenderLayerBacking::updateMaskingLayer):
(WebCore::RenderLayerBacking::updateChildClippingStrategy):
(WebCore::RenderLayerBacking::updateScrollingLayers):

  • rendering/RenderLayerBacking.h:
  • rendering/RenderLayerCompositor.cpp:

(WebCore::RenderLayerCompositor::updateCompositingLayers):
(WebCore::RenderLayerCompositor::appendDocumentOverlayLayers):
(WebCore::RenderLayerCompositor::setCompositingParent):
(WebCore::RenderLayerCompositor::rebuildCompositingLayerTree):
(WebCore::RenderLayerCompositor::parentFrameContentLayers):
(WebCore::RenderLayerCompositor::updateLayerForTopOverhangArea):
(WebCore::RenderLayerCompositor::updateLayerForBottomOverhangArea):
(WebCore::RenderLayerCompositor::updateLayerForHeader):
(WebCore::RenderLayerCompositor::updateLayerForFooter):
(WebCore::RenderLayerCompositor::updateOverflowControlsLayers):
(WebCore::RenderLayerCompositor::ensureRootLayer):
(WebCore::RenderLayerCompositor::rootLayerAttachmentChanged):

  • rendering/RenderLayerCompositor.h:

Source/WebKit:

Make GraphicsLayer be RefCounted<GraphicsLayer>. GraphicsLayers own their children, via a Vector<Ref<GraphicsLayer>>.

RenderLayerBacking and other holders of GraphicsLayers use RefPtr<GraphicsLayer>.

All the other changes are just to adapt to the new ownership patterns.

I verified that no GraphicsLayers were leaked or abandoned after this change.

  • WebProcess/WebCoreSupport/WebInspectorClient.cpp:

(WebKit::WebInspectorClient::~WebInspectorClient):
(WebKit::WebInspectorClient::showPaintRect):
(WebKit::WebInspectorClient::animationEndedForLayer):

  • WebProcess/WebCoreSupport/WebInspectorClient.h:
  • WebProcess/WebPage/RemoteLayerTree/RemoteLayerTreeContext.h:
  • WebProcess/WebPage/RemoteLayerTree/RemoteLayerTreeContext.mm:

(WebKit::RemoteLayerTreeContext::createGraphicsLayer):

  • WebProcess/WebPage/RemoteLayerTree/RemoteLayerTreeDrawingArea.h:
  • WebProcess/WebPage/RemoteLayerTree/RemoteLayerTreeDrawingArea.mm:

(WebKit::RemoteLayerTreeDrawingArea::updateRootLayers):
(WebKit::RemoteLayerTreeDrawingArea::flushLayers):

Location:
trunk/Source
Files:
34 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r235949 r235953  
     12018-09-11  Simon Fraser  <simon.fraser@apple.com>
     2
     3        Make GraphicsLayers ref-counted, so their tree can persist when disconnected from RenderLayerBackings
     4        https://bugs.webkit.org/show_bug.cgi?id=189521
     5
     6        Reviewed by Tim Horton.
     7       
     8        Make GraphicsLayer be RefCounted<GraphicsLayer>. GraphicsLayers own their children, via a Vector<Ref<GraphicsLayer>>.
     9       
     10        RenderLayerBacking and other holders of GraphicsLayers use RefPtr<GraphicsLayer>.
     11       
     12        All the other changes are just to adapt to the new ownership patterns.
     13       
     14        I verified that no GraphicsLayers were leaked or abandoned after this change.
     15
     16        No behavior change.
     17
     18        * page/PageOverlayController.cpp:
     19        (WebCore::PageOverlayController::layerWithDocumentOverlays):
     20        (WebCore::PageOverlayController::layerWithViewOverlays):
     21        (WebCore::PageOverlayController::installPageOverlay):
     22        (WebCore::PageOverlayController::uninstallPageOverlay):
     23        (WebCore::PageOverlayController::setPageOverlayNeedsDisplay):
     24        (WebCore::PageOverlayController::didChangeViewSize):
     25        (WebCore::PageOverlayController::didChangeDocumentSize):
     26        (WebCore::PageOverlayController::didChangeSettings):
     27        (WebCore::PageOverlayController::paintContents):
     28        (WebCore::PageOverlayController::didChangeOverlayFrame):
     29        (WebCore::PageOverlayController::didChangeOverlayBackgroundColor):
     30        * page/PageOverlayController.h:
     31        * page/mac/ServicesOverlayController.h:
     32        (WebCore::ServicesOverlayController::Highlight::layer const):
     33        * page/mac/ServicesOverlayController.mm:
     34        (WebCore::ServicesOverlayController::Highlight::Highlight):
     35        (WebCore::ServicesOverlayController::Highlight::invalidate):
     36        (WebCore::ServicesOverlayController::Highlight::fadeIn):
     37        (WebCore::ServicesOverlayController::Highlight::fadeOut):
     38        (WebCore::ServicesOverlayController::Highlight::didFinishFadeOutAnimation):
     39        (WebCore::ServicesOverlayController::determineActiveHighlight):
     40        * platform/graphics/GraphicsLayer.cpp:
     41        (WebCore::GraphicsLayer::GraphicsLayer):
     42        (WebCore::GraphicsLayer::willBeDestroyed):
     43        (WebCore::GraphicsLayer::setChildren):
     44        (WebCore::GraphicsLayer::addChild):
     45        (WebCore::GraphicsLayer::addChildAtIndex):
     46        (WebCore::GraphicsLayer::addChildBelow):
     47        (WebCore::GraphicsLayer::addChildAbove):
     48        (WebCore::GraphicsLayer::replaceChild):
     49        (WebCore::GraphicsLayer::removeAllChildren):
     50        (WebCore::GraphicsLayer::removeFromParent):
     51        (WebCore::GraphicsLayer::setMaskLayer):
     52        (WebCore::GraphicsLayer::noteDeviceOrPageScaleFactorChangedIncludingDescendants):
     53        (WebCore::GraphicsLayer::distributeOpacity):
     54        (WebCore::GraphicsLayer::traverse):
     55        (WebCore::dumpChildren):
     56        * platform/graphics/GraphicsLayer.h:
     57        (WebCore::GraphicsLayer::children const):
     58        (WebCore::GraphicsLayer::children):
     59        (WebCore::GraphicsLayer::maskLayer const):
     60        (WebCore::GraphicsLayer::replicaLayer const):
     61        (WebCore::GraphicsLayer::beingDestroyed const):
     62        (WebCore::GraphicsLayer:: const): Deleted.
     63        * platform/graphics/GraphicsLayerFactory.h:
     64        * platform/graphics/ca/GraphicsLayerCA.cpp:
     65        (WebCore::GraphicsLayer::create):
     66        (WebCore::GraphicsLayerCA::setChildren):
     67        (WebCore::GraphicsLayerCA::addChild):
     68        (WebCore::GraphicsLayerCA::addChildAtIndex):
     69        (WebCore::GraphicsLayerCA::addChildBelow):
     70        (WebCore::GraphicsLayerCA::addChildAbove):
     71        (WebCore::GraphicsLayerCA::replaceChild):
     72        (WebCore::GraphicsLayerCA::setMaskLayer):
     73        (WebCore::GraphicsLayerCA::recursiveVisibleRectChangeRequiresFlush const):
     74        (WebCore::GraphicsLayerCA::recursiveCommitChanges):
     75        (WebCore::GraphicsLayerCA::updateSublayerList):
     76        (WebCore::GraphicsLayerCA::createTransformAnimationsFromKeyframes):
     77        * platform/graphics/ca/GraphicsLayerCA.h:
     78        * platform/graphics/texmap/GraphicsLayerTextureMapper.cpp:
     79        (WebCore::GraphicsLayer::create):
     80        (WebCore::GraphicsLayerTextureMapper::setChildren):
     81        (WebCore::GraphicsLayerTextureMapper::addChild):
     82        (WebCore::GraphicsLayerTextureMapper::addChildAtIndex):
     83        (WebCore::GraphicsLayerTextureMapper::addChildAbove):
     84        (WebCore::GraphicsLayerTextureMapper::addChildBelow):
     85        (WebCore::GraphicsLayerTextureMapper::replaceChild):
     86        (WebCore::GraphicsLayerTextureMapper::setMaskLayer):
     87        (WebCore::GraphicsLayerTextureMapper::updateBackingStoreIncludingSubLayers):
     88        * platform/graphics/texmap/GraphicsLayerTextureMapper.h:
     89        * platform/graphics/texmap/coordinated/CoordinatedGraphicsLayer.cpp:
     90        (WebCore::GraphicsLayer::create):
     91        (WebCore::CoordinatedGraphicsLayer::setShouldUpdateVisibleRect):
     92        (WebCore::CoordinatedGraphicsLayer::addChild):
     93        (WebCore::CoordinatedGraphicsLayer::addChildAtIndex):
     94        (WebCore::CoordinatedGraphicsLayer::addChildAbove):
     95        (WebCore::CoordinatedGraphicsLayer::addChildBelow):
     96        (WebCore::CoordinatedGraphicsLayer::replaceChild):
     97        (WebCore::CoordinatedGraphicsLayer::setMaskLayer):
     98        (WebCore::CoordinatedGraphicsLayer::syncPendingStateChangesIncludingSubLayers):
     99        (WebCore::CoordinatedGraphicsLayer::updateContentBuffersIncludingSubLayers):
     100        (WebCore::CoordinatedGraphicsLayer::setCoordinatorIncludingSubLayersIfNeeded):
     101        * platform/graphics/texmap/coordinated/CoordinatedGraphicsLayer.h:
     102        * platform/graphics/win/GraphicsLayerDirect2D.cpp:
     103        (WebCore::GraphicsLayer::create):
     104        (WebCore::GraphicsLayerDirect2D::GraphicsLayerDirect2D): Deleted.
     105        (WebCore::GraphicsLayerDirect2D::initialize): Deleted.
     106        (WebCore::GraphicsLayerDirect2D::~GraphicsLayerDirect2D): Deleted.
     107        (WebCore::GraphicsLayerDirect2D::setNeedsDisplay): Deleted.
     108        (WebCore::GraphicsLayerDirect2D::setNeedsDisplayInRect): Deleted.
     109        * rendering/RenderLayerBacking.cpp:
     110        (WebCore::RenderLayerBacking::createGraphicsLayer):
     111        (WebCore::RenderLayerBacking::createPrimaryGraphicsLayer):
     112        (WebCore::RenderLayerBacking::updateConfiguration):
     113        (WebCore::RenderLayerBacking::updateInternalHierarchy):
     114        (WebCore::RenderLayerBacking::updateMaskingLayer):
     115        (WebCore::RenderLayerBacking::updateChildClippingStrategy):
     116        (WebCore::RenderLayerBacking::updateScrollingLayers):
     117        * rendering/RenderLayerBacking.h:
     118        * rendering/RenderLayerCompositor.cpp:
     119        (WebCore::RenderLayerCompositor::updateCompositingLayers):
     120        (WebCore::RenderLayerCompositor::appendDocumentOverlayLayers):
     121        (WebCore::RenderLayerCompositor::setCompositingParent):
     122        (WebCore::RenderLayerCompositor::rebuildCompositingLayerTree):
     123        (WebCore::RenderLayerCompositor::parentFrameContentLayers):
     124        (WebCore::RenderLayerCompositor::updateLayerForTopOverhangArea):
     125        (WebCore::RenderLayerCompositor::updateLayerForBottomOverhangArea):
     126        (WebCore::RenderLayerCompositor::updateLayerForHeader):
     127        (WebCore::RenderLayerCompositor::updateLayerForFooter):
     128        (WebCore::RenderLayerCompositor::updateOverflowControlsLayers):
     129        (WebCore::RenderLayerCompositor::ensureRootLayer):
     130        (WebCore::RenderLayerCompositor::rootLayerAttachmentChanged):
     131        * rendering/RenderLayerCompositor.h:
     132
    11332018-09-12  Alex Christensen  <achristensen@webkit.org>
    2134
  • trunk/Source/WebCore/page/PageOverlayController.cpp

    r230211 r235953  
    4444
    4545PageOverlayController::PageOverlayController(Page& page)
    46     : m_initialized(false)
    47     , m_page(page)
     46    :  m_page(page)
    4847{
    4948}
     
    9998            continue;
    10099
    101         GraphicsLayer& layer = *overlayAndLayer.value;
    102         GraphicsLayer::traverse(layer, [inWindow](GraphicsLayer& layer) {
     100        auto& layer = overlayAndLayer.value;
     101        GraphicsLayer::traverse(layer.get(), [inWindow](GraphicsLayer& layer) {
    103102            layer.setIsInWindow(inWindow);
    104103        });
    105         updateOverlayGeometry(overlay, layer);
     104        updateOverlayGeometry(overlay, layer.get());
    106105       
    107         if (!layer.parent())
    108             m_documentOverlayRootLayer->addChild(&layer);
     106        if (!layer->parent())
     107            m_documentOverlayRootLayer->addChild(layer.copyRef());
    109108    }
    110109
     
    123122            continue;
    124123
    125         GraphicsLayer& layer = *overlayAndLayer.value;
    126         GraphicsLayer::traverse(layer, [inWindow](GraphicsLayer& layer) {
     124        auto& layer = overlayAndLayer.value;
     125        GraphicsLayer::traverse(layer.get(), [inWindow](GraphicsLayer& layer) {
    127126            layer.setIsInWindow(inWindow);
    128127        });
    129         updateOverlayGeometry(overlay, layer);
     128        updateOverlayGeometry(overlay, layer.get());
    130129       
    131         if (!layer.parent())
    132             m_viewOverlayRootLayer->addChild(&layer);
     130        if (!layer->parent())
     131            m_viewOverlayRootLayer->addChild(layer.copyRef());
    133132    }
    134133
     
    145144    m_pageOverlays.append(&overlay);
    146145
    147     std::unique_ptr<GraphicsLayer> layer = GraphicsLayer::create(m_page.chrome().client().graphicsLayerFactory(), *this);
     146    auto layer = GraphicsLayer::create(m_page.chrome().client().graphicsLayerFactory(), *this);
    148147    layer->setAnchorPoint(FloatPoint3D());
    149148    layer->setBackgroundColor(overlay.backgroundColor());
    150149    layer->setName("Overlay content");
    151150
    152     updateSettingsForLayer(*layer);
     151    updateSettingsForLayer(layer.get());
    153152
    154153    switch (overlay.overlayType()) {
     
    161160    }
    162161
    163     GraphicsLayer& rawLayer = *layer;
     162    auto& rawLayer = layer.get();
    164163    m_overlayGraphicsLayers.set(&overlay, WTFMove(layer));
    165164
     
    186185    overlay.setPage(nullptr);
    187186
    188     m_overlayGraphicsLayers.take(&overlay)->removeFromParent();
     187    if (auto optionalLayer = m_overlayGraphicsLayers.take(&overlay))
     188        optionalLayer.value()->removeFromParent();
    189189
    190190    bool removed = m_pageOverlays.removeFirst(&overlay);
     
    212212{
    213213    ASSERT(m_pageOverlays.contains(&overlay));
    214     GraphicsLayer& graphicsLayer = *m_overlayGraphicsLayers.get(&overlay);
    215 
    216     if (!graphicsLayer.drawsContent()) {
    217         graphicsLayer.setDrawsContent(true);
    218         updateOverlayGeometry(overlay, graphicsLayer);
    219     }
    220 
    221     graphicsLayer.setNeedsDisplayInRect(dirtyRect);
     214    auto* graphicsLayer = m_overlayGraphicsLayers.get(&overlay);
     215
     216    if (!graphicsLayer->drawsContent()) {
     217        graphicsLayer->setDrawsContent(true);
     218        updateOverlayGeometry(overlay, *graphicsLayer);
     219    }
     220
     221    graphicsLayer->setNeedsDisplayInRect(dirtyRect);
    222222}
    223223
     
    242242void PageOverlayController::willDetachRootLayer()
    243243{
    244     m_documentOverlayRootLayer = nullptr;
    245     m_viewOverlayRootLayer = nullptr;
     244    if (m_documentOverlayRootLayer) {
     245        m_documentOverlayRootLayer->removeFromParent();
     246        m_documentOverlayRootLayer = nullptr;
     247    }
     248
     249    if (m_viewOverlayRootLayer) {
     250        m_viewOverlayRootLayer->removeFromParent();
     251        m_viewOverlayRootLayer = nullptr;
     252    }
    246253    m_initialized = false;
    247254}
     
    251258    for (auto& overlayAndLayer : m_overlayGraphicsLayers) {
    252259        if (overlayAndLayer.key->overlayType() == PageOverlay::OverlayType::View)
    253             updateOverlayGeometry(*overlayAndLayer.key, *overlayAndLayer.value);
     260            updateOverlayGeometry(*overlayAndLayer.key, overlayAndLayer.value.get());
    254261    }
    255262}
     
    259266    for (auto& overlayAndLayer : m_overlayGraphicsLayers) {
    260267        if (overlayAndLayer.key->overlayType() == PageOverlay::OverlayType::Document)
    261             updateOverlayGeometry(*overlayAndLayer.key, *overlayAndLayer.value);
     268            updateOverlayGeometry(*overlayAndLayer.key, overlayAndLayer.value.get());
    262269    }
    263270}
     
    267274    // FIXME: We should apply these settings to all overlay sublayers recursively.
    268275    for (auto& graphicsLayer : m_overlayGraphicsLayers.values())
    269         updateSettingsForLayer(*graphicsLayer);
     276        updateSettingsForLayer(graphicsLayer.get());
    270277}
    271278
     
    360367{
    361368    for (auto& overlayAndGraphicsLayer : m_overlayGraphicsLayers) {
    362         if (overlayAndGraphicsLayer.value.get() != graphicsLayer)
     369        if (overlayAndGraphicsLayer.value.ptr() != graphicsLayer)
    363370            continue;
    364371
     
    384391{
    385392    ASSERT(m_pageOverlays.contains(&overlay));
    386     updateOverlayGeometry(overlay, *m_overlayGraphicsLayers.get(&overlay));
     393    if (auto* layer = m_overlayGraphicsLayers.get(&overlay))
     394        updateOverlayGeometry(overlay, *layer);
    387395}
    388396
     
    390398{
    391399    ASSERT(m_pageOverlays.contains(&overlay));
    392     m_overlayGraphicsLayers.get(&overlay)->setBackgroundColor(overlay.backgroundColor());
     400    if (auto* layer = m_overlayGraphicsLayers.get(&overlay))
     401        layer->setBackgroundColor(overlay.backgroundColor());
    393402}
    394403
  • trunk/Source/WebCore/page/PageOverlayController.h

    r230211 r235953  
    9393    void tiledBackingUsageChanged(const GraphicsLayer*, bool) override;
    9494
    95     std::unique_ptr<GraphicsLayer> m_documentOverlayRootLayer;
    96     std::unique_ptr<GraphicsLayer> m_viewOverlayRootLayer;
    97     bool m_initialized;
     95    Page& m_page;
     96    RefPtr<GraphicsLayer> m_documentOverlayRootLayer;
     97    RefPtr<GraphicsLayer> m_viewOverlayRootLayer;
    9898
    99     HashMap<PageOverlay*, std::unique_ptr<GraphicsLayer>> m_overlayGraphicsLayers;
     99    HashMap<PageOverlay*, Ref<GraphicsLayer>> m_overlayGraphicsLayers;
    100100    Vector<RefPtr<PageOverlay>> m_pageOverlays;
    101     Page& m_page;
     101    bool m_initialized { false };
    102102};
    103103
  • trunk/Source/WebCore/page/ResourceUsageOverlay.h

    r225470 r235953  
    8484
    8585#if OS(LINUX)
    86     std::unique_ptr<GraphicsLayer> m_paintLayer;
     86    RefPtr<GraphicsLayer> m_paintLayer;
    8787    std::unique_ptr<GraphicsLayerClient> m_overlayPainter;
    8888#endif
  • trunk/Source/WebCore/page/linux/ResourceUsageOverlayLinux.cpp

    r234501 r235953  
    138138    m_paintLayer->setBackgroundColor(Color(0.0f, 0.0f, 0.0f, 0.8f));
    139139    m_paintLayer->setDrawsContent(true);
    140     overlay().layer().addChild(m_paintLayer.get());
     140    overlay().layer().addChild(*m_paintLayer);
    141141
    142142    ResourceUsageThread::addObserver(this, [this] (const ResourceUsageData& data) {
  • trunk/Source/WebCore/page/mac/ServicesOverlayController.h

    r230211 r235953  
    6464        DDHighlightRef ddHighlight() const { return m_ddHighlight.get(); }
    6565        Range& range() const { return m_range.get(); }
    66         GraphicsLayer* layer() const { return m_graphicsLayer.get(); }
     66        GraphicsLayer& layer() const { return m_graphicsLayer.get(); }
    6767
    6868        enum {
     
    8888        void didFinishFadeOutAnimation();
    8989
     90        ServicesOverlayController* m_controller;
    9091        RetainPtr<DDHighlightRef> m_ddHighlight;
    9192        Ref<Range> m_range;
    92         std::unique_ptr<GraphicsLayer> m_graphicsLayer;
     93        Ref<GraphicsLayer> m_graphicsLayer;
    9394        Type m_type;
    94         ServicesOverlayController* m_controller;
    9595    };
    9696
  • trunk/Source/WebCore/page/mac/ServicesOverlayController.mm

    r235935 r235953  
    6767
    6868ServicesOverlayController::Highlight::Highlight(ServicesOverlayController& controller, Type type, RetainPtr<DDHighlightRef> ddHighlight, Ref<WebCore::Range>&& range)
    69     : m_range(WTFMove(range))
     69    : m_controller(&controller)
     70    , m_range(WTFMove(range))
     71    , m_graphicsLayer(GraphicsLayer::create(controller.page().chrome().client().graphicsLayerFactory(), *this))
    7072    , m_type(type)
    71     , m_controller(&controller)
    7273{
    7374    ASSERT(ddHighlight);
    7475
    75     auto& page = controller.page();
    76     m_graphicsLayer = GraphicsLayer::create(page.chrome().client().graphicsLayerFactory(), *this);
    7776    m_graphicsLayer->setDrawsContent(true);
    7877
     
    8180    // Set directly on the PlatformCALayer so that when we leave the 'from' value implicit
    8281    // in our animations, we get the right initial value regardless of flush timing.
    83     downcast<GraphicsLayerCA>(*layer()).platformCALayer()->setOpacity(0);
     82    downcast<GraphicsLayerCA>(layer()).platformCALayer()->setOpacity(0);
    8483
    8584    controller.didCreateHighlight(this);
     
    114113void ServicesOverlayController::Highlight::invalidate()
    115114{
    116     layer()->removeFromParent();
     115    layer().removeFromParent();
    117116    m_controller = nullptr;
    118117}
     
    159158
    160159    RefPtr<PlatformCAAnimation> platformAnimation = PlatformCAAnimationCocoa::create(animation.get());
    161     downcast<GraphicsLayerCA>(*layer()).platformCALayer()->addAnimationForKey("FadeHighlightIn", *platformAnimation);
     160    downcast<GraphicsLayerCA>(layer()).platformCALayer()->addAnimationForKey("FadeHighlightIn", *platformAnimation);
    162161}
    163162
     
    177176
    178177    RefPtr<PlatformCAAnimation> platformAnimation = PlatformCAAnimationCocoa::create(animation.get());
    179     downcast<GraphicsLayerCA>(*layer()).platformCALayer()->addAnimationForKey("FadeHighlightOut", *platformAnimation);
     178    downcast<GraphicsLayerCA>(layer()).platformCALayer()->addAnimationForKey("FadeHighlightOut", *platformAnimation);
    180179    [CATransaction commit];
    181180}
     
    189188        return;
    190189
    191     layer()->removeFromParent();
     190    layer().removeFromParent();
    192191}
    193192
     
    715714
    716715        if (m_activeHighlight) {
    717             m_servicesOverlay->layer().addChild(m_activeHighlight->layer());
     716            Ref<GraphicsLayer> highlightLayer = m_activeHighlight->layer();
     717            m_servicesOverlay->layer().addChild(WTFMove(highlightLayer));
    718718            m_activeHighlight->fadeIn();
    719719        }
  • trunk/Source/WebCore/platform/graphics/GraphicsLayer.cpp

    r234610 r235953  
    114114    : m_client(client)
    115115    , m_type(type)
     116    , m_beingDestroyed(false)
    116117    , m_contentsOpaque(false)
    117118    , m_supportsSubpixelAntialiasedText(false)
     
    144145void GraphicsLayer::willBeDestroyed()
    145146{
     147    m_beingDestroyed = true;
    146148#ifndef NDEBUG
    147149    m_client.verifyNotPainting();
     
    178180}
    179181
    180 bool GraphicsLayer::setChildren(const Vector<GraphicsLayer*>& newChildren)
     182bool GraphicsLayer::setChildren(Vector<Ref<GraphicsLayer>>&& newChildren)
    181183{
    182184    // If the contents of the arrays are the same, nothing to do.
     
    185187
    186188    removeAllChildren();
    187    
     189
    188190    size_t listSize = newChildren.size();
    189191    for (size_t i = 0; i < listSize; ++i)
    190         addChild(newChildren[i]);
     192        addChild(WTFMove(newChildren[i]));
    191193   
    192194    return true;
    193195}
    194196
    195 void GraphicsLayer::addChild(GraphicsLayer* childLayer)
    196 {
    197     ASSERT(childLayer != this);
     197void GraphicsLayer::addChild(Ref<GraphicsLayer>&& childLayer)
     198{
     199    ASSERT(childLayer.ptr() != this);
    198200   
    199201    if (childLayer->parent())
     
    201203
    202204    childLayer->setParent(this);
    203     m_children.append(childLayer);
    204 }
    205 
    206 void GraphicsLayer::addChildAtIndex(GraphicsLayer* childLayer, int index)
    207 {
    208     ASSERT(childLayer != this);
     205    m_children.append(WTFMove(childLayer));
     206}
     207
     208void GraphicsLayer::addChildAtIndex(Ref<GraphicsLayer>&& childLayer, int index)
     209{
     210    ASSERT(childLayer.ptr() != this);
    209211
    210212    if (childLayer->parent())
     
    212214
    213215    childLayer->setParent(this);
    214     m_children.insert(index, childLayer);
    215 }
    216 
    217 void GraphicsLayer::addChildBelow(GraphicsLayer* childLayer, GraphicsLayer* sibling)
    218 {
    219     ASSERT(childLayer != this);
     216    m_children.insert(index, WTFMove(childLayer));
     217}
     218
     219void GraphicsLayer::addChildBelow(Ref<GraphicsLayer>&& childLayer, GraphicsLayer* sibling)
     220{
     221    ASSERT(childLayer.ptr() != this);
    220222    childLayer->removeFromParent();
     223
     224    childLayer->setParent(this);
     225
     226    for (unsigned i = 0; i < m_children.size(); i++) {
     227        if (sibling == m_children[i].ptr()) {
     228            m_children.insert(i, WTFMove(childLayer));
     229            return;
     230        }
     231    }
     232
     233    m_children.append(WTFMove(childLayer));
     234}
     235
     236void GraphicsLayer::addChildAbove(Ref<GraphicsLayer>&& childLayer, GraphicsLayer* sibling)
     237{
     238    childLayer->removeFromParent();
     239    ASSERT(childLayer.ptr() != this);
     240
     241    childLayer->setParent(this);
     242
     243    for (unsigned i = 0; i < m_children.size(); i++) {
     244        if (sibling == m_children[i].ptr()) {
     245            m_children.insert(i + 1, WTFMove(childLayer));
     246            return;
     247        }
     248    }
     249
     250    m_children.append(WTFMove(childLayer));
     251}
     252
     253bool GraphicsLayer::replaceChild(GraphicsLayer* oldChild, Ref<GraphicsLayer>&& newChild)
     254{
     255    ASSERT(!newChild->parent());
     256   
     257    GraphicsLayer* rawNewChild = newChild.ptr();
    221258
    222259    bool found = false;
    223260    for (unsigned i = 0; i < m_children.size(); i++) {
    224         if (sibling == m_children[i]) {
    225             m_children.insert(i, childLayer);
     261        if (oldChild == m_children[i].ptr()) {
     262            m_children[i] = WTFMove(newChild);
    226263            found = true;
    227264            break;
    228265        }
    229266    }
    230 
    231     childLayer->setParent(this);
    232 
    233     if (!found)
    234         m_children.append(childLayer);
    235 }
    236 
    237 void GraphicsLayer::addChildAbove(GraphicsLayer* childLayer, GraphicsLayer* sibling)
    238 {
    239     childLayer->removeFromParent();
    240     ASSERT(childLayer != this);
    241 
    242     bool found = false;
    243     for (unsigned i = 0; i < m_children.size(); i++) {
    244         if (sibling == m_children[i]) {
    245             m_children.insert(i+1, childLayer);
    246             found = true;
    247             break;
    248         }
    249     }
    250 
    251     childLayer->setParent(this);
    252 
    253     if (!found)
    254         m_children.append(childLayer);
    255 }
    256 
    257 bool GraphicsLayer::replaceChild(GraphicsLayer* oldChild, GraphicsLayer* newChild)
    258 {
    259     ASSERT(!newChild->parent());
    260     bool found = false;
    261     for (unsigned i = 0; i < m_children.size(); i++) {
    262         if (oldChild == m_children[i]) {
    263             m_children[i] = newChild;
    264             found = true;
    265             break;
    266         }
    267     }
    268267    if (found) {
    269         oldChild->setParent(0);
    270 
    271         newChild->removeFromParent();
    272         newChild->setParent(this);
     268        oldChild->setParent(nullptr);
     269
     270        rawNewChild->removeFromParent();
     271        rawNewChild->setParent(this);
    273272        return true;
    274273    }
     
    279278{
    280279    while (m_children.size()) {
    281         GraphicsLayer* curLayer = m_children[0];
     280        GraphicsLayer* curLayer = m_children[0].ptr();
    282281        ASSERT(curLayer->parent());
    283282        curLayer->removeFromParent();
     283        // curLayer may be destroyed here.
    284284    }
    285285}
     
    288288{
    289289    if (m_parent) {
    290         m_parent->m_children.removeFirst(this);
     290        GraphicsLayer* parent = m_parent;
    291291        setParent(nullptr);
     292        parent->m_children.removeFirstMatching([this](auto& layer) {
     293            return layer.ptr() == this;
     294        });
     295        // |this| may be destroyed here.
    292296    }
    293297}
     
    319323}
    320324
    321 void GraphicsLayer::setMaskLayer(GraphicsLayer* layer)
     325void GraphicsLayer::setMaskLayer(RefPtr<GraphicsLayer>&& layer)
    322326{
    323327    if (layer == m_maskLayer)
     
    333337    }
    334338   
    335     m_maskLayer = layer;
     339    m_maskLayer = WTFMove(layer);
    336340}
    337341
     
    382386        m_replicaLayer->noteDeviceOrPageScaleFactorChangedIncludingDescendants();
    383387
    384     const Vector<GraphicsLayer*>& childLayers = children();
    385     size_t numChildren = childLayers.size();
    386     for (size_t i = 0; i < numChildren; ++i)
    387         childLayers[i]->noteDeviceOrPageScaleFactorChangedIncludingDescendants();
     388    for (auto& layer : children())
     389        layer->noteDeviceOrPageScaleFactorChangedIncludingDescendants();
    388390}
    389391
     
    535537   
    536538    if (preserves3D()) {
    537         size_t numChildren = children().size();
    538         for (size_t i = 0; i < numChildren; ++i)
    539             children()[i]->distributeOpacity(accumulatedOpacity);
     539        for (auto& layer : children())
     540            layer->distributeOpacity(accumulatedOpacity);
    540541    }
    541542}
     
    694695    traversalFunc(layer);
    695696
    696     for (auto* childLayer : layer.children())
    697         traverse(*childLayer, traversalFunc);
     697    for (auto& childLayer : layer.children())
     698        traverse(childLayer.get(), traversalFunc);
    698699
    699700    if (auto* replicaLayer = layer.replicaLayer())
     
    718719}
    719720
    720 static void dumpChildren(TextStream& ts, const Vector<GraphicsLayer*>& children, unsigned& totalChildCount, LayerTreeAsTextBehavior behavior)
     721static void dumpChildren(TextStream& ts, const Vector<Ref<GraphicsLayer>>& children, unsigned& totalChildCount, LayerTreeAsTextBehavior behavior)
    721722{
    722723    totalChildCount += children.size();
    723     for (auto* child : children) {
    724         if ((behavior & LayerTreeAsTextDebug) || !child->client().shouldSkipLayerInDump(child, behavior)) {
     724    for (auto& child : children) {
     725        if ((behavior & LayerTreeAsTextDebug) || !child->client().shouldSkipLayerInDump(child.ptr(), behavior)) {
    725726            TextStream::IndentScope indentScope(ts);
    726727            child->dumpLayer(ts, behavior);
  • trunk/Source/WebCore/platform/graphics/GraphicsLayer.h

    r234610 r235953  
    231231// which may have associated transformation and animations.
    232232
    233 class GraphicsLayer {
    234     WTF_MAKE_NONCOPYABLE(GraphicsLayer); WTF_MAKE_FAST_ALLOCATED;
     233class GraphicsLayer : public RefCounted<GraphicsLayer> {
     234    WTF_MAKE_FAST_ALLOCATED;
    235235public:
    236236    enum class Type : uint8_t {
     
    240240        Shape
    241241    };
    242    
    243     WEBCORE_EXPORT static std::unique_ptr<GraphicsLayer> create(GraphicsLayerFactory*, GraphicsLayerClient&, Type = Type::Normal);
     242
     243    WEBCORE_EXPORT static Ref<GraphicsLayer> create(GraphicsLayerFactory*, GraphicsLayerClient&, Type = Type::Normal);
    244244   
    245245    WEBCORE_EXPORT virtual ~GraphicsLayer();
     
    264264    bool hasAncestor(GraphicsLayer*) const;
    265265   
    266     const Vector<GraphicsLayer*>& children() const { return m_children; }
     266    const Vector<Ref<GraphicsLayer>>& children() const { return m_children; }
     267    Vector<Ref<GraphicsLayer>>& children() { return m_children; }
     268
    267269    // Returns true if the child list changed.
    268     WEBCORE_EXPORT virtual bool setChildren(const Vector<GraphicsLayer*>&);
     270    WEBCORE_EXPORT virtual bool setChildren(Vector<Ref<GraphicsLayer>>&&);
     271
     272    // Add child layers. If the child is already parented, it will be removed from its old parent.
     273    WEBCORE_EXPORT virtual void addChild(Ref<GraphicsLayer>&&);
     274    WEBCORE_EXPORT virtual void addChildAtIndex(Ref<GraphicsLayer>&&, int index);
     275    WEBCORE_EXPORT virtual void addChildAbove(Ref<GraphicsLayer>&&, GraphicsLayer* sibling);
     276    WEBCORE_EXPORT virtual void addChildBelow(Ref<GraphicsLayer>&&, GraphicsLayer* sibling);
     277    WEBCORE_EXPORT virtual bool replaceChild(GraphicsLayer* oldChild, Ref<GraphicsLayer>&& newChild);
     278
     279    WEBCORE_EXPORT void removeAllChildren();
     280    WEBCORE_EXPORT virtual void removeFromParent();
     281
     282    // The parent() of a maskLayer is set to the layer being masked.
     283    GraphicsLayer* maskLayer() const { return m_maskLayer.get(); }
     284    virtual void setMaskLayer(RefPtr<GraphicsLayer>&&);
     285
     286    void setIsMaskLayer(bool isMask) { m_isMaskLayer = isMask; }
     287    bool isMaskLayer() const { return m_isMaskLayer; }
     288   
     289    // The given layer will replicate this layer and its children; the replica renders behind this layer.
     290    WEBCORE_EXPORT virtual void setReplicatedByLayer(GraphicsLayer*);
     291    // Whether this layer is being replicated by another layer.
     292    bool isReplicated() const { return m_replicaLayer; }
     293    // The layer that replicates this layer (if any).
     294    GraphicsLayer* replicaLayer() const { return m_replicaLayer.get(); }
     295
     296    const FloatPoint& replicatedLayerPosition() const { return m_replicatedLayerPosition; }
     297    void setReplicatedLayerPosition(const FloatPoint& p) { m_replicatedLayerPosition = p; }
     298
     299    enum ShouldSetNeedsDisplay {
     300        DontSetNeedsDisplay,
     301        SetNeedsDisplay
     302    };
     303
     304    // Offset is origin of the renderer minus origin of the graphics layer.
     305    FloatSize offsetFromRenderer() const { return m_offsetFromRenderer; }
     306    void setOffsetFromRenderer(const FloatSize&, ShouldSetNeedsDisplay = SetNeedsDisplay);
     307
     308    // The position of the layer (the location of its top-left corner in its parent)
     309    const FloatPoint& position() const { return m_position; }
     310    virtual void setPosition(const FloatPoint& p) { m_approximatePosition = std::nullopt; m_position = p; }
     311
     312    // approximatePosition, if set, overrides position() and is used during coverage rect computation.
     313    FloatPoint approximatePosition() const { return m_approximatePosition ? m_approximatePosition.value() : m_position; }
     314    virtual void setApproximatePosition(const FloatPoint& p) { m_approximatePosition = p; }
     315
     316    // For platforms that move underlying platform layers on a different thread for scrolling; just update the GraphicsLayer state.
     317    virtual void syncPosition(const FloatPoint& p) { m_position = p; }
     318
     319    // Anchor point: (0, 0) is top left, (1, 1) is bottom right. The anchor point
     320    // affects the origin of the transforms.
     321    const FloatPoint3D& anchorPoint() const { return m_anchorPoint; }
     322    virtual void setAnchorPoint(const FloatPoint3D& p) { m_anchorPoint = p; }
     323
     324    // The size of the layer.
     325    const FloatSize& size() const { return m_size; }
     326    WEBCORE_EXPORT virtual void setSize(const FloatSize&);
     327
     328    // The boundOrigin affects the offset at which content is rendered, and sublayers are positioned.
     329    const FloatPoint& boundsOrigin() const { return m_boundsOrigin; }
     330    virtual void setBoundsOrigin(const FloatPoint& origin) { m_boundsOrigin = origin; }
     331
     332    // For platforms that move underlying platform layers on a different thread for scrolling; just update the GraphicsLayer state.
     333    virtual void syncBoundsOrigin(const FloatPoint& origin) { m_boundsOrigin = origin; }
     334
     335    const TransformationMatrix& transform() const;
     336    virtual void setTransform(const TransformationMatrix&);
     337    bool hasNonIdentityTransform() const { return m_transform && !m_transform->isIdentity(); }
     338
     339    const TransformationMatrix& childrenTransform() const;
     340    virtual void setChildrenTransform(const TransformationMatrix&);
     341    bool hasNonIdentityChildrenTransform() const { return m_childrenTransform && !m_childrenTransform->isIdentity(); }
     342
     343    bool preserves3D() const { return m_preserves3D; }
     344    virtual void setPreserves3D(bool b) { m_preserves3D = b; }
     345   
     346    bool masksToBounds() const { return m_masksToBounds; }
     347    virtual void setMasksToBounds(bool b) { m_masksToBounds = b; }
     348   
     349    bool drawsContent() const { return m_drawsContent; }
     350    virtual void setDrawsContent(bool b) { m_drawsContent = b; }
     351
     352    bool contentsAreVisible() const { return m_contentsVisible; }
     353    virtual void setContentsVisible(bool b) { m_contentsVisible = b; }
     354
     355    bool userInteractionEnabled() const { return m_userInteractionEnabled; }
     356    virtual void setUserInteractionEnabled(bool b) { m_userInteractionEnabled = b; }
     357   
     358    bool acceleratesDrawing() const { return m_acceleratesDrawing; }
     359    virtual void setAcceleratesDrawing(bool b) { m_acceleratesDrawing = b; }
     360
     361    bool usesDisplayListDrawing() const { return m_usesDisplayListDrawing; }
     362    virtual void setUsesDisplayListDrawing(bool b) { m_usesDisplayListDrawing = b; }
     363
     364    bool needsBackdrop() const { return !m_backdropFilters.isEmpty(); }
     365
     366    // The color used to paint the layer background. Pass an invalid color to remove it.
     367    // Note that this covers the entire layer. Use setContentsToSolidColor() if the color should
     368    // only cover the contentsRect.
     369    const Color& backgroundColor() const { return m_backgroundColor; }
     370    WEBCORE_EXPORT virtual void setBackgroundColor(const Color&);
     371
     372    // opaque means that we know the layer contents have no alpha
     373    bool contentsOpaque() const { return m_contentsOpaque; }
     374    virtual void setContentsOpaque(bool b) { m_contentsOpaque = b; }
     375
     376    bool supportsSubpixelAntialiasedText() const { return m_supportsSubpixelAntialiasedText; }
     377    virtual void setSupportsSubpixelAntialiasedText(bool b) { m_supportsSubpixelAntialiasedText = b; }
     378
     379    bool backfaceVisibility() const { return m_backfaceVisibility; }
     380    virtual void setBackfaceVisibility(bool b) { m_backfaceVisibility = b; }
     381
     382    float opacity() const { return m_opacity; }
     383    virtual void setOpacity(float opacity) { m_opacity = opacity; }
     384
     385    const FilterOperations& filters() const { return m_filters; }
     386    // Returns true if filter can be rendered by the compositor.
     387    virtual bool setFilters(const FilterOperations& filters) { m_filters = filters; return true; }
     388
     389    const FilterOperations& backdropFilters() const { return m_backdropFilters; }
     390    virtual bool setBackdropFilters(const FilterOperations& filters) { m_backdropFilters = filters; return true; }
     391
     392    virtual void setBackdropFiltersRect(const FloatRoundedRect& backdropFiltersRect) { m_backdropFiltersRect = backdropFiltersRect; }
     393    const FloatRoundedRect& backdropFiltersRect() const { return m_backdropFiltersRect; }
     394
     395#if ENABLE(CSS_COMPOSITING)
     396    BlendMode blendMode() const { return m_blendMode; }
     397    virtual void setBlendMode(BlendMode blendMode) { m_blendMode = blendMode; }
     398#endif
     399
     400    // Some GraphicsLayers paint only the foreground or the background content
     401    GraphicsLayerPaintingPhase paintingPhase() const { return m_paintingPhase; }
     402    void setPaintingPhase(GraphicsLayerPaintingPhase phase) { m_paintingPhase = phase; }
     403
     404    enum ShouldClipToLayer {
     405        DoNotClipToLayer,
     406        ClipToLayer
     407    };
     408
     409    virtual void setNeedsDisplay() = 0;
     410    // mark the given rect (in layer coords) as needing dispay. Never goes deep.
     411    virtual void setNeedsDisplayInRect(const FloatRect&, ShouldClipToLayer = ClipToLayer) = 0;
     412
     413    virtual void setContentsNeedsDisplay() { };
     414
     415    // The tile phase is relative to the GraphicsLayer bounds.
     416    virtual void setContentsTilePhase(const FloatSize& p) { m_contentsTilePhase = p; }
     417    FloatSize contentsTilePhase() const { return m_contentsTilePhase; }
     418
     419    virtual void setContentsTileSize(const FloatSize& s) { m_contentsTileSize = s; }
     420    FloatSize contentsTileSize() const { return m_contentsTileSize; }
     421    bool hasContentsTiling() const { return !m_contentsTileSize.isEmpty(); }
     422
     423    // Set that the position/size of the contents (image or video).
     424    FloatRect contentsRect() const { return m_contentsRect; }
     425    virtual void setContentsRect(const FloatRect& r) { m_contentsRect = r; }
     426
     427    // Set a rounded rect that will be used to clip the layer contents.
     428    FloatRoundedRect contentsClippingRect() const { return m_contentsClippingRect; }
     429    virtual void setContentsClippingRect(const FloatRoundedRect& roundedRect) { m_contentsClippingRect = roundedRect; }
     430
     431    // Set a rounded rect that is used to clip this layer and its descendants (implies setting masksToBounds).
     432    // Returns false if the platform can't support this rounded clip, and we should fall back to painting a mask.
     433    FloatRoundedRect maskToBoundsRect() const { return m_masksToBoundsRect; };
     434    virtual bool setMasksToBoundsRect(const FloatRoundedRect& roundedRect) { m_masksToBoundsRect = roundedRect; return false; }
     435
     436    Path shapeLayerPath() const;
     437    virtual void setShapeLayerPath(const Path&);
     438
     439    WindRule shapeLayerWindRule() const;
     440    virtual void setShapeLayerWindRule(WindRule);
     441
     442    // Transitions are identified by a special animation name that cannot clash with a keyframe identifier.
     443    static String animationNameForTransition(AnimatedPropertyID);
     444
     445    // Return true if the animation is handled by the compositing system. If this returns
     446    // false, the animation will be run by CSSAnimationController.
     447    // These methods handle both transitions and keyframe animations.
     448    virtual bool addAnimation(const KeyframeValueList&, const FloatSize& /*boxSize*/, const Animation*, const String& /*animationName*/, double /*timeOffset*/)  { return false; }
     449    virtual void pauseAnimation(const String& /*animationName*/, double /*timeOffset*/) { }
     450    virtual void seekAnimation(const String& /*animationName*/, double /*timeOffset*/) { }
     451    virtual void removeAnimation(const String& /*animationName*/) { }
     452
     453    WEBCORE_EXPORT virtual void suspendAnimations(MonotonicTime);
     454    WEBCORE_EXPORT virtual void resumeAnimations();
     455
     456    // Layer contents
     457    virtual void setContentsToImage(Image*) { }
     458    virtual bool shouldDirectlyCompositeImage(Image*) const { return true; }
     459#if PLATFORM(IOS)
     460    virtual PlatformLayer* contentsLayerForMedia() const { return 0; }
     461#endif
    269462
    270463    enum class ContentsLayerPurpose : uint8_t {
     
    277470    };
    278471
    279     // Add child layers. If the child is already parented, it will be removed from its old parent.
    280     WEBCORE_EXPORT virtual void addChild(GraphicsLayer*);
    281     WEBCORE_EXPORT virtual void addChildAtIndex(GraphicsLayer*, int index);
    282     WEBCORE_EXPORT virtual void addChildAbove(GraphicsLayer*, GraphicsLayer* sibling);
    283     WEBCORE_EXPORT virtual void addChildBelow(GraphicsLayer*, GraphicsLayer* sibling);
    284     WEBCORE_EXPORT virtual bool replaceChild(GraphicsLayer* oldChild, GraphicsLayer* newChild);
    285 
    286     WEBCORE_EXPORT void removeAllChildren();
    287     WEBCORE_EXPORT virtual void removeFromParent();
    288 
    289     // The parent() of a maskLayer is set to the layer being masked.
    290     GraphicsLayer* maskLayer() const { return m_maskLayer; }
    291     virtual void setMaskLayer(GraphicsLayer*);
    292 
    293     void setIsMaskLayer(bool isMask) { m_isMaskLayer = isMask; }
    294     bool isMaskLayer() const { return m_isMaskLayer; }
    295    
    296     // The given layer will replicate this layer and its children; the replica renders behind this layer.
    297     WEBCORE_EXPORT virtual void setReplicatedByLayer(GraphicsLayer*);
    298     // Whether this layer is being replicated by another layer.
    299     bool isReplicated() const { return m_replicaLayer; }
    300     // The layer that replicates this layer (if any).
    301     GraphicsLayer* replicaLayer() const { return m_replicaLayer; }
    302 
    303     const FloatPoint& replicatedLayerPosition() const { return m_replicatedLayerPosition; }
    304     void setReplicatedLayerPosition(const FloatPoint& p) { m_replicatedLayerPosition = p; }
    305 
    306     enum ShouldSetNeedsDisplay {
    307         DontSetNeedsDisplay,
    308         SetNeedsDisplay
    309     };
    310 
    311     // Offset is origin of the renderer minus origin of the graphics layer.
    312     FloatSize offsetFromRenderer() const { return m_offsetFromRenderer; }
    313     void setOffsetFromRenderer(const FloatSize&, ShouldSetNeedsDisplay = SetNeedsDisplay);
    314 
    315     // The position of the layer (the location of its top-left corner in its parent)
    316     const FloatPoint& position() const { return m_position; }
    317     virtual void setPosition(const FloatPoint& p) { m_approximatePosition = std::nullopt; m_position = p; }
    318 
    319     // approximatePosition, if set, overrides position() and is used during coverage rect computation.
    320     FloatPoint approximatePosition() const { return m_approximatePosition ? m_approximatePosition.value() : m_position; }
    321     virtual void setApproximatePosition(const FloatPoint& p) { m_approximatePosition = p; }
    322 
    323     // For platforms that move underlying platform layers on a different thread for scrolling; just update the GraphicsLayer state.
    324     virtual void syncPosition(const FloatPoint& p) { m_position = p; }
    325 
    326     // Anchor point: (0, 0) is top left, (1, 1) is bottom right. The anchor point
    327     // affects the origin of the transforms.
    328     const FloatPoint3D& anchorPoint() const { return m_anchorPoint; }
    329     virtual void setAnchorPoint(const FloatPoint3D& p) { m_anchorPoint = p; }
    330 
    331     // The size of the layer.
    332     const FloatSize& size() const { return m_size; }
    333     WEBCORE_EXPORT virtual void setSize(const FloatSize&);
    334 
    335     // The boundOrigin affects the offset at which content is rendered, and sublayers are positioned.
    336     const FloatPoint& boundsOrigin() const { return m_boundsOrigin; }
    337     virtual void setBoundsOrigin(const FloatPoint& origin) { m_boundsOrigin = origin; }
    338 
    339     // For platforms that move underlying platform layers on a different thread for scrolling; just update the GraphicsLayer state.
    340     virtual void syncBoundsOrigin(const FloatPoint& origin) { m_boundsOrigin = origin; }
    341 
    342     const TransformationMatrix& transform() const;
    343     virtual void setTransform(const TransformationMatrix&);
    344     bool hasNonIdentityTransform() const { return m_transform && !m_transform->isIdentity(); }
    345 
    346     const TransformationMatrix& childrenTransform() const;
    347     virtual void setChildrenTransform(const TransformationMatrix&);
    348     bool hasNonIdentityChildrenTransform() const { return m_childrenTransform && !m_childrenTransform->isIdentity(); }
    349 
    350     bool preserves3D() const { return m_preserves3D; }
    351     virtual void setPreserves3D(bool b) { m_preserves3D = b; }
    352    
    353     bool masksToBounds() const { return m_masksToBounds; }
    354     virtual void setMasksToBounds(bool b) { m_masksToBounds = b; }
    355    
    356     bool drawsContent() const { return m_drawsContent; }
    357     virtual void setDrawsContent(bool b) { m_drawsContent = b; }
    358 
    359     bool contentsAreVisible() const { return m_contentsVisible; }
    360     virtual void setContentsVisible(bool b) { m_contentsVisible = b; }
    361 
    362     bool userInteractionEnabled() const { return m_userInteractionEnabled; }
    363     virtual void setUserInteractionEnabled(bool b) { m_userInteractionEnabled = b; }
    364    
    365     bool acceleratesDrawing() const { return m_acceleratesDrawing; }
    366     virtual void setAcceleratesDrawing(bool b) { m_acceleratesDrawing = b; }
    367 
    368     bool usesDisplayListDrawing() const { return m_usesDisplayListDrawing; }
    369     virtual void setUsesDisplayListDrawing(bool b) { m_usesDisplayListDrawing = b; }
    370 
    371     bool needsBackdrop() const { return !m_backdropFilters.isEmpty(); }
    372 
    373     // The color used to paint the layer background. Pass an invalid color to remove it.
    374     // Note that this covers the entire layer. Use setContentsToSolidColor() if the color should
    375     // only cover the contentsRect.
    376     const Color& backgroundColor() const { return m_backgroundColor; }
    377     WEBCORE_EXPORT virtual void setBackgroundColor(const Color&);
    378 
    379     // opaque means that we know the layer contents have no alpha
    380     bool contentsOpaque() const { return m_contentsOpaque; }
    381     virtual void setContentsOpaque(bool b) { m_contentsOpaque = b; }
    382 
    383     bool supportsSubpixelAntialiasedText() const { return m_supportsSubpixelAntialiasedText; }
    384     virtual void setSupportsSubpixelAntialiasedText(bool b) { m_supportsSubpixelAntialiasedText = b; }
    385 
    386     bool backfaceVisibility() const { return m_backfaceVisibility; }
    387     virtual void setBackfaceVisibility(bool b) { m_backfaceVisibility = b; }
    388 
    389     float opacity() const { return m_opacity; }
    390     virtual void setOpacity(float opacity) { m_opacity = opacity; }
    391 
    392     const FilterOperations& filters() const { return m_filters; }
    393     // Returns true if filter can be rendered by the compositor.
    394     virtual bool setFilters(const FilterOperations& filters) { m_filters = filters; return true; }
    395 
    396     const FilterOperations& backdropFilters() const { return m_backdropFilters; }
    397     virtual bool setBackdropFilters(const FilterOperations& filters) { m_backdropFilters = filters; return true; }
    398 
    399     virtual void setBackdropFiltersRect(const FloatRoundedRect& backdropFiltersRect) { m_backdropFiltersRect = backdropFiltersRect; }
    400     const FloatRoundedRect& backdropFiltersRect() const { return m_backdropFiltersRect; }
    401 
    402 #if ENABLE(CSS_COMPOSITING)
    403     BlendMode blendMode() const { return m_blendMode; }
    404     virtual void setBlendMode(BlendMode blendMode) { m_blendMode = blendMode; }
    405 #endif
    406 
    407     // Some GraphicsLayers paint only the foreground or the background content
    408     GraphicsLayerPaintingPhase paintingPhase() const { return m_paintingPhase; }
    409     void setPaintingPhase(GraphicsLayerPaintingPhase phase) { m_paintingPhase = phase; }
    410 
    411     enum ShouldClipToLayer {
    412         DoNotClipToLayer,
    413         ClipToLayer
    414     };
    415 
    416     virtual void setNeedsDisplay() = 0;
    417     // mark the given rect (in layer coords) as needing dispay. Never goes deep.
    418     virtual void setNeedsDisplayInRect(const FloatRect&, ShouldClipToLayer = ClipToLayer) = 0;
    419 
    420     virtual void setContentsNeedsDisplay() { };
    421 
    422     // The tile phase is relative to the GraphicsLayer bounds.
    423     virtual void setContentsTilePhase(const FloatSize& p) { m_contentsTilePhase = p; }
    424     FloatSize contentsTilePhase() const { return m_contentsTilePhase; }
    425 
    426     virtual void setContentsTileSize(const FloatSize& s) { m_contentsTileSize = s; }
    427     FloatSize contentsTileSize() const { return m_contentsTileSize; }
    428     bool hasContentsTiling() const { return !m_contentsTileSize.isEmpty(); }
    429 
    430     // Set that the position/size of the contents (image or video).
    431     FloatRect contentsRect() const { return m_contentsRect; }
    432     virtual void setContentsRect(const FloatRect& r) { m_contentsRect = r; }
    433 
    434     // Set a rounded rect that will be used to clip the layer contents.
    435     FloatRoundedRect contentsClippingRect() const { return m_contentsClippingRect; }
    436     virtual void setContentsClippingRect(const FloatRoundedRect& roundedRect) { m_contentsClippingRect = roundedRect; }
    437 
    438     // Set a rounded rect that is used to clip this layer and its descendants (implies setting masksToBounds).
    439     // Returns false if the platform can't support this rounded clip, and we should fall back to painting a mask.
    440     FloatRoundedRect maskToBoundsRect() const { return m_masksToBoundsRect; };
    441     virtual bool setMasksToBoundsRect(const FloatRoundedRect& roundedRect) { m_masksToBoundsRect = roundedRect; return false; }
    442 
    443     Path shapeLayerPath() const;
    444     virtual void setShapeLayerPath(const Path&);
    445 
    446     WindRule shapeLayerWindRule() const;
    447     virtual void setShapeLayerWindRule(WindRule);
    448 
    449     // Transitions are identified by a special animation name that cannot clash with a keyframe identifier.
    450     static String animationNameForTransition(AnimatedPropertyID);
    451 
    452     // Return true if the animation is handled by the compositing system. If this returns
    453     // false, the animation will be run by CSSAnimationController.
    454     // These methods handle both transitions and keyframe animations.
    455     virtual bool addAnimation(const KeyframeValueList&, const FloatSize& /*boxSize*/, const Animation*, const String& /*animationName*/, double /*timeOffset*/)  { return false; }
    456     virtual void pauseAnimation(const String& /*animationName*/, double /*timeOffset*/) { }
    457     virtual void seekAnimation(const String& /*animationName*/, double /*timeOffset*/) { }
    458     virtual void removeAnimation(const String& /*animationName*/) { }
    459 
    460     WEBCORE_EXPORT virtual void suspendAnimations(MonotonicTime);
    461     WEBCORE_EXPORT virtual void resumeAnimations();
    462 
    463     // Layer contents
    464     virtual void setContentsToImage(Image*) { }
    465     virtual bool shouldDirectlyCompositeImage(Image*) const { return true; }
    466 #if PLATFORM(IOS)
    467     virtual PlatformLayer* contentsLayerForMedia() const { return 0; }
    468 #endif
    469472    // Pass an invalid color to remove the contents layer.
    470473    virtual void setContentsToSolidColor(const Color&) { }
     
    592595    // Should be called from derived class destructors. Should call willBeDestroyed() on super.
    593596    WEBCORE_EXPORT virtual void willBeDestroyed();
     597    bool beingDestroyed() const { return m_beingDestroyed; }
    594598
    595599    // This method is used by platform GraphicsLayer classes to clear the filters
     
    657661    CompositingCoordinatesOrientation m_contentsOrientation { CompositingCoordinatesOrientation::TopDown }; // affects orientation of layer contents
    658662
     663    bool m_beingDestroyed : 1;
    659664    bool m_contentsOpaque : 1;
    660665    bool m_supportsSubpixelAntialiasedText : 1;
     
    676681    int m_repaintCount { 0 };
    677682
    678     Vector<GraphicsLayer*> m_children;
     683    Vector<Ref<GraphicsLayer>> m_children;
    679684    GraphicsLayer* m_parent { nullptr };
    680685
    681     GraphicsLayer* m_maskLayer { nullptr }; // Reference to mask layer. We don't own this.
    682 
    683     GraphicsLayer* m_replicaLayer { nullptr }; // A layer that replicates this layer. We only allow one, for now.
     686    RefPtr<GraphicsLayer> m_maskLayer { nullptr }; // Reference to mask layer.
     687
     688    RefPtr<GraphicsLayer> m_replicaLayer { nullptr }; // A layer that replicates this layer. We only allow one, for now.
    684689                                   // The replica is not parented; this is the primary reference to it.
    685690    GraphicsLayer* m_replicatedLayer { nullptr }; // For a replica layer, a reference to the original layer.
  • trunk/Source/WebCore/platform/graphics/GraphicsLayerFactory.h

    r223728 r235953  
    2424 */
    2525
    26 #ifndef GraphicsLayerFactory_h
    27 #define GraphicsLayerFactory_h
     26#pragma once
    2827
    2928#include "GraphicsLayer.h"
     
    3635    virtual ~GraphicsLayerFactory() = default;
    3736
    38     virtual std::unique_ptr<GraphicsLayer> createGraphicsLayer(GraphicsLayer::Type, GraphicsLayerClient&) = 0;
     37    virtual Ref<GraphicsLayer> createGraphicsLayer(GraphicsLayer::Type, GraphicsLayerClient&) = 0;
    3938};
    4039
    4140} // namespace WebCore
    42 
    43 #endif // GraphicsLayerFactory_h
  • trunk/Source/WebCore/platform/graphics/ca/GraphicsLayerCA.cpp

    r235854 r235953  
    340340}
    341341
    342 std::unique_ptr<GraphicsLayer> GraphicsLayer::create(GraphicsLayerFactory* factory, GraphicsLayerClient& client, Type layerType)
    343 {
    344     std::unique_ptr<GraphicsLayer> graphicsLayer;
    345     if (!factory)
    346         graphicsLayer = std::make_unique<GraphicsLayerCA>(layerType, client);
    347     else
    348         graphicsLayer = factory->createGraphicsLayer(layerType, client);
    349 
    350     graphicsLayer->initialize(layerType);
    351 
    352     return graphicsLayer;
     342Ref<GraphicsLayer> GraphicsLayer::create(GraphicsLayerFactory* factory, GraphicsLayerClient& client, Type layerType)
     343{
     344    if (factory) {
     345        auto layer = factory->createGraphicsLayer(layerType, client);
     346        layer->initialize(layerType);
     347        return layer;
     348    }
     349   
     350    auto layer = adoptRef(*new GraphicsLayerCA(layerType, client));
     351    layer->initialize(layerType);
     352    return WTFMove(layer);
    353353}
    354354
     
    506506}
    507507
    508 bool GraphicsLayerCA::setChildren(const Vector<GraphicsLayer*>& children)
    509 {
    510     bool childrenChanged = GraphicsLayer::setChildren(children);
     508bool GraphicsLayerCA::setChildren(Vector<Ref<GraphicsLayer>>&& children)
     509{
     510    bool childrenChanged = GraphicsLayer::setChildren(WTFMove(children));
    511511    if (childrenChanged)
    512512        noteSublayersChanged();
     
    515515}
    516516
    517 void GraphicsLayerCA::addChild(GraphicsLayer* childLayer)
    518 {
    519     GraphicsLayer::addChild(childLayer);
     517void GraphicsLayerCA::addChild(Ref<GraphicsLayer>&& childLayer)
     518{
     519    GraphicsLayer::addChild(WTFMove(childLayer));
    520520    noteSublayersChanged();
    521521}
    522522
    523 void GraphicsLayerCA::addChildAtIndex(GraphicsLayer* childLayer, int index)
    524 {
    525     GraphicsLayer::addChildAtIndex(childLayer, index);
     523void GraphicsLayerCA::addChildAtIndex(Ref<GraphicsLayer>&& childLayer, int index)
     524{
     525    GraphicsLayer::addChildAtIndex(WTFMove(childLayer), index);
    526526    noteSublayersChanged();
    527527}
    528528
    529 void GraphicsLayerCA::addChildBelow(GraphicsLayer* childLayer, GraphicsLayer* sibling)
    530 {
    531     GraphicsLayer::addChildBelow(childLayer, sibling);
     529void GraphicsLayerCA::addChildBelow(Ref<GraphicsLayer>&& childLayer, GraphicsLayer* sibling)
     530{
     531    GraphicsLayer::addChildBelow(WTFMove(childLayer), sibling);
    532532    noteSublayersChanged();
    533533}
    534534
    535 void GraphicsLayerCA::addChildAbove(GraphicsLayer* childLayer, GraphicsLayer* sibling)
    536 {
    537     GraphicsLayer::addChildAbove(childLayer, sibling);
     535void GraphicsLayerCA::addChildAbove(Ref<GraphicsLayer>&& childLayer, GraphicsLayer* sibling)
     536{
     537    GraphicsLayer::addChildAbove(WTFMove(childLayer), sibling);
    538538    noteSublayersChanged();
    539539}
    540540
    541 bool GraphicsLayerCA::replaceChild(GraphicsLayer* oldChild, GraphicsLayer* newChild)
    542 {
    543     if (GraphicsLayer::replaceChild(oldChild, newChild)) {
     541bool GraphicsLayerCA::replaceChild(GraphicsLayer* oldChild, Ref<GraphicsLayer>&& newChild)
     542{
     543    if (GraphicsLayer::replaceChild(oldChild, WTFMove(newChild))) {
    544544        noteSublayersChanged();
    545545        return true;
     
    555555}
    556556
    557 void GraphicsLayerCA::setMaskLayer(GraphicsLayer* layer)
     557void GraphicsLayerCA::setMaskLayer(RefPtr<GraphicsLayer>&& layer)
    558558{
    559559    if (layer == m_maskLayer)
    560560        return;
    561561
    562     GraphicsLayer::setMaskLayer(layer);
     562    GraphicsLayer::setMaskLayer(WTFMove(layer));
    563563    noteLayerPropertyChanged(MaskLayerChanged);
    564564
     
    13011301
    13021302    if (m_maskLayer) {
    1303         GraphicsLayerCA& maskLayerCA = downcast<GraphicsLayerCA>(*m_maskLayer);
     1303        auto& maskLayerCA = downcast<GraphicsLayerCA>(*m_maskLayer);
    13041304        if (maskLayerCA.recursiveVisibleRectChangeRequiresFlush(childCommitState, localState))
    13051305            return true;
    13061306    }
    13071307
    1308     const Vector<GraphicsLayer*>& childLayers = children();
    1309     size_t numChildren = childLayers.size();
    1310    
    1311     for (size_t i = 0; i < numChildren; ++i) {
    1312         GraphicsLayerCA& currentChild = downcast<GraphicsLayerCA>(*childLayers[i]);
     1308    for (const auto& layer : children()) {
     1309        const auto& currentChild = downcast<GraphicsLayerCA>(layer.get());
    13131310        if (currentChild.recursiveVisibleRectChangeRequiresFlush(childCommitState, localState))
    13141311            return true;
     
    15731570    childCommitState.ancestorIsViewportConstrained |= m_isViewportConstrained;
    15741571
    1575     if (GraphicsLayerCA* maskLayer = downcast<GraphicsLayerCA>(m_maskLayer)) {
     1572    if (GraphicsLayerCA* maskLayer = downcast<GraphicsLayerCA>(m_maskLayer.get())) {
    15761573        maskLayer->setVisibleAndCoverageRects(rects, m_isViewportConstrained || commitState.ancestorIsViewportConstrained);
    15771574        maskLayer->commitLayerChangesBeforeSublayers(childCommitState, pageScaleFactor, baseRelativePosition);
    15781575    }
    15791576
    1580     const Vector<GraphicsLayer*>& childLayers = children();
    1581     size_t numChildren = childLayers.size();
    1582 
    15831577    bool hasDescendantsWithRunningTransformAnimations = false;
    15841578   
    1585     for (size_t i = 0; i < numChildren; ++i) {
    1586         GraphicsLayerCA& currentChild = downcast<GraphicsLayerCA>(*childLayers[i]);
     1579    for (auto& layer : children()) {
     1580        auto& currentChild = downcast<GraphicsLayerCA>(layer.get());
    15871581        currentChild.recursiveCommitChanges(childCommitState, localState, pageScaleFactor, baseRelativePosition, affectedByPageScale);
    15881582
     
    15911585    }
    15921586
    1593     if (GraphicsLayerCA* replicaLayer = downcast<GraphicsLayerCA>(m_replicaLayer))
     1587    if (GraphicsLayerCA* replicaLayer = downcast<GraphicsLayerCA>(m_replicaLayer.get()))
    15941588        replicaLayer->recursiveCommitChanges(childCommitState, localState, pageScaleFactor, baseRelativePosition, affectedByPageScale);
    15951589
    1596     if (GraphicsLayerCA* maskLayer = downcast<GraphicsLayerCA>(m_maskLayer))
     1590    if (GraphicsLayerCA* maskLayer = downcast<GraphicsLayerCA>(m_maskLayer.get()))
    15971591        maskLayer->commitLayerChangesAfterSublayers(childCommitState);
    15981592
     
    19291923    }
    19301924   
    1931     const Vector<GraphicsLayer*>& childLayers = children();
    1932     size_t numChildren = childLayers.size();
    1933     for (size_t i = 0; i < numChildren; ++i) {
    1934         GraphicsLayerCA& currentChild = downcast<GraphicsLayerCA>(*childLayers[i]);
     1925    for (const auto& layer : children()) {
     1926        const auto& currentChild = downcast<GraphicsLayerCA>(layer.get());
    19351927        PlatformCALayer* childLayer = currentChild.layerForSuperlayer();
    19361928        childListForSublayers.append(childLayer);
     
    39783970    }
    39793971
    3980     const Vector<GraphicsLayer*>& childLayers = children();
     3972    auto& childLayers = children();
    39813973    Vector<RefPtr<PlatformCALayer>> clonalSublayers;
    39823974
     
    40284020        replicaState.push(ReplicaState::ChildBranch);
    40294021
    4030         for (auto* childLayer : childLayers) {
    4031             GraphicsLayerCA& childLayerCA = downcast<GraphicsLayerCA>(*childLayer);
     4022        for (auto& childLayer : childLayers) {
     4023            GraphicsLayerCA& childLayerCA = downcast<GraphicsLayerCA>(childLayer.get());
    40324024            if (auto platformLayer = childLayerCA.fetchCloneLayers(replicaRoot, replicaState, IntermediateCloneLevel))
    40334025                clonalSublayers.append(WTFMove(platformLayer));
     
    41934185void GraphicsLayerCA::noteLayerPropertyChanged(LayerChangeFlags flags, ScheduleFlushOrNot scheduleFlush)
    41944186{
     4187    if (beingDestroyed())
     4188        return;
     4189
    41954190    bool hadUncommittedChanges = !!m_uncommittedChanges;
    41964191    bool oldCanThrottleLayerFlush = canThrottleLayerFlush();
  • trunk/Source/WebCore/platform/graphics/ca/GraphicsLayerCA.h

    r234393 r235953  
    5050class GraphicsLayerCA : public GraphicsLayer, public PlatformCALayerClient {
    5151public:
    52 
    5352    WEBCORE_EXPORT explicit GraphicsLayerCA(Type, GraphicsLayerClient&);
    5453    WEBCORE_EXPORT virtual ~GraphicsLayerCA();
     
    6362    PlatformCALayer* platformCALayer() const { return primaryLayer(); }
    6463
    65     WEBCORE_EXPORT bool setChildren(const Vector<GraphicsLayer*>&) override;
    66     WEBCORE_EXPORT void addChild(GraphicsLayer*) override;
    67     WEBCORE_EXPORT void addChildAtIndex(GraphicsLayer*, int index) override;
    68     WEBCORE_EXPORT void addChildAbove(GraphicsLayer*, GraphicsLayer* sibling) override;
    69     WEBCORE_EXPORT void addChildBelow(GraphicsLayer*, GraphicsLayer* sibling) override;
    70     WEBCORE_EXPORT bool replaceChild(GraphicsLayer* oldChild, GraphicsLayer* newChild) override;
     64    WEBCORE_EXPORT bool setChildren(Vector<Ref<GraphicsLayer>>&&) override;
     65    WEBCORE_EXPORT void addChild(Ref<GraphicsLayer>&&) override;
     66    WEBCORE_EXPORT void addChildAtIndex(Ref<GraphicsLayer>&&, int index) override;
     67    WEBCORE_EXPORT void addChildAbove(Ref<GraphicsLayer>&&, GraphicsLayer* sibling) override;
     68    WEBCORE_EXPORT void addChildBelow(Ref<GraphicsLayer>&&, GraphicsLayer* sibling) override;
     69    WEBCORE_EXPORT bool replaceChild(GraphicsLayer* oldChild, Ref<GraphicsLayer>&& newChild) override;
    7170
    7271    WEBCORE_EXPORT void removeFromParent() override;
    7372
    74     WEBCORE_EXPORT void setMaskLayer(GraphicsLayer*) override;
     73    WEBCORE_EXPORT void setMaskLayer(RefPtr<GraphicsLayer>&&) override;
    7574    WEBCORE_EXPORT void setReplicatedLayer(GraphicsLayer*) override;
    7675
  • trunk/Source/WebCore/platform/graphics/texmap/GraphicsLayerTextureMapper.cpp

    r234393 r235953  
    3030namespace WebCore {
    3131
    32 std::unique_ptr<GraphicsLayer> GraphicsLayer::create(GraphicsLayerFactory* factory, GraphicsLayerClient& client, Type layerType)
     32Ref<GraphicsLayer> GraphicsLayer::create(GraphicsLayerFactory* factory, GraphicsLayerClient& client, Type layerType)
    3333{
    3434    if (!factory)
    35         return std::make_unique<GraphicsLayerTextureMapper>(layerType, client);
     35        return adoptRef(*new GraphicsLayerTextureMapper(layerType, client));
    3636
    3737    return factory->createGraphicsLayer(layerType, client);
     
    9494}
    9595
    96 bool GraphicsLayerTextureMapper::setChildren(const Vector<GraphicsLayer*>& children)
    97 {
    98     if (GraphicsLayer::setChildren(children)) {
     96bool GraphicsLayerTextureMapper::setChildren(Vector<Ref<GraphicsLayer>>&& children)
     97{
     98    if (GraphicsLayer::setChildren(WTFMove(children))) {
    9999        notifyChange(ChildrenChange);
    100100        return true;
     
    103103}
    104104
    105 void GraphicsLayerTextureMapper::addChild(GraphicsLayer* layer)
     105void GraphicsLayerTextureMapper::addChild(Ref<GraphicsLayer>&& layer)
    106106{
    107107    notifyChange(ChildrenChange);
    108     GraphicsLayer::addChild(layer);
    109 }
    110 
    111 void GraphicsLayerTextureMapper::addChildAtIndex(GraphicsLayer* layer, int index)
    112 {
    113     GraphicsLayer::addChildAtIndex(layer, index);
     108    GraphicsLayer::addChild(WTFMove(layer));
     109}
     110
     111void GraphicsLayerTextureMapper::addChildAtIndex(Ref<GraphicsLayer>&& layer, int index)
     112{
     113    GraphicsLayer::addChildAtIndex(WTFMove(layer), index);
    114114    notifyChange(ChildrenChange);
    115115}
    116116
    117 void GraphicsLayerTextureMapper::addChildAbove(GraphicsLayer* layer, GraphicsLayer* sibling)
    118 {
    119     GraphicsLayer::addChildAbove(layer, sibling);
     117void GraphicsLayerTextureMapper::addChildAbove(Ref<GraphicsLayer>&& layer, GraphicsLayer* sibling)
     118{
     119    GraphicsLayer::addChildAbove(WTFMove(layer), sibling);
    120120    notifyChange(ChildrenChange);
    121121}
    122122
    123 void GraphicsLayerTextureMapper::addChildBelow(GraphicsLayer* layer, GraphicsLayer* sibling)
    124 {
    125     GraphicsLayer::addChildBelow(layer, sibling);
     123void GraphicsLayerTextureMapper::addChildBelow(Ref<GraphicsLayer>&& layer, GraphicsLayer* sibling)
     124{
     125    GraphicsLayer::addChildBelow(WTFMove(layer), sibling);
    126126    notifyChange(ChildrenChange);
    127127}
    128128
    129 bool GraphicsLayerTextureMapper::replaceChild(GraphicsLayer* oldChild, GraphicsLayer* newChild)
    130 {
    131     if (GraphicsLayer::replaceChild(oldChild, newChild)) {
     129bool GraphicsLayerTextureMapper::replaceChild(GraphicsLayer* oldChild, Ref<GraphicsLayer>&& newChild)
     130{
     131    if (GraphicsLayer::replaceChild(oldChild, WTFMove(newChild))) {
    132132        notifyChange(ChildrenChange);
    133133        return true;
     
    136136}
    137137
    138 void GraphicsLayerTextureMapper::setMaskLayer(GraphicsLayer* value)
     138void GraphicsLayerTextureMapper::setMaskLayer(RefPtr<GraphicsLayer>&& value)
    139139{
    140140    if (value == maskLayer())
    141141        return;
    142     GraphicsLayer::setMaskLayer(value);
     142
     143    GraphicsLayer* rawLayer = value.get();
     144    GraphicsLayer::setMaskLayer(WTFMove(value));
    143145    notifyChange(MaskLayerChange);
    144146
    145     if (!value)
    146         return;
    147     value->setSize(size());
    148     value->setContentsVisible(contentsAreVisible());
     147    if (!rawLayer)
     148        return;
     149    rawLayer->setSize(size());
     150    rawLayer->setContentsVisible(contentsAreVisible());
    149151}
    150152
     
    392394        return;
    393395
    394     if (m_changeMask & ChildrenChange)
    395         m_layer.setChildren(children());
     396    if (m_changeMask & ChildrenChange) {
     397        Vector<GraphicsLayer*> rawChildren;
     398        rawChildren.reserveInitialCapacity(children().size());
     399        for (auto& layer : children())
     400            rawChildren.uncheckedAppend(layer.ptr());
     401        m_layer.setChildren(rawChildren);
     402    }
    396403
    397404    if (m_changeMask & MaskLayerChange)
     
    478485    if (replicaLayer())
    479486        replicaLayer()->flushCompositingState(rect);
    480     for (auto* child : children())
     487    for (auto& child : children())
    481488        child->flushCompositingState(rect);
    482489}
     
    493500    if (replicaLayer())
    494501        downcast<GraphicsLayerTextureMapper>(*replicaLayer()).updateBackingStoreIfNeeded();
    495     for (auto* child : children())
    496         downcast<GraphicsLayerTextureMapper>(*child).updateBackingStoreIncludingSubLayers();
     502    for (auto& child : children())
     503        downcast<GraphicsLayerTextureMapper>(child.get()).updateBackingStoreIncludingSubLayers();
    497504}
    498505
  • trunk/Source/WebCore/platform/graphics/texmap/GraphicsLayerTextureMapper.h

    r234393 r235953  
    4040
    4141    // GraphicsLayer
    42     bool setChildren(const Vector<GraphicsLayer*>&) override;
    43     void addChild(GraphicsLayer*) override;
    44     void addChildAtIndex(GraphicsLayer*, int index) override;
    45     void addChildAbove(GraphicsLayer*, GraphicsLayer* sibling) override;
    46     void addChildBelow(GraphicsLayer*, GraphicsLayer* sibling) override;
    47     bool replaceChild(GraphicsLayer* oldChild, GraphicsLayer* newChild) override;
     42    bool setChildren(Vector<Ref<GraphicsLayer>>&&) override;
     43    void addChild(Ref<GraphicsLayer>&&) override;
     44    void addChildAtIndex(Ref<GraphicsLayer>&&, int index) override;
     45    void addChildAbove(Ref<GraphicsLayer>&&, GraphicsLayer* sibling) override;
     46    void addChildBelow(Ref<GraphicsLayer>&&, GraphicsLayer* sibling) override;
     47    bool replaceChild(GraphicsLayer* oldChild, Ref<GraphicsLayer>&& newChild) override;
    4848
    49     void setMaskLayer(GraphicsLayer*) override;
     49    void setMaskLayer(RefPtr<GraphicsLayer>&&) override;
    5050    void setReplicatedByLayer(GraphicsLayer*) override;
    5151    void setPosition(const FloatPoint&) override;
  • trunk/Source/WebCore/platform/graphics/texmap/coordinated/CoordinatedGraphicsLayer.cpp

    r235671 r235953  
    4747namespace WebCore {
    4848
    49 std::unique_ptr<GraphicsLayer> GraphicsLayer::create(GraphicsLayerFactory* factory, GraphicsLayerClient& client, Type layerType)
     49Ref<GraphicsLayer> GraphicsLayer::create(GraphicsLayerFactory* factory, GraphicsLayerClient& client, Type layerType)
    5050{
    5151    if (!factory)
    52         return std::make_unique<CoordinatedGraphicsLayer>(layerType, client);
     52        return adoptRef(*new CoordinatedGraphicsLayer(layerType, client));
    5353
    5454    return factory->createGraphicsLayer(layerType, client);
     
    9898    m_shouldUpdateVisibleRect = true;
    9999    for (auto& child : children())
    100         downcast<CoordinatedGraphicsLayer>(*child).setShouldUpdateVisibleRect();
     100        downcast<CoordinatedGraphicsLayer>(child.get()).setShouldUpdateVisibleRect();
    101101    if (replicaLayer())
    102102        downcast<CoordinatedGraphicsLayer>(*replicaLayer()).setShouldUpdateVisibleRect();
     
    159159}
    160160
    161 bool CoordinatedGraphicsLayer::setChildren(const Vector<GraphicsLayer*>& children)
    162 {
    163     bool ok = GraphicsLayer::setChildren(children);
     161bool CoordinatedGraphicsLayer::setChildren(Vector<Ref<GraphicsLayer>>&& children)
     162{
     163    bool ok = GraphicsLayer::setChildren(WTFMove(children));
    164164    if (!ok)
    165165        return false;
     
    168168}
    169169
    170 void CoordinatedGraphicsLayer::addChild(GraphicsLayer* layer)
    171 {
    172     GraphicsLayer::addChild(layer);
    173     downcast<CoordinatedGraphicsLayer>(*layer).setCoordinatorIncludingSubLayersIfNeeded(m_coordinator);
     170void CoordinatedGraphicsLayer::addChild(Ref<GraphicsLayer>&& layer)
     171{
     172    GraphicsLayer* rawLayer = layer.ptr();
     173    GraphicsLayer::addChild(WTFMove(layer));
     174    downcast<CoordinatedGraphicsLayer>(*rawLayer).setCoordinatorIncludingSubLayersIfNeeded(m_coordinator);
    174175    didChangeChildren();
    175176}
    176177
    177 void CoordinatedGraphicsLayer::addChildAtIndex(GraphicsLayer* layer, int index)
    178 {
    179     GraphicsLayer::addChildAtIndex(layer, index);
    180     downcast<CoordinatedGraphicsLayer>(*layer).setCoordinatorIncludingSubLayersIfNeeded(m_coordinator);
     178void CoordinatedGraphicsLayer::addChildAtIndex(Ref<GraphicsLayer>&& layer, int index)
     179{
     180    GraphicsLayer* rawLayer = layer.ptr();
     181    GraphicsLayer::addChildAtIndex(WTFMove(layer), index);
     182    downcast<CoordinatedGraphicsLayer>(*rawLayer).setCoordinatorIncludingSubLayersIfNeeded(m_coordinator);
    181183    didChangeChildren();
    182184}
    183185
    184 void CoordinatedGraphicsLayer::addChildAbove(GraphicsLayer* layer, GraphicsLayer* sibling)
    185 {
    186     GraphicsLayer::addChildAbove(layer, sibling);
    187     downcast<CoordinatedGraphicsLayer>(*layer).setCoordinatorIncludingSubLayersIfNeeded(m_coordinator);
     186void CoordinatedGraphicsLayer::addChildAbove(Ref<GraphicsLayer>&& layer, GraphicsLayer* sibling)
     187{
     188    GraphicsLayer* rawLayer = layer.ptr();
     189    GraphicsLayer::addChildAbove(WTFMove(layer), sibling);
     190    downcast<CoordinatedGraphicsLayer>(*rawLayer).setCoordinatorIncludingSubLayersIfNeeded(m_coordinator);
    188191    didChangeChildren();
    189192}
    190193
    191 void CoordinatedGraphicsLayer::addChildBelow(GraphicsLayer* layer, GraphicsLayer* sibling)
    192 {
    193     GraphicsLayer::addChildBelow(layer, sibling);
    194     downcast<CoordinatedGraphicsLayer>(*layer).setCoordinatorIncludingSubLayersIfNeeded(m_coordinator);
     194void CoordinatedGraphicsLayer::addChildBelow(Ref<GraphicsLayer>&& layer, GraphicsLayer* sibling)
     195{
     196    GraphicsLayer* rawLayer = layer.ptr();
     197    GraphicsLayer::addChildBelow(WTFMove(layer), sibling);
     198    downcast<CoordinatedGraphicsLayer>(*rawLayer).setCoordinatorIncludingSubLayersIfNeeded(m_coordinator);
    195199    didChangeChildren();
    196200}
    197201
    198 bool CoordinatedGraphicsLayer::replaceChild(GraphicsLayer* oldChild, GraphicsLayer* newChild)
    199 {
    200     bool ok = GraphicsLayer::replaceChild(oldChild, newChild);
     202bool CoordinatedGraphicsLayer::replaceChild(GraphicsLayer* oldChild, Ref<GraphicsLayer>&& newChild)
     203{
     204    GraphicsLayer* rawLayer = newChild.ptr();
     205    bool ok = GraphicsLayer::replaceChild(oldChild, WTFMove(newChild));
    201206    if (!ok)
    202207        return false;
    203     downcast<CoordinatedGraphicsLayer>(*newChild).setCoordinatorIncludingSubLayersIfNeeded(m_coordinator);
     208    downcast<CoordinatedGraphicsLayer>(*rawLayer).setCoordinatorIncludingSubLayersIfNeeded(m_coordinator);
    204209    didChangeChildren();
    205210    return true;
     
    496501}
    497502
    498 void CoordinatedGraphicsLayer::setMaskLayer(GraphicsLayer* layer)
     503void CoordinatedGraphicsLayer::setMaskLayer(RefPtr<GraphicsLayer>&& layer)
    499504{
    500505    if (layer == maskLayer())
    501506        return;
    502507
    503     GraphicsLayer::setMaskLayer(layer);
    504 
    505     if (!layer)
    506         return;
    507 
    508     layer->setSize(size());
    509     layer->setContentsVisible(contentsAreVisible());
     508    GraphicsLayer* rawLayer = layer.get();
     509    GraphicsLayer::setMaskLayer(WTFMove(layer));
     510
     511    if (!rawLayer)
     512        return;
     513
     514    rawLayer->setSize(size());
     515    rawLayer->setContentsVisible(contentsAreVisible());
    510516
    511517    m_nicosia.delta.maskChanged = true;
     
    733739                if (localDelta.childrenChanged) {
    734740                    state.children = WTF::map(children(),
    735                         [](auto* child)
     741                        [](auto& child)
    736742                        {
    737                             return downcast<CoordinatedGraphicsLayer>(child)->m_nicosia.layer;
     743                            return downcast<CoordinatedGraphicsLayer>(child.get()).m_nicosia.layer;
    738744                        });
    739745                }
     
    785791
    786792    for (auto& child : children())
    787         downcast<CoordinatedGraphicsLayer>(*child).syncPendingStateChangesIncludingSubLayers();
     793        downcast<CoordinatedGraphicsLayer>(child.get()).syncPendingStateChangesIncludingSubLayers();
    788794}
    789795
     
    838844
    839845    for (auto& child : children())
    840         downcast<CoordinatedGraphicsLayer>(*child).updateContentBuffersIncludingSubLayers();
     846        downcast<CoordinatedGraphicsLayer>(child.get()).updateContentBuffersIncludingSubLayers();
    841847}
    842848
     
    10081014    coordinator->attachLayer(this);
    10091015    for (auto& child : children())
    1010         downcast<CoordinatedGraphicsLayer>(*child).setCoordinatorIncludingSubLayersIfNeeded(coordinator);
     1016        downcast<CoordinatedGraphicsLayer>(child.get()).setCoordinatorIncludingSubLayersIfNeeded(coordinator);
    10111017}
    10121018
  • trunk/Source/WebCore/platform/graphics/texmap/coordinated/CoordinatedGraphicsLayer.h

    r235314 r235953  
    6464
    6565    // Reimplementations from GraphicsLayer.h.
    66     bool setChildren(const Vector<GraphicsLayer*>&) override;
    67     void addChild(GraphicsLayer*) override;
    68     void addChildAtIndex(GraphicsLayer*, int) override;
    69     void addChildAbove(GraphicsLayer*, GraphicsLayer*) override;
    70     void addChildBelow(GraphicsLayer*, GraphicsLayer*) override;
    71     bool replaceChild(GraphicsLayer*, GraphicsLayer*) override;
     66    bool setChildren(Vector<Ref<GraphicsLayer>>&&) override;
     67    void addChild(Ref<GraphicsLayer>&&) override;
     68    void addChildAtIndex(Ref<GraphicsLayer>&&, int) override;
     69    void addChildAbove(Ref<GraphicsLayer>&&, GraphicsLayer*) override;
     70    void addChildBelow(Ref<GraphicsLayer>&&, GraphicsLayer*) override;
     71    bool replaceChild(GraphicsLayer*, Ref<GraphicsLayer>&&) override;
    7272    void removeFromParent() override;
    7373    void setPosition(const FloatPoint&) override;
     
    9292    bool shouldDirectlyCompositeImage(Image*) const override;
    9393    void setContentsToPlatformLayer(PlatformLayer*, ContentsLayerPurpose) override;
    94     void setMaskLayer(GraphicsLayer*) override;
     94    void setMaskLayer(RefPtr<GraphicsLayer>&&) override;
    9595    void setReplicatedByLayer(GraphicsLayer*) override;
    9696    void setNeedsDisplay() override;
  • trunk/Source/WebCore/platform/graphics/win/GraphicsLayerDirect2D.cpp

    r229209 r235953  
    4747namespace WebCore {
    4848
    49 
    50 std::unique_ptr<GraphicsLayer> GraphicsLayer::create(GraphicsLayerFactory* factory, GraphicsLayerClient& client, Type layerType)
     49Ref<GraphicsLayer> GraphicsLayer::create(GraphicsLayerFactory* factory, GraphicsLayerClient& client, Type layerType)
    5150{
    52     std::unique_ptr<GraphicsLayer> graphicsLayer;
    53     if (!factory)
    54         graphicsLayer = std::make_unique<GraphicsLayerDirect2D>(layerType, client);
    55     else
    56         graphicsLayer = factory->createGraphicsLayer(layerType, client);
    57 
    58     graphicsLayer->initialize(layerType);
    59 
    60     return graphicsLayer;
     51    if (factory) {
     52        auto layer = factory->createGraphicsLayer(layerType, client);
     53        layer->initialize(layerType);
     54        return layer;
     55    }
     56   
     57    auto layer = adoptRef(*new GraphicsLayerCA(layerType, client);
     58    layer->initialize(layerType);
     59    return layer;
    6160}
    6261
  • trunk/Source/WebCore/rendering/RenderLayerBacking.cpp

    r235586 r235953  
    255255}
    256256
    257 std::unique_ptr<GraphicsLayer> RenderLayerBacking::createGraphicsLayer(const String& name, GraphicsLayer::Type layerType)
     257Ref<GraphicsLayer> RenderLayerBacking::createGraphicsLayer(const String& name, GraphicsLayer::Type layerType)
    258258{
    259259    auto* graphicsLayerFactory = renderer().page().chrome().client().graphicsLayerFactory();
    260260
    261     std::unique_ptr<GraphicsLayer> graphicsLayer = GraphicsLayer::create(graphicsLayerFactory, *this, layerType);
     261    auto graphicsLayer = GraphicsLayer::create(graphicsLayerFactory, *this, layerType);
    262262
    263263    graphicsLayer->setName(name);
     
    402402    if (m_isFrameLayerWithTiledBacking) {
    403403        m_childContainmentLayer = createGraphicsLayer("Page TiledBacking containment");
    404         m_graphicsLayer->addChild(m_childContainmentLayer.get());
     404        m_graphicsLayer->addChild(*m_childContainmentLayer);
    405405    }
    406406
     
    710710    if (auto* flatteningLayer = tileCacheFlatteningLayer()) {
    711711        if (layerConfigChanged || flatteningLayer->parent() != m_graphicsLayer.get())
    712             m_graphicsLayer->addChild(flatteningLayer);
     712            m_graphicsLayer->addChild(*flatteningLayer);
    713713    }
    714714
     
    13031303        m_contentsContainmentLayer->removeAllChildren();
    13041304        if (m_ancestorClippingLayer)
    1305             m_ancestorClippingLayer->addChild(m_contentsContainmentLayer.get());
     1305            m_ancestorClippingLayer->addChild(*m_contentsContainmentLayer);
    13061306    }
    13071307   
    13081308    if (m_backgroundLayer)
    1309         m_contentsContainmentLayer->addChild(m_backgroundLayer.get());
     1309        m_contentsContainmentLayer->addChild(*m_backgroundLayer);
    13101310
    13111311    if (m_contentsContainmentLayer)
    1312         m_contentsContainmentLayer->addChild(m_graphicsLayer.get());
     1312        m_contentsContainmentLayer->addChild(*m_graphicsLayer);
    13131313    else if (m_ancestorClippingLayer)
    1314         m_ancestorClippingLayer->addChild(m_graphicsLayer.get());
     1314        m_ancestorClippingLayer->addChild(*m_graphicsLayer);
    13151315
    13161316    if (m_childContainmentLayer) {
    13171317        m_childContainmentLayer->removeFromParent();
    1318         m_graphicsLayer->addChild(m_childContainmentLayer.get());
     1318        m_graphicsLayer->addChild(*m_childContainmentLayer);
    13191319    }
    13201320
     
    13221322        auto* superlayer = m_childContainmentLayer ? m_childContainmentLayer.get() : m_graphicsLayer.get();
    13231323        m_scrollingLayer->removeFromParent();
    1324         superlayer->addChild(m_scrollingLayer.get());
     1324        superlayer->addChild(*m_scrollingLayer);
    13251325    }
    13261326
     
    13301330    if (m_layerForHorizontalScrollbar) {
    13311331        m_layerForHorizontalScrollbar->removeFromParent();
    1332         m_graphicsLayer->addChild(m_layerForHorizontalScrollbar.get());
     1332        m_graphicsLayer->addChild(*m_layerForHorizontalScrollbar);
    13331333    }
    13341334    if (m_layerForVerticalScrollbar) {
    13351335        m_layerForVerticalScrollbar->removeFromParent();
    1336         m_graphicsLayer->addChild(m_layerForVerticalScrollbar.get());
     1336        m_graphicsLayer->addChild(*m_layerForVerticalScrollbar);
    13371337    }
    13381338    if (m_layerForScrollCorner) {
    13391339        m_layerForScrollCorner->removeFromParent();
    1340         m_graphicsLayer->addChild(m_layerForScrollCorner.get());
     1340        m_graphicsLayer->addChild(*m_layerForScrollCorner);
    13411341    }
    13421342}
     
    16911691            m_maskLayer->setPaintingPhase(maskPhases);
    16921692            layerChanged = true;
    1693             m_graphicsLayer->setMaskLayer(m_maskLayer.get());
     1693            m_graphicsLayer->setMaskLayer(m_maskLayer.copyRef());
    16941694        }
    16951695    } else if (m_maskLayer) {
     
    17221722                m_childClippingMaskLayer->setDrawsContent(true);
    17231723                m_childClippingMaskLayer->setPaintingPhase(GraphicsLayerPaintChildClippingMask);
    1724                 clippingLayer()->setMaskLayer(m_childClippingMaskLayer.get());
     1724                clippingLayer()->setMaskLayer(m_childClippingMaskLayer.copyRef());
    17251725            }
    17261726        }
     
    17551755            paintPhase |= GraphicsLayerPaintForeground;
    17561756        m_scrollingContentsLayer->setPaintingPhase(paintPhase);
    1757         m_scrollingLayer->addChild(m_scrollingContentsLayer.get());
     1757        m_scrollingLayer->addChild(*m_scrollingContentsLayer);
    17581758    } else {
    17591759        compositor().willRemoveScrollingLayerWithBacking(m_owningLayer, *this);
  • trunk/Source/WebCore/rendering/RenderLayerBacking.h

    r234768 r235953  
    137137    void setIsScrollCoordinatedWithViewportConstrainedRole(bool);
    138138
    139     bool hasMaskLayer() const { return m_maskLayer != 0; }
     139    bool hasMaskLayer() const { return m_maskLayer; }
    140140    bool hasChildClippingMaskLayer() const { return m_childClippingMaskLayer != nullptr; }
    141141
     
    268268    LayoutRect compositedBoundsIncludingMargin() const;
    269269   
    270     std::unique_ptr<GraphicsLayer> createGraphicsLayer(const String&, GraphicsLayer::Type = GraphicsLayer::Type::Normal);
     270    Ref<GraphicsLayer> createGraphicsLayer(const String&, GraphicsLayer::Type = GraphicsLayer::Type::Normal);
    271271
    272272    RenderLayerModelObject& renderer() const { return m_owningLayer.renderer(); }
     
    356356    RenderLayer& m_owningLayer;
    357357
    358     std::unique_ptr<GraphicsLayer> m_ancestorClippingLayer; // Only used if we are clipped by an ancestor which is not a stacking context.
    359     std::unique_ptr<GraphicsLayer> m_contentsContainmentLayer; // Only used if we have a background layer; takes the transform.
    360     std::unique_ptr<GraphicsLayer> m_graphicsLayer;
    361     std::unique_ptr<GraphicsLayer> m_foregroundLayer; // Only used in cases where we need to draw the foreground separately.
    362     std::unique_ptr<GraphicsLayer> m_backgroundLayer; // Only used in cases where we need to draw the background separately.
    363     std::unique_ptr<GraphicsLayer> m_childContainmentLayer; // Only used if we have clipping on a stacking context with compositing children, or if the layer has a tile cache.
    364     std::unique_ptr<GraphicsLayer> m_maskLayer; // Only used if we have a mask and/or clip-path.
    365     std::unique_ptr<GraphicsLayer> m_childClippingMaskLayer; // Only used if we have to clip child layers or accelerated contents with border radius or clip-path.
    366 
    367     std::unique_ptr<GraphicsLayer> m_layerForHorizontalScrollbar;
    368     std::unique_ptr<GraphicsLayer> m_layerForVerticalScrollbar;
    369     std::unique_ptr<GraphicsLayer> m_layerForScrollCorner;
    370 
    371     std::unique_ptr<GraphicsLayer> m_scrollingLayer; // Only used if the layer is using composited scrolling.
    372     std::unique_ptr<GraphicsLayer> m_scrollingContentsLayer; // Only used if the layer is using composited scrolling.
     358    RefPtr<GraphicsLayer> m_ancestorClippingLayer; // Only used if we are clipped by an ancestor which is not a stacking context.
     359    RefPtr<GraphicsLayer> m_contentsContainmentLayer; // Only used if we have a background layer; takes the transform.
     360    RefPtr<GraphicsLayer> m_graphicsLayer;
     361    RefPtr<GraphicsLayer> m_foregroundLayer; // Only used in cases where we need to draw the foreground separately.
     362    RefPtr<GraphicsLayer> m_backgroundLayer; // Only used in cases where we need to draw the background separately.
     363    RefPtr<GraphicsLayer> m_childContainmentLayer; // Only used if we have clipping on a stacking context with compositing children, or if the layer has a tile cache.
     364    RefPtr<GraphicsLayer> m_maskLayer; // Only used if we have a mask and/or clip-path.
     365    RefPtr<GraphicsLayer> m_childClippingMaskLayer; // Only used if we have to clip child layers or accelerated contents with border radius or clip-path.
     366
     367    RefPtr<GraphicsLayer> m_layerForHorizontalScrollbar;
     368    RefPtr<GraphicsLayer> m_layerForVerticalScrollbar;
     369    RefPtr<GraphicsLayer> m_layerForScrollCorner;
     370
     371    RefPtr<GraphicsLayer> m_scrollingLayer; // Only used if the layer is using composited scrolling.
     372    RefPtr<GraphicsLayer> m_scrollingContentsLayer; // Only used if the layer is using composited scrolling.
    373373
    374374    LayoutRect m_compositedBounds;
  • trunk/Source/WebCore/rendering/RenderLayerCompositor.cpp

    r235560 r235953  
    759759    if (needHierarchyUpdate) {
    760760        // Update the hierarchy of the compositing layers.
    761         Vector<GraphicsLayer*> childList;
     761        Vector<Ref<GraphicsLayer>> childList;
    762762        rebuildCompositingLayerTree(*updateRoot, childList, 0);
    763763
     
    770770                destroyRootLayer();
    771771            else if (m_rootContentLayer)
    772                 m_rootContentLayer->setChildren(childList);
     772                m_rootContentLayer->setChildren(WTFMove(childList));
    773773        }
    774774       
     
    803803}
    804804
    805 void RenderLayerCompositor::appendDocumentOverlayLayers(Vector<GraphicsLayer*>& childList)
     805void RenderLayerCompositor::appendDocumentOverlayLayers(Vector<Ref<GraphicsLayer>>& childList)
    806806{
    807807    if (!isMainFrameCompositor() || !m_compositing)
    808808        return;
    809809
    810     childList.append(&page().pageOverlayController().layerWithDocumentOverlays());
     810    Ref<GraphicsLayer> overlayHost = page().pageOverlayController().layerWithDocumentOverlays();
     811    childList.append(WTFMove(overlayHost));
    811812}
    812813
     
    15241525        auto* hostedLayer = childLayer.backing()->childForSuperlayers();
    15251526       
    1526         hostingLayer->addChild(hostedLayer);
     1527        hostingLayer->addChild(*hostedLayer);
    15271528    } else
    15281529        childLayer.backing()->childForSuperlayers()->removeFromParent();
     
    15461547#endif
    15471548
    1548 void RenderLayerCompositor::rebuildCompositingLayerTree(RenderLayer& layer, Vector<GraphicsLayer*>& childLayersOfEnclosingLayer, int depth)
     1549void RenderLayerCompositor::rebuildCompositingLayerTree(RenderLayer& layer, Vector<Ref<GraphicsLayer>>& childLayersOfEnclosingLayer, int depth)
    15491550{
    15501551    // Make the layer compositing if necessary, and set up clipping and content layers.
     
    15821583    // If this layer has backing, then we are collecting its children, otherwise appending
    15831584    // to the compositing child list of an enclosing layer.
    1584     Vector<GraphicsLayer*> layerChildren;
    1585     Vector<GraphicsLayer*>& childList = layerBacking ? layerChildren : childLayersOfEnclosingLayer;
     1585    Vector<Ref<GraphicsLayer>> layerChildren;
     1586    auto& childList = layerBacking ? layerChildren : childLayersOfEnclosingLayer;
    15861587
    15871588#if !ASSERT_DISABLED
     
    15951596        // If a negative z-order child is compositing, we get a foreground layer which needs to get parented.
    15961597        if (layerBacking && layerBacking->foregroundLayer())
    1597             childList.append(layerBacking->foregroundLayer());
     1598            childList.append(*layerBacking->foregroundLayer());
    15981599    }
    15991600
     
    16141615
    16151616        if (!parented)
    1616             layerBacking->parentForSublayers()->setChildren(layerChildren);
     1617            layerBacking->parentForSublayers()->setChildren(WTFMove(layerChildren));
    16171618
    16181619        // If the layer has a clipping layer the overflow controls layers will be siblings of the clipping layer.
     
    16211622            if (auto* overflowControlLayer = layerBacking->layerForHorizontalScrollbar()) {
    16221623                overflowControlLayer->removeFromParent();
    1623                 layerBacking->parentForSublayers()->addChild(overflowControlLayer);
     1624                layerBacking->parentForSublayers()->addChild(*overflowControlLayer);
    16241625            }
    16251626
    16261627            if (auto* overflowControlLayer = layerBacking->layerForVerticalScrollbar()) {
    16271628                overflowControlLayer->removeFromParent();
    1628                 layerBacking->parentForSublayers()->addChild(overflowControlLayer);
     1629                layerBacking->parentForSublayers()->addChild(*overflowControlLayer);
    16291630            }
    16301631
    16311632            if (auto* overflowControlLayer = layerBacking->layerForScrollCorner()) {
    16321633                overflowControlLayer->removeFromParent();
    1633                 layerBacking->parentForSublayers()->addChild(overflowControlLayer);
     1634                layerBacking->parentForSublayers()->addChild(*overflowControlLayer);
    16341635            }
    16351636        }
    16361637
    1637         childLayersOfEnclosingLayer.append(layerBacking->childForSuperlayers());
     1638        childLayersOfEnclosingLayer.append(*layerBacking->childForSuperlayers());
    16381639    }
    16391640   
     
    18101811    auto* hostingLayer = backing->parentForSublayers();
    18111812    auto* rootLayer = innerCompositor->rootGraphicsLayer();
    1812     if (hostingLayer->children().size() != 1 || hostingLayer->children()[0] != rootLayer) {
     1813    if (hostingLayer->children().size() != 1 || hostingLayer->children()[0].ptr() != rootLayer) {
    18131814        hostingLayer->removeAllChildren();
    1814         hostingLayer->addChild(rootLayer);
     1815        hostingLayer->addChild(*rootLayer);
    18151816    }
    18161817    return true;
     
    30473048        m_layerForTopOverhangArea = GraphicsLayer::create(graphicsLayerFactory(), *this);
    30483049        m_layerForTopOverhangArea->setName("top overhang");
    3049         m_scrollLayer->addChildBelow(m_layerForTopOverhangArea.get(), m_rootContentLayer.get());
     3050        m_scrollLayer->addChildBelow(*m_layerForTopOverhangArea, m_rootContentLayer.get());
    30503051    }
    30513052
     
    30693070        m_layerForBottomOverhangArea = GraphicsLayer::create(graphicsLayerFactory(), *this);
    30703071        m_layerForBottomOverhangArea->setName("bottom overhang");
    3071         m_scrollLayer->addChildBelow(m_layerForBottomOverhangArea.get(), m_rootContentLayer.get());
     3072        m_scrollLayer->addChildBelow(*m_layerForBottomOverhangArea, m_rootContentLayer.get());
    30723073    }
    30733074
     
    30983099        m_layerForHeader = GraphicsLayer::create(graphicsLayerFactory(), *this);
    30993100        m_layerForHeader->setName("header");
    3100         m_scrollLayer->addChildAbove(m_layerForHeader.get(), m_rootContentLayer.get());
     3101        m_scrollLayer->addChildAbove(*m_layerForHeader, m_rootContentLayer.get());
    31013102        m_renderView.frameView().addPaintPendingMilestones(DidFirstFlushForHeaderLayer);
    31023103    }
     
    31363137        m_layerForFooter = GraphicsLayer::create(graphicsLayerFactory(), *this);
    31373138        m_layerForFooter->setName("footer");
    3138         m_scrollLayer->addChildAbove(m_layerForFooter.get(), m_rootContentLayer.get());
     3139        m_scrollLayer->addChildAbove(*m_layerForFooter, m_rootContentLayer.get());
    31393140    }
    31403141
     
    32593260            // We want the overhang areas layer to be positioned below the frame contents,
    32603261            // so insert it below the clip layer.
    3261             m_overflowControlsHostLayer->addChildBelow(m_layerForOverhangAreas.get(), m_clipLayer.get());
     3262            m_overflowControlsHostLayer->addChildBelow(*m_layerForOverhangAreas, m_clipLayer.get());
    32623263        }
    32633264    } else if (m_layerForOverhangAreas) {
     
    32753276            m_contentShadowLayer->setCustomAppearance(GraphicsLayer::CustomAppearance::ScrollingShadow);
    32763277
    3277             m_scrollLayer->addChildBelow(m_contentShadowLayer.get(), m_rootContentLayer.get());
     3278            m_scrollLayer->addChildBelow(*m_contentShadowLayer, m_rootContentLayer.get());
    32783279        }
    32793280    } else if (m_contentShadowLayer) {
     
    32923293            m_layerForHorizontalScrollbar->setAcceleratesDrawing(acceleratedDrawingEnabled());
    32933294#endif
    3294             m_overflowControlsHostLayer->addChild(m_layerForHorizontalScrollbar.get());
     3295            m_overflowControlsHostLayer->addChild(*m_layerForHorizontalScrollbar);
    32953296
    32963297            if (auto* scrollingCoordinator = this->scrollingCoordinator())
     
    33143315            m_layerForVerticalScrollbar->setAcceleratesDrawing(acceleratedDrawingEnabled());
    33153316#endif
    3316             m_overflowControlsHostLayer->addChild(m_layerForVerticalScrollbar.get());
     3317            m_overflowControlsHostLayer->addChild(*m_layerForVerticalScrollbar);
    33173318
    33183319            if (auto* scrollingCoordinator = this->scrollingCoordinator())
     
    33363337            m_layerForScrollCorner->setAcceleratesDrawing(acceleratedDrawingEnabled());
    33373338#endif
    3338             m_overflowControlsHostLayer->addChild(m_layerForScrollCorner.get());
     3339            m_overflowControlsHostLayer->addChild(*m_layerForScrollCorner);
    33393340        }
    33403341    } else if (m_layerForScrollCorner) {
     
    33883389
    33893390            // Hook them up
    3390             m_overflowControlsHostLayer->addChild(m_clipLayer.get());
    3391             m_clipLayer->addChild(m_scrollLayer.get());
    3392             m_scrollLayer->addChild(m_rootContentLayer.get());
     3391            m_overflowControlsHostLayer->addChild(*m_clipLayer);
     3392            m_clipLayer->addChild(*m_scrollLayer);
     3393            m_scrollLayer->addChild(*m_rootContentLayer);
    33933394
    33943395            m_clipLayer->setSize(m_renderView.frameView().sizeForVisibleContent());
     
    35613562        return;
    35623563
    3563     m_rootContentLayer->addChild(&page().pageOverlayController().layerWithDocumentOverlays());
     3564    Ref<GraphicsLayer> overlayHost = page().pageOverlayController().layerWithDocumentOverlays();
     3565    m_rootContentLayer->addChild(WTFMove(overlayHost));
    35643566}
    35653567
  • trunk/Source/WebCore/rendering/RenderLayerCompositor.h

    r234768 r235953  
    377377
    378378    // Recurses down the tree, parenting descendant compositing layers and collecting an array of child layers for the current compositing layer.
    379     void rebuildCompositingLayerTree(RenderLayer&, Vector<GraphicsLayer*>& childGraphicsLayersOfEnclosingLayer, int depth);
     379    void rebuildCompositingLayerTree(RenderLayer&, Vector<Ref<GraphicsLayer>>& childGraphicsLayersOfEnclosingLayer, int depth);
    380380
    381381    // Recurses down the tree, updating layer geometry only.
     
    389389    bool isRunningTransformAnimation(RenderLayerModelObject&) const;
    390390
    391     void appendDocumentOverlayLayers(Vector<GraphicsLayer*>&);
     391    void appendDocumentOverlayLayers(Vector<Ref<GraphicsLayer>>&);
    392392    bool hasAnyAdditionalCompositedLayers(const RenderLayer& rootLayer) const;
    393393
     
    489489private:
    490490    RenderView& m_renderView;
    491     std::unique_ptr<GraphicsLayer> m_rootContentLayer;
     491    RefPtr<GraphicsLayer> m_rootContentLayer;
    492492    Timer m_updateCompositingLayersTimer;
    493493
     
    525525
    526526    // Enclosing clipping layer for iframe content
    527     std::unique_ptr<GraphicsLayer> m_clipLayer;
    528     std::unique_ptr<GraphicsLayer> m_scrollLayer;
     527    RefPtr<GraphicsLayer> m_clipLayer;
     528    RefPtr<GraphicsLayer> m_scrollLayer;
    529529
    530530#if PLATFORM(IOS)
     
    536536
    537537    // Enclosing layer for overflow controls and the clipping layer
    538     std::unique_ptr<GraphicsLayer> m_overflowControlsHostLayer;
     538    RefPtr<GraphicsLayer> m_overflowControlsHostLayer;
    539539
    540540    // Layers for overflow controls
    541     std::unique_ptr<GraphicsLayer> m_layerForHorizontalScrollbar;
    542     std::unique_ptr<GraphicsLayer> m_layerForVerticalScrollbar;
    543     std::unique_ptr<GraphicsLayer> m_layerForScrollCorner;
     541    RefPtr<GraphicsLayer> m_layerForHorizontalScrollbar;
     542    RefPtr<GraphicsLayer> m_layerForVerticalScrollbar;
     543    RefPtr<GraphicsLayer> m_layerForScrollCorner;
    544544#if ENABLE(RUBBER_BANDING)
    545     std::unique_ptr<GraphicsLayer> m_layerForOverhangAreas;
    546     std::unique_ptr<GraphicsLayer> m_contentShadowLayer;
    547     std::unique_ptr<GraphicsLayer> m_layerForTopOverhangArea;
    548     std::unique_ptr<GraphicsLayer> m_layerForBottomOverhangArea;
    549     std::unique_ptr<GraphicsLayer> m_layerForHeader;
    550     std::unique_ptr<GraphicsLayer> m_layerForFooter;
     545    RefPtr<GraphicsLayer> m_layerForOverhangAreas;
     546    RefPtr<GraphicsLayer> m_contentShadowLayer;
     547    RefPtr<GraphicsLayer> m_layerForTopOverhangArea;
     548    RefPtr<GraphicsLayer> m_layerForBottomOverhangArea;
     549    RefPtr<GraphicsLayer> m_layerForHeader;
     550    RefPtr<GraphicsLayer> m_layerForFooter;
    551551#endif
    552552
  • trunk/Source/WebKit/ChangeLog

    r235952 r235953  
     12018-09-11  Simon Fraser  <simon.fraser@apple.com>
     2
     3        Make GraphicsLayers ref-counted, so their tree can persist when disconnected from RenderLayerBackings
     4        https://bugs.webkit.org/show_bug.cgi?id=189521
     5
     6        Reviewed by Tim Horton.
     7
     8        Make GraphicsLayer be RefCounted<GraphicsLayer>. GraphicsLayers own their children, via a Vector<Ref<GraphicsLayer>>.
     9       
     10        RenderLayerBacking and other holders of GraphicsLayers use RefPtr<GraphicsLayer>.
     11       
     12        All the other changes are just to adapt to the new ownership patterns.
     13       
     14        I verified that no GraphicsLayers were leaked or abandoned after this change.
     15
     16        * WebProcess/WebCoreSupport/WebInspectorClient.cpp:
     17        (WebKit::WebInspectorClient::~WebInspectorClient):
     18        (WebKit::WebInspectorClient::showPaintRect):
     19        (WebKit::WebInspectorClient::animationEndedForLayer):
     20        * WebProcess/WebCoreSupport/WebInspectorClient.h:
     21        * WebProcess/WebPage/RemoteLayerTree/RemoteLayerTreeContext.h:
     22        * WebProcess/WebPage/RemoteLayerTree/RemoteLayerTreeContext.mm:
     23        (WebKit::RemoteLayerTreeContext::createGraphicsLayer):
     24        * WebProcess/WebPage/RemoteLayerTree/RemoteLayerTreeDrawingArea.h:
     25        * WebProcess/WebPage/RemoteLayerTree/RemoteLayerTreeDrawingArea.mm:
     26        (WebKit::RemoteLayerTreeDrawingArea::updateRootLayers):
     27        (WebKit::RemoteLayerTreeDrawingArea::flushLayers):
     28
    1292018-09-12  Chris Dumez  <cdumez@apple.com>
    230
  • trunk/Source/WebKit/WebProcess/WebCoreSupport/WebInspectorClient.cpp

    r235205 r235953  
    6767WebInspectorClient::~WebInspectorClient()
    6868{
    69     for (auto layer : m_paintRectLayers) {
     69    for (auto& layer : m_paintRectLayers)
    7070        layer->removeFromParent();
    71         delete layer;
    72     }
     71   
     72    m_paintRectLayers.clear();
    7373
    7474    if (m_paintRectOverlay && m_page->corePage())
     
    153153        m_paintIndicatorLayerClient = std::make_unique<RepaintIndicatorLayerClient>(*this);
    154154
    155     std::unique_ptr<GraphicsLayer> paintLayer = GraphicsLayer::create(m_page->drawingArea()->graphicsLayerFactory(), *m_paintIndicatorLayerClient);
     155    auto paintLayer = GraphicsLayer::create(m_page->drawingArea()->graphicsLayerFactory(), *m_paintIndicatorLayerClient);
    156156   
    157157    paintLayer->setName("paint rect");
     
    166166    fadeKeyframes.insert(std::make_unique<FloatAnimationValue>(0.25, 0));
    167167   
    168     RefPtr<Animation> opacityAnimation = Animation::create();
     168    auto opacityAnimation = Animation::create();
    169169    opacityAnimation->setDuration(0.25);
    170170
    171     paintLayer->addAnimation(fadeKeyframes, FloatSize(), opacityAnimation.get(), "opacity"_s, 0);
    172    
    173     m_paintRectLayers.add(paintLayer.get());
     171    paintLayer->addAnimation(fadeKeyframes, FloatSize(), opacityAnimation.ptr(), "opacity"_s, 0);
     172   
     173    GraphicsLayer& rawLayer = paintLayer.get();
     174    m_paintRectLayers.add(WTFMove(paintLayer));
    174175
    175176    GraphicsLayer& overlayRootLayer = m_paintRectOverlay->layer();
    176     overlayRootLayer.addChild(paintLayer.release());
     177    overlayRootLayer.addChild(rawLayer);
    177178}
    178179
    179180void WebInspectorClient::animationEndedForLayer(const GraphicsLayer* layer)
    180181{
    181     const_cast<GraphicsLayer*>(layer)->removeFromParent();
    182     m_paintRectLayers.remove(const_cast<GraphicsLayer*>(layer));
    183     delete layer;
     182    GraphicsLayer* nonConstLayer = const_cast<GraphicsLayer*>(layer);
     183    nonConstLayer->removeFromParent();
     184    m_paintRectLayers.remove(*nonConstLayer);
    184185}
    185186
  • trunk/Source/WebKit/WebProcess/WebCoreSupport/WebInspectorClient.h

    r231439 r235953  
    8585    RefPtr<WebCore::PageOverlay> m_paintRectOverlay;
    8686    std::unique_ptr<RepaintIndicatorLayerClient> m_paintIndicatorLayerClient;
    87     HashSet<WebCore::GraphicsLayer*> m_paintRectLayers; // Ideally this would be HashSet<std::unique_ptr<GraphicsLayer>> but that doesn't work yet. webkit.org/b/136166
     87    HashSet<Ref<WebCore::GraphicsLayer>> m_paintRectLayers;
    8888};
    8989
  • trunk/Source/WebKit/WebProcess/WebPage/CoordinatedGraphics/CompositingCoordinator.cpp

    r235221 r235953  
    8686    m_rootCompositingLayer = graphicsLayer;
    8787    if (m_rootCompositingLayer)
    88         m_rootLayer->addChildAtIndex(m_rootCompositingLayer, 0);
     88        m_rootLayer->addChildAtIndex(*m_rootCompositingLayer, 0);
    8989}
    9090
     
    9999    m_overlayCompositingLayer = graphicsLayer;
    100100    if (m_overlayCompositingLayer)
    101         m_rootLayer->addChild(m_overlayCompositingLayer);
     101        m_rootLayer->addChild(*m_overlayCompositingLayer);
    102102}
    103103
     
    232232}
    233233
    234 std::unique_ptr<GraphicsLayer> CompositingCoordinator::createGraphicsLayer(GraphicsLayer::Type layerType, GraphicsLayerClient& client)
    235 {
    236     CoordinatedGraphicsLayer* layer = new CoordinatedGraphicsLayer(layerType, client);
     234Ref<GraphicsLayer> CompositingCoordinator::createGraphicsLayer(GraphicsLayer::Type layerType, GraphicsLayerClient& client)
     235{
     236    auto layer = adoptRef(*new CoordinatedGraphicsLayer(layerType, client));
    237237    layer->setCoordinator(this);
    238238    m_nicosia.state.layers.add(layer->compositionLayer());
    239     m_registeredLayers.add(layer->id(), layer);
     239    m_registeredLayers.add(layer->id(), layer.ptr());
    240240    layer->setNeedsVisibleRectAdjustment();
    241     notifyFlushRequired(layer);
    242     return std::unique_ptr<GraphicsLayer>(layer);
     241    notifyFlushRequired(layer.ptr());
     242    return WTFMove(layer);
    243243}
    244244
  • trunk/Source/WebKit/WebProcess/WebPage/CoordinatedGraphics/CompositingCoordinator.h

    r235221 r235953  
    104104
    105105    // GraphicsLayerFactory
    106     std::unique_ptr<WebCore::GraphicsLayer> createGraphicsLayer(WebCore::GraphicsLayer::Type, WebCore::GraphicsLayerClient&) override;
     106    Ref<WebCore::GraphicsLayer> createGraphicsLayer(WebCore::GraphicsLayer::Type, WebCore::GraphicsLayerClient&) override;
    107107
    108108    void initializeRootCompositingLayerIfNeeded();
     
    115115    CompositingCoordinator::Client& m_client;
    116116
    117     std::unique_ptr<WebCore::GraphicsLayer> m_rootLayer;
     117    RefPtr<WebCore::GraphicsLayer> m_rootLayer;
    118118    WebCore::GraphicsLayer* m_rootCompositingLayer { nullptr };
    119119    WebCore::GraphicsLayer* m_overlayCompositingLayer { nullptr };
  • trunk/Source/WebKit/WebProcess/WebPage/RemoteLayerTree/RemoteLayerTreeContext.h

    r229174 r235953  
    7575private:
    7676    // WebCore::GraphicsLayerFactory
    77     std::unique_ptr<WebCore::GraphicsLayer> createGraphicsLayer(WebCore::GraphicsLayer::Type, WebCore::GraphicsLayerClient&) override;
     77    Ref<WebCore::GraphicsLayer> createGraphicsLayer(WebCore::GraphicsLayer::Type, WebCore::GraphicsLayerClient&) override;
    7878
    7979    WebPage& m_webPage;
  • trunk/Source/WebKit/WebProcess/WebPage/RemoteLayerTree/RemoteLayerTreeContext.mm

    r235205 r235953  
    110110}
    111111
    112 std::unique_ptr<GraphicsLayer> RemoteLayerTreeContext::createGraphicsLayer(WebCore::GraphicsLayer::Type layerType, GraphicsLayerClient& client)
     112Ref<GraphicsLayer> RemoteLayerTreeContext::createGraphicsLayer(WebCore::GraphicsLayer::Type layerType, GraphicsLayerClient& client)
    113113{
    114     return std::make_unique<GraphicsLayerCARemote>(layerType, client, *this);
     114    return adoptRef(*new GraphicsLayerCARemote(layerType, client, *this));
    115115}
    116116
  • trunk/Source/WebKit/WebProcess/WebPage/RemoteLayerTree/RemoteLayerTreeDrawingArea.h

    r234920 r235953  
    138138
    139139    std::unique_ptr<RemoteLayerTreeContext> m_remoteLayerTreeContext;
    140     std::unique_ptr<WebCore::GraphicsLayer> m_rootLayer;
     140    Ref<WebCore::GraphicsLayer> m_rootLayer;
    141141
    142142    WebCore::IntSize m_viewSize;
  • trunk/Source/WebKit/WebProcess/WebPage/RemoteLayerTree/RemoteLayerTreeDrawingArea.mm

    r235205 r235953  
    116116void RemoteLayerTreeDrawingArea::updateRootLayers()
    117117{
    118     Vector<GraphicsLayer*> children;
     118    Vector<Ref<GraphicsLayer>> children;
    119119    if (m_contentLayer) {
    120         children.append(m_contentLayer);
     120        children.append(*m_contentLayer);
    121121        if (m_viewOverlayRootLayer)
    122             children.append(m_viewOverlayRootLayer);
    123     }
    124 
    125     m_rootLayer->setChildren(children);
     122            children.append(*m_viewOverlayRootLayer);
     123    }
     124
     125    m_rootLayer->setChildren(WTFMove(children));
    126126}
    127127
     
    319319void RemoteLayerTreeDrawingArea::flushLayers()
    320320{
    321     if (!m_rootLayer)
    322         return;
    323 
    324321    if (m_isFlushingSuspended) {
    325322        m_hasDeferredFlush = true;
     
    367364    layerTransaction.setCallbackIDs(WTFMove(m_pendingCallbackIDs));
    368365    m_remoteLayerTreeContext->setNextFlushIsForImmediatePaint(m_nextFlushIsForImmediatePaint);
    369     m_remoteLayerTreeContext->buildTransaction(layerTransaction, *downcast<GraphicsLayerCARemote>(*m_rootLayer).platformCALayer());
     366    m_remoteLayerTreeContext->buildTransaction(layerTransaction, *downcast<GraphicsLayerCARemote>(m_rootLayer.get()).platformCALayer());
    370367    m_remoteLayerTreeContext->setNextFlushIsForImmediatePaint(false);
    371368    backingStoreCollection.willCommitLayerTree(layerTransaction);
  • trunk/Source/WebKitLegacy/win/WebCoreSupport/AcceleratedCompositingContext.cpp

    r230211 r235953  
    9898#endif
    9999
    100     m_rootLayer->addChild(m_nonCompositedContentLayer.get());
     100    m_rootLayer->addChild(*m_nonCompositedContentLayer);
    101101    m_nonCompositedContentLayer->setNeedsDisplay();
    102102
     
    212212
    213213    m_nonCompositedContentLayer->removeAllChildren();
    214     m_nonCompositedContentLayer->addChild(graphicsLayer);
     214    m_nonCompositedContentLayer->addChild(*graphicsLayer);
    215215
    216216    stopAnyPendingLayerFlush();
  • trunk/Source/WebKitLegacy/win/WebCoreSupport/AcceleratedCompositingContext.h

    r219876 r235953  
    7272    std::unique_ptr<WebCore::GLContext> m_context;
    7373    HWND m_window;
    74     std::unique_ptr<WebCore::GraphicsLayer> m_rootLayer;
    75     std::unique_ptr<WebCore::GraphicsLayer> m_nonCompositedContentLayer;
     74    RefPtr<WebCore::GraphicsLayer> m_rootLayer;
     75    RefPtr<WebCore::GraphicsLayer> m_nonCompositedContentLayer;
    7676    std::unique_ptr<WebCore::TextureMapper> m_textureMapper;
    7777    WebCore::TextureMapperFPSCounter m_fpsCounter;
  • trunk/Source/WebKitLegacy/win/WebView.cpp

    r235560 r235953  
    71467146    if (!m_backingLayer)
    71477147        return;
    7148     m_backingLayer->addChild(layer);
     7148
     7149    if (layer)
     7150        m_backingLayer->addChild(*layer);
     7151    else
     7152        m_backingLayer->removeAllChildren();
     7153
    71497154#elif USE(TEXTURE_MAPPER_GL)
    71507155    if (!m_acceleratedCompositingContext)
  • trunk/Source/WebKitLegacy/win/WebView.h

    r229174 r235953  
    706706#if USE(CA)
    707707    RefPtr<WebCore::CACFLayerTreeHost> m_layerTreeHost;
    708     std::unique_ptr<WebCore::GraphicsLayer> m_backingLayer;
     708    RefPtr<WebCore::GraphicsLayer> m_backingLayer;
    709709#elif USE(TEXTURE_MAPPER_GL)
    710710    std::unique_ptr<AcceleratedCompositingContext> m_acceleratedCompositingContext;
Note: See TracChangeset for help on using the changeset viewer.