Chromium Code Reviews| Index: Source/core/dom/Document.cpp |
| diff --git a/Source/core/dom/Document.cpp b/Source/core/dom/Document.cpp |
| index fff83670193ce1dd38bab7914952d24d3abe66c2..a392a3378bbda2faae190a7d284d8749e4013fd4 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,6 +1763,30 @@ void Document::setNeedsFocusedElementCheck() |
| m_didPostCheckFocusedElementTask = true; |
| } |
| +void Document::recalcStyleForLayoutIgnoringPendingStylesheets() |
| +{ |
| + 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. |
| + 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. |
| + 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 |
| @@ -1768,30 +1795,36 @@ void Document::setNeedsFocusedElementCheck() |
| // to instead suspend JavaScript execution. |
| void Document::updateLayoutIgnorePendingStylesheets() |
| { |
| - bool oldIgnore = m_ignorePendingStylesheets; |
| + TemporaryChange<bool> ignorePendingStylesheets(m_ignorePendingStylesheets, m_ignorePendingStylesheets); |
|
esprehn
2013/09/03 18:15:36
This TemporaryChange should be inside recalcStyleF
pdr.
2013/09/03 21:37:35
Done.
|
| + recalcStyleForLayoutIgnoringPendingStylesheets(); |
| + updateLayout(); |
| +} |
| + |
| +void Document::partialUpdateLayoutIgnorePendingStylesheets(Node* stopLayoutAtNode) |
| +{ |
| + if (!RuntimeEnabledFeatures::partialLayoutEnabled()) |
| + updateLayoutIgnorePendingStylesheets(); |
|
esprehn
2013/09/03 18:15:36
You need to early return, otherwise your code stil
pdr.
2013/09/03 21:37:35
:(
Stupid mistake on my part; good catch.
|
| - 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. |
| - 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. |
| - recalcStyle(Force); |
| + 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(); |
|
esprehn
2013/09/03 18:15:36
I think this needs to be inside FrameView::layout(
pdr.
2013/09/03 21:37:35
I don't think we need to run the post layout tasks
|
| } |
| PassRefPtr<RenderStyle> Document::styleForElementIgnoringPendingStylesheets(Element* element) |