Modified: trunk/Source/WebCore/ChangeLog (206586 => 206587)
--- trunk/Source/WebCore/ChangeLog 2016-09-29 17:08:41 UTC (rev 206586)
+++ trunk/Source/WebCore/ChangeLog 2016-09-29 17:18:35 UTC (rev 206587)
@@ -1,3 +1,25 @@
+2016-09-29 Chris Dumez <cdu...@apple.com>
+
+ [Web IDL] Fix overload resolution when the distinguishing argument is a Window
+ https://bugs.webkit.org/show_bug.cgi?id=162728
+
+ Reviewed by Ryosuke Niwa.
+
+ Fix overload resolution when the distinguishing argument is a Window.
+ Window is special because we could have a window or a proxy to the
+ Window (JSDOMWindowShell).
+
+ * bindings/scripts/CodeGeneratorJS.pm:
+ (GenerateOverloadedFunctionOrConstructor):
+ * bindings/scripts/test/JS/JSTestObj.cpp:
+ (WebCore::jsTestObjPrototypeFunctionOverloadedMethod9):
+ (WebCore::jsTestObjPrototypeFunctionOverloadedMethod10):
+ (WebCore::jsTestObjPrototypeFunctionOverloadedMethod11):
+ (WebCore::jsTestObjPrototypeFunctionOverloadedMethod12):
+ (WebCore::jsTestObjPrototypeFunctionOverloadedMethod13):
+ (WebCore::jsTestObjPrototypeFunctionOverloadedMethod):
+ * bindings/scripts/test/TestObj.idl:
+
2016-09-29 Per Arne Vollan <pvol...@apple.com>
[Win] Compile fix.
Modified: trunk/Source/WebCore/bindings/scripts/CodeGeneratorJS.pm (206586 => 206587)
--- trunk/Source/WebCore/bindings/scripts/CodeGeneratorJS.pm 2016-09-29 17:08:41 UTC (rev 206586)
+++ trunk/Source/WebCore/bindings/scripts/CodeGeneratorJS.pm 2016-09-29 17:18:35 UTC (rev 206587)
@@ -1997,7 +1997,12 @@
my $overload = @{$tuple}[0];
my $type = StripNullable(@{@{$tuple}[1]}[$d]);
if ($codeGenerator->IsWrapperType($type) || $codeGenerator->IsTypedArrayType($type)) {
- &$generateOverloadCallIfNecessary($overload, "distinguishingArg.isObject() && asObject(distinguishingArg)->inherits(JS${type}::info())");
+ if ($type eq "DOMWindow") {
+ AddToImplIncludes("JSDOMWindowShell.h");
+ &$generateOverloadCallIfNecessary($overload, "distinguishingArg.isObject() && (asObject(distinguishingArg)->inherits(JSDOMWindowShell::info()) || asObject(distinguishingArg)->inherits(JSDOMWindow::info()))");
+ } else {
+ &$generateOverloadCallIfNecessary($overload, "distinguishingArg.isObject() && asObject(distinguishingArg)->inherits(JS${type}::info())");
+ }
}
}
Modified: trunk/Source/WebCore/bindings/scripts/test/JS/JSTestObj.cpp (206586 => 206587)
--- trunk/Source/WebCore/bindings/scripts/test/JS/JSTestObj.cpp 2016-09-29 17:08:41 UTC (rev 206586)
+++ trunk/Source/WebCore/bindings/scripts/test/JS/JSTestObj.cpp 2016-09-29 17:18:35 UTC (rev 206587)
@@ -38,6 +38,8 @@
#include "JSDOMIterator.h"
#include "JSDOMPromise.h"
#include "JSDOMStringList.h"
+#include "JSDOMWindow.h"
+#include "JSDOMWindowShell.h"
#include "JSDocument.h"
#include "JSElement.h"
#include "JSEventListener.h"
@@ -6340,6 +6342,26 @@
auto& impl = castedThis->wrapped();
if (UNLIKELY(state->argumentCount() < 1))
return throwVMError(state, throwScope, createNotEnoughArgumentsError(state));
+ auto window = JSDOMWindow::toWrapped(state->uncheckedArgument(0));
+ if (UNLIKELY(!window))
+ return throwArgumentTypeError(*state, throwScope, 0, "window", "TestObject", "overloadedMethod", "DOMWindow");
+ impl.overloadedMethod(*window);
+ return JSValue::encode(jsUndefined());
+}
+
+static inline EncodedJSValue jsTestObjPrototypeFunctionOverloadedMethod10(ExecState* state)
+{
+ VM& vm = state->vm();
+ auto throwScope = DECLARE_THROW_SCOPE(vm);
+ UNUSED_PARAM(throwScope);
+ JSValue thisValue = state->thisValue();
+ auto castedThis = jsDynamicCast<JSTestObj*>(thisValue);
+ if (UNLIKELY(!castedThis))
+ return throwThisTypeError(*state, throwScope, "TestObject", "overloadedMethod");
+ ASSERT_GC_OBJECT_INHERITS(castedThis, JSTestObj::info());
+ auto& impl = castedThis->wrapped();
+ if (UNLIKELY(state->argumentCount() < 1))
+ return throwVMError(state, throwScope, createNotEnoughArgumentsError(state));
auto arrayArg = toNativeArray<String>(*state, state->uncheckedArgument(0));
RETURN_IF_EXCEPTION(throwScope, encodedJSValue());
impl.overloadedMethod(WTFMove(arrayArg));
@@ -6346,7 +6368,7 @@
return JSValue::encode(jsUndefined());
}
-static inline EncodedJSValue jsTestObjPrototypeFunctionOverloadedMethod10(ExecState* state)
+static inline EncodedJSValue jsTestObjPrototypeFunctionOverloadedMethod11(ExecState* state)
{
VM& vm = state->vm();
auto throwScope = DECLARE_THROW_SCOPE(vm);
@@ -6365,7 +6387,7 @@
return JSValue::encode(jsUndefined());
}
-static inline EncodedJSValue jsTestObjPrototypeFunctionOverloadedMethod11(ExecState* state)
+static inline EncodedJSValue jsTestObjPrototypeFunctionOverloadedMethod12(ExecState* state)
{
VM& vm = state->vm();
auto throwScope = DECLARE_THROW_SCOPE(vm);
@@ -6384,7 +6406,7 @@
return JSValue::encode(jsUndefined());
}
-static inline EncodedJSValue jsTestObjPrototypeFunctionOverloadedMethod12(ExecState* state)
+static inline EncodedJSValue jsTestObjPrototypeFunctionOverloadedMethod13(ExecState* state)
{
VM& vm = state->vm();
auto throwScope = DECLARE_THROW_SCOPE(vm);
@@ -6409,7 +6431,7 @@
UNUSED_PARAM(throwScope);
size_t argsCount = std::min<size_t>(2, state->argumentCount());
if (argsCount == 0) {
- return jsTestObjPrototypeFunctionOverloadedMethod12(state);
+ return jsTestObjPrototypeFunctionOverloadedMethod13(state);
}
if (argsCount == 1) {
JSValue distinguishingArg = state->uncheckedArgument(0);
@@ -6423,8 +6445,10 @@
return jsTestObjPrototypeFunctionOverloadedMethod6(state);
if (distinguishingArg.isObject() && asObject(distinguishingArg)->inherits(JSTestObj::info()))
return jsTestObjPrototypeFunctionOverloadedMethod8(state);
+ if (distinguishingArg.isObject() && (asObject(distinguishingArg)->inherits(JSDOMWindowShell::info()) || asObject(distinguishingArg)->inherits(JSDOMWindow::info())))
+ return jsTestObjPrototypeFunctionOverloadedMethod9(state);
if (distinguishingArg.isObject() && asObject(distinguishingArg)->inherits(JSBlob::info()))
- return jsTestObjPrototypeFunctionOverloadedMethod12(state);
+ return jsTestObjPrototypeFunctionOverloadedMethod13(state);
if (hasIteratorMethod(*state, distinguishingArg))
return jsTestObjPrototypeFunctionOverloadedMethod7(state);
if (distinguishingArg.isObject() && asObject(distinguishingArg)->type() != RegExpObjectType)
@@ -6438,7 +6462,7 @@
if (distinguishingArg.isUndefined())
return jsTestObjPrototypeFunctionOverloadedMethod2(state);
if (distinguishingArg.isObject() && asObject(distinguishingArg)->inherits(JSBlob::info()))
- return jsTestObjPrototypeFunctionOverloadedMethod12(state);
+ return jsTestObjPrototypeFunctionOverloadedMethod13(state);
if (distinguishingArg.isNumber())
return jsTestObjPrototypeFunctionOverloadedMethod2(state);
return jsTestObjPrototypeFunctionOverloadedMethod1(state);
Modified: trunk/Source/WebCore/bindings/scripts/test/TestObj.idl (206586 => 206587)
--- trunk/Source/WebCore/bindings/scripts/test/TestObj.idl 2016-09-29 17:08:41 UTC (rev 206586)
+++ trunk/Source/WebCore/bindings/scripts/test/TestObj.idl 2016-09-29 17:18:35 UTC (rev 206587)
@@ -286,6 +286,7 @@
void overloadedMethod(DOMStringList? listArg);
void overloadedMethod(sequence<DOMString>? arrayArg);
void overloadedMethod(TestObj objArg);
+ void overloadedMethod(DOMWindow window);
void overloadedMethod(sequence<DOMString> arrayArg);
void overloadedMethod(sequence<unsigned long> arrayArg);
void overloadedMethod(DOMString strArg);