Intent to Prototype and Ship: Snap border, outline and column-rule widths before layout

173 views
Skip to first unread message

Traian Captan

unread,
Sep 28, 2022, 3:02:43 PM9/28/22
to blin...@chromium.org

Contact emails

tca...@chromium.org


Explainer

Though not a formal explainer, Emilio has an excellent writeup of this issue at https://crisal.io/words/2020/06/13/rounding-borders.html.


Spec

With this change to blink, all implementations will agree, and this can be specified (see: https://github.com/w3c/csswg-drafts/issues/5210).


Summary

Snap border, outline and column-rule widths before layout to avoid gaps between backgrounds and borders caused by paint-time snapping. With this change, Blink will match Gecko and WebKit.


Blink component

Blink


Motivation

Currently Blink snaps the border widths at paint time. This can cause a visible 1px gap between a parent element's border and a child's background when the border is rounded down during paint since the snapping floors the value but the layout rounded it up to calculate the child’s s position (eg border-width is set to 10.75 pixels, rounded to 10px at paint time, but 11 at layout time). By making this change Blink will also behave like Gecko and WebKit and increase interoperability.


Search tags

border-width, outline-widthcolumn-rule-width


TAG review

Skipping because this is a straightforward interop fix.


TAG review status

N/A


Risks

Interoperability and Compatibility

Gecko and WebKit already snap borders before layout.

This change would make Blink behave the same and increase interoperability and compatibility.

The explainer section has a link to a blog post describing the differences in more detail.

This issue and the proposed fix have been discussed in: Issue 1201762: [Task] Investigate border snapping before layout, which is currently blocking 10 issues.

 

This issue was also discussed on:

https://github.com/w3c/csswg-drafts/issues/2114

https://github.com/w3c/csswg-drafts/issues/5210




Gecko: Shipped/Shipping


WebKit: Shipped/Shipping


Web developers: Strongly positive - This has been reported in at least 10 separate bugs with a cumulative star count of 75.


Other signals:


WebView application risks

Does this intent deprecate or change behavior of existing APIs, such that it has potentially high risk for Android WebView-based applications?

No



Debuggability

N/A



Will this feature be supported on all six Blink platforms (Windows, Mac, Linux, Chrome OS, Android, and Android WebView)?

Yes


Is this feature fully tested by web-platform-tests?

New test will be added with the patch.


Flag name

Requires code in //chrome?

False

 

Tracking bug

https://crbug.com/1201762

 

Launch bug

https://crbug.com/1120347

Estimated milestones

M108

Anticipated spec changes

Open questions about a feature may be a source of future web compat or interop issues. Please list open issues (e.g. links to known github issues in the project for the feature specification) whose resolution may introduce web compat/interop risk (e.g., changing to naming or structure of the API in a non-backward-compatible way).

https://github.com/w3c/csswg-drafts/issues/5210

Link to entry on the Chrome Platform Status

https://chromestatus.com/feature/4651561863610368

This intent message was generated by Chrome Platform Status.


Mike Taylor

unread,
Sep 29, 2022, 3:15:29 PM9/29/22
to Traian Captan, blin...@chromium.org
On 9/28/22 3:01 PM, Traian Captan wrote:

Contact emails

tca...@chromium.org


Explainer

Though not a formal explainer, Emilio has an excellent writeup of this issue at https://crisal.io/words/2020/06/13/rounding-borders.html.


Spec

With this change to blink, all implementations will agree, and this can be specified (see: https://github.com/w3c/csswg-drafts/issues/5210).

Is there any current blocker to specifying this (besides someone doing the work)?
--
You received this message because you are subscribed to the Google Groups "blink-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to blink-dev+...@chromium.org.
To view this discussion on the web visit https://groups.google.com/a/chromium.org/d/msgid/blink-dev/CAFxahvsyqk3h2TZwDVJzb1KVgLjqmWDWMs3V9-1sZRA7pXkyOQ%40mail.gmail.com.


Chris Harrelson

unread,
Sep 29, 2022, 3:17:10 PM9/29/22
to Mike Taylor, Traian Captan, blink-dev
On Thu, Sep 29, 2022 at 12:15 PM Mike Taylor <mike...@chromium.org> wrote:
On 9/28/22 3:01 PM, Traian Captan wrote:

Contact emails

tca...@chromium.org


Explainer

Though not a formal explainer, Emilio has an excellent writeup of this issue at https://crisal.io/words/2020/06/13/rounding-borders.html.


Spec

With this change to blink, all implementations will agree, and this can be specified (see: https://github.com/w3c/csswg-drafts/issues/5210).

Is there any current blocker to specifying this (besides someone doing the work)?

 Currently, the specs intentionally avoid specifying pixel-snapping behavior, and instead leave it up to engines to decide how they want to do it. Changing that would be a significant effort.

Philip Rogers

unread,
Sep 29, 2022, 5:55:01 PM9/29/22
to blink-dev, Chris Harrelson, tca...@chromium.org, blink-dev, mike...@chromium.org
On Thursday, September 29, 2022 at 12:17:10 PM UTC-7 Chris Harrelson wrote:
On Thu, Sep 29, 2022 at 12:15 PM Mike Taylor <mike...@chromium.org> wrote:
On 9/28/22 3:01 PM, Traian Captan wrote:

Contact emails

tca...@chromium.org


Explainer

Though not a formal explainer, Emilio has an excellent writeup of this issue at https://crisal.io/words/2020/06/13/rounding-borders.html.


Spec

With this change to blink, all implementations will agree, and this can be specified (see: https://github.com/w3c/csswg-drafts/issues/5210).

Is there any current blocker to specifying this (besides someone doing the work)?

 Currently, the specs intentionally avoid specifying pixel-snapping behavior, and instead leave it up to engines to decide how they want to do it. Changing that would be a significant effort.

Once this change lands, won't it be straightforward to specify this specific aspect of snapping? This change is visible in the computed style.

Philip Jägenstedt

unread,
Oct 5, 2022, 11:48:37 AM10/5/22
to Philip Rogers, blink-dev, Chris Harrelson, tca...@chromium.org, mike...@chromium.org
LGTM1 with some strings attached.

We discussed this in the API owners meeting (present: Chris, Yoav, Mike, Daniel, me)

Since this matches other implementations and is somewhat deliberate unspec'd, shipping this sounds good. Very nice to see highly starred interop issues being fixed :)

Great that tests will be added, presumably those will be tentative due to a lack of a spec.

Traian, Philip, since this will be interoperable, can you propose a spec change that would define it? Or if that runs into some roadblock, can you loop back to this thread? (This does not block shipping.)

Yoav Weiss

unread,
Oct 6, 2022, 1:01:23 AM10/6/22
to Philip Jägenstedt, Philip Rogers, blink-dev, Chris Harrelson, tca...@chromium.org, mike...@chromium.org

Mike Taylor

unread,
Oct 6, 2022, 9:16:03 AM10/6/22
to Yoav Weiss, Philip Jägenstedt, Philip Rogers, blink-dev, Chris Harrelson, tca...@chromium.org
LGTM3, assuming we have useful tests.
Reply all
Reply to author
Forward
0 new messages