<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[206587] trunk/Source/WebCore</title>
</head>
<body>
<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; }
#msg dl a { font-weight: bold}
#msg dl a:link { color:#fc3; }
#msg dl a:active { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg ul { text-indent: -1em; padding-left: 1em; }#logmsg ol { text-indent: -1.5em; padding-left: 1.5em; }
#logmsg > ul, #logmsg > ol { margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<dl class="meta">
<dt>Revision</dt> <dd><a href="http://trac.webkit.org/projects/webkit/changeset/206587">206587</a></dd>
<dt>Author</dt> <dd>cdumez@apple.com</dd>
<dt>Date</dt> <dd>2016-09-29 10:18:35 -0700 (Thu, 29 Sep 2016)</dd>
</dl>
<h3>Log Message</h3>
<pre>[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:</pre>
<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkSourceWebCoreChangeLog">trunk/Source/WebCore/ChangeLog</a></li>
<li><a href="#trunkSourceWebCorebindingsscriptsCodeGeneratorJSpm">trunk/Source/WebCore/bindings/scripts/CodeGeneratorJS.pm</a></li>
<li><a href="#trunkSourceWebCorebindingsscriptstestJSJSTestObjcpp">trunk/Source/WebCore/bindings/scripts/test/JS/JSTestObj.cpp</a></li>
<li><a href="#trunkSourceWebCorebindingsscriptstestTestObjidl">trunk/Source/WebCore/bindings/scripts/test/TestObj.idl</a></li>
</ul>
</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkSourceWebCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/ChangeLog (206586 => 206587)</h4>
<pre class="diff"><span>
<span class="info">--- 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)
</span><span class="lines">@@ -1,3 +1,25 @@
</span><ins>+2016-09-29 Chris Dumez <cdumez@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:
+
</ins><span class="cx"> 2016-09-29 Per Arne Vollan <pvollan@apple.com>
</span><span class="cx">
</span><span class="cx"> [Win] Compile fix.
</span></span></pre></div>
<a id="trunkSourceWebCorebindingsscriptsCodeGeneratorJSpm"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/bindings/scripts/CodeGeneratorJS.pm (206586 => 206587)</h4>
<pre class="diff"><span>
<span class="info">--- 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)
</span><span class="lines">@@ -1997,7 +1997,12 @@
</span><span class="cx"> my $overload = @{$tuple}[0];
</span><span class="cx"> my $type = StripNullable(@{@{$tuple}[1]}[$d]);
</span><span class="cx"> if ($codeGenerator->IsWrapperType($type) || $codeGenerator->IsTypedArrayType($type)) {
</span><del>- &$generateOverloadCallIfNecessary($overload, "distinguishingArg.isObject() && asObject(distinguishingArg)->inherits(JS${type}::info())");
</del><ins>+ 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())");
+ }
</ins><span class="cx"> }
</span><span class="cx"> }
</span><span class="cx">
</span></span></pre></div>
<a id="trunkSourceWebCorebindingsscriptstestJSJSTestObjcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/bindings/scripts/test/JS/JSTestObj.cpp (206586 => 206587)</h4>
<pre class="diff"><span>
<span class="info">--- 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)
</span><span class="lines">@@ -38,6 +38,8 @@
</span><span class="cx"> #include "JSDOMIterator.h"
</span><span class="cx"> #include "JSDOMPromise.h"
</span><span class="cx"> #include "JSDOMStringList.h"
</span><ins>+#include "JSDOMWindow.h"
+#include "JSDOMWindowShell.h"
</ins><span class="cx"> #include "JSDocument.h"
</span><span class="cx"> #include "JSElement.h"
</span><span class="cx"> #include "JSEventListener.h"
</span><span class="lines">@@ -6340,6 +6342,26 @@
</span><span class="cx"> auto& impl = castedThis->wrapped();
</span><span class="cx"> if (UNLIKELY(state->argumentCount() < 1))
</span><span class="cx"> return throwVMError(state, throwScope, createNotEnoughArgumentsError(state));
</span><ins>+ 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));
</ins><span class="cx"> auto arrayArg = toNativeArray<String>(*state, state->uncheckedArgument(0));
</span><span class="cx"> RETURN_IF_EXCEPTION(throwScope, encodedJSValue());
</span><span class="cx"> impl.overloadedMethod(WTFMove(arrayArg));
</span><span class="lines">@@ -6346,7 +6368,7 @@
</span><span class="cx"> return JSValue::encode(jsUndefined());
</span><span class="cx"> }
</span><span class="cx">
</span><del>-static inline EncodedJSValue jsTestObjPrototypeFunctionOverloadedMethod10(ExecState* state)
</del><ins>+static inline EncodedJSValue jsTestObjPrototypeFunctionOverloadedMethod11(ExecState* state)
</ins><span class="cx"> {
</span><span class="cx"> VM& vm = state->vm();
</span><span class="cx"> auto throwScope = DECLARE_THROW_SCOPE(vm);
</span><span class="lines">@@ -6365,7 +6387,7 @@
</span><span class="cx"> return JSValue::encode(jsUndefined());
</span><span class="cx"> }
</span><span class="cx">
</span><del>-static inline EncodedJSValue jsTestObjPrototypeFunctionOverloadedMethod11(ExecState* state)
</del><ins>+static inline EncodedJSValue jsTestObjPrototypeFunctionOverloadedMethod12(ExecState* state)
</ins><span class="cx"> {
</span><span class="cx"> VM& vm = state->vm();
</span><span class="cx"> auto throwScope = DECLARE_THROW_SCOPE(vm);
</span><span class="lines">@@ -6384,7 +6406,7 @@
</span><span class="cx"> return JSValue::encode(jsUndefined());
</span><span class="cx"> }
</span><span class="cx">
</span><del>-static inline EncodedJSValue jsTestObjPrototypeFunctionOverloadedMethod12(ExecState* state)
</del><ins>+static inline EncodedJSValue jsTestObjPrototypeFunctionOverloadedMethod13(ExecState* state)
</ins><span class="cx"> {
</span><span class="cx"> VM& vm = state->vm();
</span><span class="cx"> auto throwScope = DECLARE_THROW_SCOPE(vm);
</span><span class="lines">@@ -6409,7 +6431,7 @@
</span><span class="cx"> UNUSED_PARAM(throwScope);
</span><span class="cx"> size_t argsCount = std::min<size_t>(2, state->argumentCount());
</span><span class="cx"> if (argsCount == 0) {
</span><del>- return jsTestObjPrototypeFunctionOverloadedMethod12(state);
</del><ins>+ return jsTestObjPrototypeFunctionOverloadedMethod13(state);
</ins><span class="cx"> }
</span><span class="cx"> if (argsCount == 1) {
</span><span class="cx"> JSValue distinguishingArg = state->uncheckedArgument(0);
</span><span class="lines">@@ -6423,8 +6445,10 @@
</span><span class="cx"> return jsTestObjPrototypeFunctionOverloadedMethod6(state);
</span><span class="cx"> if (distinguishingArg.isObject() && asObject(distinguishingArg)->inherits(JSTestObj::info()))
</span><span class="cx"> return jsTestObjPrototypeFunctionOverloadedMethod8(state);
</span><ins>+ if (distinguishingArg.isObject() && (asObject(distinguishingArg)->inherits(JSDOMWindowShell::info()) || asObject(distinguishingArg)->inherits(JSDOMWindow::info())))
+ return jsTestObjPrototypeFunctionOverloadedMethod9(state);
</ins><span class="cx"> if (distinguishingArg.isObject() && asObject(distinguishingArg)->inherits(JSBlob::info()))
</span><del>- return jsTestObjPrototypeFunctionOverloadedMethod12(state);
</del><ins>+ return jsTestObjPrototypeFunctionOverloadedMethod13(state);
</ins><span class="cx"> if (hasIteratorMethod(*state, distinguishingArg))
</span><span class="cx"> return jsTestObjPrototypeFunctionOverloadedMethod7(state);
</span><span class="cx"> if (distinguishingArg.isObject() && asObject(distinguishingArg)->type() != RegExpObjectType)
</span><span class="lines">@@ -6438,7 +6462,7 @@
</span><span class="cx"> if (distinguishingArg.isUndefined())
</span><span class="cx"> return jsTestObjPrototypeFunctionOverloadedMethod2(state);
</span><span class="cx"> if (distinguishingArg.isObject() && asObject(distinguishingArg)->inherits(JSBlob::info()))
</span><del>- return jsTestObjPrototypeFunctionOverloadedMethod12(state);
</del><ins>+ return jsTestObjPrototypeFunctionOverloadedMethod13(state);
</ins><span class="cx"> if (distinguishingArg.isNumber())
</span><span class="cx"> return jsTestObjPrototypeFunctionOverloadedMethod2(state);
</span><span class="cx"> return jsTestObjPrototypeFunctionOverloadedMethod1(state);
</span></span></pre></div>
<a id="trunkSourceWebCorebindingsscriptstestTestObjidl"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/bindings/scripts/test/TestObj.idl (206586 => 206587)</h4>
<pre class="diff"><span>
<span class="info">--- 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)
</span><span class="lines">@@ -286,6 +286,7 @@
</span><span class="cx"> void overloadedMethod(DOMStringList? listArg);
</span><span class="cx"> void overloadedMethod(sequence<DOMString>? arrayArg);
</span><span class="cx"> void overloadedMethod(TestObj objArg);
</span><ins>+ void overloadedMethod(DOMWindow window);
</ins><span class="cx"> void overloadedMethod(sequence<DOMString> arrayArg);
</span><span class="cx"> void overloadedMethod(sequence<unsigned long> arrayArg);
</span><span class="cx"> void overloadedMethod(DOMString strArg);
</span></span></pre>
</div>
</div>
</body>
</html>