- Revision
- 230816
- Author
- commit-qu...@webkit.org
- Date
- 2018-04-19 13:25:55 -0700 (Thu, 19 Apr 2018)
Log Message
Support calc() in webkit-gradient and cross-fade
https://bugs.webkit.org/show_bug.cgi?id=182225
Patch by Chris Nardi <cna...@chromium.org> on 2018-04-19
Reviewed by Simon Fraser.
Source/WebCore:
calc() was previously unsupported in webkit-gradient and webkit-cross-fade, but both should take calc() values.
Update the code to support calc() values.
Tests: LayoutTests/css3/calc/cross-fade-calc.html
LayoutTests/css3/calc/webkit-gradient-calc.html
* css/parser/CSSPropertyParserHelpers.cpp:
(WebCore::CSSPropertyParserHelpers::consumeDeprecatedGradientColorStop):
(WebCore::CSSPropertyParserHelpers::consumeCrossFade):
LayoutTests:
Add new test cases.
* css3/calc/cross-fade-calc.html: Added.
* css3/calc/cross-fade-calc-expected.txt: Added.
* css3/calc/webkit-gradient-calc.html: Added.
* css3/calc/webkit-gradient-calc-expected.txt: Added.
Modified Paths
Added Paths
Diff
Modified: trunk/LayoutTests/ChangeLog (230815 => 230816)
--- trunk/LayoutTests/ChangeLog 2018-04-19 20:20:36 UTC (rev 230815)
+++ trunk/LayoutTests/ChangeLog 2018-04-19 20:25:55 UTC (rev 230816)
@@ -1,3 +1,17 @@
+2018-04-19 Chris Nardi <cna...@chromium.org>
+
+ Support calc() in webkit-gradient and cross-fade
+ https://bugs.webkit.org/show_bug.cgi?id=182225
+
+ Reviewed by Simon Fraser.
+
+ Add new test cases.
+
+ * css3/calc/cross-fade-calc.html: Added.
+ * css3/calc/cross-fade-calc-expected.txt: Added.
+ * css3/calc/webkit-gradient-calc.html: Added.
+ * css3/calc/webkit-gradient-calc-expected.txt: Added.
+
2018-04-19 Youenn Fablet <you...@apple.com>
NetworkProcess should use CSP/content blockers for sync XHR
Added: trunk/LayoutTests/css3/calc/cross-fade-calc-expected.txt (0 => 230816)
--- trunk/LayoutTests/css3/calc/cross-fade-calc-expected.txt (rev 0)
+++ trunk/LayoutTests/css3/calc/cross-fade-calc-expected.txt 2018-04-19 20:25:55 UTC (rev 230816)
@@ -0,0 +1,3 @@
+
+PASS calc() in cross-fade
+
Added: trunk/LayoutTests/css3/calc/cross-fade-calc.html (0 => 230816)
--- trunk/LayoutTests/css3/calc/cross-fade-calc.html (rev 0)
+++ trunk/LayoutTests/css3/calc/cross-fade-calc.html 2018-04-19 20:25:55 UTC (rev 230816)
@@ -0,0 +1,18 @@
+<!doctype html>
+<meta charset="utf-8">
+<title>CSS Test: calc() function in cross-fade</title>
+<script src=""
+<script src=""
+<style>
+ #test {
+ background-image: cross-fade(url(dummy://example.png), url(dummy://example.png), calc(35% * 2));
+ }
+</style>
+<div id="test"></div>
+<script>
+ const div = document.querySelector("#test");
+ const expected = "cross-fade(url(dummy://example.png), url(dummy://example.png), 0.7)"
+ test(function() {
+ assert_equals(getComputedStyle(div).backgroundImage, expected);
+ }, "calc() in cross-fade");
+</script>
\ No newline at end of file
Added: trunk/LayoutTests/css3/calc/webkit-gradient-calc-expected.txt (0 => 230816)
--- trunk/LayoutTests/css3/calc/webkit-gradient-calc-expected.txt (rev 0)
+++ trunk/LayoutTests/css3/calc/webkit-gradient-calc-expected.txt 2018-04-19 20:25:55 UTC (rev 230816)
@@ -0,0 +1,3 @@
+
+PASS calc() in webkit-gradient
+
Added: trunk/LayoutTests/css3/calc/webkit-gradient-calc.html (0 => 230816)
--- trunk/LayoutTests/css3/calc/webkit-gradient-calc.html (rev 0)
+++ trunk/LayoutTests/css3/calc/webkit-gradient-calc.html 2018-04-19 20:25:55 UTC (rev 230816)
@@ -0,0 +1,18 @@
+<!doctype html>
+<meta charset="utf-8">
+<title>CSS Test: calc() function in webkit-gradient</title>
+<script src=""
+<script src=""
+<style>
+ #test {
+ background-image: -webkit-gradient(linear, left top, left bottom, from(#00abeb), to(#fff), color-stop(calc(40% + 10%), #fff));
+ }
+</style>
+<div id="test"></div>
+<script>
+ const div = document.querySelector("#test");
+ const expected = '-webkit-gradient(linear, 0% 0%, 0% 100%, from(rgb(0, 171, 235)), to(rgb(255, 255, 255)), color-stop(0.5, rgb(255, 255, 255)))'
+ test(function() {
+ assert_equals(getComputedStyle(div).backgroundImage, expected);
+ }, "calc() in webkit-gradient");
+</script>
\ No newline at end of file
Modified: trunk/Source/WebCore/ChangeLog (230815 => 230816)
--- trunk/Source/WebCore/ChangeLog 2018-04-19 20:20:36 UTC (rev 230815)
+++ trunk/Source/WebCore/ChangeLog 2018-04-19 20:25:55 UTC (rev 230816)
@@ -1,3 +1,20 @@
+2018-04-19 Chris Nardi <cna...@chromium.org>
+
+ Support calc() in webkit-gradient and cross-fade
+ https://bugs.webkit.org/show_bug.cgi?id=182225
+
+ Reviewed by Simon Fraser.
+
+ calc() was previously unsupported in webkit-gradient and webkit-cross-fade, but both should take calc() values.
+ Update the code to support calc() values.
+
+ Tests: LayoutTests/css3/calc/cross-fade-calc.html
+ LayoutTests/css3/calc/webkit-gradient-calc.html
+
+ * css/parser/CSSPropertyParserHelpers.cpp:
+ (WebCore::CSSPropertyParserHelpers::consumeDeprecatedGradientColorStop):
+ (WebCore::CSSPropertyParserHelpers::consumeCrossFade):
+
2018-04-17 Filip Pizlo <fpi...@apple.com>
The InternalFunction hierarchy should be in IsoSubspaces
Modified: trunk/Source/WebCore/css/parser/CSSPropertyParserHelpers.cpp (230815 => 230816)
--- trunk/Source/WebCore/css/parser/CSSPropertyParserHelpers.cpp 2018-04-19 20:20:36 UTC (rev 230815)
+++ trunk/Source/WebCore/css/parser/CSSPropertyParserHelpers.cpp 2018-04-19 20:25:55 UTC (rev 230816)
@@ -866,12 +866,9 @@
position = (id == CSSValueFrom) ? 0 : 1;
} else {
ASSERT(id == CSSValueColorStop);
- const CSSParserToken& arg = args.consumeIncludingWhitespace();
- if (arg.type() == PercentageToken)
- position = arg.numericValue() / 100.0;
- else if (arg.type() == NumberToken)
- position = arg.numericValue();
- else
+ if (auto percentValue = consumePercent(args, ValueRangeAll))
+ position = percentValue->doubleValue() / 100.0;
+ else if (!consumeNumberRaw(args, position))
return false;
if (!consumeCommaIncludingWhitespace(args))
@@ -1229,11 +1226,10 @@
return nullptr;
RefPtr<CSSPrimitiveValue> percentage;
- const CSSParserToken& percentageArg = args.consumeIncludingWhitespace();
- if (percentageArg.type() == PercentageToken)
- percentage = CSSValuePool::singleton().createValue(clampTo<double>(percentageArg.numericValue() / 100, 0, 1), CSSPrimitiveValue::UnitType::CSS_NUMBER);
- else if (percentageArg.type() == NumberToken)
- percentage = CSSValuePool::singleton().createValue(clampTo<double>(percentageArg.numericValue(), 0, 1), CSSPrimitiveValue::UnitType::CSS_NUMBER);
+ if (auto percentValue = consumePercent(args, ValueRangeAll))
+ percentage = CSSValuePool::singleton().createValue(clampTo<double>(percentValue->doubleValue() / 100.0, 0, 1), CSSPrimitiveValue::UnitType::CSS_NUMBER);
+ else if (auto numberValue = consumeNumber(args, ValueRangeAll))
+ percentage = CSSValuePool::singleton().createValue(clampTo<double>(numberValue->doubleValue(), 0, 1), CSSPrimitiveValue::UnitType::CSS_NUMBER);
if (!percentage)
return nullptr;