imported/w3c/web-platform-tests/css/css-values/calc-positive-fraction-001.html fails
authorsimon.fraser@apple.com <simon.fraser@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 25 Oct 2019 03:16:47 +0000 (03:16 +0000)
committersimon.fraser@apple.com <simon.fraser@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 25 Oct 2019 03:16:47 +0000 (03:16 +0000)
https://bugs.webkit.org/show_bug.cgi?id=203332

Reviewed by Dean Jackson.
Source/WebCore:

The calc() spec <https://drafts.csswg.org/css-values-4/#calc-range> says that you clamp
and round the result of the clamp computation. Do that, instead of treating non-integral
calc results as invalid for CSS properties that only take integers.

Tests: imported/w3c/web-platform-tests/css/css-values/calc-positive-fraction-001.html

* css/parser/CSSPropertyParserHelpers.cpp:
(WebCore::CSSPropertyParserHelpers::CalcParser::consumeInteger):
(WebCore::CSSPropertyParserHelpers::consumeInteger):

LayoutTests:

imported/w3c/web-platform-tests/css/css-values/calc-positive-fraction-001.html passes now.

* TestExpectations:

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@251580 268f45cc-cd09-0410-ab3c-d52691b4dbfc

LayoutTests/ChangeLog
LayoutTests/TestExpectations
Source/WebCore/ChangeLog
Source/WebCore/css/parser/CSSPropertyParserHelpers.cpp

index 8bdf7e4..cd0e89e 100644 (file)
@@ -1,3 +1,14 @@
+2019-10-24  Simon Fraser  <simon.fraser@apple.com>
+
+        imported/w3c/web-platform-tests/css/css-values/calc-positive-fraction-001.html fails
+        https://bugs.webkit.org/show_bug.cgi?id=203332
+
+        Reviewed by Dean Jackson.
+
+        imported/w3c/web-platform-tests/css/css-values/calc-positive-fraction-001.html passes now.
+
+        * TestExpectations:
+
 2019-10-24  Zhifei Fang  <zhifei_fang@apple.com>
 
         [jsc test] Skip intl-numberformat.js test
index 29132ce..2c713fa 100644 (file)
@@ -3899,7 +3899,6 @@ webkit.org/b/203328 imported/w3c/web-platform-tests/css/css-values/attr-length-v
 webkit.org/b/203329 imported/w3c/web-platform-tests/css/css-values/attr-length-valid.html [ ImageOnlyFailure ]
 webkit.org/b/203330 imported/w3c/web-platform-tests/css/css-values/attr-px-invalid-cast.html [ ImageOnlyFailure ]
 webkit.org/b/203331 imported/w3c/web-platform-tests/css/css-values/attr-px-valid.html [ ImageOnlyFailure ]
-webkit.org/b/203332 imported/w3c/web-platform-tests/css/css-values/calc-positive-fraction-001.html [ ImageOnlyFailure ]
 webkit.org/b/203333 imported/w3c/web-platform-tests/css/css-values/ch-unit-002.html [ ImageOnlyFailure ]
 webkit.org/b/203333 imported/w3c/web-platform-tests/css/css-values/ch-unit-003.html [ ImageOnlyFailure ]
 webkit.org/b/203333 imported/w3c/web-platform-tests/css/css-values/ch-unit-004.html [ ImageOnlyFailure ]
index 2641e98..ff07734 100644 (file)
@@ -1,3 +1,20 @@
+2019-10-24  Simon Fraser  <simon.fraser@apple.com>
+
+        imported/w3c/web-platform-tests/css/css-values/calc-positive-fraction-001.html fails
+        https://bugs.webkit.org/show_bug.cgi?id=203332
+
+        Reviewed by Dean Jackson.
+        
+        The calc() spec <https://drafts.csswg.org/css-values-4/#calc-range> says that you clamp
+        and round the result of the clamp computation. Do that, instead of treating non-integral
+        calc results as invalid for CSS properties that only take integers.
+
+        Tests: imported/w3c/web-platform-tests/css/css-values/calc-positive-fraction-001.html
+
+        * css/parser/CSSPropertyParserHelpers.cpp:
+        (WebCore::CSSPropertyParserHelpers::CalcParser::consumeInteger):
+        (WebCore::CSSPropertyParserHelpers::consumeInteger):
+
 2019-10-23  Ryosuke Niwa  <rniwa@webkit.org>
 
         Add a mechanism to find and manipulate text by paragraphs
index f1699e7..c1b13e1 100644 (file)
@@ -91,6 +91,7 @@ public:
     }
 
     const CSSCalcValue* value() const { return m_calcValue.get(); }
+
     RefPtr<CSSPrimitiveValue> consumeValue()
     {
         if (!m_calcValue)
@@ -98,6 +99,18 @@ public:
         m_sourceRange = m_range;
         return CSSValuePool::singleton().createValue(WTFMove(m_calcValue));
     }
+
+    RefPtr<CSSPrimitiveValue> consumeInteger(double minimumValue)
+    {
+        if (!m_calcValue)
+            return nullptr;
+        m_sourceRange = m_range;
+
+        double value = std::max(m_calcValue->doubleValue(), minimumValue);
+        value = std::round(value);
+        return CSSValuePool::singleton().createValue(value, CSSPrimitiveValue::UnitType::CSS_NUMBER);
+    }
+
     RefPtr<CSSPrimitiveValue> consumeNumber()
     {
         if (!m_calcValue)
@@ -146,12 +159,9 @@ RefPtr<CSSPrimitiveValue> consumeInteger(CSSParserTokenRange& range, double mini
 
     CalcParser calcParser(range, CalculationCategory::Number);
     if (const CSSCalcValue* calculation = calcParser.value()) {
-        if (calculation->category() != CalculationCategory::Number || !calculation->isInt())
+        if (calculation->category() != CalculationCategory::Number)
             return nullptr;
-        double value = calculation->doubleValue();
-        if (value < minimumValue)
-            return nullptr;
-        return calcParser.consumeNumber();
+        return calcParser.consumeInteger(minimumValue);
     }
 
     return nullptr;