diff --git a/third_party/WebKit/LayoutTests/printing/iframe-svg-in-object-print-expected.txt b/third_party/WebKit/LayoutTests/printing/iframe-svg-in-object-print-expected.txt new file mode 100644 index 00000000000000..c1119b808e6fb1 --- /dev/null +++ b/third_party/WebKit/LayoutTests/printing/iframe-svg-in-object-print-expected.txt @@ -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] + diff --git a/third_party/WebKit/LayoutTests/printing/iframe-svg-in-object-print.html b/third_party/WebKit/LayoutTests/printing/iframe-svg-in-object-print.html new file mode 100644 index 00000000000000..cb0332c6013b90 --- /dev/null +++ b/third_party/WebKit/LayoutTests/printing/iframe-svg-in-object-print.html @@ -0,0 +1,11 @@ + + + + + + diff --git a/third_party/WebKit/LayoutTests/printing/resources/circle.svg b/third_party/WebKit/LayoutTests/printing/resources/circle.svg new file mode 100644 index 00000000000000..3e340f2a78a6c6 --- /dev/null +++ b/third_party/WebKit/LayoutTests/printing/resources/circle.svg @@ -0,0 +1,6 @@ + + + diff --git a/third_party/WebKit/LayoutTests/printing/resources/iframe-subframe-svg-in-object.html b/third_party/WebKit/LayoutTests/printing/resources/iframe-subframe-svg-in-object.html new file mode 100644 index 00000000000000..dab3f3fed0fae4 --- /dev/null +++ b/third_party/WebKit/LayoutTests/printing/resources/iframe-subframe-svg-in-object.html @@ -0,0 +1,6 @@ + + + + + + diff --git a/third_party/blink/renderer/core/dom/document.cc b/third_party/blink/renderer/core/dom/document.cc index e881199fb8884c..3904ad9130f73c 100644 --- a/third_party/blink/renderer/core/dom/document.cc +++ b/third_party/blink/renderer/core/dom/document.cc @@ -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(); } }