Index: Source/core/dom/Document.cpp |
diff --git a/Source/core/dom/Document.cpp b/Source/core/dom/Document.cpp |
index 5879d9a07fb91dab241f9e23de00996dc648ec2e..1bd554bbe5db9a68d8d9713027d2200e44a82e83 100644 |
--- a/Source/core/dom/Document.cpp |
+++ b/Source/core/dom/Document.cpp |
@@ -1887,32 +1887,6 @@ void Document::clearFocusedElementTimerFired(Timer<Document>*) |
setFocusedElement(nullptr); |
} |
-void Document::recalcStyleForLayoutIgnoringPendingStylesheets() |
-{ |
- ASSERT(m_styleEngine->ignoringPendingStylesheets()); |
- |
- if (!m_styleEngine->hasPendingSheets()) |
- return; |
- |
- // FIXME: We are willing to attempt to suppress painting with outdated style info only once. |
- // Our assumption is that it would be dangerous to try to stop it a second time, after page |
- // content has already been loaded and displayed with accurate style information. (Our |
- // suppression involves blanking the whole page at the moment. If it were more refined, we |
- // might be able to do something better.) It's worth noting though that this entire method |
- // is a hack, since what we really want to do is suspend JS instead of doing a layout with |
- // inaccurate information. |
- HTMLElement* bodyElement = body(); |
- if (bodyElement && !bodyElement->renderer() && m_pendingSheetLayout == NoLayoutWithPendingSheets) { |
- m_pendingSheetLayout = DidLayoutWithPendingSheets; |
- styleResolverChanged(RecalcStyleImmediately); |
- } else if (m_hasNodesWithPlaceholderStyle) { |
- // If new nodes have been added or style recalc has been done with style sheets still |
- // pending, some nodes may not have had their real style calculated yet. Normally this |
- // gets cleaned when style sheets arrive but here we need up-to-date style immediately. |
- updateStyle(Force); |
- } |
-} |
- |
// FIXME: This is a bad idea and needs to be removed eventually. |
// Other browsers load stylesheets before they continue parsing the web page. |
// Since we don't, we can run JavaScript code that needs answers before the |
@@ -1922,8 +1896,29 @@ void Document::recalcStyleForLayoutIgnoringPendingStylesheets() |
void Document::updateLayoutIgnorePendingStylesheets(Document::RunPostLayoutTasks runPostLayoutTasks) |
{ |
StyleEngine::IgnoringPendingStylesheet ignoring(m_styleEngine.get()); |
- recalcStyleForLayoutIgnoringPendingStylesheets(); |
+ |
+ if (m_styleEngine->hasPendingSheets()) { |
+ // FIXME: We are willing to attempt to suppress painting with outdated style info only once. |
+ // Our assumption is that it would be dangerous to try to stop it a second time, after page |
+ // content has already been loaded and displayed with accurate style information. (Our |
+ // suppression involves blanking the whole page at the moment. If it were more refined, we |
+ // might be able to do something better.) It's worth noting though that this entire method |
+ // is a hack, since what we really want to do is suspend JS instead of doing a layout with |
+ // inaccurate information. |
+ HTMLElement* bodyElement = body(); |
+ if (bodyElement && !bodyElement->renderer() && m_pendingSheetLayout == NoLayoutWithPendingSheets) { |
+ m_pendingSheetLayout = DidLayoutWithPendingSheets; |
+ styleResolverChanged(RecalcStyleImmediately); |
+ } else if (m_hasNodesWithPlaceholderStyle) { |
+ // If new nodes have been added or style recalc has been done with style sheets still |
+ // pending, some nodes may not have had their real style calculated yet. Normally this |
+ // gets cleaned when style sheets arrive but here we need up-to-date style immediately. |
+ updateStyle(Force); |
+ } |
+ } |
+ |
updateLayout(); |
+ |
if (runPostLayoutTasks == RunPostLayoutTasksSynchronously && view()) |
view()->flushAnyPendingPostLayoutTasks(); |
} |