Open Bug 1622017 Opened 4 years ago Updated 3 years ago

vh & vw units are too large (and depend on DPI), in printed / print-previewed documents

Categories

(Core :: Layout, defect, P3)

defect

Tracking

()

People

(Reporter: dholbert, Unassigned)

References

Details

(Whiteboard: [print2020])

Attachments

(5 files)

Attached file testcase 1

STR:

  1. View attached testcase.
  2. Print-preview or print.

EXPECTED RESULTS: The two black boxes should be the same size (they should both be 15% of the page's width).

ACTUAL RESULTS: The one that uses vh is too big. It seems vh units are being scaled up by some factor.

The unexpected scale-up factor seems to depend on my DPI.

  • In print-preview with my monitor configured for 100% dpi scaling, the vh box is about 2.5x as big as I'd expect.
  • In print-preview with my monitor configured for 200% dpi scaling, the vh box is about 5-6x as big as I'd expect.
  • In print-to-pdf, the vh box is about 1.2x as big as I'd expect (only slightly larger)

Here's a screenshot taken on dholbert's dell XPS laptop, with Ubuntu resolution settings at 100% scale

Here's a screenshot taken on dholbert's dell XPS laptop, with Ubuntu resolution settings at 200% scale

Attached file print-to-pdf
Whiteboard: [print2020]

Note 1: bug 909780 has a similar description, but it apparently required "a big font-size (> 300px)" so it may be a different issue. --> adding to "see also.

Note 2: this issue (in part) causes our internal page about:rights to fail to print, since that page uses a min-height:100vh flex container whose contents are vertically centered via flex properties. The 100vh height ends up being huge, so the contents don't show up, via bug 939897.

See Also: → 909780
Flags: needinfo?(ksereduck)

Because this bug's Severity has not been changed from the default since it was filed, and it's Priority is P3 (Backlog,) indicating it has been triaged, the bug's Severity is being updated to S3 (normal.)

Severity: normal → S3

Here's a testcase that shows our viewport units are incompatible with Chrome.
When I print this on a printer I see "Hello" clipped vertically about halfway through the text in both Chrome/Firefox, so it appears @page { margin:0; } behaves the same, but I see the right/bottom borders about 3cm in from the edges of the paper in Firefox. Chrome clips the border on all sides so it's not visible at all. I'm guessing our vw/vh units aren't affected by the @page margin at all? whereas Chrome does take it into account?

@emilio, I seem to recall you were discussing viewport units on some CSSWG forum a while back? Was there any consensus on how these should work (in print mode or otherwise)?

Flags: needinfo?(emilio)

See https://github.com/w3c/csswg-drafts/issues/5437, yes.

Chrome does take @page into account while we don't. Doing that generally would cause cycles, and it's not clear what the best way to deal with those is. So I think that our behavior here is generally reasonable now.

Flags: needinfo?(emilio)

Thanks, I think that's the one I saw. Thanks for filing that and summarizing what various UAs do there! I hope we can reach consensus on that because it kind of sucks that authors have to deal with different behavior currently.

You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: