Changeset 237981 in webkit


Ignore:
Timestamp:
Nov 7, 2018 9:29:59 PM (5 years ago)
Author:
Justin Michaud
Message:

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.

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:
Location:
trunk
Files:
3 added
17 edited
13 copied

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r237978 r237981  
     12018-11-07  Justin Michaud  <justin_michaud@apple.com>
     2
     3        CSS Painting API should pass size, arguments and input properties to paint callback
     4        https://bugs.webkit.org/show_bug.cgi?id=191309
     5
     6        Reviewed by Chris Dumez.
     7
     8        * fast/css-custom-paint/properties-expected.html: Added.
     9        * fast/css-custom-paint/properties.html: Added.
     10        * fast/css-custom-paint/worklet.html:
     11
    1122018-11-07  Zalan Bujtas  <zalan@apple.com>
    213
  • trunk/LayoutTests/fast/css-custom-paint/worklet.html

    r237766 r237981  
    1818class MyPaint {
    1919  paint(ctx, geom, properties) {
     20    console.log("Hello from paint callback!");
     21    assert_greater_than(eval("devicePixelRatio"), 0);
     22    assert_throws({'name': 'ReferenceError'}, function () { eval("window"); });
     23
     24    const promise = new Promise((resolve, reject) => { console.log("In promise"); resolve() });
     25    promise.then(() => console.log("Promise was resolved"));
     26
    2027    for (var i = 0; i < 6; i++){
    2128      for (var j = 0; j < 6; j++){
     
    2532      }
    2633    }
    27     console.log("Hello from paint callback!");
    28     assert_greater_than(eval("devicePixelRatio"), 0);
    29     assert_throws({'name': 'ReferenceError'}, function () { eval("window"); });
    30 
    31     const promise = new Promise((resolve, reject) => { console.log("In promise"); resolve() });
    32     promise.then(() => console.log("Promise was resolved"));
    3334  }
    3435}
  • trunk/LayoutTests/imported/w3c/web-platform-tests/css/css-properties-values-api/typedom.tentative-expected.txt

    r237697 r237981  
    1 CONSOLE MESSAGE: line 340: ReferenceError: Can't find variable: CSSUnparsedValue
     1CONSOLE MESSAGE: line 349: TypeError: CSS.px is not a function. (In 'CSS.px(15)', 'CSS.px' is undefined)
    22
    3 Harness Error (FAIL), message = ReferenceError: Can't find variable: CSSUnparsedValue
     3Harness Error (FAIL), message = TypeError: CSS.px is not a function. (In 'CSS.px(15)', 'CSS.px' is undefined)
    44
    55FAIL Computed * is reified as CSSUnparsedValue target.computedStyleMap is not a function. (In 'target.computedStyleMap()', 'target.computedStyleMap' is undefined)
     
    99FAIL Computed <image> [url] is reified as CSSImageValue The given initial value does not parse for the given syntax.
    1010FAIL Computed <integer> is reified as CSSUnitValue The given initial value does not parse for the given syntax.
    11 FAIL Computed <length-percentage> [%] is reified as CSSUnitValue Can't find variable: CSSUnitValue
    12 FAIL Computed <length-percentage> [px] is reified as CSSUnitValue Can't find variable: CSSUnitValue
     11FAIL Computed <length-percentage> [%] is reified as CSSUnitValue target.computedStyleMap is not a function. (In 'target.computedStyleMap()', 'target.computedStyleMap' is undefined)
     12FAIL Computed <length-percentage> [px] is reified as CSSUnitValue target.computedStyleMap is not a function. (In 'target.computedStyleMap()', 'target.computedStyleMap' is undefined)
    1313FAIL Computed <length-percentage> [px + %] is reified as CSSMathSum Can't find variable: CSSMathSum
    14 FAIL Computed <length> is reified as CSSUnitValue Can't find variable: CSSUnitValue
     14FAIL Computed <length> is reified as CSSUnitValue target.computedStyleMap is not a function. (In 'target.computedStyleMap()', 'target.computedStyleMap' is undefined)
    1515FAIL Computed <number> is reified as CSSUnitValue The given initial value does not parse for the given syntax.
    16 FAIL Computed <percentage> is reified as CSSUnitValue Can't find variable: CSSUnitValue
     16FAIL Computed <percentage> is reified as CSSUnitValue target.computedStyleMap is not a function. (In 'target.computedStyleMap()', 'target.computedStyleMap' is undefined)
    1717FAIL Computed <resolution> is reified as CSSUnitValue The given initial value does not parse for the given syntax.
    1818FAIL Computed <time> is reified as CSSUnitValue The given initial value does not parse for the given syntax.
  • trunk/Source/WebCore/CMakeLists.txt

    r237912 r237981  
    7070    "${WEBCORE_DIR}/css"
    7171    "${WEBCORE_DIR}/css/parser"
     72    "${WEBCORE_DIR}/css/typedom"
    7273    "${WEBCORE_DIR}/cssjit"
    7374    "${WEBCORE_DIR}/dom"
     
    198199    bindings/js
    199200
     201    css/typedom
     202
    200203    html/canvas
    201204    html/shadow
     
    547550    css/CSSNamespaceRule.idl
    548551    css/CSSPaintCallback.idl
     552    css/CSSPaintSize.idl
    549553    css/CSSPageRule.idl
    550554    css/CSSRule.idl
     
    578582    css/StyleSheet.idl
    579583    css/StyleSheetList.idl
     584
     585    css/typedom/CSSNumericValue.idl
     586    css/typedom/CSSStyleValue.idl
     587    css/typedom/CSSUnitValue.idl
     588    css/typedom/CSSUnparsedValue.idl
     589    css/typedom/StylePropertyMapReadOnly.idl
     590
    580591    css/WebKitCSSMatrix.idl
    581592    css/WebKitCSSViewportRule.idl
  • trunk/Source/WebCore/ChangeLog

    r237980 r237981  
     12018-11-07  Justin Michaud  <justin_michaud@apple.com>
     2
     3        CSS Painting API should pass size, arguments and input properties to paint callback
     4        https://bugs.webkit.org/show_bug.cgi?id=191309
     5
     6        Reviewed by Chris Dumez.
     7
     8        Call paint() callback with input properties and arguments. This patch adds a stub for
     9        the CSS Typed OM StylePropertyMapReadOnly, and passes all the arguments as strings without
     10        any syntax checking to the paint callback.
     11
     12        Test: fast/css-custom-paint/properties.html
     13
     14        * CMakeLists.txt:
     15        * DerivedSources.make:
     16        * Sources.txt:
     17        * WebCore.xcodeproj/project.pbxproj:
     18        * bindings/js/JSCSSStyleValueCustom.cpp: Copied from Source/WebCore/css/CSSPaintCallback.h.
     19        (WebCore::toJSNewlyCreated):
     20        (WebCore::toJS):
     21        * bindings/js/WebCoreBuiltinNames.h:
     22        * css/CSSPaintCallback.h:
     23        * css/CSSPaintCallback.idl:
     24        * css/CSSPaintImageValue.cpp:
     25        (WebCore::CSSPaintImageValue::image):
     26        * css/CSSPaintImageValue.h:
     27        * css/CSSPaintSize.h: Copied from Source/WebCore/css/CSSPaintCallback.h.
     28        (WebCore::CSSPaintSize::create):
     29        (WebCore::CSSPaintSize::width const):
     30        (WebCore::CSSPaintSize::height const):
     31        (WebCore::CSSPaintSize::CSSPaintSize):
     32        * css/CSSPaintSize.idl: Copied from Source/WebCore/css/CSSPaintCallback.idl.
     33        * css/parser/CSSPropertyParserHelpers.cpp:
     34        (WebCore::CSSPropertyParserHelpers::consumeCustomPaint):
     35        * css/typedom/CSSNumericValue.h: Copied from Source/WebCore/css/CSSPaintCallback.h.
     36        * css/typedom/CSSNumericValue.idl: Copied from Source/WebCore/css/CSSPaintCallback.idl.
     37        * css/typedom/CSSStyleValue.h: Copied from Source/WebCore/css/CSSPaintCallback.h.
     38        (WebCore::CSSStyleValue::isUnitValue):
     39        (WebCore::CSSStyleValue::isUnparsedValue):
     40        * css/typedom/CSSStyleValue.idl: Copied from Source/WebCore/css/CSSPaintCallback.idl.
     41        * css/typedom/CSSUnitValue.h: Copied from Source/WebCore/css/CSSPaintCallback.h.
     42        * css/typedom/CSSUnitValue.idl: Copied from Source/WebCore/css/CSSPaintCallback.idl.
     43        * css/typedom/CSSUnparsedValue.h: Copied from Source/WebCore/css/CSSPaintCallback.h.
     44        * css/typedom/CSSUnparsedValue.idl: Copied from Source/WebCore/css/CSSPaintCallback.idl.
     45        * css/typedom/StylePropertyMapReadOnly.h: Copied from Source/WebCore/css/CSSPaintCallback.h.
     46        (WebCore::StylePropertyMapReadOnly::create):
     47        (WebCore::StylePropertyMapReadOnly::get):
     48        (WebCore::StylePropertyMapReadOnly::StylePropertyMapReadOnly):
     49        * css/typedom/StylePropertyMapReadOnly.idl: Copied from Source/WebCore/css/CSSPaintCallback.idl.
     50        * platform/graphics/CustomPaintImage.cpp:
     51        (WebCore::CustomPaintImage::CustomPaintImage):
     52        (WebCore::CustomPaintImage::doCustomPaint):
     53        * platform/graphics/CustomPaintImage.h:
     54
    1552018-11-07  Brent Fulgham  <bfulgham@apple.com>
    256
  • trunk/Source/WebCore/DerivedSources.make

    r237912 r237981  
    6969    $(WebCore)/crypto/parameters \
    7070    $(WebCore)/css \
     71    $(WebCore)/css/typedom \
    7172    $(WebCore)/dom \
    7273    $(WebCore)/editing \
     
    460461    $(WebCore)/css/CSSPageRule.idl \
    461462    $(WebCore)/css/CSSPaintCallback.idl \
     463    $(WebCore)/css/CSSPaintSize.idl \
    462464    $(WebCore)/css/CSSRule.idl \
    463465    $(WebCore)/css/CSSRuleList.idl \
     
    490492    $(WebCore)/css/StyleSheet.idl \
    491493    $(WebCore)/css/StyleSheetList.idl \
     494    $(WebCore)/css/typedom/CSSNumericValue.idl \
     495    $(WebCore)/css/typedom/CSSStyleValue.idl \
     496    $(WebCore)/css/typedom/CSSUnitValue.idl \
     497    $(WebCore)/css/typedom/CSSUnparsedValue.idl \
     498    $(WebCore)/css/typedom/StylePropertyMapReadOnly.idl \
    492499    $(WebCore)/css/WebKitCSSMatrix.idl \
    493500    $(WebCore)/css/WebKitCSSViewportRule.idl \
     
    15001507    $(WebCore)/animation \
    15011508    $(WebCore)/css \
     1509    $(WebCore)/css/typedom \
    15021510    $(WebCore)/crypto \
    15031511    $(WebCore)/dom \
  • trunk/Source/WebCore/Sources.txt

    r237976 r237981  
    380380bindings/js/JSCSSRuleListCustom.cpp
    381381bindings/js/JSCSSStyleDeclarationCustom.cpp
     382bindings/js/JSCSSStyleValueCustom.cpp
    382383bindings/js/JSDOMConvertDate.cpp
    383384bindings/js/JSDOMConvertNumbers.cpp
     
    24902491JSCSSMediaRule.cpp
    24912492JSCSSNamespaceRule.cpp
     2493JSCSSNumericValue.cpp
    24922494JSCSSPaintCallback.cpp
     2495JSCSSPaintSize.cpp
     2496JSCSSStyleValue.cpp
     2497JSCSSUnitValue.cpp
     2498JSCSSUnparsedValue.cpp
    24932499JSPaintWorkletGlobalScope.cpp
    24942500JSWorklet.cpp
     
    31593165JSStringCallback.cpp
    31603166JSStyleMedia.cpp
     3167JSStylePropertyMapReadOnly.cpp
    31613168JSStyleSheet.cpp
    31623169JSStyleSheetList.cpp
  • trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj

    r237976 r237981  
    13601360                4B7F9C522183B5E5001CEBA0 /* WorkletConsoleClient.h in Headers */ = {isa = PBXBuildFile; fileRef = 4B7F9C512183B5E5001CEBA0 /* WorkletConsoleClient.h */; };
    13611361                4BAE95B10B2FA9CE00AED8A0 /* EditorDeleteAction.h in Headers */ = {isa = PBXBuildFile; fileRef = 4BAE95B00B2FA9CE00AED8A0 /* EditorDeleteAction.h */; settings = {ATTRIBUTES = (Private, ); }; };
     1362                4BAFD0CB2190EBD600C0AB64 /* CSSPaintSize.h in Headers */ = {isa = PBXBuildFile; fileRef = 4BAFD0CA2190EBD600C0AB64 /* CSSPaintSize.h */; };
     1363                4BAFD0CF2190F9B500C0AB64 /* StylePropertyMapReadOnly.h in Headers */ = {isa = PBXBuildFile; fileRef = 4BAFD0CE2190F9B400C0AB64 /* StylePropertyMapReadOnly.h */; };
     1364                4BAFD0D62192146B00C0AB64 /* CSSStyleValue.h in Headers */ = {isa = PBXBuildFile; fileRef = 4BAFD0D52192146B00C0AB64 /* CSSStyleValue.h */; };
     1365                4BAFD0D921921EA000C0AB64 /* CSSUnparsedValue.h in Headers */ = {isa = PBXBuildFile; fileRef = 4BAFD0D821921EA000C0AB64 /* CSSUnparsedValue.h */; };
     1366                4BAFD0E0219220AB00C0AB64 /* CSSNumericValue.h in Headers */ = {isa = PBXBuildFile; fileRef = 4BAFD0DF219220AB00C0AB64 /* CSSNumericValue.h */; };
     1367                4BAFD0E1219242A000C0AB64 /* CSSUnitValue.h in Headers */ = {isa = PBXBuildFile; fileRef = 4BAFD0DD2192209200C0AB64 /* CSSUnitValue.h */; };
    13621368                4BDA3FFE2151B6F500FD6604 /* DOMCSSCustomPropertyDescriptor.h in Headers */ = {isa = PBXBuildFile; fileRef = 4BDA3FF82151B6F200FD6604 /* DOMCSSCustomPropertyDescriptor.h */; };
    13631369                4BDA3FFF2151B6F500FD6604 /* DOMCSSRegisterCustomProperty.h in Headers */ = {isa = PBXBuildFile; fileRef = 4BDA3FF92151B6F300FD6604 /* DOMCSSRegisterCustomProperty.h */; };
     
    79267932                4B7F9C542183B634001CEBA0 /* WorkletConsoleClient.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = WorkletConsoleClient.cpp; sourceTree = "<group>"; };
    79277933                4BAE95B00B2FA9CE00AED8A0 /* EditorDeleteAction.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = EditorDeleteAction.h; sourceTree = "<group>"; };
     7934                4BAFD0CA2190EBD600C0AB64 /* CSSPaintSize.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = CSSPaintSize.h; sourceTree = "<group>"; };
     7935                4BAFD0CD2190EBE900C0AB64 /* CSSPaintSize.idl */ = {isa = PBXFileReference; lastKnownFileType = text; path = CSSPaintSize.idl; sourceTree = "<group>"; };
     7936                4BAFD0CE2190F9B400C0AB64 /* StylePropertyMapReadOnly.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = StylePropertyMapReadOnly.h; sourceTree = "<group>"; };
     7937                4BAFD0D02190F9C200C0AB64 /* StylePropertyMapReadOnly.idl */ = {isa = PBXFileReference; lastKnownFileType = text; path = StylePropertyMapReadOnly.idl; sourceTree = "<group>"; };
     7938                4BAFD0D32192145600C0AB64 /* CSSStyleValue.idl */ = {isa = PBXFileReference; lastKnownFileType = text; path = CSSStyleValue.idl; sourceTree = "<group>"; };
     7939                4BAFD0D52192146B00C0AB64 /* CSSStyleValue.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = CSSStyleValue.h; sourceTree = "<group>"; };
     7940                4BAFD0D721921E7900C0AB64 /* CSSUnparsedValue.idl */ = {isa = PBXFileReference; lastKnownFileType = text; path = CSSUnparsedValue.idl; sourceTree = "<group>"; };
     7941                4BAFD0D821921EA000C0AB64 /* CSSUnparsedValue.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = CSSUnparsedValue.h; sourceTree = "<group>"; };
     7942                4BAFD0DB2192202200C0AB64 /* CSSNumericValue.idl */ = {isa = PBXFileReference; lastKnownFileType = text; path = CSSNumericValue.idl; sourceTree = "<group>"; };
     7943                4BAFD0DC2192204A00C0AB64 /* CSSUnitValue.idl */ = {isa = PBXFileReference; lastKnownFileType = text; path = CSSUnitValue.idl; sourceTree = "<group>"; };
     7944                4BAFD0DD2192209200C0AB64 /* CSSUnitValue.h */ = {isa = PBXFileReference; explicitFileType = sourcecode.c.h; path = CSSUnitValue.h; sourceTree = "<group>"; };
     7945                4BAFD0DF219220AB00C0AB64 /* CSSNumericValue.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = CSSNumericValue.h; sourceTree = "<group>"; };
     7946                4BAFD0E22192604D00C0AB64 /* JSCSSStyleValueCustom.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = JSCSSStyleValueCustom.cpp; sourceTree = "<group>"; };
    79287947                4BDA3FF52151B6F000FD6604 /* DOMCSSRegisterCustomProperty.idl */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = DOMCSSRegisterCustomProperty.idl; sourceTree = "<group>"; };
    79297948                4BDA3FF72151B6F100FD6604 /* DOMCSSRegisterCustomProperty.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = DOMCSSRegisterCustomProperty.cpp; sourceTree = "<group>"; };
     
    1808918108                        sourceTree = "<group>";
    1809018109                };
     18110                4BAFD0DA21921EAD00C0AB64 /* typedom */ = {
     18111                        isa = PBXGroup;
     18112                        children = (
     18113                                4BAFD0DF219220AB00C0AB64 /* CSSNumericValue.h */,
     18114                                4BAFD0DB2192202200C0AB64 /* CSSNumericValue.idl */,
     18115                                4BAFD0D52192146B00C0AB64 /* CSSStyleValue.h */,
     18116                                4BAFD0D32192145600C0AB64 /* CSSStyleValue.idl */,
     18117                                4BAFD0DD2192209200C0AB64 /* CSSUnitValue.h */,
     18118                                4BAFD0DC2192204A00C0AB64 /* CSSUnitValue.idl */,
     18119                                4BAFD0D821921EA000C0AB64 /* CSSUnparsedValue.h */,
     18120                                4BAFD0D721921E7900C0AB64 /* CSSUnparsedValue.idl */,
     18121                                4BAFD0CE2190F9B400C0AB64 /* StylePropertyMapReadOnly.h */,
     18122                                4BAFD0D02190F9C200C0AB64 /* StylePropertyMapReadOnly.idl */,
     18123                        );
     18124                        path = typedom;
     18125                        sourceTree = "<group>";
     18126                };
    1809118127                4BDEA318217EBB880052DFCD /* worklets */ = {
    1809218128                        isa = PBXGroup;
     
    2026520301                                BC5825F20C0B89380053F1B5 /* JSCSSStyleDeclarationCustom.cpp */,
    2026620302                                AD726FEA16D9F40B003A4E6D /* JSCSSStyleDeclarationCustom.h */,
     20303                                4BAFD0E22192604D00C0AB64 /* JSCSSStyleValueCustom.cpp */,
    2026720304                                BC20FB7E0C0E8E6C00D1447F /* JSDeprecatedCSSOMValueCustom.cpp */,
    2026820305                                49C7BA8C1042F5B10009D447 /* JSDocumentCustom.cpp */,
     
    2607126108                        children = (
    2607226109                                946D37271D6CB2250077084F /* parser */,
     26110                                4BAFD0DA21921EAD00C0AB64 /* typedom */,
    2607326111                                FBD6AF8415EF21D4008B7110 /* BasicShapeFunctions.cpp */,
    2607426112                                FBD6AF8515EF21D4008B7110 /* BasicShapeFunctions.h */,
     
    2617726215                                4B6E876B2176D8A100420E5E /* CSSPaintImageValue.cpp */,
    2617826216                                4B6E87682176D69200420E5E /* CSSPaintImageValue.h */,
     26217                                4BAFD0CA2190EBD600C0AB64 /* CSSPaintSize.h */,
     26218                                4BAFD0CD2190EBE900C0AB64 /* CSSPaintSize.idl */,
    2617926219                                9418278C1D8CAE9500492764 /* CSSPendingSubstitutionValue.cpp */,
    2618026220                                9418278D1D8CAE9500492764 /* CSSPendingSubstitutionValue.h */,
     
    2817228212                                314BE3A11B30F6B700141982 /* CSSNamedImageValue.h in Headers */,
    2817328213                                94E839511DFB2A0E007BC6A7 /* CSSNamespaceRule.h in Headers */,
     28214                                4BAFD0E0219220AB00C0AB64 /* CSSNumericValue.h in Headers */,
    2817428215                                A80E6D000A1989CA007FB8C5 /* CSSPageRule.h in Headers */,
    2817528216                                4B5BDD9B21658A1500DD4262 /* CSSPaintCallback.h in Headers */,
    2817628217                                4B6E87692176D69200420E5E /* CSSPaintImageValue.h in Headers */,
     28218                                4BAFD0CB2190EBD600C0AB64 /* CSSPaintSize.h in Headers */,
    2817728219                                946D372E1D6CB2940077084F /* CSSParser.h in Headers */,
    2817828220                                E4A7995220EE4B1400C19568 /* CSSParserContext.h in Headers */,
     
    2821228254                                A80E6D0C0A1989CA007FB8C5 /* CSSStyleRule.h in Headers */,
    2821328255                                A8EA80070A19516E00A8EF5F /* CSSStyleSheet.h in Headers */,
     28256                                4BAFD0D62192146B00C0AB64 /* CSSStyleValue.h in Headers */,
    2821428257                                94DE5C921D83011D00164F2A /* CSSSupportsParser.h in Headers */,
    2821528258                                FC54D05716A7673100575E4D /* CSSSupportsRule.h in Headers */,
     
    2822128264                                715AD7212050513F00D592DC /* CSSTransition.h in Headers */,
    2822228265                                371F53E90D2704F900ECE0D5 /* CSSUnicodeRangeValue.h in Headers */,
     28266                                4BAFD0E1219242A000C0AB64 /* CSSUnitValue.h in Headers */,
    2822328267                                DD7CDF250A23CF9800069928 /* CSSUnknownRule.h in Headers */,
     28268                                4BAFD0D921921EA000C0AB64 /* CSSUnparsedValue.h in Headers */,
    2822428269                                BC7D8FF01BD03B6400FFE540 /* CSSUnsetValue.h in Headers */,
    2822528270                                A80E6CEE0A1989CA007FB8C5 /* CSSValue.h in Headers */,
     
    3099831043                                E4DACE6A1D12E10B0075980F /* StylePendingResources.h in Headers */,
    3099931044                                A80E6DFC0A199067007FB8C5 /* StyleProperties.h in Headers */,
     31045                                4BAFD0CF2190F9B500C0AB64 /* StylePropertyMapReadOnly.h in Headers */,
    3100031046                                E1B25107152A0BB00069B779 /* StylePropertyShorthand.h in Headers */,
    3100131047                                83C05A5B1A686212007E5DEA /* StylePropertyShorthandFunctions.h in Headers */,
  • trunk/Source/WebCore/bindings/js/JSCSSStyleValueCustom.cpp

    r237980 r237981  
    2424 */
    2525
    26 #pragma once
     26#include "config.h"
     27#include "JSCSSStyleValue.h"
    2728
    2829#if ENABLE(CSS_PAINTING_API)
    2930
    30 #include "ActiveDOMCallback.h"
    31 #include "CallbackResult.h"
    32 #include <wtf/RefCounted.h>
     31#include "JSCSSUnitValue.h"
     32#include "JSCSSUnparsedValue.h"
    3333
    3434namespace WebCore {
    35 class PaintRenderingContext2D;
     35using namespace JSC;
    3636
    37 class CSSPaintCallback : public RefCounted<CSSPaintCallback>, public ActiveDOMCallback {
    38 public:
    39     using ActiveDOMCallback::ActiveDOMCallback;
     37JSValue toJSNewlyCreated(ExecState*, JSDOMGlobalObject* globalObject, Ref<CSSStyleValue>&& value)
     38{
     39    if (value->isUnitValue())
     40        return createWrapper<CSSUnitValue>(globalObject, WTFMove(value));
     41    if (value->isUnparsedValue())
     42        return createWrapper<CSSUnparsedValue>(globalObject, WTFMove(value));
    4043
    41     virtual CallbackResult<void> handleEvent(PaintRenderingContext2D&) = 0;
     44    ASSERT_NOT_REACHED();
     45    return createWrapper<CSSStyleValue>(globalObject, WTFMove(value));
     46}
    4247
    43     virtual ~CSSPaintCallback()
    44     {
    45     }
    46 };
     48JSValue toJS(ExecState* state, JSDOMGlobalObject* globalObject, CSSStyleValue& object)
     49{
     50    return wrap(state, globalObject, object);
     51}
    4752
    4853} // namespace WebCore
     54
    4955#endif
  • trunk/Source/WebCore/bindings/js/WebCoreBuiltinNames.h

    r237912 r237981  
    5050    macro(CredentialsContainer) \
    5151    macro(CSSAnimation) \
     52    macro(CSSNumericValue) \
     53    macro(CSSPaintSize) \
     54    macro(CSSStyleValue) \
    5255    macro(CSSTransition) \
     56    macro(CSSUnitValue) \
     57    macro(CSSUnparsedValue) \
    5358    macro(CustomElementRegistry) \
    5459    macro(Database) \
     
    162167    macro(SpectreGadget) \
    163168    macro(StaticRange) \
     169    macro(StylePropertyMapReadOnly) \
    164170    macro(VRDisplay) \
    165171    macro(VRDisplayCapabilities) \
  • trunk/Source/WebCore/bindings/js/WorkerScriptController.cpp

    r234586 r237981  
    4141#include <JavaScriptCore/ExceptionHelpers.h>
    4242#include <JavaScriptCore/GCActivityCallback.h>
     43#include <JavaScriptCore/JSCInlines.h>
    4344#include <JavaScriptCore/JSLock.h>
    4445#include <JavaScriptCore/PromiseDeferredTimer.h>
  • trunk/Source/WebCore/css/CSSPaintCallback.h

    r237344 r237981  
    2929
    3030#include "ActiveDOMCallback.h"
     31#include "CSSPaintSize.h"
    3132#include "CallbackResult.h"
     33#include "StylePropertyMapReadOnly.h"
    3234#include <wtf/RefCounted.h>
    3335
     
    3941    using ActiveDOMCallback::ActiveDOMCallback;
    4042
    41     virtual CallbackResult<void> handleEvent(PaintRenderingContext2D&) = 0;
     43    virtual CallbackResult<void> handleEvent(PaintRenderingContext2D&, CSSPaintSize&, StylePropertyMapReadOnly&, const Vector<String>&) = 0;
    4244
    4345    virtual ~CSSPaintCallback()
  • trunk/Source/WebCore/css/CSSPaintCallback.idl

    r237344 r237981  
    2727    EnabledAtRuntime=CSSPaintingAPI,
    2828    Conditional=CSS_PAINTING_API,
    29 ] callback CSSPaintCallback = void (PaintRenderingContext2D context);
     29] callback CSSPaintCallback = void (PaintRenderingContext2D context, CSSPaintSize size, StylePropertyMapReadOnly styleMap, sequence<USVString> arguments);
  • trunk/Source/WebCore/css/CSSPaintImageValue.cpp

    r237766 r237981  
    3030#if ENABLE(CSS_PAINTING_API)
    3131
     32#include "CSSVariableData.h"
    3233#include "CustomPaintImage.h"
    3334#include "PaintWorkletGlobalScope.h"
     
    5960    if (!registration)
    6061        return nullptr;
    61     return CustomPaintImage::create(*registration, size);
     62
     63    // FIXME: Check if argument list matches syntax.
     64    Vector<String> arguments;
     65    CSSParserTokenRange localRange(m_arguments->tokenRange());
     66
     67    while (!localRange.atEnd()) {
     68        StringBuilder builder;
     69        while (!localRange.atEnd() && localRange.peek() != CommaToken) {
     70            if (localRange.peek() == CommentToken)
     71                localRange.consume();
     72            else
     73                localRange.consume().serialize(builder);
     74        }
     75        if (!localRange.atEnd())
     76            localRange.consume(); // comma token
     77        arguments.append(builder.toString());
     78    }
     79
     80    return CustomPaintImage::create(*registration, size, renderElement, arguments);
    6281}
    6382
  • trunk/Source/WebCore/css/CSSPaintImageValue.h

    r237276 r237981  
    3232
    3333namespace WebCore {
     34class CSSVariableData;
    3435
    3536class CSSPaintImageValue final : public CSSImageGeneratorValue {
    3637public:
    37     static Ref<CSSPaintImageValue> create(const String& name)
     38    static Ref<CSSPaintImageValue> create(const String& name, Ref<CSSVariableData>&& arguments)
    3839    {
    39         return adoptRef(*new CSSPaintImageValue(name));
     40        return adoptRef(*new CSSPaintImageValue(name, WTFMove(arguments)));
    4041    }
    4142
     
    5455
    5556private:
    56     CSSPaintImageValue(const String& name)
     57    CSSPaintImageValue(const String& name, Ref<CSSVariableData>&& arguments)
    5758        : CSSImageGeneratorValue(PaintImageClass)
    5859        , m_name(name)
     60        , m_arguments(WTFMove(arguments))
    5961    {
    6062    }
    6163
    6264    const String m_name;
     65    Ref<CSSVariableData> m_arguments;
    6366};
    6467
  • trunk/Source/WebCore/css/CSSPaintSize.h

    r237980 r237981  
    2828#if ENABLE(CSS_PAINTING_API)
    2929
    30 #include "ActiveDOMCallback.h"
    31 #include "CallbackResult.h"
    3230#include <wtf/RefCounted.h>
     31#include <wtf/RefPtr.h>
    3332
    3433namespace WebCore {
    35 class PaintRenderingContext2D;
    3634
    37 class CSSPaintCallback : public RefCounted<CSSPaintCallback>, public ActiveDOMCallback {
     35class CSSPaintSize : public RefCounted<CSSPaintSize> {
    3836public:
    39     using ActiveDOMCallback::ActiveDOMCallback;
     37    static Ref<CSSPaintSize> create(double width, double height)
     38    {
     39        return adoptRef(*new CSSPaintSize(width, height));
     40    }
    4041
    41     virtual CallbackResult<void> handleEvent(PaintRenderingContext2D&) = 0;
     42    double width() const { return m_width; }
     43    double height() const { return m_height; }
    4244
    43     virtual ~CSSPaintCallback()
     45private:
     46    CSSPaintSize(double width, double height)
     47        : m_width(width)
     48        , m_height(height)
    4449    {
    4550    }
     51
     52    double m_width;
     53    double m_height;
    4654};
    4755
    4856} // namespace WebCore
     57
    4958#endif
  • trunk/Source/WebCore/css/CSSPaintSize.idl

    r237980 r237981  
    2727    EnabledAtRuntime=CSSPaintingAPI,
    2828    Conditional=CSS_PAINTING_API,
    29 ] callback CSSPaintCallback = void (PaintRenderingContext2D context);
     29    Exposed=PaintWorklet,
     30    ImplementationLacksVTable,
     31] interface CSSPaintSize {
     32    readonly attribute double width;
     33    readonly attribute double height;
     34};
  • trunk/Source/WebCore/css/parser/CSSPropertyParserHelpers.cpp

    r237402 r237981  
    12961296    auto name = args.consumeIncludingWhitespace().value().toString();
    12971297
    1298     // FIXME: should parse arguments.
     1298    if (!args.atEnd() && args.peek() != CommaToken)
     1299        return nullptr;
     1300    if (!args.atEnd())
     1301        args.consume();
     1302
     1303    auto argumentList = CSSVariableData::create(args);
     1304
    12991305    while (!args.atEnd())
    13001306        args.consume();
    13011307
    1302     return CSSPaintImageValue::create(name);
     1308    return CSSPaintImageValue::create(name, WTFMove(argumentList));
    13031309}
    13041310#endif
  • trunk/Source/WebCore/css/typedom/CSSNumericValue.h

    r237980 r237981  
    2828#if ENABLE(CSS_PAINTING_API)
    2929
    30 #include "ActiveDOMCallback.h"
    31 #include "CallbackResult.h"
    32 #include <wtf/RefCounted.h>
     30#include "CSSStyleValue.h"
    3331
    3432namespace WebCore {
    35 class PaintRenderingContext2D;
    3633
    37 class CSSPaintCallback : public RefCounted<CSSPaintCallback>, public ActiveDOMCallback {
    38 public:
    39     using ActiveDOMCallback::ActiveDOMCallback;
     34class CSSNumericValue : public CSSStyleValue {
     35protected:
     36    CSSNumericValue() = default;
     37};
     38} // namespace WebCore
    4039
    41     virtual CallbackResult<void> handleEvent(PaintRenderingContext2D&) = 0;
    42 
    43     virtual ~CSSPaintCallback()
    44     {
    45     }
    46 };
    47 
    48 } // namespace WebCore
    4940#endif
  • trunk/Source/WebCore/css/typedom/CSSNumericValue.idl

    r237980 r237981  
    2424*/
    2525
     26// FIXME: Implement this properly, according to the Typed OM spec.
     27// This is just a stub for the CSS painting API for now. Once the Typed OM
     28// is going to be implemented, please change the runtime flag.
    2629[
    2730    EnabledAtRuntime=CSSPaintingAPI,
    2831    Conditional=CSS_PAINTING_API,
    29 ] callback CSSPaintCallback = void (PaintRenderingContext2D context);
     32    Exposed=(Window,Worker,PaintWorklet),
     33] interface CSSNumericValue : CSSStyleValue {
     34};
  • trunk/Source/WebCore/css/typedom/CSSStyleValue.h

    r237980 r237981  
    2828#if ENABLE(CSS_PAINTING_API)
    2929
    30 #include "ActiveDOMCallback.h"
    31 #include "CallbackResult.h"
    3230#include <wtf/RefCounted.h>
     31#include <wtf/text/WTFString.h>
    3332
    3433namespace WebCore {
    35 class PaintRenderingContext2D;
    3634
    37 class CSSPaintCallback : public RefCounted<CSSPaintCallback>, public ActiveDOMCallback {
     35class CSSStyleValue : public RefCounted<CSSStyleValue> {
    3836public:
    39     using ActiveDOMCallback::ActiveDOMCallback;
     37    virtual ~CSSStyleValue() = default;
     38    virtual String toString() = 0;
    4039
    41     virtual CallbackResult<void> handleEvent(PaintRenderingContext2D&) = 0;
     40    virtual bool isUnitValue() { return false; }
     41    virtual bool isUnparsedValue() { return false; }
    4242
    43     virtual ~CSSPaintCallback()
    44     {
    45     }
     43protected:
     44    CSSStyleValue() = default;
    4645};
    4746
    4847} // namespace WebCore
     48
    4949#endif
  • trunk/Source/WebCore/css/typedom/CSSStyleValue.idl

    r237980 r237981  
    2424*/
    2525
     26// FIXME: Implement this properly, according to the Typed OM spec.
     27// This is just a stub for the CSS painting API for now. Once the Typed OM
     28// is going to be implemented, please change the runtime flag.
    2629[
     30    CustomToJSObject,
    2731    EnabledAtRuntime=CSSPaintingAPI,
    2832    Conditional=CSS_PAINTING_API,
    29 ] callback CSSPaintCallback = void (PaintRenderingContext2D context);
     33    Exposed=(Window,Worker,PaintWorklet),
     34    SkipVTableValidation,
     35] interface CSSStyleValue {
     36    stringifier;
     37};
  • trunk/Source/WebCore/css/typedom/CSSUnitValue.h

    r237980 r237981  
    2828#if ENABLE(CSS_PAINTING_API)
    2929
    30 #include "ActiveDOMCallback.h"
    31 #include "CallbackResult.h"
     30#include "CSSNumericValue.h"
    3231#include <wtf/RefCounted.h>
     32#include <wtf/text/StringConcatenateNumbers.h>
     33#include <wtf/text/WTFString.h>
    3334
    3435namespace WebCore {
    35 class PaintRenderingContext2D;
    3636
    37 class CSSPaintCallback : public RefCounted<CSSPaintCallback>, public ActiveDOMCallback {
     37class CSSUnitValue final : public CSSNumericValue {
    3838public:
    39     using ActiveDOMCallback::ActiveDOMCallback;
     39    static Ref<CSSUnitValue> create(double value, const String& unit)
     40    {
     41        return adoptRef(*new CSSUnitValue(value, unit));
     42    }
    4043
    41     virtual CallbackResult<void> handleEvent(PaintRenderingContext2D&) = 0;
     44    // FIXME: not correct.
     45    String toString() final { return makeString((int) m_value, m_unit); }
    4246
    43     virtual ~CSSPaintCallback()
     47    double value() const { return m_value; }
     48    void setValue(double value) { m_value = value; }
     49    const String& unit() const { return m_unit; }
     50    void setUnit(const String& unit) { m_unit = unit; }
     51
     52private:
     53    CSSUnitValue(double value, const String& unit)
     54        : m_value(value)
     55        , m_unit(unit)
    4456    {
    4557    }
     58
     59    bool isUnitValue() final { return true; }
     60
     61    double m_value;
     62    String m_unit;
    4663};
    4764
    4865} // namespace WebCore
     66
    4967#endif
  • trunk/Source/WebCore/css/typedom/CSSUnitValue.idl

    r237980 r237981  
    2424*/
    2525
     26// FIXME: Implement this properly, according to the Typed OM spec.
     27// This is just a stub for the CSS painting API for now. Once the Typed OM
     28// is going to be implemented, please change the runtime flag.
    2629[
    2730    EnabledAtRuntime=CSSPaintingAPI,
    2831    Conditional=CSS_PAINTING_API,
    29 ] callback CSSPaintCallback = void (PaintRenderingContext2D context);
     32    Exposed=(Window,Worker,PaintWorklet),
     33    Constructor(double value, USVString unit),
     34] interface CSSUnitValue : CSSNumericValue {
     35    attribute double value;
     36    readonly attribute USVString unit;
     37};
  • trunk/Source/WebCore/css/typedom/CSSUnparsedValue.h

    r237980 r237981  
    2828#if ENABLE(CSS_PAINTING_API)
    2929
    30 #include "ActiveDOMCallback.h"
    31 #include "CallbackResult.h"
     30#include "CSSStyleValue.h"
    3231#include <wtf/RefCounted.h>
     32#include <wtf/text/WTFString.h>
    3333
    3434namespace WebCore {
    35 class PaintRenderingContext2D;
    3635
    37 class CSSPaintCallback : public RefCounted<CSSPaintCallback>, public ActiveDOMCallback {
     36class CSSUnparsedValue final : public CSSStyleValue {
    3837public:
    39     using ActiveDOMCallback::ActiveDOMCallback;
     38    static Ref<CSSUnparsedValue> create(const String& serializedValue)
     39    {
     40        return adoptRef(*new CSSUnparsedValue(serializedValue));
     41    }
    4042
    41     virtual CallbackResult<void> handleEvent(PaintRenderingContext2D&) = 0;
     43    String toString() final { return m_serializedValue; }
    4244
    43     virtual ~CSSPaintCallback()
     45private:
     46    explicit CSSUnparsedValue(const String& serializedValue)
     47        : m_serializedValue(serializedValue)
    4448    {
    4549    }
     50
     51    bool isUnparsedValue() final { return true; }
     52
     53    String m_serializedValue;
    4654};
    4755
    4856} // namespace WebCore
     57
    4958#endif
  • trunk/Source/WebCore/css/typedom/CSSUnparsedValue.idl

    r237980 r237981  
    2424*/
    2525
     26// FIXME: Implement this properly, according to the Typed OM spec.
     27// This is just a stub for the CSS painting API for now. Once the Typed OM
     28// is going to be implemented, please change the runtime flag.
     29// FIXME: wrong constructor.
    2630[
    2731    EnabledAtRuntime=CSSPaintingAPI,
    2832    Conditional=CSS_PAINTING_API,
    29 ] callback CSSPaintCallback = void (PaintRenderingContext2D context);
     33    Exposed=(Window,Worker,PaintWorklet),
     34    Constructor(USVString serializedValue),
     35] interface CSSUnparsedValue : CSSStyleValue {
     36};
  • trunk/Source/WebCore/css/typedom/StylePropertyMapReadOnly.h

    r237980 r237981  
    2828#if ENABLE(CSS_PAINTING_API)
    2929
    30 #include "ActiveDOMCallback.h"
    31 #include "CallbackResult.h"
     30#include "CSSStyleValue.h"
     31#include <wtf/HashMap.h>
    3232#include <wtf/RefCounted.h>
     33#include <wtf/text/WTFString.h>
    3334
    3435namespace WebCore {
    35 class PaintRenderingContext2D;
    3636
    37 class CSSPaintCallback : public RefCounted<CSSPaintCallback>, public ActiveDOMCallback {
     37class StylePropertyMapReadOnly : public RefCounted<StylePropertyMapReadOnly> {
    3838public:
    39     using ActiveDOMCallback::ActiveDOMCallback;
     39    static Ref<StylePropertyMapReadOnly> create(HashMap<String, Ref<CSSStyleValue>>&& map)
     40    {
     41        return adoptRef(*new StylePropertyMapReadOnly(WTFMove(map)));
     42    }
    4043
    41     virtual CallbackResult<void> handleEvent(PaintRenderingContext2D&) = 0;
     44    CSSStyleValue* get(String property) const { return m_map.get(property); }
    4245
    43     virtual ~CSSPaintCallback()
     46private:
     47    explicit StylePropertyMapReadOnly(HashMap<String, Ref<CSSStyleValue>>&& map)
     48        : m_map(WTFMove(map))
    4449    {
    4550    }
     51
     52    HashMap<String, Ref<CSSStyleValue>> m_map;
    4653};
    4754
    4855} // namespace WebCore
     56
    4957#endif
  • trunk/Source/WebCore/css/typedom/StylePropertyMapReadOnly.idl

    r237980 r237981  
    2424*/
    2525
     26// FIXME: Implement this properly, according to the Typed OM spec.
     27// This is just a stub for the CSS painting API for now. Once the Typed OM
     28// is going to be implemented, please change the runtime flag.
    2629[
    2730    EnabledAtRuntime=CSSPaintingAPI,
    2831    Conditional=CSS_PAINTING_API,
    29 ] callback CSSPaintCallback = void (PaintRenderingContext2D context);
     32    Exposed=(Window,Worker,PaintWorklet),
     33    ImplementationLacksVTable
     34] interface StylePropertyMapReadOnly {
     35    // FIXME: should be (undefined or CSSStyleValue), not null
     36    CSSStyleValue? get(USVString property);
     37};
  • trunk/Source/WebCore/platform/graphics/CustomPaintImage.cpp

    r237766 r237981  
    2929#if ENABLE(CSS_PAINTING_API)
    3030
     31#include "CSSComputedStyleDeclaration.h"
     32#include "CSSPrimitiveValue.h"
     33#include "CSSPropertyParser.h"
     34#include "CSSUnitValue.h"
     35#include "CSSUnparsedValue.h"
    3136#include "CustomPaintCanvas.h"
    3237#include "GraphicsContext.h"
     
    3540#include "JSCSSPaintCallback.h"
    3641#include "PaintRenderingContext2D.h"
     42#include "RenderElement.h"
    3743
    3844namespace WebCore {
    3945
    40 CustomPaintImage::CustomPaintImage(const PaintWorkletGlobalScope::PaintDefinition& definition, const FloatSize& size)
     46CustomPaintImage::CustomPaintImage(const PaintWorkletGlobalScope::PaintDefinition& definition, const FloatSize& size, RenderElement& element, const Vector<String>& arguments)
    4147    : m_paintCallback(definition.paintCallback.get())
     48    , m_inputProperties(definition.inputProperties)
     49    , m_element(makeWeakPtr(element))
     50    , m_arguments(arguments)
    4251{
    4352    setContainerSize(size);
     
    4857ImageDrawResult CustomPaintImage::doCustomPaint(GraphicsContext& destContext, const FloatSize& destSize)
    4958{
     59    if (!m_element || !m_element->element())
     60        return ImageDrawResult::DidNothing;
     61
     62    ASSERT(!m_element->needsLayout());
     63    ASSERT(!m_element->element()->document().needsStyleRecalc());
     64
    5065    JSCSSPaintCallback& callback = static_cast<JSCSSPaintCallback&>(m_paintCallback.get());
    5166    auto* scriptExecutionContext = callback.scriptExecutionContext();
     
    6075    auto context = contextOrException.releaseReturnValue();
    6176
    62     auto result = m_paintCallback->handleEvent(*context);
     77    HashMap<String, Ref<CSSStyleValue>> propertyValues;
     78    ComputedStyleExtractor extractor(m_element->element());
     79
     80    for (auto& name : m_inputProperties) {
     81        RefPtr<CSSValue> value;
     82        if (isCustomPropertyName(name))
     83            value = extractor.customPropertyValue(name);
     84        else {
     85            CSSPropertyID propertyID = cssPropertyID(name);
     86            if (!propertyID)
     87                return ImageDrawResult::DidNothing;
     88            value = extractor.propertyValue(propertyID, DoNotUpdateLayout);
     89        }
     90
     91        if (!value) {
     92            propertyValues.add(name, CSSUnparsedValue::create(emptyString()));
     93            continue;
     94        }
     95
     96        // FIXME: Properly reify all length values.
     97        if (is<CSSPrimitiveValue>(*value) && downcast<CSSPrimitiveValue>(*value).primitiveType() == CSSPrimitiveValue::CSS_PX)
     98            propertyValues.add(name, CSSUnitValue::create(downcast<CSSPrimitiveValue>(*value).doubleValue(), "px"));
     99        else
     100            propertyValues.add(name, CSSUnparsedValue::create(value->cssText()));
     101    }
     102
     103    auto size = CSSPaintSize::create(destSize.width(), destSize.height());
     104    auto propertyMap = StylePropertyMapReadOnly::create(WTFMove(propertyValues));
     105
     106    auto result = m_paintCallback->handleEvent(*context, size, propertyMap, m_arguments);
    63107    if (result.type() != CallbackResultType::Success)
    64108        return ImageDrawResult::DidNothing;
  • trunk/Source/WebCore/platform/graphics/CustomPaintImage.h

    r237766 r237981  
    3030#include "GeneratedImage.h"
    3131#include "PaintWorkletGlobalScope.h"
     32#include <wtf/WeakPtr.h>
    3233
    3334namespace WebCore {
    3435
    3536class ImageBuffer;
     37class RenderElement;
    3638
    3739class CustomPaintImage final : public GeneratedImage {
    3840public:
    39     static Ref<CustomPaintImage> create(const PaintWorkletGlobalScope::PaintDefinition& definition, const FloatSize& size)
     41    static Ref<CustomPaintImage> create(const PaintWorkletGlobalScope::PaintDefinition& definition, const FloatSize& size, RenderElement& element, const Vector<String>& arguments)
    4042    {
    41         return adoptRef(*new CustomPaintImage(definition, size));
     43        return adoptRef(*new CustomPaintImage(definition, size, element, arguments));
    4244    }
    4345
     
    4648
    4749private:
    48     CustomPaintImage(const PaintWorkletGlobalScope::PaintDefinition&, const FloatSize&);
     50    CustomPaintImage(const PaintWorkletGlobalScope::PaintDefinition&, const FloatSize&, RenderElement&, const Vector<String>& arguments);
    4951
    5052    ImageDrawResult doCustomPaint(GraphicsContext&, const FloatSize&);
     
    5456
    5557    Ref<CSSPaintCallback> m_paintCallback;
     58    Vector<String> m_inputProperties;
     59    WeakPtr<RenderElement> m_element;
     60    Vector<String> m_arguments;
    5661};
    5762
Note: See TracChangeset for help on using the changeset viewer.