Title: [285255] trunk
Revision
285255
Author
[email protected]
Date
2021-11-04 01:51:14 -0700 (Thu, 04 Nov 2021)

Log Message

implement transform: perspective(none)
https://bugs.webkit.org/show_bug.cgi?id=231361
<rdar://problem/84124161>

Reviewed by Simon Fraser.

LayoutTests/imported/w3c:

* web-platform-tests/css/css-transforms/animation/transform-interpolation-001-expected.txt:
* web-platform-tests/css/css-transforms/parsing/transform-valid-expected.txt:

Source/WebCore:

Add support for perspective(none) and update test results
to show newly passing tests.

No new tests. This is covered by the existing WPT tests:
    - imported/w3c/web-platform-tests/css/css-transforms/parsing/transform-valid.html
    - imported/w3c/web-platform-tests/css/css-transforms/animation/transform-interpolation-001.html

* css/TransformFunctions.cpp:
(WebCore::transformsForValue): Accept a "none" keyword as an input and be a bit more stringent
about what kind of numbers are accepted. These should be rejected earlier in consumePerspective.
This can now hold an Undefined length which indicates perspective: none.
* css/parser/CSSPropertyParser.cpp:
(WebCore::consumePerspective): Accept "none" and clean up the code a little, using ValueRange
instead of a manual check for numerical values. Also make the code structure a little more
consistent.
* platform/graphics/transforms/PerspectiveTransformOperation.h: Update assertion, because
Undefined means perpsective: none now.
* platform/graphics/transforms/PerspectiveTransformOperation.cpp:
(WebCore::PerspectiveTransformOperation::blend): Handle the case of perspective: none for
either values.

LayoutTests:

* platform/glib/imported/w3c/web-platform-tests/css/css-transforms/animation/transform-interpolation-001-expected.txt:

Modified Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (285254 => 285255)


--- trunk/LayoutTests/ChangeLog	2021-11-04 06:28:28 UTC (rev 285254)
+++ trunk/LayoutTests/ChangeLog	2021-11-04 08:51:14 UTC (rev 285255)
@@ -1,3 +1,13 @@
+2021-11-04  Martin Robinson  <[email protected]>
+
+        implement transform: perspective(none)
+        https://bugs.webkit.org/show_bug.cgi?id=231361
+        <rdar://problem/84124161>
+
+        Reviewed by Simon Fraser.
+
+        * platform/glib/imported/w3c/web-platform-tests/css/css-transforms/animation/transform-interpolation-001-expected.txt:
+
 2021-11-03  Arcady Goldmints-Orlov  <[email protected]>
 
         [GLIB] Update test expectations and baselines. Unreviewed test gardening.

Modified: trunk/LayoutTests/imported/w3c/ChangeLog (285254 => 285255)


--- trunk/LayoutTests/imported/w3c/ChangeLog	2021-11-04 06:28:28 UTC (rev 285254)
+++ trunk/LayoutTests/imported/w3c/ChangeLog	2021-11-04 08:51:14 UTC (rev 285255)
@@ -1,3 +1,14 @@
+2021-11-04  Martin Robinson  <[email protected]>
+
+        implement transform: perspective(none)
+        https://bugs.webkit.org/show_bug.cgi?id=231361
+        <rdar://problem/84124161>
+
+        Reviewed by Simon Fraser.
+
+        * web-platform-tests/css/css-transforms/animation/transform-interpolation-001-expected.txt:
+        * web-platform-tests/css/css-transforms/parsing/transform-valid-expected.txt:
+
 2021-11-03  Joonghun Park  <[email protected]>
 
         border-radius inline style should serialize with valid syntax

Modified: trunk/LayoutTests/imported/w3c/web-platform-tests/css/css-transforms/animation/transform-interpolation-001-expected.txt (285254 => 285255)


--- trunk/LayoutTests/imported/w3c/web-platform-tests/css/css-transforms/animation/transform-interpolation-001-expected.txt	2021-11-04 06:28:28 UTC (rev 285254)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/css/css-transforms/animation/transform-interpolation-001-expected.txt	2021-11-04 08:51:14 UTC (rev 285255)
@@ -91,26 +91,26 @@
 PASS Web Animations: property <transform> from [scaleZ(2)] to [scaleZ(2) perspective(500px)] at (0.5) should be [scaleZ(2) perspective(1000px)]
 PASS Web Animations: property <transform> from [scaleZ(2)] to [scaleZ(2) perspective(500px)] at (1) should be [scaleZ(2) perspective(500px)]
 PASS Web Animations: property <transform> from [scaleZ(2)] to [scaleZ(2) perspective(500px)] at (2) should be [scaleZ(2) perspective(250px)]
-FAIL CSS Transitions: property <transform> from [perspective(none)] to [perspective(500px)] at (-1) should be [perspective(none)] assert_true: 'from' value should be supported expected true got false
-FAIL CSS Transitions: property <transform> from [perspective(none)] to [perspective(500px)] at (0) should be [perspective(none)] assert_true: 'from' value should be supported expected true got false
-FAIL CSS Transitions: property <transform> from [perspective(none)] to [perspective(500px)] at (0.5) should be [perspective(1000px)] assert_true: 'from' value should be supported expected true got false
-FAIL CSS Transitions: property <transform> from [perspective(none)] to [perspective(500px)] at (1) should be [perspective(500px)] assert_true: 'from' value should be supported expected true got false
-FAIL CSS Transitions: property <transform> from [perspective(none)] to [perspective(500px)] at (2) should be [perspective(250px)] assert_true: 'from' value should be supported expected true got false
-FAIL CSS Transitions with transition: all: property <transform> from [perspective(none)] to [perspective(500px)] at (-1) should be [perspective(none)] assert_true: 'from' value should be supported expected true got false
-FAIL CSS Transitions with transition: all: property <transform> from [perspective(none)] to [perspective(500px)] at (0) should be [perspective(none)] assert_true: 'from' value should be supported expected true got false
-FAIL CSS Transitions with transition: all: property <transform> from [perspective(none)] to [perspective(500px)] at (0.5) should be [perspective(1000px)] assert_true: 'from' value should be supported expected true got false
-FAIL CSS Transitions with transition: all: property <transform> from [perspective(none)] to [perspective(500px)] at (1) should be [perspective(500px)] assert_true: 'from' value should be supported expected true got false
-FAIL CSS Transitions with transition: all: property <transform> from [perspective(none)] to [perspective(500px)] at (2) should be [perspective(250px)] assert_true: 'from' value should be supported expected true got false
-FAIL CSS Animations: property <transform> from [perspective(none)] to [perspective(500px)] at (-1) should be [perspective(none)] assert_true: 'from' value should be supported expected true got false
-FAIL CSS Animations: property <transform> from [perspective(none)] to [perspective(500px)] at (0) should be [perspective(none)] assert_true: 'from' value should be supported expected true got false
-FAIL CSS Animations: property <transform> from [perspective(none)] to [perspective(500px)] at (0.5) should be [perspective(1000px)] assert_true: 'from' value should be supported expected true got false
-FAIL CSS Animations: property <transform> from [perspective(none)] to [perspective(500px)] at (1) should be [perspective(500px)] assert_true: 'from' value should be supported expected true got false
-FAIL CSS Animations: property <transform> from [perspective(none)] to [perspective(500px)] at (2) should be [perspective(250px)] assert_true: 'from' value should be supported expected true got false
-FAIL Web Animations: property <transform> from [perspective(none)] to [perspective(500px)] at (-1) should be [perspective(none)] assert_true: 'from' value should be supported expected true got false
-FAIL Web Animations: property <transform> from [perspective(none)] to [perspective(500px)] at (0) should be [perspective(none)] assert_true: 'from' value should be supported expected true got false
-FAIL Web Animations: property <transform> from [perspective(none)] to [perspective(500px)] at (0.5) should be [perspective(1000px)] assert_true: 'from' value should be supported expected true got false
-FAIL Web Animations: property <transform> from [perspective(none)] to [perspective(500px)] at (1) should be [perspective(500px)] assert_true: 'from' value should be supported expected true got false
-FAIL Web Animations: property <transform> from [perspective(none)] to [perspective(500px)] at (2) should be [perspective(250px)] assert_true: 'from' value should be supported expected true got false
+PASS CSS Transitions: property <transform> from [perspective(none)] to [perspective(500px)] at (-1) should be [perspective(none)]
+PASS CSS Transitions: property <transform> from [perspective(none)] to [perspective(500px)] at (0) should be [perspective(none)]
+PASS CSS Transitions: property <transform> from [perspective(none)] to [perspective(500px)] at (0.5) should be [perspective(1000px)]
+PASS CSS Transitions: property <transform> from [perspective(none)] to [perspective(500px)] at (1) should be [perspective(500px)]
+PASS CSS Transitions: property <transform> from [perspective(none)] to [perspective(500px)] at (2) should be [perspective(250px)]
+PASS CSS Transitions with transition: all: property <transform> from [perspective(none)] to [perspective(500px)] at (-1) should be [perspective(none)]
+PASS CSS Transitions with transition: all: property <transform> from [perspective(none)] to [perspective(500px)] at (0) should be [perspective(none)]
+PASS CSS Transitions with transition: all: property <transform> from [perspective(none)] to [perspective(500px)] at (0.5) should be [perspective(1000px)]
+PASS CSS Transitions with transition: all: property <transform> from [perspective(none)] to [perspective(500px)] at (1) should be [perspective(500px)]
+PASS CSS Transitions with transition: all: property <transform> from [perspective(none)] to [perspective(500px)] at (2) should be [perspective(250px)]
+PASS CSS Animations: property <transform> from [perspective(none)] to [perspective(500px)] at (-1) should be [perspective(none)]
+PASS CSS Animations: property <transform> from [perspective(none)] to [perspective(500px)] at (0) should be [perspective(none)]
+PASS CSS Animations: property <transform> from [perspective(none)] to [perspective(500px)] at (0.5) should be [perspective(1000px)]
+PASS CSS Animations: property <transform> from [perspective(none)] to [perspective(500px)] at (1) should be [perspective(500px)]
+PASS CSS Animations: property <transform> from [perspective(none)] to [perspective(500px)] at (2) should be [perspective(250px)]
+PASS Web Animations: property <transform> from [perspective(none)] to [perspective(500px)] at (-1) should be [perspective(none)]
+PASS Web Animations: property <transform> from [perspective(none)] to [perspective(500px)] at (0) should be [perspective(none)]
+PASS Web Animations: property <transform> from [perspective(none)] to [perspective(500px)] at (0.5) should be [perspective(1000px)]
+PASS Web Animations: property <transform> from [perspective(none)] to [perspective(500px)] at (1) should be [perspective(500px)]
+PASS Web Animations: property <transform> from [perspective(none)] to [perspective(500px)] at (2) should be [perspective(250px)]
 PASS CSS Transitions: property <transform> from [rotate(30deg)] to [rotate(330deg)] at (-1) should be [rotate(-270deg)]
 PASS CSS Transitions: property <transform> from [rotate(30deg)] to [rotate(330deg)] at (0) should be [rotate(30deg)]
 PASS CSS Transitions: property <transform> from [rotate(30deg)] to [rotate(330deg)] at (0.25) should be [rotate(105deg)]

Modified: trunk/LayoutTests/imported/w3c/web-platform-tests/css/css-transforms/parsing/transform-valid-expected.txt (285254 => 285255)


--- trunk/LayoutTests/imported/w3c/web-platform-tests/css/css-transforms/parsing/transform-valid-expected.txt	2021-11-04 06:28:28 UTC (rev 285254)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/css/css-transforms/parsing/transform-valid-expected.txt	2021-11-04 08:51:14 UTC (rev 285255)
@@ -38,6 +38,6 @@
 PASS e.style['transform'] = "skewY(0)" should set the property value
 PASS e.style['transform'] = "skewY(-90deg)" should set the property value
 PASS e.style['transform'] = "perspective(10px)" should set the property value
-FAIL e.style['transform'] = "perspective(none)" should set the property value assert_not_equals: property should be set got disallowed value ""
+PASS e.style['transform'] = "perspective(none)" should set the property value
 PASS e.style['transform'] = "translate(1px, 2%) scale(3, 4) rotate(-90deg)" should set the property value
 

Modified: trunk/LayoutTests/platform/glib/imported/w3c/web-platform-tests/css/css-transforms/animation/transform-interpolation-001-expected.txt (285254 => 285255)


--- trunk/LayoutTests/platform/glib/imported/w3c/web-platform-tests/css/css-transforms/animation/transform-interpolation-001-expected.txt	2021-11-04 06:28:28 UTC (rev 285254)
+++ trunk/LayoutTests/platform/glib/imported/w3c/web-platform-tests/css/css-transforms/animation/transform-interpolation-001-expected.txt	2021-11-04 08:51:14 UTC (rev 285255)
@@ -91,26 +91,26 @@
 PASS Web Animations: property <transform> from [scaleZ(2)] to [scaleZ(2) perspective(500px)] at (0.5) should be [scaleZ(2) perspective(1000px)]
 PASS Web Animations: property <transform> from [scaleZ(2)] to [scaleZ(2) perspective(500px)] at (1) should be [scaleZ(2) perspective(500px)]
 PASS Web Animations: property <transform> from [scaleZ(2)] to [scaleZ(2) perspective(500px)] at (2) should be [scaleZ(2) perspective(250px)]
-FAIL CSS Transitions: property <transform> from [perspective(none)] to [perspective(500px)] at (-1) should be [perspective(none)] assert_true: 'from' value should be supported expected true got false
-FAIL CSS Transitions: property <transform> from [perspective(none)] to [perspective(500px)] at (0) should be [perspective(none)] assert_true: 'from' value should be supported expected true got false
-FAIL CSS Transitions: property <transform> from [perspective(none)] to [perspective(500px)] at (0.5) should be [perspective(1000px)] assert_true: 'from' value should be supported expected true got false
-FAIL CSS Transitions: property <transform> from [perspective(none)] to [perspective(500px)] at (1) should be [perspective(500px)] assert_true: 'from' value should be supported expected true got false
-FAIL CSS Transitions: property <transform> from [perspective(none)] to [perspective(500px)] at (2) should be [perspective(250px)] assert_true: 'from' value should be supported expected true got false
-FAIL CSS Transitions with transition: all: property <transform> from [perspective(none)] to [perspective(500px)] at (-1) should be [perspective(none)] assert_true: 'from' value should be supported expected true got false
-FAIL CSS Transitions with transition: all: property <transform> from [perspective(none)] to [perspective(500px)] at (0) should be [perspective(none)] assert_true: 'from' value should be supported expected true got false
-FAIL CSS Transitions with transition: all: property <transform> from [perspective(none)] to [perspective(500px)] at (0.5) should be [perspective(1000px)] assert_true: 'from' value should be supported expected true got false
-FAIL CSS Transitions with transition: all: property <transform> from [perspective(none)] to [perspective(500px)] at (1) should be [perspective(500px)] assert_true: 'from' value should be supported expected true got false
-FAIL CSS Transitions with transition: all: property <transform> from [perspective(none)] to [perspective(500px)] at (2) should be [perspective(250px)] assert_true: 'from' value should be supported expected true got false
-FAIL CSS Animations: property <transform> from [perspective(none)] to [perspective(500px)] at (-1) should be [perspective(none)] assert_true: 'from' value should be supported expected true got false
-FAIL CSS Animations: property <transform> from [perspective(none)] to [perspective(500px)] at (0) should be [perspective(none)] assert_true: 'from' value should be supported expected true got false
-FAIL CSS Animations: property <transform> from [perspective(none)] to [perspective(500px)] at (0.5) should be [perspective(1000px)] assert_true: 'from' value should be supported expected true got false
-FAIL CSS Animations: property <transform> from [perspective(none)] to [perspective(500px)] at (1) should be [perspective(500px)] assert_true: 'from' value should be supported expected true got false
-FAIL CSS Animations: property <transform> from [perspective(none)] to [perspective(500px)] at (2) should be [perspective(250px)] assert_true: 'from' value should be supported expected true got false
-FAIL Web Animations: property <transform> from [perspective(none)] to [perspective(500px)] at (-1) should be [perspective(none)] assert_true: 'from' value should be supported expected true got false
-FAIL Web Animations: property <transform> from [perspective(none)] to [perspective(500px)] at (0) should be [perspective(none)] assert_true: 'from' value should be supported expected true got false
-FAIL Web Animations: property <transform> from [perspective(none)] to [perspective(500px)] at (0.5) should be [perspective(1000px)] assert_true: 'from' value should be supported expected true got false
-FAIL Web Animations: property <transform> from [perspective(none)] to [perspective(500px)] at (1) should be [perspective(500px)] assert_true: 'from' value should be supported expected true got false
-FAIL Web Animations: property <transform> from [perspective(none)] to [perspective(500px)] at (2) should be [perspective(250px)] assert_true: 'from' value should be supported expected true got false
+PASS CSS Transitions: property <transform> from [perspective(none)] to [perspective(500px)] at (-1) should be [perspective(none)]
+PASS CSS Transitions: property <transform> from [perspective(none)] to [perspective(500px)] at (0) should be [perspective(none)]
+PASS CSS Transitions: property <transform> from [perspective(none)] to [perspective(500px)] at (0.5) should be [perspective(1000px)]
+PASS CSS Transitions: property <transform> from [perspective(none)] to [perspective(500px)] at (1) should be [perspective(500px)]
+PASS CSS Transitions: property <transform> from [perspective(none)] to [perspective(500px)] at (2) should be [perspective(250px)]
+PASS CSS Transitions with transition: all: property <transform> from [perspective(none)] to [perspective(500px)] at (-1) should be [perspective(none)]
+PASS CSS Transitions with transition: all: property <transform> from [perspective(none)] to [perspective(500px)] at (0) should be [perspective(none)]
+PASS CSS Transitions with transition: all: property <transform> from [perspective(none)] to [perspective(500px)] at (0.5) should be [perspective(1000px)]
+PASS CSS Transitions with transition: all: property <transform> from [perspective(none)] to [perspective(500px)] at (1) should be [perspective(500px)]
+PASS CSS Transitions with transition: all: property <transform> from [perspective(none)] to [perspective(500px)] at (2) should be [perspective(250px)]
+PASS CSS Animations: property <transform> from [perspective(none)] to [perspective(500px)] at (-1) should be [perspective(none)]
+PASS CSS Animations: property <transform> from [perspective(none)] to [perspective(500px)] at (0) should be [perspective(none)]
+PASS CSS Animations: property <transform> from [perspective(none)] to [perspective(500px)] at (0.5) should be [perspective(1000px)]
+PASS CSS Animations: property <transform> from [perspective(none)] to [perspective(500px)] at (1) should be [perspective(500px)]
+PASS CSS Animations: property <transform> from [perspective(none)] to [perspective(500px)] at (2) should be [perspective(250px)]
+PASS Web Animations: property <transform> from [perspective(none)] to [perspective(500px)] at (-1) should be [perspective(none)]
+PASS Web Animations: property <transform> from [perspective(none)] to [perspective(500px)] at (0) should be [perspective(none)]
+PASS Web Animations: property <transform> from [perspective(none)] to [perspective(500px)] at (0.5) should be [perspective(1000px)]
+PASS Web Animations: property <transform> from [perspective(none)] to [perspective(500px)] at (1) should be [perspective(500px)]
+PASS Web Animations: property <transform> from [perspective(none)] to [perspective(500px)] at (2) should be [perspective(250px)]
 PASS CSS Transitions: property <transform> from [rotate(30deg)] to [rotate(330deg)] at (-1) should be [rotate(-270deg)]
 PASS CSS Transitions: property <transform> from [rotate(30deg)] to [rotate(330deg)] at (0) should be [rotate(30deg)]
 PASS CSS Transitions: property <transform> from [rotate(30deg)] to [rotate(330deg)] at (0.25) should be [rotate(105deg)]

Modified: trunk/Source/WebCore/ChangeLog (285254 => 285255)


--- trunk/Source/WebCore/ChangeLog	2021-11-04 06:28:28 UTC (rev 285254)
+++ trunk/Source/WebCore/ChangeLog	2021-11-04 08:51:14 UTC (rev 285255)
@@ -1,3 +1,32 @@
+2021-11-04  Martin Robinson  <[email protected]>
+
+        implement transform: perspective(none)
+        https://bugs.webkit.org/show_bug.cgi?id=231361
+        <rdar://problem/84124161>
+
+        Reviewed by Simon Fraser.
+
+        Add support for perspective(none) and update test results
+        to show newly passing tests.
+
+        No new tests. This is covered by the existing WPT tests:
+            - imported/w3c/web-platform-tests/css/css-transforms/parsing/transform-valid.html
+            - imported/w3c/web-platform-tests/css/css-transforms/animation/transform-interpolation-001.html
+
+        * css/TransformFunctions.cpp:
+        (WebCore::transformsForValue): Accept a "none" keyword as an input and be a bit more stringent
+        about what kind of numbers are accepted. These should be rejected earlier in consumePerspective.
+        This can now hold an Undefined length which indicates perspective: none.
+        * css/parser/CSSPropertyParser.cpp:
+        (WebCore::consumePerspective): Accept "none" and clean up the code a little, using ValueRange
+        instead of a manual check for numerical values. Also make the code structure a little more
+        consistent.
+        * platform/graphics/transforms/PerspectiveTransformOperation.h: Update assertion, because
+        Undefined means perpsective: none now.
+        * platform/graphics/transforms/PerspectiveTransformOperation.cpp:
+        (WebCore::PerspectiveTransformOperation::blend): Handle the case of perspective: none for
+        either values.
+
 2021-11-03  Megan Gardner  <[email protected]>
 
         TextIndicators are flipped when spanning more than one line.

Modified: trunk/Source/WebCore/css/TransformFunctions.cpp (285254 => 285255)


--- trunk/Source/WebCore/css/TransformFunctions.cpp	2021-11-04 06:28:28 UTC (rev 285254)
+++ trunk/Source/WebCore/css/TransformFunctions.cpp	2021-11-04 08:51:14 UTC (rev 285255)
@@ -322,21 +322,25 @@
             break;
         }
         case CSSValuePerspective: {
-            Length p = Length(0, LengthType::Fixed);
-            if (firstValue.isLength())
-                p = convertToFloatLength(&firstValue, conversionData);
-            else {
-                // This is a quirk that should go away when 3d transforms are finalized.
-                double val = firstValue.doubleValue();
-                p = val >= 0 ? Length(clampToPositiveInteger(val), LengthType::Fixed) : Length(LengthType::Undefined);
-            }
+            std::optional<Length> perspectiveLength;
+            if (!firstValue.isValueID()) {
+                if (firstValue.isLength())
+                    perspectiveLength = convertToFloatLength(&firstValue, conversionData);
+                else {
+                    // This is a quirk that should go away when 3d transforms are finalized.
+                    // FIXME: https://bugs.webkit.org/show_bug.cgi?id=232669
+                    // This does not deal properly with calc(), because we aren't passing conversionData here.
+                    double doubleValue = firstValue.doubleValue();
+                    if (doubleValue < 0) {
+                        operations.clear();
+                        return false;
+                    }
+                    perspectiveLength = Length(clampToPositiveInteger(doubleValue), LengthType::Fixed);
+                }
+            } else
+                ASSERT(firstValue.valueID() == CSSValueNone);
 
-            if (p.isUndefined()) {
-                operations.clear();
-                return false;
-            }
-
-            operations.append(PerspectiveTransformOperation::create(p));
+            operations.append(PerspectiveTransformOperation::create(perspectiveLength));
             break;
         }
         default:

Modified: trunk/Source/WebCore/css/parser/CSSPropertyParser.cpp (285254 => 285255)


--- trunk/Source/WebCore/css/parser/CSSPropertyParser.cpp	2021-11-04 06:28:28 UTC (rev 285254)
+++ trunk/Source/WebCore/css/parser/CSSPropertyParser.cpp	2021-11-04 08:51:14 UTC (rev 285255)
@@ -1831,16 +1831,22 @@
 
 static bool consumePerspective(CSSParserTokenRange& args, CSSParserMode cssParserMode, RefPtr<CSSFunctionValue>& transformValue)
 {
+    if (args.peek().id() == CSSValueNone) {
+        transformValue->append(consumeIdent(args).releaseNonNull());
+        return true;
+    }
+
     if (auto parsedValue = consumeLength(args, cssParserMode, ValueRange::NonNegative)) {
         transformValue->append(parsedValue.releaseNonNull());
         return true;
     }
 
-    auto perspective = consumeNumberRaw(args);
-    if (!perspective || *perspective < 0)
-        return false;
-    transformValue->append(CSSPrimitiveValue::create(*perspective, CSSUnitType::CSS_PX));
-    return true;
+    if (auto perspective = consumeNumberRaw(args, ValueRange::NonNegative)) {
+        transformValue->append(CSSPrimitiveValue::create(*perspective, CSSUnitType::CSS_PX));
+        return true;
+    }
+
+    return false;
 }
 
 static RefPtr<CSSValue> consumeTransformValue(CSSParserTokenRange& range, CSSParserMode cssParserMode)

Modified: trunk/Source/WebCore/platform/graphics/transforms/PerspectiveTransformOperation.cpp (285254 => 285255)


--- trunk/Source/WebCore/platform/graphics/transforms/PerspectiveTransformOperation.cpp	2021-11-04 06:28:28 UTC (rev 285254)
+++ trunk/Source/WebCore/platform/graphics/transforms/PerspectiveTransformOperation.cpp	2021-11-04 08:51:14 UTC (rev 285255)
@@ -45,19 +45,29 @@
         return *this;
     
     if (blendToIdentity) {
-        double p = floatValueForLength(m_p, 1);
+        if (!m_p)
+            return PerspectiveTransformOperation::create(m_p);
+
+        double p = floatValueForLength(*m_p, 1);
         p = WebCore::blend(p, 1.0, context); // FIXME: this seems wrong. https://bugs.webkit.org/show_bug.cgi?id=52700
         return PerspectiveTransformOperation::create(Length(clampToPositiveInteger(p), LengthType::Fixed));
     }
     
     const PerspectiveTransformOperation* fromOp = downcast<PerspectiveTransformOperation>(from);
-    Length fromP = fromOp ? fromOp->m_p : Length(m_p.type());
-    Length toP = m_p;
+    if (!fromOp)
+        return *this;
 
+    auto fromP = fromOp->m_p;
+    auto toP = m_p;
+
     TransformationMatrix fromT;
+    if (fromP)
+        fromT.applyPerspective(floatValueForLength(*fromP, 1));
+
     TransformationMatrix toT;
-    fromT.applyPerspective(floatValueForLength(fromP, 1));
-    toT.applyPerspective(floatValueForLength(toP, 1));
+    if (toP)
+        toT.applyPerspective(floatValueForLength(*toP, 1));
+
     toT.blend(fromT, context.progress);
     TransformationMatrix::Decomposed4Type decomp;
     toT.decompose4(decomp);
@@ -71,7 +81,12 @@
 
 void PerspectiveTransformOperation::dump(TextStream& ts) const
 {
-    ts << type() << "(" << m_p << ")";
+    ts << type() << "(";
+    if (!m_p)
+        ts << "none";
+    else
+        ts << m_p;
+    ts << ")";
 }
 
 } // namespace WebCore

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


--- trunk/Source/WebCore/platform/graphics/transforms/PerspectiveTransformOperation.h	2021-11-04 06:28:28 UTC (rev 285254)
+++ trunk/Source/WebCore/platform/graphics/transforms/PerspectiveTransformOperation.h	2021-11-04 08:51:14 UTC (rev 285255)
@@ -28,6 +28,7 @@
 #include "Length.h"
 #include "LengthFunctions.h"
 #include "TransformOperation.h"
+#include <optional>
 #include <wtf/Ref.h>
 
 namespace WebCore {
@@ -36,7 +37,7 @@
 
 class PerspectiveTransformOperation final : public TransformOperation {
 public:
-    static Ref<PerspectiveTransformOperation> create(const Length& p)
+    static Ref<PerspectiveTransformOperation> create(const std::optional<Length>& p)
     {
         return adoptRef(*new PerspectiveTransformOperation(p));
     }
@@ -46,10 +47,10 @@
         return adoptRef(*new PerspectiveTransformOperation(m_p));
     }
 
-    Length perspective() const { return m_p; }
+    std::optional<Length> perspective() const { return m_p; }
     
 private:
-    bool isIdentity() const override { return !floatValueForLength(m_p, 1); }
+    bool isIdentity() const override { return !m_p || !floatValueForLength(*m_p, 1); }
     bool isAffectedByTransformOrigin() const override { return !isIdentity(); }
     bool isRepresentableIn2D() const final { return false; }
 
@@ -57,7 +58,8 @@
 
     bool apply(TransformationMatrix& transform, const FloatSize&) const override
     {
-        transform.applyPerspective(floatValueForLength(m_p, 1));
+        if (m_p)
+            transform.applyPerspective(floatValueForLength(*m_p, 1));
         return false;
     }
 
@@ -65,14 +67,14 @@
 
     void dump(WTF::TextStream&) const final;
 
-    PerspectiveTransformOperation(const Length& p)
+    PerspectiveTransformOperation(const std::optional<Length>& p)
         : TransformOperation(PERSPECTIVE)
         , m_p(p)
     {
-        ASSERT(p.isFixed());
+        ASSERT(!p || (*p).isFixed());
     }
 
-    Length m_p;
+    std::optional<Length> m_p;
 };
 
 } // namespace WebCore
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to