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

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

Issue 146023008: Add layout states to DocumentLifecycle state machine (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 6 years, 10 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 a56a6f7aaac11f46d0eb5706b8077b9e41587789..003172ee82ea39f3be3b033206c2ead825522078 100644
--- a/Source/core/dom/Document.cpp
+++ b/Source/core/dom/Document.cpp
@@ -1549,15 +1549,31 @@ bool Document::shouldCallRecalcStyleForDocument()
return needsStyleRecalc() || childNeedsStyleRecalc() || childNeedsDistributionRecalc() || !m_useElementsNeedingUpdate.isEmpty() || childNeedsStyleInvalidation();
}
+bool Document::shouldScheduleStyleRecalc()
+{
+ if (!isActive())
+ return false;
+ if (hasPendingStyleRecalc())
+ return false;
+ if (inStyleRecalc())
+ return false;
+ // InPreLayout will recalc style itself. There's no reason to schedule another recalc.
+ if (m_lifecycle.state() == DocumentLifecycle::InPreLayout)
+ return false;
+ if (!shouldScheduleLayout())
+ return false;
+ return true;
+}
+
void Document::scheduleStyleRecalc()
{
- if (hasPendingStyleRecalc() || !isActive() || inStyleRecalc() || !shouldScheduleLayout())
+ if (!shouldScheduleStyleRecalc())
return;
ASSERT(shouldCallRecalcStyleForDocument());
view()->scheduleAnimation();
- m_lifecycle.rewindTo(DocumentLifecycle::StyleRecalcPending);
+ m_lifecycle.advanceTo(DocumentLifecycle::StyleRecalcPending);
InspectorInstrumentation::didScheduleStyleRecalculation(this);
}
@@ -1769,7 +1785,7 @@ void Document::recalcStyle(StyleRecalcChange change)
ASSERT(!needsStyleRecalc());
ASSERT(!childNeedsStyleRecalc());
ASSERT(inStyleRecalc());
- m_lifecycle.advanceTo(DocumentLifecycle::Clean);
+ m_lifecycle.advanceTo(DocumentLifecycle::StyleClean);
}
InspectorInstrumentation::didRecalculateStyle(cookie);
@@ -2049,7 +2065,7 @@ void Document::attach(const AttachContext& context)
ContainerNode::attach(context);
- m_lifecycle.advanceTo(DocumentLifecycle::Clean);
+ m_lifecycle.advanceTo(DocumentLifecycle::StyleClean);
}
void Document::detach(const AttachContext& context)

Powered by Google App Engine
This is Rietveld 408576698