<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[235953] trunk/Source</title>
</head>
<body>

<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt;  }
#msg dl a { font-weight: bold}
#msg dl a:link    { color:#fc3; }
#msg dl a:active  { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg ul { text-indent: -1em; padding-left: 1em; }#logmsg ol { text-indent: -1.5em; padding-left: 1.5em; }
#logmsg > ul, #logmsg > ol { margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff  {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<dl class="meta">
<dt>Revision</dt> <dd><a href="http://trac.webkit.org/projects/webkit/changeset/235953">235953</a></dd>
<dt>Author</dt> <dd>simon.fraser@apple.com</dd>
<dt>Date</dt> <dd>2018-09-12 14:27:07 -0700 (Wed, 12 Sep 2018)</dd>
</dl>

<h3>Log Message</h3>
<pre>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):</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkSourceWebCoreChangeLog">trunk/Source/WebCore/ChangeLog</a></li>
<li><a href="#trunkSourceWebCorepagePageOverlayControllercpp">trunk/Source/WebCore/page/PageOverlayController.cpp</a></li>
<li><a href="#trunkSourceWebCorepagePageOverlayControllerh">trunk/Source/WebCore/page/PageOverlayController.h</a></li>
<li><a href="#trunkSourceWebCorepageResourceUsageOverlayh">trunk/Source/WebCore/page/ResourceUsageOverlay.h</a></li>
<li><a href="#trunkSourceWebCorepagelinuxResourceUsageOverlayLinuxcpp">trunk/Source/WebCore/page/linux/ResourceUsageOverlayLinux.cpp</a></li>
<li><a href="#trunkSourceWebCorepagemacServicesOverlayControllerh">trunk/Source/WebCore/page/mac/ServicesOverlayController.h</a></li>
<li><a href="#trunkSourceWebCorepagemacServicesOverlayControllermm">trunk/Source/WebCore/page/mac/ServicesOverlayController.mm</a></li>
<li><a href="#trunkSourceWebCoreplatformgraphicsGraphicsLayercpp">trunk/Source/WebCore/platform/graphics/GraphicsLayer.cpp</a></li>
<li><a href="#trunkSourceWebCoreplatformgraphicsGraphicsLayerh">trunk/Source/WebCore/platform/graphics/GraphicsLayer.h</a></li>
<li><a href="#trunkSourceWebCoreplatformgraphicsGraphicsLayerFactoryh">trunk/Source/WebCore/platform/graphics/GraphicsLayerFactory.h</a></li>
<li><a href="#trunkSourceWebCoreplatformgraphicscaGraphicsLayerCAcpp">trunk/Source/WebCore/platform/graphics/ca/GraphicsLayerCA.cpp</a></li>
<li><a href="#trunkSourceWebCoreplatformgraphicscaGraphicsLayerCAh">trunk/Source/WebCore/platform/graphics/ca/GraphicsLayerCA.h</a></li>
<li><a href="#trunkSourceWebCoreplatformgraphicstexmapGraphicsLayerTextureMappercpp">trunk/Source/WebCore/platform/graphics/texmap/GraphicsLayerTextureMapper.cpp</a></li>
<li><a href="#trunkSourceWebCoreplatformgraphicstexmapGraphicsLayerTextureMapperh">trunk/Source/WebCore/platform/graphics/texmap/GraphicsLayerTextureMapper.h</a></li>
<li><a href="#trunkSourceWebCoreplatformgraphicstexmapcoordinatedCoordinatedGraphicsLayercpp">trunk/Source/WebCore/platform/graphics/texmap/coordinated/CoordinatedGraphicsLayer.cpp</a></li>
<li><a href="#trunkSourceWebCoreplatformgraphicstexmapcoordinatedCoordinatedGraphicsLayerh">trunk/Source/WebCore/platform/graphics/texmap/coordinated/CoordinatedGraphicsLayer.h</a></li>
<li><a href="#trunkSourceWebCoreplatformgraphicswinGraphicsLayerDirect2Dcpp">trunk/Source/WebCore/platform/graphics/win/GraphicsLayerDirect2D.cpp</a></li>
<li><a href="#trunkSourceWebCorerenderingRenderLayerBackingcpp">trunk/Source/WebCore/rendering/RenderLayerBacking.cpp</a></li>
<li><a href="#trunkSourceWebCorerenderingRenderLayerBackingh">trunk/Source/WebCore/rendering/RenderLayerBacking.h</a></li>
<li><a href="#trunkSourceWebCorerenderingRenderLayerCompositorcpp">trunk/Source/WebCore/rendering/RenderLayerCompositor.cpp</a></li>
<li><a href="#trunkSourceWebCorerenderingRenderLayerCompositorh">trunk/Source/WebCore/rendering/RenderLayerCompositor.h</a></li>
<li><a href="#trunkSourceWebKitChangeLog">trunk/Source/WebKit/ChangeLog</a></li>
<li><a href="#trunkSourceWebKitWebProcessWebCoreSupportWebInspectorClientcpp">trunk/Source/WebKit/WebProcess/WebCoreSupport/WebInspectorClient.cpp</a></li>
<li><a href="#trunkSourceWebKitWebProcessWebCoreSupportWebInspectorClienth">trunk/Source/WebKit/WebProcess/WebCoreSupport/WebInspectorClient.h</a></li>
<li><a href="#trunkSourceWebKitWebProcessWebPageCoordinatedGraphicsCompositingCoordinatorcpp">trunk/Source/WebKit/WebProcess/WebPage/CoordinatedGraphics/CompositingCoordinator.cpp</a></li>
<li><a href="#trunkSourceWebKitWebProcessWebPageCoordinatedGraphicsCompositingCoordinatorh">trunk/Source/WebKit/WebProcess/WebPage/CoordinatedGraphics/CompositingCoordinator.h</a></li>
<li><a href="#trunkSourceWebKitWebProcessWebPageRemoteLayerTreeRemoteLayerTreeContexth">trunk/Source/WebKit/WebProcess/WebPage/RemoteLayerTree/RemoteLayerTreeContext.h</a></li>
<li><a href="#trunkSourceWebKitWebProcessWebPageRemoteLayerTreeRemoteLayerTreeContextmm">trunk/Source/WebKit/WebProcess/WebPage/RemoteLayerTree/RemoteLayerTreeContext.mm</a></li>
<li><a href="#trunkSourceWebKitWebProcessWebPageRemoteLayerTreeRemoteLayerTreeDrawingAreah">trunk/Source/WebKit/WebProcess/WebPage/RemoteLayerTree/RemoteLayerTreeDrawingArea.h</a></li>
<li><a href="#trunkSourceWebKitWebProcessWebPageRemoteLayerTreeRemoteLayerTreeDrawingAreamm">trunk/Source/WebKit/WebProcess/WebPage/RemoteLayerTree/RemoteLayerTreeDrawingArea.mm</a></li>
<li><a href="#trunkSourceWebKitLegacywinWebCoreSupportAcceleratedCompositingContextcpp">trunk/Source/WebKitLegacy/win/WebCoreSupport/AcceleratedCompositingContext.cpp</a></li>
<li><a href="#trunkSourceWebKitLegacywinWebCoreSupportAcceleratedCompositingContexth">trunk/Source/WebKitLegacy/win/WebCoreSupport/AcceleratedCompositingContext.h</a></li>
<li><a href="#trunkSourceWebKitLegacywinWebViewcpp">trunk/Source/WebKitLegacy/win/WebView.cpp</a></li>
<li><a href="#trunkSourceWebKitLegacywinWebViewh">trunk/Source/WebKitLegacy/win/WebView.h</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkSourceWebCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/ChangeLog (235952 => 235953)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/ChangeLog   2018-09-12 21:23:40 UTC (rev 235952)
+++ trunk/Source/WebCore/ChangeLog      2018-09-12 21:27:07 UTC (rev 235953)
</span><span class="lines">@@ -1,3 +1,135 @@
</span><ins>+2018-09-11  Simon Fraser  <simon.fraser@apple.com>
+
+        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.
+        
+        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:
+
</ins><span class="cx"> 2018-09-12  Alex Christensen  <achristensen@webkit.org>
</span><span class="cx"> 
</span><span class="cx">         Expose fewer of URL's internal members
</span></span></pre></div>
<a id="trunkSourceWebCorepagePageOverlayControllercpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/page/PageOverlayController.cpp (235952 => 235953)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/page/PageOverlayController.cpp      2018-09-12 21:23:40 UTC (rev 235952)
+++ trunk/Source/WebCore/page/PageOverlayController.cpp 2018-09-12 21:27:07 UTC (rev 235953)
</span><span class="lines">@@ -43,8 +43,7 @@
</span><span class="cx"> namespace WebCore {
</span><span class="cx"> 
</span><span class="cx"> PageOverlayController::PageOverlayController(Page& page)
</span><del>-    : m_initialized(false)
-    , m_page(page)
</del><ins>+    :  m_page(page)
</ins><span class="cx"> {
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="lines">@@ -98,14 +97,14 @@
</span><span class="cx">         if (overlay.overlayType() != PageOverlay::OverlayType::Document)
</span><span class="cx">             continue;
</span><span class="cx"> 
</span><del>-        GraphicsLayer& layer = *overlayAndLayer.value;
-        GraphicsLayer::traverse(layer, [inWindow](GraphicsLayer& layer) {
</del><ins>+        auto& layer = overlayAndLayer.value;
+        GraphicsLayer::traverse(layer.get(), [inWindow](GraphicsLayer& layer) {
</ins><span class="cx">             layer.setIsInWindow(inWindow);
</span><span class="cx">         });
</span><del>-        updateOverlayGeometry(overlay, layer);
</del><ins>+        updateOverlayGeometry(overlay, layer.get());
</ins><span class="cx">         
</span><del>-        if (!layer.parent())
-            m_documentOverlayRootLayer->addChild(&layer);
</del><ins>+        if (!layer->parent())
+            m_documentOverlayRootLayer->addChild(layer.copyRef());
</ins><span class="cx">     }
</span><span class="cx"> 
</span><span class="cx">     return *m_documentOverlayRootLayer;
</span><span class="lines">@@ -122,14 +121,14 @@
</span><span class="cx">         if (overlay.overlayType() != PageOverlay::OverlayType::View)
</span><span class="cx">             continue;
</span><span class="cx"> 
</span><del>-        GraphicsLayer& layer = *overlayAndLayer.value;
-        GraphicsLayer::traverse(layer, [inWindow](GraphicsLayer& layer) {
</del><ins>+        auto& layer = overlayAndLayer.value;
+        GraphicsLayer::traverse(layer.get(), [inWindow](GraphicsLayer& layer) {
</ins><span class="cx">             layer.setIsInWindow(inWindow);
</span><span class="cx">         });
</span><del>-        updateOverlayGeometry(overlay, layer);
</del><ins>+        updateOverlayGeometry(overlay, layer.get());
</ins><span class="cx">         
</span><del>-        if (!layer.parent())
-            m_viewOverlayRootLayer->addChild(&layer);
</del><ins>+        if (!layer->parent())
+            m_viewOverlayRootLayer->addChild(layer.copyRef());
</ins><span class="cx">     }
</span><span class="cx"> 
</span><span class="cx">     return *m_viewOverlayRootLayer;
</span><span class="lines">@@ -144,12 +143,12 @@
</span><span class="cx"> 
</span><span class="cx">     m_pageOverlays.append(&overlay);
</span><span class="cx"> 
</span><del>-    std::unique_ptr<GraphicsLayer> layer = GraphicsLayer::create(m_page.chrome().client().graphicsLayerFactory(), *this);
</del><ins>+    auto layer = GraphicsLayer::create(m_page.chrome().client().graphicsLayerFactory(), *this);
</ins><span class="cx">     layer->setAnchorPoint(FloatPoint3D());
</span><span class="cx">     layer->setBackgroundColor(overlay.backgroundColor());
</span><span class="cx">     layer->setName("Overlay content");
</span><span class="cx"> 
</span><del>-    updateSettingsForLayer(*layer);
</del><ins>+    updateSettingsForLayer(layer.get());
</ins><span class="cx"> 
</span><span class="cx">     switch (overlay.overlayType()) {
</span><span class="cx">     case PageOverlay::OverlayType::View:
</span><span class="lines">@@ -160,7 +159,7 @@
</span><span class="cx">         break;
</span><span class="cx">     }
</span><span class="cx"> 
</span><del>-    GraphicsLayer& rawLayer = *layer;
</del><ins>+    auto& rawLayer = layer.get();
</ins><span class="cx">     m_overlayGraphicsLayers.set(&overlay, WTFMove(layer));
</span><span class="cx"> 
</span><span class="cx">     updateForceSynchronousScrollLayerPositionUpdates();
</span><span class="lines">@@ -185,7 +184,8 @@
</span><span class="cx"> 
</span><span class="cx">     overlay.setPage(nullptr);
</span><span class="cx"> 
</span><del>-    m_overlayGraphicsLayers.take(&overlay)->removeFromParent();
</del><ins>+    if (auto optionalLayer = m_overlayGraphicsLayers.take(&overlay))
+        optionalLayer.value()->removeFromParent();
</ins><span class="cx"> 
</span><span class="cx">     bool removed = m_pageOverlays.removeFirst(&overlay);
</span><span class="cx">     ASSERT_UNUSED(removed, removed);
</span><span class="lines">@@ -211,14 +211,14 @@
</span><span class="cx"> void PageOverlayController::setPageOverlayNeedsDisplay(PageOverlay& overlay, const WebCore::IntRect& dirtyRect)
</span><span class="cx"> {
</span><span class="cx">     ASSERT(m_pageOverlays.contains(&overlay));
</span><del>-    GraphicsLayer& graphicsLayer = *m_overlayGraphicsLayers.get(&overlay);
</del><ins>+    auto* graphicsLayer = m_overlayGraphicsLayers.get(&overlay);
</ins><span class="cx"> 
</span><del>-    if (!graphicsLayer.drawsContent()) {
-        graphicsLayer.setDrawsContent(true);
-        updateOverlayGeometry(overlay, graphicsLayer);
</del><ins>+    if (!graphicsLayer->drawsContent()) {
+        graphicsLayer->setDrawsContent(true);
+        updateOverlayGeometry(overlay, *graphicsLayer);
</ins><span class="cx">     }
</span><span class="cx"> 
</span><del>-    graphicsLayer.setNeedsDisplayInRect(dirtyRect);
</del><ins>+    graphicsLayer->setNeedsDisplayInRect(dirtyRect);
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void PageOverlayController::setPageOverlayOpacity(PageOverlay& overlay, float opacity)
</span><span class="lines">@@ -241,8 +241,15 @@
</span><span class="cx"> 
</span><span class="cx"> void PageOverlayController::willDetachRootLayer()
</span><span class="cx"> {
</span><del>-    m_documentOverlayRootLayer = nullptr;
-    m_viewOverlayRootLayer = nullptr;
</del><ins>+    if (m_documentOverlayRootLayer) {
+        m_documentOverlayRootLayer->removeFromParent();
+        m_documentOverlayRootLayer = nullptr;
+    }
+
+    if (m_viewOverlayRootLayer) {
+        m_viewOverlayRootLayer->removeFromParent();
+        m_viewOverlayRootLayer = nullptr;
+    }
</ins><span class="cx">     m_initialized = false;
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="lines">@@ -250,7 +257,7 @@
</span><span class="cx"> {
</span><span class="cx">     for (auto& overlayAndLayer : m_overlayGraphicsLayers) {
</span><span class="cx">         if (overlayAndLayer.key->overlayType() == PageOverlay::OverlayType::View)
</span><del>-            updateOverlayGeometry(*overlayAndLayer.key, *overlayAndLayer.value);
</del><ins>+            updateOverlayGeometry(*overlayAndLayer.key, overlayAndLayer.value.get());
</ins><span class="cx">     }
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="lines">@@ -258,7 +265,7 @@
</span><span class="cx"> {
</span><span class="cx">     for (auto& overlayAndLayer : m_overlayGraphicsLayers) {
</span><span class="cx">         if (overlayAndLayer.key->overlayType() == PageOverlay::OverlayType::Document)
</span><del>-            updateOverlayGeometry(*overlayAndLayer.key, *overlayAndLayer.value);
</del><ins>+            updateOverlayGeometry(*overlayAndLayer.key, overlayAndLayer.value.get());
</ins><span class="cx">     }
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="lines">@@ -266,7 +273,7 @@
</span><span class="cx"> {
</span><span class="cx">     // FIXME: We should apply these settings to all overlay sublayers recursively.
</span><span class="cx">     for (auto& graphicsLayer : m_overlayGraphicsLayers.values())
</span><del>-        updateSettingsForLayer(*graphicsLayer);
</del><ins>+        updateSettingsForLayer(graphicsLayer.get());
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void PageOverlayController::didChangeDeviceScaleFactor()
</span><span class="lines">@@ -359,7 +366,7 @@
</span><span class="cx"> void PageOverlayController::paintContents(const WebCore::GraphicsLayer* graphicsLayer, WebCore::GraphicsContext& graphicsContext, WebCore::GraphicsLayerPaintingPhase, const WebCore::FloatRect& clipRect, GraphicsLayerPaintBehavior)
</span><span class="cx"> {
</span><span class="cx">     for (auto& overlayAndGraphicsLayer : m_overlayGraphicsLayers) {
</span><del>-        if (overlayAndGraphicsLayer.value.get() != graphicsLayer)
</del><ins>+        if (overlayAndGraphicsLayer.value.ptr() != graphicsLayer)
</ins><span class="cx">             continue;
</span><span class="cx"> 
</span><span class="cx">         GraphicsContextStateSaver stateSaver(graphicsContext);
</span><span class="lines">@@ -383,13 +390,15 @@
</span><span class="cx"> void PageOverlayController::didChangeOverlayFrame(PageOverlay& overlay)
</span><span class="cx"> {
</span><span class="cx">     ASSERT(m_pageOverlays.contains(&overlay));
</span><del>-    updateOverlayGeometry(overlay, *m_overlayGraphicsLayers.get(&overlay));
</del><ins>+    if (auto* layer = m_overlayGraphicsLayers.get(&overlay))
+        updateOverlayGeometry(overlay, *layer);
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void PageOverlayController::didChangeOverlayBackgroundColor(PageOverlay& overlay)
</span><span class="cx"> {
</span><span class="cx">     ASSERT(m_pageOverlays.contains(&overlay));
</span><del>-    m_overlayGraphicsLayers.get(&overlay)->setBackgroundColor(overlay.backgroundColor());
</del><ins>+    if (auto* layer = m_overlayGraphicsLayers.get(&overlay))
+        layer->setBackgroundColor(overlay.backgroundColor());
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> bool PageOverlayController::shouldSkipLayerInDump(const GraphicsLayer*, LayerTreeAsTextBehavior behavior) const
</span></span></pre></div>
<a id="trunkSourceWebCorepagePageOverlayControllerh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/page/PageOverlayController.h (235952 => 235953)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/page/PageOverlayController.h        2018-09-12 21:23:40 UTC (rev 235952)
+++ trunk/Source/WebCore/page/PageOverlayController.h   2018-09-12 21:27:07 UTC (rev 235953)
</span><span class="lines">@@ -92,13 +92,13 @@
</span><span class="cx">     bool shouldSkipLayerInDump(const GraphicsLayer*, LayerTreeAsTextBehavior) const override;
</span><span class="cx">     void tiledBackingUsageChanged(const GraphicsLayer*, bool) override;
</span><span class="cx"> 
</span><del>-    std::unique_ptr<GraphicsLayer> m_documentOverlayRootLayer;
-    std::unique_ptr<GraphicsLayer> m_viewOverlayRootLayer;
-    bool m_initialized;
</del><ins>+    Page& m_page;
+    RefPtr<GraphicsLayer> m_documentOverlayRootLayer;
+    RefPtr<GraphicsLayer> m_viewOverlayRootLayer;
</ins><span class="cx"> 
</span><del>-    HashMap<PageOverlay*, std::unique_ptr<GraphicsLayer>> m_overlayGraphicsLayers;
</del><ins>+    HashMap<PageOverlay*, Ref<GraphicsLayer>> m_overlayGraphicsLayers;
</ins><span class="cx">     Vector<RefPtr<PageOverlay>> m_pageOverlays;
</span><del>-    Page& m_page;
</del><ins>+    bool m_initialized { false };
</ins><span class="cx"> };
</span><span class="cx"> 
</span><span class="cx"> } // namespace WebKit
</span></span></pre></div>
<a id="trunkSourceWebCorepageResourceUsageOverlayh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/page/ResourceUsageOverlay.h (235952 => 235953)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/page/ResourceUsageOverlay.h 2018-09-12 21:23:40 UTC (rev 235952)
+++ trunk/Source/WebCore/page/ResourceUsageOverlay.h    2018-09-12 21:27:07 UTC (rev 235953)
</span><span class="lines">@@ -83,7 +83,7 @@
</span><span class="cx"> #endif
</span><span class="cx"> 
</span><span class="cx"> #if OS(LINUX)
</span><del>-    std::unique_ptr<GraphicsLayer> m_paintLayer;
</del><ins>+    RefPtr<GraphicsLayer> m_paintLayer;
</ins><span class="cx">     std::unique_ptr<GraphicsLayerClient> m_overlayPainter;
</span><span class="cx"> #endif
</span><span class="cx"> };
</span></span></pre></div>
<a id="trunkSourceWebCorepagelinuxResourceUsageOverlayLinuxcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/page/linux/ResourceUsageOverlayLinux.cpp (235952 => 235953)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/page/linux/ResourceUsageOverlayLinux.cpp    2018-09-12 21:23:40 UTC (rev 235952)
+++ trunk/Source/WebCore/page/linux/ResourceUsageOverlayLinux.cpp       2018-09-12 21:27:07 UTC (rev 235953)
</span><span class="lines">@@ -137,7 +137,7 @@
</span><span class="cx">     m_paintLayer->setSize({ normalWidth, normalHeight });
</span><span class="cx">     m_paintLayer->setBackgroundColor(Color(0.0f, 0.0f, 0.0f, 0.8f));
</span><span class="cx">     m_paintLayer->setDrawsContent(true);
</span><del>-    overlay().layer().addChild(m_paintLayer.get());
</del><ins>+    overlay().layer().addChild(*m_paintLayer);
</ins><span class="cx"> 
</span><span class="cx">     ResourceUsageThread::addObserver(this, [this] (const ResourceUsageData& data) {
</span><span class="cx">         gData = data;
</span></span></pre></div>
<a id="trunkSourceWebCorepagemacServicesOverlayControllerh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/page/mac/ServicesOverlayController.h (235952 => 235953)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/page/mac/ServicesOverlayController.h        2018-09-12 21:23:40 UTC (rev 235952)
+++ trunk/Source/WebCore/page/mac/ServicesOverlayController.h   2018-09-12 21:27:07 UTC (rev 235953)
</span><span class="lines">@@ -63,7 +63,7 @@
</span><span class="cx"> 
</span><span class="cx">         DDHighlightRef ddHighlight() const { return m_ddHighlight.get(); }
</span><span class="cx">         Range& range() const { return m_range.get(); }
</span><del>-        GraphicsLayer* layer() const { return m_graphicsLayer.get(); }
</del><ins>+        GraphicsLayer& layer() const { return m_graphicsLayer.get(); }
</ins><span class="cx"> 
</span><span class="cx">         enum {
</span><span class="cx">             TelephoneNumberType = 1 << 0,
</span><span class="lines">@@ -87,11 +87,11 @@
</span><span class="cx"> 
</span><span class="cx">         void didFinishFadeOutAnimation();
</span><span class="cx"> 
</span><ins>+        ServicesOverlayController* m_controller;
</ins><span class="cx">         RetainPtr<DDHighlightRef> m_ddHighlight;
</span><span class="cx">         Ref<Range> m_range;
</span><del>-        std::unique_ptr<GraphicsLayer> m_graphicsLayer;
</del><ins>+        Ref<GraphicsLayer> m_graphicsLayer;
</ins><span class="cx">         Type m_type;
</span><del>-        ServicesOverlayController* m_controller;
</del><span class="cx">     };
</span><span class="cx"> 
</span><span class="cx">     // PageOverlay::Client
</span></span></pre></div>
<a id="trunkSourceWebCorepagemacServicesOverlayControllermm"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/page/mac/ServicesOverlayController.mm (235952 => 235953)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/page/mac/ServicesOverlayController.mm       2018-09-12 21:23:40 UTC (rev 235952)
+++ trunk/Source/WebCore/page/mac/ServicesOverlayController.mm  2018-09-12 21:27:07 UTC (rev 235953)
</span><span class="lines">@@ -66,14 +66,13 @@
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> ServicesOverlayController::Highlight::Highlight(ServicesOverlayController& controller, Type type, RetainPtr<DDHighlightRef> ddHighlight, Ref<WebCore::Range>&& range)
</span><del>-    : m_range(WTFMove(range))
</del><ins>+    : m_controller(&controller)
+    , m_range(WTFMove(range))
+    , m_graphicsLayer(GraphicsLayer::create(controller.page().chrome().client().graphicsLayerFactory(), *this))
</ins><span class="cx">     , m_type(type)
</span><del>-    , m_controller(&controller)
</del><span class="cx"> {
</span><span class="cx">     ASSERT(ddHighlight);
</span><span class="cx"> 
</span><del>-    auto& page = controller.page();
-    m_graphicsLayer = GraphicsLayer::create(page.chrome().client().graphicsLayerFactory(), *this);
</del><span class="cx">     m_graphicsLayer->setDrawsContent(true);
</span><span class="cx"> 
</span><span class="cx">     setDDHighlight(ddHighlight.get());
</span><span class="lines">@@ -80,7 +79,7 @@
</span><span class="cx"> 
</span><span class="cx">     // Set directly on the PlatformCALayer so that when we leave the 'from' value implicit
</span><span class="cx">     // in our animations, we get the right initial value regardless of flush timing.
</span><del>-    downcast<GraphicsLayerCA>(*layer()).platformCALayer()->setOpacity(0);
</del><ins>+    downcast<GraphicsLayerCA>(layer()).platformCALayer()->setOpacity(0);
</ins><span class="cx"> 
</span><span class="cx">     controller.didCreateHighlight(this);
</span><span class="cx"> }
</span><span class="lines">@@ -113,7 +112,7 @@
</span><span class="cx"> 
</span><span class="cx"> void ServicesOverlayController::Highlight::invalidate()
</span><span class="cx"> {
</span><del>-    layer()->removeFromParent();
</del><ins>+    layer().removeFromParent();
</ins><span class="cx">     m_controller = nullptr;
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="lines">@@ -158,7 +157,7 @@
</span><span class="cx">     [animation setToValue:@1];
</span><span class="cx"> 
</span><span class="cx">     RefPtr<PlatformCAAnimation> platformAnimation = PlatformCAAnimationCocoa::create(animation.get());
</span><del>-    downcast<GraphicsLayerCA>(*layer()).platformCALayer()->addAnimationForKey("FadeHighlightIn", *platformAnimation);
</del><ins>+    downcast<GraphicsLayerCA>(layer()).platformCALayer()->addAnimationForKey("FadeHighlightIn", *platformAnimation);
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void ServicesOverlayController::Highlight::fadeOut()
</span><span class="lines">@@ -176,7 +175,7 @@
</span><span class="cx">     }];
</span><span class="cx"> 
</span><span class="cx">     RefPtr<PlatformCAAnimation> platformAnimation = PlatformCAAnimationCocoa::create(animation.get());
</span><del>-    downcast<GraphicsLayerCA>(*layer()).platformCALayer()->addAnimationForKey("FadeHighlightOut", *platformAnimation);
</del><ins>+    downcast<GraphicsLayerCA>(layer()).platformCALayer()->addAnimationForKey("FadeHighlightOut", *platformAnimation);
</ins><span class="cx">     [CATransaction commit];
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="lines">@@ -188,7 +187,7 @@
</span><span class="cx">     if (m_controller->activeHighlight() == this)
</span><span class="cx">         return;
</span><span class="cx"> 
</span><del>-    layer()->removeFromParent();
</del><ins>+    layer().removeFromParent();
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> static IntRect textQuadsToBoundingRectForRange(Range& range)
</span><span class="lines">@@ -714,7 +713,8 @@
</span><span class="cx">         m_activeHighlight = WTFMove(m_nextActiveHighlight);
</span><span class="cx"> 
</span><span class="cx">         if (m_activeHighlight) {
</span><del>-            m_servicesOverlay->layer().addChild(m_activeHighlight->layer());
</del><ins>+            Ref<GraphicsLayer> highlightLayer = m_activeHighlight->layer();
+            m_servicesOverlay->layer().addChild(WTFMove(highlightLayer));
</ins><span class="cx">             m_activeHighlight->fadeIn();
</span><span class="cx">         }
</span><span class="cx">     }
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformgraphicsGraphicsLayercpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/graphics/GraphicsLayer.cpp (235952 => 235953)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/graphics/GraphicsLayer.cpp 2018-09-12 21:23:40 UTC (rev 235952)
+++ trunk/Source/WebCore/platform/graphics/GraphicsLayer.cpp    2018-09-12 21:27:07 UTC (rev 235953)
</span><span class="lines">@@ -113,6 +113,7 @@
</span><span class="cx"> GraphicsLayer::GraphicsLayer(Type type, GraphicsLayerClient& client)
</span><span class="cx">     : m_client(client)
</span><span class="cx">     , m_type(type)
</span><ins>+    , m_beingDestroyed(false)
</ins><span class="cx">     , m_contentsOpaque(false)
</span><span class="cx">     , m_supportsSubpixelAntialiasedText(false)
</span><span class="cx">     , m_preserves3D(false)
</span><span class="lines">@@ -143,6 +144,7 @@
</span><span class="cx"> 
</span><span class="cx"> void GraphicsLayer::willBeDestroyed()
</span><span class="cx"> {
</span><ins>+    m_beingDestroyed = true;
</ins><span class="cx"> #ifndef NDEBUG
</span><span class="cx">     m_client.verifyNotPainting();
</span><span class="cx"> #endif
</span><span class="lines">@@ -177,7 +179,7 @@
</span><span class="cx">     return false;
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-bool GraphicsLayer::setChildren(const Vector<GraphicsLayer*>& newChildren)
</del><ins>+bool GraphicsLayer::setChildren(Vector<Ref<GraphicsLayer>>&& newChildren)
</ins><span class="cx"> {
</span><span class="cx">     // If the contents of the arrays are the same, nothing to do.
</span><span class="cx">     if (newChildren == m_children)
</span><span class="lines">@@ -184,92 +186,89 @@
</span><span class="cx">         return false;
</span><span class="cx"> 
</span><span class="cx">     removeAllChildren();
</span><del>-    
</del><ins>+
</ins><span class="cx">     size_t listSize = newChildren.size();
</span><span class="cx">     for (size_t i = 0; i < listSize; ++i)
</span><del>-        addChild(newChildren[i]);
</del><ins>+        addChild(WTFMove(newChildren[i]));
</ins><span class="cx">     
</span><span class="cx">     return true;
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-void GraphicsLayer::addChild(GraphicsLayer* childLayer)
</del><ins>+void GraphicsLayer::addChild(Ref<GraphicsLayer>&& childLayer)
</ins><span class="cx"> {
</span><del>-    ASSERT(childLayer != this);
</del><ins>+    ASSERT(childLayer.ptr() != this);
</ins><span class="cx">     
</span><span class="cx">     if (childLayer->parent())
</span><span class="cx">         childLayer->removeFromParent();
</span><span class="cx"> 
</span><span class="cx">     childLayer->setParent(this);
</span><del>-    m_children.append(childLayer);
</del><ins>+    m_children.append(WTFMove(childLayer));
</ins><span class="cx"> }
</span><span class="cx"> 
</span><del>-void GraphicsLayer::addChildAtIndex(GraphicsLayer* childLayer, int index)
</del><ins>+void GraphicsLayer::addChildAtIndex(Ref<GraphicsLayer>&& childLayer, int index)
</ins><span class="cx"> {
</span><del>-    ASSERT(childLayer != this);
</del><ins>+    ASSERT(childLayer.ptr() != this);
</ins><span class="cx"> 
</span><span class="cx">     if (childLayer->parent())
</span><span class="cx">         childLayer->removeFromParent();
</span><span class="cx"> 
</span><span class="cx">     childLayer->setParent(this);
</span><del>-    m_children.insert(index, childLayer);
</del><ins>+    m_children.insert(index, WTFMove(childLayer));
</ins><span class="cx"> }
</span><span class="cx"> 
</span><del>-void GraphicsLayer::addChildBelow(GraphicsLayer* childLayer, GraphicsLayer* sibling)
</del><ins>+void GraphicsLayer::addChildBelow(Ref<GraphicsLayer>&& childLayer, GraphicsLayer* sibling)
</ins><span class="cx"> {
</span><del>-    ASSERT(childLayer != this);
</del><ins>+    ASSERT(childLayer.ptr() != this);
</ins><span class="cx">     childLayer->removeFromParent();
</span><span class="cx"> 
</span><del>-    bool found = false;
</del><ins>+    childLayer->setParent(this);
+
</ins><span class="cx">     for (unsigned i = 0; i < m_children.size(); i++) {
</span><del>-        if (sibling == m_children[i]) {
-            m_children.insert(i, childLayer);
-            found = true;
-            break;
</del><ins>+        if (sibling == m_children[i].ptr()) {
+            m_children.insert(i, WTFMove(childLayer));
+            return;
</ins><span class="cx">         }
</span><span class="cx">     }
</span><span class="cx"> 
</span><del>-    childLayer->setParent(this);
-
-    if (!found)
-        m_children.append(childLayer);
</del><ins>+    m_children.append(WTFMove(childLayer));
</ins><span class="cx"> }
</span><span class="cx"> 
</span><del>-void GraphicsLayer::addChildAbove(GraphicsLayer* childLayer, GraphicsLayer* sibling)
</del><ins>+void GraphicsLayer::addChildAbove(Ref<GraphicsLayer>&& childLayer, GraphicsLayer* sibling)
</ins><span class="cx"> {
</span><span class="cx">     childLayer->removeFromParent();
</span><del>-    ASSERT(childLayer != this);
</del><ins>+    ASSERT(childLayer.ptr() != this);
</ins><span class="cx"> 
</span><del>-    bool found = false;
</del><ins>+    childLayer->setParent(this);
+
</ins><span class="cx">     for (unsigned i = 0; i < m_children.size(); i++) {
</span><del>-        if (sibling == m_children[i]) {
-            m_children.insert(i+1, childLayer);
-            found = true;
-            break;
</del><ins>+        if (sibling == m_children[i].ptr()) {
+            m_children.insert(i + 1, WTFMove(childLayer));
+            return;
</ins><span class="cx">         }
</span><span class="cx">     }
</span><span class="cx"> 
</span><del>-    childLayer->setParent(this);
-
-    if (!found)
-        m_children.append(childLayer);
</del><ins>+    m_children.append(WTFMove(childLayer));
</ins><span class="cx"> }
</span><span class="cx"> 
</span><del>-bool GraphicsLayer::replaceChild(GraphicsLayer* oldChild, GraphicsLayer* newChild)
</del><ins>+bool GraphicsLayer::replaceChild(GraphicsLayer* oldChild, Ref<GraphicsLayer>&& newChild)
</ins><span class="cx"> {
</span><span class="cx">     ASSERT(!newChild->parent());
</span><ins>+    
+    GraphicsLayer* rawNewChild = newChild.ptr();
+
</ins><span class="cx">     bool found = false;
</span><span class="cx">     for (unsigned i = 0; i < m_children.size(); i++) {
</span><del>-        if (oldChild == m_children[i]) {
-            m_children[i] = newChild;
</del><ins>+        if (oldChild == m_children[i].ptr()) {
+            m_children[i] = WTFMove(newChild);
</ins><span class="cx">             found = true;
</span><span class="cx">             break;
</span><span class="cx">         }
</span><span class="cx">     }
</span><span class="cx">     if (found) {
</span><del>-        oldChild->setParent(0);
</del><ins>+        oldChild->setParent(nullptr);
</ins><span class="cx"> 
</span><del>-        newChild->removeFromParent();
-        newChild->setParent(this);
</del><ins>+        rawNewChild->removeFromParent();
+        rawNewChild->setParent(this);
</ins><span class="cx">         return true;
</span><span class="cx">     }
</span><span class="cx">     return false;
</span><span class="lines">@@ -278,9 +277,10 @@
</span><span class="cx"> void GraphicsLayer::removeAllChildren()
</span><span class="cx"> {
</span><span class="cx">     while (m_children.size()) {
</span><del>-        GraphicsLayer* curLayer = m_children[0];
</del><ins>+        GraphicsLayer* curLayer = m_children[0].ptr();
</ins><span class="cx">         ASSERT(curLayer->parent());
</span><span class="cx">         curLayer->removeFromParent();
</span><ins>+        // curLayer may be destroyed here.
</ins><span class="cx">     }
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="lines">@@ -287,8 +287,12 @@
</span><span class="cx"> void GraphicsLayer::removeFromParent()
</span><span class="cx"> {
</span><span class="cx">     if (m_parent) {
</span><del>-        m_parent->m_children.removeFirst(this);
</del><ins>+        GraphicsLayer* parent = m_parent;
</ins><span class="cx">         setParent(nullptr);
</span><ins>+        parent->m_children.removeFirstMatching([this](auto& layer) {
+            return layer.ptr() == this;
+        });
+        // |this| may be destroyed here.
</ins><span class="cx">     }
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="lines">@@ -318,7 +322,7 @@
</span><span class="cx">         m_childrenTransform = std::make_unique<TransformationMatrix>(matrix);
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-void GraphicsLayer::setMaskLayer(GraphicsLayer* layer)
</del><ins>+void GraphicsLayer::setMaskLayer(RefPtr<GraphicsLayer>&& layer)
</ins><span class="cx"> {
</span><span class="cx">     if (layer == m_maskLayer)
</span><span class="cx">         return;
</span><span class="lines">@@ -332,7 +336,7 @@
</span><span class="cx">         m_maskLayer->setIsMaskLayer(false);
</span><span class="cx">     }
</span><span class="cx">     
</span><del>-    m_maskLayer = layer;
</del><ins>+    m_maskLayer = WTFMove(layer);
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> Path GraphicsLayer::shapeLayerPath() const
</span><span class="lines">@@ -381,10 +385,8 @@
</span><span class="cx">     if (m_replicaLayer)
</span><span class="cx">         m_replicaLayer->noteDeviceOrPageScaleFactorChangedIncludingDescendants();
</span><span class="cx"> 
</span><del>-    const Vector<GraphicsLayer*>& childLayers = children();
-    size_t numChildren = childLayers.size();
-    for (size_t i = 0; i < numChildren; ++i)
-        childLayers[i]->noteDeviceOrPageScaleFactorChangedIncludingDescendants();
</del><ins>+    for (auto& layer : children())
+        layer->noteDeviceOrPageScaleFactorChangedIncludingDescendants();
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void GraphicsLayer::setIsInWindow(bool inWindow)
</span><span class="lines">@@ -534,9 +536,8 @@
</span><span class="cx">     setOpacityInternal(accumulatedOpacity);
</span><span class="cx">     
</span><span class="cx">     if (preserves3D()) {
</span><del>-        size_t numChildren = children().size();
-        for (size_t i = 0; i < numChildren; ++i)
-            children()[i]->distributeOpacity(accumulatedOpacity);
</del><ins>+        for (auto& layer : children())
+            layer->distributeOpacity(accumulatedOpacity);
</ins><span class="cx">     }
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="lines">@@ -693,8 +694,8 @@
</span><span class="cx"> {
</span><span class="cx">     traversalFunc(layer);
</span><span class="cx"> 
</span><del>-    for (auto* childLayer : layer.children())
-        traverse(*childLayer, traversalFunc);
</del><ins>+    for (auto& childLayer : layer.children())
+        traverse(childLayer.get(), traversalFunc);
</ins><span class="cx"> 
</span><span class="cx">     if (auto* replicaLayer = layer.replicaLayer())
</span><span class="cx">         traverse(*replicaLayer, traversalFunc);
</span><span class="lines">@@ -717,11 +718,11 @@
</span><span class="cx">     ts << indent << ")\n";
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-static void dumpChildren(TextStream& ts, const Vector<GraphicsLayer*>& children, unsigned& totalChildCount, LayerTreeAsTextBehavior behavior)
</del><ins>+static void dumpChildren(TextStream& ts, const Vector<Ref<GraphicsLayer>>& children, unsigned& totalChildCount, LayerTreeAsTextBehavior behavior)
</ins><span class="cx"> {
</span><span class="cx">     totalChildCount += children.size();
</span><del>-    for (auto* child : children) {
-        if ((behavior & LayerTreeAsTextDebug) || !child->client().shouldSkipLayerInDump(child, behavior)) {
</del><ins>+    for (auto& child : children) {
+        if ((behavior & LayerTreeAsTextDebug) || !child->client().shouldSkipLayerInDump(child.ptr(), behavior)) {
</ins><span class="cx">             TextStream::IndentScope indentScope(ts);
</span><span class="cx">             child->dumpLayer(ts, behavior);
</span><span class="cx">             continue;
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformgraphicsGraphicsLayerh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/graphics/GraphicsLayer.h (235952 => 235953)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/graphics/GraphicsLayer.h   2018-09-12 21:23:40 UTC (rev 235952)
+++ trunk/Source/WebCore/platform/graphics/GraphicsLayer.h      2018-09-12 21:27:07 UTC (rev 235953)
</span><span class="lines">@@ -230,8 +230,8 @@
</span><span class="cx"> // GraphicsLayer is an abstraction for a rendering surface with backing store,
</span><span class="cx"> // which may have associated transformation and animations.
</span><span class="cx"> 
</span><del>-class GraphicsLayer {
-    WTF_MAKE_NONCOPYABLE(GraphicsLayer); WTF_MAKE_FAST_ALLOCATED;
</del><ins>+class GraphicsLayer : public RefCounted<GraphicsLayer> {
+    WTF_MAKE_FAST_ALLOCATED;
</ins><span class="cx"> public:
</span><span class="cx">     enum class Type : uint8_t {
</span><span class="cx">         Normal,
</span><span class="lines">@@ -239,9 +239,9 @@
</span><span class="cx">         Scrolling,
</span><span class="cx">         Shape
</span><span class="cx">     };
</span><ins>+
+    WEBCORE_EXPORT static Ref<GraphicsLayer> create(GraphicsLayerFactory*, GraphicsLayerClient&, Type = Type::Normal);
</ins><span class="cx">     
</span><del>-    WEBCORE_EXPORT static std::unique_ptr<GraphicsLayer> create(GraphicsLayerFactory*, GraphicsLayerClient&, Type = Type::Normal);
-    
</del><span class="cx">     WEBCORE_EXPORT virtual ~GraphicsLayer();
</span><span class="cx">     
</span><span class="cx">     Type type() const { return m_type; }
</span><span class="lines">@@ -263,32 +263,25 @@
</span><span class="cx">     // Returns true if the layer has the given layer as an ancestor (excluding self).
</span><span class="cx">     bool hasAncestor(GraphicsLayer*) const;
</span><span class="cx">     
</span><del>-    const Vector<GraphicsLayer*>& children() const { return m_children; }
</del><ins>+    const Vector<Ref<GraphicsLayer>>& children() const { return m_children; }
+    Vector<Ref<GraphicsLayer>>& children() { return m_children; }
+
</ins><span class="cx">     // Returns true if the child list changed.
</span><del>-    WEBCORE_EXPORT virtual bool setChildren(const Vector<GraphicsLayer*>&);
</del><ins>+    WEBCORE_EXPORT virtual bool setChildren(Vector<Ref<GraphicsLayer>>&&);
</ins><span class="cx"> 
</span><del>-    enum class ContentsLayerPurpose : uint8_t {
-        None = 0,
-        Image,
-        Media,
-        Canvas,
-        BackgroundColor,
-        Plugin
-    };
-
</del><span class="cx">     // Add child layers. If the child is already parented, it will be removed from its old parent.
</span><del>-    WEBCORE_EXPORT virtual void addChild(GraphicsLayer*);
-    WEBCORE_EXPORT virtual void addChildAtIndex(GraphicsLayer*, int index);
-    WEBCORE_EXPORT virtual void addChildAbove(GraphicsLayer*, GraphicsLayer* sibling);
-    WEBCORE_EXPORT virtual void addChildBelow(GraphicsLayer*, GraphicsLayer* sibling);
-    WEBCORE_EXPORT virtual bool replaceChild(GraphicsLayer* oldChild, GraphicsLayer* newChild);
</del><ins>+    WEBCORE_EXPORT virtual void addChild(Ref<GraphicsLayer>&&);
+    WEBCORE_EXPORT virtual void addChildAtIndex(Ref<GraphicsLayer>&&, int index);
+    WEBCORE_EXPORT virtual void addChildAbove(Ref<GraphicsLayer>&&, GraphicsLayer* sibling);
+    WEBCORE_EXPORT virtual void addChildBelow(Ref<GraphicsLayer>&&, GraphicsLayer* sibling);
+    WEBCORE_EXPORT virtual bool replaceChild(GraphicsLayer* oldChild, Ref<GraphicsLayer>&& newChild);
</ins><span class="cx"> 
</span><span class="cx">     WEBCORE_EXPORT void removeAllChildren();
</span><span class="cx">     WEBCORE_EXPORT virtual void removeFromParent();
</span><span class="cx"> 
</span><span class="cx">     // The parent() of a maskLayer is set to the layer being masked.
</span><del>-    GraphicsLayer* maskLayer() const { return m_maskLayer; }
-    virtual void setMaskLayer(GraphicsLayer*);
</del><ins>+    GraphicsLayer* maskLayer() const { return m_maskLayer.get(); }
+    virtual void setMaskLayer(RefPtr<GraphicsLayer>&&);
</ins><span class="cx"> 
</span><span class="cx">     void setIsMaskLayer(bool isMask) { m_isMaskLayer = isMask; }
</span><span class="cx">     bool isMaskLayer() const { return m_isMaskLayer; }
</span><span class="lines">@@ -298,7 +291,7 @@
</span><span class="cx">     // Whether this layer is being replicated by another layer.
</span><span class="cx">     bool isReplicated() const { return m_replicaLayer; }
</span><span class="cx">     // The layer that replicates this layer (if any).
</span><del>-    GraphicsLayer* replicaLayer() const { return m_replicaLayer; }
</del><ins>+    GraphicsLayer* replicaLayer() const { return m_replicaLayer.get(); }
</ins><span class="cx"> 
</span><span class="cx">     const FloatPoint& replicatedLayerPosition() const { return m_replicatedLayerPosition; }
</span><span class="cx">     void setReplicatedLayerPosition(const FloatPoint& p) { m_replicatedLayerPosition = p; }
</span><span class="lines">@@ -466,6 +459,16 @@
</span><span class="cx"> #if PLATFORM(IOS)
</span><span class="cx">     virtual PlatformLayer* contentsLayerForMedia() const { return 0; }
</span><span class="cx"> #endif
</span><ins>+
+    enum class ContentsLayerPurpose : uint8_t {
+        None = 0,
+        Image,
+        Media,
+        Canvas,
+        BackgroundColor,
+        Plugin
+    };
+
</ins><span class="cx">     // Pass an invalid color to remove the contents layer.
</span><span class="cx">     virtual void setContentsToSolidColor(const Color&) { }
</span><span class="cx">     virtual void setContentsToPlatformLayer(PlatformLayer*, ContentsLayerPurpose) { }
</span><span class="lines">@@ -591,6 +594,7 @@
</span><span class="cx"> 
</span><span class="cx">     // Should be called from derived class destructors. Should call willBeDestroyed() on super.
</span><span class="cx">     WEBCORE_EXPORT virtual void willBeDestroyed();
</span><ins>+    bool beingDestroyed() const { return m_beingDestroyed; }
</ins><span class="cx"> 
</span><span class="cx">     // This method is used by platform GraphicsLayer classes to clear the filters
</span><span class="cx">     // when compositing is not done in hardware. It is not virtual, so the caller
</span><span class="lines">@@ -656,6 +660,7 @@
</span><span class="cx">     GraphicsLayerPaintingPhase m_paintingPhase { GraphicsLayerPaintAllWithOverflowClip };
</span><span class="cx">     CompositingCoordinatesOrientation m_contentsOrientation { CompositingCoordinatesOrientation::TopDown }; // affects orientation of layer contents
</span><span class="cx"> 
</span><ins>+    bool m_beingDestroyed : 1;
</ins><span class="cx">     bool m_contentsOpaque : 1;
</span><span class="cx">     bool m_supportsSubpixelAntialiasedText : 1;
</span><span class="cx">     bool m_preserves3D: 1;
</span><span class="lines">@@ -675,12 +680,12 @@
</span><span class="cx"> 
</span><span class="cx">     int m_repaintCount { 0 };
</span><span class="cx"> 
</span><del>-    Vector<GraphicsLayer*> m_children;
</del><ins>+    Vector<Ref<GraphicsLayer>> m_children;
</ins><span class="cx">     GraphicsLayer* m_parent { nullptr };
</span><span class="cx"> 
</span><del>-    GraphicsLayer* m_maskLayer { nullptr }; // Reference to mask layer. We don't own this.
</del><ins>+    RefPtr<GraphicsLayer> m_maskLayer { nullptr }; // Reference to mask layer.
</ins><span class="cx"> 
</span><del>-    GraphicsLayer* m_replicaLayer { nullptr }; // A layer that replicates this layer. We only allow one, for now.
</del><ins>+    RefPtr<GraphicsLayer> m_replicaLayer { nullptr }; // A layer that replicates this layer. We only allow one, for now.
</ins><span class="cx">                                    // The replica is not parented; this is the primary reference to it.
</span><span class="cx">     GraphicsLayer* m_replicatedLayer { nullptr }; // For a replica layer, a reference to the original layer.
</span><span class="cx">     FloatPoint m_replicatedLayerPosition; // For a replica layer, the position of the replica.
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformgraphicsGraphicsLayerFactoryh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/graphics/GraphicsLayerFactory.h (235952 => 235953)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/graphics/GraphicsLayerFactory.h    2018-09-12 21:23:40 UTC (rev 235952)
+++ trunk/Source/WebCore/platform/graphics/GraphicsLayerFactory.h       2018-09-12 21:27:07 UTC (rev 235953)
</span><span class="lines">@@ -23,8 +23,7 @@
</span><span class="cx">  * THE POSSIBILITY OF SUCH DAMAGE.
</span><span class="cx">  */
</span><span class="cx"> 
</span><del>-#ifndef GraphicsLayerFactory_h
-#define GraphicsLayerFactory_h
</del><ins>+#pragma once
</ins><span class="cx"> 
</span><span class="cx"> #include "GraphicsLayer.h"
</span><span class="cx"> #include <wtf/Forward.h>
</span><span class="lines">@@ -35,9 +34,7 @@
</span><span class="cx"> public:
</span><span class="cx">     virtual ~GraphicsLayerFactory() = default;
</span><span class="cx"> 
</span><del>-    virtual std::unique_ptr<GraphicsLayer> createGraphicsLayer(GraphicsLayer::Type, GraphicsLayerClient&) = 0;
</del><ins>+    virtual Ref<GraphicsLayer> createGraphicsLayer(GraphicsLayer::Type, GraphicsLayerClient&) = 0;
</ins><span class="cx"> };
</span><span class="cx"> 
</span><span class="cx"> } // namespace WebCore
</span><del>-
-#endif // GraphicsLayerFactory_h
</del></span></pre></div>
<a id="trunkSourceWebCoreplatformgraphicscaGraphicsLayerCAcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/graphics/ca/GraphicsLayerCA.cpp (235952 => 235953)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/graphics/ca/GraphicsLayerCA.cpp    2018-09-12 21:23:40 UTC (rev 235952)
+++ trunk/Source/WebCore/platform/graphics/ca/GraphicsLayerCA.cpp       2018-09-12 21:27:07 UTC (rev 235953)
</span><span class="lines">@@ -339,17 +339,17 @@
</span><span class="cx"> #endif
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-std::unique_ptr<GraphicsLayer> GraphicsLayer::create(GraphicsLayerFactory* factory, GraphicsLayerClient& client, Type layerType)
</del><ins>+Ref<GraphicsLayer> GraphicsLayer::create(GraphicsLayerFactory* factory, GraphicsLayerClient& client, Type layerType)
</ins><span class="cx"> {
</span><del>-    std::unique_ptr<GraphicsLayer> graphicsLayer;
-    if (!factory)
-        graphicsLayer = std::make_unique<GraphicsLayerCA>(layerType, client);
-    else
-        graphicsLayer = factory->createGraphicsLayer(layerType, client);
-
-    graphicsLayer->initialize(layerType);
-
-    return graphicsLayer;
</del><ins>+    if (factory) {
+        auto layer = factory->createGraphicsLayer(layerType, client);
+        layer->initialize(layerType);
+        return layer;
+    }
+    
+    auto layer = adoptRef(*new GraphicsLayerCA(layerType, client));
+    layer->initialize(layerType);
+    return WTFMove(layer);
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> bool GraphicsLayerCA::filtersCanBeComposited(const FilterOperations& filters)
</span><span class="lines">@@ -505,9 +505,9 @@
</span><span class="cx">     return primaryLayer()->platformLayer();
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-bool GraphicsLayerCA::setChildren(const Vector<GraphicsLayer*>& children)
</del><ins>+bool GraphicsLayerCA::setChildren(Vector<Ref<GraphicsLayer>>&& children)
</ins><span class="cx"> {
</span><del>-    bool childrenChanged = GraphicsLayer::setChildren(children);
</del><ins>+    bool childrenChanged = GraphicsLayer::setChildren(WTFMove(children));
</ins><span class="cx">     if (childrenChanged)
</span><span class="cx">         noteSublayersChanged();
</span><span class="cx">     
</span><span class="lines">@@ -514,33 +514,33 @@
</span><span class="cx">     return childrenChanged;
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-void GraphicsLayerCA::addChild(GraphicsLayer* childLayer)
</del><ins>+void GraphicsLayerCA::addChild(Ref<GraphicsLayer>&& childLayer)
</ins><span class="cx"> {
</span><del>-    GraphicsLayer::addChild(childLayer);
</del><ins>+    GraphicsLayer::addChild(WTFMove(childLayer));
</ins><span class="cx">     noteSublayersChanged();
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-void GraphicsLayerCA::addChildAtIndex(GraphicsLayer* childLayer, int index)
</del><ins>+void GraphicsLayerCA::addChildAtIndex(Ref<GraphicsLayer>&& childLayer, int index)
</ins><span class="cx"> {
</span><del>-    GraphicsLayer::addChildAtIndex(childLayer, index);
</del><ins>+    GraphicsLayer::addChildAtIndex(WTFMove(childLayer), index);
</ins><span class="cx">     noteSublayersChanged();
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-void GraphicsLayerCA::addChildBelow(GraphicsLayer* childLayer, GraphicsLayer* sibling)
</del><ins>+void GraphicsLayerCA::addChildBelow(Ref<GraphicsLayer>&& childLayer, GraphicsLayer* sibling)
</ins><span class="cx"> {
</span><del>-    GraphicsLayer::addChildBelow(childLayer, sibling);
</del><ins>+    GraphicsLayer::addChildBelow(WTFMove(childLayer), sibling);
</ins><span class="cx">     noteSublayersChanged();
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-void GraphicsLayerCA::addChildAbove(GraphicsLayer* childLayer, GraphicsLayer* sibling)
</del><ins>+void GraphicsLayerCA::addChildAbove(Ref<GraphicsLayer>&& childLayer, GraphicsLayer* sibling)
</ins><span class="cx"> {
</span><del>-    GraphicsLayer::addChildAbove(childLayer, sibling);
</del><ins>+    GraphicsLayer::addChildAbove(WTFMove(childLayer), sibling);
</ins><span class="cx">     noteSublayersChanged();
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-bool GraphicsLayerCA::replaceChild(GraphicsLayer* oldChild, GraphicsLayer* newChild)
</del><ins>+bool GraphicsLayerCA::replaceChild(GraphicsLayer* oldChild, Ref<GraphicsLayer>&& newChild)
</ins><span class="cx"> {
</span><del>-    if (GraphicsLayer::replaceChild(oldChild, newChild)) {
</del><ins>+    if (GraphicsLayer::replaceChild(oldChild, WTFMove(newChild))) {
</ins><span class="cx">         noteSublayersChanged();
</span><span class="cx">         return true;
</span><span class="cx">     }
</span><span class="lines">@@ -554,12 +554,12 @@
</span><span class="cx">     GraphicsLayer::removeFromParent();
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-void GraphicsLayerCA::setMaskLayer(GraphicsLayer* layer)
</del><ins>+void GraphicsLayerCA::setMaskLayer(RefPtr<GraphicsLayer>&& layer)
</ins><span class="cx"> {
</span><span class="cx">     if (layer == m_maskLayer)
</span><span class="cx">         return;
</span><span class="cx"> 
</span><del>-    GraphicsLayer::setMaskLayer(layer);
</del><ins>+    GraphicsLayer::setMaskLayer(WTFMove(layer));
</ins><span class="cx">     noteLayerPropertyChanged(MaskLayerChanged);
</span><span class="cx"> 
</span><span class="cx">     propagateLayerChangeToReplicas();
</span><span class="lines">@@ -1300,16 +1300,13 @@
</span><span class="cx">     childCommitState.ancestorIsViewportConstrained |= m_isViewportConstrained;
</span><span class="cx"> 
</span><span class="cx">     if (m_maskLayer) {
</span><del>-        GraphicsLayerCA& maskLayerCA = downcast<GraphicsLayerCA>(*m_maskLayer);
</del><ins>+        auto& maskLayerCA = downcast<GraphicsLayerCA>(*m_maskLayer);
</ins><span class="cx">         if (maskLayerCA.recursiveVisibleRectChangeRequiresFlush(childCommitState, localState))
</span><span class="cx">             return true;
</span><span class="cx">     }
</span><span class="cx"> 
</span><del>-    const Vector<GraphicsLayer*>& childLayers = children();
-    size_t numChildren = childLayers.size();
-    
-    for (size_t i = 0; i < numChildren; ++i) {
-        GraphicsLayerCA& currentChild = downcast<GraphicsLayerCA>(*childLayers[i]);
</del><ins>+    for (const auto& layer : children()) {
+        const auto& currentChild = downcast<GraphicsLayerCA>(layer.get());
</ins><span class="cx">         if (currentChild.recursiveVisibleRectChangeRequiresFlush(childCommitState, localState))
</span><span class="cx">             return true;
</span><span class="cx">     }
</span><span class="lines">@@ -1572,18 +1569,15 @@
</span><span class="cx">     
</span><span class="cx">     childCommitState.ancestorIsViewportConstrained |= m_isViewportConstrained;
</span><span class="cx"> 
</span><del>-    if (GraphicsLayerCA* maskLayer = downcast<GraphicsLayerCA>(m_maskLayer)) {
</del><ins>+    if (GraphicsLayerCA* maskLayer = downcast<GraphicsLayerCA>(m_maskLayer.get())) {
</ins><span class="cx">         maskLayer->setVisibleAndCoverageRects(rects, m_isViewportConstrained || commitState.ancestorIsViewportConstrained);
</span><span class="cx">         maskLayer->commitLayerChangesBeforeSublayers(childCommitState, pageScaleFactor, baseRelativePosition);
</span><span class="cx">     }
</span><span class="cx"> 
</span><del>-    const Vector<GraphicsLayer*>& childLayers = children();
-    size_t numChildren = childLayers.size();
-
</del><span class="cx">     bool hasDescendantsWithRunningTransformAnimations = false;
</span><span class="cx">     
</span><del>-    for (size_t i = 0; i < numChildren; ++i) {
-        GraphicsLayerCA& currentChild = downcast<GraphicsLayerCA>(*childLayers[i]);
</del><ins>+    for (auto& layer : children()) {
+        auto& currentChild = downcast<GraphicsLayerCA>(layer.get());
</ins><span class="cx">         currentChild.recursiveCommitChanges(childCommitState, localState, pageScaleFactor, baseRelativePosition, affectedByPageScale);
</span><span class="cx"> 
</span><span class="cx">         if (currentChild.isRunningTransformAnimation() || currentChild.hasDescendantsWithRunningTransformAnimations())
</span><span class="lines">@@ -1590,10 +1584,10 @@
</span><span class="cx">             hasDescendantsWithRunningTransformAnimations = true;
</span><span class="cx">     }
</span><span class="cx"> 
</span><del>-    if (GraphicsLayerCA* replicaLayer = downcast<GraphicsLayerCA>(m_replicaLayer))
</del><ins>+    if (GraphicsLayerCA* replicaLayer = downcast<GraphicsLayerCA>(m_replicaLayer.get()))
</ins><span class="cx">         replicaLayer->recursiveCommitChanges(childCommitState, localState, pageScaleFactor, baseRelativePosition, affectedByPageScale);
</span><span class="cx"> 
</span><del>-    if (GraphicsLayerCA* maskLayer = downcast<GraphicsLayerCA>(m_maskLayer))
</del><ins>+    if (GraphicsLayerCA* maskLayer = downcast<GraphicsLayerCA>(m_maskLayer.get()))
</ins><span class="cx">         maskLayer->commitLayerChangesAfterSublayers(childCommitState);
</span><span class="cx"> 
</span><span class="cx">     setHasDescendantsWithUncommittedChanges(false);
</span><span class="lines">@@ -1928,10 +1922,8 @@
</span><span class="cx">         primaryLayerChildren.append(m_contentsClippingLayer ? m_contentsClippingLayer : m_contentsLayer);
</span><span class="cx">     }
</span><span class="cx">     
</span><del>-    const Vector<GraphicsLayer*>& childLayers = children();
-    size_t numChildren = childLayers.size();
-    for (size_t i = 0; i < numChildren; ++i) {
-        GraphicsLayerCA& currentChild = downcast<GraphicsLayerCA>(*childLayers[i]);
</del><ins>+    for (const auto& layer : children()) {
+        const auto& currentChild = downcast<GraphicsLayerCA>(layer.get());
</ins><span class="cx">         PlatformCALayer* childLayer = currentChild.layerForSuperlayer();
</span><span class="cx">         childListForSublayers.append(childLayer);
</span><span class="cx">     }
</span><span class="lines">@@ -3977,7 +3969,7 @@
</span><span class="cx">         return primaryLayer;
</span><span class="cx">     }
</span><span class="cx"> 
</span><del>-    const Vector<GraphicsLayer*>& childLayers = children();
</del><ins>+    auto& childLayers = children();
</ins><span class="cx">     Vector<RefPtr<PlatformCALayer>> clonalSublayers;
</span><span class="cx"> 
</span><span class="cx">     RefPtr<PlatformCALayer> replicaLayer;
</span><span class="lines">@@ -4027,8 +4019,8 @@
</span><span class="cx">         
</span><span class="cx">         replicaState.push(ReplicaState::ChildBranch);
</span><span class="cx"> 
</span><del>-        for (auto* childLayer : childLayers) {
-            GraphicsLayerCA& childLayerCA = downcast<GraphicsLayerCA>(*childLayer);
</del><ins>+        for (auto& childLayer : childLayers) {
+            GraphicsLayerCA& childLayerCA = downcast<GraphicsLayerCA>(childLayer.get());
</ins><span class="cx">             if (auto platformLayer = childLayerCA.fetchCloneLayers(replicaRoot, replicaState, IntermediateCloneLevel))
</span><span class="cx">                 clonalSublayers.append(WTFMove(platformLayer));
</span><span class="cx">         }
</span><span class="lines">@@ -4192,6 +4184,9 @@
</span><span class="cx"> 
</span><span class="cx"> void GraphicsLayerCA::noteLayerPropertyChanged(LayerChangeFlags flags, ScheduleFlushOrNot scheduleFlush)
</span><span class="cx"> {
</span><ins>+    if (beingDestroyed())
+        return;
+
</ins><span class="cx">     bool hadUncommittedChanges = !!m_uncommittedChanges;
</span><span class="cx">     bool oldCanThrottleLayerFlush = canThrottleLayerFlush();
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformgraphicscaGraphicsLayerCAh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/graphics/ca/GraphicsLayerCA.h (235952 => 235953)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/graphics/ca/GraphicsLayerCA.h      2018-09-12 21:23:40 UTC (rev 235952)
+++ trunk/Source/WebCore/platform/graphics/ca/GraphicsLayerCA.h 2018-09-12 21:27:07 UTC (rev 235953)
</span><span class="lines">@@ -49,7 +49,6 @@
</span><span class="cx"> 
</span><span class="cx"> class GraphicsLayerCA : public GraphicsLayer, public PlatformCALayerClient {
</span><span class="cx"> public:
</span><del>-
</del><span class="cx">     WEBCORE_EXPORT explicit GraphicsLayerCA(Type, GraphicsLayerClient&);
</span><span class="cx">     WEBCORE_EXPORT virtual ~GraphicsLayerCA();
</span><span class="cx"> 
</span><span class="lines">@@ -62,16 +61,16 @@
</span><span class="cx">     WEBCORE_EXPORT PlatformLayer* platformLayer() const override;
</span><span class="cx">     PlatformCALayer* platformCALayer() const { return primaryLayer(); }
</span><span class="cx"> 
</span><del>-    WEBCORE_EXPORT bool setChildren(const Vector<GraphicsLayer*>&) override;
-    WEBCORE_EXPORT void addChild(GraphicsLayer*) override;
-    WEBCORE_EXPORT void addChildAtIndex(GraphicsLayer*, int index) override;
-    WEBCORE_EXPORT void addChildAbove(GraphicsLayer*, GraphicsLayer* sibling) override;
-    WEBCORE_EXPORT void addChildBelow(GraphicsLayer*, GraphicsLayer* sibling) override;
-    WEBCORE_EXPORT bool replaceChild(GraphicsLayer* oldChild, GraphicsLayer* newChild) override;
</del><ins>+    WEBCORE_EXPORT bool setChildren(Vector<Ref<GraphicsLayer>>&&) override;
+    WEBCORE_EXPORT void addChild(Ref<GraphicsLayer>&&) override;
+    WEBCORE_EXPORT void addChildAtIndex(Ref<GraphicsLayer>&&, int index) override;
+    WEBCORE_EXPORT void addChildAbove(Ref<GraphicsLayer>&&, GraphicsLayer* sibling) override;
+    WEBCORE_EXPORT void addChildBelow(Ref<GraphicsLayer>&&, GraphicsLayer* sibling) override;
+    WEBCORE_EXPORT bool replaceChild(GraphicsLayer* oldChild, Ref<GraphicsLayer>&& newChild) override;
</ins><span class="cx"> 
</span><span class="cx">     WEBCORE_EXPORT void removeFromParent() override;
</span><span class="cx"> 
</span><del>-    WEBCORE_EXPORT void setMaskLayer(GraphicsLayer*) override;
</del><ins>+    WEBCORE_EXPORT void setMaskLayer(RefPtr<GraphicsLayer>&&) override;
</ins><span class="cx">     WEBCORE_EXPORT void setReplicatedLayer(GraphicsLayer*) override;
</span><span class="cx"> 
</span><span class="cx">     WEBCORE_EXPORT void setPosition(const FloatPoint&) override;
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformgraphicstexmapGraphicsLayerTextureMappercpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/graphics/texmap/GraphicsLayerTextureMapper.cpp (235952 => 235953)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/graphics/texmap/GraphicsLayerTextureMapper.cpp     2018-09-12 21:23:40 UTC (rev 235952)
+++ trunk/Source/WebCore/platform/graphics/texmap/GraphicsLayerTextureMapper.cpp        2018-09-12 21:27:07 UTC (rev 235953)
</span><span class="lines">@@ -29,10 +29,10 @@
</span><span class="cx"> 
</span><span class="cx"> namespace WebCore {
</span><span class="cx"> 
</span><del>-std::unique_ptr<GraphicsLayer> GraphicsLayer::create(GraphicsLayerFactory* factory, GraphicsLayerClient& client, Type layerType)
</del><ins>+Ref<GraphicsLayer> GraphicsLayer::create(GraphicsLayerFactory* factory, GraphicsLayerClient& client, Type layerType)
</ins><span class="cx"> {
</span><span class="cx">     if (!factory)
</span><del>-        return std::make_unique<GraphicsLayerTextureMapper>(layerType, client);
</del><ins>+        return adoptRef(*new GraphicsLayerTextureMapper(layerType, client));
</ins><span class="cx"> 
</span><span class="cx">     return factory->createGraphicsLayer(layerType, client);
</span><span class="cx"> }
</span><span class="lines">@@ -93,9 +93,9 @@
</span><span class="cx">     addRepaintRect(rect);
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-bool GraphicsLayerTextureMapper::setChildren(const Vector<GraphicsLayer*>& children)
</del><ins>+bool GraphicsLayerTextureMapper::setChildren(Vector<Ref<GraphicsLayer>>&& children)
</ins><span class="cx"> {
</span><del>-    if (GraphicsLayer::setChildren(children)) {
</del><ins>+    if (GraphicsLayer::setChildren(WTFMove(children))) {
</ins><span class="cx">         notifyChange(ChildrenChange);
</span><span class="cx">         return true;
</span><span class="cx">     }
</span><span class="lines">@@ -102,33 +102,33 @@
</span><span class="cx">     return false;
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-void GraphicsLayerTextureMapper::addChild(GraphicsLayer* layer)
</del><ins>+void GraphicsLayerTextureMapper::addChild(Ref<GraphicsLayer>&& layer)
</ins><span class="cx"> {
</span><span class="cx">     notifyChange(ChildrenChange);
</span><del>-    GraphicsLayer::addChild(layer);
</del><ins>+    GraphicsLayer::addChild(WTFMove(layer));
</ins><span class="cx"> }
</span><span class="cx"> 
</span><del>-void GraphicsLayerTextureMapper::addChildAtIndex(GraphicsLayer* layer, int index)
</del><ins>+void GraphicsLayerTextureMapper::addChildAtIndex(Ref<GraphicsLayer>&& layer, int index)
</ins><span class="cx"> {
</span><del>-    GraphicsLayer::addChildAtIndex(layer, index);
</del><ins>+    GraphicsLayer::addChildAtIndex(WTFMove(layer), index);
</ins><span class="cx">     notifyChange(ChildrenChange);
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-void GraphicsLayerTextureMapper::addChildAbove(GraphicsLayer* layer, GraphicsLayer* sibling)
</del><ins>+void GraphicsLayerTextureMapper::addChildAbove(Ref<GraphicsLayer>&& layer, GraphicsLayer* sibling)
</ins><span class="cx"> {
</span><del>-    GraphicsLayer::addChildAbove(layer, sibling);
</del><ins>+    GraphicsLayer::addChildAbove(WTFMove(layer), sibling);
</ins><span class="cx">     notifyChange(ChildrenChange);
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-void GraphicsLayerTextureMapper::addChildBelow(GraphicsLayer* layer, GraphicsLayer* sibling)
</del><ins>+void GraphicsLayerTextureMapper::addChildBelow(Ref<GraphicsLayer>&& layer, GraphicsLayer* sibling)
</ins><span class="cx"> {
</span><del>-    GraphicsLayer::addChildBelow(layer, sibling);
</del><ins>+    GraphicsLayer::addChildBelow(WTFMove(layer), sibling);
</ins><span class="cx">     notifyChange(ChildrenChange);
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-bool GraphicsLayerTextureMapper::replaceChild(GraphicsLayer* oldChild, GraphicsLayer* newChild)
</del><ins>+bool GraphicsLayerTextureMapper::replaceChild(GraphicsLayer* oldChild, Ref<GraphicsLayer>&& newChild)
</ins><span class="cx"> {
</span><del>-    if (GraphicsLayer::replaceChild(oldChild, newChild)) {
</del><ins>+    if (GraphicsLayer::replaceChild(oldChild, WTFMove(newChild))) {
</ins><span class="cx">         notifyChange(ChildrenChange);
</span><span class="cx">         return true;
</span><span class="cx">     }
</span><span class="lines">@@ -135,17 +135,19 @@
</span><span class="cx">     return false;
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-void GraphicsLayerTextureMapper::setMaskLayer(GraphicsLayer* value)
</del><ins>+void GraphicsLayerTextureMapper::setMaskLayer(RefPtr<GraphicsLayer>&& value)
</ins><span class="cx"> {
</span><span class="cx">     if (value == maskLayer())
</span><span class="cx">         return;
</span><del>-    GraphicsLayer::setMaskLayer(value);
</del><ins>+
+    GraphicsLayer* rawLayer = value.get();
+    GraphicsLayer::setMaskLayer(WTFMove(value));
</ins><span class="cx">     notifyChange(MaskLayerChange);
</span><span class="cx"> 
</span><del>-    if (!value)
</del><ins>+    if (!rawLayer)
</ins><span class="cx">         return;
</span><del>-    value->setSize(size());
-    value->setContentsVisible(contentsAreVisible());
</del><ins>+    rawLayer->setSize(size());
+    rawLayer->setContentsVisible(contentsAreVisible());
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> 
</span><span class="lines">@@ -391,8 +393,13 @@
</span><span class="cx">     if (m_changeMask == NoChanges)
</span><span class="cx">         return;
</span><span class="cx"> 
</span><del>-    if (m_changeMask & ChildrenChange)
-        m_layer.setChildren(children());
</del><ins>+    if (m_changeMask & ChildrenChange) {
+        Vector<GraphicsLayer*> rawChildren;
+        rawChildren.reserveInitialCapacity(children().size());
+        for (auto& layer : children())
+            rawChildren.uncheckedAppend(layer.ptr());
+        m_layer.setChildren(rawChildren);
+    }
</ins><span class="cx"> 
</span><span class="cx">     if (m_changeMask & MaskLayerChange)
</span><span class="cx">         m_layer.setMaskLayer(&downcast<GraphicsLayerTextureMapper>(maskLayer())->layer());
</span><span class="lines">@@ -477,7 +484,7 @@
</span><span class="cx">         maskLayer()->flushCompositingState(rect);
</span><span class="cx">     if (replicaLayer())
</span><span class="cx">         replicaLayer()->flushCompositingState(rect);
</span><del>-    for (auto* child : children())
</del><ins>+    for (auto& child : children())
</ins><span class="cx">         child->flushCompositingState(rect);
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="lines">@@ -492,8 +499,8 @@
</span><span class="cx">         downcast<GraphicsLayerTextureMapper>(*maskLayer()).updateBackingStoreIfNeeded();
</span><span class="cx">     if (replicaLayer())
</span><span class="cx">         downcast<GraphicsLayerTextureMapper>(*replicaLayer()).updateBackingStoreIfNeeded();
</span><del>-    for (auto* child : children())
-        downcast<GraphicsLayerTextureMapper>(*child).updateBackingStoreIncludingSubLayers();
</del><ins>+    for (auto& child : children())
+        downcast<GraphicsLayerTextureMapper>(child.get()).updateBackingStoreIncludingSubLayers();
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void GraphicsLayerTextureMapper::updateBackingStoreIfNeeded()
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformgraphicstexmapGraphicsLayerTextureMapperh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/graphics/texmap/GraphicsLayerTextureMapper.h (235952 => 235953)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/graphics/texmap/GraphicsLayerTextureMapper.h       2018-09-12 21:23:40 UTC (rev 235952)
+++ trunk/Source/WebCore/platform/graphics/texmap/GraphicsLayerTextureMapper.h  2018-09-12 21:27:07 UTC (rev 235953)
</span><span class="lines">@@ -39,14 +39,14 @@
</span><span class="cx">     void setID(uint32_t id) { m_layer.setID(id); }
</span><span class="cx"> 
</span><span class="cx">     // GraphicsLayer
</span><del>-    bool setChildren(const Vector<GraphicsLayer*>&) override;
-    void addChild(GraphicsLayer*) override;
-    void addChildAtIndex(GraphicsLayer*, int index) override;
-    void addChildAbove(GraphicsLayer*, GraphicsLayer* sibling) override;
-    void addChildBelow(GraphicsLayer*, GraphicsLayer* sibling) override;
-    bool replaceChild(GraphicsLayer* oldChild, GraphicsLayer* newChild) override;
</del><ins>+    bool setChildren(Vector<Ref<GraphicsLayer>>&&) override;
+    void addChild(Ref<GraphicsLayer>&&) override;
+    void addChildAtIndex(Ref<GraphicsLayer>&&, int index) override;
+    void addChildAbove(Ref<GraphicsLayer>&&, GraphicsLayer* sibling) override;
+    void addChildBelow(Ref<GraphicsLayer>&&, GraphicsLayer* sibling) override;
+    bool replaceChild(GraphicsLayer* oldChild, Ref<GraphicsLayer>&& newChild) override;
</ins><span class="cx"> 
</span><del>-    void setMaskLayer(GraphicsLayer*) override;
</del><ins>+    void setMaskLayer(RefPtr<GraphicsLayer>&&) override;
</ins><span class="cx">     void setReplicatedByLayer(GraphicsLayer*) override;
</span><span class="cx">     void setPosition(const FloatPoint&) override;
</span><span class="cx">     void setAnchorPoint(const FloatPoint3D&) override;
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformgraphicstexmapcoordinatedCoordinatedGraphicsLayercpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/graphics/texmap/coordinated/CoordinatedGraphicsLayer.cpp (235952 => 235953)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/graphics/texmap/coordinated/CoordinatedGraphicsLayer.cpp   2018-09-12 21:23:40 UTC (rev 235952)
+++ trunk/Source/WebCore/platform/graphics/texmap/coordinated/CoordinatedGraphicsLayer.cpp      2018-09-12 21:27:07 UTC (rev 235953)
</span><span class="lines">@@ -46,10 +46,10 @@
</span><span class="cx"> 
</span><span class="cx"> namespace WebCore {
</span><span class="cx"> 
</span><del>-std::unique_ptr<GraphicsLayer> GraphicsLayer::create(GraphicsLayerFactory* factory, GraphicsLayerClient& client, Type layerType)
</del><ins>+Ref<GraphicsLayer> GraphicsLayer::create(GraphicsLayerFactory* factory, GraphicsLayerClient& client, Type layerType)
</ins><span class="cx"> {
</span><span class="cx">     if (!factory)
</span><del>-        return std::make_unique<CoordinatedGraphicsLayer>(layerType, client);
</del><ins>+        return adoptRef(*new CoordinatedGraphicsLayer(layerType, client));
</ins><span class="cx"> 
</span><span class="cx">     return factory->createGraphicsLayer(layerType, client);
</span><span class="cx"> }
</span><span class="lines">@@ -97,7 +97,7 @@
</span><span class="cx"> {
</span><span class="cx">     m_shouldUpdateVisibleRect = true;
</span><span class="cx">     for (auto& child : children())
</span><del>-        downcast<CoordinatedGraphicsLayer>(*child).setShouldUpdateVisibleRect();
</del><ins>+        downcast<CoordinatedGraphicsLayer>(child.get()).setShouldUpdateVisibleRect();
</ins><span class="cx">     if (replicaLayer())
</span><span class="cx">         downcast<CoordinatedGraphicsLayer>(*replicaLayer()).setShouldUpdateVisibleRect();
</span><span class="cx"> }
</span><span class="lines">@@ -158,9 +158,9 @@
</span><span class="cx">     return id();
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-bool CoordinatedGraphicsLayer::setChildren(const Vector<GraphicsLayer*>& children)
</del><ins>+bool CoordinatedGraphicsLayer::setChildren(Vector<Ref<GraphicsLayer>>&& children)
</ins><span class="cx"> {
</span><del>-    bool ok = GraphicsLayer::setChildren(children);
</del><ins>+    bool ok = GraphicsLayer::setChildren(WTFMove(children));
</ins><span class="cx">     if (!ok)
</span><span class="cx">         return false;
</span><span class="cx">     didChangeChildren();
</span><span class="lines">@@ -167,40 +167,45 @@
</span><span class="cx">     return true;
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-void CoordinatedGraphicsLayer::addChild(GraphicsLayer* layer)
</del><ins>+void CoordinatedGraphicsLayer::addChild(Ref<GraphicsLayer>&& layer)
</ins><span class="cx"> {
</span><del>-    GraphicsLayer::addChild(layer);
-    downcast<CoordinatedGraphicsLayer>(*layer).setCoordinatorIncludingSubLayersIfNeeded(m_coordinator);
</del><ins>+    GraphicsLayer* rawLayer = layer.ptr();
+    GraphicsLayer::addChild(WTFMove(layer));
+    downcast<CoordinatedGraphicsLayer>(*rawLayer).setCoordinatorIncludingSubLayersIfNeeded(m_coordinator);
</ins><span class="cx">     didChangeChildren();
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-void CoordinatedGraphicsLayer::addChildAtIndex(GraphicsLayer* layer, int index)
</del><ins>+void CoordinatedGraphicsLayer::addChildAtIndex(Ref<GraphicsLayer>&& layer, int index)
</ins><span class="cx"> {
</span><del>-    GraphicsLayer::addChildAtIndex(layer, index);
-    downcast<CoordinatedGraphicsLayer>(*layer).setCoordinatorIncludingSubLayersIfNeeded(m_coordinator);
</del><ins>+    GraphicsLayer* rawLayer = layer.ptr();
+    GraphicsLayer::addChildAtIndex(WTFMove(layer), index);
+    downcast<CoordinatedGraphicsLayer>(*rawLayer).setCoordinatorIncludingSubLayersIfNeeded(m_coordinator);
</ins><span class="cx">     didChangeChildren();
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-void CoordinatedGraphicsLayer::addChildAbove(GraphicsLayer* layer, GraphicsLayer* sibling)
</del><ins>+void CoordinatedGraphicsLayer::addChildAbove(Ref<GraphicsLayer>&& layer, GraphicsLayer* sibling)
</ins><span class="cx"> {
</span><del>-    GraphicsLayer::addChildAbove(layer, sibling);
-    downcast<CoordinatedGraphicsLayer>(*layer).setCoordinatorIncludingSubLayersIfNeeded(m_coordinator);
</del><ins>+    GraphicsLayer* rawLayer = layer.ptr();
+    GraphicsLayer::addChildAbove(WTFMove(layer), sibling);
+    downcast<CoordinatedGraphicsLayer>(*rawLayer).setCoordinatorIncludingSubLayersIfNeeded(m_coordinator);
</ins><span class="cx">     didChangeChildren();
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-void CoordinatedGraphicsLayer::addChildBelow(GraphicsLayer* layer, GraphicsLayer* sibling)
</del><ins>+void CoordinatedGraphicsLayer::addChildBelow(Ref<GraphicsLayer>&& layer, GraphicsLayer* sibling)
</ins><span class="cx"> {
</span><del>-    GraphicsLayer::addChildBelow(layer, sibling);
-    downcast<CoordinatedGraphicsLayer>(*layer).setCoordinatorIncludingSubLayersIfNeeded(m_coordinator);
</del><ins>+    GraphicsLayer* rawLayer = layer.ptr();
+    GraphicsLayer::addChildBelow(WTFMove(layer), sibling);
+    downcast<CoordinatedGraphicsLayer>(*rawLayer).setCoordinatorIncludingSubLayersIfNeeded(m_coordinator);
</ins><span class="cx">     didChangeChildren();
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-bool CoordinatedGraphicsLayer::replaceChild(GraphicsLayer* oldChild, GraphicsLayer* newChild)
</del><ins>+bool CoordinatedGraphicsLayer::replaceChild(GraphicsLayer* oldChild, Ref<GraphicsLayer>&& newChild)
</ins><span class="cx"> {
</span><del>-    bool ok = GraphicsLayer::replaceChild(oldChild, newChild);
</del><ins>+    GraphicsLayer* rawLayer = newChild.ptr();
+    bool ok = GraphicsLayer::replaceChild(oldChild, WTFMove(newChild));
</ins><span class="cx">     if (!ok)
</span><span class="cx">         return false;
</span><del>-    downcast<CoordinatedGraphicsLayer>(*newChild).setCoordinatorIncludingSubLayersIfNeeded(m_coordinator);
</del><ins>+    downcast<CoordinatedGraphicsLayer>(*rawLayer).setCoordinatorIncludingSubLayersIfNeeded(m_coordinator);
</ins><span class="cx">     didChangeChildren();
</span><span class="cx">     return true;
</span><span class="cx"> }
</span><span class="lines">@@ -495,18 +500,19 @@
</span><span class="cx">     notifyFlushRequired();
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-void CoordinatedGraphicsLayer::setMaskLayer(GraphicsLayer* layer)
</del><ins>+void CoordinatedGraphicsLayer::setMaskLayer(RefPtr<GraphicsLayer>&& layer)
</ins><span class="cx"> {
</span><span class="cx">     if (layer == maskLayer())
</span><span class="cx">         return;
</span><span class="cx"> 
</span><del>-    GraphicsLayer::setMaskLayer(layer);
</del><ins>+    GraphicsLayer* rawLayer = layer.get();
+    GraphicsLayer::setMaskLayer(WTFMove(layer));
</ins><span class="cx"> 
</span><del>-    if (!layer)
</del><ins>+    if (!rawLayer)
</ins><span class="cx">         return;
</span><span class="cx"> 
</span><del>-    layer->setSize(size());
-    layer->setContentsVisible(contentsAreVisible());
</del><ins>+    rawLayer->setSize(size());
+    rawLayer->setContentsVisible(contentsAreVisible());
</ins><span class="cx"> 
</span><span class="cx">     m_nicosia.delta.maskChanged = true;
</span><span class="cx"> 
</span><span class="lines">@@ -732,9 +738,9 @@
</span><span class="cx"> 
</span><span class="cx">                 if (localDelta.childrenChanged) {
</span><span class="cx">                     state.children = WTF::map(children(),
</span><del>-                        [](auto* child)
</del><ins>+                        [](auto& child)
</ins><span class="cx">                         {
</span><del>-                            return downcast<CoordinatedGraphicsLayer>(child)->m_nicosia.layer;
</del><ins>+                            return downcast<CoordinatedGraphicsLayer>(child.get()).m_nicosia.layer;
</ins><span class="cx">                         });
</span><span class="cx">                 }
</span><span class="cx"> 
</span><span class="lines">@@ -784,7 +790,7 @@
</span><span class="cx">         downcast<CoordinatedGraphicsLayer>(*maskLayer()).syncPendingStateChangesIncludingSubLayers();
</span><span class="cx"> 
</span><span class="cx">     for (auto& child : children())
</span><del>-        downcast<CoordinatedGraphicsLayer>(*child).syncPendingStateChangesIncludingSubLayers();
</del><ins>+        downcast<CoordinatedGraphicsLayer>(child.get()).syncPendingStateChangesIncludingSubLayers();
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void CoordinatedGraphicsLayer::deviceOrPageScaleFactorChanged()
</span><span class="lines">@@ -837,7 +843,7 @@
</span><span class="cx">     updateContentBuffers();
</span><span class="cx"> 
</span><span class="cx">     for (auto& child : children())
</span><del>-        downcast<CoordinatedGraphicsLayer>(*child).updateContentBuffersIncludingSubLayers();
</del><ins>+        downcast<CoordinatedGraphicsLayer>(child.get()).updateContentBuffersIncludingSubLayers();
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void CoordinatedGraphicsLayer::updateContentBuffers()
</span><span class="lines">@@ -1007,7 +1013,7 @@
</span><span class="cx"> 
</span><span class="cx">     coordinator->attachLayer(this);
</span><span class="cx">     for (auto& child : children())
</span><del>-        downcast<CoordinatedGraphicsLayer>(*child).setCoordinatorIncludingSubLayersIfNeeded(coordinator);
</del><ins>+        downcast<CoordinatedGraphicsLayer>(child.get()).setCoordinatorIncludingSubLayersIfNeeded(coordinator);
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> const RefPtr<Nicosia::CompositionLayer>& CoordinatedGraphicsLayer::compositionLayer() const
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformgraphicstexmapcoordinatedCoordinatedGraphicsLayerh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/graphics/texmap/coordinated/CoordinatedGraphicsLayer.h (235952 => 235953)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/graphics/texmap/coordinated/CoordinatedGraphicsLayer.h     2018-09-12 21:23:40 UTC (rev 235952)
+++ trunk/Source/WebCore/platform/graphics/texmap/coordinated/CoordinatedGraphicsLayer.h        2018-09-12 21:27:07 UTC (rev 235953)
</span><span class="lines">@@ -63,12 +63,12 @@
</span><span class="cx">     PlatformLayerID primaryLayerID() const override;
</span><span class="cx"> 
</span><span class="cx">     // Reimplementations from GraphicsLayer.h.
</span><del>-    bool setChildren(const Vector<GraphicsLayer*>&) override;
-    void addChild(GraphicsLayer*) override;
-    void addChildAtIndex(GraphicsLayer*, int) override;
-    void addChildAbove(GraphicsLayer*, GraphicsLayer*) override;
-    void addChildBelow(GraphicsLayer*, GraphicsLayer*) override;
-    bool replaceChild(GraphicsLayer*, GraphicsLayer*) override;
</del><ins>+    bool setChildren(Vector<Ref<GraphicsLayer>>&&) override;
+    void addChild(Ref<GraphicsLayer>&&) override;
+    void addChildAtIndex(Ref<GraphicsLayer>&&, int) override;
+    void addChildAbove(Ref<GraphicsLayer>&&, GraphicsLayer*) override;
+    void addChildBelow(Ref<GraphicsLayer>&&, GraphicsLayer*) override;
+    bool replaceChild(GraphicsLayer*, Ref<GraphicsLayer>&&) override;
</ins><span class="cx">     void removeFromParent() override;
</span><span class="cx">     void setPosition(const FloatPoint&) override;
</span><span class="cx">     void setAnchorPoint(const FloatPoint3D&) override;
</span><span class="lines">@@ -91,7 +91,7 @@
</span><span class="cx">     void setShowRepaintCounter(bool) override;
</span><span class="cx">     bool shouldDirectlyCompositeImage(Image*) const override;
</span><span class="cx">     void setContentsToPlatformLayer(PlatformLayer*, ContentsLayerPurpose) override;
</span><del>-    void setMaskLayer(GraphicsLayer*) override;
</del><ins>+    void setMaskLayer(RefPtr<GraphicsLayer>&&) override;
</ins><span class="cx">     void setReplicatedByLayer(GraphicsLayer*) override;
</span><span class="cx">     void setNeedsDisplay() override;
</span><span class="cx">     void setNeedsDisplayInRect(const FloatRect&, ShouldClipToLayer = ClipToLayer) override;
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformgraphicswinGraphicsLayerDirect2Dcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/graphics/win/GraphicsLayerDirect2D.cpp (235952 => 235953)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/graphics/win/GraphicsLayerDirect2D.cpp     2018-09-12 21:23:40 UTC (rev 235952)
+++ trunk/Source/WebCore/platform/graphics/win/GraphicsLayerDirect2D.cpp        2018-09-12 21:27:07 UTC (rev 235953)
</span><span class="lines">@@ -46,18 +46,17 @@
</span><span class="cx"> 
</span><span class="cx"> namespace WebCore {
</span><span class="cx"> 
</span><del>-
-std::unique_ptr<GraphicsLayer> GraphicsLayer::create(GraphicsLayerFactory* factory, GraphicsLayerClient& client, Type layerType)
</del><ins>+Ref<GraphicsLayer> GraphicsLayer::create(GraphicsLayerFactory* factory, GraphicsLayerClient& client, Type layerType)
</ins><span class="cx"> {
</span><del>-    std::unique_ptr<GraphicsLayer> graphicsLayer;
-    if (!factory)
-        graphicsLayer = std::make_unique<GraphicsLayerDirect2D>(layerType, client);
-    else
-        graphicsLayer = factory->createGraphicsLayer(layerType, client);
-
-    graphicsLayer->initialize(layerType);
-
-    return graphicsLayer;
</del><ins>+    if (factory) {
+        auto layer = factory->createGraphicsLayer(layerType, client);
+        layer->initialize(layerType);
+        return layer;
+    }
+    
+    auto layer = adoptRef(*new GraphicsLayerCA(layerType, client);
+    layer->initialize(layerType);
+    return layer;
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> GraphicsLayerDirect2D::GraphicsLayerDirect2D(Type layerType, GraphicsLayerClient& client)
</span></span></pre></div>
<a id="trunkSourceWebCorerenderingRenderLayerBackingcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/rendering/RenderLayerBacking.cpp (235952 => 235953)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/rendering/RenderLayerBacking.cpp    2018-09-12 21:23:40 UTC (rev 235952)
+++ trunk/Source/WebCore/rendering/RenderLayerBacking.cpp       2018-09-12 21:27:07 UTC (rev 235953)
</span><span class="lines">@@ -254,11 +254,11 @@
</span><span class="cx">         compositor().layerTiledBackingUsageChanged(layer, false);
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-std::unique_ptr<GraphicsLayer> RenderLayerBacking::createGraphicsLayer(const String& name, GraphicsLayer::Type layerType)
</del><ins>+Ref<GraphicsLayer> RenderLayerBacking::createGraphicsLayer(const String& name, GraphicsLayer::Type layerType)
</ins><span class="cx"> {
</span><span class="cx">     auto* graphicsLayerFactory = renderer().page().chrome().client().graphicsLayerFactory();
</span><span class="cx"> 
</span><del>-    std::unique_ptr<GraphicsLayer> graphicsLayer = GraphicsLayer::create(graphicsLayerFactory, *this, layerType);
</del><ins>+    auto graphicsLayer = GraphicsLayer::create(graphicsLayerFactory, *this, layerType);
</ins><span class="cx"> 
</span><span class="cx">     graphicsLayer->setName(name);
</span><span class="cx"> 
</span><span class="lines">@@ -401,7 +401,7 @@
</span><span class="cx"> 
</span><span class="cx">     if (m_isFrameLayerWithTiledBacking) {
</span><span class="cx">         m_childContainmentLayer = createGraphicsLayer("Page TiledBacking containment");
</span><del>-        m_graphicsLayer->addChild(m_childContainmentLayer.get());
</del><ins>+        m_graphicsLayer->addChild(*m_childContainmentLayer);
</ins><span class="cx">     }
</span><span class="cx"> 
</span><span class="cx"> #if !PLATFORM(IOS)
</span><span class="lines">@@ -709,7 +709,7 @@
</span><span class="cx"> 
</span><span class="cx">     if (auto* flatteningLayer = tileCacheFlatteningLayer()) {
</span><span class="cx">         if (layerConfigChanged || flatteningLayer->parent() != m_graphicsLayer.get())
</span><del>-            m_graphicsLayer->addChild(flatteningLayer);
</del><ins>+            m_graphicsLayer->addChild(*flatteningLayer);
</ins><span class="cx">     }
</span><span class="cx"> 
</span><span class="cx">     updateMaskingLayer(renderer().hasMask(), renderer().hasClipPath());
</span><span class="lines">@@ -1302,26 +1302,26 @@
</span><span class="cx">     if (m_contentsContainmentLayer) {
</span><span class="cx">         m_contentsContainmentLayer->removeAllChildren();
</span><span class="cx">         if (m_ancestorClippingLayer)
</span><del>-            m_ancestorClippingLayer->addChild(m_contentsContainmentLayer.get());
</del><ins>+            m_ancestorClippingLayer->addChild(*m_contentsContainmentLayer);
</ins><span class="cx">     }
</span><span class="cx">     
</span><span class="cx">     if (m_backgroundLayer)
</span><del>-        m_contentsContainmentLayer->addChild(m_backgroundLayer.get());
</del><ins>+        m_contentsContainmentLayer->addChild(*m_backgroundLayer);
</ins><span class="cx"> 
</span><span class="cx">     if (m_contentsContainmentLayer)
</span><del>-        m_contentsContainmentLayer->addChild(m_graphicsLayer.get());
</del><ins>+        m_contentsContainmentLayer->addChild(*m_graphicsLayer);
</ins><span class="cx">     else if (m_ancestorClippingLayer)
</span><del>-        m_ancestorClippingLayer->addChild(m_graphicsLayer.get());
</del><ins>+        m_ancestorClippingLayer->addChild(*m_graphicsLayer);
</ins><span class="cx"> 
</span><span class="cx">     if (m_childContainmentLayer) {
</span><span class="cx">         m_childContainmentLayer->removeFromParent();
</span><del>-        m_graphicsLayer->addChild(m_childContainmentLayer.get());
</del><ins>+        m_graphicsLayer->addChild(*m_childContainmentLayer);
</ins><span class="cx">     }
</span><span class="cx"> 
</span><span class="cx">     if (m_scrollingLayer) {
</span><span class="cx">         auto* superlayer = m_childContainmentLayer ? m_childContainmentLayer.get() : m_graphicsLayer.get();
</span><span class="cx">         m_scrollingLayer->removeFromParent();
</span><del>-        superlayer->addChild(m_scrollingLayer.get());
</del><ins>+        superlayer->addChild(*m_scrollingLayer);
</ins><span class="cx">     }
</span><span class="cx"> 
</span><span class="cx">     // The clip for child layers does not include space for overflow controls, so they exist as
</span><span class="lines">@@ -1329,15 +1329,15 @@
</span><span class="cx">     // children of the clipping layer.
</span><span class="cx">     if (m_layerForHorizontalScrollbar) {
</span><span class="cx">         m_layerForHorizontalScrollbar->removeFromParent();
</span><del>-        m_graphicsLayer->addChild(m_layerForHorizontalScrollbar.get());
</del><ins>+        m_graphicsLayer->addChild(*m_layerForHorizontalScrollbar);
</ins><span class="cx">     }
</span><span class="cx">     if (m_layerForVerticalScrollbar) {
</span><span class="cx">         m_layerForVerticalScrollbar->removeFromParent();
</span><del>-        m_graphicsLayer->addChild(m_layerForVerticalScrollbar.get());
</del><ins>+        m_graphicsLayer->addChild(*m_layerForVerticalScrollbar);
</ins><span class="cx">     }
</span><span class="cx">     if (m_layerForScrollCorner) {
</span><span class="cx">         m_layerForScrollCorner->removeFromParent();
</span><del>-        m_graphicsLayer->addChild(m_layerForScrollCorner.get());
</del><ins>+        m_graphicsLayer->addChild(*m_layerForScrollCorner);
</ins><span class="cx">     }
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="lines">@@ -1690,7 +1690,7 @@
</span><span class="cx">             m_maskLayer->setDrawsContent(paintsContent);
</span><span class="cx">             m_maskLayer->setPaintingPhase(maskPhases);
</span><span class="cx">             layerChanged = true;
</span><del>-            m_graphicsLayer->setMaskLayer(m_maskLayer.get());
</del><ins>+            m_graphicsLayer->setMaskLayer(m_maskLayer.copyRef());
</ins><span class="cx">         }
</span><span class="cx">     } else if (m_maskLayer) {
</span><span class="cx">         m_graphicsLayer->setMaskLayer(nullptr);
</span><span class="lines">@@ -1721,7 +1721,7 @@
</span><span class="cx">                 m_childClippingMaskLayer = createGraphicsLayer("child clipping mask");
</span><span class="cx">                 m_childClippingMaskLayer->setDrawsContent(true);
</span><span class="cx">                 m_childClippingMaskLayer->setPaintingPhase(GraphicsLayerPaintChildClippingMask);
</span><del>-                clippingLayer()->setMaskLayer(m_childClippingMaskLayer.get());
</del><ins>+                clippingLayer()->setMaskLayer(m_childClippingMaskLayer.copyRef());
</ins><span class="cx">             }
</span><span class="cx">         }
</span><span class="cx">     } else {
</span><span class="lines">@@ -1754,7 +1754,7 @@
</span><span class="cx">         if (!m_foregroundLayer)
</span><span class="cx">             paintPhase |= GraphicsLayerPaintForeground;
</span><span class="cx">         m_scrollingContentsLayer->setPaintingPhase(paintPhase);
</span><del>-        m_scrollingLayer->addChild(m_scrollingContentsLayer.get());
</del><ins>+        m_scrollingLayer->addChild(*m_scrollingContentsLayer);
</ins><span class="cx">     } else {
</span><span class="cx">         compositor().willRemoveScrollingLayerWithBacking(m_owningLayer, *this);
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceWebCorerenderingRenderLayerBackingh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/rendering/RenderLayerBacking.h (235952 => 235953)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/rendering/RenderLayerBacking.h      2018-09-12 21:23:40 UTC (rev 235952)
+++ trunk/Source/WebCore/rendering/RenderLayerBacking.h 2018-09-12 21:27:07 UTC (rev 235953)
</span><span class="lines">@@ -136,7 +136,7 @@
</span><span class="cx"> 
</span><span class="cx">     void setIsScrollCoordinatedWithViewportConstrainedRole(bool);
</span><span class="cx"> 
</span><del>-    bool hasMaskLayer() const { return m_maskLayer != 0; }
</del><ins>+    bool hasMaskLayer() const { return m_maskLayer; }
</ins><span class="cx">     bool hasChildClippingMaskLayer() const { return m_childClippingMaskLayer != nullptr; }
</span><span class="cx"> 
</span><span class="cx">     GraphicsLayer* parentForSublayers() const;
</span><span class="lines">@@ -267,7 +267,7 @@
</span><span class="cx"> 
</span><span class="cx">     LayoutRect compositedBoundsIncludingMargin() const;
</span><span class="cx">     
</span><del>-    std::unique_ptr<GraphicsLayer> createGraphicsLayer(const String&, GraphicsLayer::Type = GraphicsLayer::Type::Normal);
</del><ins>+    Ref<GraphicsLayer> createGraphicsLayer(const String&, GraphicsLayer::Type = GraphicsLayer::Type::Normal);
</ins><span class="cx"> 
</span><span class="cx">     RenderLayerModelObject& renderer() const { return m_owningLayer.renderer(); }
</span><span class="cx">     RenderBox* renderBox() const { return m_owningLayer.renderBox(); }
</span><span class="lines">@@ -355,21 +355,21 @@
</span><span class="cx"> 
</span><span class="cx">     RenderLayer& m_owningLayer;
</span><span class="cx"> 
</span><del>-    std::unique_ptr<GraphicsLayer> m_ancestorClippingLayer; // Only used if we are clipped by an ancestor which is not a stacking context.
-    std::unique_ptr<GraphicsLayer> m_contentsContainmentLayer; // Only used if we have a background layer; takes the transform.
-    std::unique_ptr<GraphicsLayer> m_graphicsLayer;
-    std::unique_ptr<GraphicsLayer> m_foregroundLayer; // Only used in cases where we need to draw the foreground separately.
-    std::unique_ptr<GraphicsLayer> m_backgroundLayer; // Only used in cases where we need to draw the background separately.
-    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.
-    std::unique_ptr<GraphicsLayer> m_maskLayer; // Only used if we have a mask and/or clip-path.
-    std::unique_ptr<GraphicsLayer> m_childClippingMaskLayer; // Only used if we have to clip child layers or accelerated contents with border radius or clip-path.
</del><ins>+    RefPtr<GraphicsLayer> m_ancestorClippingLayer; // Only used if we are clipped by an ancestor which is not a stacking context.
+    RefPtr<GraphicsLayer> m_contentsContainmentLayer; // Only used if we have a background layer; takes the transform.
+    RefPtr<GraphicsLayer> m_graphicsLayer;
+    RefPtr<GraphicsLayer> m_foregroundLayer; // Only used in cases where we need to draw the foreground separately.
+    RefPtr<GraphicsLayer> m_backgroundLayer; // Only used in cases where we need to draw the background separately.
+    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.
+    RefPtr<GraphicsLayer> m_maskLayer; // Only used if we have a mask and/or clip-path.
+    RefPtr<GraphicsLayer> m_childClippingMaskLayer; // Only used if we have to clip child layers or accelerated contents with border radius or clip-path.
</ins><span class="cx"> 
</span><del>-    std::unique_ptr<GraphicsLayer> m_layerForHorizontalScrollbar;
-    std::unique_ptr<GraphicsLayer> m_layerForVerticalScrollbar;
-    std::unique_ptr<GraphicsLayer> m_layerForScrollCorner;
</del><ins>+    RefPtr<GraphicsLayer> m_layerForHorizontalScrollbar;
+    RefPtr<GraphicsLayer> m_layerForVerticalScrollbar;
+    RefPtr<GraphicsLayer> m_layerForScrollCorner;
</ins><span class="cx"> 
</span><del>-    std::unique_ptr<GraphicsLayer> m_scrollingLayer; // Only used if the layer is using composited scrolling.
-    std::unique_ptr<GraphicsLayer> m_scrollingContentsLayer; // Only used if the layer is using composited scrolling.
</del><ins>+    RefPtr<GraphicsLayer> m_scrollingLayer; // Only used if the layer is using composited scrolling.
+    RefPtr<GraphicsLayer> m_scrollingContentsLayer; // Only used if the layer is using composited scrolling.
</ins><span class="cx"> 
</span><span class="cx">     LayoutRect m_compositedBounds;
</span><span class="cx">     LayoutSize m_subpixelOffsetFromRenderer; // This is the subpixel distance between the primary graphics layer and the associated renderer's bounds.
</span></span></pre></div>
<a id="trunkSourceWebCorerenderingRenderLayerCompositorcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/rendering/RenderLayerCompositor.cpp (235952 => 235953)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/rendering/RenderLayerCompositor.cpp 2018-09-12 21:23:40 UTC (rev 235952)
+++ trunk/Source/WebCore/rendering/RenderLayerCompositor.cpp    2018-09-12 21:27:07 UTC (rev 235953)
</span><span class="lines">@@ -758,7 +758,7 @@
</span><span class="cx"> 
</span><span class="cx">     if (needHierarchyUpdate) {
</span><span class="cx">         // Update the hierarchy of the compositing layers.
</span><del>-        Vector<GraphicsLayer*> childList;
</del><ins>+        Vector<Ref<GraphicsLayer>> childList;
</ins><span class="cx">         rebuildCompositingLayerTree(*updateRoot, childList, 0);
</span><span class="cx"> 
</span><span class="cx">         // Host the document layer in the RenderView's root layer.
</span><span class="lines">@@ -769,7 +769,7 @@
</span><span class="cx">             if (childList.isEmpty() && !hasAnyAdditionalCompositedLayers(*updateRoot))
</span><span class="cx">                 destroyRootLayer();
</span><span class="cx">             else if (m_rootContentLayer)
</span><del>-                m_rootContentLayer->setChildren(childList);
</del><ins>+                m_rootContentLayer->setChildren(WTFMove(childList));
</ins><span class="cx">         }
</span><span class="cx">         
</span><span class="cx">         reattachSubframeScrollLayers();
</span><span class="lines">@@ -802,12 +802,13 @@
</span><span class="cx">     return true;
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-void RenderLayerCompositor::appendDocumentOverlayLayers(Vector<GraphicsLayer*>& childList)
</del><ins>+void RenderLayerCompositor::appendDocumentOverlayLayers(Vector<Ref<GraphicsLayer>>& childList)
</ins><span class="cx"> {
</span><span class="cx">     if (!isMainFrameCompositor() || !m_compositing)
</span><span class="cx">         return;
</span><span class="cx"> 
</span><del>-    childList.append(&page().pageOverlayController().layerWithDocumentOverlays());
</del><ins>+    Ref<GraphicsLayer> overlayHost = page().pageOverlayController().layerWithDocumentOverlays();
+    childList.append(WTFMove(overlayHost));
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void RenderLayerCompositor::layerBecameNonComposited(const RenderLayer& layer)
</span><span class="lines">@@ -1523,7 +1524,7 @@
</span><span class="cx">         auto* hostingLayer = parentLayer->backing()->parentForSublayers();
</span><span class="cx">         auto* hostedLayer = childLayer.backing()->childForSuperlayers();
</span><span class="cx">         
</span><del>-        hostingLayer->addChild(hostedLayer);
</del><ins>+        hostingLayer->addChild(*hostedLayer);
</ins><span class="cx">     } else
</span><span class="cx">         childLayer.backing()->childForSuperlayers()->removeFromParent();
</span><span class="cx"> }
</span><span class="lines">@@ -1545,7 +1546,7 @@
</span><span class="cx"> }
</span><span class="cx"> #endif
</span><span class="cx"> 
</span><del>-void RenderLayerCompositor::rebuildCompositingLayerTree(RenderLayer& layer, Vector<GraphicsLayer*>& childLayersOfEnclosingLayer, int depth)
</del><ins>+void RenderLayerCompositor::rebuildCompositingLayerTree(RenderLayer& layer, Vector<Ref<GraphicsLayer>>& childLayersOfEnclosingLayer, int depth)
</ins><span class="cx"> {
</span><span class="cx">     // Make the layer compositing if necessary, and set up clipping and content layers.
</span><span class="cx">     // Note that we can only do work here that is independent of whether the descendant layers
</span><span class="lines">@@ -1581,8 +1582,8 @@
</span><span class="cx"> 
</span><span class="cx">     // If this layer has backing, then we are collecting its children, otherwise appending
</span><span class="cx">     // to the compositing child list of an enclosing layer.
</span><del>-    Vector<GraphicsLayer*> layerChildren;
-    Vector<GraphicsLayer*>& childList = layerBacking ? layerChildren : childLayersOfEnclosingLayer;
</del><ins>+    Vector<Ref<GraphicsLayer>> layerChildren;
+    auto& childList = layerBacking ? layerChildren : childLayersOfEnclosingLayer;
</ins><span class="cx"> 
</span><span class="cx"> #if !ASSERT_DISABLED
</span><span class="cx">     LayerListMutationDetector mutationChecker(&layer);
</span><span class="lines">@@ -1594,7 +1595,7 @@
</span><span class="cx"> 
</span><span class="cx">         // If a negative z-order child is compositing, we get a foreground layer which needs to get parented.
</span><span class="cx">         if (layerBacking && layerBacking->foregroundLayer())
</span><del>-            childList.append(layerBacking->foregroundLayer());
</del><ins>+            childList.append(*layerBacking->foregroundLayer());
</ins><span class="cx">     }
</span><span class="cx"> 
</span><span class="cx">     if (auto* normalFlowList = layer.normalFlowList()) {
</span><span class="lines">@@ -1613,7 +1614,7 @@
</span><span class="cx">             parented = parentFrameContentLayers(&downcast<RenderWidget>(layer.renderer()));
</span><span class="cx"> 
</span><span class="cx">         if (!parented)
</span><del>-            layerBacking->parentForSublayers()->setChildren(layerChildren);
</del><ins>+            layerBacking->parentForSublayers()->setChildren(WTFMove(layerChildren));
</ins><span class="cx"> 
</span><span class="cx">         // If the layer has a clipping layer the overflow controls layers will be siblings of the clipping layer.
</span><span class="cx">         // Otherwise, the overflow control layers are normal children.
</span><span class="lines">@@ -1620,21 +1621,21 @@
</span><span class="cx">         if (!layerBacking->hasClippingLayer() && !layerBacking->hasScrollingLayer()) {
</span><span class="cx">             if (auto* overflowControlLayer = layerBacking->layerForHorizontalScrollbar()) {
</span><span class="cx">                 overflowControlLayer->removeFromParent();
</span><del>-                layerBacking->parentForSublayers()->addChild(overflowControlLayer);
</del><ins>+                layerBacking->parentForSublayers()->addChild(*overflowControlLayer);
</ins><span class="cx">             }
</span><span class="cx"> 
</span><span class="cx">             if (auto* overflowControlLayer = layerBacking->layerForVerticalScrollbar()) {
</span><span class="cx">                 overflowControlLayer->removeFromParent();
</span><del>-                layerBacking->parentForSublayers()->addChild(overflowControlLayer);
</del><ins>+                layerBacking->parentForSublayers()->addChild(*overflowControlLayer);
</ins><span class="cx">             }
</span><span class="cx"> 
</span><span class="cx">             if (auto* overflowControlLayer = layerBacking->layerForScrollCorner()) {
</span><span class="cx">                 overflowControlLayer->removeFromParent();
</span><del>-                layerBacking->parentForSublayers()->addChild(overflowControlLayer);
</del><ins>+                layerBacking->parentForSublayers()->addChild(*overflowControlLayer);
</ins><span class="cx">             }
</span><span class="cx">         }
</span><span class="cx"> 
</span><del>-        childLayersOfEnclosingLayer.append(layerBacking->childForSuperlayers());
</del><ins>+        childLayersOfEnclosingLayer.append(*layerBacking->childForSuperlayers());
</ins><span class="cx">     }
</span><span class="cx">     
</span><span class="cx">     if (auto* layerBacking = layer.backing())
</span><span class="lines">@@ -1809,9 +1810,9 @@
</span><span class="cx">     auto* backing = layer->backing();
</span><span class="cx">     auto* hostingLayer = backing->parentForSublayers();
</span><span class="cx">     auto* rootLayer = innerCompositor->rootGraphicsLayer();
</span><del>-    if (hostingLayer->children().size() != 1 || hostingLayer->children()[0] != rootLayer) {
</del><ins>+    if (hostingLayer->children().size() != 1 || hostingLayer->children()[0].ptr() != rootLayer) {
</ins><span class="cx">         hostingLayer->removeAllChildren();
</span><del>-        hostingLayer->addChild(rootLayer);
</del><ins>+        hostingLayer->addChild(*rootLayer);
</ins><span class="cx">     }
</span><span class="cx">     return true;
</span><span class="cx"> }
</span><span class="lines">@@ -3046,7 +3047,7 @@
</span><span class="cx">     if (!m_layerForTopOverhangArea) {
</span><span class="cx">         m_layerForTopOverhangArea = GraphicsLayer::create(graphicsLayerFactory(), *this);
</span><span class="cx">         m_layerForTopOverhangArea->setName("top overhang");
</span><del>-        m_scrollLayer->addChildBelow(m_layerForTopOverhangArea.get(), m_rootContentLayer.get());
</del><ins>+        m_scrollLayer->addChildBelow(*m_layerForTopOverhangArea, m_rootContentLayer.get());
</ins><span class="cx">     }
</span><span class="cx"> 
</span><span class="cx">     return m_layerForTopOverhangArea.get();
</span><span class="lines">@@ -3068,7 +3069,7 @@
</span><span class="cx">     if (!m_layerForBottomOverhangArea) {
</span><span class="cx">         m_layerForBottomOverhangArea = GraphicsLayer::create(graphicsLayerFactory(), *this);
</span><span class="cx">         m_layerForBottomOverhangArea->setName("bottom overhang");
</span><del>-        m_scrollLayer->addChildBelow(m_layerForBottomOverhangArea.get(), m_rootContentLayer.get());
</del><ins>+        m_scrollLayer->addChildBelow(*m_layerForBottomOverhangArea, m_rootContentLayer.get());
</ins><span class="cx">     }
</span><span class="cx"> 
</span><span class="cx">     m_layerForBottomOverhangArea->setPosition(FloatPoint(0, m_rootContentLayer->size().height() + m_renderView.frameView().headerHeight()
</span><span class="lines">@@ -3097,7 +3098,7 @@
</span><span class="cx">     if (!m_layerForHeader) {
</span><span class="cx">         m_layerForHeader = GraphicsLayer::create(graphicsLayerFactory(), *this);
</span><span class="cx">         m_layerForHeader->setName("header");
</span><del>-        m_scrollLayer->addChildAbove(m_layerForHeader.get(), m_rootContentLayer.get());
</del><ins>+        m_scrollLayer->addChildAbove(*m_layerForHeader, m_rootContentLayer.get());
</ins><span class="cx">         m_renderView.frameView().addPaintPendingMilestones(DidFirstFlushForHeaderLayer);
</span><span class="cx">     }
</span><span class="cx"> 
</span><span class="lines">@@ -3135,7 +3136,7 @@
</span><span class="cx">     if (!m_layerForFooter) {
</span><span class="cx">         m_layerForFooter = GraphicsLayer::create(graphicsLayerFactory(), *this);
</span><span class="cx">         m_layerForFooter->setName("footer");
</span><del>-        m_scrollLayer->addChildAbove(m_layerForFooter.get(), m_rootContentLayer.get());
</del><ins>+        m_scrollLayer->addChildAbove(*m_layerForFooter, m_rootContentLayer.get());
</ins><span class="cx">     }
</span><span class="cx"> 
</span><span class="cx">     float totalContentHeight = m_rootContentLayer->size().height() + m_renderView.frameView().headerHeight() + m_renderView.frameView().footerHeight();
</span><span class="lines">@@ -3258,7 +3259,7 @@
</span><span class="cx"> 
</span><span class="cx">             // We want the overhang areas layer to be positioned below the frame contents,
</span><span class="cx">             // so insert it below the clip layer.
</span><del>-            m_overflowControlsHostLayer->addChildBelow(m_layerForOverhangAreas.get(), m_clipLayer.get());
</del><ins>+            m_overflowControlsHostLayer->addChildBelow(*m_layerForOverhangAreas, m_clipLayer.get());
</ins><span class="cx">         }
</span><span class="cx">     } else if (m_layerForOverhangAreas) {
</span><span class="cx">         m_layerForOverhangAreas->removeFromParent();
</span><span class="lines">@@ -3274,7 +3275,7 @@
</span><span class="cx">             m_contentShadowLayer->setAnchorPoint(FloatPoint3D());
</span><span class="cx">             m_contentShadowLayer->setCustomAppearance(GraphicsLayer::CustomAppearance::ScrollingShadow);
</span><span class="cx"> 
</span><del>-            m_scrollLayer->addChildBelow(m_contentShadowLayer.get(), m_rootContentLayer.get());
</del><ins>+            m_scrollLayer->addChildBelow(*m_contentShadowLayer, m_rootContentLayer.get());
</ins><span class="cx">         }
</span><span class="cx">     } else if (m_contentShadowLayer) {
</span><span class="cx">         m_contentShadowLayer->removeFromParent();
</span><span class="lines">@@ -3291,7 +3292,7 @@
</span><span class="cx"> #if PLATFORM(COCOA) && USE(CA)
</span><span class="cx">             m_layerForHorizontalScrollbar->setAcceleratesDrawing(acceleratedDrawingEnabled());
</span><span class="cx"> #endif
</span><del>-            m_overflowControlsHostLayer->addChild(m_layerForHorizontalScrollbar.get());
</del><ins>+            m_overflowControlsHostLayer->addChild(*m_layerForHorizontalScrollbar);
</ins><span class="cx"> 
</span><span class="cx">             if (auto* scrollingCoordinator = this->scrollingCoordinator())
</span><span class="cx">                 scrollingCoordinator->scrollableAreaScrollbarLayerDidChange(m_renderView.frameView(), HorizontalScrollbar);
</span><span class="lines">@@ -3313,7 +3314,7 @@
</span><span class="cx"> #if PLATFORM(COCOA) && USE(CA)
</span><span class="cx">             m_layerForVerticalScrollbar->setAcceleratesDrawing(acceleratedDrawingEnabled());
</span><span class="cx"> #endif
</span><del>-            m_overflowControlsHostLayer->addChild(m_layerForVerticalScrollbar.get());
</del><ins>+            m_overflowControlsHostLayer->addChild(*m_layerForVerticalScrollbar);
</ins><span class="cx"> 
</span><span class="cx">             if (auto* scrollingCoordinator = this->scrollingCoordinator())
</span><span class="cx">                 scrollingCoordinator->scrollableAreaScrollbarLayerDidChange(m_renderView.frameView(), VerticalScrollbar);
</span><span class="lines">@@ -3335,7 +3336,7 @@
</span><span class="cx"> #if PLATFORM(COCOA) && USE(CA)
</span><span class="cx">             m_layerForScrollCorner->setAcceleratesDrawing(acceleratedDrawingEnabled());
</span><span class="cx"> #endif
</span><del>-            m_overflowControlsHostLayer->addChild(m_layerForScrollCorner.get());
</del><ins>+            m_overflowControlsHostLayer->addChild(*m_layerForScrollCorner);
</ins><span class="cx">         }
</span><span class="cx">     } else if (m_layerForScrollCorner) {
</span><span class="cx">         m_layerForScrollCorner->removeFromParent();
</span><span class="lines">@@ -3387,9 +3388,9 @@
</span><span class="cx">             m_scrollLayer->setName("frame scrolling");
</span><span class="cx"> 
</span><span class="cx">             // Hook them up
</span><del>-            m_overflowControlsHostLayer->addChild(m_clipLayer.get());
-            m_clipLayer->addChild(m_scrollLayer.get());
-            m_scrollLayer->addChild(m_rootContentLayer.get());
</del><ins>+            m_overflowControlsHostLayer->addChild(*m_clipLayer);
+            m_clipLayer->addChild(*m_scrollLayer);
+            m_scrollLayer->addChild(*m_rootContentLayer);
</ins><span class="cx"> 
</span><span class="cx">             m_clipLayer->setSize(m_renderView.frameView().sizeForVisibleContent());
</span><span class="cx">             m_clipLayer->setPosition(positionForClipLayer());
</span><span class="lines">@@ -3560,7 +3561,8 @@
</span><span class="cx">     if (!frame.isMainFrame())
</span><span class="cx">         return;
</span><span class="cx"> 
</span><del>-    m_rootContentLayer->addChild(&page().pageOverlayController().layerWithDocumentOverlays());
</del><ins>+    Ref<GraphicsLayer> overlayHost = page().pageOverlayController().layerWithDocumentOverlays();
+    m_rootContentLayer->addChild(WTFMove(overlayHost));
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void RenderLayerCompositor::notifyIFramesOfCompositingChange()
</span></span></pre></div>
<a id="trunkSourceWebCorerenderingRenderLayerCompositorh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/rendering/RenderLayerCompositor.h (235952 => 235953)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/rendering/RenderLayerCompositor.h   2018-09-12 21:23:40 UTC (rev 235952)
+++ trunk/Source/WebCore/rendering/RenderLayerCompositor.h      2018-09-12 21:27:07 UTC (rev 235953)
</span><span class="lines">@@ -376,7 +376,7 @@
</span><span class="cx">     void computeCompositingRequirements(RenderLayer* ancestorLayer, RenderLayer&, OverlapMap&, CompositingState&, bool& layersChanged, bool& descendantHas3DTransform);
</span><span class="cx"> 
</span><span class="cx">     // Recurses down the tree, parenting descendant compositing layers and collecting an array of child layers for the current compositing layer.
</span><del>-    void rebuildCompositingLayerTree(RenderLayer&, Vector<GraphicsLayer*>& childGraphicsLayersOfEnclosingLayer, int depth);
</del><ins>+    void rebuildCompositingLayerTree(RenderLayer&, Vector<Ref<GraphicsLayer>>& childGraphicsLayersOfEnclosingLayer, int depth);
</ins><span class="cx"> 
</span><span class="cx">     // Recurses down the tree, updating layer geometry only.
</span><span class="cx">     void updateLayerTreeGeometry(RenderLayer&, int depth);
</span><span class="lines">@@ -388,7 +388,7 @@
</span><span class="cx">     bool layerHas3DContent(const RenderLayer&) const;
</span><span class="cx">     bool isRunningTransformAnimation(RenderLayerModelObject&) const;
</span><span class="cx"> 
</span><del>-    void appendDocumentOverlayLayers(Vector<GraphicsLayer*>&);
</del><ins>+    void appendDocumentOverlayLayers(Vector<Ref<GraphicsLayer>>&);
</ins><span class="cx">     bool hasAnyAdditionalCompositedLayers(const RenderLayer& rootLayer) const;
</span><span class="cx"> 
</span><span class="cx">     void ensureRootLayer();
</span><span class="lines">@@ -488,7 +488,7 @@
</span><span class="cx"> 
</span><span class="cx"> private:
</span><span class="cx">     RenderView& m_renderView;
</span><del>-    std::unique_ptr<GraphicsLayer> m_rootContentLayer;
</del><ins>+    RefPtr<GraphicsLayer> m_rootContentLayer;
</ins><span class="cx">     Timer m_updateCompositingLayersTimer;
</span><span class="cx"> 
</span><span class="cx">     ChromeClient::CompositingTriggerFlags m_compositingTriggers { static_cast<ChromeClient::CompositingTriggerFlags>(ChromeClient::AllTriggers) };
</span><span class="lines">@@ -524,8 +524,8 @@
</span><span class="cx">     RootLayerAttachment m_rootLayerAttachment { RootLayerUnattached };
</span><span class="cx"> 
</span><span class="cx">     // Enclosing clipping layer for iframe content
</span><del>-    std::unique_ptr<GraphicsLayer> m_clipLayer;
-    std::unique_ptr<GraphicsLayer> m_scrollLayer;
</del><ins>+    RefPtr<GraphicsLayer> m_clipLayer;
+    RefPtr<GraphicsLayer> m_scrollLayer;
</ins><span class="cx"> 
</span><span class="cx"> #if PLATFORM(IOS)
</span><span class="cx">     HashSet<RenderLayer*> m_scrollingLayers;
</span><span class="lines">@@ -535,19 +535,19 @@
</span><span class="cx">     HashSet<RenderLayer*> m_scrollCoordinatedLayersNeedingUpdate;
</span><span class="cx"> 
</span><span class="cx">     // Enclosing layer for overflow controls and the clipping layer
</span><del>-    std::unique_ptr<GraphicsLayer> m_overflowControlsHostLayer;
</del><ins>+    RefPtr<GraphicsLayer> m_overflowControlsHostLayer;
</ins><span class="cx"> 
</span><span class="cx">     // Layers for overflow controls
</span><del>-    std::unique_ptr<GraphicsLayer> m_layerForHorizontalScrollbar;
-    std::unique_ptr<GraphicsLayer> m_layerForVerticalScrollbar;
-    std::unique_ptr<GraphicsLayer> m_layerForScrollCorner;
</del><ins>+    RefPtr<GraphicsLayer> m_layerForHorizontalScrollbar;
+    RefPtr<GraphicsLayer> m_layerForVerticalScrollbar;
+    RefPtr<GraphicsLayer> m_layerForScrollCorner;
</ins><span class="cx"> #if ENABLE(RUBBER_BANDING)
</span><del>-    std::unique_ptr<GraphicsLayer> m_layerForOverhangAreas;
-    std::unique_ptr<GraphicsLayer> m_contentShadowLayer;
-    std::unique_ptr<GraphicsLayer> m_layerForTopOverhangArea;
-    std::unique_ptr<GraphicsLayer> m_layerForBottomOverhangArea;
-    std::unique_ptr<GraphicsLayer> m_layerForHeader;
-    std::unique_ptr<GraphicsLayer> m_layerForFooter;
</del><ins>+    RefPtr<GraphicsLayer> m_layerForOverhangAreas;
+    RefPtr<GraphicsLayer> m_contentShadowLayer;
+    RefPtr<GraphicsLayer> m_layerForTopOverhangArea;
+    RefPtr<GraphicsLayer> m_layerForBottomOverhangArea;
+    RefPtr<GraphicsLayer> m_layerForHeader;
+    RefPtr<GraphicsLayer> m_layerForFooter;
</ins><span class="cx"> #endif
</span><span class="cx"> 
</span><span class="cx">     std::unique_ptr<GraphicsLayerUpdater> m_layerUpdater; // Updates tiled layer visible area periodically while animations are running.
</span></span></pre></div>
<a id="trunkSourceWebKitChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit/ChangeLog (235952 => 235953)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit/ChangeLog    2018-09-12 21:23:40 UTC (rev 235952)
+++ trunk/Source/WebKit/ChangeLog       2018-09-12 21:27:07 UTC (rev 235953)
</span><span class="lines">@@ -1,3 +1,31 @@
</span><ins>+2018-09-11  Simon Fraser  <simon.fraser@apple.com>
+
+        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.
+
+        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):
+
</ins><span class="cx"> 2018-09-12  Chris Dumez  <cdumez@apple.com>
</span><span class="cx"> 
</span><span class="cx">         PSON: No process swap on back navigation after URL bar navigation
</span></span></pre></div>
<a id="trunkSourceWebKitWebProcessWebCoreSupportWebInspectorClientcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit/WebProcess/WebCoreSupport/WebInspectorClient.cpp (235952 => 235953)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit/WebProcess/WebCoreSupport/WebInspectorClient.cpp     2018-09-12 21:23:40 UTC (rev 235952)
+++ trunk/Source/WebKit/WebProcess/WebCoreSupport/WebInspectorClient.cpp        2018-09-12 21:27:07 UTC (rev 235953)
</span><span class="lines">@@ -66,10 +66,10 @@
</span><span class="cx"> 
</span><span class="cx"> WebInspectorClient::~WebInspectorClient()
</span><span class="cx"> {
</span><del>-    for (auto layer : m_paintRectLayers) {
</del><ins>+    for (auto& layer : m_paintRectLayers)
</ins><span class="cx">         layer->removeFromParent();
</span><del>-        delete layer;
-    }
</del><ins>+    
+    m_paintRectLayers.clear();
</ins><span class="cx"> 
</span><span class="cx">     if (m_paintRectOverlay && m_page->corePage())
</span><span class="cx">         m_page->corePage()->pageOverlayController().uninstallPageOverlay(*m_paintRectOverlay, PageOverlay::FadeMode::Fade);
</span><span class="lines">@@ -152,7 +152,7 @@
</span><span class="cx">     if (!m_paintIndicatorLayerClient)
</span><span class="cx">         m_paintIndicatorLayerClient = std::make_unique<RepaintIndicatorLayerClient>(*this);
</span><span class="cx"> 
</span><del>-    std::unique_ptr<GraphicsLayer> paintLayer = GraphicsLayer::create(m_page->drawingArea()->graphicsLayerFactory(), *m_paintIndicatorLayerClient);
</del><ins>+    auto paintLayer = GraphicsLayer::create(m_page->drawingArea()->graphicsLayerFactory(), *m_paintIndicatorLayerClient);
</ins><span class="cx">     
</span><span class="cx">     paintLayer->setName("paint rect");
</span><span class="cx">     paintLayer->setAnchorPoint(FloatPoint3D());
</span><span class="lines">@@ -165,22 +165,23 @@
</span><span class="cx"> 
</span><span class="cx">     fadeKeyframes.insert(std::make_unique<FloatAnimationValue>(0.25, 0));
</span><span class="cx">     
</span><del>-    RefPtr<Animation> opacityAnimation = Animation::create();
</del><ins>+    auto opacityAnimation = Animation::create();
</ins><span class="cx">     opacityAnimation->setDuration(0.25);
</span><span class="cx"> 
</span><del>-    paintLayer->addAnimation(fadeKeyframes, FloatSize(), opacityAnimation.get(), "opacity"_s, 0);
</del><ins>+    paintLayer->addAnimation(fadeKeyframes, FloatSize(), opacityAnimation.ptr(), "opacity"_s, 0);
</ins><span class="cx">     
</span><del>-    m_paintRectLayers.add(paintLayer.get());
</del><ins>+    GraphicsLayer& rawLayer = paintLayer.get();
+    m_paintRectLayers.add(WTFMove(paintLayer));
</ins><span class="cx"> 
</span><span class="cx">     GraphicsLayer& overlayRootLayer = m_paintRectOverlay->layer();
</span><del>-    overlayRootLayer.addChild(paintLayer.release());
</del><ins>+    overlayRootLayer.addChild(rawLayer);
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void WebInspectorClient::animationEndedForLayer(const GraphicsLayer* layer)
</span><span class="cx"> {
</span><del>-    const_cast<GraphicsLayer*>(layer)->removeFromParent();
-    m_paintRectLayers.remove(const_cast<GraphicsLayer*>(layer));
-    delete layer;
</del><ins>+    GraphicsLayer* nonConstLayer = const_cast<GraphicsLayer*>(layer);
+    nonConstLayer->removeFromParent();
+    m_paintRectLayers.remove(*nonConstLayer);
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> #if PLATFORM(IOS)
</span></span></pre></div>
<a id="trunkSourceWebKitWebProcessWebCoreSupportWebInspectorClienth"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit/WebProcess/WebCoreSupport/WebInspectorClient.h (235952 => 235953)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit/WebProcess/WebCoreSupport/WebInspectorClient.h       2018-09-12 21:23:40 UTC (rev 235952)
+++ trunk/Source/WebKit/WebProcess/WebCoreSupport/WebInspectorClient.h  2018-09-12 21:27:07 UTC (rev 235953)
</span><span class="lines">@@ -84,7 +84,7 @@
</span><span class="cx">     
</span><span class="cx">     RefPtr<WebCore::PageOverlay> m_paintRectOverlay;
</span><span class="cx">     std::unique_ptr<RepaintIndicatorLayerClient> m_paintIndicatorLayerClient;
</span><del>-    HashSet<WebCore::GraphicsLayer*> m_paintRectLayers; // Ideally this would be HashSet<std::unique_ptr<GraphicsLayer>> but that doesn't work yet. webkit.org/b/136166
</del><ins>+    HashSet<Ref<WebCore::GraphicsLayer>> m_paintRectLayers;
</ins><span class="cx"> };
</span><span class="cx"> 
</span><span class="cx"> } // namespace WebKit
</span></span></pre></div>
<a id="trunkSourceWebKitWebProcessWebPageCoordinatedGraphicsCompositingCoordinatorcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit/WebProcess/WebPage/CoordinatedGraphics/CompositingCoordinator.cpp (235952 => 235953)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit/WebProcess/WebPage/CoordinatedGraphics/CompositingCoordinator.cpp    2018-09-12 21:23:40 UTC (rev 235952)
+++ trunk/Source/WebKit/WebProcess/WebPage/CoordinatedGraphics/CompositingCoordinator.cpp       2018-09-12 21:27:07 UTC (rev 235953)
</span><span class="lines">@@ -85,7 +85,7 @@
</span><span class="cx"> 
</span><span class="cx">     m_rootCompositingLayer = graphicsLayer;
</span><span class="cx">     if (m_rootCompositingLayer)
</span><del>-        m_rootLayer->addChildAtIndex(m_rootCompositingLayer, 0);
</del><ins>+        m_rootLayer->addChildAtIndex(*m_rootCompositingLayer, 0);
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void CompositingCoordinator::setViewOverlayRootLayer(GraphicsLayer* graphicsLayer)
</span><span class="lines">@@ -98,7 +98,7 @@
</span><span class="cx"> 
</span><span class="cx">     m_overlayCompositingLayer = graphicsLayer;
</span><span class="cx">     if (m_overlayCompositingLayer)
</span><del>-        m_rootLayer->addChild(m_overlayCompositingLayer);
</del><ins>+        m_rootLayer->addChild(*m_overlayCompositingLayer);
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void CompositingCoordinator::sizeDidChange(const IntSize& newSize)
</span><span class="lines">@@ -231,15 +231,15 @@
</span><span class="cx">     return m_page->pageScaleFactor();
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-std::unique_ptr<GraphicsLayer> CompositingCoordinator::createGraphicsLayer(GraphicsLayer::Type layerType, GraphicsLayerClient& client)
</del><ins>+Ref<GraphicsLayer> CompositingCoordinator::createGraphicsLayer(GraphicsLayer::Type layerType, GraphicsLayerClient& client)
</ins><span class="cx"> {
</span><del>-    CoordinatedGraphicsLayer* layer = new CoordinatedGraphicsLayer(layerType, client);
</del><ins>+    auto layer = adoptRef(*new CoordinatedGraphicsLayer(layerType, client));
</ins><span class="cx">     layer->setCoordinator(this);
</span><span class="cx">     m_nicosia.state.layers.add(layer->compositionLayer());
</span><del>-    m_registeredLayers.add(layer->id(), layer);
</del><ins>+    m_registeredLayers.add(layer->id(), layer.ptr());
</ins><span class="cx">     layer->setNeedsVisibleRectAdjustment();
</span><del>-    notifyFlushRequired(layer);
-    return std::unique_ptr<GraphicsLayer>(layer);
</del><ins>+    notifyFlushRequired(layer.ptr());
+    return WTFMove(layer);
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> FloatRect CompositingCoordinator::visibleContentsRect() const
</span></span></pre></div>
<a id="trunkSourceWebKitWebProcessWebPageCoordinatedGraphicsCompositingCoordinatorh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit/WebProcess/WebPage/CoordinatedGraphics/CompositingCoordinator.h (235952 => 235953)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit/WebProcess/WebPage/CoordinatedGraphics/CompositingCoordinator.h      2018-09-12 21:23:40 UTC (rev 235952)
+++ trunk/Source/WebKit/WebProcess/WebPage/CoordinatedGraphics/CompositingCoordinator.h 2018-09-12 21:27:07 UTC (rev 235953)
</span><span class="lines">@@ -103,7 +103,7 @@
</span><span class="cx">     void syncLayerState() override;
</span><span class="cx"> 
</span><span class="cx">     // GraphicsLayerFactory
</span><del>-    std::unique_ptr<WebCore::GraphicsLayer> createGraphicsLayer(WebCore::GraphicsLayer::Type, WebCore::GraphicsLayerClient&) override;
</del><ins>+    Ref<WebCore::GraphicsLayer> createGraphicsLayer(WebCore::GraphicsLayer::Type, WebCore::GraphicsLayerClient&) override;
</ins><span class="cx"> 
</span><span class="cx">     void initializeRootCompositingLayerIfNeeded();
</span><span class="cx"> 
</span><span class="lines">@@ -114,7 +114,7 @@
</span><span class="cx">     WebCore::Page* m_page;
</span><span class="cx">     CompositingCoordinator::Client& m_client;
</span><span class="cx"> 
</span><del>-    std::unique_ptr<WebCore::GraphicsLayer> m_rootLayer;
</del><ins>+    RefPtr<WebCore::GraphicsLayer> m_rootLayer;
</ins><span class="cx">     WebCore::GraphicsLayer* m_rootCompositingLayer { nullptr };
</span><span class="cx">     WebCore::GraphicsLayer* m_overlayCompositingLayer { nullptr };
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceWebKitWebProcessWebPageRemoteLayerTreeRemoteLayerTreeContexth"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit/WebProcess/WebPage/RemoteLayerTree/RemoteLayerTreeContext.h (235952 => 235953)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit/WebProcess/WebPage/RemoteLayerTree/RemoteLayerTreeContext.h  2018-09-12 21:23:40 UTC (rev 235952)
+++ trunk/Source/WebKit/WebProcess/WebPage/RemoteLayerTree/RemoteLayerTreeContext.h     2018-09-12 21:27:07 UTC (rev 235953)
</span><span class="lines">@@ -74,7 +74,7 @@
</span><span class="cx"> 
</span><span class="cx"> private:
</span><span class="cx">     // WebCore::GraphicsLayerFactory
</span><del>-    std::unique_ptr<WebCore::GraphicsLayer> createGraphicsLayer(WebCore::GraphicsLayer::Type, WebCore::GraphicsLayerClient&) override;
</del><ins>+    Ref<WebCore::GraphicsLayer> createGraphicsLayer(WebCore::GraphicsLayer::Type, WebCore::GraphicsLayerClient&) override;
</ins><span class="cx"> 
</span><span class="cx">     WebPage& m_webPage;
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceWebKitWebProcessWebPageRemoteLayerTreeRemoteLayerTreeContextmm"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit/WebProcess/WebPage/RemoteLayerTree/RemoteLayerTreeContext.mm (235952 => 235953)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit/WebProcess/WebPage/RemoteLayerTree/RemoteLayerTreeContext.mm 2018-09-12 21:23:40 UTC (rev 235952)
+++ trunk/Source/WebKit/WebProcess/WebPage/RemoteLayerTree/RemoteLayerTreeContext.mm    2018-09-12 21:27:07 UTC (rev 235953)
</span><span class="lines">@@ -109,9 +109,9 @@
</span><span class="cx">     return m_backingStoreCollection.backingStoreWillBeDisplayed(backingStore);
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-std::unique_ptr<GraphicsLayer> RemoteLayerTreeContext::createGraphicsLayer(WebCore::GraphicsLayer::Type layerType, GraphicsLayerClient& client)
</del><ins>+Ref<GraphicsLayer> RemoteLayerTreeContext::createGraphicsLayer(WebCore::GraphicsLayer::Type layerType, GraphicsLayerClient& client)
</ins><span class="cx"> {
</span><del>-    return std::make_unique<GraphicsLayerCARemote>(layerType, client, *this);
</del><ins>+    return adoptRef(*new GraphicsLayerCARemote(layerType, client, *this));
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void RemoteLayerTreeContext::buildTransaction(RemoteLayerTreeTransaction& transaction, PlatformCALayer& rootLayer)
</span></span></pre></div>
<a id="trunkSourceWebKitWebProcessWebPageRemoteLayerTreeRemoteLayerTreeDrawingAreah"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit/WebProcess/WebPage/RemoteLayerTree/RemoteLayerTreeDrawingArea.h (235952 => 235953)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit/WebProcess/WebPage/RemoteLayerTree/RemoteLayerTreeDrawingArea.h      2018-09-12 21:23:40 UTC (rev 235952)
+++ trunk/Source/WebKit/WebProcess/WebPage/RemoteLayerTree/RemoteLayerTreeDrawingArea.h 2018-09-12 21:27:07 UTC (rev 235953)
</span><span class="lines">@@ -137,7 +137,7 @@
</span><span class="cx">     };
</span><span class="cx"> 
</span><span class="cx">     std::unique_ptr<RemoteLayerTreeContext> m_remoteLayerTreeContext;
</span><del>-    std::unique_ptr<WebCore::GraphicsLayer> m_rootLayer;
</del><ins>+    Ref<WebCore::GraphicsLayer> m_rootLayer;
</ins><span class="cx"> 
</span><span class="cx">     WebCore::IntSize m_viewSize;
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceWebKitWebProcessWebPageRemoteLayerTreeRemoteLayerTreeDrawingAreamm"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit/WebProcess/WebPage/RemoteLayerTree/RemoteLayerTreeDrawingArea.mm (235952 => 235953)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit/WebProcess/WebPage/RemoteLayerTree/RemoteLayerTreeDrawingArea.mm     2018-09-12 21:23:40 UTC (rev 235952)
+++ trunk/Source/WebKit/WebProcess/WebPage/RemoteLayerTree/RemoteLayerTreeDrawingArea.mm        2018-09-12 21:27:07 UTC (rev 235953)
</span><span class="lines">@@ -115,14 +115,14 @@
</span><span class="cx"> 
</span><span class="cx"> void RemoteLayerTreeDrawingArea::updateRootLayers()
</span><span class="cx"> {
</span><del>-    Vector<GraphicsLayer*> children;
</del><ins>+    Vector<Ref<GraphicsLayer>> children;
</ins><span class="cx">     if (m_contentLayer) {
</span><del>-        children.append(m_contentLayer);
</del><ins>+        children.append(*m_contentLayer);
</ins><span class="cx">         if (m_viewOverlayRootLayer)
</span><del>-            children.append(m_viewOverlayRootLayer);
</del><ins>+            children.append(*m_viewOverlayRootLayer);
</ins><span class="cx">     }
</span><span class="cx"> 
</span><del>-    m_rootLayer->setChildren(children);
</del><ins>+    m_rootLayer->setChildren(WTFMove(children));
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void RemoteLayerTreeDrawingArea::attachViewOverlayGraphicsLayer(Frame* frame, GraphicsLayer* viewOverlayRootLayer)
</span><span class="lines">@@ -318,9 +318,6 @@
</span><span class="cx"> 
</span><span class="cx"> void RemoteLayerTreeDrawingArea::flushLayers()
</span><span class="cx"> {
</span><del>-    if (!m_rootLayer)
-        return;
-
</del><span class="cx">     if (m_isFlushingSuspended) {
</span><span class="cx">         m_hasDeferredFlush = true;
</span><span class="cx">         return;
</span><span class="lines">@@ -366,7 +363,7 @@
</span><span class="cx">     layerTransaction.setTransactionID(takeNextTransactionID());
</span><span class="cx">     layerTransaction.setCallbackIDs(WTFMove(m_pendingCallbackIDs));
</span><span class="cx">     m_remoteLayerTreeContext->setNextFlushIsForImmediatePaint(m_nextFlushIsForImmediatePaint);
</span><del>-    m_remoteLayerTreeContext->buildTransaction(layerTransaction, *downcast<GraphicsLayerCARemote>(*m_rootLayer).platformCALayer());
</del><ins>+    m_remoteLayerTreeContext->buildTransaction(layerTransaction, *downcast<GraphicsLayerCARemote>(m_rootLayer.get()).platformCALayer());
</ins><span class="cx">     m_remoteLayerTreeContext->setNextFlushIsForImmediatePaint(false);
</span><span class="cx">     backingStoreCollection.willCommitLayerTree(layerTransaction);
</span><span class="cx">     m_webPage.willCommitLayerTree(layerTransaction);
</span></span></pre></div>
<a id="trunkSourceWebKitLegacywinWebCoreSupportAcceleratedCompositingContextcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKitLegacy/win/WebCoreSupport/AcceleratedCompositingContext.cpp (235952 => 235953)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKitLegacy/win/WebCoreSupport/AcceleratedCompositingContext.cpp   2018-09-12 21:23:40 UTC (rev 235952)
+++ trunk/Source/WebKitLegacy/win/WebCoreSupport/AcceleratedCompositingContext.cpp      2018-09-12 21:27:07 UTC (rev 235953)
</span><span class="lines">@@ -97,7 +97,7 @@
</span><span class="cx">     m_nonCompositedContentLayer->setName("Non-composited content");
</span><span class="cx"> #endif
</span><span class="cx"> 
</span><del>-    m_rootLayer->addChild(m_nonCompositedContentLayer.get());
</del><ins>+    m_rootLayer->addChild(*m_nonCompositedContentLayer);
</ins><span class="cx">     m_nonCompositedContentLayer->setNeedsDisplay();
</span><span class="cx"> 
</span><span class="cx">     // The creation of the TextureMapper needs an active OpenGL context.
</span><span class="lines">@@ -211,7 +211,7 @@
</span><span class="cx">         return;
</span><span class="cx"> 
</span><span class="cx">     m_nonCompositedContentLayer->removeAllChildren();
</span><del>-    m_nonCompositedContentLayer->addChild(graphicsLayer);
</del><ins>+    m_nonCompositedContentLayer->addChild(*graphicsLayer);
</ins><span class="cx"> 
</span><span class="cx">     stopAnyPendingLayerFlush();
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceWebKitLegacywinWebCoreSupportAcceleratedCompositingContexth"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKitLegacy/win/WebCoreSupport/AcceleratedCompositingContext.h (235952 => 235953)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKitLegacy/win/WebCoreSupport/AcceleratedCompositingContext.h     2018-09-12 21:23:40 UTC (rev 235952)
+++ trunk/Source/WebKitLegacy/win/WebCoreSupport/AcceleratedCompositingContext.h        2018-09-12 21:27:07 UTC (rev 235953)
</span><span class="lines">@@ -71,8 +71,8 @@
</span><span class="cx">     WebView& m_webView;
</span><span class="cx">     std::unique_ptr<WebCore::GLContext> m_context;
</span><span class="cx">     HWND m_window;
</span><del>-    std::unique_ptr<WebCore::GraphicsLayer> m_rootLayer;
-    std::unique_ptr<WebCore::GraphicsLayer> m_nonCompositedContentLayer;
</del><ins>+    RefPtr<WebCore::GraphicsLayer> m_rootLayer;
+    RefPtr<WebCore::GraphicsLayer> m_nonCompositedContentLayer;
</ins><span class="cx">     std::unique_ptr<WebCore::TextureMapper> m_textureMapper;
</span><span class="cx">     WebCore::TextureMapperFPSCounter m_fpsCounter;
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceWebKitLegacywinWebViewcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKitLegacy/win/WebView.cpp (235952 => 235953)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKitLegacy/win/WebView.cpp        2018-09-12 21:23:40 UTC (rev 235952)
+++ trunk/Source/WebKitLegacy/win/WebView.cpp   2018-09-12 21:27:07 UTC (rev 235953)
</span><span class="lines">@@ -7145,7 +7145,12 @@
</span><span class="cx"> #if USE(CA)
</span><span class="cx">     if (!m_backingLayer)
</span><span class="cx">         return;
</span><del>-    m_backingLayer->addChild(layer);
</del><ins>+
+    if (layer)
+        m_backingLayer->addChild(*layer);
+    else
+        m_backingLayer->removeAllChildren();
+
</ins><span class="cx"> #elif USE(TEXTURE_MAPPER_GL)
</span><span class="cx">     if (!m_acceleratedCompositingContext)
</span><span class="cx">         return;
</span></span></pre></div>
<a id="trunkSourceWebKitLegacywinWebViewh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKitLegacy/win/WebView.h (235952 => 235953)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKitLegacy/win/WebView.h  2018-09-12 21:23:40 UTC (rev 235952)
+++ trunk/Source/WebKitLegacy/win/WebView.h     2018-09-12 21:27:07 UTC (rev 235953)
</span><span class="lines">@@ -705,7 +705,7 @@
</span><span class="cx">     void setAcceleratedCompositing(bool);
</span><span class="cx"> #if USE(CA)
</span><span class="cx">     RefPtr<WebCore::CACFLayerTreeHost> m_layerTreeHost;
</span><del>-    std::unique_ptr<WebCore::GraphicsLayer> m_backingLayer;
</del><ins>+    RefPtr<WebCore::GraphicsLayer> m_backingLayer;
</ins><span class="cx"> #elif USE(TEXTURE_MAPPER_GL)
</span><span class="cx">     std::unique_ptr<AcceleratedCompositingContext> m_acceleratedCompositingContext;
</span><span class="cx"> #endif
</span></span></pre>
</div>
</div>

</body>
</html>