Changeset 291841 in webkit


Ignore:
Timestamp:
Mar 24, 2022 6:03:07 PM (4 months ago)
Author:
Nikos Mouchtaris
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):

Location:
trunk
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/imported/w3c/ChangeLog

    r291830 r291841  
     12022-03-24  Nikolaos Mouchtaris  <nmouchtaris@apple.com>
     2
     3        calc(): Handle finite value with infinite step in round()
     4        https://bugs.webkit.org/show_bug.cgi?id=238231
     5
     6        Reviewed by Simon Fraser.
     7
     8        * web-platform-tests/css/css-values/round-function-expected.txt:
     9
    1102022-03-24  Nikolaos Mouchtaris  <nmouchtaris@apple.com>
    211
  • trunk/LayoutTests/imported/w3c/web-platform-tests/css/css-values/round-function-expected.txt

    r283434 r291841  
    5050PASS round(-infinity, 5) should be used-value-equivalent to calc(-infinity)
    5151PASS round(-infinity, -5) should be used-value-equivalent to calc(-infinity)
    52 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)"
    53 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)"
    54 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)"
    55 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)"
    56 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)"
    57 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)"
    58 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)"
    59 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)"
    60 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)"
    61 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)"
    62 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)"
    63 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)"
    64 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)"
    65 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)"
    66 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)"
    67 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)"
     52PASS calc(1 / round(5, infinity)) should be used-value-equivalent to calc(infinity)
     53PASS calc(1 / round(5, -infinity)) should be used-value-equivalent to calc(infinity)
     54PASS calc(1 / round(-5, infinity)) should be used-value-equivalent to calc(-infinity)
     55PASS calc(1 / round(-5, -infinity)) should be used-value-equivalent to calc(-infinity)
     56PASS calc(1 / round(to-zero, 5, infinity)) should be used-value-equivalent to calc(infinity)
     57PASS calc(1 / round(to-zero, 5, -infinity)) should be used-value-equivalent to calc(infinity)
     58PASS calc(1 / round(to-zero, -5, infinity)) should be used-value-equivalent to calc(-infinity)
     59PASS calc(1 / round(to-zero, -5, -infinity)) should be used-value-equivalent to calc(-infinity)
     60PASS round(up, 1, infinity) should be used-value-equivalent to calc(infinity)
     61PASS calc(1 / round(up, 0, infinity)) should be used-value-equivalent to calc(infinity)
     62PASS calc(1 / round(up, -1 * 0, infinity) should be used-value-equivalent to calc(-infinity)
     63PASS calc(1 / round(up, -1, infinity) should be used-value-equivalent to calc(-infinity)
     64PASS round(down, -1, infinity) should be used-value-equivalent to calc(-infinity)
     65PASS calc(1 / round(down, -1 * 0, infinity)) should be used-value-equivalent to calc(-infinity)
     66PASS calc(1 / round(down, 0, infinity)) should be used-value-equivalent to calc(infinity)
     67PASS calc(1 / round(down, 1, infinity)) should be used-value-equivalent to calc(infinity)
    6868
  • trunk/Source/WebCore/ChangeLog

    r291837 r291841  
     12022-03-24  Nikolaos Mouchtaris  <nmouchtaris@apple.com>
     2
     3        calc(): Handle finite value with infinite step in round()
     4        https://bugs.webkit.org/show_bug.cgi?id=238231
     5
     6        Reviewed by Simon Fraser.
     7
     8        Add handling for finite value with infinite step in round().
     9
     10        * css/calc/CSSCalcOperationNode.cpp:
     11        (WebCore::CSSCalcOperationNode::evaluateOperator):
     12        * css/calc/CSSCalcPrimitiveValueNode.cpp:
     13        (WebCore::CSSCalcPrimitiveValueNode::invert):
     14
    1152022-03-24  Chris Dumez  <cdumez@apple.com>
    216
  • trunk/Source/WebCore/css/calc/CSSCalcOperationNode.cpp

    r291516 r291841  
    14281428        if (children.size() != 2)
    14291429            return std::numeric_limits<double>::quiet_NaN();
     1430        if (!isinf(children[0]) && std::isinf(children[1])) {
     1431            if (!children[0])
     1432                return children[0];
     1433            return signbit(children[0]) ? -0.0 : std::numeric_limits<double>::infinity();
     1434        }
    14301435        auto ret = getNearestMultiples(children[0], children[1]);
    14311436        return ret.second;
     
    14341439        if (children.size() != 2)
    14351440            return std::numeric_limits<double>::quiet_NaN();
     1441        if (!isinf(children[0]) && isinf(children[1])) {
     1442            if (!children[0])
     1443                return children[0];
     1444            return signbit(children[0]) ? -std::numeric_limits<double>::infinity() : +0.0;
     1445        }
    14361446        auto ret = getNearestMultiples(children[0], children[1]);
    14371447        return ret.first;
     
    14401450        if (children.size() != 2)
    14411451            return std::numeric_limits<double>::quiet_NaN();
     1452        if (!isinf(children[0]) && isinf(children[1]))
     1453            return signbit(children[0]) ? -0.0 : +0.0;
    14421454        auto ret = getNearestMultiples(children[0], children[1]);
    14431455        auto upperB = ret.second;
     
    14481460        if (children.size() != 2)
    14491461            return std::numeric_limits<double>::quiet_NaN();
     1462        if (!isinf(children[0]) && isinf(children[1]))
     1463            return signbit(children[0]) ? -0.0 : +0.0;
    14501464        auto ret = getNearestMultiples(children[0], children[1]);
    14511465        auto upperB = ret.second;
  • trunk/Source/WebCore/css/calc/CSSCalcPrimitiveValueNode.cpp

    r287909 r291841  
    8787    ASSERT(isNumericValue());
    8888    if (!m_value->doubleValue()) {
    89         m_value = CSSPrimitiveValue::create(std::numeric_limits<double>::infinity(), m_value->primitiveType());
     89        m_value = CSSPrimitiveValue::create(std::copysign(std::numeric_limits<double>::infinity(), m_value->doubleValue()), m_value->primitiveType());
    9090        return;
    9191    }
Note: See TracChangeset for help on using the changeset viewer.