Title: [286591] trunk
Revision
286591
Author
[email protected]
Date
2021-12-07 00:27:13 -0800 (Tue, 07 Dec 2021)

Log Message

perspective() <= 1px should be clamped to 1px
https://bugs.webkit.org/show_bug.cgi?id=232619
<rdar://problem/85197362>

Reviewed by Simon Fraser.

LayoutTests/imported/w3c:

* web-platform-tests/css/css-transforms/animation/transform-interpolation-verify-reftests-expected.txt: Update to show newly passing subtests.

Source/WebCore:

No new tests. This is covered by the newly passing WPT tests
in this change.

When the CSS 3D transform interoperability experimental feature is turned on,
round perspectives that are < 1 pixel to 1 pixel. This behavior is described
in the specification, but breaks backward compatibility. The reasoning provided
by the specification is:

    As very small <length> values can produce bizarre rendering results and
    stress the numerical accuracy of transform calculations, values less than
    1px must be treated as 1px for rendering purposes.

* platform/graphics/transforms/PerspectiveTransformOperation.h: When getting
the floating point perspective value, round to 1px.
* rendering/RenderLayer.cpp:
(WebCore::RenderLayer::perspectiveTransform const): Use usedPerspective from
RenderSTyle.
* rendering/RenderObject.cpp:
(WebCore::RenderObject::getTransformFromContainer const): Ditto.
* rendering/style/RenderStyle.cpp:
(WebCore::RenderStyle::usedPerspective const): Added this method which rounds
to 1px.
* rendering/style/RenderStyle.h:

LayoutTests:

* TestExpectations: Mark tests as passing.
* transforms/3d/general/3dtransform-values.html:
* transforms/3d/general/prefixed-3dtransform-values.html:
* transforms/3d/general/3dtransform-values-expected.txt:
* transforms/3d/general/prefixed-3dtransform-values-expected.txt:

Modified Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (286590 => 286591)


--- trunk/LayoutTests/ChangeLog	2021-12-07 07:30:07 UTC (rev 286590)
+++ trunk/LayoutTests/ChangeLog	2021-12-07 08:27:13 UTC (rev 286591)
@@ -1,3 +1,17 @@
+2021-12-07  Martin Robinson  <[email protected]>
+
+        perspective() <= 1px should be clamped to 1px
+        https://bugs.webkit.org/show_bug.cgi?id=232619
+        <rdar://problem/85197362>
+
+        Reviewed by Simon Fraser.
+
+        * TestExpectations: Mark tests as passing.
+        * transforms/3d/general/3dtransform-values.html:
+        * transforms/3d/general/prefixed-3dtransform-values.html:
+        * transforms/3d/general/3dtransform-values-expected.txt:
+        * transforms/3d/general/prefixed-3dtransform-values-expected.txt:
+
 2021-12-06  Said Abou-Hallawa  <[email protected]>
 
         [GPU Process]  [Filters] Make FilterEffect::externalRepresentation() and its overridable functions work iteratively

Modified: trunk/LayoutTests/TestExpectations (286590 => 286591)


--- trunk/LayoutTests/TestExpectations	2021-12-07 07:30:07 UTC (rev 286590)
+++ trunk/LayoutTests/TestExpectations	2021-12-07 08:27:13 UTC (rev 286591)
@@ -3922,9 +3922,6 @@
 webkit.org/b/230080 imported/w3c/web-platform-tests/css/css-transforms/perspective-children-only-inline.html [ ImageOnlyFailure ]
 webkit.org/b/230080 imported/w3c/web-platform-tests/css/css-transforms/perspective-containing-block-dynamic-1b.html [ ImageOnlyFailure ]
 webkit.org/b/230080 imported/w3c/web-platform-tests/css/css-transforms/perspective-transforms-equivalence.html [ ImageOnlyFailure ]
-webkit.org/b/230080 imported/w3c/web-platform-tests/css/css-transforms/perspective-zero-2.html [ ImageOnlyFailure ]
-webkit.org/b/230080 imported/w3c/web-platform-tests/css/css-transforms/perspective-zero-3.html [ ImageOnlyFailure ]
-webkit.org/b/230080 imported/w3c/web-platform-tests/css/css-transforms/perspective-zero.html [ ImageOnlyFailure ]
 webkit.org/b/230080 imported/w3c/web-platform-tests/css/css-transforms/preserve3d-and-filter-no-perspective.html [ ImageOnlyFailure ]
 webkit.org/b/230080 imported/w3c/web-platform-tests/css/css-transforms/rotateY-180deg-with-overflow-scroll.html [ ImageOnlyFailure ]
 webkit.org/b/230080 imported/w3c/web-platform-tests/css/css-transforms/rotate_45deg.html [ ImageOnlyFailure ]
@@ -3987,7 +3984,6 @@
 webkit.org/b/230080 imported/w3c/web-platform-tests/css/css-transforms/transform3d-perspective-002.html [ Pass ImageOnlyFailure ]
 webkit.org/b/230080 imported/w3c/web-platform-tests/css/css-transforms/transform3d-perspective-003.html [ ImageOnlyFailure ]
 webkit.org/b/230080 imported/w3c/web-platform-tests/css/css-transforms/transform3d-perspective-004.html [ ImageOnlyFailure ]
-webkit.org/b/230080 imported/w3c/web-platform-tests/css/css-transforms/transform3d-perspective-005.html [ ImageOnlyFailure ]
 webkit.org/b/230080 imported/w3c/web-platform-tests/css/css-transforms/transform3d-preserve3d-006.html [ Pass ImageOnlyFailure ]
 webkit.org/b/230080 imported/w3c/web-platform-tests/css/css-transforms/transform3d-preserve3d-007.html [ Pass ImageOnlyFailure ]
 webkit.org/b/230080 imported/w3c/web-platform-tests/css/css-transforms/transform3d-preserve3d-008.html [ Pass ImageOnlyFailure ]

Modified: trunk/LayoutTests/imported/w3c/ChangeLog (286590 => 286591)


--- trunk/LayoutTests/imported/w3c/ChangeLog	2021-12-07 07:30:07 UTC (rev 286590)
+++ trunk/LayoutTests/imported/w3c/ChangeLog	2021-12-07 08:27:13 UTC (rev 286591)
@@ -1,3 +1,13 @@
+2021-12-07  Martin Robinson  <[email protected]>
+
+        perspective() <= 1px should be clamped to 1px
+        https://bugs.webkit.org/show_bug.cgi?id=232619
+        <rdar://problem/85197362>
+
+        Reviewed by Simon Fraser.
+
+        * web-platform-tests/css/css-transforms/animation/transform-interpolation-verify-reftests-expected.txt: Update to show newly passing subtests.
+
 2021-12-06  Tadeu Zagallo  <[email protected]>
 
         Restore navigator.hardwareConcurrency

Modified: trunk/LayoutTests/imported/w3c/web-platform-tests/css/css-transforms/animation/transform-interpolation-verify-reftests-expected.txt (286590 => 286591)


--- trunk/LayoutTests/imported/w3c/web-platform-tests/css/css-transforms/animation/transform-interpolation-verify-reftests-expected.txt	2021-12-07 07:30:07 UTC (rev 286590)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/css/css-transforms/animation/transform-interpolation-verify-reftests-expected.txt	2021-12-07 08:27:13 UTC (rev 286591)
@@ -155,12 +155,12 @@
 PASS CSS Transitions with transition: all: property <transform> from [perspective(100px) translateZ(15px)] to [perspective(25px) translateZ(15px)] at (0.5) should be [perspective(40px) translateZ(15px)]
 PASS CSS Animations: property <transform> from [perspective(100px) translateZ(15px)] to [perspective(25px) translateZ(15px)] at (0.5) should be [perspective(40px) translateZ(15px)]
 PASS Web Animations: property <transform> from [perspective(100px) translateZ(15px)] to [perspective(25px) translateZ(15px)] at (0.5) should be [perspective(40px) translateZ(15px)]
-FAIL CSS Transitions: property <transform> from [perspective(0.1px) translateZ(0.25px)] to [perspective(0.1px) translateZ(0.25px)] at (0.5) should be [perspective(1px) translateZ(0.25px)] assert_equals: expected "matrix3d ( 1 , 0 , 0 , 0 , 0 , 1 , 0 , 0 , 0 , 0 , 1 , - 1 , 0 , 0 , 0.25 , 0.75 ) " but got "matrix3d ( 1 , 0 , 0 , 0 , 0 , 1 , 0 , 0 , 0 , 0 , 1 , - 10 , 0 , 0 , 0.25 , - 1.5 ) "
-FAIL CSS Transitions with transition: all: property <transform> from [perspective(0.1px) translateZ(0.25px)] to [perspective(0.1px) translateZ(0.25px)] at (0.5) should be [perspective(1px) translateZ(0.25px)] assert_equals: expected "matrix3d ( 1 , 0 , 0 , 0 , 0 , 1 , 0 , 0 , 0 , 0 , 1 , - 1 , 0 , 0 , 0.25 , 0.75 ) " but got "matrix3d ( 1 , 0 , 0 , 0 , 0 , 1 , 0 , 0 , 0 , 0 , 1 , - 10 , 0 , 0 , 0.25 , - 1.5 ) "
-FAIL CSS Animations: property <transform> from [perspective(0.1px) translateZ(0.25px)] to [perspective(0.1px) translateZ(0.25px)] at (0.5) should be [perspective(1px) translateZ(0.25px)] assert_equals: expected "matrix3d ( 1 , 0 , 0 , 0 , 0 , 1 , 0 , 0 , 0 , 0 , 1 , - 1 , 0 , 0 , 0.25 , 0.75 ) " but got "matrix3d ( 1 , 0 , 0 , 0 , 0 , 1 , 0 , 0 , 0 , 0 , 1 , - 10 , 0 , 0 , 0.25 , - 1.5 ) "
-FAIL Web Animations: property <transform> from [perspective(0.1px) translateZ(0.25px)] to [perspective(0.1px) translateZ(0.25px)] at (0.5) should be [perspective(1px) translateZ(0.25px)] assert_equals: expected "matrix3d ( 1 , 0 , 0 , 0 , 0 , 1 , 0 , 0 , 0 , 0 , 1 , - 1 , 0 , 0 , 0.25 , 0.75 ) " but got "matrix3d ( 1 , 0 , 0 , 0 , 0 , 1 , 0 , 0 , 0 , 0 , 1 , - 10 , 0 , 0 , 0.25 , - 1.5 ) "
-FAIL CSS Transitions: property <transform> from [perspective(0px) translateZ(0.25px)] to [perspective(0px) translateZ(0.25px)] at (0.5) should be [perspective(1px) translateZ(0.25px)] assert_equals: expected "matrix3d ( 1 , 0 , 0 , 0 , 0 , 1 , 0 , 0 , 0 , 0 , 1 , - 1 , 0 , 0 , 0.25 , 0.75 ) " but got "matrix3d ( 1 , 0 , 0 , 0 , 0 , 1 , 0 , 0 , 0 , 0 , 1 , 0 , 0 , 0 , 0.25 , 1 ) "
-FAIL CSS Transitions with transition: all: property <transform> from [perspective(0px) translateZ(0.25px)] to [perspective(0px) translateZ(0.25px)] at (0.5) should be [perspective(1px) translateZ(0.25px)] assert_equals: expected "matrix3d ( 1 , 0 , 0 , 0 , 0 , 1 , 0 , 0 , 0 , 0 , 1 , - 1 , 0 , 0 , 0.25 , 0.75 ) " but got "matrix3d ( 1 , 0 , 0 , 0 , 0 , 1 , 0 , 0 , 0 , 0 , 1 , 0 , 0 , 0 , 0.25 , 1 ) "
+PASS CSS Transitions: property <transform> from [perspective(0.1px) translateZ(0.25px)] to [perspective(0.1px) translateZ(0.25px)] at (0.5) should be [perspective(1px) translateZ(0.25px)]
+PASS CSS Transitions with transition: all: property <transform> from [perspective(0.1px) translateZ(0.25px)] to [perspective(0.1px) translateZ(0.25px)] at (0.5) should be [perspective(1px) translateZ(0.25px)]
+PASS CSS Animations: property <transform> from [perspective(0.1px) translateZ(0.25px)] to [perspective(0.1px) translateZ(0.25px)] at (0.5) should be [perspective(1px) translateZ(0.25px)]
+PASS Web Animations: property <transform> from [perspective(0.1px) translateZ(0.25px)] to [perspective(0.1px) translateZ(0.25px)] at (0.5) should be [perspective(1px) translateZ(0.25px)]
+PASS CSS Transitions: property <transform> from [perspective(0px) translateZ(0.25px)] to [perspective(0px) translateZ(0.25px)] at (0.5) should be [perspective(1px) translateZ(0.25px)]
+PASS CSS Transitions with transition: all: property <transform> from [perspective(0px) translateZ(0.25px)] to [perspective(0px) translateZ(0.25px)] at (0.5) should be [perspective(1px) translateZ(0.25px)]
 FAIL CSS Animations: property <transform> from [perspective(0px) translateZ(0.25px)] to [perspective(0px) translateZ(0.25px)] at (0.5) should be [perspective(1px) translateZ(0.25px)] assert_equals: expected "matrix3d ( 1 , 0 , 0 , 0 , 0 , 1 , 0 , 0 , 0 , 0 , 1 , - 1 , 0 , 0 , 0.25 , 0.75 ) " but got "matrix3d ( 1 , 0 , 0 , 0 , 0 , 1 , 0 , 0 , 0 , 0 , 1 , 0 , 0 , 0 , 0.25 , 1 ) "
 FAIL Web Animations: property <transform> from [perspective(0px) translateZ(0.25px)] to [perspective(0px) translateZ(0.25px)] at (0.5) should be [perspective(1px) translateZ(0.25px)] assert_equals: expected "matrix3d ( 1 , 0 , 0 , 0 , 0 , 1 , 0 , 0 , 0 , 0 , 1 , - 1 , 0 , 0 , 0.25 , 0.75 ) " but got "matrix3d ( 1 , 0 , 0 , 0 , 0 , 1 , 0 , 0 , 0 , 0 , 1 , 0 , 0 , 0 , 0.25 , 1 ) "
 FAIL CSS Transitions: property <transform> from [perspective(0px) translateZ(0.5px)] to [perspective(3px) translateZ(0.5px)] at (0.5) should be [perspective(1.5px) translateZ(0.5px)] assert_equals: expected "matrix3d ( 1 , 0 , 0 , 0 , 0 , 1 , 0 , 0 , 0 , 0 , 1 , - 0.67 , 0 , 0 , 0.5 , 0.67 ) " but got "matrix3d ( 1 , 0 , 0 , 0 , 0 , 1 , 0 , 0 , 0 , 0 , 1 , - 0.17 , 0 , 0 , 0.5 , 0.92 ) "
@@ -171,8 +171,8 @@
 PASS CSS Transitions with transition: all: property <transform> from [perspective(10px) translateZ(0.5px)] to [perspective(1px) translateZ(0.5px)] at (-1) should be [translateZ(0.5px)]
 PASS CSS Animations: property <transform> from [perspective(10px) translateZ(0.5px)] to [perspective(1px) translateZ(0.5px)] at (-1) should be [translateZ(0.5px)]
 PASS Web Animations: property <transform> from [perspective(10px) translateZ(0.5px)] to [perspective(1px) translateZ(0.5px)] at (-1) should be [translateZ(0.5px)]
-FAIL CSS Transitions: property <transform> from [perspective(1px) translateZ(0.5px)] to [perspective(10px) translateZ(0.5px)] at (-1) should be [perspective(1px) translateZ(0.5px)] assert_equals: expected "matrix3d ( 1 , 0 , 0 , 0 , 0 , 1 , 0 , 0 , 0 , 0 , 1 , - 1 , 0 , 0 , 0.5 , 0.5 ) " but got "matrix3d ( 1 , 0 , 0 , 0 , 0 , 1 , 0 , 0 , 0 , 0 , 1 , - 1.9 , 0 , 0 , 0.5 , 0.05 ) "
-FAIL CSS Transitions with transition: all: property <transform> from [perspective(1px) translateZ(0.5px)] to [perspective(10px) translateZ(0.5px)] at (-1) should be [perspective(1px) translateZ(0.5px)] assert_equals: expected "matrix3d ( 1 , 0 , 0 , 0 , 0 , 1 , 0 , 0 , 0 , 0 , 1 , - 1 , 0 , 0 , 0.5 , 0.5 ) " but got "matrix3d ( 1 , 0 , 0 , 0 , 0 , 1 , 0 , 0 , 0 , 0 , 1 , - 1.9 , 0 , 0 , 0.5 , 0.05 ) "
-FAIL CSS Animations: property <transform> from [perspective(1px) translateZ(0.5px)] to [perspective(10px) translateZ(0.5px)] at (-1) should be [perspective(1px) translateZ(0.5px)] assert_equals: expected "matrix3d ( 1 , 0 , 0 , 0 , 0 , 1 , 0 , 0 , 0 , 0 , 1 , - 1 , 0 , 0 , 0.5 , 0.5 ) " but got "matrix3d ( 1 , 0 , 0 , 0 , 0 , 1 , 0 , 0 , 0 , 0 , 1 , - 1.9 , 0 , 0 , 0.5 , 0.05 ) "
-FAIL Web Animations: property <transform> from [perspective(1px) translateZ(0.5px)] to [perspective(10px) translateZ(0.5px)] at (-1) should be [perspective(1px) translateZ(0.5px)] assert_equals: expected "matrix3d ( 1 , 0 , 0 , 0 , 0 , 1 , 0 , 0 , 0 , 0 , 1 , - 1 , 0 , 0 , 0.5 , 0.5 ) " but got "matrix3d ( 1 , 0 , 0 , 0 , 0 , 1 , 0 , 0 , 0 , 0 , 1 , - 1.9 , 0 , 0 , 0.5 , 0.05 ) "
+PASS CSS Transitions: property <transform> from [perspective(1px) translateZ(0.5px)] to [perspective(10px) translateZ(0.5px)] at (-1) should be [perspective(1px) translateZ(0.5px)]
+PASS CSS Transitions with transition: all: property <transform> from [perspective(1px) translateZ(0.5px)] to [perspective(10px) translateZ(0.5px)] at (-1) should be [perspective(1px) translateZ(0.5px)]
+PASS CSS Animations: property <transform> from [perspective(1px) translateZ(0.5px)] to [perspective(10px) translateZ(0.5px)] at (-1) should be [perspective(1px) translateZ(0.5px)]
+PASS Web Animations: property <transform> from [perspective(1px) translateZ(0.5px)] to [perspective(10px) translateZ(0.5px)] at (-1) should be [perspective(1px) translateZ(0.5px)]
 

Modified: trunk/LayoutTests/transforms/3d/general/3dtransform-values-expected.txt (286590 => 286591)


--- trunk/LayoutTests/transforms/3d/general/3dtransform-values-expected.txt	2021-12-07 07:30:07 UTC (rev 286590)
+++ trunk/LayoutTests/transforms/3d/general/3dtransform-values-expected.txt	2021-12-07 08:27:13 UTC (rev 286591)
@@ -15,7 +15,8 @@
 transform "perspective(400em)" expected "matrix3d(1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, -0.00015625, 0, 0, 0, 1)" : PASS
 transform "perspective(50%)" expected "none" : PASS
 transform "perspective(-400)" expected "none" : PASS
-transform "perspective(0)" expected "matrix(1, 0, 0, 1, 0, 0)" : PASS
+transform "perspective(0)" expected "matrix3d(1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, -1, 0, 0, 0, 1)" : PASS
+transform "perspective(none)" expected "matrix(1, 0, 0, 1, 0, 0)" : PASS
 transform "perspective(400deg)" expected "none" : PASS
 transform "perspective(banana)" expected "none" : PASS
 

Modified: trunk/LayoutTests/transforms/3d/general/3dtransform-values.html (286590 => 286591)


--- trunk/LayoutTests/transforms/3d/general/3dtransform-values.html	2021-12-07 07:30:07 UTC (rev 286590)
+++ trunk/LayoutTests/transforms/3d/general/3dtransform-values.html	2021-12-07 08:27:13 UTC (rev 286591)
@@ -43,7 +43,8 @@
       { 'transform' : 'perspective(400em)', 'result' : 'matrix3d(1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, -0.00015625, 0, 0, 0, 1)' },
       { 'transform' : 'perspective(50%)', 'result' : 'none' },
       { 'transform' : 'perspective(-400)', 'result' : 'none' },
-      { 'transform' : 'perspective(0)', 'result' : 'matrix(1, 0, 0, 1, 0, 0)' },
+      { 'transform' : 'perspective(0)', 'result' : 'matrix3d(1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, -1, 0, 0, 0, 1)' },
+      { 'transform' : 'perspective(none)', 'result' : 'matrix(1, 0, 0, 1, 0, 0)' },
       { 'transform' : 'perspective(400deg)', 'result' : 'none' }, // unit must be length
       { 'transform' : 'perspective(banana)', 'result' : 'none' }, // unit must be length
     ];

Modified: trunk/LayoutTests/transforms/3d/general/prefixed-3dtransform-values-expected.txt (286590 => 286591)


--- trunk/LayoutTests/transforms/3d/general/prefixed-3dtransform-values-expected.txt	2021-12-07 07:30:07 UTC (rev 286590)
+++ trunk/LayoutTests/transforms/3d/general/prefixed-3dtransform-values-expected.txt	2021-12-07 08:27:13 UTC (rev 286591)
@@ -15,7 +15,8 @@
 transform "perspective(400em)" expected "matrix3d(1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, -0.00015625, 0, 0, 0, 1)" : PASS
 transform "perspective(50%)" expected "none" : PASS
 transform "perspective(-400)" expected "none" : PASS
-transform "perspective(0)" expected "matrix(1, 0, 0, 1, 0, 0)" : PASS
+transform "perspective(0)" expected "matrix3d(1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, -1, 0, 0, 0, 1)" : PASS
+transform "perspective(none)" expected "matrix(1, 0, 0, 1, 0, 0)" : PASS
 transform "perspective(400deg)" expected "none" : PASS
 transform "perspective(banana)" expected "none" : PASS
 

Modified: trunk/LayoutTests/transforms/3d/general/prefixed-3dtransform-values.html (286590 => 286591)


--- trunk/LayoutTests/transforms/3d/general/prefixed-3dtransform-values.html	2021-12-07 07:30:07 UTC (rev 286590)
+++ trunk/LayoutTests/transforms/3d/general/prefixed-3dtransform-values.html	2021-12-07 08:27:13 UTC (rev 286591)
@@ -43,7 +43,8 @@
       { 'transform' : 'perspective(400em)', 'result' : 'matrix3d(1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, -0.00015625, 0, 0, 0, 1)' },
       { 'transform' : 'perspective(50%)', 'result' : 'none' },
       { 'transform' : 'perspective(-400)', 'result' : 'none' },
-      { 'transform' : 'perspective(0)', 'result' : 'matrix(1, 0, 0, 1, 0, 0)' },
+      { 'transform' : 'perspective(0)', 'result' : 'matrix3d(1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, -1, 0, 0, 0, 1)' },
+      { 'transform' : 'perspective(none)', 'result' : 'matrix(1, 0, 0, 1, 0, 0)' },
       { 'transform' : 'perspective(400deg)', 'result' : 'none' }, // unit must be length
       { 'transform' : 'perspective(banana)', 'result' : 'none' }, // unit must be length
     ];

Modified: trunk/Source/WebCore/ChangeLog (286590 => 286591)


--- trunk/Source/WebCore/ChangeLog	2021-12-07 07:30:07 UTC (rev 286590)
+++ trunk/Source/WebCore/ChangeLog	2021-12-07 08:27:13 UTC (rev 286591)
@@ -1,3 +1,35 @@
+2021-12-07  Martin Robinson  <[email protected]>
+
+        perspective() <= 1px should be clamped to 1px
+        https://bugs.webkit.org/show_bug.cgi?id=232619
+        <rdar://problem/85197362>
+
+        Reviewed by Simon Fraser.
+
+        No new tests. This is covered by the newly passing WPT tests
+        in this change.
+
+        When the CSS 3D transform interoperability experimental feature is turned on,
+        round perspectives that are < 1 pixel to 1 pixel. This behavior is described
+        in the specification, but breaks backward compatibility. The reasoning provided
+        by the specification is:
+
+            As very small <length> values can produce bizarre rendering results and
+            stress the numerical accuracy of transform calculations, values less than
+            1px must be treated as 1px for rendering purposes.
+
+        * platform/graphics/transforms/PerspectiveTransformOperation.h: When getting
+        the floating point perspective value, round to 1px.
+        * rendering/RenderLayer.cpp:
+        (WebCore::RenderLayer::perspectiveTransform const): Use usedPerspective from
+        RenderSTyle.
+        * rendering/RenderObject.cpp:
+        (WebCore::RenderObject::getTransformFromContainer const): Ditto.
+        * rendering/style/RenderStyle.cpp:
+        (WebCore::RenderStyle::usedPerspective const): Added this method which rounds
+        to 1px.
+        * rendering/style/RenderStyle.h:
+
 2021-12-06  Said Abou-Hallawa  <[email protected]>
 
         [GPU Process]  [Filters] Make FilterEffect::externalRepresentation() and its overridable functions work iteratively

Modified: trunk/Source/WebCore/platform/graphics/transforms/PerspectiveTransformOperation.h (286590 => 286591)


--- trunk/Source/WebCore/platform/graphics/transforms/PerspectiveTransformOperation.h	2021-12-07 07:30:07 UTC (rev 286590)
+++ trunk/Source/WebCore/platform/graphics/transforms/PerspectiveTransformOperation.h	2021-12-07 08:27:13 UTC (rev 286591)
@@ -60,7 +60,12 @@
     {
         if (!m_p)
             return { };
-        return floatValueForLength(*m_p, 1.0);
+
+        // From https://www.w3.org/TR/css-transforms-2/#perspective-property:
+        // "As very small <length> values can produce bizarre rendering results and stress the numerical accuracy of
+        // transform calculations, values less than 1px must be treated as 1px for rendering purposes. (This clamping
+        // does not affect the underlying value, so perspective: 0; in a stylesheet will still serialize back as 0.)"
+        return std::max(1.0f, floatValueForLength(*m_p, 1.0));
     }
 
     bool apply(TransformationMatrix& transform, const FloatSize&) const override

Modified: trunk/Source/WebCore/rendering/RenderLayer.cpp (286590 => 286591)


--- trunk/Source/WebCore/rendering/RenderLayer.cpp	2021-12-07 07:30:07 UTC (rev 286590)
+++ trunk/Source/WebCore/rendering/RenderLayer.cpp	2021-12-07 08:27:13 UTC (rev 286591)
@@ -1764,7 +1764,7 @@
 
     TransformationMatrix t;
     t.translate(perspectiveOrigin.x(), perspectiveOrigin.y());
-    t.applyPerspective(style.perspective());
+    t.applyPerspective(style.usedPerspective(renderer()));
     t.translate(-perspectiveOrigin.x(), -perspectiveOrigin.y());
 
     return t;

Modified: trunk/Source/WebCore/rendering/RenderObject.cpp (286590 => 286591)


--- trunk/Source/WebCore/rendering/RenderObject.cpp	2021-12-07 07:30:07 UTC (rev 286590)
+++ trunk/Source/WebCore/rendering/RenderObject.cpp	2021-12-07 08:27:13 UTC (rev 286591)
@@ -1389,7 +1389,7 @@
         FloatPoint perspectiveOrigin = downcast<RenderLayerModelObject>(*containerObject).layer()->perspectiveOrigin();
 
         TransformationMatrix perspectiveMatrix;
-        perspectiveMatrix.applyPerspective(containerObject->style().perspective());
+        perspectiveMatrix.applyPerspective(containerObject->style().usedPerspective(*this));
         
         transform.translateRight3d(-perspectiveOrigin.x(), -perspectiveOrigin.y(), 0);
         transform = perspectiveMatrix * transform;

Modified: trunk/Source/WebCore/rendering/style/RenderStyle.cpp (286590 => 286591)


--- trunk/Source/WebCore/rendering/style/RenderStyle.cpp	2021-12-07 07:30:07 UTC (rev 286590)
+++ trunk/Source/WebCore/rendering/style/RenderStyle.cpp	2021-12-07 08:27:13 UTC (rev 286591)
@@ -1813,6 +1813,11 @@
     return *m_rareNonInheritedData->transitions;
 }
 
+float RenderStyle::usedPerspective(const RenderObject& object) const
+{
+    return object.document().settings().css3DTransformInteroperabilityEnabled() ? std::max(1.0f, perspective()) : perspective();
+}
+
 const Animation* RenderStyle::transitionForProperty(CSSPropertyID property) const
 {
     auto* transitions = this->transitions();

Modified: trunk/Source/WebCore/rendering/style/RenderStyle.h (286590 => 286591)


--- trunk/Source/WebCore/rendering/style/RenderStyle.h	2021-12-07 07:30:07 UTC (rev 286590)
+++ trunk/Source/WebCore/rendering/style/RenderStyle.h	2021-12-07 08:27:13 UTC (rev 286591)
@@ -730,6 +730,7 @@
 
     BackfaceVisibility backfaceVisibility() const { return static_cast<BackfaceVisibility>(m_rareNonInheritedData->backfaceVisibility); }
     float perspective() const { return m_rareNonInheritedData->perspective; }
+    float usedPerspective(const RenderObject&) const;
     bool hasPerspective() const { return m_rareNonInheritedData->perspective != initialPerspective(); }
     const Length& perspectiveOriginX() const { return m_rareNonInheritedData->perspectiveOriginX; }
     const Length& perspectiveOriginY() const { return m_rareNonInheritedData->perspectiveOriginY; }
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to