Skip to content

Commit

Permalink
Fix HTMLObjectElement printing in iframes.
Browse files Browse the repository at this point in the history
LazyReattachIfAttached is not idempotent. Calling it will cause
HTMLObjectElements to discard their contents, which must be asynchronously
regenerated. Avoid calling it if we think it won't have an effect.

This still leaves the edge case of HTMLObjectElements in display:none iframes
not printing correctly.

Bug: 838760
Change-Id: I5d4fdbfe7e2710b824c3ecc446385fae09cbc7c7
Reviewed-on: https://chromium-review.googlesource.com/1053882
Commit-Queue: Erik Chen <erikchen@chromium.org>
Reviewed-by: Steve Kobes <skobes@chromium.org>
Cr-Commit-Position: refs/heads/master@{#559652}
  • Loading branch information
erikchen authored and Commit Bot committed May 17, 2018
1 parent 5585713 commit 0bb8bde
Show file tree
Hide file tree
Showing 5 changed files with 53 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
layer at (0,0) size 800x600
LayoutView at (0,0) size 1066x799
layer at (0,0) size 1066x799 backgroundClip at (0,0) size 800x600 clip at (0,0) size 800x600
LayoutBlockFlow {HTML} at (0,0) size 1066x799
LayoutBlockFlow {BODY} at (8,8) size 1050x783
LayoutText {#text} at (0,0) size 0x0
layer at (8,8) size 204x204
LayoutIFrame {IFRAME} at (0,0) size 204x204 [border: (2px inset #EEEEEE)]
layer at (0,0) size 200x200
LayoutView at (0,0) size 200x200
layer at (0,0) size 100x100
LayoutBlockFlow {HTML} at (0,0) size 100x100
LayoutBlockFlow {BODY} at (8,8) size 100x100
LayoutText {#text} at (0,0) size 0x0
layer at (8,8) size 100x100
LayoutEmbeddedObject {OBJECT} at (0,0) size 100x100
layer at (0,0) size 100x100
LayoutView at (0,0) size 100x100
layer at (0,0) size 100x100
LayoutSVGRoot {svg} at (0,0) size 100x100
LayoutSVGEllipse {circle} at (25,25) size 50x50 [fill={[type=SOLID] [color=#0000FF]}] [cx=50.00] [cy=50.00] [r=25.00]

Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<html>
<body>
<iframe src="./resources/iframe-subframe-svg-in-object.html" width="200px" height="200px"></iframe>
</body>
<script>
if (window.testRunner) {
testRunner.setPrinting();
testRunner.dumpAsText();
}
</script>
</html>
6 changes: 6 additions & 0 deletions third_party/WebKit/LayoutTests/printing/resources/circle.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<!DOCTYPE html>
<html style="width: 100px; height:100px;">
<body style="width: 100px; height:100px;">
<object width="100px" height="100px" data="circle.svg" type="image/svg+xml"></object>
</body>
</html>
9 changes: 8 additions & 1 deletion third_party/blink/renderer/core/dom/document.cc
Original file line number Diff line number Diff line change
Expand Up @@ -2907,7 +2907,14 @@ void Document::SetPrinting(PrintingState state) {
// LayoutView::CanHaveChildren.
// https://crbug.com/819327.
if ((was_printing != is_printing) && documentElement() && GetFrame() &&
!GetFrame()->IsMainFrame()) {
!GetFrame()->IsMainFrame() && GetFrame()->Owner() &&
GetFrame()->Owner()->IsDisplayNone()) {
// LazyReattachIfAttached() is not idempotent. HTMLObjectElements will lose
// their contents, which must be asynchronously regenerated. As such, we
// avoid calling this method unless we think that this is a display-none
// iframe and calling this is necessary.
// This still leaves the edge case of a display: none iframe with an
// HTMLObjectElement that doesn't print properly. https://crbug.com/838760.
documentElement()->LazyReattachIfAttached();
}
}
Expand Down

0 comments on commit 0bb8bde

Please sign in to comment.