Skip to content

Add support for device-pixel-content-box-size #3554 #4476

New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Merged
merged 4 commits into from
Nov 8, 2019

Conversation

dlibby-
Copy link
Contributor

@dlibby- dlibby- commented Oct 31, 2019

Minutes: #3554 (comment)

Authors need a way to get the content box size in integral physical pixels. This allows for the correct sizing of the backing store of a canvas to match the snapped CSS size and prevents moire patterns that arise when the sizes are mismatched.

Currently authors could use devicePixelRatio and rounding in order to approximate this, but due to implementation differences in pixel snapping, can still get the wrong answer. Additionally, this can be affected by position changes which authors cannot currently hook into in a reasonable manner.

@dlibby-
Copy link
Contributor Author

dlibby- commented Oct 31, 2019

@gregwhitworth - mind taking a first pass review on this? Please bear with me as this is my first spec PR. Thanks!

@astearns astearns changed the title Add support for device-pixel-border-box-size #3554 Add support for device-pixel-content-box-size #3554 Oct 31, 2019
@dlibby-
Copy link
Contributor Author

dlibby- commented Nov 1, 2019

@atotic @chrishtr - Mind taking a look to make sure I'm not missing anything with this change? Any feedback is much appreciated, thanks!

Reference browser-specific behavior, rather than implementation
specific.

Mention that the device pixels are not affected by transforms.

Clarify which box contentRect refers to.
before applying any CSS transforms on the element or its ancestors.
This size must contain integer values.

<p class="note">
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How about adding a non-normative note specifying a typical way that UAs compute this box?

e.g. "How a UA computes the device pixel box for an element is implementation-dependent. One way could be to multiply the box size and position by the device pixel ratio, then round the resulting (floating-point) size and position of the box to integer values in some way that maximizes quality of rendered output".

<p class="note">
The {{device-pixel-content-box}} can be approximated by multiplying <a>devicePixelRatio</a> by the {{content-box}} size.
However, due to browser-specific subpixel snapping behavior,
authors cannot determine the correct way to round the scaled {{content-box}} size.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

s/the scaled/this scaled/, to make clearer that you're referring to the output of multiplying by devicePixelRatio.

@dlibby- dlibby- merged commit bc14435 into w3c:master Nov 8, 2019
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants