Using calc() for -webkit-filter does not work
authorcdumez@apple.com <cdumez@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 6 Jan 2015 05:51:44 +0000 (05:51 +0000)
committercdumez@apple.com <cdumez@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 6 Jan 2015 05:51:44 +0000 (05:51 +0000)
https://bugs.webkit.org/show_bug.cgi?id=140106

Reviewed by Darin Adler.

Source/WebCore:

Using calc() for -webkit-filter did not work because the CSS parser did
not handle it properly. This patch addresses the issue.

Test: fast/css/webkit-filter-calc.html

* css/CSSParser.cpp:
(WebCore::CSSParser::parseBuiltinFilterArguments):

LayoutTests:

Add a layout test to make sure using calc() for -webkit-filter CSS
property is working as intended.

* fast/css/webkit-filter-calc-expected.txt: Added.
* fast/css/webkit-filter-calc.html: Added.

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

LayoutTests/ChangeLog
LayoutTests/fast/css/webkit-filter-calc-expected.txt [new file with mode: 0644]
LayoutTests/fast/css/webkit-filter-calc.html [new file with mode: 0644]
Source/WebCore/ChangeLog
Source/WebCore/css/CSSParser.cpp

index dc980ca..14303b4 100644 (file)
@@ -1,5 +1,18 @@
 2015-01-05  Chris Dumez  <cdumez@apple.com>
 
+        Using calc() for -webkit-filter does not work
+        https://bugs.webkit.org/show_bug.cgi?id=140106
+
+        Reviewed by Darin Adler.
+
+        Add a layout test to make sure using calc() for -webkit-filter CSS
+        property is working as intended.
+
+        * fast/css/webkit-filter-calc-expected.txt: Added.
+        * fast/css/webkit-filter-calc.html: Added.
+
+2015-01-05  Chris Dumez  <cdumez@apple.com>
+
         Allow HTTPS + 'Cache-control: no-cache' pages into the page cache
         https://bugs.webkit.org/show_bug.cgi?id=139251
 
diff --git a/LayoutTests/fast/css/webkit-filter-calc-expected.txt b/LayoutTests/fast/css/webkit-filter-calc-expected.txt
new file mode 100644 (file)
index 0000000..ef1c9db
--- /dev/null
@@ -0,0 +1,13 @@
+Tests assigning a calculated value to '-webkit-filter' CSS property.
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+PASS testDiv.style['-webkit-filter'] is ""
+testDiv.style['-webkit-filter'] = 'saturate(calc(10% * 2))'
+PASS testDiv.style['-webkit-filter'] is "saturate(calc(20%))"
+PASS window.getComputedStyle(testDiv).getPropertyValue('-webkit-filter') is "saturate(0.2)"
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
diff --git a/LayoutTests/fast/css/webkit-filter-calc.html b/LayoutTests/fast/css/webkit-filter-calc.html
new file mode 100644 (file)
index 0000000..69f4b97
--- /dev/null
@@ -0,0 +1,17 @@
+<!DOCTYPE html>
+<body>
+<script src="../../resources/js-test-pre.js"></script>
+<div id="testDiv" style="position: absolute;"></div>
+<script>
+description("Tests assigning a calculated value to '-webkit-filter' CSS property.");
+
+var testDiv = document.getElementById("testDiv");
+
+shouldBeEmptyString("testDiv.style['-webkit-filter']");
+evalAndLog("testDiv.style['-webkit-filter'] = 'saturate(calc(10% * 2))'");
+shouldBeEqualToString("testDiv.style['-webkit-filter']", "saturate(calc(20%))");
+shouldBeEqualToString("window.getComputedStyle(testDiv).getPropertyValue('-webkit-filter')", "saturate(0.2)");
+
+</script>
+<script src="../../resources/js-test-post.js"></script>
+</body>
index 2e7a2d4..2ca3ad2 100644 (file)
@@ -1,5 +1,20 @@
 2015-01-05  Chris Dumez  <cdumez@apple.com>
 
+        Using calc() for -webkit-filter does not work
+        https://bugs.webkit.org/show_bug.cgi?id=140106
+
+        Reviewed by Darin Adler.
+
+        Using calc() for -webkit-filter did not work because the CSS parser did
+        not handle it properly. This patch addresses the issue.
+
+        Test: fast/css/webkit-filter-calc.html
+
+        * css/CSSParser.cpp:
+        (WebCore::CSSParser::parseBuiltinFilterArguments):
+
+2015-01-05  Chris Dumez  <cdumez@apple.com>
+
         Allow HTTPS + 'Cache-control: no-cache' pages into the page cache
         https://bugs.webkit.org/show_bug.cgi?id=139251
 
index d2433cf..969094c 100644 (file)
@@ -9353,19 +9353,18 @@ PassRefPtr<WebKitCSSFilterValue> CSSParser::parseBuiltinFilterArguments(CSSParse
             ValueWithCalculation argumentWithCalculation(*args.current());
             if (!validateUnit(argumentWithCalculation, FNumber | FPercent | FNonNeg, CSSStrictMode))
                 return nullptr;
-                
-            // FIXME: This does not handle calculated values.
-            double amount = argumentWithCalculation.value().fValue;
-            
+
+            auto primitiveValue = createPrimitiveNumericValue(argumentWithCalculation);
+
             // Saturate and Contrast allow values over 100%.
             if (filterType != WebKitCSSFilterValue::SaturateFilterOperation
                 && filterType != WebKitCSSFilterValue::ContrastFilterOperation) {
-                double maxAllowed = argumentWithCalculation.value().unit == CSSPrimitiveValue::CSS_PERCENTAGE ? 100.0 : 1.0;
-                if (amount > maxAllowed)
+                double maxAllowed = primitiveValue->primitiveType() == CSSPrimitiveValue::CSS_PERCENTAGE ? 100.0 : 1.0;
+                if (primitiveValue->getDoubleValue() > maxAllowed)
                     return nullptr;
             }
 
-            filterValue->append(cssValuePool().createValue(amount, static_cast<CSSPrimitiveValue::UnitTypes>(argumentWithCalculation.value().unit)));
+            filterValue->append(WTF::move(primitiveValue));
         }
         break;
     }