will-change should sometimes trigger compositing
[WebKit-https.git] / Source / WebCore / inspector / InspectorLayerTreeAgent.cpp
index f0cef40..d43b69c 100644 (file)
  */
 
 #include "config.h"
-
-#if ENABLE(INSPECTOR)
-
 #include "InspectorLayerTreeAgent.h"
 
 #include "InspectorDOMAgent.h"
-#include "InspectorWebFrontendDispatchers.h"
+#include <inspector/InspectorFrontendDispatchers.h>
 #include "InstrumentingAgents.h"
 #include "IntRect.h"
 #include "PseudoElement.h"
@@ -59,16 +56,16 @@ InspectorLayerTreeAgent::~InspectorLayerTreeAgent()
     reset();
 }
 
-void InspectorLayerTreeAgent::didCreateFrontendAndBackend(Inspector::InspectorFrontendChannel* frontendChannel, InspectorBackendDispatcher* backendDispatcher)
+void InspectorLayerTreeAgent::didCreateFrontendAndBackend(Inspector::FrontendChannel* frontendChannel, Inspector::BackendDispatcher* backendDispatcher)
 {
-    m_frontendDispatcher = std::make_unique<InspectorLayerTreeFrontendDispatcher>(frontendChannel);
-    m_backendDispatcher = InspectorLayerTreeBackendDispatcher::create(backendDispatcher, this);
+    m_frontendDispatcher = std::make_unique<Inspector::LayerTreeFrontendDispatcher>(frontendChannel);
+    m_backendDispatcher = Inspector::LayerTreeBackendDispatcher::create(backendDispatcher, this);
 }
 
-void InspectorLayerTreeAgent::willDestroyFrontendAndBackend(InspectorDisconnectReason)
+void InspectorLayerTreeAgent::willDestroyFrontendAndBackend(Inspector::DisconnectReason)
 {
     m_frontendDispatcher = nullptr;
-    m_backendDispatcher.clear();
+    m_backendDispatcher = nullptr;
 
     ErrorString unused;
     disable(unused);
@@ -97,14 +94,14 @@ void InspectorLayerTreeAgent::layerTreeDidChange()
     m_frontendDispatcher->layerTreeDidChange();
 }
 
-void InspectorLayerTreeAgent::renderLayerDestroyed(const RenderLayer* renderLayer)
+void InspectorLayerTreeAgent::renderLayerDestroyed(const RenderLayer& renderLayer)
 {
-    unbind(renderLayer);
+    unbind(&renderLayer);
 }
 
-void InspectorLayerTreeAgent::pseudoElementDestroyed(PseudoElement* pseudoElement)
+void InspectorLayerTreeAgent::pseudoElementDestroyed(PseudoElement& pseudoElement)
 {
-    unbindPseudoElement(pseudoElement);
+    unbindPseudoElement(&pseudoElement);
 }
 
 void InspectorLayerTreeAgent::layersForNode(ErrorString& errorString, int nodeId, RefPtr<Inspector::Protocol::Array<Inspector::Protocol::LayerTree::Layer>>& layers)
@@ -146,7 +143,7 @@ void InspectorLayerTreeAgent::gatherLayersUsingRenderLayerHierarchy(ErrorString&
         gatherLayersUsingRenderLayerHierarchy(errorString, renderLayer, layers);
 }
 
-PassRefPtr<Inspector::Protocol::LayerTree::Layer> InspectorLayerTreeAgent::buildObjectForLayer(ErrorString& errorString, RenderLayer* renderLayer)
+Ref<Inspector::Protocol::LayerTree::Layer> InspectorLayerTreeAgent::buildObjectForLayer(ErrorString& errorString, RenderLayer* renderLayer)
 {
     RenderObject* renderer = &renderLayer->renderer();
     RenderLayerBacking* backing = renderLayer->backing();
@@ -166,13 +163,14 @@ PassRefPtr<Inspector::Protocol::LayerTree::Layer> InspectorLayerTreeAgent::build
         node = renderer->parent()->element();
 
     // Basic set of properties.
-    RefPtr<Inspector::Protocol::LayerTree::Layer> layerObject = Inspector::Protocol::LayerTree::Layer::create()
+    auto layerObject = Inspector::Protocol::LayerTree::Layer::create()
         .setLayerId(bind(renderLayer))
         .setNodeId(idForNode(errorString, node))
         .setBounds(buildObjectForIntRect(renderer->absoluteBoundingBoxRect()))
         .setMemory(backing->backingStoreMemoryEstimate())
         .setCompositedBounds(buildObjectForIntRect(enclosingIntRect(backing->compositedBounds())))
-        .setPaintCount(backing->graphicsLayer()->repaintCount());
+        .setPaintCount(backing->graphicsLayer()->repaintCount())
+        .release();
 
     if (node && node->shadowHost())
         layerObject->setIsInShadowTree(true);
@@ -201,7 +199,7 @@ PassRefPtr<Inspector::Protocol::LayerTree::Layer> InspectorLayerTreeAgent::build
             layerObject->setPseudoElement("first-line");
     }
 
-    return layerObject;
+    return WTF::move(layerObject);
 }
 
 int InspectorLayerTreeAgent::idForNode(ErrorString& errorString, Node* node)
@@ -218,16 +216,17 @@ int InspectorLayerTreeAgent::idForNode(ErrorString& errorString, Node* node)
     return nodeId;
 }
 
-PassRefPtr<Inspector::Protocol::LayerTree::IntRect> InspectorLayerTreeAgent::buildObjectForIntRect(const IntRect& rect)
+Ref<Inspector::Protocol::LayerTree::IntRect> InspectorLayerTreeAgent::buildObjectForIntRect(const IntRect& rect)
 {
     return Inspector::Protocol::LayerTree::IntRect::create()
         .setX(rect.x())
         .setY(rect.y())
         .setWidth(rect.width())
-        .setHeight(rect.height()).release();
+        .setHeight(rect.height())
+        .release();
 }
 
-void InspectorLayerTreeAgent::reasonsForCompositingLayer(ErrorString& errorString, const String& layerId, RefPtr<Inspector::Protocol::LayerTree::CompositingReasons>& compositingReasons)
+void InspectorLayerTreeAgent::reasonsForCompositingLayer(ErrorString& errorString, const String& layerId, RefPtr<Inspector::Protocol::LayerTree::CompositingReasons>& compositingReasonsResult)
 {
     const RenderLayer* renderLayer = m_idToLayer.get(layerId);
 
@@ -237,7 +236,7 @@ void InspectorLayerTreeAgent::reasonsForCompositingLayer(ErrorString& errorStrin
     }
 
     CompositingReasons reasonsBitmask = renderLayer->compositor().reasonsForCompositing(*renderLayer);
-    compositingReasons = Inspector::Protocol::LayerTree::CompositingReasons::create();
+    auto compositingReasons = Inspector::Protocol::LayerTree::CompositingReasons::create().release();
 
     if (reasonsBitmask & CompositingReason3DTransform)
         compositingReasons->setTransform3D(true);
@@ -308,8 +307,13 @@ void InspectorLayerTreeAgent::reasonsForCompositingLayer(ErrorString& errorStrin
     if (reasonsBitmask & CompositingReasonPreserve3D)
         compositingReasons->setPreserve3D(true);
 
+    if (reasonsBitmask & CompositingReasonWillChange)
+        compositingReasons->setWillChange(true);
+
     if (reasonsBitmask & CompositingReasonRoot)
         compositingReasons->setRoot(true);
+    
+    compositingReasonsResult = WTF::move(compositingReasons);
 }
 
 String InspectorLayerTreeAgent::bind(const RenderLayer* layer)
@@ -357,5 +361,3 @@ void InspectorLayerTreeAgent::unbindPseudoElement(PseudoElement* pseudoElement)
 }
 
 } // namespace WebCore
-
-#endif // ENABLE(INSPECTOR)