Title: [251580] trunk
Revision
251580
Author
simon.fra...@apple.com
Date
2019-10-24 20:16:47 -0700 (Thu, 24 Oct 2019)

Log Message

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.
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:

Modified Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (251579 => 251580)


--- trunk/LayoutTests/ChangeLog	2019-10-25 01:36:22 UTC (rev 251579)
+++ trunk/LayoutTests/ChangeLog	2019-10-25 03:16:47 UTC (rev 251580)
@@ -1,3 +1,14 @@
+2019-10-24  Simon Fraser  <simon.fra...@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_f...@apple.com>
 
         [jsc test] Skip intl-numberformat.js test

Modified: trunk/LayoutTests/TestExpectations (251579 => 251580)


--- trunk/LayoutTests/TestExpectations	2019-10-25 01:36:22 UTC (rev 251579)
+++ trunk/LayoutTests/TestExpectations	2019-10-25 03:16:47 UTC (rev 251580)
@@ -3899,7 +3899,6 @@
 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 ]

Modified: trunk/Source/WebCore/ChangeLog (251579 => 251580)


--- trunk/Source/WebCore/ChangeLog	2019-10-25 01:36:22 UTC (rev 251579)
+++ trunk/Source/WebCore/ChangeLog	2019-10-25 03:16:47 UTC (rev 251580)
@@ -1,3 +1,20 @@
+2019-10-24  Simon Fraser  <simon.fra...@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  <rn...@webkit.org>
 
         Add a mechanism to find and manipulate text by paragraphs

Modified: trunk/Source/WebCore/css/parser/CSSPropertyParserHelpers.cpp (251579 => 251580)


--- trunk/Source/WebCore/css/parser/CSSPropertyParserHelpers.cpp	2019-10-25 01:36:22 UTC (rev 251579)
+++ trunk/Source/WebCore/css/parser/CSSPropertyParserHelpers.cpp	2019-10-25 03:16:47 UTC (rev 251580)
@@ -91,6 +91,7 @@
     }
 
     const CSSCalcValue* value() const { return m_calcValue.get(); }
+
     RefPtr<CSSPrimitiveValue> consumeValue()
     {
         if (!m_calcValue)
@@ -98,6 +99,18 @@
         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 @@
 
     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;
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to