<!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>[200562] trunk/Source</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/200562">200562</a></dd>
<dt>Author</dt> <dd>cdumez@apple.com</dd>
<dt>Date</dt> <dd>2016-05-08 14:56:57 -0700 (Sun, 08 May 2016)</dd>
</dl>
<h3>Log Message</h3>
<pre>[Bindings] Simplify [RequiresExistingAtomicString] IDL extended attribute handling
https://bugs.webkit.org/show_bug.cgi?id=157465
Reviewed by Darin Adler.
Source/WebCore:
Simplify [RequiresExistingAtomicString] IDL extended attribute handling
in the bindings generator.
* bindings/scripts/CodeGeneratorJS.pm:
(GenerateParametersCheck):
Drop code specific to [RequiresExistingAtomicString].
(JSValueToNative):
Deal with [RequiresExistingAtomicString] IDL extended attribute,
similarly to [AtomicString] and [TreatNullAs].
* bindings/scripts/test/JS/JSTestObj.cpp:
* bindings/scripts/test/TestObj.idl:
Add bindings test coverage.
* dom/DocumentFragment.cpp:
(WebCore::DocumentFragment::getElementById):
* svg/SVGSVGElement.cpp:
(WebCore::SVGSVGElement::getElementById):
Add null check for the id parameter. The generated bindings used to do
this null check for us but it is no longer the case (to make the bindings
generator a bit simpler). This extended attribute is not commonly used
and is meant as a micro-optimization for getElementById().
Source/WTF:
Add an AtomicString(RefPtr<AtomicStringImpl>&&) constructor that is now
used by the bindings when [RequiresExistingAtomicString] is used. This
is more efficient than using AtomicString(AtomicStringImpl*) as the
caller has a RefPtr<AtomicStringImpl> and is consistent with the
pre-existing String(RefPtr<AtomicStringImpl>&&) constructor.
* wtf/text/AtomicString.h:
(WTF::AtomicString::AtomicString):</pre>
<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkSourceWTFChangeLog">trunk/Source/WTF/ChangeLog</a></li>
<li><a href="#trunkSourceWTFwtftextAtomicStringh">trunk/Source/WTF/wtf/text/AtomicString.h</a></li>
<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>
<li><a href="#trunkSourceWebCoredomDocumentFragmentcpp">trunk/Source/WebCore/dom/DocumentFragment.cpp</a></li>
<li><a href="#trunkSourceWebCoresvgSVGSVGElementcpp">trunk/Source/WebCore/svg/SVGSVGElement.cpp</a></li>
</ul>
</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkSourceWTFChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WTF/ChangeLog (200561 => 200562)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WTF/ChangeLog        2016-05-08 19:11:03 UTC (rev 200561)
+++ trunk/Source/WTF/ChangeLog        2016-05-08 21:56:57 UTC (rev 200562)
</span><span class="lines">@@ -1,3 +1,19 @@
</span><ins>+2016-05-08 Chris Dumez <cdumez@apple.com>
+
+ [Bindings] Simplify [RequiresExistingAtomicString] IDL extended attribute handling
+ https://bugs.webkit.org/show_bug.cgi?id=157465
+
+ Reviewed by Darin Adler.
+
+ Add an AtomicString(RefPtr<AtomicStringImpl>&&) constructor that is now
+ used by the bindings when [RequiresExistingAtomicString] is used. This
+ is more efficient than using AtomicString(AtomicStringImpl*) as the
+ caller has a RefPtr<AtomicStringImpl> and is consistent with the
+ pre-existing String(RefPtr<AtomicStringImpl>&&) constructor.
+
+ * wtf/text/AtomicString.h:
+ (WTF::AtomicString::AtomicString):
+
</ins><span class="cx"> 2016-05-08 Darin Adler <darin@apple.com>
</span><span class="cx">
</span><span class="cx"> * wtf/text/WTFString.h: Remove pragma once. Not working for some reason.
</span></span></pre></div>
<a id="trunkSourceWTFwtftextAtomicStringh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WTF/wtf/text/AtomicString.h (200561 => 200562)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WTF/wtf/text/AtomicString.h        2016-05-08 19:11:03 UTC (rev 200561)
+++ trunk/Source/WTF/wtf/text/AtomicString.h        2016-05-08 21:56:57 UTC (rev 200562)
</span><span class="lines">@@ -56,6 +56,7 @@
</span><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> AtomicString(AtomicStringImpl*);
</span><ins>+ AtomicString(RefPtr<AtomicStringImpl>&&);
</ins><span class="cx"> ATOMICSTRING_CONVERSION AtomicString(StringImpl*);
</span><span class="cx"> ATOMICSTRING_CONVERSION AtomicString(const String&);
</span><span class="cx"> AtomicString(StringImpl* baseString, unsigned start, unsigned length);
</span><span class="lines">@@ -259,6 +260,11 @@
</span><span class="cx"> {
</span><span class="cx"> }
</span><span class="cx">
</span><ins>+inline AtomicString::AtomicString(RefPtr<AtomicStringImpl>&& imp)
+ : m_string(WTFMove(imp))
+{
+}
+
</ins><span class="cx"> inline AtomicString::AtomicString(StringImpl* imp)
</span><span class="cx"> : m_string(AtomicStringImpl::add(imp))
</span><span class="cx"> {
</span></span></pre></div>
<a id="trunkSourceWebCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/ChangeLog (200561 => 200562)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/ChangeLog        2016-05-08 19:11:03 UTC (rev 200561)
+++ trunk/Source/WebCore/ChangeLog        2016-05-08 21:56:57 UTC (rev 200562)
</span><span class="lines">@@ -1,3 +1,34 @@
</span><ins>+2016-05-08 Chris Dumez <cdumez@apple.com>
+
+ [Bindings] Simplify [RequiresExistingAtomicString] IDL extended attribute handling
+ https://bugs.webkit.org/show_bug.cgi?id=157465
+
+ Reviewed by Darin Adler.
+
+ Simplify [RequiresExistingAtomicString] IDL extended attribute handling
+ in the bindings generator.
+
+ * bindings/scripts/CodeGeneratorJS.pm:
+ (GenerateParametersCheck):
+ Drop code specific to [RequiresExistingAtomicString].
+
+ (JSValueToNative):
+ Deal with [RequiresExistingAtomicString] IDL extended attribute,
+ similarly to [AtomicString] and [TreatNullAs].
+
+ * bindings/scripts/test/JS/JSTestObj.cpp:
+ * bindings/scripts/test/TestObj.idl:
+ Add bindings test coverage.
+
+ * dom/DocumentFragment.cpp:
+ (WebCore::DocumentFragment::getElementById):
+ * svg/SVGSVGElement.cpp:
+ (WebCore::SVGSVGElement::getElementById):
+ Add null check for the id parameter. The generated bindings used to do
+ this null check for us but it is no longer the case (to make the bindings
+ generator a bit simpler). This extended attribute is not commonly used
+ and is meant as a micro-optimization for getElementById().
+
</ins><span class="cx"> 2016-05-08 David Kilzer <ddkilzer@apple.com>
</span><span class="cx">
</span><span class="cx"> Roll out: ThreadSanitizer: Data race and thread leak in WebCore::ScrollingThread::createThreadIfNeeded
</span></span></pre></div>
<a id="trunkSourceWebCorebindingsscriptsCodeGeneratorJSpm"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/bindings/scripts/CodeGeneratorJS.pm (200561 => 200562)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/bindings/scripts/CodeGeneratorJS.pm        2016-05-08 19:11:03 UTC (rev 200561)
+++ trunk/Source/WebCore/bindings/scripts/CodeGeneratorJS.pm        2016-05-08 21:56:57 UTC (rev 200562)
</span><span class="lines">@@ -3748,56 +3748,47 @@
</span><span class="cx"> }
</span><span class="cx"> }
</span><span class="cx">
</span><del>- if ($parameter->extendedAttributes->{"RequiresExistingAtomicString"}) {
- # FIXME: This could be made slightly more efficient if we added an AtomicString(RefPtr<AtomicStringImpl>&&) constructor and removed the call to get() here.
- push(@$outputArray, " AtomicString $name = state->argument($argumentIndex).toString(state)->toExistingAtomicString(state).get();\n");
- push(@$outputArray, " if ($name.isNull())\n");
- push(@$outputArray, " return JSValue::encode(jsNull());\n");
- push(@$outputArray, " if (UNLIKELY(state->hadException()))\n");
- push(@$outputArray, " return JSValue::encode(jsUndefined());\n");
- } else {
- my $outer;
- my $inner;
- my $nativeType = GetNativeTypeFromSignature($interface, $parameter);
</del><ins>+ my $outer;
+ my $inner;
+ my $nativeType = GetNativeTypeFromSignature($interface, $parameter);
</ins><span class="cx">
</span><del>- if ($parameter->isOptional && defined($parameter->default) && !WillConvertUndefinedToDefaultParameterValue($type, $parameter->default)) {
- my $defaultValue = $parameter->default;
</del><ins>+ if ($parameter->isOptional && defined($parameter->default) && !WillConvertUndefinedToDefaultParameterValue($type, $parameter->default)) {
+ my $defaultValue = $parameter->default;
</ins><span class="cx">
</span><del>- # String-related optimizations.
- if ($type eq "DOMString") {
- my $useAtomicString = $parameter->extendedAttributes->{"AtomicString"};
- if ($defaultValue eq "null") {
- $defaultValue = $useAtomicString ? "nullAtom" : "String()";
- } elsif ($defaultValue eq "\"\"") {
- $defaultValue = $useAtomicString ? "emptyAtom" : "emptyString()";
- } else {
- $defaultValue = $useAtomicString ? "AtomicString($defaultValue, AtomicString::ConstructFromLiteral)" : "ASCIILiteral($defaultValue)";
- }
</del><ins>+ # String-related optimizations.
+ if ($type eq "DOMString") {
+ my $useAtomicString = $parameter->extendedAttributes->{"AtomicString"};
+ if ($defaultValue eq "null") {
+ $defaultValue = $useAtomicString ? "nullAtom" : "String()";
+ } elsif ($defaultValue eq "\"\"") {
+ $defaultValue = $useAtomicString ? "emptyAtom" : "emptyString()";
</ins><span class="cx"> } else {
</span><del>- $defaultValue = "nullptr" if $defaultValue eq "null";
- $defaultValue = "PNaN" if $defaultValue eq "NaN";
- $defaultValue = "$nativeType()" if $defaultValue eq "[]";
- $defaultValue = "JSValue::JSUndefined" if $defaultValue eq "undefined";
</del><ins>+ $defaultValue = $useAtomicString ? "AtomicString($defaultValue, AtomicString::ConstructFromLiteral)" : "ASCIILiteral($defaultValue)";
</ins><span class="cx"> }
</span><del>-
- $outer = "state->argument($argumentIndex).isUndefined() ? $defaultValue : ";
- $inner = "state->uncheckedArgument($argumentIndex)";
- } elsif ($parameter->isOptional && !defined($parameter->default)) {
- # Use WTF::Optional<>() for optional parameters that are missing or undefined and that do not have a default value in the IDL.
- $outer = "state->argument($argumentIndex).isUndefined() ? Optional<$nativeType>() : ";
- $inner = "state->uncheckedArgument($argumentIndex)";
</del><span class="cx"> } else {
</span><del>- $outer = "";
- $inner = "state->argument($argumentIndex)";
</del><ins>+ $defaultValue = "nullptr" if $defaultValue eq "null";
+ $defaultValue = "PNaN" if $defaultValue eq "NaN";
+ $defaultValue = "$nativeType()" if $defaultValue eq "[]";
+ $defaultValue = "JSValue::JSUndefined" if $defaultValue eq "undefined";
</ins><span class="cx"> }
</span><del>- my ($nativeValue, $mayThrowException) = JSValueToNative($interface, $parameter, $inner, $function->signature->extendedAttributes->{"Conditional"});
- push(@$outputArray, " auto $name = ${outer}${nativeValue};\n");
- $value = "WTFMove($name)";
- if ($mayThrowException) {
- push(@$outputArray, " if (UNLIKELY(state->hadException()))\n");
- push(@$outputArray, " return JSValue::encode(jsUndefined());\n");
- }
</del><ins>+
+ $outer = "state->argument($argumentIndex).isUndefined() ? $defaultValue : ";
+ $inner = "state->uncheckedArgument($argumentIndex)";
+ } elsif ($parameter->isOptional && !defined($parameter->default)) {
+ # Use WTF::Optional<>() for optional parameters that are missing or undefined and that do not have a default value in the IDL.
+ $outer = "state->argument($argumentIndex).isUndefined() ? Optional<$nativeType>() : ";
+ $inner = "state->uncheckedArgument($argumentIndex)";
+ } else {
+ $outer = "";
+ $inner = "state->argument($argumentIndex)";
</ins><span class="cx"> }
</span><ins>+ my ($nativeValue, $mayThrowException) = JSValueToNative($interface, $parameter, $inner, $function->signature->extendedAttributes->{"Conditional"});
+ push(@$outputArray, " auto $name = ${outer}${nativeValue};\n");
+ $value = "WTFMove($name)";
+ if ($mayThrowException) {
+ push(@$outputArray, " if (UNLIKELY(state->hadException()))\n");
+ push(@$outputArray, " return JSValue::encode(jsUndefined());\n");
+ }
</ins><span class="cx">
</span><span class="cx"> my $isTearOff = $codeGenerator->IsSVGTypeNeedingTearOff($type) && $interfaceName !~ /List$/;
</span><span class="cx"> my $shouldPassByReference = ShouldPassWrapperByReference($parameter, $interface);
</span><span class="lines">@@ -4388,6 +4379,8 @@
</span><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> if ($type eq "DOMString") {
</span><ins>+ return ("AtomicString($value.toString(state)->toExistingAtomicString(state))", 1) if $signature->extendedAttributes->{"RequiresExistingAtomicString"};
+
</ins><span class="cx"> if ($signature->extendedAttributes->{"TreatNullAs"}) {
</span><span class="cx"> return ("valueToStringTreatingNullAsEmptyString(state, $value)", 1) if $signature->extendedAttributes->{"TreatNullAs"} eq "EmptyString";
</span><span class="cx"> return ("valueToStringWithNullCheck(state, $value)", 1) if $signature->extendedAttributes->{"TreatNullAs"} eq "LegacyNullString";
</span></span></pre></div>
<a id="trunkSourceWebCorebindingsscriptstestJSJSTestObjcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/bindings/scripts/test/JS/JSTestObj.cpp (200561 => 200562)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/bindings/scripts/test/JS/JSTestObj.cpp        2016-05-08 19:11:03 UTC (rev 200561)
+++ trunk/Source/WebCore/bindings/scripts/test/JS/JSTestObj.cpp        2016-05-08 21:56:57 UTC (rev 200562)
</span><span class="lines">@@ -25,6 +25,7 @@
</span><span class="cx"> #include "DOMStringList.h"
</span><span class="cx"> #include "Dictionary.h"
</span><span class="cx"> #include "Document.h"
</span><ins>+#include "Element.h"
</ins><span class="cx"> #include "ExceptionCode.h"
</span><span class="cx"> #include "Frame.h"
</span><span class="cx"> #include "HTMLNames.h"
</span><span class="lines">@@ -35,6 +36,7 @@
</span><span class="cx"> #include "JSDOMPromise.h"
</span><span class="cx"> #include "JSDOMStringList.h"
</span><span class="cx"> #include "JSDocument.h"
</span><ins>+#include "JSElement.h"
</ins><span class="cx"> #include "JSEventListener.h"
</span><span class="cx"> #include "JSFetchRequest.h"
</span><span class="cx"> #include "JSNode.h"
</span><span class="lines">@@ -635,6 +637,7 @@
</span><span class="cx"> JSC::EncodedJSValue JSC_HOST_CALL jsTestObjPrototypeFunctionDomStringListFunction(JSC::ExecState*);
</span><span class="cx"> JSC::EncodedJSValue JSC_HOST_CALL jsTestObjPrototypeFunctionMethodWithAndWithoutNullableSequence(JSC::ExecState*);
</span><span class="cx"> JSC::EncodedJSValue JSC_HOST_CALL jsTestObjPrototypeFunctionMethodWithAndWithoutNullableSequence2(JSC::ExecState*);
</span><ins>+JSC::EncodedJSValue JSC_HOST_CALL jsTestObjPrototypeFunctionGetElementById(JSC::ExecState*);
</ins><span class="cx"> JSC::EncodedJSValue JSC_HOST_CALL jsTestObjPrototypeFunctionGetSVGDocument(JSC::ExecState*);
</span><span class="cx"> JSC::EncodedJSValue JSC_HOST_CALL jsTestObjPrototypeFunctionConvert1(JSC::ExecState*);
</span><span class="cx"> JSC::EncodedJSValue JSC_HOST_CALL jsTestObjPrototypeFunctionConvert2(JSC::ExecState*);
</span><span class="lines">@@ -1212,6 +1215,7 @@
</span><span class="cx"> { "domStringListFunction", JSC::Function, NoIntrinsic, { (intptr_t)static_cast<NativeFunction>(jsTestObjPrototypeFunctionDomStringListFunction), (intptr_t) (1) } },
</span><span class="cx"> { "methodWithAndWithoutNullableSequence", JSC::Function, NoIntrinsic, { (intptr_t)static_cast<NativeFunction>(jsTestObjPrototypeFunctionMethodWithAndWithoutNullableSequence), (intptr_t) (2) } },
</span><span class="cx"> { "methodWithAndWithoutNullableSequence2", JSC::Function, NoIntrinsic, { (intptr_t)static_cast<NativeFunction>(jsTestObjPrototypeFunctionMethodWithAndWithoutNullableSequence2), (intptr_t) (2) } },
</span><ins>+ { "getElementById", JSC::Function, NoIntrinsic, { (intptr_t)static_cast<NativeFunction>(jsTestObjPrototypeFunctionGetElementById), (intptr_t) (1) } },
</ins><span class="cx"> { "getSVGDocument", JSC::Function, NoIntrinsic, { (intptr_t)static_cast<NativeFunction>(jsTestObjPrototypeFunctionGetSVGDocument), (intptr_t) (0) } },
</span><span class="cx"> { "convert1", JSC::Function, NoIntrinsic, { (intptr_t)static_cast<NativeFunction>(jsTestObjPrototypeFunctionConvert1), (intptr_t) (1) } },
</span><span class="cx"> { "convert2", JSC::Function, NoIntrinsic, { (intptr_t)static_cast<NativeFunction>(jsTestObjPrototypeFunctionConvert2), (intptr_t) (1) } },
</span><span class="lines">@@ -5637,6 +5641,23 @@
</span><span class="cx"> return JSValue::encode(jsUndefined());
</span><span class="cx"> }
</span><span class="cx">
</span><ins>+EncodedJSValue JSC_HOST_CALL jsTestObjPrototypeFunctionGetElementById(ExecState* state)
+{
+ JSValue thisValue = state->thisValue();
+ auto castedThis = jsDynamicCast<JSTestObj*>(thisValue);
+ if (UNLIKELY(!castedThis))
+ return throwThisTypeError(*state, "TestObj", "getElementById");
+ ASSERT_GC_OBJECT_INHERITS(castedThis, JSTestObj::info());
+ auto& impl = castedThis->wrapped();
+ if (UNLIKELY(state->argumentCount() < 1))
+ return throwVMError(state, createNotEnoughArgumentsError(state));
+ auto elementId = AtomicString(state->argument(0).toString(state)->toExistingAtomicString(state));
+ if (UNLIKELY(state->hadException()))
+ return JSValue::encode(jsUndefined());
+ JSValue result = toJS(state, castedThis->globalObject(), WTF::getPtr(impl.getElementById(WTFMove(elementId))));
+ return JSValue::encode(result);
+}
+
</ins><span class="cx"> EncodedJSValue JSC_HOST_CALL jsTestObjPrototypeFunctionGetSVGDocument(ExecState* state)
</span><span class="cx"> {
</span><span class="cx"> JSValue thisValue = state->thisValue();
</span></span></pre></div>
<a id="trunkSourceWebCorebindingsscriptstestTestObjidl"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/bindings/scripts/test/TestObj.idl (200561 => 200562)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/bindings/scripts/test/TestObj.idl        2016-05-08 19:11:03 UTC (rev 200561)
+++ trunk/Source/WebCore/bindings/scripts/test/TestObj.idl        2016-05-08 21:56:57 UTC (rev 200562)
</span><span class="lines">@@ -290,6 +290,8 @@
</span><span class="cx">
</span><span class="cx"> void methodWithAndWithoutNullableSequence(sequence<unsigned long> arrayArg, sequence<unsigned long>? nullableArrayArg);
</span><span class="cx"> void methodWithAndWithoutNullableSequence2(unsigned long[] arrayArg, unsigned long[]? nullableArrayArg);
</span><ins>+
+ Element? getElementById([RequiresExistingAtomicString] DOMString elementId);
</ins><span class="cx"> #endif
</span><span class="cx">
</span><span class="cx"> [CheckSecurityForNode] readonly attribute Document contentDocument;
</span></span></pre></div>
<a id="trunkSourceWebCoredomDocumentFragmentcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/dom/DocumentFragment.cpp (200561 => 200562)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/dom/DocumentFragment.cpp        2016-05-08 19:11:03 UTC (rev 200561)
+++ trunk/Source/WebCore/dom/DocumentFragment.cpp        2016-05-08 21:56:57 UTC (rev 200562)
</span><span class="lines">@@ -93,6 +93,9 @@
</span><span class="cx">
</span><span class="cx"> Element* DocumentFragment::getElementById(const AtomicString& id) const
</span><span class="cx"> {
</span><ins>+ if (id.isNull())
+ return nullptr;
+
</ins><span class="cx"> // Fast path for ShadowRoot, where we are both a DocumentFragment and a TreeScope.
</span><span class="cx"> if (isTreeScope())
</span><span class="cx"> return treeScope().getElementById(id);
</span></span></pre></div>
<a id="trunkSourceWebCoresvgSVGSVGElementcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/svg/SVGSVGElement.cpp (200561 => 200562)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/svg/SVGSVGElement.cpp        2016-05-08 19:11:03 UTC (rev 200561)
+++ trunk/Source/WebCore/svg/SVGSVGElement.cpp        2016-05-08 21:56:57 UTC (rev 200562)
</span><span class="lines">@@ -672,6 +672,9 @@
</span><span class="cx"> // See http://www.w3.org/TR/SVG11/struct.html#InterfaceSVGSVGElement
</span><span class="cx"> Element* SVGSVGElement::getElementById(const AtomicString& id)
</span><span class="cx"> {
</span><ins>+ if (id.isNull())
+ return nullptr;
+
</ins><span class="cx"> Element* element = treeScope().getElementById(id);
</span><span class="cx"> if (element && element->isDescendantOf(this))
</span><span class="cx"> return element;
</span></span></pre>
</div>
</div>
</body>
</html>