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

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

Issue 14604003: When there are no more stylesheets schedule the recalc async (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Now that we lazyAttach... Created 7 years, 3 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') | no next file » | 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 b2ba85404dafcb1612f45d95646ee0625d1d4edf..7517e92423a45924f19f06f7e4a3c536eb99360d 100644
--- a/Source/core/dom/Document.cpp
+++ b/Source/core/dom/Document.cpp
@@ -385,6 +385,7 @@ Document::Document(const DocumentInit& initializer, DocumentClassFlags documentC
, m_lastStyleResolverAccessTime(0)
, m_didCalculateStyleResolver(false)
, m_ignorePendingStylesheets(false)
+ , m_evaluateMediaQueriesOnStyleRecalc(false)
, m_needsNotifyRemoveAllPendingStylesheet(false)
, m_hasNodesWithPlaceholderStyle(false)
, m_pendingSheetLayout(NoLayoutWithPendingSheets)
@@ -1692,6 +1693,11 @@ void Document::recalcStyle(StyleRecalcChange change)
TRACE_EVENT0("webkit", "Document::recalcStyle");
TRACE_EVENT_SCOPED_SAMPLING_STATE("Blink", "RecalcStyle");
+ if (m_evaluateMediaQueriesOnStyleRecalc) {
+ m_evaluateMediaQueriesOnStyleRecalc = false;
+ evaluateMediaQueryList();
+ }
+
updateDistributionIfNeeded();
// FIXME: We should update style on our ancestor chain before proceeding (especially for seamless),
@@ -2828,7 +2834,7 @@ void Document::didRemoveAllPendingStylesheet()
{
m_needsNotifyRemoveAllPendingStylesheet = false;
- styleResolverChanged(RecalcStyleImmediately, AnalyzedStyleUpdate);
+ styleResolverChanged(RecalcStyleDeferred, AnalyzedStyleUpdate);
executeScriptsWaitingForResourcesIfNeeded();
if (m_gotoAnchorNeededAfterStylesheetsLoad && view())
@@ -3303,34 +3309,21 @@ void Document::styleResolverChanged(StyleResolverUpdateType updateType, StyleRes
bool needsRecalc = m_styleSheetCollections->updateActiveStyleSheets(updateMode);
- if (updateType >= RecalcStyleDeferred) {
- setNeedsStyleRecalc();
- return;
- }
-
if (didLayoutWithPendingStylesheets() && !m_styleSheetCollections->hasPendingSheets()) {
+ // We need to manually repaint because we avoid doing all repaints in layout or style
+ // recalc while sheets are still loading to avoid FOUC.
m_pendingSheetLayout = IgnoreLayoutWithPendingSheets;
- if (renderer())
- renderView()->repaintViewAndCompositedLayers();
+ renderView()->repaintViewAndCompositedLayers();
}
if (!needsRecalc)
return;
- // This recalcStyle initiates a new recalc cycle. We need to bracket it to
- // make sure animations get the correct update time
- {
- AnimationUpdateBlock animationUpdateBlock(m_frame ? m_frame->animation() : 0);
- recalcStyle(Force);
- }
-
- if (renderer()) {
- renderer()->setNeedsLayoutAndPrefWidthsRecalc();
- if (view())
- view()->scheduleRelayout();
- }
+ m_evaluateMediaQueriesOnStyleRecalc = true;
+ setNeedsStyleRecalc();
- evaluateMediaQueryList();
+ if (updateType == RecalcStyleImmediately)
+ updateStyleIfNeeded();
}
void Document::notifySeamlessChildDocumentsOfStylesheetUpdate() const
« no previous file with comments | « Source/core/dom/Document.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698