CSS Painting API should pass size, arguments and input properties to paint callback
authorjustin_michaud@apple.com <justin_michaud@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 8 Nov 2018 05:29:59 +0000 (05:29 +0000)
committerjustin_michaud@apple.com <justin_michaud@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 8 Nov 2018 05:29:59 +0000 (05:29 +0000)
https://bugs.webkit.org/show_bug.cgi?id=191309

Reviewed by Chris Dumez.

Source/WebCore:

Call paint() callback with input properties and arguments. This patch adds a stub for
the CSS Typed OM StylePropertyMapReadOnly, and passes all the arguments as strings without
any syntax checking to the paint callback.

Test: fast/css-custom-paint/properties.html

* CMakeLists.txt:
* DerivedSources.make:
* Sources.txt:
* WebCore.xcodeproj/project.pbxproj:
* bindings/js/JSCSSStyleValueCustom.cpp: Copied from Source/WebCore/css/CSSPaintCallback.h.
(WebCore::toJSNewlyCreated):
(WebCore::toJS):
* bindings/js/WebCoreBuiltinNames.h:
* css/CSSPaintCallback.h:
* css/CSSPaintCallback.idl:
* css/CSSPaintImageValue.cpp:
(WebCore::CSSPaintImageValue::image):
* css/CSSPaintImageValue.h:
* css/CSSPaintSize.h: Copied from Source/WebCore/css/CSSPaintCallback.h.
(WebCore::CSSPaintSize::create):
(WebCore::CSSPaintSize::width const):
(WebCore::CSSPaintSize::height const):
(WebCore::CSSPaintSize::CSSPaintSize):
* css/CSSPaintSize.idl: Copied from Source/WebCore/css/CSSPaintCallback.idl.
* css/parser/CSSPropertyParserHelpers.cpp:
(WebCore::CSSPropertyParserHelpers::consumeCustomPaint):
* css/typedom/CSSNumericValue.h: Copied from Source/WebCore/css/CSSPaintCallback.h.
* css/typedom/CSSNumericValue.idl: Copied from Source/WebCore/css/CSSPaintCallback.idl.
* css/typedom/CSSStyleValue.h: Copied from Source/WebCore/css/CSSPaintCallback.h.
(WebCore::CSSStyleValue::isUnitValue):
(WebCore::CSSStyleValue::isUnparsedValue):
* css/typedom/CSSStyleValue.idl: Copied from Source/WebCore/css/CSSPaintCallback.idl.
* css/typedom/CSSUnitValue.h: Copied from Source/WebCore/css/CSSPaintCallback.h.
* css/typedom/CSSUnitValue.idl: Copied from Source/WebCore/css/CSSPaintCallback.idl.
* css/typedom/CSSUnparsedValue.h: Copied from Source/WebCore/css/CSSPaintCallback.h.
* css/typedom/CSSUnparsedValue.idl: Copied from Source/WebCore/css/CSSPaintCallback.idl.
* css/typedom/StylePropertyMapReadOnly.h: Copied from Source/WebCore/css/CSSPaintCallback.h.
(WebCore::StylePropertyMapReadOnly::create):
(WebCore::StylePropertyMapReadOnly::get):
(WebCore::StylePropertyMapReadOnly::StylePropertyMapReadOnly):
* css/typedom/StylePropertyMapReadOnly.idl: Copied from Source/WebCore/css/CSSPaintCallback.idl.
* platform/graphics/CustomPaintImage.cpp:
(WebCore::CustomPaintImage::CustomPaintImage):
(WebCore::CustomPaintImage::doCustomPaint):
* platform/graphics/CustomPaintImage.h:

LayoutTests:

* fast/css-custom-paint/properties-expected.html: Added.
* fast/css-custom-paint/properties.html: Added.
* fast/css-custom-paint/worklet.html:

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

32 files changed:
LayoutTests/ChangeLog
LayoutTests/fast/css-custom-paint/properties-expected.html [new file with mode: 0644]
LayoutTests/fast/css-custom-paint/properties.html [new file with mode: 0644]
LayoutTests/fast/css-custom-paint/worklet.html
LayoutTests/imported/w3c/web-platform-tests/css/css-properties-values-api/typedom.tentative-expected.txt
Source/WebCore/CMakeLists.txt
Source/WebCore/ChangeLog
Source/WebCore/DerivedSources.make
Source/WebCore/Sources.txt
Source/WebCore/WebCore.xcodeproj/project.pbxproj
Source/WebCore/bindings/js/JSCSSStyleValueCustom.cpp [new file with mode: 0644]
Source/WebCore/bindings/js/WebCoreBuiltinNames.h
Source/WebCore/bindings/js/WorkerScriptController.cpp
Source/WebCore/css/CSSPaintCallback.h
Source/WebCore/css/CSSPaintCallback.idl
Source/WebCore/css/CSSPaintImageValue.cpp
Source/WebCore/css/CSSPaintImageValue.h
Source/WebCore/css/CSSPaintSize.h [new file with mode: 0644]
Source/WebCore/css/CSSPaintSize.idl [new file with mode: 0644]
Source/WebCore/css/parser/CSSPropertyParserHelpers.cpp
Source/WebCore/css/typedom/CSSNumericValue.h [new file with mode: 0644]
Source/WebCore/css/typedom/CSSNumericValue.idl [new file with mode: 0644]
Source/WebCore/css/typedom/CSSStyleValue.h [new file with mode: 0644]
Source/WebCore/css/typedom/CSSStyleValue.idl [new file with mode: 0644]
Source/WebCore/css/typedom/CSSUnitValue.h [new file with mode: 0644]
Source/WebCore/css/typedom/CSSUnitValue.idl [new file with mode: 0644]
Source/WebCore/css/typedom/CSSUnparsedValue.h [new file with mode: 0644]
Source/WebCore/css/typedom/CSSUnparsedValue.idl [new file with mode: 0644]
Source/WebCore/css/typedom/StylePropertyMapReadOnly.h [new file with mode: 0644]
Source/WebCore/css/typedom/StylePropertyMapReadOnly.idl [new file with mode: 0644]
Source/WebCore/platform/graphics/CustomPaintImage.cpp
Source/WebCore/platform/graphics/CustomPaintImage.h

index 0fd8f51..2fda4b1 100644 (file)
@@ -1,3 +1,14 @@
+2018-11-07  Justin Michaud  <justin_michaud@apple.com>
+
+        CSS Painting API should pass size, arguments and input properties to paint callback
+        https://bugs.webkit.org/show_bug.cgi?id=191309
+
+        Reviewed by Chris Dumez.
+
+        * fast/css-custom-paint/properties-expected.html: Added.
+        * fast/css-custom-paint/properties.html: Added.
+        * fast/css-custom-paint/worklet.html:
+
 2018-11-07  Zalan Bujtas  <zalan@apple.com>
 
         Click and touch event listeners on the body don't work
diff --git a/LayoutTests/fast/css-custom-paint/properties-expected.html b/LayoutTests/fast/css-custom-paint/properties-expected.html
new file mode 100644 (file)
index 0000000..3697e9b
--- /dev/null
@@ -0,0 +1,25 @@
+<!DOCTYPE html><!-- webkit-test-runner [ experimental:CSSPaintingAPIEnabled=true ] -->
+
+<style>
+canvas {
+  display: block;
+}
+</style>
+
+<canvas id="paint" width="150px" height="150px" ></canvas>
+<canvas id="paint2" width="150px" height="150px" ></canvas>
+
+<script id="code">
+for (canvasID of ['paint', 'paint2']) {
+  var canvas = document.getElementById(canvasID);
+  var ctx = canvas.getContext('2d');
+
+  for (var i = 0; i < 6; i++){
+    for (var j = 0; j < 6; j++){
+      ctx.fillStyle = 'rgb(' + Math.floor(255 - 42.5 * i) + ',' +
+                       Math.floor(255 - 42.5 * j) + ',0)';
+      ctx.fillRect(j * 25, i * 25, 25, 25);
+    }
+  }
+}
+</script>
diff --git a/LayoutTests/fast/css-custom-paint/properties.html b/LayoutTests/fast/css-custom-paint/properties.html
new file mode 100644 (file)
index 0000000..0ae688b
--- /dev/null
@@ -0,0 +1,53 @@
+<!DOCTYPE html><!-- webkit-test-runner [ experimental:CSSPaintingAPIEnabled=true ] -->
+<meta name="author" title="Justin Michaud" href="mailto:justin_michaud@webkit.org">
+<meta name="assert" content="Test paint worklet input properties and arguments">
+<link rel="help" content="https://drafts.css-houdini.org/css-paint-api-1/">
+<script src="resources/testharness.js"></script>
+
+<style>
+  .paint {
+    background-image: paint(my-paint,150px,helloworld1,helloworld2);
+    width: 150px;
+    height: 150px;
+    --my-prop:helloworld1;
+    --my-registered-prop:helloworld2;
+  }
+</style>
+
+<div class="paint"></div>
+<div class="paint"></div>
+
+<script id="code" type="text/worklet">
+class MyPaint {
+  static get inputProperties() { return ['height', '--my-prop', '--my-registered-prop', "--never-specified"]; }
+  static get inputArguments() { return ['*', '*', '*']; }
+  paint(ctx, geom, properties, args) {
+    assert_equals(properties.get('height').toString(), args[0].toString());
+    assert_equals(properties.get('height').value, 150);
+    assert_equals(properties.get('height').unit, 'px');
+    assert_equals(properties.get('--my-prop').toString(), args[1].toString());
+    assert_equals(properties.get('--my-registered-prop').toString(), args[2].toString());
+    assert_equals(properties.get('width'), null);
+    assert_equals(properties.get('--never-specified').toString(), '');
+
+    for (var i = 0; i < 6; i++){
+      for (var j = 0; j < 6; j++){
+        ctx.fillStyle = 'rgb(' + Math.floor(255 - 42.5 * i) + ',' +
+                         Math.floor(255 - 42.5 * j) + ',0)';
+        ctx.fillRect(j * 25, i * 25, 25, 25);
+      }
+    }
+  }
+}
+registerPaint('my-paint', MyPaint);
+</script>
+
+<script>
+importWorklet(CSS.paintWorklet, document.getElementById('code').textContent);
+CSS.registerProperty({
+  name: '--my-registered-prop',
+  syntax: '*',
+  initialValue: 'initialValueProp',
+  inherits: false
+});
+</script>
index 2cff935..eb69952 100644 (file)
 <script id="code" type="text/worklet">
 class MyPaint {
   paint(ctx, geom, properties) {
+    console.log("Hello from paint callback!");
+    assert_greater_than(eval("devicePixelRatio"), 0);
+    assert_throws({'name': 'ReferenceError'}, function () { eval("window"); });
+
+    const promise = new Promise((resolve, reject) => { console.log("In promise"); resolve() });
+    promise.then(() => console.log("Promise was resolved"));
+
     for (var i = 0; i < 6; i++){
       for (var j = 0; j < 6; j++){
         ctx.fillStyle = 'rgb(' + Math.floor(255 - 42.5 * i) + ',' +
@@ -24,12 +31,6 @@ class MyPaint {
         ctx.fillRect(j * 25, i * 25, 25, 25);
       }
     }
-    console.log("Hello from paint callback!");
-    assert_greater_than(eval("devicePixelRatio"), 0);
-    assert_throws({'name': 'ReferenceError'}, function () { eval("window"); });
-
-    const promise = new Promise((resolve, reject) => { console.log("In promise"); resolve() });
-    promise.then(() => console.log("Promise was resolved"));
   }
 }
 console.log("Hello from paint worklet!");
index 66fbbca..1366c0a 100644 (file)
@@ -1,6 +1,6 @@
-CONSOLE MESSAGE: line 340: ReferenceError: Can't find variable: CSSUnparsedValue
+CONSOLE MESSAGE: line 349: TypeError: CSS.px is not a function. (In 'CSS.px(15)', 'CSS.px' is undefined)
 
-Harness Error (FAIL), message = ReferenceError: Can't find variable: CSSUnparsedValue
+Harness Error (FAIL), message = TypeError: CSS.px is not a function. (In 'CSS.px(15)', 'CSS.px' is undefined)
 
 FAIL Computed * is reified as CSSUnparsedValue target.computedStyleMap is not a function. (In 'target.computedStyleMap()', 'target.computedStyleMap' is undefined)
 FAIL Computed <angle> is reified as CSSUnitValue The given initial value does not parse for the given syntax.
@@ -8,12 +8,12 @@ FAIL Computed <color> is reified as CSSStyleValue The given initial value does n
 FAIL Computed <custom-ident> is reified as CSSKeywordValue The given initial value does not parse for the given syntax.
 FAIL Computed <image> [url] is reified as CSSImageValue The given initial value does not parse for the given syntax.
 FAIL Computed <integer> is reified as CSSUnitValue The given initial value does not parse for the given syntax.
-FAIL Computed <length-percentage> [%] is reified as CSSUnitValue Can't find variable: CSSUnitValue
-FAIL Computed <length-percentage> [px] is reified as CSSUnitValue Can't find variable: CSSUnitValue
+FAIL Computed <length-percentage> [%] is reified as CSSUnitValue target.computedStyleMap is not a function. (In 'target.computedStyleMap()', 'target.computedStyleMap' is undefined)
+FAIL Computed <length-percentage> [px] is reified as CSSUnitValue target.computedStyleMap is not a function. (In 'target.computedStyleMap()', 'target.computedStyleMap' is undefined)
 FAIL Computed <length-percentage> [px + %] is reified as CSSMathSum Can't find variable: CSSMathSum
-FAIL Computed <length> is reified as CSSUnitValue Can't find variable: CSSUnitValue
+FAIL Computed <length> is reified as CSSUnitValue target.computedStyleMap is not a function. (In 'target.computedStyleMap()', 'target.computedStyleMap' is undefined)
 FAIL Computed <number> is reified as CSSUnitValue The given initial value does not parse for the given syntax.
-FAIL Computed <percentage> is reified as CSSUnitValue Can't find variable: CSSUnitValue
+FAIL Computed <percentage> is reified as CSSUnitValue target.computedStyleMap is not a function. (In 'target.computedStyleMap()', 'target.computedStyleMap' is undefined)
 FAIL Computed <resolution> is reified as CSSUnitValue The given initial value does not parse for the given syntax.
 FAIL Computed <time> is reified as CSSUnitValue The given initial value does not parse for the given syntax.
 FAIL Computed <url> is reified as CSSStyleValue The given initial value does not parse for the given syntax.
index 9c928c5..246f9ba 100644 (file)
@@ -69,6 +69,7 @@ set(WebCore_INCLUDE_DIRECTORIES
     "${WEBCORE_DIR}/crypto/parameters"
     "${WEBCORE_DIR}/css"
     "${WEBCORE_DIR}/css/parser"
+    "${WEBCORE_DIR}/css/typedom"
     "${WEBCORE_DIR}/cssjit"
     "${WEBCORE_DIR}/dom"
     "${WEBCORE_DIR}/dom/default"
@@ -197,6 +198,8 @@ set(WebCore_IDL_INCLUDES
 
     bindings/js
 
+    css/typedom
+
     html/canvas
     html/shadow
     html/track
@@ -546,6 +549,7 @@ set(WebCore_NON_SVG_IDL_FILES
     css/CSSMediaRule.idl
     css/CSSNamespaceRule.idl
     css/CSSPaintCallback.idl
+    css/CSSPaintSize.idl
     css/CSSPageRule.idl
     css/CSSRule.idl
     css/CSSRuleList.idl
@@ -577,6 +581,13 @@ set(WebCore_NON_SVG_IDL_FILES
     css/StyleMedia.idl
     css/StyleSheet.idl
     css/StyleSheetList.idl
+
+    css/typedom/CSSNumericValue.idl
+    css/typedom/CSSStyleValue.idl
+    css/typedom/CSSUnitValue.idl
+    css/typedom/CSSUnparsedValue.idl
+    css/typedom/StylePropertyMapReadOnly.idl
+
     css/WebKitCSSMatrix.idl
     css/WebKitCSSViewportRule.idl
 
index a47dd0f..f4320ee 100644 (file)
@@ -1,3 +1,57 @@
+2018-11-07  Justin Michaud  <justin_michaud@apple.com>
+
+        CSS Painting API should pass size, arguments and input properties to paint callback
+        https://bugs.webkit.org/show_bug.cgi?id=191309
+
+        Reviewed by Chris Dumez.
+
+        Call paint() callback with input properties and arguments. This patch adds a stub for 
+        the CSS Typed OM StylePropertyMapReadOnly, and passes all the arguments as strings without 
+        any syntax checking to the paint callback.
+
+        Test: fast/css-custom-paint/properties.html
+
+        * CMakeLists.txt:
+        * DerivedSources.make:
+        * Sources.txt:
+        * WebCore.xcodeproj/project.pbxproj:
+        * bindings/js/JSCSSStyleValueCustom.cpp: Copied from Source/WebCore/css/CSSPaintCallback.h.
+        (WebCore::toJSNewlyCreated):
+        (WebCore::toJS):
+        * bindings/js/WebCoreBuiltinNames.h:
+        * css/CSSPaintCallback.h:
+        * css/CSSPaintCallback.idl:
+        * css/CSSPaintImageValue.cpp:
+        (WebCore::CSSPaintImageValue::image):
+        * css/CSSPaintImageValue.h:
+        * css/CSSPaintSize.h: Copied from Source/WebCore/css/CSSPaintCallback.h.
+        (WebCore::CSSPaintSize::create):
+        (WebCore::CSSPaintSize::width const):
+        (WebCore::CSSPaintSize::height const):
+        (WebCore::CSSPaintSize::CSSPaintSize):
+        * css/CSSPaintSize.idl: Copied from Source/WebCore/css/CSSPaintCallback.idl.
+        * css/parser/CSSPropertyParserHelpers.cpp:
+        (WebCore::CSSPropertyParserHelpers::consumeCustomPaint):
+        * css/typedom/CSSNumericValue.h: Copied from Source/WebCore/css/CSSPaintCallback.h.
+        * css/typedom/CSSNumericValue.idl: Copied from Source/WebCore/css/CSSPaintCallback.idl.
+        * css/typedom/CSSStyleValue.h: Copied from Source/WebCore/css/CSSPaintCallback.h.
+        (WebCore::CSSStyleValue::isUnitValue):
+        (WebCore::CSSStyleValue::isUnparsedValue):
+        * css/typedom/CSSStyleValue.idl: Copied from Source/WebCore/css/CSSPaintCallback.idl.
+        * css/typedom/CSSUnitValue.h: Copied from Source/WebCore/css/CSSPaintCallback.h.
+        * css/typedom/CSSUnitValue.idl: Copied from Source/WebCore/css/CSSPaintCallback.idl.
+        * css/typedom/CSSUnparsedValue.h: Copied from Source/WebCore/css/CSSPaintCallback.h.
+        * css/typedom/CSSUnparsedValue.idl: Copied from Source/WebCore/css/CSSPaintCallback.idl.
+        * css/typedom/StylePropertyMapReadOnly.h: Copied from Source/WebCore/css/CSSPaintCallback.h.
+        (WebCore::StylePropertyMapReadOnly::create):
+        (WebCore::StylePropertyMapReadOnly::get):
+        (WebCore::StylePropertyMapReadOnly::StylePropertyMapReadOnly):
+        * css/typedom/StylePropertyMapReadOnly.idl: Copied from Source/WebCore/css/CSSPaintCallback.idl.
+        * platform/graphics/CustomPaintImage.cpp:
+        (WebCore::CustomPaintImage::CustomPaintImage):
+        (WebCore::CustomPaintImage::doCustomPaint):
+        * platform/graphics/CustomPaintImage.h:
+
 2018-11-07  Brent Fulgham  <bfulgham@apple.com>
 
         Provide better Font fallbacks for DirectX backend
index f61d4c0..e97808f 100644 (file)
@@ -68,6 +68,7 @@ VPATH = \
     $(WebCore)/crypto/keys \
     $(WebCore)/crypto/parameters \
     $(WebCore)/css \
+    $(WebCore)/css/typedom \
     $(WebCore)/dom \
     $(WebCore)/editing \
     $(WebCore)/fileapi \
@@ -459,6 +460,7 @@ JS_BINDING_IDLS = \
     $(WebCore)/css/CSSNamespaceRule.idl \
     $(WebCore)/css/CSSPageRule.idl \
     $(WebCore)/css/CSSPaintCallback.idl \
+    $(WebCore)/css/CSSPaintSize.idl \
     $(WebCore)/css/CSSRule.idl \
     $(WebCore)/css/CSSRuleList.idl \
     $(WebCore)/css/CSSStyleDeclaration.idl \
@@ -489,6 +491,11 @@ JS_BINDING_IDLS = \
     $(WebCore)/css/StyleMedia.idl \
     $(WebCore)/css/StyleSheet.idl \
     $(WebCore)/css/StyleSheetList.idl \
+    $(WebCore)/css/typedom/CSSNumericValue.idl \
+    $(WebCore)/css/typedom/CSSStyleValue.idl \
+    $(WebCore)/css/typedom/CSSUnitValue.idl \
+    $(WebCore)/css/typedom/CSSUnparsedValue.idl \
+    $(WebCore)/css/typedom/StylePropertyMapReadOnly.idl \
     $(WebCore)/css/WebKitCSSMatrix.idl \
     $(WebCore)/css/WebKitCSSViewportRule.idl \
     $(WebCore)/dom/AbortController.idl \
@@ -1499,6 +1506,7 @@ IDL_INCLUDES = \
     $(WebCore)/accessibility \
     $(WebCore)/animation \
     $(WebCore)/css \
+    $(WebCore)/css/typedom \
     $(WebCore)/crypto \
     $(WebCore)/dom \
     $(WebCore)/fileapi \
index d4d6fbe..60632cf 100644 (file)
@@ -379,6 +379,7 @@ bindings/js/JSBlobCustom.cpp
 bindings/js/JSCSSRuleCustom.cpp
 bindings/js/JSCSSRuleListCustom.cpp
 bindings/js/JSCSSStyleDeclarationCustom.cpp
+bindings/js/JSCSSStyleValueCustom.cpp
 bindings/js/JSDOMConvertDate.cpp
 bindings/js/JSDOMConvertNumbers.cpp
 bindings/js/JSDOMConvertStrings.cpp
@@ -2489,7 +2490,12 @@ JSCSSKeyframeRule.cpp
 JSCSSKeyframesRule.cpp
 JSCSSMediaRule.cpp
 JSCSSNamespaceRule.cpp
+JSCSSNumericValue.cpp
 JSCSSPaintCallback.cpp
+JSCSSPaintSize.cpp
+JSCSSStyleValue.cpp
+JSCSSUnitValue.cpp
+JSCSSUnparsedValue.cpp
 JSPaintWorkletGlobalScope.cpp
 JSWorklet.cpp
 JSWorkletGlobalScope.cpp
@@ -3158,6 +3164,7 @@ JSStorage.cpp
 JSStorageEvent.cpp
 JSStringCallback.cpp
 JSStyleMedia.cpp
+JSStylePropertyMapReadOnly.cpp
 JSStyleSheet.cpp
 JSStyleSheetList.cpp
 JSSubtleCrypto.cpp
index 73dc451..14204a5 100644 (file)
                4B7AE4932177B56F00C59959 /* CustomPaintImage.h in Headers */ = {isa = PBXBuildFile; fileRef = 4B7AE4922177B56F00C59959 /* CustomPaintImage.h */; };
                4B7F9C522183B5E5001CEBA0 /* WorkletConsoleClient.h in Headers */ = {isa = PBXBuildFile; fileRef = 4B7F9C512183B5E5001CEBA0 /* WorkletConsoleClient.h */; };
                4BAE95B10B2FA9CE00AED8A0 /* EditorDeleteAction.h in Headers */ = {isa = PBXBuildFile; fileRef = 4BAE95B00B2FA9CE00AED8A0 /* EditorDeleteAction.h */; settings = {ATTRIBUTES = (Private, ); }; };
+               4BAFD0CB2190EBD600C0AB64 /* CSSPaintSize.h in Headers */ = {isa = PBXBuildFile; fileRef = 4BAFD0CA2190EBD600C0AB64 /* CSSPaintSize.h */; };
+               4BAFD0CF2190F9B500C0AB64 /* StylePropertyMapReadOnly.h in Headers */ = {isa = PBXBuildFile; fileRef = 4BAFD0CE2190F9B400C0AB64 /* StylePropertyMapReadOnly.h */; };
+               4BAFD0D62192146B00C0AB64 /* CSSStyleValue.h in Headers */ = {isa = PBXBuildFile; fileRef = 4BAFD0D52192146B00C0AB64 /* CSSStyleValue.h */; };
+               4BAFD0D921921EA000C0AB64 /* CSSUnparsedValue.h in Headers */ = {isa = PBXBuildFile; fileRef = 4BAFD0D821921EA000C0AB64 /* CSSUnparsedValue.h */; };
+               4BAFD0E0219220AB00C0AB64 /* CSSNumericValue.h in Headers */ = {isa = PBXBuildFile; fileRef = 4BAFD0DF219220AB00C0AB64 /* CSSNumericValue.h */; };
+               4BAFD0E1219242A000C0AB64 /* CSSUnitValue.h in Headers */ = {isa = PBXBuildFile; fileRef = 4BAFD0DD2192209200C0AB64 /* CSSUnitValue.h */; };
                4BDA3FFE2151B6F500FD6604 /* DOMCSSCustomPropertyDescriptor.h in Headers */ = {isa = PBXBuildFile; fileRef = 4BDA3FF82151B6F200FD6604 /* DOMCSSCustomPropertyDescriptor.h */; };
                4BDA3FFF2151B6F500FD6604 /* DOMCSSRegisterCustomProperty.h in Headers */ = {isa = PBXBuildFile; fileRef = 4BDA3FF92151B6F300FD6604 /* DOMCSSRegisterCustomProperty.h */; };
                4BDA40012151B6F500FD6604 /* CSSRegisteredCustomProperty.h in Headers */ = {isa = PBXBuildFile; fileRef = 4BDA3FFB2151B6F400FD6604 /* CSSRegisteredCustomProperty.h */; settings = {ATTRIBUTES = (Private, ); }; };
                4B7F9C512183B5E5001CEBA0 /* WorkletConsoleClient.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = WorkletConsoleClient.h; sourceTree = "<group>"; };
                4B7F9C542183B634001CEBA0 /* WorkletConsoleClient.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = WorkletConsoleClient.cpp; sourceTree = "<group>"; };
                4BAE95B00B2FA9CE00AED8A0 /* EditorDeleteAction.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = EditorDeleteAction.h; sourceTree = "<group>"; };
+               4BAFD0CA2190EBD600C0AB64 /* CSSPaintSize.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = CSSPaintSize.h; sourceTree = "<group>"; };
+               4BAFD0CD2190EBE900C0AB64 /* CSSPaintSize.idl */ = {isa = PBXFileReference; lastKnownFileType = text; path = CSSPaintSize.idl; sourceTree = "<group>"; };
+               4BAFD0CE2190F9B400C0AB64 /* StylePropertyMapReadOnly.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = StylePropertyMapReadOnly.h; sourceTree = "<group>"; };
+               4BAFD0D02190F9C200C0AB64 /* StylePropertyMapReadOnly.idl */ = {isa = PBXFileReference; lastKnownFileType = text; path = StylePropertyMapReadOnly.idl; sourceTree = "<group>"; };
+               4BAFD0D32192145600C0AB64 /* CSSStyleValue.idl */ = {isa = PBXFileReference; lastKnownFileType = text; path = CSSStyleValue.idl; sourceTree = "<group>"; };
+               4BAFD0D52192146B00C0AB64 /* CSSStyleValue.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = CSSStyleValue.h; sourceTree = "<group>"; };
+               4BAFD0D721921E7900C0AB64 /* CSSUnparsedValue.idl */ = {isa = PBXFileReference; lastKnownFileType = text; path = CSSUnparsedValue.idl; sourceTree = "<group>"; };
+               4BAFD0D821921EA000C0AB64 /* CSSUnparsedValue.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = CSSUnparsedValue.h; sourceTree = "<group>"; };
+               4BAFD0DB2192202200C0AB64 /* CSSNumericValue.idl */ = {isa = PBXFileReference; lastKnownFileType = text; path = CSSNumericValue.idl; sourceTree = "<group>"; };
+               4BAFD0DC2192204A00C0AB64 /* CSSUnitValue.idl */ = {isa = PBXFileReference; lastKnownFileType = text; path = CSSUnitValue.idl; sourceTree = "<group>"; };
+               4BAFD0DD2192209200C0AB64 /* CSSUnitValue.h */ = {isa = PBXFileReference; explicitFileType = sourcecode.c.h; path = CSSUnitValue.h; sourceTree = "<group>"; };
+               4BAFD0DF219220AB00C0AB64 /* CSSNumericValue.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = CSSNumericValue.h; sourceTree = "<group>"; };
+               4BAFD0E22192604D00C0AB64 /* JSCSSStyleValueCustom.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = JSCSSStyleValueCustom.cpp; sourceTree = "<group>"; };
                4BDA3FF52151B6F000FD6604 /* DOMCSSRegisterCustomProperty.idl */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = DOMCSSRegisterCustomProperty.idl; sourceTree = "<group>"; };
                4BDA3FF72151B6F100FD6604 /* DOMCSSRegisterCustomProperty.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = DOMCSSRegisterCustomProperty.cpp; sourceTree = "<group>"; };
                4BDA3FF82151B6F200FD6604 /* DOMCSSCustomPropertyDescriptor.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DOMCSSCustomPropertyDescriptor.h; sourceTree = "<group>"; };
                        path = animation;
                        sourceTree = "<group>";
                };
+               4BAFD0DA21921EAD00C0AB64 /* typedom */ = {
+                       isa = PBXGroup;
+                       children = (
+                               4BAFD0DF219220AB00C0AB64 /* CSSNumericValue.h */,
+                               4BAFD0DB2192202200C0AB64 /* CSSNumericValue.idl */,
+                               4BAFD0D52192146B00C0AB64 /* CSSStyleValue.h */,
+                               4BAFD0D32192145600C0AB64 /* CSSStyleValue.idl */,
+                               4BAFD0DD2192209200C0AB64 /* CSSUnitValue.h */,
+                               4BAFD0DC2192204A00C0AB64 /* CSSUnitValue.idl */,
+                               4BAFD0D821921EA000C0AB64 /* CSSUnparsedValue.h */,
+                               4BAFD0D721921E7900C0AB64 /* CSSUnparsedValue.idl */,
+                               4BAFD0CE2190F9B400C0AB64 /* StylePropertyMapReadOnly.h */,
+                               4BAFD0D02190F9C200C0AB64 /* StylePropertyMapReadOnly.idl */,
+                       );
+                       path = typedom;
+                       sourceTree = "<group>";
+               };
                4BDEA318217EBB880052DFCD /* worklets */ = {
                        isa = PBXGroup;
                        children = (
                                9392262E10321084006E7D5D /* JSCSSRuleListCustom.cpp */,
                                BC5825F20C0B89380053F1B5 /* JSCSSStyleDeclarationCustom.cpp */,
                                AD726FEA16D9F40B003A4E6D /* JSCSSStyleDeclarationCustom.h */,
+                               4BAFD0E22192604D00C0AB64 /* JSCSSStyleValueCustom.cpp */,
                                BC20FB7E0C0E8E6C00D1447F /* JSDeprecatedCSSOMValueCustom.cpp */,
                                49C7BA8C1042F5B10009D447 /* JSDocumentCustom.cpp */,
                                ADDA94BF19686F8000453029 /* JSDocumentCustom.h */,
                        isa = PBXGroup;
                        children = (
                                946D37271D6CB2250077084F /* parser */,
+                               4BAFD0DA21921EAD00C0AB64 /* typedom */,
                                FBD6AF8415EF21D4008B7110 /* BasicShapeFunctions.cpp */,
                                FBD6AF8515EF21D4008B7110 /* BasicShapeFunctions.h */,
                                A80E6CDA0A1989CA007FB8C5 /* Counter.h */,
                                4B5BDD99216588E500DD4262 /* CSSPaintCallback.idl */,
                                4B6E876B2176D8A100420E5E /* CSSPaintImageValue.cpp */,
                                4B6E87682176D69200420E5E /* CSSPaintImageValue.h */,
+                               4BAFD0CA2190EBD600C0AB64 /* CSSPaintSize.h */,
+                               4BAFD0CD2190EBE900C0AB64 /* CSSPaintSize.idl */,
                                9418278C1D8CAE9500492764 /* CSSPendingSubstitutionValue.cpp */,
                                9418278D1D8CAE9500492764 /* CSSPendingSubstitutionValue.h */,
                                A80E6CDB0A1989CA007FB8C5 /* CSSPrimitiveValue.cpp */,
                                A80E6D030A1989CA007FB8C5 /* CSSMediaRule.h in Headers */,
                                314BE3A11B30F6B700141982 /* CSSNamedImageValue.h in Headers */,
                                94E839511DFB2A0E007BC6A7 /* CSSNamespaceRule.h in Headers */,
+                               4BAFD0E0219220AB00C0AB64 /* CSSNumericValue.h in Headers */,
                                A80E6D000A1989CA007FB8C5 /* CSSPageRule.h in Headers */,
                                4B5BDD9B21658A1500DD4262 /* CSSPaintCallback.h in Headers */,
                                4B6E87692176D69200420E5E /* CSSPaintImageValue.h in Headers */,
+                               4BAFD0CB2190EBD600C0AB64 /* CSSPaintSize.h in Headers */,
                                946D372E1D6CB2940077084F /* CSSParser.h in Headers */,
                                E4A7995220EE4B1400C19568 /* CSSParserContext.h in Headers */,
                                949C77011D6E1D9800C0DE4F /* CSSParserFastPaths.h in Headers */,
                                A80E6E0F0A19911C007FB8C5 /* CSSStyleDeclaration.h in Headers */,
                                A80E6D0C0A1989CA007FB8C5 /* CSSStyleRule.h in Headers */,
                                A8EA80070A19516E00A8EF5F /* CSSStyleSheet.h in Headers */,
+                               4BAFD0D62192146B00C0AB64 /* CSSStyleValue.h in Headers */,
                                94DE5C921D83011D00164F2A /* CSSSupportsParser.h in Headers */,
                                FC54D05716A7673100575E4D /* CSSSupportsRule.h in Headers */,
                                BC80C9880CD294EE00A0B7B3 /* CSSTimingFunctionValue.h in Headers */,
                                A882DA231593848D000115ED /* CSSToStyleMap.h in Headers */,
                                715AD7212050513F00D592DC /* CSSTransition.h in Headers */,
                                371F53E90D2704F900ECE0D5 /* CSSUnicodeRangeValue.h in Headers */,
+                               4BAFD0E1219242A000C0AB64 /* CSSUnitValue.h in Headers */,
                                DD7CDF250A23CF9800069928 /* CSSUnknownRule.h in Headers */,
+                               4BAFD0D921921EA000C0AB64 /* CSSUnparsedValue.h in Headers */,
                                BC7D8FF01BD03B6400FFE540 /* CSSUnsetValue.h in Headers */,
                                A80E6CEE0A1989CA007FB8C5 /* CSSValue.h in Headers */,
                                6565815109D13043000E61D7 /* CSSValueKeywords.h in Headers */,
                                BC5EB74E0E81E06700B25965 /* StyleMultiColData.h in Headers */,
                                E4DACE6A1D12E10B0075980F /* StylePendingResources.h in Headers */,
                                A80E6DFC0A199067007FB8C5 /* StyleProperties.h in Headers */,
+                               4BAFD0CF2190F9B500C0AB64 /* StylePropertyMapReadOnly.h in Headers */,
                                E1B25107152A0BB00069B779 /* StylePropertyShorthand.h in Headers */,
                                83C05A5B1A686212007E5DEA /* StylePropertyShorthandFunctions.h in Headers */,
                                BC2272E40E82EE9B00E7F975 /* StyleRareInheritedData.h in Headers */,
diff --git a/Source/WebCore/bindings/js/JSCSSStyleValueCustom.cpp b/Source/WebCore/bindings/js/JSCSSStyleValueCustom.cpp
new file mode 100644 (file)
index 0000000..de3145c
--- /dev/null
@@ -0,0 +1,55 @@
+/*
+ * 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 APPLE INC. ``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 APPLE INC. OR
+ * CONTRIBUTORS 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 "JSCSSStyleValue.h"
+
+#if ENABLE(CSS_PAINTING_API)
+
+#include "JSCSSUnitValue.h"
+#include "JSCSSUnparsedValue.h"
+
+namespace WebCore {
+using namespace JSC;
+
+JSValue toJSNewlyCreated(ExecState*, JSDOMGlobalObject* globalObject, Ref<CSSStyleValue>&& value)
+{
+    if (value->isUnitValue())
+        return createWrapper<CSSUnitValue>(globalObject, WTFMove(value));
+    if (value->isUnparsedValue())
+        return createWrapper<CSSUnparsedValue>(globalObject, WTFMove(value));
+
+    ASSERT_NOT_REACHED();
+    return createWrapper<CSSStyleValue>(globalObject, WTFMove(value));
+}
+
+JSValue toJS(ExecState* state, JSDOMGlobalObject* globalObject, CSSStyleValue& object)
+{
+    return wrap(state, globalObject, object);
+}
+
+} // namespace WebCore
+
+#endif
index f2f36c9..42c1932 100644 (file)
@@ -49,7 +49,12 @@ namespace WebCore {
     macro(Credential) \
     macro(CredentialsContainer) \
     macro(CSSAnimation) \
+    macro(CSSNumericValue) \
+    macro(CSSPaintSize) \
+    macro(CSSStyleValue) \
     macro(CSSTransition) \
+    macro(CSSUnitValue) \
+    macro(CSSUnparsedValue) \
     macro(CustomElementRegistry) \
     macro(Database) \
     macro(DataTransferItem) \
@@ -161,6 +166,7 @@ namespace WebCore {
     macro(ShadowRoot) \
     macro(SpectreGadget) \
     macro(StaticRange) \
+    macro(StylePropertyMapReadOnly) \
     macro(VRDisplay) \
     macro(VRDisplayCapabilities) \
     macro(VRDisplayEvent) \
index a373c39..a623523 100644 (file)
@@ -40,6 +40,7 @@
 #include <JavaScriptCore/Exception.h>
 #include <JavaScriptCore/ExceptionHelpers.h>
 #include <JavaScriptCore/GCActivityCallback.h>
+#include <JavaScriptCore/JSCInlines.h>
 #include <JavaScriptCore/JSLock.h>
 #include <JavaScriptCore/PromiseDeferredTimer.h>
 #include <JavaScriptCore/StrongInlines.h>
index f21e678..756563c 100644 (file)
@@ -28,7 +28,9 @@
 #if ENABLE(CSS_PAINTING_API)
 
 #include "ActiveDOMCallback.h"
+#include "CSSPaintSize.h"
 #include "CallbackResult.h"
+#include "StylePropertyMapReadOnly.h"
 #include <wtf/RefCounted.h>
 
 namespace WebCore {
@@ -38,7 +40,7 @@ class CSSPaintCallback : public RefCounted<CSSPaintCallback>, public ActiveDOMCa
 public:
     using ActiveDOMCallback::ActiveDOMCallback;
 
-    virtual CallbackResult<void> handleEvent(PaintRenderingContext2D&) = 0;
+    virtual CallbackResult<void> handleEvent(PaintRenderingContext2D&, CSSPaintSize&, StylePropertyMapReadOnly&, const Vector<String>&) = 0;
 
     virtual ~CSSPaintCallback()
     {
index 2941473..86756b5 100644 (file)
@@ -26,4 +26,4 @@
 [
     EnabledAtRuntime=CSSPaintingAPI,
     Conditional=CSS_PAINTING_API,
-] callback CSSPaintCallback = void (PaintRenderingContext2D context);
+] callback CSSPaintCallback = void (PaintRenderingContext2D context, CSSPaintSize size, StylePropertyMapReadOnly styleMap, sequence<USVString> arguments);
index 731f31d..1466526 100644 (file)
@@ -29,6 +29,7 @@
 
 #if ENABLE(CSS_PAINTING_API)
 
+#include "CSSVariableData.h"
 #include "CustomPaintImage.h"
 #include "PaintWorkletGlobalScope.h"
 #include "RenderElement.h"
@@ -58,7 +59,25 @@ RefPtr<Image> CSSPaintImageValue::image(RenderElement& renderElement, const Floa
 
     if (!registration)
         return nullptr;
-    return CustomPaintImage::create(*registration, size);
+
+    // FIXME: Check if argument list matches syntax.
+    Vector<String> arguments;
+    CSSParserTokenRange localRange(m_arguments->tokenRange());
+
+    while (!localRange.atEnd()) {
+        StringBuilder builder;
+        while (!localRange.atEnd() && localRange.peek() != CommaToken) {
+            if (localRange.peek() == CommentToken)
+                localRange.consume();
+            else
+                localRange.consume().serialize(builder);
+        }
+        if (!localRange.atEnd())
+            localRange.consume(); // comma token
+        arguments.append(builder.toString());
+    }
+
+    return CustomPaintImage::create(*registration, size, renderElement, arguments);
 }
 
 } // namespace WebCore
index 57679fc..b6b69c8 100644 (file)
 #include "CSSImageGeneratorValue.h"
 
 namespace WebCore {
+class CSSVariableData;
 
 class CSSPaintImageValue final : public CSSImageGeneratorValue {
 public:
-    static Ref<CSSPaintImageValue> create(const String& name)
+    static Ref<CSSPaintImageValue> create(const String& name, Ref<CSSVariableData>&& arguments)
     {
-        return adoptRef(*new CSSPaintImageValue(name));
+        return adoptRef(*new CSSPaintImageValue(name, WTFMove(arguments)));
     }
 
     RefPtr<Image> image(RenderElement&, const FloatSize&);
@@ -53,13 +54,15 @@ public:
     void loadSubimages(CachedResourceLoader&, const ResourceLoaderOptions&) { }
 
 private:
-    CSSPaintImageValue(const String& name)
+    CSSPaintImageValue(const String& name, Ref<CSSVariableData>&& arguments)
         : CSSImageGeneratorValue(PaintImageClass)
         , m_name(name)
+        , m_arguments(WTFMove(arguments))
     {
     }
 
     const String m_name;
+    Ref<CSSVariableData> m_arguments;
 };
 
 } // namespace WebCore
diff --git a/Source/WebCore/css/CSSPaintSize.h b/Source/WebCore/css/CSSPaintSize.h
new file mode 100644 (file)
index 0000000..6d3fc56
--- /dev/null
@@ -0,0 +1,58 @@
+/*
+ * 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 APPLE INC. ``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 APPLE INC. OR
+ * CONTRIBUTORS 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 <wtf/RefCounted.h>
+#include <wtf/RefPtr.h>
+
+namespace WebCore {
+
+class CSSPaintSize : public RefCounted<CSSPaintSize> {
+public:
+    static Ref<CSSPaintSize> create(double width, double height)
+    {
+        return adoptRef(*new CSSPaintSize(width, height));
+    }
+
+    double width() const { return m_width; }
+    double height() const { return m_height; }
+
+private:
+    CSSPaintSize(double width, double height)
+        : m_width(width)
+        , m_height(height)
+    {
+    }
+
+    double m_width;
+    double m_height;
+};
+
+} // namespace WebCore
+
+#endif
diff --git a/Source/WebCore/css/CSSPaintSize.idl b/Source/WebCore/css/CSSPaintSize.idl
new file mode 100644 (file)
index 0000000..48619b3
--- /dev/null
@@ -0,0 +1,34 @@
+/*
+* 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 APPLE INC. ``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 APPLE INC. OR
+* CONTRIBUTORS 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.
+*/
+
+[
+    EnabledAtRuntime=CSSPaintingAPI,
+    Conditional=CSS_PAINTING_API,
+    Exposed=PaintWorklet,
+    ImplementationLacksVTable,
+] interface CSSPaintSize {
+    readonly attribute double width;
+    readonly attribute double height;
+};
index 792b0d1..07c4d70 100644 (file)
@@ -1295,11 +1295,17 @@ static RefPtr<CSSValue> consumeCustomPaint(CSSParserTokenRange& args)
         return nullptr;
     auto name = args.consumeIncludingWhitespace().value().toString();
 
-    // FIXME: should parse arguments.
+    if (!args.atEnd() && args.peek() != CommaToken)
+        return nullptr;
+    if (!args.atEnd())
+        args.consume();
+
+    auto argumentList = CSSVariableData::create(args);
+
     while (!args.atEnd())
         args.consume();
 
-    return CSSPaintImageValue::create(name);
+    return CSSPaintImageValue::create(name, WTFMove(argumentList));
 }
 #endif
 
diff --git a/Source/WebCore/css/typedom/CSSNumericValue.h b/Source/WebCore/css/typedom/CSSNumericValue.h
new file mode 100644 (file)
index 0000000..de49784
--- /dev/null
@@ -0,0 +1,40 @@
+/*
+ * 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 APPLE INC. ``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 APPLE INC. OR
+ * CONTRIBUTORS 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 "CSSStyleValue.h"
+
+namespace WebCore {
+
+class CSSNumericValue : public CSSStyleValue {
+protected:
+    CSSNumericValue() = default;
+};
+} // namespace WebCore
+
+#endif
diff --git a/Source/WebCore/css/typedom/CSSNumericValue.idl b/Source/WebCore/css/typedom/CSSNumericValue.idl
new file mode 100644 (file)
index 0000000..d4a2666
--- /dev/null
@@ -0,0 +1,34 @@
+/*
+* 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 APPLE INC. ``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 APPLE INC. OR
+* CONTRIBUTORS 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.
+*/
+
+// FIXME: Implement this properly, according to the Typed OM spec.
+// This is just a stub for the CSS painting API for now. Once the Typed OM
+// is going to be implemented, please change the runtime flag.
+[
+    EnabledAtRuntime=CSSPaintingAPI,
+    Conditional=CSS_PAINTING_API,
+    Exposed=(Window,Worker,PaintWorklet),
+] interface CSSNumericValue : CSSStyleValue {
+};
diff --git a/Source/WebCore/css/typedom/CSSStyleValue.h b/Source/WebCore/css/typedom/CSSStyleValue.h
new file mode 100644 (file)
index 0000000..b662ea6
--- /dev/null
@@ -0,0 +1,49 @@
+/*
+ * 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 APPLE INC. ``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 APPLE INC. OR
+ * CONTRIBUTORS 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 <wtf/RefCounted.h>
+#include <wtf/text/WTFString.h>
+
+namespace WebCore {
+
+class CSSStyleValue : public RefCounted<CSSStyleValue> {
+public:
+    virtual ~CSSStyleValue() = default;
+    virtual String toString() = 0;
+
+    virtual bool isUnitValue() { return false; }
+    virtual bool isUnparsedValue() { return false; }
+
+protected:
+    CSSStyleValue() = default;
+};
+
+} // namespace WebCore
+
+#endif
diff --git a/Source/WebCore/css/typedom/CSSStyleValue.idl b/Source/WebCore/css/typedom/CSSStyleValue.idl
new file mode 100644 (file)
index 0000000..a87430c
--- /dev/null
@@ -0,0 +1,37 @@
+/*
+* 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 APPLE INC. ``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 APPLE INC. OR
+* CONTRIBUTORS 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.
+*/
+
+// FIXME: Implement this properly, according to the Typed OM spec.
+// This is just a stub for the CSS painting API for now. Once the Typed OM
+// is going to be implemented, please change the runtime flag.
+[
+    CustomToJSObject,
+    EnabledAtRuntime=CSSPaintingAPI,
+    Conditional=CSS_PAINTING_API,
+    Exposed=(Window,Worker,PaintWorklet),
+    SkipVTableValidation,
+] interface CSSStyleValue {
+    stringifier;
+};
diff --git a/Source/WebCore/css/typedom/CSSUnitValue.h b/Source/WebCore/css/typedom/CSSUnitValue.h
new file mode 100644 (file)
index 0000000..4979974
--- /dev/null
@@ -0,0 +1,67 @@
+/*
+ * 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 APPLE INC. ``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 APPLE INC. OR
+ * CONTRIBUTORS 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 "CSSNumericValue.h"
+#include <wtf/RefCounted.h>
+#include <wtf/text/StringConcatenateNumbers.h>
+#include <wtf/text/WTFString.h>
+
+namespace WebCore {
+
+class CSSUnitValue final : public CSSNumericValue {
+public:
+    static Ref<CSSUnitValue> create(double value, const String& unit)
+    {
+        return adoptRef(*new CSSUnitValue(value, unit));
+    }
+
+    // FIXME: not correct.
+    String toString() final { return makeString((int) m_value, m_unit); }
+
+    double value() const { return m_value; }
+    void setValue(double value) { m_value = value; }
+    const String& unit() const { return m_unit; }
+    void setUnit(const String& unit) { m_unit = unit; }
+
+private:
+    CSSUnitValue(double value, const String& unit)
+        : m_value(value)
+        , m_unit(unit)
+    {
+    }
+
+    bool isUnitValue() final { return true; }
+
+    double m_value;
+    String m_unit;
+};
+
+} // namespace WebCore
+
+#endif
diff --git a/Source/WebCore/css/typedom/CSSUnitValue.idl b/Source/WebCore/css/typedom/CSSUnitValue.idl
new file mode 100644 (file)
index 0000000..2c78aa5
--- /dev/null
@@ -0,0 +1,37 @@
+/*
+* 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 APPLE INC. ``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 APPLE INC. OR
+* CONTRIBUTORS 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.
+*/
+
+// FIXME: Implement this properly, according to the Typed OM spec.
+// This is just a stub for the CSS painting API for now. Once the Typed OM
+// is going to be implemented, please change the runtime flag.
+[
+    EnabledAtRuntime=CSSPaintingAPI,
+    Conditional=CSS_PAINTING_API,
+    Exposed=(Window,Worker,PaintWorklet),
+    Constructor(double value, USVString unit),
+] interface CSSUnitValue : CSSNumericValue {
+    attribute double value;
+    readonly attribute USVString unit;
+};
diff --git a/Source/WebCore/css/typedom/CSSUnparsedValue.h b/Source/WebCore/css/typedom/CSSUnparsedValue.h
new file mode 100644 (file)
index 0000000..3bccf3a
--- /dev/null
@@ -0,0 +1,58 @@
+/*
+ * 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 APPLE INC. ``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 APPLE INC. OR
+ * CONTRIBUTORS 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 "CSSStyleValue.h"
+#include <wtf/RefCounted.h>
+#include <wtf/text/WTFString.h>
+
+namespace WebCore {
+
+class CSSUnparsedValue final : public CSSStyleValue {
+public:
+    static Ref<CSSUnparsedValue> create(const String& serializedValue)
+    {
+        return adoptRef(*new CSSUnparsedValue(serializedValue));
+    }
+
+    String toString() final { return m_serializedValue; }
+
+private:
+    explicit CSSUnparsedValue(const String& serializedValue)
+        : m_serializedValue(serializedValue)
+    {
+    }
+
+    bool isUnparsedValue() final { return true; }
+
+    String m_serializedValue;
+};
+
+} // namespace WebCore
+
+#endif
diff --git a/Source/WebCore/css/typedom/CSSUnparsedValue.idl b/Source/WebCore/css/typedom/CSSUnparsedValue.idl
new file mode 100644 (file)
index 0000000..d039c82
--- /dev/null
@@ -0,0 +1,36 @@
+/*
+* 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 APPLE INC. ``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 APPLE INC. OR
+* CONTRIBUTORS 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.
+*/
+
+// FIXME: Implement this properly, according to the Typed OM spec.
+// This is just a stub for the CSS painting API for now. Once the Typed OM
+// is going to be implemented, please change the runtime flag.
+// FIXME: wrong constructor.
+[
+    EnabledAtRuntime=CSSPaintingAPI,
+    Conditional=CSS_PAINTING_API,
+    Exposed=(Window,Worker,PaintWorklet),
+    Constructor(USVString serializedValue),
+] interface CSSUnparsedValue : CSSStyleValue {
+};
diff --git a/Source/WebCore/css/typedom/StylePropertyMapReadOnly.h b/Source/WebCore/css/typedom/StylePropertyMapReadOnly.h
new file mode 100644 (file)
index 0000000..5993f8b
--- /dev/null
@@ -0,0 +1,57 @@
+/*
+ * 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 APPLE INC. ``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 APPLE INC. OR
+ * CONTRIBUTORS 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 "CSSStyleValue.h"
+#include <wtf/HashMap.h>
+#include <wtf/RefCounted.h>
+#include <wtf/text/WTFString.h>
+
+namespace WebCore {
+
+class StylePropertyMapReadOnly : public RefCounted<StylePropertyMapReadOnly> {
+public:
+    static Ref<StylePropertyMapReadOnly> create(HashMap<String, Ref<CSSStyleValue>>&& map)
+    {
+        return adoptRef(*new StylePropertyMapReadOnly(WTFMove(map)));
+    }
+
+    CSSStyleValue* get(String property) const { return m_map.get(property); }
+
+private:
+    explicit StylePropertyMapReadOnly(HashMap<String, Ref<CSSStyleValue>>&& map)
+        : m_map(WTFMove(map))
+    {
+    }
+
+    HashMap<String, Ref<CSSStyleValue>> m_map;
+};
+
+} // namespace WebCore
+
+#endif
diff --git a/Source/WebCore/css/typedom/StylePropertyMapReadOnly.idl b/Source/WebCore/css/typedom/StylePropertyMapReadOnly.idl
new file mode 100644 (file)
index 0000000..b7e1983
--- /dev/null
@@ -0,0 +1,37 @@
+/*
+* 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 APPLE INC. ``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 APPLE INC. OR
+* CONTRIBUTORS 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.
+*/
+
+// FIXME: Implement this properly, according to the Typed OM spec.
+// This is just a stub for the CSS painting API for now. Once the Typed OM
+// is going to be implemented, please change the runtime flag.
+[
+    EnabledAtRuntime=CSSPaintingAPI,
+    Conditional=CSS_PAINTING_API,
+    Exposed=(Window,Worker,PaintWorklet),
+    ImplementationLacksVTable
+] interface StylePropertyMapReadOnly {
+    // FIXME: should be (undefined or CSSStyleValue), not null
+    CSSStyleValue? get(USVString property);
+};
index 15aa924..43962c5 100644 (file)
 
 #if ENABLE(CSS_PAINTING_API)
 
+#include "CSSComputedStyleDeclaration.h"
+#include "CSSPrimitiveValue.h"
+#include "CSSPropertyParser.h"
+#include "CSSUnitValue.h"
+#include "CSSUnparsedValue.h"
 #include "CustomPaintCanvas.h"
 #include "GraphicsContext.h"
 #include "ImageBitmap.h"
 #include "ImageBuffer.h"
 #include "JSCSSPaintCallback.h"
 #include "PaintRenderingContext2D.h"
+#include "RenderElement.h"
 
 namespace WebCore {
 
-CustomPaintImage::CustomPaintImage(const PaintWorkletGlobalScope::PaintDefinition& definition, const FloatSize& size)
+CustomPaintImage::CustomPaintImage(const PaintWorkletGlobalScope::PaintDefinition& definition, const FloatSize& size, RenderElement& element, const Vector<String>& arguments)
     : m_paintCallback(definition.paintCallback.get())
+    , m_inputProperties(definition.inputProperties)
+    , m_element(makeWeakPtr(element))
+    , m_arguments(arguments)
 {
     setContainerSize(size);
 }
@@ -47,6 +56,12 @@ CustomPaintImage::~CustomPaintImage() = default;
 
 ImageDrawResult CustomPaintImage::doCustomPaint(GraphicsContext& destContext, const FloatSize& destSize)
 {
+    if (!m_element || !m_element->element())
+        return ImageDrawResult::DidNothing;
+
+    ASSERT(!m_element->needsLayout());
+    ASSERT(!m_element->element()->document().needsStyleRecalc());
+
     JSCSSPaintCallback& callback = static_cast<JSCSSPaintCallback&>(m_paintCallback.get());
     auto* scriptExecutionContext = callback.scriptExecutionContext();
     if (!scriptExecutionContext)
@@ -59,7 +74,36 @@ ImageDrawResult CustomPaintImage::doCustomPaint(GraphicsContext& destContext, co
         return ImageDrawResult::DidNothing;
     auto context = contextOrException.releaseReturnValue();
 
-    auto result = m_paintCallback->handleEvent(*context);
+    HashMap<String, Ref<CSSStyleValue>> propertyValues;
+    ComputedStyleExtractor extractor(m_element->element());
+
+    for (auto& name : m_inputProperties) {
+        RefPtr<CSSValue> value;
+        if (isCustomPropertyName(name))
+            value = extractor.customPropertyValue(name);
+        else {
+            CSSPropertyID propertyID = cssPropertyID(name);
+            if (!propertyID)
+                return ImageDrawResult::DidNothing;
+            value = extractor.propertyValue(propertyID, DoNotUpdateLayout);
+        }
+
+        if (!value) {
+            propertyValues.add(name, CSSUnparsedValue::create(emptyString()));
+            continue;
+        }
+
+        // FIXME: Properly reify all length values.
+        if (is<CSSPrimitiveValue>(*value) && downcast<CSSPrimitiveValue>(*value).primitiveType() == CSSPrimitiveValue::CSS_PX)
+            propertyValues.add(name, CSSUnitValue::create(downcast<CSSPrimitiveValue>(*value).doubleValue(), "px"));
+        else
+            propertyValues.add(name, CSSUnparsedValue::create(value->cssText()));
+    }
+
+    auto size = CSSPaintSize::create(destSize.width(), destSize.height());
+    auto propertyMap = StylePropertyMapReadOnly::create(WTFMove(propertyValues));
+
+    auto result = m_paintCallback->handleEvent(*context, size, propertyMap, m_arguments);
     if (result.type() != CallbackResultType::Success)
         return ImageDrawResult::DidNothing;
 
index eb6a81b..d306793 100644 (file)
 
 #include "GeneratedImage.h"
 #include "PaintWorkletGlobalScope.h"
+#include <wtf/WeakPtr.h>
 
 namespace WebCore {
 
 class ImageBuffer;
+class RenderElement;
 
 class CustomPaintImage final : public GeneratedImage {
 public:
-    static Ref<CustomPaintImage> create(const PaintWorkletGlobalScope::PaintDefinition& definition, const FloatSize& size)
+    static Ref<CustomPaintImage> create(const PaintWorkletGlobalScope::PaintDefinition& definition, const FloatSize& size, RenderElement& element, const Vector<String>& arguments)
     {
-        return adoptRef(*new CustomPaintImage(definition, size));
+        return adoptRef(*new CustomPaintImage(definition, size, element, arguments));
     }
 
     virtual ~CustomPaintImage();
     bool isCustomPaintImage() const override { return true; }
 
 private:
-    CustomPaintImage(const PaintWorkletGlobalScope::PaintDefinition&, const FloatSize&);
+    CustomPaintImage(const PaintWorkletGlobalScope::PaintDefinition&, const FloatSize&, RenderElement&, const Vector<String>& arguments);
 
     ImageDrawResult doCustomPaint(GraphicsContext&, const FloatSize&);
 
@@ -53,6 +55,9 @@ private:
     void drawPattern(GraphicsContext&, const FloatRect& destRect, const FloatRect& srcRect, const AffineTransform& patternTransform, const FloatPoint& phase, const FloatSize& spacing, CompositeOperator, BlendMode) final;
 
     Ref<CSSPaintCallback> m_paintCallback;
+    Vector<String> m_inputProperties;
+    WeakPtr<RenderElement> m_element;
+    Vector<String> m_arguments;
 };
 
 }