[SCM] WebKit Debian packaging branch, debian/experimental, updated. upstream/1.3.3-9427-gc2be6fc

kinuko at chromium.org kinuko at chromium.org
Wed Dec 22 13:01:16 UTC 2010


The following commit has been merged in the debian/experimental branch:
commit 2c08aad674608fcddf16e7cb4ec16c81157fd429
Author: kinuko at chromium.org <kinuko at chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date:   Sat Sep 4 04:25:14 2010 +0000

    2010-09-03  Kinuko Yasuda  <kinuko at chromium.org>
    
            Reviewed by Darin Adler.
    
            V8/JS bindings should not perform type checks if the parameter has Callback attribute
            https://bugs.webkit.org/show_bug.cgi?id=45143
    
            No new tests, should not affect existing idls.
    
            * bindings/scripts/CodeGeneratorJS.pm:
            * bindings/scripts/CodeGeneratorV8.pm:
            * bindings/scripts/test/JS/JSTestObj.cpp:
            (WebCore::jsTestObjPrototypeFunctionOverloadedMethod5):
            (WebCore::jsTestObjPrototypeFunctionOverloadedMethod):
            * bindings/scripts/test/TestObj.idl:
            * bindings/scripts/test/V8/V8TestObj.cpp:
            (WebCore::TestObjInternal::overloadedMethod5Callback):
            (WebCore::TestObjInternal::overloadedMethodCallback):
    
    
    git-svn-id: http://svn.webkit.org/repository/webkit/trunk@66791 268f45cc-cd09-0410-ab3c-d52691b4dbfc

diff --git a/WebCore/ChangeLog b/WebCore/ChangeLog
index e317fa3..e3d72e0 100644
--- a/WebCore/ChangeLog
+++ b/WebCore/ChangeLog
@@ -1,3 +1,22 @@
+2010-09-03  Kinuko Yasuda  <kinuko at chromium.org>
+
+        Reviewed by Darin Adler.
+
+        V8/JS bindings should not perform type checks if the parameter has Callback attribute
+        https://bugs.webkit.org/show_bug.cgi?id=45143
+
+        No new tests, should not affect existing idls.
+
+        * bindings/scripts/CodeGeneratorJS.pm:
+        * bindings/scripts/CodeGeneratorV8.pm:
+        * bindings/scripts/test/JS/JSTestObj.cpp:
+        (WebCore::jsTestObjPrototypeFunctionOverloadedMethod5):
+        (WebCore::jsTestObjPrototypeFunctionOverloadedMethod):
+        * bindings/scripts/test/TestObj.idl:
+        * bindings/scripts/test/V8/V8TestObj.cpp:
+        (WebCore::TestObjInternal::overloadedMethod5Callback):
+        (WebCore::TestObjInternal::overloadedMethodCallback):
+
 2010-09-03  Kenneth Russell  <kbr at google.com>
 
         Unreviewed, Chromium build fix. Fix breakage on Windows after
diff --git a/WebCore/bindings/scripts/CodeGeneratorJS.pm b/WebCore/bindings/scripts/CodeGeneratorJS.pm
index 84e3919..1a114a4 100644
--- a/WebCore/bindings/scripts/CodeGeneratorJS.pm
+++ b/WebCore/bindings/scripts/CodeGeneratorJS.pm
@@ -1134,9 +1134,14 @@ sub GenerateParametersCheckExpression
         # For DOMString, Null, Undefined and any Object are accepted too, as
         # these are acceptable values for a DOMString argument (any Object can
         # be converted to a string via .toString).
-        push(@andExpression, "(${value}.isNull() || ${value}.isUndefined() || ${value}.isString() || ${value}.isObject())") if $codeGenerator->IsStringType($type);
-        push(@andExpression, "(${value}.isNull() || (${value}.isObject() && asObject(${value})->inherits(&JS${type}::s_info)))") unless IsNativeType($type);
-
+        if ($codeGenerator->IsStringType($type)) {
+            push(@andExpression, "(${value}.isNull() || ${value}.isUndefined() || ${value}.isString() || ${value}.isObject())");
+        } elsif ($parameter->extendedAttributes->{"Callback"}) {
+            # For Callbacks only checks if the value is null or object.
+            push(@andExpression, "(${value}.isNull() || ${value}.isObject())");
+        } elsif (!IsNativeType($type)) {
+            push(@andExpression, "(${value}.isNull() || (${value}.isObject() && asObject(${value})->inherits(&JS${type}::s_info)))");
+        }
         $parameterIndex++;
     }
     my $res = join(" && ", @andExpression);
diff --git a/WebCore/bindings/scripts/CodeGeneratorV8.pm b/WebCore/bindings/scripts/CodeGeneratorV8.pm
index 028169f..eca7301 100644
--- a/WebCore/bindings/scripts/CodeGeneratorV8.pm
+++ b/WebCore/bindings/scripts/CodeGeneratorV8.pm
@@ -1031,8 +1031,14 @@ sub GenerateParametersCheckExpression
         # For DOMString, Null, Undefined and any Object are accepted too, as
         # these are acceptable values for a DOMString argument (any Object can
         # be converted to a string via .toString).
-        push(@andExpression, "(${value}->IsNull() || ${value}->IsUndefined() || ${value}->IsString() || ${value}->IsObject())") if $codeGenerator->IsStringType($type);
-        push(@andExpression, "(${value}->IsNull() || V8${type}::HasInstance($value))") if IsWrapperType($type);
+        if ($codeGenerator->IsStringType($type)) {
+            push(@andExpression, "(${value}->IsNull() || ${value}->IsUndefined() || ${value}->IsString() || ${value}->IsObject())");
+        } elsif ($parameter->extendedAttributes->{"Callback"}) {
+            # For Callbacks only checks if the value is null or object.
+            push(@andExpression, "(${value}->IsNull() || ${value}->IsObject())");
+        } elsif (IsWrapperType($type)) {
+            push(@andExpression, "(${value}->IsNull() || V8${type}::HasInstance($value))");
+        }
 
         $parameterIndex++;
     }
diff --git a/WebCore/bindings/scripts/test/JS/JSTestObj.cpp b/WebCore/bindings/scripts/test/JS/JSTestObj.cpp
index 2a39ac4..e172cd5 100644
--- a/WebCore/bindings/scripts/test/JS/JSTestObj.cpp
+++ b/WebCore/bindings/scripts/test/JS/JSTestObj.cpp
@@ -1415,6 +1415,23 @@ static EncodedJSValue JSC_HOST_CALL jsTestObjPrototypeFunctionOverloadedMethod4(
     return JSValue::encode(jsUndefined());
 }
 
+static EncodedJSValue JSC_HOST_CALL jsTestObjPrototypeFunctionOverloadedMethod5(ExecState* exec)
+{
+    JSValue thisValue = exec->hostThisValue();
+    if (!thisValue.inherits(&JSTestObj::s_info))
+        return throwVMTypeError(exec);
+    JSTestObj* castedThis = static_cast<JSTestObj*>(asObject(thisValue));
+    TestObj* imp = static_cast<TestObj*>(castedThis->impl());
+    if (exec->argumentCount() <= 0 || !exec->argument(0).isObject()) {
+        setDOMException(exec, TYPE_MISMATCH_ERR);
+        return JSValue::encode(jsUndefined());
+    }
+    RefPtr<TestCallback> callback = JSTestCallback::create(asObject(exec->argument(0)), castedThis->globalObject());
+
+    imp->overloadedMethod(callback);
+    return JSValue::encode(jsUndefined());
+}
+
 EncodedJSValue JSC_HOST_CALL jsTestObjPrototypeFunctionOverloadedMethod(ExecState* exec)
 {
     if ((exec->argumentCount() == 2 && (exec->argument(0).isNull() || (exec->argument(0).isObject() && asObject(exec->argument(0))->inherits(&JSTestObj::s_info))) && (exec->argument(1).isNull() || exec->argument(1).isUndefined() || exec->argument(1).isString() || exec->argument(1).isObject())))
@@ -1425,6 +1442,8 @@ EncodedJSValue JSC_HOST_CALL jsTestObjPrototypeFunctionOverloadedMethod(ExecStat
         return jsTestObjPrototypeFunctionOverloadedMethod3(exec);
     if (exec->argumentCount() == 1)
         return jsTestObjPrototypeFunctionOverloadedMethod4(exec);
+    if ((exec->argumentCount() == 1 && (exec->argument(0).isNull() || exec->argument(0).isObject())))
+        return jsTestObjPrototypeFunctionOverloadedMethod5(exec);
     return throwVMTypeError(exec);
 }
 
diff --git a/WebCore/bindings/scripts/test/TestObj.idl b/WebCore/bindings/scripts/test/TestObj.idl
index 94f734b..f8fe782 100644
--- a/WebCore/bindings/scripts/test/TestObj.idl
+++ b/WebCore/bindings/scripts/test/TestObj.idl
@@ -135,6 +135,7 @@ module test {
         void    overloadedMethod(in TestObj objArg, in [Optional] long intArg);
         void    overloadedMethod(in DOMString strArg);
         void    overloadedMethod(in long intArg);
+        void    overloadedMethod(in [Callback] TestCallback callback);
 #endif
 
         // ObjectiveC reserved words.
diff --git a/WebCore/bindings/scripts/test/V8/V8TestObj.cpp b/WebCore/bindings/scripts/test/V8/V8TestObj.cpp
index 52887d1..b4acf74 100644
--- a/WebCore/bindings/scripts/test/V8/V8TestObj.cpp
+++ b/WebCore/bindings/scripts/test/V8/V8TestObj.cpp
@@ -975,6 +975,17 @@ static v8::Handle<v8::Value> overloadedMethod4Callback(const v8::Arguments& args
     return v8::Handle<v8::Value>();
 }
 
+static v8::Handle<v8::Value> overloadedMethod5Callback(const v8::Arguments& args)
+{
+    INC_STATS("DOM.TestObj.overloadedMethod5");
+    TestObj* imp = V8TestObj::toNative(args.Holder());
+    if (args.Length() <= 0 || !args[0]->IsObject())
+        return throwError(TYPE_MISMATCH_ERR);
+    RefPtr<TestCallback> callback = V8TestCallback::create(args[0], getScriptExecutionContext());
+    imp->overloadedMethod(callback);
+    return v8::Handle<v8::Value>();
+}
+
 static v8::Handle<v8::Value> overloadedMethodCallback(const v8::Arguments& args)
 {
     INC_STATS("DOM.TestObj.overloadedMethod");
@@ -986,6 +997,8 @@ static v8::Handle<v8::Value> overloadedMethodCallback(const v8::Arguments& args)
         return overloadedMethod3Callback(args);
     if (args.Length() == 1)
         return overloadedMethod4Callback(args);
+    if ((args.Length() == 1 && (args[0]->IsNull() || args[0]->IsObject())))
+        return overloadedMethod5Callback(args);
     V8Proxy::throwTypeError();
     return notHandledByInterceptor();
 }

-- 
WebKit Debian packaging



More information about the Pkg-webkit-commits mailing list