Title: [291841] trunk
Revision
291841
Author
[email protected]
Date
2022-03-24 18:03:07 -0700 (Thu, 24 Mar 2022)

Log Message

calc(): Handle finite value with infinite step in round()
https://bugs.webkit.org/show_bug.cgi?id=238231

Reviewed by Simon Fraser.

LayoutTests/imported/w3c:

* web-platform-tests/css/css-values/round-function-expected.txt:

Source/WebCore:

Add handling for finite value with infinite step in round().

* css/calc/CSSCalcOperationNode.cpp:
(WebCore::CSSCalcOperationNode::evaluateOperator):
* css/calc/CSSCalcPrimitiveValueNode.cpp:
(WebCore::CSSCalcPrimitiveValueNode::invert):

Modified Paths

Diff

Modified: trunk/LayoutTests/imported/w3c/ChangeLog (291840 => 291841)


--- trunk/LayoutTests/imported/w3c/ChangeLog	2022-03-25 00:50:04 UTC (rev 291840)
+++ trunk/LayoutTests/imported/w3c/ChangeLog	2022-03-25 01:03:07 UTC (rev 291841)
@@ -1,5 +1,14 @@
 2022-03-24  Nikolaos Mouchtaris  <[email protected]>
 
+        calc(): Handle finite value with infinite step in round()
+        https://bugs.webkit.org/show_bug.cgi?id=238231
+
+        Reviewed by Simon Fraser.
+
+        * web-platform-tests/css/css-values/round-function-expected.txt:
+
+2022-03-24  Nikolaos Mouchtaris  <[email protected]>
+
         Fix serialization of nan, infinity, -infinity for calc()
         https://bugs.webkit.org/show_bug.cgi?id=238288
 

Modified: trunk/LayoutTests/imported/w3c/web-platform-tests/css/css-values/round-function-expected.txt (291840 => 291841)


--- trunk/LayoutTests/imported/w3c/web-platform-tests/css/css-values/round-function-expected.txt	2022-03-25 00:50:04 UTC (rev 291840)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/css/css-values/round-function-expected.txt	2022-03-25 01:03:07 UTC (rev 291841)
@@ -49,20 +49,20 @@
 PASS round(infinity, -5) should be used-value-equivalent to calc(infinity)
 PASS round(-infinity, 5) should be used-value-equivalent to calc(-infinity)
 PASS round(-infinity, -5) should be used-value-equivalent to calc(-infinity)
-FAIL calc(1 / round(5, infinity)) should be used-value-equivalent to calc(infinity) assert_equals: calc(1 / round(5, infinity)) and calc(infinity) serialize to the same thing in used values. expected "matrix3d(infinity, NaN, NaN, NaN, NaN, infinity, NaN, NaN, 0, 0, 1, 0, 0, 0, 0, 1)" but got "matrix3d(NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, 0, 0, 1, 0, 0, 0, 0, 1)"
-FAIL calc(1 / round(5, -infinity)) should be used-value-equivalent to calc(infinity) assert_equals: calc(1 / round(5, -infinity)) and calc(infinity) serialize to the same thing in used values. expected "matrix3d(infinity, NaN, NaN, NaN, NaN, infinity, NaN, NaN, 0, 0, 1, 0, 0, 0, 0, 1)" but got "matrix3d(NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, 0, 0, 1, 0, 0, 0, 0, 1)"
-FAIL calc(1 / round(-5, infinity)) should be used-value-equivalent to calc(-infinity) assert_equals: calc(1 / round(-5, infinity)) and calc(-infinity) serialize to the same thing in used values. expected "matrix3d(-infinity, NaN, NaN, NaN, NaN, -infinity, NaN, NaN, 0, 0, 1, 0, 0, 0, 0, 1)" but got "matrix3d(NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, 0, 0, 1, 0, 0, 0, 0, 1)"
-FAIL calc(1 / round(-5, -infinity)) should be used-value-equivalent to calc(-infinity) assert_equals: calc(1 / round(-5, -infinity)) and calc(-infinity) serialize to the same thing in used values. expected "matrix3d(-infinity, NaN, NaN, NaN, NaN, -infinity, NaN, NaN, 0, 0, 1, 0, 0, 0, 0, 1)" but got "matrix3d(NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, 0, 0, 1, 0, 0, 0, 0, 1)"
-FAIL calc(1 / round(to-zero, 5, infinity)) should be used-value-equivalent to calc(infinity) assert_equals: calc(1 / round(to-zero, 5, infinity)) and calc(infinity) serialize to the same thing in used values. expected "matrix3d(infinity, NaN, NaN, NaN, NaN, infinity, NaN, NaN, 0, 0, 1, 0, 0, 0, 0, 1)" but got "matrix3d(NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, 0, 0, 1, 0, 0, 0, 0, 1)"
-FAIL calc(1 / round(to-zero, 5, -infinity)) should be used-value-equivalent to calc(infinity) assert_equals: calc(1 / round(to-zero, 5, -infinity)) and calc(infinity) serialize to the same thing in used values. expected "matrix3d(infinity, NaN, NaN, NaN, NaN, infinity, NaN, NaN, 0, 0, 1, 0, 0, 0, 0, 1)" but got "matrix3d(NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, 0, 0, 1, 0, 0, 0, 0, 1)"
-FAIL calc(1 / round(to-zero, -5, infinity)) should be used-value-equivalent to calc(-infinity) assert_equals: calc(1 / round(to-zero, -5, infinity)) and calc(-infinity) serialize to the same thing in used values. expected "matrix3d(-infinity, NaN, NaN, NaN, NaN, -infinity, NaN, NaN, 0, 0, 1, 0, 0, 0, 0, 1)" but got "matrix3d(NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, 0, 0, 1, 0, 0, 0, 0, 1)"
-FAIL calc(1 / round(to-zero, -5, -infinity)) should be used-value-equivalent to calc(-infinity) assert_equals: calc(1 / round(to-zero, -5, -infinity)) and calc(-infinity) serialize to the same thing in used values. expected "matrix3d(-infinity, NaN, NaN, NaN, NaN, -infinity, NaN, NaN, 0, 0, 1, 0, 0, 0, 0, 1)" but got "matrix3d(NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, 0, 0, 1, 0, 0, 0, 0, 1)"
-FAIL round(up, 1, infinity) should be used-value-equivalent to calc(infinity) assert_equals: round(up, 1, infinity) and calc(infinity) serialize to the same thing in used values. expected "matrix3d(infinity, NaN, NaN, NaN, NaN, infinity, NaN, NaN, 0, 0, 1, 0, 0, 0, 0, 1)" but got "matrix3d(NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, 0, 0, 1, 0, 0, 0, 0, 1)"
-FAIL calc(1 / round(up, 0, infinity)) should be used-value-equivalent to calc(infinity) assert_equals: calc(1 / round(up, 0, infinity)) and calc(infinity) serialize to the same thing in used values. expected "matrix3d(infinity, NaN, NaN, NaN, NaN, infinity, NaN, NaN, 0, 0, 1, 0, 0, 0, 0, 1)" but got "matrix3d(NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, 0, 0, 1, 0, 0, 0, 0, 1)"
-FAIL calc(1 / round(up, -1 * 0, infinity) should be used-value-equivalent to calc(-infinity) assert_equals: calc(1 / round(up, -1 * 0, infinity) and calc(-infinity) serialize to the same thing in used values. expected "matrix3d(-infinity, NaN, NaN, NaN, NaN, -infinity, NaN, NaN, 0, 0, 1, 0, 0, 0, 0, 1)" but got "matrix3d(NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, 0, 0, 1, 0, 0, 0, 0, 1)"
-FAIL calc(1 / round(up, -1, infinity) should be used-value-equivalent to calc(-infinity) assert_equals: calc(1 / round(up, -1, infinity) and calc(-infinity) serialize to the same thing in used values. expected "matrix3d(-infinity, NaN, NaN, NaN, NaN, -infinity, NaN, NaN, 0, 0, 1, 0, 0, 0, 0, 1)" but got "matrix3d(NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, 0, 0, 1, 0, 0, 0, 0, 1)"
-FAIL round(down, -1, infinity) should be used-value-equivalent to calc(-infinity) assert_equals: round(down, -1, infinity) and calc(-infinity) serialize to the same thing in used values. expected "matrix3d(-infinity, NaN, NaN, NaN, NaN, -infinity, NaN, NaN, 0, 0, 1, 0, 0, 0, 0, 1)" but got "matrix3d(NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, 0, 0, 1, 0, 0, 0, 0, 1)"
-FAIL calc(1 / round(down, -1 * 0, infinity)) should be used-value-equivalent to calc(-infinity) assert_equals: calc(1 / round(down, -1 * 0, infinity)) and calc(-infinity) serialize to the same thing in used values. expected "matrix3d(-infinity, NaN, NaN, NaN, NaN, -infinity, NaN, NaN, 0, 0, 1, 0, 0, 0, 0, 1)" but got "matrix3d(NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, 0, 0, 1, 0, 0, 0, 0, 1)"
-FAIL calc(1 / round(down, 0, infinity)) should be used-value-equivalent to calc(infinity) assert_equals: calc(1 / round(down, 0, infinity)) and calc(infinity) serialize to the same thing in used values. expected "matrix3d(infinity, NaN, NaN, NaN, NaN, infinity, NaN, NaN, 0, 0, 1, 0, 0, 0, 0, 1)" but got "matrix3d(NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, 0, 0, 1, 0, 0, 0, 0, 1)"
-FAIL calc(1 / round(down, 1, infinity)) should be used-value-equivalent to calc(infinity) assert_equals: calc(1 / round(down, 1, infinity)) and calc(infinity) serialize to the same thing in used values. expected "matrix3d(infinity, NaN, NaN, NaN, NaN, infinity, NaN, NaN, 0, 0, 1, 0, 0, 0, 0, 1)" but got "matrix3d(NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, 0, 0, 1, 0, 0, 0, 0, 1)"
+PASS calc(1 / round(5, infinity)) should be used-value-equivalent to calc(infinity)
+PASS calc(1 / round(5, -infinity)) should be used-value-equivalent to calc(infinity)
+PASS calc(1 / round(-5, infinity)) should be used-value-equivalent to calc(-infinity)
+PASS calc(1 / round(-5, -infinity)) should be used-value-equivalent to calc(-infinity)
+PASS calc(1 / round(to-zero, 5, infinity)) should be used-value-equivalent to calc(infinity)
+PASS calc(1 / round(to-zero, 5, -infinity)) should be used-value-equivalent to calc(infinity)
+PASS calc(1 / round(to-zero, -5, infinity)) should be used-value-equivalent to calc(-infinity)
+PASS calc(1 / round(to-zero, -5, -infinity)) should be used-value-equivalent to calc(-infinity)
+PASS round(up, 1, infinity) should be used-value-equivalent to calc(infinity)
+PASS calc(1 / round(up, 0, infinity)) should be used-value-equivalent to calc(infinity)
+PASS calc(1 / round(up, -1 * 0, infinity) should be used-value-equivalent to calc(-infinity)
+PASS calc(1 / round(up, -1, infinity) should be used-value-equivalent to calc(-infinity)
+PASS round(down, -1, infinity) should be used-value-equivalent to calc(-infinity)
+PASS calc(1 / round(down, -1 * 0, infinity)) should be used-value-equivalent to calc(-infinity)
+PASS calc(1 / round(down, 0, infinity)) should be used-value-equivalent to calc(infinity)
+PASS calc(1 / round(down, 1, infinity)) should be used-value-equivalent to calc(infinity)
 

Modified: trunk/Source/WebCore/ChangeLog (291840 => 291841)


--- trunk/Source/WebCore/ChangeLog	2022-03-25 00:50:04 UTC (rev 291840)
+++ trunk/Source/WebCore/ChangeLog	2022-03-25 01:03:07 UTC (rev 291841)
@@ -1,3 +1,17 @@
+2022-03-24  Nikolaos Mouchtaris  <[email protected]>
+
+        calc(): Handle finite value with infinite step in round()
+        https://bugs.webkit.org/show_bug.cgi?id=238231
+
+        Reviewed by Simon Fraser.
+
+        Add handling for finite value with infinite step in round().
+
+        * css/calc/CSSCalcOperationNode.cpp:
+        (WebCore::CSSCalcOperationNode::evaluateOperator):
+        * css/calc/CSSCalcPrimitiveValueNode.cpp:
+        (WebCore::CSSCalcPrimitiveValueNode::invert):
+
 2022-03-24  Chris Dumez  <[email protected]>
 
         String's startsWith() / endsWith() / replace() should take in a StringView instead of a String

Modified: trunk/Source/WebCore/css/calc/CSSCalcOperationNode.cpp (291840 => 291841)


--- trunk/Source/WebCore/css/calc/CSSCalcOperationNode.cpp	2022-03-25 00:50:04 UTC (rev 291840)
+++ trunk/Source/WebCore/css/calc/CSSCalcOperationNode.cpp	2022-03-25 01:03:07 UTC (rev 291841)
@@ -1427,6 +1427,11 @@
     case CalcOperator::Up: {
         if (children.size() != 2)
             return std::numeric_limits<double>::quiet_NaN();
+        if (!isinf(children[0]) && std::isinf(children[1])) {
+            if (!children[0])
+                return children[0];
+            return signbit(children[0]) ? -0.0 : std::numeric_limits<double>::infinity();
+        }
         auto ret = getNearestMultiples(children[0], children[1]);
         return ret.second;
     }
@@ -1433,6 +1438,11 @@
     case CalcOperator::Down: {
         if (children.size() != 2)
             return std::numeric_limits<double>::quiet_NaN();
+        if (!isinf(children[0]) && isinf(children[1])) {
+            if (!children[0])
+                return children[0];
+            return signbit(children[0]) ? -std::numeric_limits<double>::infinity() : +0.0;
+        }
         auto ret = getNearestMultiples(children[0], children[1]);
         return ret.first;
     }
@@ -1439,6 +1449,8 @@
     case CalcOperator::Nearest: {
         if (children.size() != 2)
             return std::numeric_limits<double>::quiet_NaN();
+        if (!isinf(children[0]) && isinf(children[1]))
+            return signbit(children[0]) ? -0.0 : +0.0;
         auto ret = getNearestMultiples(children[0], children[1]);
         auto upperB = ret.second;
         auto lowerB = ret.first;
@@ -1447,6 +1459,8 @@
     case CalcOperator::ToZero: {
         if (children.size() != 2)
             return std::numeric_limits<double>::quiet_NaN();
+        if (!isinf(children[0]) && isinf(children[1]))
+            return signbit(children[0]) ? -0.0 : +0.0;
         auto ret = getNearestMultiples(children[0], children[1]);
         auto upperB = ret.second;
         auto lowerB = ret.first;

Modified: trunk/Source/WebCore/css/calc/CSSCalcPrimitiveValueNode.cpp (291840 => 291841)


--- trunk/Source/WebCore/css/calc/CSSCalcPrimitiveValueNode.cpp	2022-03-25 00:50:04 UTC (rev 291840)
+++ trunk/Source/WebCore/css/calc/CSSCalcPrimitiveValueNode.cpp	2022-03-25 01:03:07 UTC (rev 291841)
@@ -86,7 +86,7 @@
 {
     ASSERT(isNumericValue());
     if (!m_value->doubleValue()) {
-        m_value = CSSPrimitiveValue::create(std::numeric_limits<double>::infinity(), m_value->primitiveType());
+        m_value = CSSPrimitiveValue::create(std::copysign(std::numeric_limits<double>::infinity(), m_value->doubleValue()), m_value->primitiveType());
         return;
     }
 
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to