Skip to content

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants