Index: Source/core/dom/Document.cpp |
diff --git a/Source/core/dom/Document.cpp b/Source/core/dom/Document.cpp |
index bada69d3e1731260fae475700b2836ceddb6a922..9050eeddf4864a06bd978629e1e3923a773d237b 100644 |
--- a/Source/core/dom/Document.cpp |
+++ b/Source/core/dom/Document.cpp |
@@ -1748,6 +1748,9 @@ void Document::updateLayout() |
if (frameView && renderer() && (frameView->layoutPending() || renderer()->needsLayout())) |
frameView->layout(); |
+ if (frameView) |
+ frameView->partialLayout().reset(); |
+ |
setNeedsFocusedElementCheck(); |
} |
@@ -1760,38 +1763,64 @@ void Document::setNeedsFocusedElementCheck() |
m_didPostCheckFocusedElementTask = true; |
} |
-// 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 |
-// stylesheets are loaded. Doing a layout ignoring the pending stylesheets |
-// lets us get reasonable answers. The long term solution to this problem is |
-// to instead suspend JavaScript execution. |
-void Document::updateLayoutIgnorePendingStylesheets() |
+void Document::recalcStyleForLayoutIgnoringPendingStylesheets() |
{ |
- bool oldIgnore = m_ignorePendingStylesheets; |
- |
if (!haveStylesheetsLoaded()) { |
m_ignorePendingStylesheets = true; |
- // 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. |
+ // 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) |
ojan
2013/08/27 01:33:41
Nit: moar curly braces plz.
|
- // 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. |
+ // 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. |
recalcStyle(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 |
+// stylesheets are loaded. Doing a layout ignoring the pending stylesheets |
+// lets us get reasonable answers. The long term solution to this problem is |
+// to instead suspend JavaScript execution. |
+void Document::updateLayoutIgnorePendingStylesheets() |
+{ |
+ TemporaryChange<bool> ignorePendingStylesheets(m_ignorePendingStylesheets, m_ignorePendingStylesheets); |
+ recalcStyleForLayoutIgnoringPendingStylesheets(); |
+ updateLayout(); |
+} |
+ |
+void Document::partialUpdateLayoutIgnorePendingStylesheets(Node* stopLayoutAtNode) |
+{ |
+ TemporaryChange<bool> ignorePendingStylesheets(m_ignorePendingStylesheets, m_ignorePendingStylesheets); |
+ recalcStyleForLayoutIgnoringPendingStylesheets(); |
+ |
+ if (stopLayoutAtNode) { |
+ bool canPartialLayout = true; |
+ RenderObject* renderer = stopLayoutAtNode->renderer(); |
+ while (renderer) { |
+ if (!renderer->supportsPartialLayout()) { |
+ canPartialLayout = false; |
+ break; |
+ } |
+ renderer = renderer->parent(); |
+ } |
+ if (canPartialLayout) |
+ view()->partialLayout().setStopAtRenderer(stopLayoutAtNode->renderer()); |
+ } |
updateLayout(); |
- m_ignorePendingStylesheets = oldIgnore; |
+ view()->partialLayout().reset(); |
} |
PassRefPtr<RenderStyle> Document::styleForElementIgnoringPendingStylesheets(Element* element) |