- Revision
- 121817
- Author
- [email protected]
- Date
- 2012-07-03 17:23:35 -0700 (Tue, 03 Jul 2012)
Log Message
Binding: IDL type DOMString[] shouldn't match null
https://bugs.webkit.org/show_bug.cgi?id=84217
Reviewed by Kentaro Hara.
Similar to r121714, IDL overloads with T[] (which is only minimally supported)
were being treated as Nullable by default during overloaded method dispatching,
which deviates from the WebIDL specification. Extend the previous change to
look for Nullable (specified by "?" type suffix in the IDL) for array types.
Also, after inspection of the spec, use a strict "is this an Array?" test in
the JS generator rather than an "inherits from Array.prototype?" test, to
match the WebIDL spec.
IDL files with affected overloads are modified to include the "?" suffix
so that no behavior changes are introduced by this patch - the JS and V8
generator results before/after the change show no diffs apart from the stricter
isJSArray() test.
Test: bindings/scripts/test/TestObj.idl (a non-Nullable T[] overload)
* Modules/indexeddb/IDBDatabase.idl: Tag T[] overloads with ? suffix.
* Modules/indexeddb/IDBObjectStore.idl: Ditto.
* Modules/vibration/NavigatorVibration.idl: Ditto.
* bindings/scripts/CodeGeneratorJS.pm: Check isNullable for T[].
(GenerateParametersCheckExpression):
* bindings/scripts/CodeGeneratorV8.pm: Ditto.
(GenerateParametersCheckExpression):
* bindings/scripts/test/JS/JSTestObj.cpp: Rebaselined.
(WebCore::jsTestObjPrototypeFunctionOverloadedMethod9):
(WebCore):
(WebCore::jsTestObjPrototypeFunctionOverloadedMethod):
* bindings/scripts/test/TestObj.idl: Tag existing T[] with ?, add non-? T[].
* bindings/scripts/test/V8/V8TestObj.cpp: Rebaselined.
(WebCore::TestObjV8Internal::overloadedMethod9Callback):
(TestObjV8Internal):
(WebCore::TestObjV8Internal::overloadedMethodCallback):
Modified Paths
Diff
Modified: trunk/Source/WebCore/ChangeLog (121816 => 121817)
--- trunk/Source/WebCore/ChangeLog 2012-07-04 00:14:25 UTC (rev 121816)
+++ trunk/Source/WebCore/ChangeLog 2012-07-04 00:23:35 UTC (rev 121817)
@@ -1,3 +1,43 @@
+2012-07-03 Joshua Bell <[email protected]>
+
+ Binding: IDL type DOMString[] shouldn't match null
+ https://bugs.webkit.org/show_bug.cgi?id=84217
+
+ Reviewed by Kentaro Hara.
+
+ Similar to r121714, IDL overloads with T[] (which is only minimally supported)
+ were being treated as Nullable by default during overloaded method dispatching,
+ which deviates from the WebIDL specification. Extend the previous change to
+ look for Nullable (specified by "?" type suffix in the IDL) for array types.
+
+ Also, after inspection of the spec, use a strict "is this an Array?" test in
+ the JS generator rather than an "inherits from Array.prototype?" test, to
+ match the WebIDL spec.
+
+ IDL files with affected overloads are modified to include the "?" suffix
+ so that no behavior changes are introduced by this patch - the JS and V8
+ generator results before/after the change show no diffs apart from the stricter
+ isJSArray() test.
+
+ Test: bindings/scripts/test/TestObj.idl (a non-Nullable T[] overload)
+
+ * Modules/indexeddb/IDBDatabase.idl: Tag T[] overloads with ? suffix.
+ * Modules/indexeddb/IDBObjectStore.idl: Ditto.
+ * Modules/vibration/NavigatorVibration.idl: Ditto.
+ * bindings/scripts/CodeGeneratorJS.pm: Check isNullable for T[].
+ (GenerateParametersCheckExpression):
+ * bindings/scripts/CodeGeneratorV8.pm: Ditto.
+ (GenerateParametersCheckExpression):
+ * bindings/scripts/test/JS/JSTestObj.cpp: Rebaselined.
+ (WebCore::jsTestObjPrototypeFunctionOverloadedMethod9):
+ (WebCore):
+ (WebCore::jsTestObjPrototypeFunctionOverloadedMethod):
+ * bindings/scripts/test/TestObj.idl: Tag existing T[] with ?, add non-? T[].
+ * bindings/scripts/test/V8/V8TestObj.cpp: Rebaselined.
+ (WebCore::TestObjV8Internal::overloadedMethod9Callback):
+ (TestObjV8Internal):
+ (WebCore::TestObjV8Internal::overloadedMethodCallback):
+
2012-07-03 Nate Chapin <[email protected]>
REGRESSION (r115654): Sometimes does not replace content for multipart/x-mixed-replace
Modified: trunk/Source/WebCore/Modules/indexeddb/IDBDatabase.idl (121816 => 121817)
--- trunk/Source/WebCore/Modules/indexeddb/IDBDatabase.idl 2012-07-04 00:14:25 UTC (rev 121816)
+++ trunk/Source/WebCore/Modules/indexeddb/IDBDatabase.idl 2012-07-04 00:23:35 UTC (rev 121817)
@@ -47,7 +47,7 @@
raises (IDBDatabaseException);
[CallWith=ScriptExecutionContext] IDBTransaction transaction(in DOMStringList? storeNames, in [Optional=DefaultIsNullString] DOMString mode)
raises (IDBDatabaseException);
- [CallWith=ScriptExecutionContext] IDBTransaction transaction(in DOMString[] storeNames, in [Optional=DefaultIsNullString] DOMString mode)
+ [CallWith=ScriptExecutionContext] IDBTransaction transaction(in DOMString[]? storeNames, in [Optional=DefaultIsNullString] DOMString mode)
raises (IDBDatabaseException);
[CallWith=ScriptExecutionContext] IDBTransaction transaction(in DOMString storeName, in [Optional=DefaultIsNullString] DOMString mode)
raises (IDBDatabaseException);
@@ -55,7 +55,7 @@
// FIXME: remove these when https://bugs.webkit.org/show_bug.cgi?id=85326 is fixed.
[CallWith=ScriptExecutionContext] IDBTransaction transaction(in DOMStringList? storeNames, in unsigned short mode)
raises (IDBDatabaseException);
- [CallWith=ScriptExecutionContext] IDBTransaction transaction(in DOMString[] storeNames, in unsigned short mode)
+ [CallWith=ScriptExecutionContext] IDBTransaction transaction(in DOMString[]? storeNames, in unsigned short mode)
raises (IDBDatabaseException);
[CallWith=ScriptExecutionContext] IDBTransaction transaction(in DOMString storeName, in unsigned short mode)
raises (IDBDatabaseException);
Modified: trunk/Source/WebCore/Modules/indexeddb/IDBObjectStore.idl (121816 => 121817)
--- trunk/Source/WebCore/Modules/indexeddb/IDBObjectStore.idl 2012-07-04 00:14:25 UTC (rev 121816)
+++ trunk/Source/WebCore/Modules/indexeddb/IDBObjectStore.idl 2012-07-04 00:23:35 UTC (rev 121817)
@@ -59,7 +59,7 @@
[CallWith=ScriptExecutionContext] IDBRequest openCursor(in IDBKey key, in [Optional] unsigned short direction)
raises (IDBDatabaseException);
- IDBIndex createIndex(in DOMString name, in DOMString[] keyPath, in [Optional] Dictionary options)
+ IDBIndex createIndex(in DOMString name, in DOMString[]? keyPath, in [Optional] Dictionary options)
raises (IDBDatabaseException);
IDBIndex createIndex(in DOMString name, in DOMString keyPath, in [Optional] Dictionary options)
raises (IDBDatabaseException);
Modified: trunk/Source/WebCore/Modules/vibration/NavigatorVibration.idl (121816 => 121817)
--- trunk/Source/WebCore/Modules/vibration/NavigatorVibration.idl 2012-07-04 00:14:25 UTC (rev 121816)
+++ trunk/Source/WebCore/Modules/vibration/NavigatorVibration.idl 2012-07-04 00:23:35 UTC (rev 121817)
@@ -23,7 +23,7 @@
Conditional=VIBRATION,
Supplemental=Navigator
] NavigatorVibration {
- void webkitVibrate(in unsigned long[] pattern) raises(DOMException);
+ void webkitVibrate(in unsigned long[]? pattern) raises(DOMException);
void webkitVibrate(in unsigned long time) raises(DOMException);
};
Modified: trunk/Source/WebCore/bindings/scripts/CodeGeneratorJS.pm (121816 => 121817)
--- trunk/Source/WebCore/bindings/scripts/CodeGeneratorJS.pm 2012-07-04 00:14:25 UTC (rev 121816)
+++ trunk/Source/WebCore/bindings/scripts/CodeGeneratorJS.pm 2012-07-04 00:23:35 UTC (rev 121817)
@@ -1260,7 +1260,11 @@
$usedArguments{$parameterIndex} = 1;
} elsif (IsArrayType($type)) {
# FIXME: Add proper support for T[], T[]?, sequence<T>
- push(@andExpression, "(${value}.isNull() || (${value}.isObject() && asObject(${value})->inherits(&JSArray::s_info)))");
+ if ($parameter->isNullable) {
+ push(@andExpression, "(${value}.isNull() || (${value}.isObject() && isJSArray(${value})))");
+ } else {
+ push(@andExpression, "(${value}.isObject() && isJSArray(${value}))");
+ }
$usedArguments{$parameterIndex} = 1;
} elsif (!IsNativeType($type)) {
if ($parameter->isNullable) {
Modified: trunk/Source/WebCore/bindings/scripts/CodeGeneratorV8.pm (121816 => 121817)
--- trunk/Source/WebCore/bindings/scripts/CodeGeneratorV8.pm 2012-07-04 00:14:25 UTC (rev 121816)
+++ trunk/Source/WebCore/bindings/scripts/CodeGeneratorV8.pm 2012-07-04 00:23:35 UTC (rev 121817)
@@ -1357,7 +1357,11 @@
push(@andExpression, "(${value}->IsNull() || ${value}->IsFunction())");
} elsif (IsArrayType($type)) {
# FIXME: Add proper support for T[], T[]?, sequence<T>.
- push(@andExpression, "(${value}->IsNull() || ${value}->IsArray())");
+ if ($parameter->isNullable) {
+ push(@andExpression, "(${value}->IsNull() || ${value}->IsArray())");
+ } else {
+ push(@andExpression, "(${value}->IsArray())");
+ }
} elsif (IsWrapperType($type)) {
if ($parameter->isNullable) {
push(@andExpression, "(${value}->IsNull() || V8${type}::HasInstance($value))");
Modified: trunk/Source/WebCore/bindings/scripts/test/JS/JSTestObj.cpp (121816 => 121817)
--- trunk/Source/WebCore/bindings/scripts/test/JS/JSTestObj.cpp 2012-07-04 00:14:25 UTC (rev 121816)
+++ trunk/Source/WebCore/bindings/scripts/test/JS/JSTestObj.cpp 2012-07-04 00:23:35 UTC (rev 121817)
@@ -2160,6 +2160,23 @@
return JSValue::encode(jsUndefined());
}
+static EncodedJSValue JSC_HOST_CALL jsTestObjPrototypeFunctionOverloadedMethod9(ExecState* exec)
+{
+ JSValue thisValue = exec->hostThisValue();
+ if (!thisValue.inherits(&JSTestObj::s_info))
+ return throwVMTypeError(exec);
+ JSTestObj* castedThis = jsCast<JSTestObj*>(asObject(thisValue));
+ ASSERT_GC_OBJECT_INHERITS(castedThis, &JSTestObj::s_info);
+ TestObj* impl = static_cast<TestObj*>(castedThis->impl());
+ if (exec->argumentCount() < 1)
+ return throwVMError(exec, createNotEnoughArgumentsError(exec));
+ RefPtr<DOMStringList> arrayArg(toDOMStringList(exec, MAYBE_MISSING_PARAMETER(exec, 0, DefaultIsUndefined)));
+ if (exec->hadException())
+ return JSValue::encode(jsUndefined());
+ impl->overloadedMethod(arrayArg);
+ return JSValue::encode(jsUndefined());
+}
+
EncodedJSValue JSC_HOST_CALL jsTestObjPrototypeFunctionOverloadedMethod(ExecState* exec)
{
size_t argsCount = exec->argumentCount();
@@ -2177,10 +2194,12 @@
return jsTestObjPrototypeFunctionOverloadedMethod5(exec);
if ((argsCount == 1 && (arg0.isNull() || (arg0.isObject() && asObject(arg0)->inherits(&JSDOMStringList::s_info)))))
return jsTestObjPrototypeFunctionOverloadedMethod6(exec);
- if ((argsCount == 1 && (arg0.isNull() || (arg0.isObject() && asObject(arg0)->inherits(&JSArray::s_info)))))
+ if ((argsCount == 1 && (arg0.isNull() || (arg0.isObject() && isJSArray(arg0)))))
return jsTestObjPrototypeFunctionOverloadedMethod7(exec);
if ((argsCount == 1 && (arg0.isObject() && asObject(arg0)->inherits(&JSTestObj::s_info))))
return jsTestObjPrototypeFunctionOverloadedMethod8(exec);
+ if ((argsCount == 1 && (arg0.isObject() && isJSArray(arg0))))
+ return jsTestObjPrototypeFunctionOverloadedMethod9(exec);
return throwVMTypeError(exec);
}
Modified: trunk/Source/WebCore/bindings/scripts/test/TestObj.idl (121816 => 121817)
--- trunk/Source/WebCore/bindings/scripts/test/TestObj.idl 2012-07-04 00:14:25 UTC (rev 121816)
+++ trunk/Source/WebCore/bindings/scripts/test/TestObj.idl 2012-07-04 00:23:35 UTC (rev 121817)
@@ -169,8 +169,9 @@
void overloadedMethod(in long intArg);
void overloadedMethod(in [Callback] TestCallback callback);
void overloadedMethod(in DOMStringList? listArg);
+ void overloadedMethod(in DOMString[]? arrayArg);
+ void overloadedMethod(in TestObj objArg);
void overloadedMethod(in DOMString[] arrayArg);
- void overloadedMethod(in TestObj objArg);
#endif
// Class methods within _javascript_ (like what's used for IDBKeyRange).
Modified: trunk/Source/WebCore/bindings/scripts/test/V8/V8TestObj.cpp (121816 => 121817)
--- trunk/Source/WebCore/bindings/scripts/test/V8/V8TestObj.cpp 2012-07-04 00:14:25 UTC (rev 121816)
+++ trunk/Source/WebCore/bindings/scripts/test/V8/V8TestObj.cpp 2012-07-04 00:23:35 UTC (rev 121817)
@@ -1582,6 +1582,17 @@
return v8::Handle<v8::Value>();
}
+static v8::Handle<v8::Value> overloadedMethod9Callback(const v8::Arguments& args)
+{
+ INC_STATS("DOM.TestObj.overloadedMethod9");
+ if (args.Length() < 1)
+ return V8Proxy::throwNotEnoughArgumentsError(args.GetIsolate());
+ TestObj* imp = V8TestObj::toNative(args.Holder());
+ EXCEPTION_BLOCK(RefPtr<DOMStringList>, arrayArg, v8ValueToWebCoreDOMStringList(MAYBE_MISSING_PARAMETER(args, 0, DefaultIsUndefined)));
+ imp->overloadedMethod(arrayArg);
+ return v8::Handle<v8::Value>();
+}
+
static v8::Handle<v8::Value> overloadedMethodCallback(const v8::Arguments& args)
{
INC_STATS("DOM.TestObj.overloadedMethod");
@@ -1601,6 +1612,8 @@
return overloadedMethod7Callback(args);
if ((args.Length() == 1 && (V8TestObj::HasInstance(args[0]))))
return overloadedMethod8Callback(args);
+ if ((args.Length() == 1 && (args[0]->IsArray())))
+ return overloadedMethod9Callback(args);
return V8Proxy::throwTypeError(0, args.GetIsolate());
}