Title: [236857] trunk/Source/WebCore
Revision
236857
Author
[email protected]
Date
2018-10-04 16:18:12 -0700 (Thu, 04 Oct 2018)

Log Message

Bindings generator should support static attributes that are interfaces with CallWith
https://bugs.webkit.org/show_bug.cgi?id=190292

Patch by Justin Michaud <[email protected]> on 2018-10-04
Reviewed by Chris Dumez.

Add support for static attributes that support callWith to the bindings generator. This
is needed for CSS.paintWorklet.

* bindings/scripts/CodeGeneratorJS.pm:
(GenerateAttributeGetterBodyDefinition):
* bindings/scripts/test/JS/JSTestObj.cpp:
(WebCore::jsTestObjConstructorTestStaticReadonlyObjGetter):
(WebCore::jsTestObjConstructorTestStaticReadonlyObj):
* bindings/scripts/test/TestObj.idl:

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (236856 => 236857)


--- trunk/Source/WebCore/ChangeLog	2018-10-04 22:40:45 UTC (rev 236856)
+++ trunk/Source/WebCore/ChangeLog	2018-10-04 23:18:12 UTC (rev 236857)
@@ -1,3 +1,20 @@
+2018-10-04  Justin Michaud  <[email protected]>
+
+        Bindings generator should support static attributes that are interfaces with CallWith
+        https://bugs.webkit.org/show_bug.cgi?id=190292
+
+        Reviewed by Chris Dumez.
+
+        Add support for static attributes that support callWith to the bindings generator. This
+        is needed for CSS.paintWorklet.
+
+        * bindings/scripts/CodeGeneratorJS.pm:
+        (GenerateAttributeGetterBodyDefinition):
+        * bindings/scripts/test/JS/JSTestObj.cpp:
+        (WebCore::jsTestObjConstructorTestStaticReadonlyObjGetter):
+        (WebCore::jsTestObjConstructorTestStaticReadonlyObj):
+        * bindings/scripts/test/TestObj.idl:
+
 2018-10-04  Matt Lewis  <[email protected]>
 
         Unreviewed, rolling out r236730.

Modified: trunk/Source/WebCore/bindings/scripts/CodeGeneratorJS.pm (236856 => 236857)


--- trunk/Source/WebCore/bindings/scripts/CodeGeneratorJS.pm	2018-10-04 22:40:45 UTC (rev 236856)
+++ trunk/Source/WebCore/bindings/scripts/CodeGeneratorJS.pm	2018-10-04 23:18:12 UTC (rev 236857)
@@ -4818,8 +4818,9 @@
         AddAdditionalArgumentsForImplementationCall(\@arguments, $interface, $attribute, "impl", "state", "thisObject");
         
         unshift(@arguments, @callWithArgs);
-        
-        my $toJSExpression = NativeToJSValueUsingReferences($attribute, $interface, "${functionName}(" . join(", ", @arguments) . ")", "*thisObject.globalObject()");
+
+        my $globalObjectReference = $attribute->isStatic ? "*jsCast<JSDOMGlobalObject*>(state.lexicalGlobalObject())" : "*thisObject.globalObject()";
+        my $toJSExpression = NativeToJSValueUsingReferences($attribute, $interface, "${functionName}(" . join(", ", @arguments) . ")", $globalObjectReference);
         push(@$outputArray, "    auto& impl = thisObject.wrapped();\n") unless $attribute->isStatic or $attribute->isMapLike;
 
         if (!IsReadonly($attribute)) {

Modified: trunk/Source/WebCore/bindings/scripts/test/JS/JSTestObj.cpp (236856 => 236857)


--- trunk/Source/WebCore/bindings/scripts/test/JS/JSTestObj.cpp	2018-10-04 22:40:45 UTC (rev 236856)
+++ trunk/Source/WebCore/bindings/scripts/test/JS/JSTestObj.cpp	2018-10-04 23:18:12 UTC (rev 236857)
@@ -1601,6 +1601,7 @@
 JSC::EncodedJSValue jsTestObjConstructorStaticStringAttr(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName);
 bool setJSTestObjConstructorStaticStringAttr(JSC::ExecState*, JSC::EncodedJSValue, JSC::EncodedJSValue);
 JSC::EncodedJSValue jsTestObjConstructorTestSubObj(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName);
+JSC::EncodedJSValue jsTestObjConstructorTestStaticReadonlyObj(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName);
 JSC::EncodedJSValue jsTestObjEnumAttr(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName);
 bool setJSTestObjEnumAttr(JSC::ExecState*, JSC::EncodedJSValue, JSC::EncodedJSValue);
 JSC::EncodedJSValue jsTestObjByteAttr(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName);
@@ -1886,6 +1887,7 @@
     { "staticReadOnlyLongAttr", static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsTestObjConstructorStaticReadOnlyLongAttr), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) } },
     { "staticStringAttr", static_cast<unsigned>(0), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsTestObjConstructorStaticStringAttr), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(setJSTestObjConstructorStaticStringAttr) } },
     { "TestSubObj", static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsTestObjConstructorTestSubObj), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) } },
+    { "testStaticReadonlyObj", static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsTestObjConstructorTestStaticReadonlyObj), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) } },
 #if ENABLE(TEST_FEATURE)
     { "enabledAtRuntimeAttributeStatic", static_cast<unsigned>(0), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsTestObjConstructorEnabledAtRuntimeAttributeStatic), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(setJSTestObjConstructorEnabledAtRuntimeAttributeStatic) } },
 #else
@@ -2649,6 +2651,24 @@
     return IDLAttribute<JSTestObj>::getStatic<jsTestObjConstructorTestSubObjGetter>(*state, thisValue, "TestSubObj");
 }
 
+static inline JSValue jsTestObjConstructorTestStaticReadonlyObjGetter(ExecState& state, ThrowScope& throwScope)
+{
+    UNUSED_PARAM(throwScope);
+    UNUSED_PARAM(state);
+    auto* context = jsCast<JSDOMGlobalObject*>(state.lexicalGlobalObject())->scriptExecutionContext();
+    if (UNLIKELY(!context))
+        return jsUndefined();
+    ASSERT(context->isDocument());
+    auto& document = downcast<Document>(*context);
+    JSValue result = toJS<IDLInterface<TestObj>>(state, *jsCast<JSDOMGlobalObject*>(state.lexicalGlobalObject()), throwScope, TestObj::testStaticReadonlyObj(document));
+    return result;
+}
+
+EncodedJSValue jsTestObjConstructorTestStaticReadonlyObj(ExecState* state, EncodedJSValue thisValue, PropertyName)
+{
+    return IDLAttribute<JSTestObj>::getStatic<jsTestObjConstructorTestStaticReadonlyObjGetter>(*state, thisValue, "testStaticReadonlyObj");
+}
+
 static inline JSValue jsTestObjEnumAttrGetter(ExecState& state, JSTestObj& thisObject, ThrowScope& throwScope)
 {
     UNUSED_PARAM(throwScope);

Modified: trunk/Source/WebCore/bindings/scripts/test/TestObj.idl (236856 => 236857)


--- trunk/Source/WebCore/bindings/scripts/test/TestObj.idl	2018-10-04 22:40:45 UTC (rev 236856)
+++ trunk/Source/WebCore/bindings/scripts/test/TestObj.idl	2018-10-04 23:18:12 UTC (rev 236857)
@@ -58,6 +58,7 @@
     static readonly attribute long     staticReadOnlyLongAttr;
     static attribute DOMString         staticStringAttr;
     static readonly attribute TestSubObjConstructor TestSubObj;
+    [CallWith=Document] static readonly attribute TestObj testStaticReadonlyObj;
     attribute TestEnumType enumAttr;
     attribute byte byteAttr;
     attribute octet octetAttr;
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to