<!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>[201128] 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/201128">201128</a></dd>
<dt>Author</dt> <dd>youenn.fablet@crf.canon.fr</dd>
<dt>Date</dt> <dd>2016-05-19 00:14:45 -0700 (Thu, 19 May 2016)</dd>
</dl>

<h3>Log Message</h3>
<pre>Make binding DOM constructor use toJSNewlyCreated instead of toJS
https://bugs.webkit.org/show_bug.cgi?id=157832

Reviewed by Chris Dumez.

Using toJSNewlyCreated in generated constructors instead of toJS.
Enabling generation of toJS and toJSNewlyCreated for constructable DOM objects.
This ensures that toJSNewlyCreated call in constructor will compile properly.

Updating some custom code to implement toJSNewlyCreated.

Covered by existing tests.

* bindings/js/JSImageDataCustom.cpp:
(WebCore::toJSNewlyCreated):
(WebCore::toJS):
* bindings/js/JSTextTrackCueCustom.cpp:
(WebCore::toJSNewlyCreated):
(WebCore::toJS):
* bindings/scripts/CodeGeneratorJS.pm:
(ShouldGenerateToJSDeclaration):
(GenerateConstructorDefinition):
* bindings/scripts/test/JS/JSTestInterface.cpp:
(WebCore::JSTestInterfaceConstructor::construct):
* bindings/scripts/test/JS/JSTestNamedConstructor.cpp:
(WebCore::JSTestNamedConstructorNamedConstructor::construct):
* bindings/scripts/test/JS/JSTestNode.cpp:
(WebCore::JSTestNodeConstructor::construct):
(WebCore::toJSNewlyCreated):
(WebCore::toJS):
* bindings/scripts/test/JS/JSTestNode.h:
(WebCore::toJS):
(WebCore::toJSNewlyCreated):
* bindings/scripts/test/JS/JSTestObj.cpp:
(WebCore::JSTestObjConstructor::construct):
* bindings/scripts/test/JS/JSTestOverloadedConstructors.cpp:
(WebCore::constructJSTestOverloadedConstructors1):
(WebCore::constructJSTestOverloadedConstructors2):
(WebCore::constructJSTestOverloadedConstructors3):
(WebCore::constructJSTestOverloadedConstructors4):
(WebCore::constructJSTestOverloadedConstructors5):
* bindings/scripts/test/JS/JSTestTypedefs.cpp:
(WebCore::JSTestTypedefsConstructor::construct):</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkSourceWebCoreChangeLog">trunk/Source/WebCore/ChangeLog</a></li>
<li><a href="#trunkSourceWebCorebindingsjsJSImageDataCustomcpp">trunk/Source/WebCore/bindings/js/JSImageDataCustom.cpp</a></li>
<li><a href="#trunkSourceWebCorebindingsjsJSTextTrackCueCustomcpp">trunk/Source/WebCore/bindings/js/JSTextTrackCueCustom.cpp</a></li>
<li><a href="#trunkSourceWebCorebindingsscriptsCodeGeneratorJSpm">trunk/Source/WebCore/bindings/scripts/CodeGeneratorJS.pm</a></li>
<li><a href="#trunkSourceWebCorebindingsscriptstestJSJSTestInterfacecpp">trunk/Source/WebCore/bindings/scripts/test/JS/JSTestInterface.cpp</a></li>
<li><a href="#trunkSourceWebCorebindingsscriptstestJSJSTestNamedConstructorcpp">trunk/Source/WebCore/bindings/scripts/test/JS/JSTestNamedConstructor.cpp</a></li>
<li><a href="#trunkSourceWebCorebindingsscriptstestJSJSTestNodecpp">trunk/Source/WebCore/bindings/scripts/test/JS/JSTestNode.cpp</a></li>
<li><a href="#trunkSourceWebCorebindingsscriptstestJSJSTestNodeh">trunk/Source/WebCore/bindings/scripts/test/JS/JSTestNode.h</a></li>
<li><a href="#trunkSourceWebCorebindingsscriptstestJSJSTestObjcpp">trunk/Source/WebCore/bindings/scripts/test/JS/JSTestObj.cpp</a></li>
<li><a href="#trunkSourceWebCorebindingsscriptstestJSJSTestOverloadedConstructorscpp">trunk/Source/WebCore/bindings/scripts/test/JS/JSTestOverloadedConstructors.cpp</a></li>
<li><a href="#trunkSourceWebCorebindingsscriptstestJSJSTestTypedefscpp">trunk/Source/WebCore/bindings/scripts/test/JS/JSTestTypedefs.cpp</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkSourceWebCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/ChangeLog (201127 => 201128)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/ChangeLog        2016-05-19 05:20:03 UTC (rev 201127)
+++ trunk/Source/WebCore/ChangeLog        2016-05-19 07:14:45 UTC (rev 201128)
</span><span class="lines">@@ -1,3 +1,49 @@
</span><ins>+2016-05-19  Youenn Fablet  &lt;youenn.fablet@crf.canon.fr&gt;
+
+        Make binding DOM constructor use toJSNewlyCreated instead of toJS
+        https://bugs.webkit.org/show_bug.cgi?id=157832
+
+        Reviewed by Chris Dumez.
+
+        Using toJSNewlyCreated in generated constructors instead of toJS.
+        Enabling generation of toJS and toJSNewlyCreated for constructable DOM objects.
+        This ensures that toJSNewlyCreated call in constructor will compile properly.
+
+        Updating some custom code to implement toJSNewlyCreated.
+
+        Covered by existing tests.
+
+        * bindings/js/JSImageDataCustom.cpp:
+        (WebCore::toJSNewlyCreated):
+        (WebCore::toJS):
+        * bindings/js/JSTextTrackCueCustom.cpp:
+        (WebCore::toJSNewlyCreated):
+        (WebCore::toJS):
+        * bindings/scripts/CodeGeneratorJS.pm:
+        (ShouldGenerateToJSDeclaration):
+        (GenerateConstructorDefinition):
+        * bindings/scripts/test/JS/JSTestInterface.cpp:
+        (WebCore::JSTestInterfaceConstructor::construct):
+        * bindings/scripts/test/JS/JSTestNamedConstructor.cpp:
+        (WebCore::JSTestNamedConstructorNamedConstructor::construct):
+        * bindings/scripts/test/JS/JSTestNode.cpp:
+        (WebCore::JSTestNodeConstructor::construct):
+        (WebCore::toJSNewlyCreated):
+        (WebCore::toJS):
+        * bindings/scripts/test/JS/JSTestNode.h:
+        (WebCore::toJS):
+        (WebCore::toJSNewlyCreated):
+        * bindings/scripts/test/JS/JSTestObj.cpp:
+        (WebCore::JSTestObjConstructor::construct):
+        * bindings/scripts/test/JS/JSTestOverloadedConstructors.cpp:
+        (WebCore::constructJSTestOverloadedConstructors1):
+        (WebCore::constructJSTestOverloadedConstructors2):
+        (WebCore::constructJSTestOverloadedConstructors3):
+        (WebCore::constructJSTestOverloadedConstructors4):
+        (WebCore::constructJSTestOverloadedConstructors5):
+        * bindings/scripts/test/JS/JSTestTypedefs.cpp:
+        (WebCore::JSTestTypedefsConstructor::construct):
+
</ins><span class="cx"> 2016-05-18  Zalan Bujtas  &lt;zalan@apple.com&gt;
</span><span class="cx"> 
</span><span class="cx">         Make LayoutUnit::operator bool() explicit.
</span></span></pre></div>
<a id="trunkSourceWebCorebindingsjsJSImageDataCustomcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/bindings/js/JSImageDataCustom.cpp (201127 => 201128)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/bindings/js/JSImageDataCustom.cpp        2016-05-19 05:20:03 UTC (rev 201127)
+++ trunk/Source/WebCore/bindings/js/JSImageDataCustom.cpp        2016-05-19 07:14:45 UTC (rev 201128)
</span><span class="lines">@@ -35,19 +35,24 @@
</span><span class="cx"> 
</span><span class="cx"> namespace WebCore {
</span><span class="cx"> 
</span><del>-JSValue toJS(ExecState* exec, JSDOMGlobalObject* globalObject, ImageData&amp; imageData)
</del><ins>+JSValue toJSNewlyCreated(ExecState* state, JSDOMGlobalObject* globalObject, Ref&lt;ImageData&gt;&amp;&amp; imageData)
</ins><span class="cx"> {
</span><del>-    if (auto* wrapper = getCachedWrapper(globalObject-&gt;world(), imageData))
-        return wrapper;
-    
-    auto* wrapper = CREATE_DOM_WRAPPER(globalObject, ImageData, imageData);
-    Identifier dataName = Identifier::fromString(exec, &quot;data&quot;);
-    wrapper-&gt;putDirect(exec-&gt;vm(), dataName, toJS(exec, globalObject, imageData.data()), DontDelete | ReadOnly);
</del><ins>+    auto* data = imageData-&gt;data();
+    auto* wrapper = CREATE_DOM_WRAPPER(globalObject, ImageData, WTFMove(imageData));
+    Identifier dataName = Identifier::fromString(state, &quot;data&quot;);
+    wrapper-&gt;putDirect(state-&gt;vm(), dataName, toJS(state, globalObject, data), DontDelete | ReadOnly);
</ins><span class="cx">     // FIXME: Adopt reportExtraMemoryVisited, and switch to reportExtraMemoryAllocated.
</span><span class="cx">     // https://bugs.webkit.org/show_bug.cgi?id=142595
</span><del>-    exec-&gt;heap()-&gt;deprecatedReportExtraMemory(imageData.data()-&gt;length());
</del><ins>+    state-&gt;heap()-&gt;deprecatedReportExtraMemory(data-&gt;length());
</ins><span class="cx">     
</span><span class="cx">     return wrapper;
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+JSValue toJS(ExecState* state, JSDOMGlobalObject* globalObject, ImageData&amp; imageData)
+{
+    if (auto* wrapper = getCachedWrapper(globalObject-&gt;world(), imageData))
+        return wrapper;
+    return toJSNewlyCreated(state, globalObject, Ref&lt;ImageData&gt;(imageData));
</ins><span class="cx"> }
</span><ins>+
+}
</ins></span></pre></div>
<a id="trunkSourceWebCorebindingsjsJSTextTrackCueCustomcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/bindings/js/JSTextTrackCueCustom.cpp (201127 => 201128)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/bindings/js/JSTextTrackCueCustom.cpp        2016-05-19 05:20:03 UTC (rev 201127)
+++ trunk/Source/WebCore/bindings/js/JSTextTrackCueCustom.cpp        2016-05-19 07:14:45 UTC (rev 201128)
</span><span class="lines">@@ -59,24 +59,29 @@
</span><span class="cx">     return visitor.containsOpaqueRoot(root(textTrackCue.track()));
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-JSValue toJS(ExecState*, JSDOMGlobalObject* globalObject, TextTrackCue&amp; cue)
</del><ins>+JSValue toJSNewlyCreated(ExecState*, JSDOMGlobalObject* globalObject, Ref&lt;TextTrackCue&gt;&amp;&amp; cue)
</ins><span class="cx"> {
</span><del>-    if (auto* wrapper = getCachedWrapper(globalObject-&gt;world(), cue))
-        return wrapper;
-
</del><span class="cx">     // This switch will make more sense once we support DataCue
</span><del>-    switch (cue.cueType()) {
</del><ins>+    switch (cue-&gt;cueType()) {
</ins><span class="cx">     case TextTrackCue::Data:
</span><del>-        return CREATE_DOM_WRAPPER(globalObject, DataCue, cue);
</del><ins>+        return CREATE_DOM_WRAPPER(globalObject, DataCue, WTFMove(cue));
</ins><span class="cx">     case TextTrackCue::WebVTT:
</span><span class="cx">     case TextTrackCue::Generic:
</span><del>-        return CREATE_DOM_WRAPPER(globalObject, VTTCue, cue);
</del><ins>+        return CREATE_DOM_WRAPPER(globalObject, VTTCue, WTFMove(cue));
</ins><span class="cx">     default:
</span><span class="cx">         ASSERT_NOT_REACHED();
</span><span class="cx">         return jsNull();
</span><span class="cx">     }
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+JSValue toJS(ExecState* state, JSDOMGlobalObject* globalObject, TextTrackCue&amp; cue)
+{
+    if (auto* wrapper = getCachedWrapper(globalObject-&gt;world(), cue))
+        return wrapper;
+
+    return toJSNewlyCreated(state, globalObject, Ref&lt;TextTrackCue&gt;(cue));
+}
+
</ins><span class="cx"> void JSTextTrackCue::visitAdditionalChildren(SlotVisitor&amp; visitor)
</span><span class="cx"> {
</span><span class="cx">     if (TextTrack* textTrack = wrapped().track())
</span></span></pre></div>
<a id="trunkSourceWebCorebindingsscriptsCodeGeneratorJSpm"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/bindings/scripts/CodeGeneratorJS.pm (201127 => 201128)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/bindings/scripts/CodeGeneratorJS.pm        2016-05-19 05:20:03 UTC (rev 201127)
+++ trunk/Source/WebCore/bindings/scripts/CodeGeneratorJS.pm        2016-05-19 07:14:45 UTC (rev 201128)
</span><span class="lines">@@ -474,6 +474,7 @@
</span><span class="cx">     return 0 if $interface-&gt;extendedAttributes-&gt;{&quot;CustomProxyToJSObject&quot;};
</span><span class="cx">     return 1 if (!$hasParent or $interface-&gt;extendedAttributes-&gt;{&quot;JSGenerateToJSObject&quot;} or $interface-&gt;extendedAttributes-&gt;{&quot;CustomToJSObject&quot;});
</span><span class="cx">     return 1 if $interface-&gt;parent &amp;&amp; $interface-&gt;parent eq &quot;EventTarget&quot;;
</span><ins>+    return 1 if $interface-&gt;extendedAttributes-&gt;{&quot;Constructor&quot;} or $interface-&gt;extendedAttributes-&gt;{&quot;NamedConstructor&quot;};
</ins><span class="cx">     return 0;
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="lines">@@ -5154,7 +5155,7 @@
</span><span class="cx">                  push(@$outputArray, &quot;        return JSValue::encode(jsUndefined());\n&quot;);
</span><span class="cx">             }
</span><span class="cx"> 
</span><del>-            push(@$outputArray, &quot;    return JSValue::encode(asObject(toJS(state, castedThis-&gt;globalObject(), WTFMove(object))));\n&quot;);
</del><ins>+            push(@$outputArray, &quot;    return JSValue::encode(asObject(toJSNewlyCreated(state, castedThis-&gt;globalObject(), WTFMove(object))));\n&quot;);
</ins><span class="cx">             push(@$outputArray, &quot;}\n\n&quot;);
</span><span class="cx">         }
</span><span class="cx">     }
</span></span></pre></div>
<a id="trunkSourceWebCorebindingsscriptstestJSJSTestInterfacecpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/bindings/scripts/test/JS/JSTestInterface.cpp (201127 => 201128)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/bindings/scripts/test/JS/JSTestInterface.cpp        2016-05-19 05:20:03 UTC (rev 201127)
+++ trunk/Source/WebCore/bindings/scripts/test/JS/JSTestInterface.cpp        2016-05-19 07:14:45 UTC (rev 201128)
</span><span class="lines">@@ -240,7 +240,7 @@
</span><span class="cx">         setDOMException(state, ec);
</span><span class="cx">         return JSValue::encode(JSValue());
</span><span class="cx">     }
</span><del>-    return JSValue::encode(asObject(toJS(state, castedThis-&gt;globalObject(), WTFMove(object))));
</del><ins>+    return JSValue::encode(asObject(toJSNewlyCreated(state, castedThis-&gt;globalObject(), WTFMove(object))));
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> template&lt;&gt; JSValue JSTestInterfaceConstructor::prototypeForStructure(JSC::VM&amp; vm, const JSDOMGlobalObject&amp; globalObject)
</span></span></pre></div>
<a id="trunkSourceWebCorebindingsscriptstestJSJSTestNamedConstructorcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/bindings/scripts/test/JS/JSTestNamedConstructor.cpp (201127 => 201128)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/bindings/scripts/test/JS/JSTestNamedConstructor.cpp        2016-05-19 05:20:03 UTC (rev 201127)
+++ trunk/Source/WebCore/bindings/scripts/test/JS/JSTestNamedConstructor.cpp        2016-05-19 07:14:45 UTC (rev 201128)
</span><span class="lines">@@ -100,7 +100,7 @@
</span><span class="cx">         setDOMException(state, ec);
</span><span class="cx">         return JSValue::encode(JSValue());
</span><span class="cx">     }
</span><del>-    return JSValue::encode(asObject(toJS(state, castedThis-&gt;globalObject(), WTFMove(object))));
</del><ins>+    return JSValue::encode(asObject(toJSNewlyCreated(state, castedThis-&gt;globalObject(), WTFMove(object))));
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> template&lt;&gt; JSValue JSTestNamedConstructorNamedConstructor::prototypeForStructure(JSC::VM&amp; vm, const JSDOMGlobalObject&amp; globalObject)
</span></span></pre></div>
<a id="trunkSourceWebCorebindingsscriptstestJSJSTestNodecpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/bindings/scripts/test/JS/JSTestNode.cpp (201127 => 201128)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/bindings/scripts/test/JS/JSTestNode.cpp        2016-05-19 05:20:03 UTC (rev 201127)
+++ trunk/Source/WebCore/bindings/scripts/test/JS/JSTestNode.cpp        2016-05-19 07:14:45 UTC (rev 201128)
</span><span class="lines">@@ -80,7 +80,7 @@
</span><span class="cx"> {
</span><span class="cx">     auto* castedThis = jsCast&lt;JSTestNodeConstructor*&gt;(state-&gt;callee());
</span><span class="cx">     auto object = TestNode::create();
</span><del>-    return JSValue::encode(asObject(toJS(state, castedThis-&gt;globalObject(), WTFMove(object))));
</del><ins>+    return JSValue::encode(asObject(toJSNewlyCreated(state, castedThis-&gt;globalObject(), WTFMove(object))));
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> template&lt;&gt; JSValue JSTestNodeConstructor::prototypeForStructure(JSC::VM&amp; vm, const JSDOMGlobalObject&amp; globalObject)
</span><span class="lines">@@ -234,5 +234,45 @@
</span><span class="cx">     thisObject-&gt;wrapped().visitJSEventListeners(visitor);
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+#if ENABLE(BINDING_INTEGRITY)
+#if PLATFORM(WIN)
+#pragma warning(disable: 4483)
+extern &quot;C&quot; { extern void (*const __identifier(&quot;??_7TestNode@WebCore@@6B@&quot;)[])(); }
+#else
+extern &quot;C&quot; { extern void* _ZTVN7WebCore8TestNodeE[]; }
+#endif
+#endif
</ins><span class="cx"> 
</span><ins>+JSC::JSValue toJSNewlyCreated(JSC::ExecState*, JSDOMGlobalObject* globalObject, Ref&lt;TestNode&gt;&amp;&amp; impl)
+{
+    return createNewWrapper&lt;JSTestNode&gt;(globalObject, WTFMove(impl));
</ins><span class="cx"> }
</span><ins>+
+JSC::JSValue toJS(JSC::ExecState*, JSDOMGlobalObject* globalObject, TestNode&amp; impl)
+{
+    if (JSValue result = getExistingWrapper&lt;JSTestNode&gt;(globalObject, impl))
+        return result;
+
+#if ENABLE(BINDING_INTEGRITY)
+    void* actualVTablePointer = *(reinterpret_cast&lt;void**&gt;(&amp;impl));
+#if PLATFORM(WIN)
+    void* expectedVTablePointer = reinterpret_cast&lt;void*&gt;(__identifier(&quot;??_7TestNode@WebCore@@6B@&quot;));
+#else
+    void* expectedVTablePointer = &amp;_ZTVN7WebCore8TestNodeE[2];
+#if COMPILER(CLANG)
+    // If this fails TestNode does not have a vtable, so you need to add the
+    // ImplementationLacksVTable attribute to the interface definition
+    static_assert(__is_polymorphic(TestNode), &quot;TestNode is not polymorphic&quot;);
+#endif
+#endif
+    // If you hit this assertion you either have a use after free bug, or
+    // TestNode has subclasses. If TestNode has subclasses that get passed
+    // to toJS() we currently require TestNode you to opt out of binding hardening
+    // by adding the SkipVTableValidation attribute to the interface IDL definition
+    RELEASE_ASSERT(actualVTablePointer == expectedVTablePointer);
+#endif
+    return createNewWrapper&lt;JSTestNode, TestNode&gt;(globalObject, impl);
+}
+
+
+}
</ins></span></pre></div>
<a id="trunkSourceWebCorebindingsscriptstestJSJSTestNodeh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/bindings/scripts/test/JS/JSTestNode.h (201127 => 201128)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/bindings/scripts/test/JS/JSTestNode.h        2016-05-19 05:20:03 UTC (rev 201127)
+++ trunk/Source/WebCore/bindings/scripts/test/JS/JSTestNode.h        2016-05-19 07:14:45 UTC (rev 201128)
</span><span class="lines">@@ -65,6 +65,10 @@
</span><span class="cx"> 
</span><span class="cx"> };
</span><span class="cx"> 
</span><ins>+WEBCORE_TESTSUPPORT_EXPORT JSC::JSValue toJS(JSC::ExecState*, JSDOMGlobalObject*, TestNode&amp;);
+inline JSC::JSValue toJS(JSC::ExecState* state, JSDOMGlobalObject* globalObject, TestNode* impl) { return impl ? toJS(state, globalObject, *impl) : JSC::jsNull(); }
+JSC::JSValue toJSNewlyCreated(JSC::ExecState*, JSDOMGlobalObject*, Ref&lt;TestNode&gt;&amp;&amp;);
+inline JSC::JSValue toJSNewlyCreated(JSC::ExecState* state, JSDOMGlobalObject* globalObject, RefPtr&lt;TestNode&gt;&amp;&amp; impl) { return impl ? toJSNewlyCreated(state, globalObject, impl.releaseNonNull()) : JSC::jsNull(); }
</ins><span class="cx"> 
</span><span class="cx"> 
</span><span class="cx"> } // namespace WebCore
</span></span></pre></div>
<a id="trunkSourceWebCorebindingsscriptstestJSJSTestObjcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/bindings/scripts/test/JS/JSTestObj.cpp (201127 => 201128)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/bindings/scripts/test/JS/JSTestObj.cpp        2016-05-19 05:20:03 UTC (rev 201127)
+++ trunk/Source/WebCore/bindings/scripts/test/JS/JSTestObj.cpp        2016-05-19 07:14:45 UTC (rev 201128)
</span><span class="lines">@@ -1024,7 +1024,7 @@
</span><span class="cx">         return throwArgumentMustBeFunctionError(*state, 1, &quot;testCallbackFunction&quot;, &quot;TestObj&quot;, nullptr);
</span><span class="cx">     RefPtr&lt;TestCallbackFunction&gt; testCallbackFunction = JSTestCallbackFunction::create(asObject(state-&gt;uncheckedArgument(1)), castedThis-&gt;globalObject());
</span><span class="cx">     auto object = TestObj::create(*testCallback, *testCallbackFunction);
</span><del>-    return JSValue::encode(asObject(toJS(state, castedThis-&gt;globalObject(), WTFMove(object))));
</del><ins>+    return JSValue::encode(asObject(toJSNewlyCreated(state, castedThis-&gt;globalObject(), WTFMove(object))));
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> template&lt;&gt; JSValue JSTestObjConstructor::prototypeForStructure(JSC::VM&amp; vm, const JSDOMGlobalObject&amp; globalObject)
</span></span></pre></div>
<a id="trunkSourceWebCorebindingsscriptstestJSJSTestOverloadedConstructorscpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/bindings/scripts/test/JS/JSTestOverloadedConstructors.cpp (201127 => 201128)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/bindings/scripts/test/JS/JSTestOverloadedConstructors.cpp        2016-05-19 05:20:03 UTC (rev 201127)
+++ trunk/Source/WebCore/bindings/scripts/test/JS/JSTestOverloadedConstructors.cpp        2016-05-19 07:14:45 UTC (rev 201128)
</span><span class="lines">@@ -76,7 +76,7 @@
</span><span class="cx">     if (UNLIKELY(!arrayBuffer))
</span><span class="cx">         return throwArgumentTypeError(*state, 0, &quot;arrayBuffer&quot;, &quot;TestOverloadedConstructors&quot;, nullptr, &quot;ArrayBuffer&quot;);
</span><span class="cx">     auto object = TestOverloadedConstructors::create(*arrayBuffer);
</span><del>-    return JSValue::encode(asObject(toJS(state, castedThis-&gt;globalObject(), WTFMove(object))));
</del><ins>+    return JSValue::encode(asObject(toJSNewlyCreated(state, castedThis-&gt;globalObject(), WTFMove(object))));
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> static inline EncodedJSValue constructJSTestOverloadedConstructors2(ExecState* state)
</span><span class="lines">@@ -90,7 +90,7 @@
</span><span class="cx">     if (UNLIKELY(!arrayBufferView))
</span><span class="cx">         return throwArgumentTypeError(*state, 0, &quot;arrayBufferView&quot;, &quot;TestOverloadedConstructors&quot;, nullptr, &quot;ArrayBufferView&quot;);
</span><span class="cx">     auto object = TestOverloadedConstructors::create(*arrayBufferView);
</span><del>-    return JSValue::encode(asObject(toJS(state, castedThis-&gt;globalObject(), WTFMove(object))));
</del><ins>+    return JSValue::encode(asObject(toJSNewlyCreated(state, castedThis-&gt;globalObject(), WTFMove(object))));
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> static inline EncodedJSValue constructJSTestOverloadedConstructors3(ExecState* state)
</span><span class="lines">@@ -102,7 +102,7 @@
</span><span class="cx">     if (UNLIKELY(!blob))
</span><span class="cx">         return throwArgumentTypeError(*state, 0, &quot;blob&quot;, &quot;TestOverloadedConstructors&quot;, nullptr, &quot;Blob&quot;);
</span><span class="cx">     auto object = TestOverloadedConstructors::create(*blob);
</span><del>-    return JSValue::encode(asObject(toJS(state, castedThis-&gt;globalObject(), WTFMove(object))));
</del><ins>+    return JSValue::encode(asObject(toJSNewlyCreated(state, castedThis-&gt;globalObject(), WTFMove(object))));
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> static inline EncodedJSValue constructJSTestOverloadedConstructors4(ExecState* state)
</span><span class="lines">@@ -114,7 +114,7 @@
</span><span class="cx">     if (UNLIKELY(state-&gt;hadException()))
</span><span class="cx">         return JSValue::encode(jsUndefined());
</span><span class="cx">     auto object = TestOverloadedConstructors::create(string);
</span><del>-    return JSValue::encode(asObject(toJS(state, castedThis-&gt;globalObject(), WTFMove(object))));
</del><ins>+    return JSValue::encode(asObject(toJSNewlyCreated(state, castedThis-&gt;globalObject(), WTFMove(object))));
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> static inline EncodedJSValue constructJSTestOverloadedConstructors5(ExecState* state)
</span><span class="lines">@@ -124,7 +124,7 @@
</span><span class="cx">     if (UNLIKELY(state-&gt;hadException()))
</span><span class="cx">         return JSValue::encode(jsUndefined());
</span><span class="cx">     auto object = TestOverloadedConstructors::create(longArgs);
</span><del>-    return JSValue::encode(asObject(toJS(state, castedThis-&gt;globalObject(), WTFMove(object))));
</del><ins>+    return JSValue::encode(asObject(toJSNewlyCreated(state, castedThis-&gt;globalObject(), WTFMove(object))));
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> template&lt;&gt; EncodedJSValue JSC_HOST_CALL JSTestOverloadedConstructorsConstructor::construct(ExecState* state)
</span></span></pre></div>
<a id="trunkSourceWebCorebindingsscriptstestJSJSTestTypedefscpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/bindings/scripts/test/JS/JSTestTypedefs.cpp (201127 => 201128)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/bindings/scripts/test/JS/JSTestTypedefs.cpp        2016-05-19 05:20:03 UTC (rev 201127)
+++ trunk/Source/WebCore/bindings/scripts/test/JS/JSTestTypedefs.cpp        2016-05-19 07:14:45 UTC (rev 201128)
</span><span class="lines">@@ -136,7 +136,7 @@
</span><span class="cx">         return throwArgumentMustBeFunctionError(*state, 1, &quot;testCallback&quot;, &quot;TestTypedefs&quot;, nullptr);
</span><span class="cx">     RefPtr&lt;TestCallback&gt; testCallback = JSTestCallback::create(asObject(state-&gt;uncheckedArgument(1)), castedThis-&gt;globalObject());
</span><span class="cx">     auto object = TestTypedefs::create(hello, *testCallback);
</span><del>-    return JSValue::encode(asObject(toJS(state, castedThis-&gt;globalObject(), WTFMove(object))));
</del><ins>+    return JSValue::encode(asObject(toJSNewlyCreated(state, castedThis-&gt;globalObject(), WTFMove(object))));
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> template&lt;&gt; JSValue JSTestTypedefsConstructor::prototypeForStructure(JSC::VM&amp; vm, const JSDOMGlobalObject&amp; globalObject)
</span></span></pre>
</div>
</div>

</body>
</html>