<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[208700] trunk</title>
</head>
<body>
<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; }
#msg dl a { font-weight: bold}
#msg dl a:link { color:#fc3; }
#msg dl a:active { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg ul { text-indent: -1em; padding-left: 1em; }#logmsg ol { text-indent: -1.5em; padding-left: 1.5em; }
#logmsg > ul, #logmsg > ol { margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<dl class="meta">
<dt>Revision</dt> <dd><a href="http://trac.webkit.org/projects/webkit/changeset/208700">208700</a></dd>
<dt>Author</dt> <dd>dino@apple.com</dd>
<dt>Date</dt> <dd>2016-11-14 11:57:03 -0800 (Mon, 14 Nov 2016)</dd>
</dl>
<h3>Log Message</h3>
<pre>Handle filter() image type in new CSS Parser
https://bugs.webkit.org/show_bug.cgi?id=164673
<rdar://problems/29231376>
Reviewed by Darin Adler.
Source/WebCore:
Add support for the <image> type filter() to the
new CSS Parser. This involved moving some functions
from CSSPropertyParser into CSSPropertyParserHelpers.
Covered by fast/filter-image tests.
* css/CSSValueKeywords.in:
* css/parser/CSSPropertyParser.cpp:
(WebCore::consumeShadow):
(WebCore::parseSingleShadow): Deleted.
(WebCore::consumeFilterFunction): Deleted.
(WebCore::consumeFilter): Deleted.
* css/parser/CSSPropertyParserHelpers.cpp:
(WebCore::CSSPropertyParserHelpers::consumeFilterImage):
(WebCore::CSSPropertyParserHelpers::consumeGeneratedImage):
(WebCore::CSSPropertyParserHelpers::isGeneratedImage):
(WebCore::CSSPropertyParserHelpers::consumeFilterFunction):
(WebCore::CSSPropertyParserHelpers::consumeFilter):
(WebCore::CSSPropertyParserHelpers::consumeSingleShadow):
* css/parser/CSSPropertyParserHelpers.h:
LayoutTests:
Remove the test that allows a string value for the
image source rather than a url().
* fast/filter-image/filter-image-animation-expected.txt:
* fast/filter-image/filter-image-animation.html:</pre>
<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkLayoutTestsChangeLog">trunk/LayoutTests/ChangeLog</a></li>
<li><a href="#trunkLayoutTestsfastfilterimagefilterimageanimationexpectedtxt">trunk/LayoutTests/fast/filter-image/filter-image-animation-expected.txt</a></li>
<li><a href="#trunkLayoutTestsfastfilterimagefilterimageanimationhtml">trunk/LayoutTests/fast/filter-image/filter-image-animation.html</a></li>
<li><a href="#trunkSourceWebCoreChangeLog">trunk/Source/WebCore/ChangeLog</a></li>
<li><a href="#trunkSourceWebCorecssCSSValueKeywordsin">trunk/Source/WebCore/css/CSSValueKeywords.in</a></li>
<li><a href="#trunkSourceWebCorecssparserCSSPropertyParsercpp">trunk/Source/WebCore/css/parser/CSSPropertyParser.cpp</a></li>
<li><a href="#trunkSourceWebCorecssparserCSSPropertyParserHelperscpp">trunk/Source/WebCore/css/parser/CSSPropertyParserHelpers.cpp</a></li>
<li><a href="#trunkSourceWebCorecssparserCSSPropertyParserHelpersh">trunk/Source/WebCore/css/parser/CSSPropertyParserHelpers.h</a></li>
</ul>
</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkLayoutTestsChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/ChangeLog (208699 => 208700)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/ChangeLog        2016-11-14 19:42:41 UTC (rev 208699)
+++ trunk/LayoutTests/ChangeLog        2016-11-14 19:57:03 UTC (rev 208700)
</span><span class="lines">@@ -1,3 +1,17 @@
</span><ins>+2016-11-14 Dean Jackson <dino@apple.com>
+
+ Handle filter() image type in new CSS Parser
+ https://bugs.webkit.org/show_bug.cgi?id=164673
+ <rdar://problems/29231376>
+
+ Reviewed by Darin Adler.
+
+ Remove the test that allows a string value for the
+ image source rather than a url().
+
+ * fast/filter-image/filter-image-animation-expected.txt:
+ * fast/filter-image/filter-image-animation.html:
+
</ins><span class="cx"> 2016-11-14 Joanmarie Diggs <jdiggs@igalia.com>
</span><span class="cx">
</span><span class="cx"> AX: In ARIA 1.1, the implicit value for aria-level on headings is 2
</span></span></pre></div>
<a id="trunkLayoutTestsfastfilterimagefilterimageanimationexpectedtxt"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/fast/filter-image/filter-image-animation-expected.txt (208699 => 208700)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/fast/filter-image/filter-image-animation-expected.txt        2016-11-14 19:42:41 UTC (rev 208699)
+++ trunk/LayoutTests/fast/filter-image/filter-image-animation-expected.txt        2016-11-14 19:57:03 UTC (rev 208700)
</span><span class="lines">@@ -1,10 +1,9 @@
</span><del>-
</del><ins>+
</ins><span class="cx"> PASS - "backgroundImage" property for "brightness" element at 1s saw something close to: filter(url(image.svg), brightness(0.5))
</span><span class="cx"> PASS - "backgroundImage" property for "blur" element at 1s saw something close to: filter(url(image.svg), blur(5px))
</span><span class="cx"> PASS - "backgroundImage" property for "grayscale" element at 1s saw something close to: filter(url(image.svg), grayscale(0.5))
</span><span class="cx"> PASS - "backgroundImage" property for "sepia" element at 1s saw something close to: filter(url(image.svg), sepia(0.5))
</span><span class="cx"> PASS - "backgroundImage" property for "no" element at 1s saw something close to: filter(url(blue.svg), sepia(0))
</span><del>-PASS - "backgroundImage" property for "string" element at 1s saw something close to: filter(url(image.svg), sepia(0.5))
</del><span class="cx"> PASS - "backgroundImage" property for "multiple1" element at 1s saw something close to: filter(url(image.svg), sepia(0.5) blur(1.5px) hue-rotate(22.5deg))
</span><span class="cx"> PASS - "backgroundImage" property for "multiple2" element at 1s saw something close to: filter(url(image.svg), contrast(0.5) blur(1.5px) hue-rotate(22.5deg))
</span><span class="cx"> PASS - "backgroundImage" property for "urlfilter" element at 1s saw something close to: filter(url(image.svg), sepia(0.25))
</span></span></pre></div>
<a id="trunkLayoutTestsfastfilterimagefilterimageanimationhtml"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/fast/filter-image/filter-image-animation.html (208699 => 208700)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/fast/filter-image/filter-image-animation.html        2016-11-14 19:42:41 UTC (rev 208699)
+++ trunk/LayoutTests/fast/filter-image/filter-image-animation.html        2016-11-14 19:57:03 UTC (rev 208700)
</span><span class="lines">@@ -31,10 +31,6 @@
</span><span class="cx"> -webkit-animation: no-anim 2s linear;
</span><span class="cx"> }
</span><span class="cx">
</span><del>- #string {
- -webkit-animation: string-anim 2s linear;
- }
-
</del><span class="cx"> #multiple1 {
</span><span class="cx"> -webkit-animation: multiple-anim1 2s linear;
</span><span class="cx"> }
</span><span class="lines">@@ -88,11 +84,6 @@
</span><span class="cx"> to { background-image: filter(url(resources/blue.svg), sepia(0)); }
</span><span class="cx"> }
</span><span class="cx">
</span><del>- @-webkit-keyframes string-anim {
- from { background-image: filter('resources/image.svg', sepia(1)); }
- to { background-image: filter(url(resources/image.svg), sepia(0)); }
- }
-
</del><span class="cx"> @-webkit-keyframes multiple-anim1 {
</span><span class="cx"> from { background-image: filter(url(resources/image.svg), sepia(0.25) blur(3px) hue-rotate(45deg)); }
</span><span class="cx"> to { background-image: filter(url(resources/image.svg), sepia(0.75)); }
</span><span class="lines">@@ -137,7 +128,6 @@
</span><span class="cx"> ["grayscale-anim", 1, "grayscale", "backgroundImage", "filter(url(image.svg), grayscale(0.5))", 0.05],
</span><span class="cx"> ["sepia-anim", 1, "sepia", "backgroundImage", "filter(url(image.svg), sepia(0.5))", 0.05],
</span><span class="cx"> ["no-anim", 1, "no", "backgroundImage", "filter(url(blue.svg), sepia(0))", 0],
</span><del>- ["string-anim", 1, "string", "backgroundImage", "filter(url(image.svg), sepia(0.5))", 0],
</del><span class="cx"> ["multiple-anim1", 1, "multiple1", "backgroundImage", "filter(url(image.svg), sepia(0.5) blur(1.5px) hue-rotate(22.5deg))", 0.05],
</span><span class="cx"> ["multiple-anim2", 1, "multiple2", "backgroundImage", "filter(url(image.svg), contrast(0.5) blur(1.5px) hue-rotate(22.5deg))", 0.05],
</span><span class="cx"> ["url-to-filter-anim", 1, "urlfilter", "backgroundImage", " filter(url(image.svg), sepia(0.25))", 0.05],
</span><span class="lines">@@ -158,7 +148,6 @@
</span><span class="cx"> <div class="box" id="grayscale"></div>
</span><span class="cx"> <div class="box" id="sepia"></div>
</span><span class="cx"> <div class="box" id="no"></div>
</span><del>-<div class="box" id="string"></div>
</del><span class="cx"> <div class="box" id="multiple1"></div>
</span><span class="cx"> <div class="box" id="multiple2"></div>
</span><span class="cx"> <div class="box" id="urlfilter"></div>
</span></span></pre></div>
<a id="trunkSourceWebCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/ChangeLog (208699 => 208700)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/ChangeLog        2016-11-14 19:42:41 UTC (rev 208699)
+++ trunk/Source/WebCore/ChangeLog        2016-11-14 19:57:03 UTC (rev 208700)
</span><span class="lines">@@ -1,3 +1,32 @@
</span><ins>+2016-11-14 Dean Jackson <dino@apple.com>
+
+ Handle filter() image type in new CSS Parser
+ https://bugs.webkit.org/show_bug.cgi?id=164673
+ <rdar://problems/29231376>
+
+ Reviewed by Darin Adler.
+
+ Add support for the <image> type filter() to the
+ new CSS Parser. This involved moving some functions
+ from CSSPropertyParser into CSSPropertyParserHelpers.
+
+ Covered by fast/filter-image tests.
+
+ * css/CSSValueKeywords.in:
+ * css/parser/CSSPropertyParser.cpp:
+ (WebCore::consumeShadow):
+ (WebCore::parseSingleShadow): Deleted.
+ (WebCore::consumeFilterFunction): Deleted.
+ (WebCore::consumeFilter): Deleted.
+ * css/parser/CSSPropertyParserHelpers.cpp:
+ (WebCore::CSSPropertyParserHelpers::consumeFilterImage):
+ (WebCore::CSSPropertyParserHelpers::consumeGeneratedImage):
+ (WebCore::CSSPropertyParserHelpers::isGeneratedImage):
+ (WebCore::CSSPropertyParserHelpers::consumeFilterFunction):
+ (WebCore::CSSPropertyParserHelpers::consumeFilter):
+ (WebCore::CSSPropertyParserHelpers::consumeSingleShadow):
+ * css/parser/CSSPropertyParserHelpers.h:
+
</ins><span class="cx"> 2016-11-14 Dave Hyatt <hyatt@apple.com>
</span><span class="cx">
</span><span class="cx"> [CSS Parser] Support percentages in word-spacing
</span></span></pre></div>
<a id="trunkSourceWebCorecssCSSValueKeywordsin"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/css/CSSValueKeywords.in (208699 => 208700)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/css/CSSValueKeywords.in        2016-11-14 19:42:41 UTC (rev 208699)
+++ trunk/Source/WebCore/css/CSSValueKeywords.in        2016-11-14 19:57:03 UTC (rev 208700)
</span><span class="lines">@@ -1165,6 +1165,8 @@
</span><span class="cx"> -webkit-repeating-radial-gradient
</span><span class="cx"> -webkit-image-set
</span><span class="cx"> -webkit-named-image
</span><ins>+filter
+-webkit-filter
</ins><span class="cx">
</span><span class="cx"> // deprecated gradients
</span><span class="cx"> from
</span></span></pre></div>
<a id="trunkSourceWebCorecssparserCSSPropertyParsercpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/css/parser/CSSPropertyParser.cpp (208699 => 208700)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/css/parser/CSSPropertyParser.cpp        2016-11-14 19:42:41 UTC (rev 208699)
+++ trunk/Source/WebCore/css/parser/CSSPropertyParser.cpp        2016-11-14 19:57:03 UTC (rev 208700)
</span><span class="lines">@@ -1353,52 +1353,6 @@
</span><span class="cx"> return consumeInteger(range);
</span><span class="cx"> }
</span><span class="cx">
</span><del>-static RefPtr<CSSShadowValue> parseSingleShadow(CSSParserTokenRange& range, CSSParserMode cssParserMode, bool allowInset, bool allowSpread)
-{
- RefPtr<CSSPrimitiveValue> style;
- RefPtr<CSSPrimitiveValue> color;
-
- if (range.atEnd())
- return nullptr;
- if (range.peek().id() == CSSValueInset) {
- if (!allowInset)
- return nullptr;
- style = consumeIdent(range);
- }
- color = consumeColor(range, cssParserMode);
-
- RefPtr<CSSPrimitiveValue> horizontalOffset = consumeLength(range, cssParserMode, ValueRangeAll);
- if (!horizontalOffset)
- return nullptr;
-
- RefPtr<CSSPrimitiveValue> verticalOffset = consumeLength(range, cssParserMode, ValueRangeAll);
- if (!verticalOffset)
- return nullptr;
-
- RefPtr<CSSPrimitiveValue> blurRadius = consumeLength(range, cssParserMode, ValueRangeAll);
- RefPtr<CSSPrimitiveValue> spreadDistance;
- if (blurRadius) {
- // Blur radius must be non-negative.
- if (blurRadius->doubleValue() < 0)
- return nullptr;
- if (allowSpread)
- spreadDistance = consumeLength(range, cssParserMode, ValueRangeAll);
- }
-
- if (!range.atEnd()) {
- if (!color)
- color = consumeColor(range, cssParserMode);
- if (range.peek().id() == CSSValueInset) {
- if (!allowInset || style)
- return nullptr;
- style = consumeIdent(range);
- }
- }
-
- // We pass RefPtrs, since they can actually be null.
- return CSSShadowValue::create(WTFMove(horizontalOffset), WTFMove(verticalOffset), WTFMove(blurRadius), WTFMove(spreadDistance), WTFMove(style), WTFMove(color));
-}
-
</del><span class="cx"> static RefPtr<CSSValue> consumeShadow(CSSParserTokenRange& range, CSSParserMode cssParserMode, bool isBoxShadowProperty)
</span><span class="cx"> {
</span><span class="cx"> if (range.peek().id() == CSSValueNone)
</span><span class="lines">@@ -1406,7 +1360,7 @@
</span><span class="cx">
</span><span class="cx"> RefPtr<CSSValueList> shadowValueList = CSSValueList::createCommaSeparated();
</span><span class="cx"> do {
</span><del>- if (RefPtr<CSSShadowValue> shadowValue = parseSingleShadow(range, cssParserMode, isBoxShadowProperty, isBoxShadowProperty))
</del><ins>+ if (RefPtr<CSSShadowValue> shadowValue = consumeSingleShadow(range, cssParserMode, isBoxShadowProperty, isBoxShadowProperty))
</ins><span class="cx"> shadowValueList->append(*shadowValue);
</span><span class="cx"> else
</span><span class="cx"> return nullptr;
</span><span class="lines">@@ -1414,67 +1368,6 @@
</span><span class="cx"> return shadowValueList;
</span><span class="cx"> }
</span><span class="cx">
</span><del>-static RefPtr<CSSFunctionValue> consumeFilterFunction(CSSParserTokenRange& range, const CSSParserContext& context)
-{
- CSSValueID filterType = range.peek().functionId();
- if (filterType < CSSValueInvert || filterType > CSSValueDropShadow)
- return nullptr;
- CSSParserTokenRange args = consumeFunction(range);
- RefPtr<CSSFunctionValue> filterValue = CSSFunctionValue::create(filterType);
- RefPtr<CSSValue> parsedValue;
-
- if (filterType == CSSValueDropShadow)
- parsedValue = parseSingleShadow(args, context.mode, false, false);
- else {
- if (args.atEnd())
- return filterValue;
- if (filterType == CSSValueBrightness) {
- // FIXME (crbug.com/397061): Support calc expressions like calc(10% + 0.5)
- parsedValue = consumePercent(args, ValueRangeAll);
- if (!parsedValue)
- parsedValue = consumeNumber(args, ValueRangeAll);
- } else if (filterType == CSSValueHueRotate)
- parsedValue = consumeAngle(args, context.mode, UnitlessQuirk::Forbid);
- else if (filterType == CSSValueBlur) {
- parsedValue = consumeLength(args, HTMLStandardMode, ValueRangeNonNegative);
- } else {
- // FIXME (crbug.com/397061): Support calc expressions like calc(10% + 0.5)
- parsedValue = consumePercent(args, ValueRangeNonNegative);
- if (!parsedValue)
- parsedValue = consumeNumber(args, ValueRangeNonNegative);
- if (parsedValue && filterType != CSSValueSaturate && filterType != CSSValueContrast) {
- bool isPercentage = downcast<CSSPrimitiveValue>(*parsedValue).isPercentage();
- double maxAllowed = isPercentage ? 100.0 : 1.0;
- if (downcast<CSSPrimitiveValue>(*parsedValue).doubleValue() > maxAllowed) {
- parsedValue = CSSPrimitiveValue::create(maxAllowed, isPercentage ? CSSPrimitiveValue::UnitTypes::CSS_PERCENTAGE : CSSPrimitiveValue::UnitTypes::CSS_NUMBER);
- }
- }
- }
- }
- if (!parsedValue || !args.atEnd())
- return nullptr;
- filterValue->append(*parsedValue);
- return filterValue;
-}
-
-static RefPtr<CSSValue> consumeFilter(CSSParserTokenRange& range, const CSSParserContext& context)
-{
- if (range.peek().id() == CSSValueNone)
- return consumeIdent(range);
-
- RefPtr<CSSValueList> list = CSSValueList::createSpaceSeparated();
- do {
- RefPtr<CSSValue> filterValue = consumeUrl(range);
- if (!filterValue) {
- filterValue = consumeFilterFunction(range, context);
- if (!filterValue)
- return nullptr;
- }
- list->append(filterValue.releaseNonNull());
- } while (!range.atEnd());
- return list;
-}
-
</del><span class="cx"> static RefPtr<CSSValue> consumeTextDecorationLine(CSSParserTokenRange& range)
</span><span class="cx"> {
</span><span class="cx"> CSSValueID id = range.peek().id();
</span></span></pre></div>
<a id="trunkSourceWebCorecssparserCSSPropertyParserHelperscpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/css/parser/CSSPropertyParserHelpers.cpp (208699 => 208700)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/css/parser/CSSPropertyParserHelpers.cpp        2016-11-14 19:42:41 UTC (rev 208699)
+++ trunk/Source/WebCore/css/parser/CSSPropertyParserHelpers.cpp        2016-11-14 19:57:03 UTC (rev 208700)
</span><span class="lines">@@ -33,6 +33,7 @@
</span><span class="cx"> #include "CSSCalculationValue.h"
</span><span class="cx"> #include "CSSCanvasValue.h"
</span><span class="cx"> #include "CSSCrossfadeValue.h"
</span><ins>+#include "CSSFilterImageValue.h"
</ins><span class="cx"> #include "CSSGradientValue.h"
</span><span class="cx"> #include "CSSImageSetValue.h"
</span><span class="cx"> #include "CSSImageValue.h"
</span><span class="lines">@@ -1086,7 +1087,24 @@
</span><span class="cx"> return nullptr;
</span><span class="cx"> return CSSNamedImageValue::create(imageName);
</span><span class="cx"> }
</span><del>-
</del><ins>+
+static RefPtr<CSSValue> consumeFilterImage(CSSParserTokenRange& args, const CSSParserContext& context)
+{
+ auto imageValue = consumeImageOrNone(args, context);
+ if (!imageValue || !consumeCommaIncludingWhitespace(args))
+ return nullptr;
+
+ auto filterValue = consumeFilter(args, context);
+
+ if (!filterValue)
+ return nullptr;
+
+ if (!args.atEnd())
+ return nullptr;
+
+ return CSSFilterImageValue::create(imageValue.releaseNonNull(), filterValue.releaseNonNull());
+}
+
</ins><span class="cx"> static RefPtr<CSSValue> consumeGeneratedImage(CSSParserTokenRange& range, CSSParserContext context)
</span><span class="cx"> {
</span><span class="cx"> CSSValueID id = range.peek().functionId();
</span><span class="lines">@@ -1117,7 +1135,8 @@
</span><span class="cx"> result = consumeWebkitCanvas(args);
</span><span class="cx"> else if (id == CSSValueWebkitNamedImage)
</span><span class="cx"> result = consumeWebkitNamedImage(args);
</span><del>-
</del><ins>+ else if (id == CSSValueWebkitFilter || id == CSSValueFilter)
+ result = consumeFilterImage(args, context);
</ins><span class="cx"> if (!result || !args.atEnd())
</span><span class="cx"> return nullptr;
</span><span class="cx"> range = rangeCopy;
</span><span class="lines">@@ -1161,9 +1180,113 @@
</span><span class="cx"> || id == CSSValueWebkitLinearGradient || id == CSSValueWebkitRadialGradient
</span><span class="cx"> || id == CSSValueWebkitRepeatingLinearGradient || id == CSSValueWebkitRepeatingRadialGradient
</span><span class="cx"> || id == CSSValueWebkitGradient || id == CSSValueWebkitCrossFade || id == CSSValueWebkitCanvas
</span><del>- || id == CSSValueCrossFade || id == CSSValueWebkitNamedImage;
</del><ins>+ || id == CSSValueCrossFade || id == CSSValueWebkitNamedImage || id == CSSValueWebkitFilter || id == CSSValueFilter;
</ins><span class="cx"> }
</span><span class="cx">
</span><ins>+RefPtr<CSSFunctionValue> consumeFilterFunction(CSSParserTokenRange& range, const CSSParserContext& context)
+{
+ CSSValueID filterType = range.peek().functionId();
+ if (filterType < CSSValueInvert || filterType > CSSValueDropShadow)
+ return nullptr;
+ CSSParserTokenRange args = consumeFunction(range);
+ auto filterValue = CSSFunctionValue::create(filterType);
+ RefPtr<CSSValue> parsedValue;
+
+ if (filterType == CSSValueDropShadow)
+ parsedValue = consumeSingleShadow(args, context.mode, false, false);
+ else {
+ if (args.atEnd())
+ return filterValue.ptr();
+ if (filterType == CSSValueBrightness) {
+ parsedValue = consumePercent(args, ValueRangeAll);
+ if (!parsedValue)
+ parsedValue = consumeNumber(args, ValueRangeAll);
+ } else if (filterType == CSSValueHueRotate)
+ parsedValue = consumeAngle(args, context.mode, UnitlessQuirk::Forbid);
+ else if (filterType == CSSValueBlur)
+ parsedValue = consumeLength(args, HTMLStandardMode, ValueRangeNonNegative);
+ else {
+ parsedValue = consumePercent(args, ValueRangeNonNegative);
+ if (!parsedValue)
+ parsedValue = consumeNumber(args, ValueRangeNonNegative);
+ if (parsedValue && filterType != CSSValueSaturate && filterType != CSSValueContrast) {
+ bool isPercentage = downcast<CSSPrimitiveValue>(*parsedValue).isPercentage();
+ double maxAllowed = isPercentage ? 100.0 : 1.0;
+ if (downcast<CSSPrimitiveValue>(*parsedValue).doubleValue() > maxAllowed)
+ parsedValue = CSSPrimitiveValue::create(maxAllowed, isPercentage ? CSSPrimitiveValue::UnitTypes::CSS_PERCENTAGE : CSSPrimitiveValue::UnitTypes::CSS_NUMBER);
+ }
+ }
+ }
+ if (!parsedValue || !args.atEnd())
+ return nullptr;
+ filterValue->append(*parsedValue);
+ return filterValue.ptr();
+}
+
+RefPtr<CSSValue> consumeFilter(CSSParserTokenRange& range, const CSSParserContext& context)
+{
+ if (range.peek().id() == CSSValueNone)
+ return consumeIdent(range);
+
+ auto list = CSSValueList::createSpaceSeparated();
+ do {
+ RefPtr<CSSValue> filterValue = consumeUrl(range);
+ if (!filterValue) {
+ filterValue = consumeFilterFunction(range, context);
+ if (!filterValue)
+ return nullptr;
+ }
+ list->append(filterValue.releaseNonNull());
+ } while (!range.atEnd());
+
+ return list.ptr();
+}
+
+RefPtr<CSSShadowValue> consumeSingleShadow(CSSParserTokenRange& range, CSSParserMode cssParserMode, bool allowInset, bool allowSpread)
+{
+ RefPtr<CSSPrimitiveValue> style;
+ RefPtr<CSSPrimitiveValue> color;
+
+ if (range.atEnd())
+ return nullptr;
+ if (range.peek().id() == CSSValueInset) {
+ if (!allowInset)
+ return nullptr;
+ style = consumeIdent(range);
+ }
+ color = consumeColor(range, cssParserMode);
+
+ auto horizontalOffset = consumeLength(range, cssParserMode, ValueRangeAll);
+ if (!horizontalOffset)
+ return nullptr;
+
+ auto verticalOffset = consumeLength(range, cssParserMode, ValueRangeAll);
+ if (!verticalOffset)
+ return nullptr;
+
+ auto blurRadius = consumeLength(range, cssParserMode, ValueRangeAll);
+ RefPtr<CSSPrimitiveValue> spreadDistance;
+ if (blurRadius) {
+ // Blur radius must be non-negative.
+ if (blurRadius->doubleValue() < 0)
+ return nullptr;
+ if (allowSpread)
+ spreadDistance = consumeLength(range, cssParserMode, ValueRangeAll);
+ }
+
+ if (!range.atEnd()) {
+ if (!color)
+ color = consumeColor(range, cssParserMode);
+ if (range.peek().id() == CSSValueInset) {
+ if (!allowInset || style)
+ return nullptr;
+ style = consumeIdent(range);
+ }
+ }
+
+ return CSSShadowValue::create(WTFMove(horizontalOffset), WTFMove(verticalOffset), WTFMove(blurRadius), WTFMove(spreadDistance), WTFMove(style), WTFMove(color));
+}
+
</ins><span class="cx"> RefPtr<CSSValue> consumeImage(CSSParserTokenRange& range, CSSParserContext context, ConsumeGeneratedImage generatedImage)
</span><span class="cx"> {
</span><span class="cx"> AtomicString uri = consumeUrlAsStringView(range).toAtomicString();
</span></span></pre></div>
<a id="trunkSourceWebCorecssparserCSSPropertyParserHelpersh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/css/parser/CSSPropertyParserHelpers.h (208699 => 208700)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/css/parser/CSSPropertyParserHelpers.h        2016-11-14 19:42:41 UTC (rev 208699)
+++ trunk/Source/WebCore/css/parser/CSSPropertyParserHelpers.h        2016-11-14 19:57:03 UTC (rev 208700)
</span><span class="lines">@@ -30,9 +30,11 @@
</span><span class="cx"> #pragma once
</span><span class="cx">
</span><span class="cx"> #include "CSSCustomIdentValue.h"
</span><ins>+#include "CSSFunctionValue.h"
</ins><span class="cx"> #include "CSSParserMode.h"
</span><span class="cx"> #include "CSSParserTokenRange.h"
</span><span class="cx"> #include "CSSPrimitiveValue.h"
</span><ins>+#include "CSSShadowValue.h"
</ins><span class="cx"> #include "Length.h" // For ValueRange
</span><span class="cx">
</span><span class="cx"> namespace WebCore {
</span><span class="lines">@@ -88,6 +90,10 @@
</span><span class="cx"> RefPtr<CSSValue> consumeImage(CSSParserTokenRange&, CSSParserContext, ConsumeGeneratedImage = ConsumeGeneratedImage::Allow);
</span><span class="cx"> RefPtr<CSSValue> consumeImageOrNone(CSSParserTokenRange&, CSSParserContext);
</span><span class="cx">
</span><ins>+RefPtr<CSSValue> consumeFilter(CSSParserTokenRange&, const CSSParserContext&);
+RefPtr<CSSFunctionValue> consumeFilterFunction(CSSParserTokenRange&, const CSSParserContext&);
+RefPtr<CSSShadowValue> consumeSingleShadow(CSSParserTokenRange&, CSSParserMode, bool allowInset, bool allowSpread);
+
</ins><span class="cx"> // Template implementations are at the bottom of the file for readability.
</span><span class="cx">
</span><span class="cx"> template<typename... emptyBaseCase> inline bool identMatches(CSSValueID) { return false; }
</span></span></pre>
</div>
</div>
</body>
</html>