[CSS Parser] Add support for -webkit-canvas images
authorhyatt@apple.com <hyatt@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 28 Oct 2016 20:41:38 +0000 (20:41 +0000)
committerhyatt@apple.com <hyatt@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 28 Oct 2016 20:41:38 +0000 (20:41 +0000)
https://bugs.webkit.org/show_bug.cgi?id=164144

Reviewed by Simon Fraser.

* css/CSSValueKeywords.in:
* css/parser/CSSParser.cpp:
(WebCore::CSSParserContext::CSSParserContext):
* css/parser/CSSPropertyParserHelpers.cpp:
(WebCore::CSSPropertyParserHelpers::consumeWebkitCanvas):
(WebCore::CSSPropertyParserHelpers::consumeGeneratedImage):
(WebCore::CSSPropertyParserHelpers::isGeneratedImage):

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

Source/WebCore/ChangeLog
Source/WebCore/css/CSSValueKeywords.in
Source/WebCore/css/parser/CSSPropertyParserHelpers.cpp

index 6b8b699..4136ec3 100644 (file)
@@ -1,3 +1,18 @@
+2016-10-28  Dave Hyatt  <hyatt@apple.com>
+
+        [CSS Parser] Add support for -webkit-canvas images
+        https://bugs.webkit.org/show_bug.cgi?id=164144
+
+        Reviewed by Simon Fraser.
+
+        * css/CSSValueKeywords.in:
+        * css/parser/CSSParser.cpp:
+        (WebCore::CSSParserContext::CSSParserContext):
+        * css/parser/CSSPropertyParserHelpers.cpp:
+        (WebCore::CSSPropertyParserHelpers::consumeWebkitCanvas):
+        (WebCore::CSSPropertyParserHelpers::consumeGeneratedImage):
+        (WebCore::CSSPropertyParserHelpers::isGeneratedImage):
+
 2016-10-27  Geoffrey Garen  <ggaren@apple.com>
 
         One file per class for Executable.h/.cpp
index 5b3da1a..0591ab3 100644 (file)
@@ -1155,6 +1155,7 @@ radial-gradient
 repeating-linear-gradient
 repeating-radial-gradient
 paint
+-webkit-canvas
 -webkit-cross-fade
 -webkit-gradient
 -webkit-linear-gradient
index cb79435..a59f0b1 100644 (file)
@@ -31,6 +31,7 @@
 #include "CSSPropertyParserHelpers.h"
 
 #include "CSSCalculationValue.h"
+#include "CSSCanvasValue.h"
 #include "CSSCrossfadeValue.h"
 #include "CSSGradientValue.h"
 #include "CSSImageSetValue.h"
@@ -1020,6 +1021,16 @@ static RefPtr<CSSValue> consumeCrossFade(CSSParserTokenRange& args, CSSParserCon
     return CSSCrossfadeValue::create(fromImageValue.releaseNonNull(), toImageValue.releaseNonNull(), percentage.releaseNonNull());
 }
 
+static RefPtr<CSSValue> consumeWebkitCanvas(CSSParserTokenRange& args)
+{
+    if (args.peek().type() != IdentToken)
+        return nullptr;
+    auto canvasName = args.consumeIncludingWhitespace().value().toString();
+    if (!args.atEnd())
+        return nullptr;
+    return CSSCanvasValue::create(canvasName);
+}
+    
 static RefPtr<CSSValue> consumeGeneratedImage(CSSParserTokenRange& range, CSSParserContext context)
 {
     CSSValueID id = range.peek().functionId();
@@ -1046,6 +1057,8 @@ static RefPtr<CSSValue> consumeGeneratedImage(CSSParserTokenRange& range, CSSPar
         result = consumeDeprecatedRadialGradient(args, context.mode, Repeating);
     else if (id == CSSValueWebkitCrossFade)
         result = consumeCrossFade(args, context);
+    else if (id == CSSValueWebkitCanvas)
+        result = consumeWebkitCanvas(args);
 
     if (!result || !args.atEnd())
         return nullptr;
@@ -1089,7 +1102,8 @@ static bool isGeneratedImage(CSSValueID id)
         || id == CSSValueRepeatingLinearGradient || id == CSSValueRepeatingRadialGradient
         || id == CSSValueWebkitLinearGradient || id == CSSValueWebkitRadialGradient
         || id == CSSValueWebkitRepeatingLinearGradient || id == CSSValueWebkitRepeatingRadialGradient
-        || id == CSSValueWebkitGradient || id == CSSValueWebkitCrossFade || id == CSSValuePaint;
+        || id == CSSValueWebkitGradient || id == CSSValueWebkitCrossFade || id == CSSValueWebkitCanvas
+        || id == CSSValuePaint;
 }
 
 RefPtr<CSSValue> consumeImage(CSSParserTokenRange& range, CSSParserContext context, ConsumeGeneratedImage generatedImage)