Title: [191439] trunk/Source/WebCore
Revision
191439
Author
[email protected]
Date
2015-10-21 23:10:53 -0700 (Wed, 21 Oct 2015)

Log Message

Print out the render tree from command line.
https://bugs.webkit.org/show_bug.cgi?id=150416

Use system-wide notification server (https://developer.apple.com/library/mac/documentation/Darwin/Reference/ManPages/man3/notify_register_dispatch.3.html)
to print out the render tree for the live documents.

Usage: notifyutil -p com.apple.WebKit.showRenderTree

Reviewed by Simon Fraser.

No change in functionality.

* platform/Logging.cpp:
(WebCore::registerNotifyCallback):
* platform/Logging.h:
* rendering/RenderObject.cpp:
(WebCore::RenderObject::RenderObject):
(WebCore::printRenderTreeForLiveDocuments):

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (191438 => 191439)


--- trunk/Source/WebCore/ChangeLog	2015-10-22 05:50:24 UTC (rev 191438)
+++ trunk/Source/WebCore/ChangeLog	2015-10-22 06:10:53 UTC (rev 191439)
@@ -1,3 +1,24 @@
+2015-10-21  Zalan Bujtas  <[email protected]>
+
+        Print out the render tree from command line.
+        https://bugs.webkit.org/show_bug.cgi?id=150416
+
+        Use system-wide notification server (https://developer.apple.com/library/mac/documentation/Darwin/Reference/ManPages/man3/notify_register_dispatch.3.html)
+        to print out the render tree for the live documents.
+
+        Usage: notifyutil -p com.apple.WebKit.showRenderTree
+
+        Reviewed by Simon Fraser.
+
+        No change in functionality.
+
+        * platform/Logging.cpp:
+        (WebCore::registerNotifyCallback):
+        * platform/Logging.h:
+        * rendering/RenderObject.cpp:
+        (WebCore::RenderObject::RenderObject):
+        (WebCore::printRenderTreeForLiveDocuments):
+
 2015-10-21  Alex Christensen  <[email protected]>
 
         Fix CMake clean build after r191423.

Modified: trunk/Source/WebCore/platform/Logging.cpp (191438 => 191439)


--- trunk/Source/WebCore/platform/Logging.cpp	2015-10-22 05:50:24 UTC (rev 191438)
+++ trunk/Source/WebCore/platform/Logging.cpp	2015-10-22 06:10:53 UTC (rev 191439)
@@ -30,6 +30,10 @@
 #include <wtf/text/CString.h>
 #include <wtf/text/WTFString.h>
 
+#if PLATFORM(COCOA)
+#include <notify.h>
+#endif
+
 #if !LOG_DISABLED
 
 namespace WebCore {
@@ -63,6 +67,18 @@
     WTFInitializeLogChannelStatesFromString(logChannels, logChannelCount, logLevelString().utf8().data());
 }
 
+#ifndef NDEBUG
+void registerNotifyCallback(const String& notifyID, std::function<void()> callback)
+{
+#if PLATFORM(COCOA)
+    int token;
+    notify_register_dispatch(notifyID.utf8().data(), &token, dispatch_get_main_queue(), ^(int) {
+        callback();
+    });
+#endif
 }
+#endif
 
+}
+
 #endif // !LOG_DISABLED

Modified: trunk/Source/WebCore/platform/Logging.h (191438 => 191439)


--- trunk/Source/WebCore/platform/Logging.h	2015-10-22 05:50:24 UTC (rev 191438)
+++ trunk/Source/WebCore/platform/Logging.h	2015-10-22 06:10:53 UTC (rev 191439)
@@ -26,6 +26,7 @@
 #ifndef Logging_h
 #define Logging_h
 
+#include <functional>
 #include <wtf/Assertions.h>
 #include <wtf/Forward.h>
 
@@ -89,6 +90,9 @@
     String logLevelString();
     bool isLogChannelEnabled(const String& name);
     WEBCORE_EXPORT void initializeLoggingChannelsIfNecessary();
+#ifndef NDEBUG
+    void registerNotifyCallback(const String& notifyID, std::function<void()> callback);
+#endif
 }
 
 #endif // !LOG_DISABLED

Modified: trunk/Source/WebCore/rendering/RenderObject.cpp (191438 => 191439)


--- trunk/Source/WebCore/rendering/RenderObject.cpp	2015-10-22 05:50:24 UTC (rev 191438)
+++ trunk/Source/WebCore/rendering/RenderObject.cpp	2015-10-22 06:10:53 UTC (rev 191439)
@@ -43,6 +43,7 @@
 #include "HTMLTableCellElement.h"
 #include "HTMLTableElement.h"
 #include "HitTestResult.h"
+#include "Logging.h"
 #include "LogicalSelectionOffsetCaches.h"
 #include "Page.h"
 #include "PseudoElement.h"
@@ -81,6 +82,8 @@
 using namespace HTMLNames;
 
 #ifndef NDEBUG
+void printRenderTreeForLiveDocuments();
+
 RenderObject::SetLayoutNeededForbiddenScope::SetLayoutNeededForbiddenScope(RenderObject* renderObject, bool isForbidden)
     : m_renderObject(renderObject)
     , m_preexistingForbidden(m_renderObject->isSetNeedsLayoutForbidden())
@@ -123,6 +126,10 @@
         renderView->didCreateRenderer();
 #ifndef NDEBUG
     renderObjectCounter.increment();
+    static std::once_flag onceFlag;
+    std::call_once(onceFlag, [] {
+        registerNotifyCallback("com.apple.WebKit.showRenderTree", printRenderTreeForLiveDocuments);
+    });
 #endif
 }
 
@@ -2215,6 +2222,19 @@
     setHasRareData(false);
 }
 
+#ifndef NDEBUG
+void printRenderTreeForLiveDocuments()
+{
+    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());
+        showRenderTree(document->renderView());
+    }
+}
+#endif
 } // namespace WebCore
 
 #if ENABLE(TREE_DEBUGGING)
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to