New issue
Advanced search Search tips

Issue 697233 link

Starred by 3 users

Issue metadata

Status: Available
Owner: ----
Components:
EstimatedDays: ----
NextAction: ----
OS: Linux , Android , Windows , Chrome , Mac
Pri: 2
Type: Bug
Team-Blink-Paint

Blocking:
issue 753706



Sign in to add a comment

getBoundingClientRect() wrong when printing

Project Member Reported by anomaly@chromium.org, Feb 28 2017

Issue description

Chrome Version: 56.0.2924.87 (Official Build) (64-bit)
OS: Mac OS X 10.12.3

What steps will reproduce the problem?
(1) Open the attached HTML. Use a browser window size different from print size.
(2) View the JavaScript console output. Observe the logged width and height values.
(3) Open print preview (cmd-P on Mac) and dismiss. Observe the logged width and height values during print preview are the same as before, but should be different. Observe also that the print preview showed the SVG elements were resized correctly for layout.

What is the expected result?
getBoundingClientRect() should return the width and height of the element in print layout.

What happens instead?
getBoundingClientRect() returns the width and height of the element in the original client layout.

Please use labels and text to provide additional information.
This bug prevents redrawing SVG charts (e.g., D3) so that they print correctly, unless the browser window happens to be at approximately the same size as the printed page.

For graphics-related bugs, please copy/paste the contents of the about:gpu
page at the end of this report.

 
test-print.html
633 bytes View Download
Hmm, the plot thickens. In the original repro, I attached to the 'resize' event. In this update, I also used matchMedia('print'). When opening and dismissing print preview, this fires twice (!) (once before resize, once after), and the first one has the correct width and height for printing, but the second reverts to the original values.

This will be enough for me to implement a temporary Chrome-specific work around, but there appears to be something(s) broken here.
test-print.html
2.0 KB View Download
Components: Internals>Printing Blink>Layout

Comment 3 by e...@chromium.org, Mar 5 2017

Labels: -Pri-2 Pri-3
Status: Available (was: Untriaged)

Comment 4 by pdr@chromium.org, Aug 16 2017

Components: Blink>SVG
Blocking: 753706
Labels: -Pri-3 PaintTeamTriaged-20170816 BugSource-User Pri-2
Based on the report for http://crbug.com/753706, this seems like a fairly important issue. Raising priority and marking as blocking.
I faced the same issue.

Two remarks: SVG is unrelated to the issue. If we replace <svg> to <div> in the above example, the behavior would be the same.

You also can test the incorrect resize behavior by switching portrait/album paper orientation, choose other paper size or custom fields in Google Chrome Preview.

I also found a possible workaround: we can use an `event.matches` field in the `matchMedia` event handler to calculate only valid element sizes when necessary.

I added this workaround to the latest `test-print.html`. Thanks, anomaly@chromium.org for building good test example.
test-print.html
2.1 KB View Download
Components: -Blink>SVG
Labels: OS-Android OS-Chrome OS-Linux OS-Windows
Project Member

Comment 8 by sheriffbot@chromium.org, Jan 11

Labels: Hotlist-Recharge-Cold
Status: Untriaged (was: Available)
This issue has been Available for over a year. If it's no longer important or seems unlikely to be fixed, please consider closing it out. If it is important, please re-triage the issue.

Sorry for the inconvenience if the bug really should have been left as Available.

For more details visit https://www.chromium.org/issue-tracking/autotriage - Your friendly Sheriffbot
From the printing side, we have no idea how getBoundingClientRect() works. So it's up to Blink folks to figure this one out.
Components: -Internals>Printing Blink>Geometry

Comment 11 by e...@chromium.org, Jan 17 (6 days ago)

Status: Available (was: Untriaged)

Sign in to add a comment