Title: [206743] trunk/Source/WebCore
Revision
206743
Author
[email protected]
Date
2016-10-03 13:26:00 -0700 (Mon, 03 Oct 2016)

Log Message

Log an error to stderr when FrameView::layout() fails to clean all the renderers.
https://bugs.webkit.org/show_bug.cgi?id=162835

Reviewed by Simon Fraser.

We've come across multiple layout/painting bugs caused by renderers left dirty
after FrameView::layout(). This patch helps catching such issues early.
Once all the blocking bugs are fixed (webkit.org/b/162835), logging should be replaced with ASSERT().

Not testable.

* page/FrameView.cpp:
(WebCore::RenderTreeNeedsLayoutChecker::~RenderTreeNeedsLayoutChecker):
(WebCore::FrameView::layout):

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (206742 => 206743)


--- trunk/Source/WebCore/ChangeLog	2016-10-03 20:22:57 UTC (rev 206742)
+++ trunk/Source/WebCore/ChangeLog	2016-10-03 20:26:00 UTC (rev 206743)
@@ -1,3 +1,20 @@
+2016-10-03  Zalan Bujtas  <[email protected]>
+
+        Log an error to stderr when FrameView::layout() fails to clean all the renderers.
+        https://bugs.webkit.org/show_bug.cgi?id=162835
+
+        Reviewed by Simon Fraser.
+
+        We've come across multiple layout/painting bugs caused by renderers left dirty
+        after FrameView::layout(). This patch helps catching such issues early.
+        Once all the blocking bugs are fixed (webkit.org/b/162835), logging should be replaced with ASSERT(). 
+
+        Not testable.
+
+        * page/FrameView.cpp:
+        (WebCore::RenderTreeNeedsLayoutChecker::~RenderTreeNeedsLayoutChecker):
+        (WebCore::FrameView::layout):
+
 2016-10-03  Brent Fulgham  <[email protected]>
 
         [Win][Direct2D] Add D2D Bitmap Image handling code

Modified: trunk/Source/WebCore/page/FrameView.cpp (206742 => 206743)


--- trunk/Source/WebCore/page/FrameView.cpp	2016-10-03 20:22:57 UTC (rev 206742)
+++ trunk/Source/WebCore/page/FrameView.cpp	2016-10-03 20:26:00 UTC (rev 206743)
@@ -202,6 +202,40 @@
     bool m_didDisableLayoutState { false };
 };
 
+#ifndef NDEBUG
+class RenderTreeNeedsLayoutChecker {
+public :
+    RenderTreeNeedsLayoutChecker(const RenderElement& layoutRoot)
+        : m_layoutRoot(layoutRoot)
+    {
+    }
+
+    ~RenderTreeNeedsLayoutChecker()
+    {
+        auto reportNeedsLayoutError = [] (const RenderObject& renderer) {
+            WTFReportError(__FILE__, __LINE__, WTF_PRETTY_FUNCTION, "post-layout: dirty renderer(s)");
+            renderer.showRenderTreeForThis();
+        };
+
+        if (m_layoutRoot.needsLayout()) {
+            reportNeedsLayoutError(m_layoutRoot);
+            return;
+        }
+
+        for (auto* descendant = m_layoutRoot.firstChild(); descendant; descendant = descendant->nextInPreOrder(&m_layoutRoot)) {
+            if (!descendant->needsLayout())
+                continue;
+            
+            reportNeedsLayoutError(*descendant);
+            return;
+        }
+    }
+
+private:
+    const RenderElement& m_layoutRoot;
+};
+#endif
+
 FrameView::FrameView(Frame& frame)
     : m_frame(frame)
     , m_canHaveScrollbars(true)
@@ -1421,7 +1455,9 @@
         forceLayoutParentViewIfNeeded();
 
         ASSERT(m_layoutPhase == InRenderTreeLayout);
-
+#ifndef NDEBUG
+        RenderTreeNeedsLayoutChecker checker(*root);
+#endif
         root->layout();
 
 #if ENABLE(TEXT_AUTOSIZING)
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to