2010-04-29 Adam Barth <abarth@webkit.org>
authoreric@webkit.org <eric@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 29 Apr 2010 11:46:33 +0000 (11:46 +0000)
committereric@webkit.org <eric@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 29 Apr 2010 11:46:33 +0000 (11:46 +0000)
        Reviewed by Maciej Stachowiak.

        Remove custom bindings for PopStateEvent.initPopStateEvent
        https://bugs.webkit.org/show_bug.cgi?id=38311

        Our code generation of SerializedScriptValue was slightly buggy, but
        it's easy to fix.  Notice that the conversion to an atomic string is
        handled by the C++ type system and doesn't require logic in the code
        generator.

        * bindings/js/JSPopStateEventCustom.cpp:
        * bindings/scripts/CodeGeneratorJS.pm:
        * bindings/scripts/CodeGeneratorV8.pm:
        * bindings/scripts/test/GObject/WebKitDOMTestObj.cpp:
        (webkit_dom_test_obj_serialized_value):
        * bindings/scripts/test/GObject/WebKitDOMTestObj.h:
        * bindings/scripts/test/JS/JSTestObj.cpp:
        (WebCore::):
        (WebCore::jsTestObjPrototypeFunctionSerializedValue):
        * bindings/scripts/test/JS/JSTestObj.h:
        * bindings/scripts/test/ObjC/DOMTestObj.h:
        * bindings/scripts/test/ObjC/DOMTestObj.mm:
        (-[DOMTestObj serializedValue:]):
        * bindings/scripts/test/TestObj.idl:
        * bindings/scripts/test/V8/V8TestObj.cpp:
        (WebCore::TestObjInternal::serializedValueCallback):
        (WebCore::ConfigureV8TestObjTemplate):
        * bindings/v8/custom/V8PopStateEventCustom.cpp:
        * dom/PopStateEvent.idl:

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

14 files changed:
WebCore/ChangeLog
WebCore/bindings/js/JSPopStateEventCustom.cpp
WebCore/bindings/scripts/CodeGeneratorJS.pm
WebCore/bindings/scripts/CodeGeneratorV8.pm
WebCore/bindings/scripts/test/GObject/WebKitDOMTestObj.cpp
WebCore/bindings/scripts/test/GObject/WebKitDOMTestObj.h
WebCore/bindings/scripts/test/JS/JSTestObj.cpp
WebCore/bindings/scripts/test/JS/JSTestObj.h
WebCore/bindings/scripts/test/ObjC/DOMTestObj.h
WebCore/bindings/scripts/test/ObjC/DOMTestObj.mm
WebCore/bindings/scripts/test/TestObj.idl
WebCore/bindings/scripts/test/V8/V8TestObj.cpp
WebCore/bindings/v8/custom/V8PopStateEventCustom.cpp
WebCore/dom/PopStateEvent.idl

index 28cce14..40aac14 100644 (file)
@@ -1,3 +1,35 @@
+2010-04-29  Adam Barth  <abarth@webkit.org>
+
+        Reviewed by Maciej Stachowiak.
+
+        Remove custom bindings for PopStateEvent.initPopStateEvent
+        https://bugs.webkit.org/show_bug.cgi?id=38311
+
+        Our code generation of SerializedScriptValue was slightly buggy, but
+        it's easy to fix.  Notice that the conversion to an atomic string is
+        handled by the C++ type system and doesn't require logic in the code
+        generator.
+
+        * bindings/js/JSPopStateEventCustom.cpp:
+        * bindings/scripts/CodeGeneratorJS.pm:
+        * bindings/scripts/CodeGeneratorV8.pm:
+        * bindings/scripts/test/GObject/WebKitDOMTestObj.cpp:
+        (webkit_dom_test_obj_serialized_value):
+        * bindings/scripts/test/GObject/WebKitDOMTestObj.h:
+        * bindings/scripts/test/JS/JSTestObj.cpp:
+        (WebCore::):
+        (WebCore::jsTestObjPrototypeFunctionSerializedValue):
+        * bindings/scripts/test/JS/JSTestObj.h:
+        * bindings/scripts/test/ObjC/DOMTestObj.h:
+        * bindings/scripts/test/ObjC/DOMTestObj.mm:
+        (-[DOMTestObj serializedValue:]):
+        * bindings/scripts/test/TestObj.idl:
+        * bindings/scripts/test/V8/V8TestObj.cpp:
+        (WebCore::TestObjInternal::serializedValueCallback):
+        (WebCore::ConfigureV8TestObjTemplate):
+        * bindings/v8/custom/V8PopStateEventCustom.cpp:
+        * dom/PopStateEvent.idl:
+
 2010-04-29  Kent Tamura  <tkent@chromium.org>
 
         Reviewed by Darin Adler.
index ce430ab..14fc9d9 100644 (file)
@@ -33,16 +33,6 @@ using namespace JSC;
 
 namespace WebCore {
 
-JSValue JSPopStateEvent::initPopStateEvent(ExecState* exec, const ArgList& args)
-{
-    const UString& typeArg = args.at(0).toString(exec);
-    bool canBubbleArg = args.at(1).toBoolean(exec);
-    bool cancelableArg = args.at(2).toBoolean(exec);
-    RefPtr<SerializedScriptValue> stateObjectArg = SerializedScriptValue::create(exec, args.at(3));
-    
-    PopStateEvent* event = static_cast<PopStateEvent*>(impl());
-    event->initPopStateEvent(ustringToAtomicString(typeArg), canBubbleArg, cancelableArg, stateObjectArg.release());
-    return jsUndefined();
-}
+// FIXME: Remove this file.
 
 } // namespace WebCore
index 228e15a..c3a2e80 100644 (file)
@@ -1952,6 +1952,7 @@ my %nativeType = (
     "DOMString" => "const String&",
     "DOMObject" => "ScriptValue",
     "NodeFilter" => "RefPtr<NodeFilter>",
+    "SerializedScriptValue" => "RefPtr<SerializedScriptValue>",
     "SVGAngle" => "SVGAngle",
     "SVGLength" => "SVGLength",
     "SVGMatrix" => "AffineTransform",
index 0d121ae..62b8b23 100644 (file)
@@ -1224,7 +1224,8 @@ END
 
         if ($parameter->type eq "SerializedScriptValue") {
             push(@implContentDecls, "SerializedScriptValue::create(args[$paramIndex], ${parameterName}DidThrow);\n");
-            push(@implContentDecls, "    if (${parameterName}DidThrow)\n    return v8::Undefined();\n");
+            push(@implContentDecls, "    if (${parameterName}DidThrow)\n");
+            push(@implContentDecls, "        return v8::Undefined();\n");
         } else {
             push(@implContentDecls, JSValueToNative($parameter, "args[$paramIndex]",
                                                     BasicTypeCanFailConversion($parameter) ?  "${parameterName}Ok" : undef) . ";\n");
@@ -2568,6 +2569,8 @@ sub GetNativeType
     # temporary hack
     return "RefPtr<NodeFilter>" if $type eq "NodeFilter";
 
+    return "RefPtr<SerializedScriptValue>" if $type eq "SerializedScriptValue";
+
     # necessary as resolvers could be constructed on fly.
     return "RefPtr<XPathNSResolver>" if $type eq "XPathNSResolver";
 
@@ -2766,6 +2769,7 @@ sub RequiresCustomSignature
 }
 
 
+# FIXME: Sort this array.
 my %non_wrapper_types = (
     'float' => 1,
     'double' => 1,
@@ -2780,6 +2784,7 @@ my %non_wrapper_types = (
     'unsigned long long' => 1,
     'DOMString' => 1,
     'CompareHow' => 1,
+    'SerializedScriptValue' => 1,
     'SVGAngle' => 1,
     'SVGRect' => 1,
     'SVGPoint' => 1,
index 4abf8a0..632283f 100644 (file)
@@ -27,6 +27,8 @@
 #include "TestObj.h"
 #include "WebKitDOMBinding.h"
 #include "gobject/ConvertToUTF8String.h"
+#include "webkit/WebKitDOMSerializedScriptValue.h"
+#include "webkit/WebKitDOMSerializedScriptValuePrivate.h"
 #include "webkit/WebKitDOMTestObj.h"
 #include "webkit/WebKitDOMTestObjPrivate.h"
 #include "webkit/WebKitDOMlog.h"
@@ -124,6 +126,18 @@ webkit_dom_test_obj_obj_method_with_args (WebKitDOMTestObj *self, glong int_arg,
 }
 
 void
+webkit_dom_test_obj_serialized_value (WebKitDOMTestObj *self, WebKitDOMSerializedScriptValue*  serialized_arg)
+{
+    g_return_if_fail (self);
+    WebCore::TestObj * item = WebKit::core(self);
+    g_return_if_fail (serialized_arg);
+    WebCore::SerializedScriptValue * _g_serialized_arg = WebKit::core(serialized_arg);
+    g_return_if_fail (_g_serialized_arg);
+    item->serializedValue(_g_serialized_arg);
+
+}
+
+void
 webkit_dom_test_obj_method_with_exception (WebKitDOMTestObj *self, GError **error)
 {
     g_return_if_fail (self);
index e5e769f..8ea5b32 100644 (file)
@@ -65,6 +65,9 @@ WEBKIT_API WebKitDOMTestObj*
 webkit_dom_test_obj_obj_method_with_args (WebKitDOMTestObj *self, glong int_arg, gchar*  str_arg, WebKitDOMTestObj*  obj_arg);
 
 WEBKIT_API void
+webkit_dom_test_obj_serialized_value (WebKitDOMTestObj *self, WebKitDOMSerializedScriptValue*  serialized_arg);
+
+WEBKIT_API void
 webkit_dom_test_obj_method_with_exception (WebKitDOMTestObj *self, GError **error);
 
 
index dd08ec0..1493692 100644 (file)
@@ -26,6 +26,7 @@
 #include "JSlog.h"
 #include "KURL.h"
 #include "ScriptCallStack.h"
+#include "SerializedScriptValue.h"
 #include "TestObj.h"
 #include <runtime/Error.h>
 #include <runtime/JSNumberCell.h>
@@ -131,7 +132,7 @@ bool JSTestObjConstructor::getOwnPropertyDescriptor(ExecState* exec, const Ident
 #define THUNK_GENERATOR(generator)
 #endif
 
-static const HashTableValue JSTestObjPrototypeTableValues[25] =
+static const HashTableValue JSTestObjPrototypeTableValues[26] =
 {
     { "voidMethod", DontDelete|Function, (intptr_t)static_cast<NativeFunction>(jsTestObjPrototypeFunctionVoidMethod), (intptr_t)0 THUNK_GENERATOR(0) },
     { "voidMethodWithArgs", DontDelete|Function, (intptr_t)static_cast<NativeFunction>(jsTestObjPrototypeFunctionVoidMethodWithArgs), (intptr_t)3 THUNK_GENERATOR(0) },
@@ -139,6 +140,7 @@ static const HashTableValue JSTestObjPrototypeTableValues[25] =
     { "intMethodWithArgs", DontDelete|Function, (intptr_t)static_cast<NativeFunction>(jsTestObjPrototypeFunctionIntMethodWithArgs), (intptr_t)3 THUNK_GENERATOR(0) },
     { "objMethod", DontDelete|Function, (intptr_t)static_cast<NativeFunction>(jsTestObjPrototypeFunctionObjMethod), (intptr_t)0 THUNK_GENERATOR(0) },
     { "objMethodWithArgs", DontDelete|Function, (intptr_t)static_cast<NativeFunction>(jsTestObjPrototypeFunctionObjMethodWithArgs), (intptr_t)3 THUNK_GENERATOR(0) },
+    { "serializedValue", DontDelete|Function, (intptr_t)static_cast<NativeFunction>(jsTestObjPrototypeFunctionSerializedValue), (intptr_t)1 THUNK_GENERATOR(0) },
     { "methodWithException", DontDelete|Function, (intptr_t)static_cast<NativeFunction>(jsTestObjPrototypeFunctionMethodWithException), (intptr_t)0 THUNK_GENERATOR(0) },
     { "customMethod", DontDelete|Function, (intptr_t)static_cast<NativeFunction>(jsTestObjPrototypeFunctionCustomMethod), (intptr_t)0 THUNK_GENERATOR(0) },
     { "customMethodWithArgs", DontDelete|Function, (intptr_t)static_cast<NativeFunction>(jsTestObjPrototypeFunctionCustomMethodWithArgs), (intptr_t)3 THUNK_GENERATOR(0) },
@@ -479,6 +481,19 @@ JSValue JSC_HOST_CALL jsTestObjPrototypeFunctionObjMethodWithArgs(ExecState* exe
     return result;
 }
 
+JSValue JSC_HOST_CALL jsTestObjPrototypeFunctionSerializedValue(ExecState* exec, JSObject*, JSValue thisValue, const ArgList& args)
+{
+    UNUSED_PARAM(args);
+    if (!thisValue.inherits(&JSTestObj::s_info))
+        return throwError(exec, TypeError);
+    JSTestObj* castedThisObj = static_cast<JSTestObj*>(asObject(thisValue));
+    TestObj* imp = static_cast<TestObj*>(castedThisObj->impl());
+    RefPtr<SerializedScriptValue> serializedArg = SerializedScriptValue::create(exec, args.at(0));
+
+    imp->serializedValue(serializedArg);
+    return jsUndefined();
+}
+
 JSValue JSC_HOST_CALL jsTestObjPrototypeFunctionMethodWithException(ExecState* exec, JSObject*, JSValue thisValue, const ArgList& args)
 {
     UNUSED_PARAM(args);
index 150e0bd..704622f 100644 (file)
@@ -91,6 +91,7 @@ JSC::JSValue JSC_HOST_CALL jsTestObjPrototypeFunctionIntMethod(JSC::ExecState*,
 JSC::JSValue JSC_HOST_CALL jsTestObjPrototypeFunctionIntMethodWithArgs(JSC::ExecState*, JSC::JSObject*, JSC::JSValue, const JSC::ArgList&);
 JSC::JSValue JSC_HOST_CALL jsTestObjPrototypeFunctionObjMethod(JSC::ExecState*, JSC::JSObject*, JSC::JSValue, const JSC::ArgList&);
 JSC::JSValue JSC_HOST_CALL jsTestObjPrototypeFunctionObjMethodWithArgs(JSC::ExecState*, JSC::JSObject*, JSC::JSValue, const JSC::ArgList&);
+JSC::JSValue JSC_HOST_CALL jsTestObjPrototypeFunctionSerializedValue(JSC::ExecState*, JSC::JSObject*, JSC::JSValue, const JSC::ArgList&);
 JSC::JSValue JSC_HOST_CALL jsTestObjPrototypeFunctionMethodWithException(JSC::ExecState*, JSC::JSObject*, JSC::JSValue, const JSC::ArgList&);
 JSC::JSValue JSC_HOST_CALL jsTestObjPrototypeFunctionCustomMethod(JSC::ExecState*, JSC::JSObject*, JSC::JSValue, const JSC::ArgList&);
 JSC::JSValue JSC_HOST_CALL jsTestObjPrototypeFunctionCustomMethodWithArgs(JSC::ExecState*, JSC::JSObject*, JSC::JSValue, const JSC::ArgList&);
index 9cb6121..d13ff52 100644 (file)
@@ -61,6 +61,7 @@
 - (int)intMethodWithArgs:(int)intArg strArg:(NSString *)strArg objArg:(DOMTestObj *)objArg;
 - (DOMTestObj *)objMethod;
 - (DOMTestObj *)objMethodWithArgs:(int)intArg strArg:(NSString *)strArg objArg:(DOMTestObj *)objArg;
+- (void)serializedValue:(NSString *)serializedArg;
 - (void)methodWithException;
 - (void)customMethod;
 - (void)customMethodWithArgs:(int)intArg strArg:(NSString *)strArg objArg:(DOMTestObj *)objArg;
index c653d7d..7257469 100644 (file)
@@ -41,6 +41,7 @@
 #import "ExceptionHandlers.h"
 #import "KURL.h"
 #import "ObjCEventListener.h"
+#import "SerializedScriptValue.h"
 #import "TestObj.h"
 #import "ThreadCheck.h"
 #import "WebCoreObjCExtras.h"
     return kit(WTF::getPtr(IMPL->objMethodWithArgs(intArg, strArg, core(objArg))));
 }
 
+- (void)serializedValue:(NSString *)serializedArg
+{
+    IMPL->serializedValue(WebCore::SerializedScriptValue::create(WebCore::String(serializedArg)));
+}
+
 - (void)methodWithException
 {
     WebCore::ExceptionCode ec = 0;
index 932e8a7..5f9ece3 100644 (file)
@@ -48,6 +48,8 @@ module test {
         TestObj objMethod();
         TestObj objMethodWithArgs(in long intArg, in DOMString strArg, in TestObj objArg);
 
+        void serializedValue(in SerializedScriptValue serializedArg);
+
         // Exceptions
         void    methodWithException() raises(DOMException);
         attribute long attrWithException raises(DOMException);
index ac72a3c..f5a1cc6 100644 (file)
@@ -24,6 +24,7 @@
 #include "ExceptionCode.h"
 #include "RuntimeEnabledFeatures.h"
 #include "ScriptCallStack.h"
+#include "SerializedScriptValue.h"
 #include "V8Binding.h"
 #include "V8BindingState.h"
 #include "V8DOMWrapper.h"
@@ -251,6 +252,18 @@ static v8::Handle<v8::Value> objMethodWithArgsCallback(const v8::Arguments& args
     return toV8(imp->objMethodWithArgs(intArg, strArg, objArg));
 }
 
+static v8::Handle<v8::Value> serializedValueCallback(const v8::Arguments& args)
+{
+    INC_STATS("DOM.TestObj.serializedValue");
+    TestObj* imp = V8TestObj::toNative(args.Holder());
+    bool serializedArgDidThrow = false;
+    RefPtr<SerializedScriptValue> serializedArg = SerializedScriptValue::create(args[0], serializedArgDidThrow);
+    if (serializedArgDidThrow)
+        return v8::Undefined();
+    imp->serializedValue(serializedArg);
+    return v8::Handle<v8::Value>();
+}
+
 static v8::Handle<v8::Value> methodWithExceptionCallback(const v8::Arguments& args)
 {
     INC_STATS("DOM.TestObj.methodWithException");
@@ -575,6 +588,7 @@ static const BatchedCallback TestObjCallbacks[] = {
     {"voidMethod", TestObjInternal::voidMethodCallback},
     {"intMethod", TestObjInternal::intMethodCallback},
     {"objMethod", TestObjInternal::objMethodCallback},
+    {"serializedValue", TestObjInternal::serializedValueCallback},
     {"methodWithException", TestObjInternal::methodWithExceptionCallback},
     {"customMethod", V8TestObj::customMethodCallback},
     {"customMethodWithArgs", V8TestObj::customMethodWithArgsCallback},
index cdb160d..51a57c0 100644 (file)
 
 namespace WebCore {
 
-v8::Handle<v8::Value> V8PopStateEvent::initPopStateEventCallback(const v8::Arguments& args)
-{
-    INC_STATS("DOM.PopStateEvent.initPopStateEvent");
-
-    String typeArg = v8ValueToWebCoreString(args[0]);
-    bool canBubbleArg = args[1]->BooleanValue();
-    bool cancelableArg = args[2]->BooleanValue();
-
-    bool didThrow = false;
-    RefPtr<SerializedScriptValue> stateArg = SerializedScriptValue::create(args[3], didThrow);
-    if (didThrow)
-        return v8::Undefined();
-
-    PopStateEvent* event = V8PopStateEvent::toNative(args.Holder());
-    event->initPopStateEvent(typeArg, canBubbleArg, cancelableArg, stateArg.release());
-
-    return v8::Undefined();
-}
-
 v8::Handle<v8::Value> V8PopStateEvent::stateAccessorGetter(v8::Local<v8::String> name, const v8::AccessorInfo& info)
 {
     INC_STATS("DOM.PopStateEvent.state");
index f9c9a71..28da9e6 100644 (file)
 module events {
 
     interface PopStateEvent : Event {
-        [Custom] void initPopStateEvent(in DOMString typeArg, 
+        void initPopStateEvent(in DOMString typeArg, 
                                in boolean canBubbleArg, 
                                in boolean cancelableArg, 
-                               in any stateArg);
-                               
+                               in SerializedScriptValue stateArg);
+
         readonly attribute [V8CustomGetter] any state;
     };