Add a "notifyutil" callback for dumping the RenderLayer tree, and move the registrati...
authorsimon.fraser@apple.com <simon.fraser@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 5 Apr 2016 19:40:07 +0000 (19:40 +0000)
committersimon.fraser@apple.com <simon.fraser@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 5 Apr 2016 19:40:07 +0000 (19:40 +0000)
https://bugs.webkit.org/show_bug.cgi?id=156224

Reviewed by Zalan Bujtas.

Make it possible to run:
    notifyutil -p com.apple.WebKit.showLayerTree
on the command line and have it dump out layer trees for all live documents, in
debug builds.

Move callback registration from RenderObject's constructor to Page.

* page/mac/PageMac.mm:
(WebCore::Page::platformInitialize):
* rendering/RenderObject.cpp:
(WebCore::printLayerTreeForLiveDocuments):
(WebCore::RenderObject::RenderObject): Deleted.
* rendering/RenderObject.h:

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

Source/WebCore/ChangeLog
Source/WebCore/page/mac/PageMac.mm
Source/WebCore/rendering/RenderObject.cpp
Source/WebCore/rendering/RenderObject.h

index fde1d21..77fd250 100644 (file)
@@ -1,3 +1,24 @@
+2016-04-05  Simon Fraser  <simon.fraser@apple.com>
+
+        Add a "notifyutil" callback for dumping the RenderLayer tree, and move the registration to Page code
+        https://bugs.webkit.org/show_bug.cgi?id=156224
+
+        Reviewed by Zalan Bujtas.
+
+        Make it possible to run:
+            notifyutil -p com.apple.WebKit.showLayerTree
+        on the command line and have it dump out layer trees for all live documents, in
+        debug builds.
+        
+        Move callback registration from RenderObject's constructor to Page.
+
+        * page/mac/PageMac.mm:
+        (WebCore::Page::platformInitialize):
+        * rendering/RenderObject.cpp:
+        (WebCore::printLayerTreeForLiveDocuments):
+        (WebCore::RenderObject::RenderObject): Deleted.
+        * rendering/RenderObject.h:
+
 2016-04-05  Antoine Quint  <graouts@apple.com>
 
         [WebGL2] Turn the ENABLE_WEBGL2 flag on
index db20090..f49cdeb 100644 (file)
@@ -32,7 +32,9 @@
 #import "DocumentLoader.h"
 #import "FrameLoader.h"
 #import "FrameTree.h"
+#import "Logging.h"
 #import "MainFrame.h"
+#import "RenderObject.h"
 
 #if PLATFORM(IOS)
 #import "WebCoreThread.h"
@@ -51,6 +53,14 @@ void Page::platformInitialize()
 #else
     addSchedulePair(SchedulePair::create([NSRunLoop currentRunLoop], kCFRunLoopCommonModes));
 #endif
+
+#if ENABLE(TREE_DEBUGGING)
+    static std::once_flag onceFlag;
+    std::call_once(onceFlag, [] {
+        registerNotifyCallback("com.apple.WebKit.showRenderTree", printRenderTreeForLiveDocuments);
+        registerNotifyCallback("com.apple.WebKit.showLayerTree", printLayerTreeForLiveDocuments);
+    });
+#endif
 }
 
 void Page::addSchedulePair(Ref<SchedulePair>&& pair)
index edb4f33..5381a1d 100644 (file)
@@ -43,7 +43,6 @@
 #include "HTMLTableCellElement.h"
 #include "HTMLTableElement.h"
 #include "HitTestResult.h"
-#include "Logging.h"
 #include "LogicalSelectionOffsetCaches.h"
 #include "MainFrame.h"
 #include "Page.h"
@@ -84,7 +83,6 @@ namespace WebCore {
 using namespace HTMLNames;
 
 #ifndef NDEBUG
-void printRenderTreeForLiveDocuments();
 
 RenderObject::SetLayoutNeededForbiddenScope::SetLayoutNeededForbiddenScope(RenderObject* renderObject, bool isForbidden)
     : m_renderObject(renderObject)
@@ -128,10 +126,6 @@ RenderObject::RenderObject(Node& node)
         renderView->didCreateRenderer();
 #ifndef NDEBUG
     renderObjectCounter.increment();
-    static std::once_flag onceFlag;
-    std::call_once(onceFlag, [] {
-        registerNotifyCallback("com.apple.WebKit.showRenderTree", printRenderTreeForLiveDocuments);
-    });
 #endif
 }
 
@@ -2277,7 +2271,8 @@ void RenderObject::removeRareData()
     setHasRareData(false);
 }
 
-#ifndef NDEBUG
+#if ENABLE(TREE_DEBUGGING)
+
 void printRenderTreeForLiveDocuments()
 {
     for (const auto* document : Document::allDocuments()) {
@@ -2289,7 +2284,21 @@ void printRenderTreeForLiveDocuments()
         showRenderTree(document->renderView());
     }
 }
-#endif
+
+void printLayerTreeForLiveDocuments()
+{
+    for (const auto* document : Document::allDocuments()) {
+        if (!document->renderView() || document->inPageCache())
+            continue;
+        if (document->frame() && document->frame()->isMainFrame())
+            fprintf(stderr, "----------------------main frame--------------------------\n");
+        fprintf(stderr, "%s", document->url().string().utf8().data());
+        showLayerTree(document->renderView());
+    }
+}
+
+#endif // ENABLE(TREE_DEBUGGING)
+
 } // namespace WebCore
 
 #if ENABLE(TREE_DEBUGGING)
index 0eab5dd..fad5676 100644 (file)
@@ -1152,6 +1152,11 @@ inline bool RenderObject::backgroundIsKnownToBeObscured(const LayoutPoint& paint
     return m_bitfields.boxDecorationState() == HasBoxDecorationsAndBackgroundIsKnownToBeObscured;
 }
 
+#if ENABLE(TREE_DEBUGGING)
+void printRenderTreeForLiveDocuments();
+void printLayerTreeForLiveDocuments();
+#endif
+
 } // namespace WebCore
 
 #define SPECIALIZE_TYPE_TRAITS_RENDER_OBJECT(ToValueTypeName, predicate) \