From 6cf72c16d2b222e5d1c0b2a822df8b8249e94dd1 Mon Sep 17 00:00:00 2001 From: Traian Captan Date: Wed, 12 Oct 2022 21:51:38 -0700 Subject: [PATCH] Snap Border and Outline Widths before Layout MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Chrome renders a 1 pixel gap between a parent's border and a child's background, when a sub pixel borders widths decimal value is greater than or equal to 0.5. This happens because * the parent's size gets calculated at layout time with the sub pixel values * the child's position gets calculated based on the parent's position and size * the border width gets floored at paint time to just the whole value This leaves a 1 pixel gap between the last pixel in the parent's border and the first pixel in the child's background. This behavior is a regression introduced in: https://chromium-review.googlesource.com/c/chromium/src/+/2199140 Which changed Chrome to "Use floor instead of round for decimal border widths" with the intent to increase interop with Firefox and Safari which both floor borders. Previously Chrome was rounding the borders at Paint time, avoiding the gaps between a parent's border and a child's background. The proposed fix is to snap (floor) the borders widths before layout, matching what Gecko and WebKit do. Outline widths also use `ConvertBorderWidth` as their conversion function and will also be snapped before layout. CSS isses: https://github.com/w3c/csswg-drafts/issues/5210 https://github.com/w3c/csswg-drafts/issues/7473 R=pdr Change-Id: Ib32ba28e4f193ba79f90f96771378abaf0c589a8 Bug: 1120347, 1201762 --- ...border-width-computed-value.tentative.html | 48 ++++++++++ ...n-rule-width-computed-value.tentative.html | 94 +++++++++++++++++++ ...utline-width-computed-value.tentative.html | 48 ++++++++++ ...er-width-computed-value-ref.tentative.html | 44 +++++++++ ...le-width-computed-value-ref.tentative.html | 92 ++++++++++++++++++ ...ne-width-computed-value-ref.tentative.html | 44 +++++++++ .../subpixel-collapsed-borders-003-ref.html | 3 +- .../subpixel-collapsed-borders-003.html | 7 +- .../parsing/outline-width-computed.html | 2 +- 9 files changed, 377 insertions(+), 5 deletions(-) create mode 100644 css/css-borders/border-width-computed-value.tentative.html create mode 100644 css/css-borders/column-rule-width-computed-value.tentative.html create mode 100644 css/css-borders/outline-width-computed-value.tentative.html create mode 100644 css/css-borders/reference/border-width-computed-value-ref.tentative.html create mode 100644 css/css-borders/reference/column-rule-width-computed-value-ref.tentative.html create mode 100644 css/css-borders/reference/outline-width-computed-value-ref.tentative.html diff --git a/css/css-borders/border-width-computed-value.tentative.html b/css/css-borders/border-width-computed-value.tentative.html new file mode 100644 index 000000000000000..15fb77810579e96 --- /dev/null +++ b/css/css-borders/border-width-computed-value.tentative.html @@ -0,0 +1,48 @@ + + + + + CSS Border: width computed value + + + + + + + + + + + + +

+ Test passes if border widths are rounded up + when they are greater than 0 and less than 1, + and rounded down when they are greater than 1. +

+ +
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ + diff --git a/css/css-borders/column-rule-width-computed-value.tentative.html b/css/css-borders/column-rule-width-computed-value.tentative.html new file mode 100644 index 000000000000000..7c3f326ee5de632 --- /dev/null +++ b/css/css-borders/column-rule-width-computed-value.tentative.html @@ -0,0 +1,94 @@ + + + + + CSS Column-Rule: width computed value + + + + + + + + + + + + +

+ Test passes if column rule widths are rounded up + when they are greater than 0 and less than 1, + and rounded down when they are greater than 1. +

+ +
+ Lorem ipsum dolor sit amet, + consectetur adipisicing elit, + sed do eiusmod tempor incididunt + ut labore et dolore magna aliqua. +
+ +
+ Lorem ipsum dolor sit amet, + consectetur adipisicing elit, + sed do eiusmod tempor incididunt + ut labore et dolore magna aliqua. +
+ +
+ Lorem ipsum dolor sit amet, + consectetur adipisicing elit, + sed do eiusmod tempor incididunt + ut labore et dolore magna aliqua. +
+ +
+ Lorem ipsum dolor sit amet, + consectetur adipisicing elit, + sed do eiusmod tempor incididunt + ut labore et dolore magna aliqua. +
+ +
+ Lorem ipsum dolor sit amet, + consectetur adipisicing elit, + sed do eiusmod tempor incididunt + ut labore et dolore magna aliqua. +
+ +
+ Lorem ipsum dolor sit amet, + consectetur adipisicing elit, + sed do eiusmod tempor incididunt + ut labore et dolore magna aliqua. +
+ +
+ Lorem ipsum dolor sit amet, + consectetur adipisicing elit, + sed do eiusmod tempor incididunt + ut labore et dolore magna aliqua. +
+ +
+ Lorem ipsum dolor sit amet, + consectetur adipisicing elit, + sed do eiusmod tempor incididunt + ut labore et dolore magna aliqua. +
+ +
+ Lorem ipsum dolor sit amet, + consectetur adipisicing elit, + sed do eiusmod tempor incididunt + ut labore et dolore magna aliqua. +
+ + diff --git a/css/css-borders/outline-width-computed-value.tentative.html b/css/css-borders/outline-width-computed-value.tentative.html new file mode 100644 index 000000000000000..82c0c2752c4ddf6 --- /dev/null +++ b/css/css-borders/outline-width-computed-value.tentative.html @@ -0,0 +1,48 @@ + + + + + CSS Outline: width computed value + + + + + + + + + + + + +

+ Test passes if outline widths are rounded up + when they are greater than 0 and less than 1, + and rounded down when they are greater than 1. +

+ +
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ + diff --git a/css/css-borders/reference/border-width-computed-value-ref.tentative.html b/css/css-borders/reference/border-width-computed-value-ref.tentative.html new file mode 100644 index 000000000000000..d35ea10a0cfb512 --- /dev/null +++ b/css/css-borders/reference/border-width-computed-value-ref.tentative.html @@ -0,0 +1,44 @@ + + + + + CSS Border: width computed value + + + + + + + + +

+ Test passes if border widths are rounded up + when they are greater than 0 and less than 1, + and rounded down when they are greater than 1. +

+ +
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ + diff --git a/css/css-borders/reference/column-rule-width-computed-value-ref.tentative.html b/css/css-borders/reference/column-rule-width-computed-value-ref.tentative.html new file mode 100644 index 000000000000000..47300675fb84313 --- /dev/null +++ b/css/css-borders/reference/column-rule-width-computed-value-ref.tentative.html @@ -0,0 +1,92 @@ + + + + + + CSS Column-Rule: width computed value + + + + + + + + +

+ Test passes if column rule widths are rounded up + when they are greater than 0 and less than 1, + and rounded down when they are greater than 1. +

+ +
+ Lorem ipsum dolor sit amet, + consectetur adipisicing elit, + sed do eiusmod tempor incididunt + ut labore et dolore magna aliqua. +
+ +
+ Lorem ipsum dolor sit amet, + consectetur adipisicing elit, + sed do eiusmod tempor incididunt + ut labore et dolore magna aliqua. +
+ +
+ Lorem ipsum dolor sit amet, + consectetur adipisicing elit, + sed do eiusmod tempor incididunt + ut labore et dolore magna aliqua. +
+ +
+ Lorem ipsum dolor sit amet, + consectetur adipisicing elit, + sed do eiusmod tempor incididunt + ut labore et dolore magna aliqua. +
+ +
+ Lorem ipsum dolor sit amet, + consectetur adipisicing elit, + sed do eiusmod tempor incididunt + ut labore et dolore magna aliqua. +
+ +
+ Lorem ipsum dolor sit amet, + consectetur adipisicing elit, + sed do eiusmod tempor incididunt + ut labore et dolore magna aliqua. +
+ +
+ Lorem ipsum dolor sit amet, + consectetur adipisicing elit, + sed do eiusmod tempor incididunt + ut labore et dolore magna aliqua. +
+ +
+ Lorem ipsum dolor sit amet, + consectetur adipisicing elit, + sed do eiusmod tempor incididunt + ut labore et dolore magna aliqua. +
+ +
+ Lorem ipsum dolor sit amet, + consectetur adipisicing elit, + sed do eiusmod tempor incididunt + ut labore et dolore magna aliqua. +
+ + + diff --git a/css/css-borders/reference/outline-width-computed-value-ref.tentative.html b/css/css-borders/reference/outline-width-computed-value-ref.tentative.html new file mode 100644 index 000000000000000..7ad93f252710c57 --- /dev/null +++ b/css/css-borders/reference/outline-width-computed-value-ref.tentative.html @@ -0,0 +1,44 @@ + + + + + CSS Outline: width computed value + + + + + + + + +

+ Test passes if outline widths are rounded up + when they are greater than 0 and less than 1, + and rounded down when they are greater than 1. +

+ +
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ + diff --git a/css/css-tables/subpixel-collapsed-borders-003-ref.html b/css/css-tables/subpixel-collapsed-borders-003-ref.html index 78e0be389393e23..46049a0f1bff661 100644 --- a/css/css-tables/subpixel-collapsed-borders-003-ref.html +++ b/css/css-tables/subpixel-collapsed-borders-003-ref.html @@ -12,7 +12,8 @@ } -

There should be a square with a green border, not a red border. +

+ There should be a square with a green border, not a red border.

diff --git a/css/css-tables/subpixel-collapsed-borders-003.html b/css/css-tables/subpixel-collapsed-borders-003.html index e22df9e51a6a394..ce24f3d6f265690 100644 --- a/css/css-tables/subpixel-collapsed-borders-003.html +++ b/css/css-tables/subpixel-collapsed-borders-003.html @@ -4,7 +4,7 @@ - + -

There should be a square with a green border, not a red border. +

+ There should be a square with a green border, not a red border.

diff --git a/css/css-ui/parsing/outline-width-computed.html b/css/css-ui/parsing/outline-width-computed.html index abd5826bbb387ec..17b56d46631e36c 100644 --- a/css/css-ui/parsing/outline-width-computed.html +++ b/css/css-ui/parsing/outline-width-computed.html @@ -24,7 +24,7 @@