Title: [188913] trunk/Source/WebCore
Revision
188913
Author
[email protected]
Date
2015-08-25 10:04:47 -0700 (Tue, 25 Aug 2015)

Log Message

Add support for callback interfaces using other callback names than "handleEvent"
https://bugs.webkit.org/show_bug.cgi?id=148418

Reviewed by Ryosuke Niwa.

Add support for callback interfaces using other callback names than
"handleEvent" [1].

This is a pre-requirement for Bug 148415, as NodeFilter's callback
function name is "acceptNode":
- https://dom.spec.whatwg.org/#interface-nodefilter

[1] https://heycam.github.io/webidl/#es-user-objects

* bindings/js/JSCallbackData.cpp:
(WebCore::JSCallbackData::invokeCallback):
* bindings/js/JSCallbackData.h:
* bindings/js/JSCustomSQLStatementErrorCallback.cpp:
(WebCore::JSSQLStatementErrorCallback::handleEvent):
* bindings/scripts/CodeGeneratorJS.pm:
(GenerateCallbackImplementation):
* bindings/scripts/test/JS/JSTestCallback.cpp:
(WebCore::JSTestCallback::callbackWithNoParam):
(WebCore::JSTestCallback::callbackWithArrayParam):
(WebCore::JSTestCallback::callbackWithSerializedScriptValueParam):
(WebCore::JSTestCallback::callbackWithStringList):
(WebCore::JSTestCallback::callbackWithBoolean):
(WebCore::JSTestCallback::callbackRequiresThisToPass):

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (188912 => 188913)


--- trunk/Source/WebCore/ChangeLog	2015-08-25 17:02:34 UTC (rev 188912)
+++ trunk/Source/WebCore/ChangeLog	2015-08-25 17:04:47 UTC (rev 188913)
@@ -1,5 +1,36 @@
 2015-08-25  Chris Dumez  <[email protected]>
 
+        Add support for callback interfaces using other callback names than "handleEvent"
+        https://bugs.webkit.org/show_bug.cgi?id=148418
+
+        Reviewed by Ryosuke Niwa.
+
+        Add support for callback interfaces using other callback names than
+        "handleEvent" [1].
+
+        This is a pre-requirement for Bug 148415, as NodeFilter's callback
+        function name is "acceptNode":
+        - https://dom.spec.whatwg.org/#interface-nodefilter
+
+        [1] https://heycam.github.io/webidl/#es-user-objects
+
+        * bindings/js/JSCallbackData.cpp:
+        (WebCore::JSCallbackData::invokeCallback):
+        * bindings/js/JSCallbackData.h:
+        * bindings/js/JSCustomSQLStatementErrorCallback.cpp:
+        (WebCore::JSSQLStatementErrorCallback::handleEvent):
+        * bindings/scripts/CodeGeneratorJS.pm:
+        (GenerateCallbackImplementation):
+        * bindings/scripts/test/JS/JSTestCallback.cpp:
+        (WebCore::JSTestCallback::callbackWithNoParam):
+        (WebCore::JSTestCallback::callbackWithArrayParam):
+        (WebCore::JSTestCallback::callbackWithSerializedScriptValueParam):
+        (WebCore::JSTestCallback::callbackWithStringList):
+        (WebCore::JSTestCallback::callbackWithBoolean):
+        (WebCore::JSTestCallback::callbackRequiresThisToPass):
+
+2015-08-25  Chris Dumez  <[email protected]>
+
         Get rid of custom bindings for RequestAnimationFrameCallback.handleEvent()
         https://bugs.webkit.org/show_bug.cgi?id=148417
 

Modified: trunk/Source/WebCore/bindings/js/JSCallbackData.cpp (188912 => 188913)


--- trunk/Source/WebCore/bindings/js/JSCallbackData.cpp	2015-08-25 17:02:34 UTC (rev 188912)
+++ trunk/Source/WebCore/bindings/js/JSCallbackData.cpp	2015-08-25 17:04:47 UTC (rev 188913)
@@ -43,13 +43,13 @@
     delete static_cast<JSCallbackData*>(context);
 }
 
-JSValue JSCallbackData::invokeCallback(MarkedArgumentBuffer& args, bool* raisedException)
+JSValue JSCallbackData::invokeCallback(MarkedArgumentBuffer& args, PropertyName functionName, bool* raisedException)
 {
     ASSERT(callback());
-    return invokeCallback(callback(), args, raisedException);
+    return invokeCallback(callback(), args, functionName, raisedException);
 }
 
-JSValue JSCallbackData::invokeCallback(JSValue thisValue, MarkedArgumentBuffer& args, bool* raisedException)
+JSValue JSCallbackData::invokeCallback(JSValue thisValue, MarkedArgumentBuffer& args, PropertyName functionName, bool* raisedException)
 {
     ASSERT(callback());
     ASSERT(globalObject());
@@ -60,7 +60,7 @@
     CallData callData;
     CallType callType = callback()->methodTable()->getCallData(callback(), callData);
     if (callType == CallTypeNone) {
-        function = callback()->get(exec, Identifier::fromString(exec, "handleEvent"));
+        function = callback()->get(exec, functionName);
         callType = getCallData(function, callData);
         if (callType == CallTypeNone)
             return JSValue();

Modified: trunk/Source/WebCore/bindings/js/JSCallbackData.h (188912 => 188913)


--- trunk/Source/WebCore/bindings/js/JSCallbackData.h	2015-08-25 17:02:34 UTC (rev 188912)
+++ trunk/Source/WebCore/bindings/js/JSCallbackData.h	2015-08-25 17:04:47 UTC (rev 188913)
@@ -66,8 +66,8 @@
     JSC::JSObject* callback() { return m_callback.get(); }
     JSDOMGlobalObject* globalObject() { return m_globalObject.get(); }
     
-    JSC::JSValue invokeCallback(JSC::MarkedArgumentBuffer&, bool* raisedException = 0);
-    JSC::JSValue invokeCallback(JSC::JSValue thisValue, JSC::MarkedArgumentBuffer&, bool* raisedException = 0);
+    JSC::JSValue invokeCallback(JSC::MarkedArgumentBuffer&, JSC::PropertyName functionName, bool* raisedException = nullptr);
+    JSC::JSValue invokeCallback(JSC::JSValue thisValue, JSC::MarkedArgumentBuffer&, JSC::PropertyName functionName, bool* raisedException = nullptr);
 
 private:
     JSC::Strong<JSC::JSObject> m_callback;

Modified: trunk/Source/WebCore/bindings/js/JSCustomSQLStatementErrorCallback.cpp (188912 => 188913)


--- trunk/Source/WebCore/bindings/js/JSCustomSQLStatementErrorCallback.cpp	2015-08-25 17:02:34 UTC (rev 188912)
+++ trunk/Source/WebCore/bindings/js/JSCustomSQLStatementErrorCallback.cpp	2015-08-25 17:04:47 UTC (rev 188913)
@@ -54,7 +54,7 @@
     args.append(toJS(exec, m_data->globalObject(), error));
 
     bool raisedException = false;
-    JSValue result = m_data->invokeCallback(args, &raisedException);
+    JSValue result = m_data->invokeCallback(args, Identifier::fromString(exec, "handleEvent"), &raisedException);
     if (raisedException) {
         // The spec says:
         // "If the error callback returns false, then move on to the next statement..."

Modified: trunk/Source/WebCore/bindings/scripts/CodeGeneratorJS.pm (188912 => 188913)


--- trunk/Source/WebCore/bindings/scripts/CodeGeneratorJS.pm	2015-08-25 17:02:34 UTC (rev 188912)
+++ trunk/Source/WebCore/bindings/scripts/CodeGeneratorJS.pm	2015-08-25 17:04:47 UTC (rev 188913)
@@ -3570,7 +3570,8 @@
             }
 
             AddIncludesForTypeInImpl($function->signature->type);
-            push(@implContent, "\n" . GetNativeTypeForCallbacks($function->signature->type) . " ${className}::" . $function->signature->name . "(");
+            my $functionName = $function->signature->name;
+            push(@implContent, "\n" . GetNativeTypeForCallbacks($function->signature->type) . " ${className}::${functionName}(");
 
             my @args = ();
             my @argsCheck = ();
@@ -3588,10 +3589,7 @@
             push(@implContent, "        return true;\n\n");
             push(@implContent, "    Ref<$className> protect(*this);\n\n");
             push(@implContent, "    JSLockHolder lock(m_data->globalObject()->vm());\n\n");
-            if (@params) {
-                push(@implContent, "    ExecState* exec = m_data->globalObject()->globalExec();\n");
-                push(@implContent, "    UNUSED_PARAM(exec);\n");
-            }
+            push(@implContent, "    ExecState* exec = m_data->globalObject()->globalExec();\n");
             push(@implContent, "    MarkedArgumentBuffer args;\n");
 
             foreach my $param (@params) {
@@ -3600,7 +3598,7 @@
             }
 
             push(@implContent, "\n    bool raisedException = false;\n");
-            push(@implContent, "    m_data->invokeCallback(args, &raisedException);\n");
+            push(@implContent, "    m_data->invokeCallback(args, Identifier::fromString(exec, \"${functionName}\"), &raisedException);\n");
             push(@implContent, "    return !raisedException;\n");
             push(@implContent, "}\n");
         }

Modified: trunk/Source/WebCore/bindings/scripts/test/JS/JSTestCallback.cpp (188912 => 188913)


--- trunk/Source/WebCore/bindings/scripts/test/JS/JSTestCallback.cpp	2015-08-25 17:02:34 UTC (rev 188912)
+++ trunk/Source/WebCore/bindings/scripts/test/JS/JSTestCallback.cpp	2015-08-25 17:04:47 UTC (rev 188913)
@@ -71,10 +71,11 @@
 
     JSLockHolder lock(m_data->globalObject()->vm());
 
+    ExecState* exec = m_data->globalObject()->globalExec();
     MarkedArgumentBuffer args;
 
     bool raisedException = false;
-    m_data->invokeCallback(args, &raisedException);
+    m_data->invokeCallback(args, Identifier::fromString(exec, "callbackWithNoParam"), &raisedException);
     return !raisedException;
 }
 
@@ -88,12 +89,11 @@
     JSLockHolder lock(m_data->globalObject()->vm());
 
     ExecState* exec = m_data->globalObject()->globalExec();
-    UNUSED_PARAM(exec);
     MarkedArgumentBuffer args;
     args.append(toJS(exec, m_data->globalObject(), WTF::getPtr(arrayParam)));
 
     bool raisedException = false;
-    m_data->invokeCallback(args, &raisedException);
+    m_data->invokeCallback(args, Identifier::fromString(exec, "callbackWithArrayParam"), &raisedException);
     return !raisedException;
 }
 
@@ -107,13 +107,12 @@
     JSLockHolder lock(m_data->globalObject()->vm());
 
     ExecState* exec = m_data->globalObject()->globalExec();
-    UNUSED_PARAM(exec);
     MarkedArgumentBuffer args;
     args.append(srzParam ? srzParam->deserialize(exec, castedThis->globalObject(), 0) : jsNull());
     args.append(jsStringWithCache(exec, strArg));
 
     bool raisedException = false;
-    m_data->invokeCallback(args, &raisedException);
+    m_data->invokeCallback(args, Identifier::fromString(exec, "callbackWithSerializedScriptValueParam"), &raisedException);
     return !raisedException;
 }
 
@@ -127,12 +126,11 @@
     JSLockHolder lock(m_data->globalObject()->vm());
 
     ExecState* exec = m_data->globalObject()->globalExec();
-    UNUSED_PARAM(exec);
     MarkedArgumentBuffer args;
     args.append(toJS(exec, m_data->globalObject(), WTF::getPtr(listParam)));
 
     bool raisedException = false;
-    m_data->invokeCallback(args, &raisedException);
+    m_data->invokeCallback(args, Identifier::fromString(exec, "callbackWithStringList"), &raisedException);
     return !raisedException;
 }
 
@@ -146,12 +144,11 @@
     JSLockHolder lock(m_data->globalObject()->vm());
 
     ExecState* exec = m_data->globalObject()->globalExec();
-    UNUSED_PARAM(exec);
     MarkedArgumentBuffer args;
     args.append(jsBoolean(boolParam));
 
     bool raisedException = false;
-    m_data->invokeCallback(args, &raisedException);
+    m_data->invokeCallback(args, Identifier::fromString(exec, "callbackWithBoolean"), &raisedException);
     return !raisedException;
 }
 
@@ -165,13 +162,12 @@
     JSLockHolder lock(m_data->globalObject()->vm());
 
     ExecState* exec = m_data->globalObject()->globalExec();
-    UNUSED_PARAM(exec);
     MarkedArgumentBuffer args;
     args.append(jsNumber(longParam));
     args.append(toJS(exec, m_data->globalObject(), WTF::getPtr(testNodeParam)));
 
     bool raisedException = false;
-    m_data->invokeCallback(args, &raisedException);
+    m_data->invokeCallback(args, Identifier::fromString(exec, "callbackRequiresThisToPass"), &raisedException);
     return !raisedException;
 }
 
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to