Parse paint() and store paint callbacks for CSS Painting API
authorcommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 18 Oct 2018 02:47:00 +0000 (02:47 +0000)
committercommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 18 Oct 2018 02:47:00 +0000 (02:47 +0000)
https://bugs.webkit.org/show_bug.cgi?id=190657

Patch by Justin Michaud <justin_michaud@apple.com> on 2018-10-17
Reviewed by Dean Jackson.

Source/WebCore:

Implement support for parsing paint() images in css, and store CSS paint callback objects in the paint definition map.

* Sources.txt:
* WebCore.xcodeproj/project.pbxproj:
* bindings/js/JSCSSPaintWorkletGlobalScopeCustom.cpp:
(WebCore::JSCSSPaintWorkletGlobalScope::visitAdditionalChildren):
(WebCore::JSCSSPaintWorkletGlobalScope::registerPaint):
* css/CSSImageGeneratorValue.cpp:
(WebCore::CSSImageGeneratorValue::image):
(WebCore::CSSImageGeneratorValue::isFixedSize const):
(WebCore::CSSImageGeneratorValue::fixedSize):
(WebCore::CSSImageGeneratorValue::isPending const):
(WebCore::CSSImageGeneratorValue::knownToBeOpaque const):
(WebCore::CSSImageGeneratorValue::loadSubimages):
* css/CSSPaintImageValue.cpp: Added.
(WebCore::CSSPaintImageValue::customCSSText const):
* css/CSSPaintImageValue.h: Added.
* css/CSSPaintWorkletGlobalScope.h:
* css/CSSPaintWorkletGlobalScope.idl:
* css/CSSValue.cpp:
(WebCore::CSSValue::equals const):
(WebCore::CSSValue::cssText const):
(WebCore::CSSValue::destroy):
* css/CSSValue.h:
(WebCore::CSSValue::isPaintImageValue const):
* css/CSSValueKeywords.in:
* css/parser/CSSPropertyParserHelpers.cpp:
(WebCore::CSSPropertyParserHelpers::consumeCustomPaint):
(WebCore::CSSPropertyParserHelpers::consumeGeneratedImage):
(WebCore::CSSPropertyParserHelpers::isGeneratedImage):
* platform/mediastream/mac/RealtimeVideoUtilities.h:

LayoutTests:

* fast/css-custom-paint/basic-expected.txt:
* fast/css-custom-paint/basic.html:

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

17 files changed:
LayoutTests/ChangeLog
LayoutTests/fast/css-custom-paint/basic-expected.txt
LayoutTests/fast/css-custom-paint/basic.html
Source/WebCore/ChangeLog
Source/WebCore/Sources.txt
Source/WebCore/WebCore.xcodeproj/project.pbxproj
Source/WebCore/bindings/js/JSCSSPaintWorkletGlobalScopeCustom.cpp
Source/WebCore/css/CSSImageGeneratorValue.cpp
Source/WebCore/css/CSSPaintImageValue.cpp [new file with mode: 0644]
Source/WebCore/css/CSSPaintImageValue.h [new file with mode: 0644]
Source/WebCore/css/CSSPaintWorkletGlobalScope.h
Source/WebCore/css/CSSPaintWorkletGlobalScope.idl
Source/WebCore/css/CSSValue.cpp
Source/WebCore/css/CSSValue.h
Source/WebCore/css/CSSValueKeywords.in
Source/WebCore/css/parser/CSSPropertyParserHelpers.cpp
Source/WebCore/platform/mediastream/mac/RealtimeVideoUtilities.h

index 4b9c328..5e5e37b 100644 (file)
@@ -1,3 +1,13 @@
+2018-10-17  Justin Michaud  <justin_michaud@apple.com>
+
+        Parse paint() and store paint callbacks for CSS Painting API
+        https://bugs.webkit.org/show_bug.cgi?id=190657
+
+        Reviewed by Dean Jackson.
+
+        * fast/css-custom-paint/basic-expected.txt:
+        * fast/css-custom-paint/basic.html:
+
 2018-10-17  Justin Fan  <justin_fan@apple.com>
 
         [WebGPU] Implement WebGPU bindings up through WebGPUDevice creation
index e712dcc..cd7f2ee 100644 (file)
@@ -5,4 +5,5 @@ PASS test that registerPaint runs with inputArguments
 PASS test that registerPaint runs with contextOptions 
 PASS test that registerPaint runs with predefined class 
 PASS test that registerPaint accepts only a string and a class constructor 
+PASS test that test div has paint() value 
 
index 52c0e5b..3699aa2 100644 (file)
@@ -4,6 +4,17 @@
 <link rel="help" content="https://drafts.css-houdini.org/css-paint-api-1/">
 <script src="../../resources/testharness.js"></script>
 <script src="../../resources/testharnessreport.js"></script>
+
+<style>
+  #paint {
+    background-image: paint(my-paint);
+    width: 50px;
+    height: 50px;
+  }
+</style>
+
+<div id="paint"></div>
+
 <script>
 test(function() {
   CSS.paintWorkletGlobalScope.registerPaint('test1', class {
@@ -51,4 +62,8 @@ test(function() {
   assert_throws(new TypeError(), () => CSS.paintWorkletGlobalScope.registerPaint('', 5));
 }, 'test that registerPaint accepts only a string and a class constructor');
 
+test(function() {
+  assert_equals(getComputedStyle(paint).getPropertyValue("background-image"), "paint(my-paint)");
+}, 'test that test div has paint() value');
+
 </script>
index 759a10b..91dc4b7 100644 (file)
@@ -1,3 +1,42 @@
+2018-10-17  Justin Michaud  <justin_michaud@apple.com>
+
+        Parse paint() and store paint callbacks for CSS Painting API
+        https://bugs.webkit.org/show_bug.cgi?id=190657
+
+        Reviewed by Dean Jackson.
+
+        Implement support for parsing paint() images in css, and store CSS paint callback objects in the paint definition map.
+
+        * Sources.txt:
+        * WebCore.xcodeproj/project.pbxproj:
+        * bindings/js/JSCSSPaintWorkletGlobalScopeCustom.cpp:
+        (WebCore::JSCSSPaintWorkletGlobalScope::visitAdditionalChildren):
+        (WebCore::JSCSSPaintWorkletGlobalScope::registerPaint):
+        * css/CSSImageGeneratorValue.cpp:
+        (WebCore::CSSImageGeneratorValue::image):
+        (WebCore::CSSImageGeneratorValue::isFixedSize const):
+        (WebCore::CSSImageGeneratorValue::fixedSize):
+        (WebCore::CSSImageGeneratorValue::isPending const):
+        (WebCore::CSSImageGeneratorValue::knownToBeOpaque const):
+        (WebCore::CSSImageGeneratorValue::loadSubimages):
+        * css/CSSPaintImageValue.cpp: Added.
+        (WebCore::CSSPaintImageValue::customCSSText const):
+        * css/CSSPaintImageValue.h: Added.
+        * css/CSSPaintWorkletGlobalScope.h:
+        * css/CSSPaintWorkletGlobalScope.idl:
+        * css/CSSValue.cpp:
+        (WebCore::CSSValue::equals const):
+        (WebCore::CSSValue::cssText const):
+        (WebCore::CSSValue::destroy):
+        * css/CSSValue.h:
+        (WebCore::CSSValue::isPaintImageValue const):
+        * css/CSSValueKeywords.in:
+        * css/parser/CSSPropertyParserHelpers.cpp:
+        (WebCore::CSSPropertyParserHelpers::consumeCustomPaint):
+        (WebCore::CSSPropertyParserHelpers::consumeGeneratedImage):
+        (WebCore::CSSPropertyParserHelpers::isGeneratedImage):
+        * platform/mediastream/mac/RealtimeVideoUtilities.h:
+
 2018-10-17  Eric Carlson  <eric.carlson@apple.com>
 
         [MediaStream] Consolidate all image conversion and resizing into one class
index 212fc59..d193d9e 100644 (file)
@@ -609,6 +609,7 @@ css/CSSMediaRule.cpp
 css/CSSNamedImageValue.cpp
 css/CSSNamespaceRule.cpp
 css/CSSPageRule.cpp
+css/CSSPaintImageValue.cpp
 css/CSSPaintWorkletGlobalScope.cpp
 css/CSSPendingSubstitutionValue.cpp
 css/CSSPrimitiveValue.cpp
index f713e96..68f71d4 100644 (file)
                4B5BDD9B21658A1500DD4262 /* CSSPaintCallback.h in Headers */ = {isa = PBXBuildFile; fileRef = 4B5BDD9A21658A1500DD4262 /* CSSPaintCallback.h */; };
                4B6B5CBD21640EFF00603817 /* DOMCSSPaintWorklet.h in Headers */ = {isa = PBXBuildFile; fileRef = 4B6B5CB82163EC0700603817 /* DOMCSSPaintWorklet.h */; settings = {ATTRIBUTES = (Private, ); }; };
                4B6B5CC02164386400603817 /* CSSPaintWorkletGlobalScope.h in Headers */ = {isa = PBXBuildFile; fileRef = 4B6B5CBF2164386400603817 /* CSSPaintWorkletGlobalScope.h */; };
+               4B6E87692176D69200420E5E /* CSSPaintImageValue.h in Headers */ = {isa = PBXBuildFile; fileRef = 4B6E87682176D69200420E5E /* CSSPaintImageValue.h */; };
                4B6FA6F40C39E48C00087011 /* SmartReplace.h in Headers */ = {isa = PBXBuildFile; fileRef = 4B6FA6F20C39E48C00087011 /* SmartReplace.h */; settings = {ATTRIBUTES = (Private, ); }; };
                4BAE95B10B2FA9CE00AED8A0 /* EditorDeleteAction.h in Headers */ = {isa = PBXBuildFile; fileRef = 4BAE95B00B2FA9CE00AED8A0 /* EditorDeleteAction.h */; settings = {ATTRIBUTES = (Private, ); }; };
                4BDA3FFE2151B6F500FD6604 /* DOMCSSCustomPropertyDescriptor.h in Headers */ = {isa = PBXBuildFile; fileRef = 4BDA3FF82151B6F200FD6604 /* DOMCSSCustomPropertyDescriptor.h */; };
                4B6B5CBF2164386400603817 /* CSSPaintWorkletGlobalScope.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = CSSPaintWorkletGlobalScope.h; sourceTree = "<group>"; };
                4B6B5CC1216439CF00603817 /* CSSPaintWorkletGlobalScope.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = CSSPaintWorkletGlobalScope.cpp; sourceTree = "<group>"; };
                4B6B5CC321643A8E00603817 /* CSSPaintWorkletGlobalScope.idl */ = {isa = PBXFileReference; lastKnownFileType = text; path = CSSPaintWorkletGlobalScope.idl; sourceTree = "<group>"; };
+               4B6E87682176D69200420E5E /* CSSPaintImageValue.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = CSSPaintImageValue.h; sourceTree = "<group>"; };
+               4B6E876B2176D8A100420E5E /* CSSPaintImageValue.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = CSSPaintImageValue.cpp; sourceTree = "<group>"; };
                4B6FA6F20C39E48C00087011 /* SmartReplace.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SmartReplace.h; sourceTree = "<group>"; };
                4B6FA6F60C39E4A100087011 /* SmartReplaceCF.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = SmartReplaceCF.cpp; sourceTree = "<group>"; };
                4BAE95B00B2FA9CE00AED8A0 /* EditorDeleteAction.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = EditorDeleteAction.h; sourceTree = "<group>"; };
                                85C56CA60AA89D5F00D95755 /* CSSPageRule.idl */,
                                4B5BDD9A21658A1500DD4262 /* CSSPaintCallback.h */,
                                4B5BDD99216588E500DD4262 /* CSSPaintCallback.idl */,
+                               4B6E876B2176D8A100420E5E /* CSSPaintImageValue.cpp */,
+                               4B6E87682176D69200420E5E /* CSSPaintImageValue.h */,
                                4B6B5CC1216439CF00603817 /* CSSPaintWorkletGlobalScope.cpp */,
                                4B6B5CBF2164386400603817 /* CSSPaintWorkletGlobalScope.h */,
                                4B6B5CC321643A8E00603817 /* CSSPaintWorkletGlobalScope.idl */,
                                94E839511DFB2A0E007BC6A7 /* CSSNamespaceRule.h in Headers */,
                                A80E6D000A1989CA007FB8C5 /* CSSPageRule.h in Headers */,
                                4B5BDD9B21658A1500DD4262 /* CSSPaintCallback.h in Headers */,
+                               4B6E87692176D69200420E5E /* CSSPaintImageValue.h in Headers */,
                                4B6B5CC02164386400603817 /* CSSPaintWorkletGlobalScope.h in Headers */,
                                946D372E1D6CB2940077084F /* CSSParser.h in Headers */,
                                E4A7995220EE4B1400C19568 /* CSSParserContext.h in Headers */,
index 057ac3f..b9fa345 100644 (file)
@@ -44,6 +44,12 @@ static JSValue throwInvalidModificationError(ExecState& state, ThrowScope& scope
     return jsUndefined();
 }
 
+void JSCSSPaintWorkletGlobalScope::visitAdditionalChildren(JSC::SlotVisitor& visitor)
+{
+    for (auto& registered : wrapped().paintDefinitionMap().values())
+        registered->paintCallback->visitJSFunction(visitor);
+}
+
 // https://drafts.css-houdini.org/css-paint-api/#registering-custom-paint
 JSValue JSCSSPaintWorkletGlobalScope::registerPaint(ExecState& state)
 {
@@ -115,18 +121,11 @@ JSValue JSCSSPaintWorkletGlobalScope::registerPaint(ExecState& state)
     RefPtr<JSCSSPaintCallback> paint = convert<IDLCallbackFunction<JSCSSPaintCallback>>(state, paintValue, *globalObject());
     RETURN_IF_EXCEPTION(scope, JSValue());
 
-    auto paintDefinition = std::unique_ptr<PaintDefinition>(new PaintDefinition { name });
+    auto paintDefinition = std::unique_ptr<PaintDefinition>(new PaintDefinition { name, paint.releaseNonNull(), inputProperties, inputArguments });
     paintDefinitionMap.add(name, WTFMove(paintDefinition));
 
     // FIXME: construct documentDefinition (step 22).
 
-    // FIXME: This is for testing only.
-    paint->handleEvent();
-    RETURN_IF_EXCEPTION(scope, JSValue());
-
-    UNUSED_PARAM(inputProperties);
-    UNUSED_PARAM(inputArguments);
-
     return jsUndefined();
 }
 
index 7a8e19f..b600033 100644 (file)
@@ -150,6 +150,10 @@ RefPtr<Image> CSSImageGeneratorValue::image(RenderElement& renderer, const Float
         return downcast<CSSRadialGradientValue>(*this).image(renderer, size);
     case ConicGradientClass:
         return downcast<CSSConicGradientValue>(*this).image(renderer, size);
+#if ENABLE(CSS_PAINTING_API)
+    case PaintImageClass:
+        return nullptr;
+#endif
     default:
         ASSERT_NOT_REACHED();
     }
@@ -173,6 +177,10 @@ bool CSSImageGeneratorValue::isFixedSize() const
         return downcast<CSSRadialGradientValue>(*this).isFixedSize();
     case ConicGradientClass:
         return downcast<CSSConicGradientValue>(*this).isFixedSize();
+#if ENABLE(CSS_PAINTING_API)
+    case PaintImageClass:
+        return false;
+#endif
     default:
         ASSERT_NOT_REACHED();
     }
@@ -194,6 +202,10 @@ FloatSize CSSImageGeneratorValue::fixedSize(const RenderElement& renderer)
         return downcast<CSSRadialGradientValue>(*this).fixedSize(renderer);
     case ConicGradientClass:
         return downcast<CSSConicGradientValue>(*this).fixedSize(renderer);
+#if ENABLE(CSS_PAINTING_API)
+    case PaintImageClass:
+        return FloatSize();
+#endif
     default:
         ASSERT_NOT_REACHED();
     }
@@ -217,6 +229,10 @@ bool CSSImageGeneratorValue::isPending() const
         return downcast<CSSRadialGradientValue>(*this).isPending();
     case ConicGradientClass:
         return downcast<CSSConicGradientValue>(*this).isPending();
+#if ENABLE(CSS_PAINTING_API)
+    case PaintImageClass:
+        return false;
+#endif
     default:
         ASSERT_NOT_REACHED();
     }
@@ -240,6 +256,10 @@ bool CSSImageGeneratorValue::knownToBeOpaque(const RenderElement& renderer) cons
         return downcast<CSSRadialGradientValue>(*this).knownToBeOpaque(renderer);
     case ConicGradientClass:
         return downcast<CSSConicGradientValue>(*this).knownToBeOpaque(renderer);
+#if ENABLE(CSS_PAINTING_API)
+    case PaintImageClass:
+        return false;
+#endif
     default:
         ASSERT_NOT_REACHED();
     }
@@ -267,6 +287,10 @@ void CSSImageGeneratorValue::loadSubimages(CachedResourceLoader& cachedResourceL
     case ConicGradientClass:
         downcast<CSSConicGradientValue>(*this).loadSubimages(cachedResourceLoader, options);
         break;
+#if ENABLE(CSS_PAINTING_API)
+    case PaintImageClass:
+        break;
+#endif
     default:
         ASSERT_NOT_REACHED();
     }
diff --git a/Source/WebCore/css/CSSPaintImageValue.cpp b/Source/WebCore/css/CSSPaintImageValue.cpp
new file mode 100644 (file)
index 0000000..c421a1d
--- /dev/null
@@ -0,0 +1,48 @@
+/*
+ * Copyright (C) 2018 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER "AS IS" AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
+ * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
+ * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
+ * THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include "config.h"
+#include "CSSPaintImageValue.h"
+
+#if ENABLE(CSS_PAINTING_API)
+
+#include <wtf/text/StringBuilder.h>
+
+namespace WebCore {
+
+String CSSPaintImageValue::customCSSText() const
+{
+    StringBuilder result;
+    result.appendLiteral("paint(");
+    result.append(m_name);
+    // FIXME: print args.
+    result.append(')');
+    return result.toString();
+}
+
+} // namespace WebCore
+
+#endif
diff --git a/Source/WebCore/css/CSSPaintImageValue.h b/Source/WebCore/css/CSSPaintImageValue.h
new file mode 100644 (file)
index 0000000..b6ca845
--- /dev/null
@@ -0,0 +1,60 @@
+/*
+ * Copyright (C) 2018 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER "AS IS" AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
+ * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
+ * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
+ * THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#pragma once
+
+#if ENABLE(CSS_PAINTING_API)
+
+#include "CSSImageGeneratorValue.h"
+
+namespace WebCore {
+
+class CSSPaintImageValue final : public CSSImageGeneratorValue {
+public:
+    static Ref<CSSPaintImageValue> create(const String& name)
+    {
+        return adoptRef(*new CSSPaintImageValue(name));
+    }
+
+    bool equals(const CSSPaintImageValue& other) const { return m_name == other.m_name; }
+
+    String customCSSText() const;
+
+private:
+    CSSPaintImageValue(const String& name)
+        : CSSImageGeneratorValue(PaintImageClass)
+        , m_name(name)
+    {
+    }
+
+    const String m_name;
+};
+
+} // namespace WebCore
+
+SPECIALIZE_TYPE_TRAITS_CSS_VALUE(CSSPaintImageValue, isPaintImageValue())
+
+#endif
index 90092d9..23b0d9d 100644 (file)
@@ -27,6 +27,7 @@
 
 #if ENABLE(CSS_PAINTING_API)
 
+#include "CSSPaintCallback.h"
 #include "ExceptionOr.h"
 #include <wtf/HashMap.h>
 #include <wtf/RefCounted.h>
@@ -49,6 +50,9 @@ public:
 
     struct PaintDefinition {
         const AtomicString name;
+        const Ref<CSSPaintCallback> paintCallback;
+        const Vector<String> inputProperties;
+        const Vector<String> inputArguments;
     };
 
     HashMap<String, std::unique_ptr<PaintDefinition>>& paintDefinitionMap() { return m_paintDefinitionMap; }
index 411eb74..a536c0a 100644 (file)
@@ -27,6 +27,7 @@
     EnabledAtRuntime=CSSPaintingAPI,
     Conditional=CSS_PAINTING_API,
     ImplementationLacksVTable,
+    JSCustomMarkFunction,
     JSGenerateToNativeObject
 ] interface CSSPaintWorkletGlobalScope {
     [Custom, MayThrowException] void registerPaint(DOMString name, Function paintCtor);
index 8498b2b..cc3f59f 100644 (file)
@@ -52,6 +52,7 @@
 #include "CSSInitialValue.h"
 #include "CSSLineBoxContainValue.h"
 #include "CSSNamedImageValue.h"
+#include "CSSPaintImageValue.h"
 #include "CSSPendingSubstitutionValue.h"
 #include "CSSPrimitiveValue.h"
 #include "CSSProperty.h"
@@ -151,6 +152,10 @@ bool CSSValue::equals(const CSSValue& other) const
             return compareCSSValues<CSSCursorImageValue>(*this, other);
         case FilterImageClass:
             return compareCSSValues<CSSFilterImageValue>(*this, other);
+#if ENABLE(CSS_PAINTING_API)
+        case PaintImageClass:
+            return compareCSSValues<CSSPaintImageValue>(*this, other);
+#endif
         case FontClass:
             return compareCSSValues<CSSFontValue>(*this, other);
         case FontFaceSrcClass:
@@ -247,6 +252,10 @@ String CSSValue::cssText() const
         return downcast<CSSCursorImageValue>(*this).customCSSText();
     case FilterImageClass:
         return downcast<CSSFilterImageValue>(*this).customCSSText();
+#if ENABLE(CSS_PAINTING_API)
+    case PaintImageClass:
+        return downcast<CSSPaintImageValue>(*this).customCSSText();
+#endif
     case FontClass:
         return downcast<CSSFontValue>(*this).customCSSText();
     case FontFaceSrcClass:
@@ -432,6 +441,11 @@ void CSSValue::destroy()
     case FilterImageClass:
         delete downcast<CSSFilterImageValue>(this);
         return;
+#if ENABLE(CSS_PAINTING_API)
+    case PaintImageClass:
+        delete downcast<CSSPaintImageValue>(this);
+        return;
+#endif
     case CSSContentDistributionClass:
         delete downcast<CSSContentDistributionValue>(this);
         return;
index c16a528..ef50e2d 100644 (file)
@@ -106,6 +106,9 @@ public:
     bool isLineBoxContainValue() const { return m_classType == LineBoxContainClass; }
     bool isCalcValue() const {return m_classType == CalculationClass; }
     bool isFilterImageValue() const { return m_classType == FilterImageClass; }
+#if ENABLE(CSS_PAINTING_API)
+    bool isPaintImageValue() const { return m_classType == PaintImageClass; }
+#endif
     bool isContentDistributionValue() const { return m_classType == CSSContentDistributionClass; }
     bool isGridAutoRepeatValue() const { return m_classType == GridAutoRepeatClass; }
     bool isGridTemplateAreasValue() const { return m_classType == GridTemplateAreasClass; }
@@ -142,6 +145,9 @@ protected:
 
         // Image generator classes.
         CanvasClass,
+#if ENABLE(CSS_PAINTING_API)
+        PaintImageClass,
+#endif
         NamedImageClass,
         CrossfadeClass,
         FilterImageClass,
index d133b6d..f148058 100644 (file)
@@ -1201,6 +1201,9 @@ repeating-conic-gradient
 filter
 -webkit-filter
 dashboard-region
+#if defined(ENABLE_CSS_PAINTING_API) && ENABLE_CSS_PAINTING_API
+paint
+#endif
 
 // deprecated gradients
 from
index 29d52b8..22acd61 100644 (file)
@@ -38,6 +38,7 @@
 #include "CSSImageSetValue.h"
 #include "CSSImageValue.h"
 #include "CSSNamedImageValue.h"
+#include "CSSPaintImageValue.h"
 #include "CSSParserIdioms.h"
 #include "CSSValuePool.h"
 #include "Pair.h"
@@ -1281,6 +1282,23 @@ static RefPtr<CSSValue> consumeFilterImage(CSSParserTokenRange& args, const CSSP
     return CSSFilterImageValue::create(imageValue.releaseNonNull(), filterValue.releaseNonNull());
 }
 
+#if ENABLE(CSS_PAINTING_API)
+static RefPtr<CSSValue> consumeCustomPaint(CSSParserTokenRange& args)
+{
+    if (!RuntimeEnabledFeatures::sharedFeatures().cssPaintingAPIEnabled())
+        return nullptr;
+    if (args.peek().type() != IdentToken)
+        return nullptr;
+    auto name = args.consumeIncludingWhitespace().value().toString();
+
+    // FIXME: should parse arguments.
+    while (!args.atEnd())
+        args.consume();
+
+    return CSSPaintImageValue::create(name);
+}
+#endif
+
 static RefPtr<CSSValue> consumeGeneratedImage(CSSParserTokenRange& range, CSSParserContext context)
 {
     CSSValueID id = range.peek().functionId();
@@ -1317,6 +1335,10 @@ static RefPtr<CSSValue> consumeGeneratedImage(CSSParserTokenRange& range, CSSPar
         result = consumeWebkitNamedImage(args);
     else if (id == CSSValueWebkitFilter || id == CSSValueFilter)
         result = consumeFilterImage(args, context);
+#if ENABLE(CSS_PAINTING_API)
+    else if (id == CSSValuePaint)
+        result = consumeCustomPaint(args);
+#endif
     if (!result || !args.atEnd())
         return nullptr;
     range = rangeCopy;
@@ -1371,6 +1393,9 @@ static bool isGeneratedImage(CSSValueID id)
         || id == CSSValueCrossFade
         || id == CSSValueWebkitNamedImage
         || id == CSSValueWebkitFilter
+#if ENABLE(CSS_PAINTING_API)
+        || id == CSSValuePaint
+#endif
         || id == CSSValueFilter;
 }
     
index b702674..380d373 100644 (file)
@@ -23,6 +23,8 @@
  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
+#pragma once
+
 #include <CoreVideo/CoreVideo.h>
 
 namespace WebCore {