Commit 4f9317ce authored by Fredrik Söderquist's avatar Fredrik Söderquist Committed by Commit Bot

Update style for child SVG documents in PerformPreLayoutTasks

Like in LocalFrameView::UpdateStyleAndLayoutIfNeededRecursive,
explicitly update style (and attach the layout tree) before proceeding
to layout. This ensures that the style update/layout tree attachment of
the child document does not mark its frame owner as dirty after layout
has already been performed for the top-level document.

Bug: 933409
Change-Id: I6b2c864aededed7429c63cbd068ec45c58972ae0
Reviewed-on: https://chromium-review.googlesource.com/c/1481331Reviewed-by: default avatarChris Harrelson <chrishtr@chromium.org>
Commit-Queue: Fredrik Söderquist <fs@opera.com>
Cr-Commit-Position: refs/heads/master@{#635459}
parent 71d4f8fc
...@@ -654,6 +654,16 @@ void LocalFrameView::PerformPreLayoutTasks() { ...@@ -654,6 +654,16 @@ void LocalFrameView::PerformPreLayoutTasks() {
} }
document->UpdateStyleAndLayoutTree(); document->UpdateStyleAndLayoutTree();
// Update style for all embedded SVG documents underneath this frame, so
// that intrinsic size computation for any embedded objects has up-to-date
// information before layout.
ForAllChildLocalFrameViews([](LocalFrameView& view) {
Document& document = *view.GetFrame().GetDocument();
if (document.IsSVGDocument())
document.UpdateStyleAndLayoutTree();
});
Lifecycle().AdvanceTo(DocumentLifecycle::kStyleClean); Lifecycle().AdvanceTo(DocumentLifecycle::kStyleClean);
if (was_resized) if (was_resized)
......
...@@ -329,5 +329,30 @@ TEST_F(LocalFrameViewSimTest, FragmentNavChangesFocusWhileRenderingBlocked) { ...@@ -329,5 +329,30 @@ TEST_F(LocalFrameViewSimTest, FragmentNavChangesFocusWhileRenderingBlocked) {
<< "Scroll offset wasn't changed after load completed."; << "Scroll offset wasn't changed after load completed.";
} }
TEST_F(LocalFrameViewSimTest, ForcedLayoutWithIncompleteSVGChildFrame) {
SimRequest main_resource("https://example.com/test.html", "text/html");
SimRequest svg_resource("https://example.com/file.svg", "image/svg+xml");
LoadURL("https://example.com/test.html");
main_resource.Complete(R"HTML(
<!DOCTYPE html>
<object data="file.svg"></object>
)HTML");
// Write the SVG document so that there is something to layout, but don't let
// the resource finish loading.
svg_resource.Write(R"SVG(
<svg xmlns="http://www.w3.org/2000/svg"></svg>
)SVG");
// Mark the top-level document for layout and then force layout. This will
// cause the layout tree in the <object> object to be built.
GetDocument().View()->SetNeedsLayout();
GetDocument().UpdateStyleAndLayoutIgnorePendingStylesheets();
svg_resource.Finish();
}
} // namespace } // namespace
} // namespace blink } // namespace blink
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment