Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(814)

Unified Diff: Source/core/dom/Document.cpp

Issue 1156273002: Add assert that updateLayoutTree clears dirty bits. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Check the accept conditions for documents. Created 5 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: Source/core/dom/Document.cpp
diff --git a/Source/core/dom/Document.cpp b/Source/core/dom/Document.cpp
index 0c62d74ae835d3206f7712a5c853869eb9d488dd..051d4d2969e4b60cc15fdbab7cc9e8f0d5ce3a9c 100644
--- a/Source/core/dom/Document.cpp
+++ b/Source/core/dom/Document.cpp
@@ -1683,6 +1683,30 @@ void Document::inheritHtmlAndBodyElementStyles(StyleRecalcChange change)
}
}
+#if ENABLE(ASSERT)
+static void assertLayoutTreeUpdated(Node& root)
+{
+ for (Node& node : NodeTraversal::inclusiveDescendantsOf(root)) {
+ // We leave some nodes with dirty bits in the tree because they don't
+ // matter like Comment and ProcessingInstruction nodes.
+ if (!node.isElementNode()
+ && !node.isTextNode()
+ && !node.isShadowRoot()
+ && !node.isDocumentNode())
+ continue;
+
+ ASSERT(!node.needsStyleRecalc());
+ ASSERT(!node.childNeedsStyleRecalc());
+ ASSERT(!node.childNeedsDistributionRecalc());
+ ASSERT(!node.needsStyleInvalidation());
+ ASSERT(!node.childNeedsStyleInvalidation());
+
+ for (ShadowRoot* shadowRoot = node.youngestShadowRoot(); shadowRoot; shadowRoot = shadowRoot->olderShadowRoot())
+ assertLayoutTreeUpdated(*shadowRoot);
+ }
+}
+#endif
+
void Document::updateLayoutTree(StyleRecalcChange change)
{
ASSERT(isMainThread());
@@ -1748,6 +1772,10 @@ void Document::updateLayoutTree(StyleRecalcChange change)
ASSERT(!m_timeline->hasOutdatedAnimation());
+#if ENABLE(ASSERT)
+ assertLayoutTreeUpdated(*this);
+#endif
+
TRACE_EVENT_END1(TRACE_DISABLED_BY_DEFAULT("devtools.timeline"), "RecalculateStyles", "elementCount", m_styleRecalcElementCounter);
TRACE_EVENT_END1("blink", "Document::updateLayoutTree", "elementCount", m_styleRecalcElementCounter);
InspectorInstrumentation::didRecalculateStyle(cookie, m_styleRecalcElementCounter);

Powered by Google App Engine
This is Rietveld 408576698