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

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

Issue 156413002: [WIP] Move layout states into the DocumentLifecycle state machine (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: uber patch 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
« no previous file with comments | « Source/core/dom/Document.h ('k') | Source/core/dom/DocumentLifecycle.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/core/dom/Document.cpp
diff --git a/Source/core/dom/Document.cpp b/Source/core/dom/Document.cpp
index b4e3993c274ca1c784bec08c5c1de641e2402c42..48b75b5f0e3f35baec0baf4df883a2f1603f30ce 100644
--- a/Source/core/dom/Document.cpp
+++ b/Source/core/dom/Document.cpp
@@ -435,7 +435,6 @@ Document::Document(const DocumentInit& initializer, DocumentClassFlags documentC
, m_cssTarget(0)
, m_loadEventProgress(LoadEventNotRun)
, m_startTime(currentTime())
- , m_overMinimumLayoutThreshold(false)
, m_scriptRunner(ScriptRunner::create(this))
, m_xmlVersion("1.0")
, m_xmlStandalone(StandaloneUnspecified)
@@ -1549,9 +1548,23 @@ 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;
+ return true;
+}
+
void Document::scheduleStyleRecalc()
{
- if (hasPendingStyleRecalc() || !isActive() || inStyleRecalc() || !shouldScheduleLayout())
+ if (!shouldScheduleStyleRecalc() || !shouldScheduleLayout())
return;
ASSERT(shouldCallRecalcStyleForDocument());
@@ -1769,7 +1782,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 +2062,7 @@ void Document::attach(const AttachContext& context)
ContainerNode::attach(context);
- m_lifecycle.advanceTo(DocumentLifecycle::Clean);
+ m_lifecycle.advanceTo(DocumentLifecycle::LayoutClean);
}
void Document::detach(const AttachContext& context)
@@ -2432,14 +2445,12 @@ void Document::implicitClose()
// Just bail out. Before or during the onload we were shifted to another page.
// The old i-Bench suite does this. When this happens don't bother painting or laying out.
m_loadEventProgress = LoadEventCompleted;
- view()->unscheduleRelayout();
return;
}
// We used to force a synchronous display and flush here. This really isn't
// necessary and can in fact be actively harmful if pages are loading at a rate of > 60fps
// (if your platform is syncing flushes and limiting them to 60fps).
- m_overMinimumLayoutThreshold = true;
if (!ownerElement() || (ownerElement()->renderer() && !ownerElement()->renderer()->needsLayout())) {
updateStyleIfNeeded();
@@ -2585,19 +2596,7 @@ bool Document::shouldScheduleLayout()
bool Document::shouldParserYieldAgressivelyBeforeScriptExecution()
{
- return view() && view()->layoutPending() && !minimumLayoutDelay();
-}
-
-int Document::minimumLayoutDelay()
-{
- if (m_overMinimumLayoutThreshold)
- return 0;
-
- int elapsed = elapsedTime();
- m_overMinimumLayoutThreshold = elapsed > cLayoutScheduleThreshold;
-
- // We'll want to schedule the timer to fire at the minimum layout threshold.
- return max(0, cLayoutScheduleThreshold - elapsed);
+ return view() && view()->layoutPending();
}
int Document::elapsedTime() const
« no previous file with comments | « Source/core/dom/Document.h ('k') | Source/core/dom/DocumentLifecycle.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698