Add compact logging for the paint-order RenderLayer tree
authorsimon.fraser@apple.com <simon.fraser@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 15 Oct 2018 20:09:15 +0000 (20:09 +0000)
committersimon.fraser@apple.com <simon.fraser@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 15 Oct 2018 20:09:15 +0000 (20:09 +0000)
https://bugs.webkit.org/show_bug.cgi?id=190592

Reviewed by Zalan Bujtas.

Add a way to dump the RenderLayer tree in paint order, which will be extended in future
to show more dirty bit state.

* rendering/RenderLayer.cpp:
(WebCore::outputPaintOrderTreeLegend):
(WebCore::outputIdent):
(WebCore::outputPaintOrderTreeRecursive):
(WebCore::showPaintOrderTree):
* rendering/RenderLayer.h:

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@237139 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Source/WebCore/ChangeLog
Source/WebCore/rendering/RenderLayer.cpp
Source/WebCore/rendering/RenderLayer.h

index c6f16a2..2a517d9 100644 (file)
@@ -1,3 +1,20 @@
+2018-10-15  Simon Fraser  <simon.fraser@apple.com>
+
+        Add compact logging for the paint-order RenderLayer tree
+        https://bugs.webkit.org/show_bug.cgi?id=190592
+
+        Reviewed by Zalan Bujtas.
+
+        Add a way to dump the RenderLayer tree in paint order, which will be extended in future
+        to show more dirty bit state.
+
+        * rendering/RenderLayer.cpp:
+        (WebCore::outputPaintOrderTreeLegend):
+        (WebCore::outputIdent):
+        (WebCore::outputPaintOrderTreeRecursive):
+        (WebCore::showPaintOrderTree):
+        * rendering/RenderLayer.h:
+
 2018-10-15  Alex Christensen  <achristensen@webkit.org>
 
         Remove unused parameters from FrameLoaderClient::createFrame
index 61b8ce3..2971586 100644 (file)
@@ -6580,4 +6580,66 @@ void showLayerTree(const WebCore::RenderObject* renderer)
     showLayerTree(renderer->enclosingLayer());
 }
 
+static void outputPaintOrderTreeLegend(TextStream& stream)
+{
+    stream.nextLine();
+    stream << "(S)tacking Context, (N)ormal flow only, (O)verflow clip, (A)lpha (opacity or mask), (T)ransform-ish, (F)ilter, Fi(X)ed position, (C)omposited\n"
+        "Dirty (z)-lists, Dirty (n)ormal flow lists";
+    stream.nextLine();
+}
+
+static void outputIdent(TextStream& stream, unsigned depth)
+{
+    unsigned i = 0;
+    while (++i <= depth * 2)
+        stream << " ";
+}
+
+static void outputPaintOrderTreeRecursive(TextStream& stream, const WebCore::RenderLayer& layer, const char* prefix, unsigned depth = 0)
+{
+    stream << (layer.isStackingContext() ? "S" : "-");
+    stream << (layer.isNormalFlowOnly() ? "N" : "-");
+    stream << (layer.renderer().hasOverflowClip() ? "O" : "-");
+    stream << (layer.isTransparent() ? "A" : "-");
+    stream << (layer.renderer().hasTransformRelatedProperty() ? "T" : "-");
+    stream << (layer.hasFilter() ? "F" : "-");
+    stream << (layer.renderer().isFixedPositioned() ? "X" : "-");
+    stream << (layer.isComposited() ? "C" : "-");
+
+    stream << " ";
+
+    stream << (layer.zOrderListsDirty() ? "z" : "-");
+    stream << (layer.normalFlowListDirty() ? "n" : "-");
+
+    outputIdent(stream, depth);
+
+    stream << prefix;
+
+    auto layerRect = layer.rect();
+
+    stream << &layer << " " << layerRect;
+    stream.nextLine();
+
+    const_cast<WebCore::RenderLayer&>(layer).updateLayerListsIfNeeded();
+
+    for (auto* child : layer.negativeZOrderLayers())
+        outputPaintOrderTreeRecursive(stream, *child, "- ", depth + 1);
+
+    for (auto* child : layer.normalFlowLayers())
+        outputPaintOrderTreeRecursive(stream, *child, "n ", depth + 1);
+
+    for (auto* child : layer.positiveZOrderLayers())
+        outputPaintOrderTreeRecursive(stream, *child, "+ ", depth + 1);
+}
+
+void showPaintOrderTree(const WebCore::RenderLayer* layer)
+{
+    TextStream stream;
+    outputPaintOrderTreeLegend(stream);
+    if (layer)
+        outputPaintOrderTreeRecursive(stream, *layer, "");
+    
+    WTFLogAlways("%s", stream.release().utf8().data());
+}
+
 #endif
index 02ef8fe..c48016a 100644 (file)
@@ -182,6 +182,9 @@ public:
     void dirtyZOrderLists();
     void dirtyStackingContextZOrderLists();
 
+    bool normalFlowListDirty() const { return m_normalFlowListDirty; }
+    bool zOrderListsDirty() const { return m_zOrderListsDirty; }
+
     class LayerList {
         friend class RenderLayer;
     public:
@@ -1224,5 +1227,6 @@ WTF::TextStream& operator<<(WTF::TextStream&, const RenderLayer&);
 #if ENABLE(TREE_DEBUGGING)
 // Outside the WebCore namespace for ease of invocation from lldb.
 void showLayerTree(const WebCore::RenderLayer*);
+void showPaintOrderTree(const WebCore::RenderLayer*);
 void showLayerTree(const WebCore::RenderObject*);
 #endif