Wide image above div distorts div width on print
Reported by
howard.w...@gmail.com,
Mar 17 2017
|
|||||
Issue descriptionUserAgent: Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/57.0.2987.110 Safari/537.36 Steps to reproduce the problem: 1. Open attached html in chrome 2. Right-click/print / The div should be 100% 3. Renders correctly in dev tools/rendering/emulate css media What is the expected behavior? The div should be 100% What went wrong? The div should be 100% width and it is not. If I change the image width to 700 it renders as expected. Sample of 700 width commented out in attached html. Did this work before? N/A Does this work in other browsers? Yes Chrome version: 57.0.2987.110 Channel: stable OS Version: 6.1 (Windows 7, Windows Server 2008 R2) Flash Version:
,
Mar 21 2017
,
Mar 21 2017
,
Mar 21 2017
,
Mar 21 2017
Confirming what you see. Indeed caused by r428626. Attaching simplified test. Should probably come up with one that uses multicol instead of printing, since that's less tedious to test.
,
Mar 21 2017
No equivalent testcase for multicol is possible. This is a pure printing bug. The shrink-to-fit machinery for printing resizes the LayoutView when it needs to zoom out to fit everything (in our case the wide DIV, which was an IMG in the original test case) on the page. It resizes LayoutView outside of layout, which is bad and evil. Then the layout engine has no means of detecting the size change, which in turn means that the auto-width descendants (HTML and then BODY and then the DIV) won't be relaid out. So r428626 really only made an existing bug more visible.
,
Mar 21 2017
Do you have any suggestions on how the printing code can work better with the layout engine?
,
Mar 21 2017
I don't know how LayoutView gets its size when the browser window is resized, but ideally printing should work the same way. In general, it would be great to get rid of all such printing peculiarities. Also, not temporarily reformatting the current screen document for printing (and back to screen afterwards) when printing would be good. Cloning all data structures (DOM and layout) would be a cleaner way, but there may be reasons why that's not feasible, for all I know. I'm speaking as a layout person here. :) Finally, writing printing tests for layout wasn't exactly easy last time I tried. I don't know how to write a LayoutTest for this bug, for instance. https://bugs.chromium.org/p/chromium/issues/detail?id=664235#c9 suggests that this is also preventing us from fixing that bug.
,
Mar 22 2017
The test case I attached represents a div container for a full page business form. A letterhead image sets on top of the div in the body. The proof of concept document (a full page business form) renders to print correctly. In case that's any help.
,
Mar 22 2017
Discovered that if I set the body min-width to the size of the image in my test case that it will render to print correctly. It works on the simplified test also. In case that's any help.
,
Mar 22 2017
Thanks. That makes sense, because, if you set the final BODY width right away, #container gets its final width right away, and it won't need a second layout pass.
,
May 31 2017
The following revision refers to this bug: https://chromium.googlesource.com/chromium/src.git/+/7d39380b14728b8debd8bcc73672ff778018f63e commit 7d39380b14728b8debd8bcc73672ff778018f63e Author: mstensho <mstensho@opera.com> Date: Wed May 31 10:06:06 2017 Always relayout children of LayoutView when printing. We can normally trust UpdateLogicalWidth() to detect and report size changes, but this is not the case when printing, because FrameView::ForceLayoutForPagination() changes the logical width of the LayoutView behind our back. BUG= 702778 Review-Url: https://codereview.chromium.org/2908503003 Cr-Commit-Position: refs/heads/master@{#475862} [add] https://crrev.com/7d39380b14728b8debd8bcc73672ff778018f63e/third_party/WebKit/LayoutTests/printing/block-width-relayout-shrink-expected.html [add] https://crrev.com/7d39380b14728b8debd8bcc73672ff778018f63e/third_party/WebKit/LayoutTests/printing/block-width-relayout-shrink.html [modify] https://crrev.com/7d39380b14728b8debd8bcc73672ff778018f63e/third_party/WebKit/Source/core/layout/LayoutView.cpp [modify] https://crrev.com/7d39380b14728b8debd8bcc73672ff778018f63e/third_party/WebKit/Source/core/layout/LayoutView.h
,
May 31 2017
|
|||||
►
Sign in to add a comment |
|||||
Comment 1 by rjwright@chromium.org
, Mar 19 2017Labels: Needs-Bisect
Status: Untriaged (was: Unconfirmed)