<!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>[164505] 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/164505">164505</a></dd>
<dt>Author</dt> <dd>benjamin@webkit.org</dd>
<dt>Date</dt> <dd>2014-02-21 14:47:37 -0800 (Fri, 21 Feb 2014)</dd>
</dl>

<h3>Log Message</h3>
<pre>jsDocumentPrototypeFunctionGetElementById should not create an AtomicString for the function argument
https://bugs.webkit.org/show_bug.cgi?id=128893

Reviewed by Darin Adler.

Source/WebCore: 

The declaration of TreeScope::getElementById() was taking an AtomicString as the parameter.
Because of this, all the call sites manipulating String were creating and keeping alive an AtomicString
to make the call.

This had two negative consequences:
-The call sites were ref-ing the ID's atomic string for no reason.
-When there is no ID associated with the input string, an atomic string was created for the sole
 purpose of failing the query. Since IDs are stored as AtomicString, if there is not an existing
 AtomicString for the input, there is no reason to query anything.

* WebCore.exp.in:
* bindings/js/JSDOMBinding.cpp:
(WebCore::findAtomicString): Update this after the rename.

* bindings/scripts/CodeGeneratorObjC.pm:
(GenerateImplementation):
* bindings/scripts/IDLAttributes.txt:
Now that there are two overloads for TreeScope::getElementById(), the conversion from NSString*
is ambiguous. I add the keyword ObjCExplicitAtomicString to force an explicit conversion to AtomicString.

* dom/Document.idl:
* dom/TreeScope.cpp:
(WebCore::TreeScope::getElementById):
When getting an AtomicString, the case of a empty string is not important, use isNull() instead.
When getting a String, get the corresponding AtomicString if any and use that for getting the element.

* dom/TreeScope.h:
* html/FTPDirectoryDocument.cpp:
(WebCore::FTPDirectoryDocumentParser::loadDocumentTemplate):
Solve the ambiguous call.

* svg/SVGAElement.cpp:
(WebCore::SVGAElement::defaultEventHandler):
This is a wonderful candidate for substringSharingImpl. The substring does not survive the call since
the new getElementById never create any AtomicString.

* svg/SVGSVGElement.cpp:
(WebCore::SVGSVGElement::getElementById):
It looks like there are opportunities to get faster here, Ryosuke should have a look.

* svg/SVGSVGElement.h:
* xml/XMLTreeViewer.cpp:
(WebCore::XMLTreeViewer::transformDocumentToTreeView):
Unrelated cleanup: noStyleMessage was useless.

Source/WebKit2: 

* WebProcess/InjectedBundle/InjectedBundle.cpp:
(WebKit::InjectedBundle::pageNumberForElementById): Remove the explicit conversion to use the right overload.

Source/WTF: 

AtomicString::find() is a special case optimized for the JavaScript bindings. The method can only
be called under specific conditions.
The method is renamed to findStringWithHash().

The new AtomicString::find is generic and does not require any propery on the input.

* wtf/text/AtomicString.cpp:
(WTF::AtomicString::findStringWithHash):
(WTF::AtomicString::findSlowCase):
* wtf/text/AtomicString.h:
(WTF::AtomicString::find):</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkSourceWTFChangeLog">trunk/Source/WTF/ChangeLog</a></li>
<li><a href="#trunkSourceWTFwtftextAtomicStringcpp">trunk/Source/WTF/wtf/text/AtomicString.cpp</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="#trunkSourceWebCoreWebCoreexpin">trunk/Source/WebCore/WebCore.exp.in</a></li>
<li><a href="#trunkSourceWebCorebindingsjsJSDOMBindingcpp">trunk/Source/WebCore/bindings/js/JSDOMBinding.cpp</a></li>
<li><a href="#trunkSourceWebCorebindingsscriptsCodeGeneratorObjCpm">trunk/Source/WebCore/bindings/scripts/CodeGeneratorObjC.pm</a></li>
<li><a href="#trunkSourceWebCorebindingsscriptsIDLAttributestxt">trunk/Source/WebCore/bindings/scripts/IDLAttributes.txt</a></li>
<li><a href="#trunkSourceWebCoredomDocumentidl">trunk/Source/WebCore/dom/Document.idl</a></li>
<li><a href="#trunkSourceWebCoredomTreeScopecpp">trunk/Source/WebCore/dom/TreeScope.cpp</a></li>
<li><a href="#trunkSourceWebCoredomTreeScopeh">trunk/Source/WebCore/dom/TreeScope.h</a></li>
<li><a href="#trunkSourceWebCorehtmlFTPDirectoryDocumentcpp">trunk/Source/WebCore/html/FTPDirectoryDocument.cpp</a></li>
<li><a href="#trunkSourceWebCoresvgSVGAElementcpp">trunk/Source/WebCore/svg/SVGAElement.cpp</a></li>
<li><a href="#trunkSourceWebCoresvgSVGSVGElementcpp">trunk/Source/WebCore/svg/SVGSVGElement.cpp</a></li>
<li><a href="#trunkSourceWebCoresvgSVGSVGElementh">trunk/Source/WebCore/svg/SVGSVGElement.h</a></li>
<li><a href="#trunkSourceWebCorexmlXMLTreeViewercpp">trunk/Source/WebCore/xml/XMLTreeViewer.cpp</a></li>
<li><a href="#trunkSourceWebKit2ChangeLog">trunk/Source/WebKit2/ChangeLog</a></li>
<li><a href="#trunkSourceWebKit2WebProcessInjectedBundleInjectedBundlecpp">trunk/Source/WebKit2/WebProcess/InjectedBundle/InjectedBundle.cpp</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkSourceWTFChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WTF/ChangeLog (164504 => 164505)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WTF/ChangeLog        2014-02-21 22:38:12 UTC (rev 164504)
+++ trunk/Source/WTF/ChangeLog        2014-02-21 22:47:37 UTC (rev 164505)
</span><span class="lines">@@ -1,3 +1,22 @@
</span><ins>+2014-02-21  Benjamin Poulain  &lt;benjamin@webkit.org&gt;
+
+        jsDocumentPrototypeFunctionGetElementById should not create an AtomicString for the function argument
+        https://bugs.webkit.org/show_bug.cgi?id=128893
+
+        Reviewed by Darin Adler.
+
+        AtomicString::find() is a special case optimized for the JavaScript bindings. The method can only
+        be called under specific conditions.
+        The method is renamed to findStringWithHash().
+
+        The new AtomicString::find is generic and does not require any propery on the input.
+
+        * wtf/text/AtomicString.cpp:
+        (WTF::AtomicString::findStringWithHash):
+        (WTF::AtomicString::findSlowCase):
+        * wtf/text/AtomicString.h:
+        (WTF::AtomicString::find):
+
</ins><span class="cx"> 2014-02-20  Csaba Osztrogonác  &lt;ossy@webkit.org&gt;
</span><span class="cx"> 
</span><span class="cx">         Add StackStats sources to cmake and autotools build files
</span></span></pre></div>
<a id="trunkSourceWTFwtftextAtomicStringcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WTF/wtf/text/AtomicString.cpp (164504 => 164505)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WTF/wtf/text/AtomicString.cpp        2014-02-21 22:38:12 UTC (rev 164504)
+++ trunk/Source/WTF/wtf/text/AtomicString.cpp        2014-02-21 22:47:37 UTC (rev 164505)
</span><span class="lines">@@ -404,20 +404,19 @@
</span><span class="cx">     return stringTable().find&lt;HashAndCharactersTranslator&lt;CharacterType&gt;&gt;(buffer);
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-AtomicStringImpl* AtomicString::find(const StringImpl* stringImpl)
</del><ins>+AtomicStringImpl* AtomicString::findStringWithHash(const StringImpl&amp; stringImpl)
</ins><span class="cx"> {
</span><del>-    ASSERT(stringImpl);
-    ASSERT(stringImpl-&gt;existingHash());
</del><ins>+    ASSERT(stringImpl.existingHash());
</ins><span class="cx"> 
</span><del>-    if (!stringImpl-&gt;length())
</del><ins>+    if (!stringImpl.length())
</ins><span class="cx">         return static_cast&lt;AtomicStringImpl*&gt;(StringImpl::empty());
</span><span class="cx"> 
</span><span class="cx">     AtomicStringTableLocker locker;
</span><span class="cx">     HashSet&lt;StringImpl*&gt;::iterator iterator;
</span><del>-    if (stringImpl-&gt;is8Bit())
-        iterator = findString&lt;LChar&gt;(stringImpl);
</del><ins>+    if (stringImpl.is8Bit())
+        iterator = findString&lt;LChar&gt;(&amp;stringImpl);
</ins><span class="cx">     else
</span><del>-        iterator = findString&lt;UChar&gt;(stringImpl);
</del><ins>+        iterator = findString&lt;UChar&gt;(&amp;stringImpl);
</ins><span class="cx">     if (iterator == stringTable().end())
</span><span class="cx">         return 0;
</span><span class="cx">     return static_cast&lt;AtomicStringImpl*&gt;(*iterator);
</span><span class="lines">@@ -449,6 +448,18 @@
</span><span class="cx">     return returnValue;
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+AtomicStringImpl* AtomicString::findSlowCase(StringImpl&amp; string)
+{
+    ASSERT_WITH_MESSAGE(!string.isAtomic(), &quot;AtomicStringImpls should return from the fast case.&quot;);
+
+    AtomicStringTableLocker locker;
+    HashSet&lt;StringImpl*&gt;&amp; atomicStringTable = stringTable();
+    auto iterator = atomicStringTable.find(&amp;string);
+    if (iterator != atomicStringTable.end())
+        return static_cast&lt;AtomicStringImpl*&gt;(*iterator);
+    return nullptr;
+}
+
</ins><span class="cx"> AtomicString AtomicString::fromUTF8Internal(const char* charactersStart, const char* charactersEnd)
</span><span class="cx"> {
</span><span class="cx">     HashAndUTF8Characters buffer;
</span></span></pre></div>
<a id="trunkSourceWTFwtftextAtomicStringh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WTF/wtf/text/AtomicString.h (164504 => 164505)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WTF/wtf/text/AtomicString.h        2014-02-21 22:38:12 UTC (rev 164504)
+++ trunk/Source/WTF/wtf/text/AtomicString.h        2014-02-21 22:47:37 UTC (rev 164505)
</span><span class="lines">@@ -85,7 +85,13 @@
</span><span class="cx">     AtomicString(WTF::HashTableDeletedValueType) : m_string(WTF::HashTableDeletedValue) { }
</span><span class="cx">     bool isHashTableDeletedValue() const { return m_string.isHashTableDeletedValue(); }
</span><span class="cx"> 
</span><del>-    WTF_EXPORT_STRING_API static AtomicStringImpl* find(const StringImpl*);
</del><ins>+    WTF_EXPORT_STRING_API static AtomicStringImpl* findStringWithHash(const StringImpl&amp;);
+    static AtomicStringImpl* find(StringImpl* string)
+    {
+        if (!string || string-&gt;isAtomic())
+            return static_cast&lt;AtomicStringImpl*&gt;(string);
+        return findSlowCase(*string);
+    }
</ins><span class="cx"> 
</span><span class="cx">     operator const String&amp;() const { return m_string; }
</span><span class="cx">     const String&amp; string() const { return m_string; };
</span><span class="lines">@@ -190,6 +196,7 @@
</span><span class="cx">     WTF_EXPORT_STRING_API static PassRefPtr&lt;StringImpl&gt; add(CFStringRef);
</span><span class="cx"> #endif
</span><span class="cx"> 
</span><ins>+    WTF_EXPORT_STRING_API static AtomicStringImpl* findSlowCase(StringImpl&amp;);
</ins><span class="cx">     WTF_EXPORT_STRING_API static AtomicString fromUTF8Internal(const char*, const char*);
</span><span class="cx"> 
</span><span class="cx"> #if !ASSERT_DISABLED
</span></span></pre></div>
<a id="trunkSourceWebCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/ChangeLog (164504 => 164505)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/ChangeLog        2014-02-21 22:38:12 UTC (rev 164504)
+++ trunk/Source/WebCore/ChangeLog        2014-02-21 22:47:37 UTC (rev 164505)
</span><span class="lines">@@ -1,3 +1,55 @@
</span><ins>+2014-02-21  Benjamin Poulain  &lt;benjamin@webkit.org&gt;
+
+        jsDocumentPrototypeFunctionGetElementById should not create an AtomicString for the function argument
+        https://bugs.webkit.org/show_bug.cgi?id=128893
+
+        Reviewed by Darin Adler.
+
+        The declaration of TreeScope::getElementById() was taking an AtomicString as the parameter.
+        Because of this, all the call sites manipulating String were creating and keeping alive an AtomicString
+        to make the call.
+
+        This had two negative consequences:
+        -The call sites were ref-ing the ID's atomic string for no reason.
+        -When there is no ID associated with the input string, an atomic string was created for the sole
+         purpose of failing the query. Since IDs are stored as AtomicString, if there is not an existing
+         AtomicString for the input, there is no reason to query anything.
+
+        * WebCore.exp.in:
+        * bindings/js/JSDOMBinding.cpp:
+        (WebCore::findAtomicString): Update this after the rename.
+
+        * bindings/scripts/CodeGeneratorObjC.pm:
+        (GenerateImplementation):
+        * bindings/scripts/IDLAttributes.txt:
+        Now that there are two overloads for TreeScope::getElementById(), the conversion from NSString*
+        is ambiguous. I add the keyword ObjCExplicitAtomicString to force an explicit conversion to AtomicString.
+
+        * dom/Document.idl:
+        * dom/TreeScope.cpp:
+        (WebCore::TreeScope::getElementById):
+        When getting an AtomicString, the case of a empty string is not important, use isNull() instead.
+        When getting a String, get the corresponding AtomicString if any and use that for getting the element.
+
+        * dom/TreeScope.h:
+        * html/FTPDirectoryDocument.cpp:
+        (WebCore::FTPDirectoryDocumentParser::loadDocumentTemplate):
+        Solve the ambiguous call.
+
+        * svg/SVGAElement.cpp:
+        (WebCore::SVGAElement::defaultEventHandler):
+        This is a wonderful candidate for substringSharingImpl. The substring does not survive the call since
+        the new getElementById never create any AtomicString.
+
+        * svg/SVGSVGElement.cpp:
+        (WebCore::SVGSVGElement::getElementById):
+        It looks like there are opportunities to get faster here, Ryosuke should have a look.
+
+        * svg/SVGSVGElement.h:
+        * xml/XMLTreeViewer.cpp:
+        (WebCore::XMLTreeViewer::transformDocumentToTreeView):
+        Unrelated cleanup: noStyleMessage was useless.
+
</ins><span class="cx"> 2014-02-21  Daniel Bates  &lt;dabates@apple.com&gt;
</span><span class="cx"> 
</span><span class="cx">         COL element in table has 0 for offsetWidth
</span></span></pre></div>
<a id="trunkSourceWebCoreWebCoreexpin"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/WebCore.exp.in (164504 => 164505)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/WebCore.exp.in        2014-02-21 22:38:12 UTC (rev 164504)
+++ trunk/Source/WebCore/WebCore.exp.in        2014-02-21 22:47:37 UTC (rev 164505)
</span><span class="lines">@@ -1876,7 +1876,7 @@
</span><span class="cx"> __ZNK7WebCore9PageCache10frameCountEv
</span><span class="cx"> __ZNK7WebCore9RenderBox11clientWidthEv
</span><span class="cx"> __ZNK7WebCore9RenderBox12clientHeightEv
</span><del>-__ZNK7WebCore9TreeScope14getElementByIdERKN3WTF12AtomicStringE
</del><ins>+__ZNK7WebCore9TreeScope14getElementByIdERKN3WTF6StringE
</ins><span class="cx"> __ZTVN7WebCore12ChromeClientE
</span><span class="cx"> __ZTVN7WebCore14LoaderStrategyE
</span><span class="cx"> __ZTVN7WebCore14StaticNodeListE
</span></span></pre></div>
<a id="trunkSourceWebCorebindingsjsJSDOMBindingcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/bindings/js/JSDOMBinding.cpp (164504 => 164505)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/bindings/js/JSDOMBinding.cpp        2014-02-21 22:38:12 UTC (rev 164504)
+++ trunk/Source/WebCore/bindings/js/JSDOMBinding.cpp        2014-02-21 22:47:37 UTC (rev 164505)
</span><span class="lines">@@ -108,7 +108,7 @@
</span><span class="cx">     if (!impl)
</span><span class="cx">         return 0;
</span><span class="cx">     ASSERT(impl-&gt;existingHash());
</span><del>-    return AtomicString::find(impl);
</del><ins>+    return AtomicString::findStringWithHash(*impl);
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> String valueToStringWithNullCheck(ExecState* exec, JSValue value)
</span></span></pre></div>
<a id="trunkSourceWebCorebindingsscriptsCodeGeneratorObjCpm"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/bindings/scripts/CodeGeneratorObjC.pm (164504 => 164505)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/bindings/scripts/CodeGeneratorObjC.pm        2014-02-21 22:38:12 UTC (rev 164504)
+++ trunk/Source/WebCore/bindings/scripts/CodeGeneratorObjC.pm        2014-02-21 22:47:37 UTC (rev 164505)
</span><span class="lines">@@ -1474,7 +1474,12 @@
</span><span class="cx">                 AddIncludesForType($param-&gt;type);
</span><span class="cx"> 
</span><span class="cx">                 my $idlType = $param-&gt;type;
</span><del>-                my $implGetter = GetObjCTypeGetter($paramName, $idlType);
</del><ins>+                my $implGetter;
+                if ($param-&gt;extendedAttributes-&gt;{&quot;ObjCExplicitAtomicString&quot;}) {
+                    $implGetter = &quot;AtomicString($paramName)&quot;
+                } else {
+                    $implGetter = GetObjCTypeGetter($paramName, $idlType);
+                }
</ins><span class="cx"> 
</span><span class="cx">                 push(@parameterNames, $implGetter);
</span><span class="cx">                 $needsCustom{&quot;XPathNSResolver&quot;} = $paramName if $idlType eq &quot;XPathNSResolver&quot;;
</span></span></pre></div>
<a id="trunkSourceWebCorebindingsscriptsIDLAttributestxt"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/bindings/scripts/IDLAttributes.txt (164504 => 164505)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/bindings/scripts/IDLAttributes.txt        2014-02-21 22:38:12 UTC (rev 164504)
+++ trunk/Source/WebCore/bindings/scripts/IDLAttributes.txt        2014-02-21 22:47:37 UTC (rev 164505)
</span><span class="lines">@@ -88,6 +88,7 @@
</span><span class="cx"> NotEnumerable
</span><span class="cx"> NotDeletable
</span><span class="cx"> ObjCCustomImplementation
</span><ins>+ObjCExplicitAtomicString
</ins><span class="cx"> ObjCLegacyUnnamedParameters
</span><span class="cx"> ObjCPolymorphic
</span><span class="cx"> ObjCProtocol
</span></span></pre></div>
<a id="trunkSourceWebCoredomDocumentidl"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/dom/Document.idl (164504 => 164505)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/dom/Document.idl        2014-02-21 22:38:12 UTC (rev 164504)
+++ trunk/Source/WebCore/dom/Document.idl        2014-02-21 22:47:37 UTC (rev 164505)
</span><span class="lines">@@ -51,7 +51,7 @@
</span><span class="cx">                                                                           [TreatNullAs=NullString,Default=Undefined] optional DOMString qualifiedName);
</span><span class="cx">     [ObjCLegacyUnnamedParameters] NodeList getElementsByTagNameNS([TreatNullAs=NullString,Default=Undefined] optional DOMString namespaceURI,
</span><span class="cx">                                                    [Default=Undefined] optional DOMString localName);
</span><del>-    Element getElementById([Default=Undefined] optional DOMString elementId);
</del><ins>+    Element getElementById([Default=Undefined,ObjCExplicitAtomicString] optional DOMString elementId);
</ins><span class="cx"> 
</span><span class="cx">     // DOM Level 3 Core
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceWebCoredomTreeScopecpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/dom/TreeScope.cpp (164504 => 164505)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/dom/TreeScope.cpp        2014-02-21 22:38:12 UTC (rev 164504)
+++ trunk/Source/WebCore/dom/TreeScope.cpp        2014-02-21 22:47:37 UTC (rev 164505)
</span><span class="lines">@@ -102,13 +102,24 @@
</span><span class="cx"> 
</span><span class="cx"> Element* TreeScope::getElementById(const AtomicString&amp; elementId) const
</span><span class="cx"> {
</span><del>-    if (elementId.isEmpty())
</del><ins>+    if (elementId.isNull())
</ins><span class="cx">         return nullptr;
</span><span class="cx">     if (!m_elementsById)
</span><span class="cx">         return nullptr;
</span><span class="cx">     return m_elementsById-&gt;getElementById(*elementId.impl(), *this);
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+Element* TreeScope::getElementById(const String&amp; elementId) const
+{
+    if (!m_elementsById)
+        return nullptr;
+
+    if (AtomicStringImpl* atomicElementId = AtomicString::find(elementId.impl()))
+        return m_elementsById-&gt;getElementById(*atomicElementId, *this);
+
+    return nullptr;
+}
+
</ins><span class="cx"> const Vector&lt;Element*&gt;* TreeScope::getAllElementsById(const AtomicString&amp; elementId) const
</span><span class="cx"> {
</span><span class="cx">     if (elementId.isEmpty())
</span></span></pre></div>
<a id="trunkSourceWebCoredomTreeScopeh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/dom/TreeScope.h (164504 => 164505)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/dom/TreeScope.h        2014-02-21 22:38:12 UTC (rev 164504)
+++ trunk/Source/WebCore/dom/TreeScope.h        2014-02-21 22:47:37 UTC (rev 164505)
</span><span class="lines">@@ -55,6 +55,7 @@
</span><span class="cx"> 
</span><span class="cx">     Element* focusedElement();
</span><span class="cx">     Element* getElementById(const AtomicString&amp;) const;
</span><ins>+    Element* getElementById(const String&amp;) const;
</ins><span class="cx">     const Vector&lt;Element*&gt;* getAllElementsById(const AtomicString&amp;) const;
</span><span class="cx">     bool hasElementWithId(const AtomicStringImpl&amp;) const;
</span><span class="cx">     bool containsMultipleElementsWithId(const AtomicString&amp; id) const;
</span></span></pre></div>
<a id="trunkSourceWebCorehtmlFTPDirectoryDocumentcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/html/FTPDirectoryDocument.cpp (164504 => 164505)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/html/FTPDirectoryDocument.cpp        2014-02-21 22:38:12 UTC (rev 164504)
+++ trunk/Source/WebCore/html/FTPDirectoryDocument.cpp        2014-02-21 22:47:37 UTC (rev 164505)
</span><span class="lines">@@ -297,7 +297,7 @@
</span><span class="cx"> 
</span><span class="cx">     HTMLDocumentParser::insert(String(templateDocumentData-&gt;data(), templateDocumentData-&gt;size()));
</span><span class="cx"> 
</span><del>-    RefPtr&lt;Element&gt; tableElement = document()-&gt;getElementById(&quot;ftpDirectoryTable&quot;);
</del><ins>+    RefPtr&lt;Element&gt; tableElement = document()-&gt;getElementById(String(ASCIILiteral(&quot;ftpDirectoryTable&quot;)));
</ins><span class="cx">     if (!tableElement)
</span><span class="cx">         LOG_ERROR(&quot;Unable to find element by id \&quot;ftpDirectoryTable\&quot; in the template document.&quot;);
</span><span class="cx">     else if (!isHTMLTableElement(tableElement.get()))
</span></span></pre></div>
<a id="trunkSourceWebCoresvgSVGAElementcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/svg/SVGAElement.cpp (164504 => 164505)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/svg/SVGAElement.cpp        2014-02-21 22:38:12 UTC (rev 164504)
+++ trunk/Source/WebCore/svg/SVGAElement.cpp        2014-02-21 22:47:37 UTC (rev 164505)
</span><span class="lines">@@ -158,7 +158,7 @@
</span><span class="cx">             String url = stripLeadingAndTrailingHTMLSpaces(href());
</span><span class="cx"> 
</span><span class="cx">             if (url[0] == '#') {
</span><del>-                Element* targetElement = treeScope().getElementById(url.substring(1));
</del><ins>+                Element* targetElement = treeScope().getElementById(url.substringSharingImpl(1));
</ins><span class="cx">                 if (targetElement &amp;&amp; isSVGSMILElement(*targetElement)) {
</span><span class="cx">                     toSVGSMILElement(*targetElement).beginByLinkActivation();
</span><span class="cx">                     event-&gt;setDefaultHandled();
</span></span></pre></div>
<a id="trunkSourceWebCoresvgSVGSVGElementcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/svg/SVGSVGElement.cpp (164504 => 164505)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/svg/SVGSVGElement.cpp        2014-02-21 22:38:12 UTC (rev 164504)
+++ trunk/Source/WebCore/svg/SVGSVGElement.cpp        2014-02-21 22:47:37 UTC (rev 164505)
</span><span class="lines">@@ -765,12 +765,13 @@
</span><span class="cx"> 
</span><span class="cx"> // getElementById on SVGSVGElement is restricted to only the child subtree defined by the &lt;svg&gt; element.
</span><span class="cx"> // See http://www.w3.org/TR/SVG11/struct.html#InterfaceSVGSVGElement
</span><del>-Element* SVGSVGElement::getElementById(const AtomicString&amp; id)
</del><ins>+Element* SVGSVGElement::getElementById(const String&amp; id)
</ins><span class="cx"> {
</span><span class="cx">     Element* element = treeScope().getElementById(id);
</span><span class="cx">     if (element &amp;&amp; element-&gt;isDescendantOf(this))
</span><span class="cx">         return element;
</span><span class="cx"> 
</span><ins>+    // FIXME: This should use treeScope().getAllElementsById.
</ins><span class="cx">     // Fall back to traversing our subtree. Duplicate ids are allowed, the first found will
</span><span class="cx">     // be returned.
</span><span class="cx">     for (auto&amp; element : descendantsOfType&lt;Element&gt;(*this)) {
</span></span></pre></div>
<a id="trunkSourceWebCoresvgSVGSVGElementh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/svg/SVGSVGElement.h (164504 => 164505)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/svg/SVGSVGElement.h        2014-02-21 22:38:12 UTC (rev 164504)
+++ trunk/Source/WebCore/svg/SVGSVGElement.h        2014-02-21 22:47:37 UTC (rev 164505)
</span><span class="lines">@@ -122,7 +122,7 @@
</span><span class="cx"> 
</span><span class="cx">     void setupInitialView(const String&amp; fragmentIdentifier, Element* anchorNode);
</span><span class="cx"> 
</span><del>-    Element* getElementById(const AtomicString&amp;);
</del><ins>+    Element* getElementById(const String&amp;);
</ins><span class="cx"> 
</span><span class="cx">     bool widthAttributeEstablishesViewport() const;
</span><span class="cx">     bool heightAttributeEstablishesViewport() const;
</span></span></pre></div>
<a id="trunkSourceWebCorexmlXMLTreeViewercpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/xml/XMLTreeViewer.cpp (164504 => 164505)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/xml/XMLTreeViewer.cpp        2014-02-21 22:38:12 UTC (rev 164504)
+++ trunk/Source/WebCore/xml/XMLTreeViewer.cpp        2014-02-21 22:47:37 UTC (rev 164505)
</span><span class="lines">@@ -57,12 +57,11 @@
</span><span class="cx"> 
</span><span class="cx">     String scriptString = StringImpl::createWithoutCopying(XMLViewer_js, sizeof(XMLViewer_js));
</span><span class="cx">     m_document.frame()-&gt;script().evaluate(ScriptSourceCode(scriptString));
</span><del>-    String noStyleMessage(&quot;This XML file does not appear to have any style information associated with it. The document tree is shown below.&quot;);
-    m_document.frame()-&gt;script().evaluate(ScriptSourceCode(&quot;prepareWebKitXMLViewer('&quot; + noStyleMessage + &quot;');&quot;));
</del><ins>+    m_document.frame()-&gt;script().evaluate(ScriptSourceCode(AtomicString(&quot;prepareWebKitXMLViewer('This XML file does not appear to have any style information associated with it. The document tree is shown below.');&quot;)));
</ins><span class="cx"> 
</span><span class="cx">     String cssString = StringImpl::createWithoutCopying(XMLViewer_css, sizeof(XMLViewer_css));
</span><span class="cx">     RefPtr&lt;Text&gt; text = m_document.createTextNode(cssString);
</span><del>-    m_document.getElementById(&quot;xml-viewer-style&quot;)-&gt;appendChild(text, IGNORE_EXCEPTION);
</del><ins>+    m_document.getElementById(String(ASCIILiteral(&quot;xml-viewer-style&quot;)))-&gt;appendChild(text, IGNORE_EXCEPTION);
</ins><span class="cx">     m_document.styleResolverChanged(RecalcStyleImmediately);
</span><span class="cx"> }
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceWebKit2ChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/ChangeLog (164504 => 164505)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/ChangeLog        2014-02-21 22:38:12 UTC (rev 164504)
+++ trunk/Source/WebKit2/ChangeLog        2014-02-21 22:47:37 UTC (rev 164505)
</span><span class="lines">@@ -1,3 +1,13 @@
</span><ins>+2014-02-21  Benjamin Poulain  &lt;benjamin@webkit.org&gt;
+
+        jsDocumentPrototypeFunctionGetElementById should not create an AtomicString for the function argument
+        https://bugs.webkit.org/show_bug.cgi?id=128893
+
+        Reviewed by Darin Adler.
+
+        * WebProcess/InjectedBundle/InjectedBundle.cpp:
+        (WebKit::InjectedBundle::pageNumberForElementById): Remove the explicit conversion to use the right overload.
+
</ins><span class="cx"> 2014-02-21  Enrica Casucci  &lt;enrica@apple.com&gt;
</span><span class="cx"> 
</span><span class="cx">         Support WebSelections in WK2 on iOS.
</span></span></pre></div>
<a id="trunkSourceWebKit2WebProcessInjectedBundleInjectedBundlecpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/WebProcess/InjectedBundle/InjectedBundle.cpp (164504 => 164505)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/WebProcess/InjectedBundle/InjectedBundle.cpp        2014-02-21 22:38:12 UTC (rev 164504)
+++ trunk/Source/WebKit2/WebProcess/InjectedBundle/InjectedBundle.cpp        2014-02-21 22:47:37 UTC (rev 164505)
</span><span class="lines">@@ -446,7 +446,7 @@
</span><span class="cx">     if (!coreFrame)
</span><span class="cx">         return -1;
</span><span class="cx"> 
</span><del>-    Element* element = coreFrame-&gt;document()-&gt;getElementById(AtomicString(id));
</del><ins>+    Element* element = coreFrame-&gt;document()-&gt;getElementById(id);
</ins><span class="cx">     if (!element)
</span><span class="cx">         return -1;
</span><span class="cx"> 
</span></span></pre>
</div>
</div>

</body>
</html>