<!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>[202176] trunk</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/202176">202176</a></dd>
<dt>Author</dt> <dd>cdumez@apple.com</dd>
<dt>Date</dt> <dd>2016-06-17 13:18:54 -0700 (Fri, 17 Jun 2016)</dd>
</dl>

<h3>Log Message</h3>
<pre>URL hash setter does not remove fragment identifier if argument is an empty string
https://bugs.webkit.org/show_bug.cgi?id=158869
&lt;rdar://problem/26863430&gt;

Reviewed by Darin Adler.

Source/WebCore:

URL hash setter and URLUtils hash setter should remove the fragment identifier
if set to &quot;#&quot; or &quot;&quot;:
- https://url.spec.whatwg.org/#dom-url-hash
- https://html.spec.whatwg.org/multipage/semantics.html#dom-hyperlink-hash

This patch aligns our behavior with the specification and with other browsers
(tested Firefox and Chrome).

This patch also updates HTMLAnchorElement to inherit URLUtils to avoid code
duplication. HTMLAnchorElement already implements URLUtils in the IDL, as per
the specification:
- https://html.spec.whatwg.org/multipage/semantics.html#htmlanchorelement

No new tests, rebaselined existing tests.

* html/HTMLAnchorElement.cpp:
(WebCore::HTMLAnchorElement::origin): Deleted.
(WebCore::HTMLAnchorElement::text): Deleted.
(WebCore::HTMLAnchorElement::setText): Deleted.
(WebCore::HTMLAnchorElement::toString): Deleted.
(WebCore::HTMLAnchorElement::isLiveLink): Deleted.
(WebCore::HTMLAnchorElement::sendPings): Deleted.
(WebCore::HTMLAnchorElement::handleClick): Deleted.
(WebCore::HTMLAnchorElement::eventType): Deleted.
(WebCore::HTMLAnchorElement::treatLinkAsLiveForEventType): Deleted.
(WebCore::isEnterKeyKeydownEvent): Deleted.
(WebCore::shouldProhibitLinks): Deleted.
(WebCore::HTMLAnchorElement::willRespondToMouseClickEvents): Deleted.
(WebCore::rootEditableElementMap): Deleted.
(WebCore::HTMLAnchorElement::rootEditableElementForSelectionOnMouseDown): Deleted.
(WebCore::HTMLAnchorElement::clearRootEditableElementForSelectionOnMouseDown): Deleted.
(WebCore::HTMLAnchorElement::setRootEditableElementForSelectionOnMouseDown): Deleted.
* html/HTMLAnchorElement.h:
(WebCore::HTMLAnchorElement::invalidateCachedVisitedLinkHash): Deleted.
* html/URLUtils.h:
(WebCore::URLUtils&lt;T&gt;::setHash):

LayoutTests:

Update existing layout tests now that setting hash to &quot;&quot; or &quot;#&quot; clears
the fragment identifier.

* fast/dom/DOMURL/set-href-attribute-hash-expected.txt:
* fast/dom/DOMURL/set-href-attribute-hash.html:
* fast/dom/HTMLAnchorElement/script-tests/set-href-attribute-hash.js:
* fast/dom/HTMLAnchorElement/set-href-attribute-hash-expected.txt:</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkLayoutTestsChangeLog">trunk/LayoutTests/ChangeLog</a></li>
<li><a href="#trunkLayoutTestsfastdomDOMURLsethrefattributehashexpectedtxt">trunk/LayoutTests/fast/dom/DOMURL/set-href-attribute-hash-expected.txt</a></li>
<li><a href="#trunkLayoutTestsfastdomDOMURLsethrefattributehashhtml">trunk/LayoutTests/fast/dom/DOMURL/set-href-attribute-hash.html</a></li>
<li><a href="#trunkLayoutTestsfastdomHTMLAnchorElementscripttestssethrefattributehashjs">trunk/LayoutTests/fast/dom/HTMLAnchorElement/script-tests/set-href-attribute-hash.js</a></li>
<li><a href="#trunkLayoutTestsfastdomHTMLAnchorElementsethrefattributehashexpectedtxt">trunk/LayoutTests/fast/dom/HTMLAnchorElement/set-href-attribute-hash-expected.txt</a></li>
<li><a href="#trunkSourceWebCoreChangeLog">trunk/Source/WebCore/ChangeLog</a></li>
<li><a href="#trunkSourceWebCorehtmlHTMLAnchorElementcpp">trunk/Source/WebCore/html/HTMLAnchorElement.cpp</a></li>
<li><a href="#trunkSourceWebCorehtmlHTMLAnchorElementh">trunk/Source/WebCore/html/HTMLAnchorElement.h</a></li>
<li><a href="#trunkSourceWebCorehtmlURLUtilsh">trunk/Source/WebCore/html/URLUtils.h</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkLayoutTestsChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/ChangeLog (202175 => 202176)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/ChangeLog        2016-06-17 19:51:33 UTC (rev 202175)
+++ trunk/LayoutTests/ChangeLog        2016-06-17 20:18:54 UTC (rev 202176)
</span><span class="lines">@@ -1,3 +1,19 @@
</span><ins>+2016-06-17  Chris Dumez  &lt;cdumez@apple.com&gt;
+
+        URL hash setter does not remove fragment identifier if argument is an empty string
+        https://bugs.webkit.org/show_bug.cgi?id=158869
+        &lt;rdar://problem/26863430&gt;
+
+        Reviewed by Darin Adler.
+
+        Update existing layout tests now that setting hash to &quot;&quot; or &quot;#&quot; clears
+        the fragment identifier.
+
+        * fast/dom/DOMURL/set-href-attribute-hash-expected.txt:
+        * fast/dom/DOMURL/set-href-attribute-hash.html:
+        * fast/dom/HTMLAnchorElement/script-tests/set-href-attribute-hash.js:
+        * fast/dom/HTMLAnchorElement/set-href-attribute-hash-expected.txt:
+
</ins><span class="cx"> 2016-06-17  John Wilander  &lt;wilander@apple.com&gt;
</span><span class="cx"> 
</span><span class="cx">         Ignore case in the check for security origin inheritance
</span></span></pre></div>
<a id="trunkLayoutTestsfastdomDOMURLsethrefattributehashexpectedtxt"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/fast/dom/DOMURL/set-href-attribute-hash-expected.txt (202175 => 202176)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/fast/dom/DOMURL/set-href-attribute-hash-expected.txt        2016-06-17 19:51:33 UTC (rev 202175)
+++ trunk/LayoutTests/fast/dom/DOMURL/set-href-attribute-hash-expected.txt        2016-06-17 20:18:54 UTC (rev 202176)
</span><span class="lines">@@ -15,13 +15,13 @@
</span><span class="cx"> Set hash to null
</span><span class="cx"> PASS a.href is 'https://www.mydomain.com/path/testurl.html#null'
</span><span class="cx"> Set hash to empty string
</span><del>-PASS a.href is 'https://www.mydomain.com/path/testurl.html#'
</del><ins>+PASS a.href is 'https://www.mydomain.com/path/testurl.html'
</ins><span class="cx"> Add hash to mailto: protocol
</span><span class="cx"> PASS a.href is 'mailto:e-mail_address@goes_here#hash-value'
</span><span class="cx"> Add hash to file: protocol
</span><span class="cx"> PASS a.href is 'file:///some%20path#hash value'
</span><span class="cx"> Set hash to '#'
</span><del>-PASS a.href is 'http://mydomain.com/#'
</del><ins>+PASS a.href is 'http://mydomain.com/'
</ins><span class="cx"> Add hash to non-standard protocol
</span><span class="cx"> PASS a.href is 'foo:bar#hash'
</span><span class="cx"> PASS successfullyParsed is true
</span></span></pre></div>
<a id="trunkLayoutTestsfastdomDOMURLsethrefattributehashhtml"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/fast/dom/DOMURL/set-href-attribute-hash.html (202175 => 202176)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/fast/dom/DOMURL/set-href-attribute-hash.html        2016-06-17 19:51:33 UTC (rev 202175)
+++ trunk/LayoutTests/fast/dom/DOMURL/set-href-attribute-hash.html        2016-06-17 20:18:54 UTC (rev 202176)
</span><span class="lines">@@ -44,7 +44,7 @@
</span><span class="cx"> debug(&quot;Set hash to empty string&quot;);
</span><span class="cx"> a.href = &quot;https://www.mydomain.com/path/testurl.html#middle&quot;;
</span><span class="cx"> a.hash = &quot;&quot;;
</span><del>-shouldBe(&quot;a.href&quot;, &quot;'https://www.mydomain.com/path/testurl.html#'&quot;);
</del><ins>+shouldBe(&quot;a.href&quot;, &quot;'https://www.mydomain.com/path/testurl.html'&quot;);
</ins><span class="cx"> 
</span><span class="cx"> // Firefox 3.5.2 does not allow setting hash to mailto: scheme, and it should.
</span><span class="cx"> debug(&quot;Add hash to mailto: protocol&quot;);
</span><span class="lines">@@ -62,7 +62,7 @@
</span><span class="cx"> debug(&quot;Set hash to '#'&quot;);
</span><span class="cx"> a.href = &quot;http://mydomain.com#middle&quot;;
</span><span class="cx"> a.hash = &quot;#&quot;;
</span><del>-shouldBe(&quot;a.href&quot;, &quot;'http://mydomain.com/#'&quot;);
</del><ins>+shouldBe(&quot;a.href&quot;, &quot;'http://mydomain.com/'&quot;);
</ins><span class="cx"> 
</span><span class="cx"> // Firefox 3.5.2 does not allow setting hash to foo: scheme, and it should.
</span><span class="cx"> debug(&quot;Add hash to non-standard protocol&quot;);
</span></span></pre></div>
<a id="trunkLayoutTestsfastdomHTMLAnchorElementscripttestssethrefattributehashjs"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/fast/dom/HTMLAnchorElement/script-tests/set-href-attribute-hash.js (202175 => 202176)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/fast/dom/HTMLAnchorElement/script-tests/set-href-attribute-hash.js        2016-06-17 19:51:33 UTC (rev 202175)
+++ trunk/LayoutTests/fast/dom/HTMLAnchorElement/script-tests/set-href-attribute-hash.js        2016-06-17 20:18:54 UTC (rev 202176)
</span><span class="lines">@@ -34,7 +34,7 @@
</span><span class="cx"> debug(&quot;Set hash to empty string&quot;);
</span><span class="cx"> a.href = &quot;https://www.mydomain.com/path/testurl.html#middle&quot;;
</span><span class="cx"> a.hash = &quot;&quot;;
</span><del>-shouldBe(&quot;a.href&quot;, &quot;'https://www.mydomain.com/path/testurl.html#'&quot;);
</del><ins>+shouldBe(&quot;a.href&quot;, &quot;'https://www.mydomain.com/path/testurl.html'&quot;);
</ins><span class="cx"> 
</span><span class="cx"> // Firefox 3.5.2 does not allow setting hash to mailto: scheme, and it should.
</span><span class="cx"> debug(&quot;Add hash to mailto: protocol&quot;);
</span><span class="lines">@@ -52,7 +52,7 @@
</span><span class="cx"> debug(&quot;Set hash to '#'&quot;);
</span><span class="cx"> a.href = &quot;http://mydomain.com#middle&quot;;
</span><span class="cx"> a.hash = &quot;#&quot;;
</span><del>-shouldBe(&quot;a.href&quot;, &quot;'http://mydomain.com/#'&quot;);
</del><ins>+shouldBe(&quot;a.href&quot;, &quot;'http://mydomain.com/'&quot;);
</ins><span class="cx"> 
</span><span class="cx"> // Firefox 3.5.2 does not allow setting hash to foo: scheme, and it should.
</span><span class="cx"> debug(&quot;Add hash to non-standard protocol&quot;);
</span></span></pre></div>
<a id="trunkLayoutTestsfastdomHTMLAnchorElementsethrefattributehashexpectedtxt"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/fast/dom/HTMLAnchorElement/set-href-attribute-hash-expected.txt (202175 => 202176)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/fast/dom/HTMLAnchorElement/set-href-attribute-hash-expected.txt        2016-06-17 19:51:33 UTC (rev 202175)
+++ trunk/LayoutTests/fast/dom/HTMLAnchorElement/set-href-attribute-hash-expected.txt        2016-06-17 20:18:54 UTC (rev 202176)
</span><span class="lines">@@ -14,13 +14,13 @@
</span><span class="cx"> Set hash to null
</span><span class="cx"> PASS a.href is 'https://www.mydomain.com/path/testurl.html#null'
</span><span class="cx"> Set hash to empty string
</span><del>-PASS a.href is 'https://www.mydomain.com/path/testurl.html#'
</del><ins>+PASS a.href is 'https://www.mydomain.com/path/testurl.html'
</ins><span class="cx"> Add hash to mailto: protocol
</span><span class="cx"> PASS a.href is 'mailto:e-mail_address@goes_here#hash-value'
</span><span class="cx"> Add hash to file: protocol
</span><span class="cx"> PASS a.href is 'file:///some%20path#hash value'
</span><span class="cx"> Set hash to '#'
</span><del>-PASS a.href is 'http://mydomain.com/#'
</del><ins>+PASS a.href is 'http://mydomain.com/'
</ins><span class="cx"> Add hash to non-standard protocol
</span><span class="cx"> PASS a.href is 'foo:bar#hash'
</span><span class="cx"> PASS successfullyParsed is true
</span></span></pre></div>
<a id="trunkSourceWebCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/ChangeLog (202175 => 202176)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/ChangeLog        2016-06-17 19:51:33 UTC (rev 202175)
+++ trunk/Source/WebCore/ChangeLog        2016-06-17 20:18:54 UTC (rev 202176)
</span><span class="lines">@@ -1,3 +1,48 @@
</span><ins>+2016-06-17  Chris Dumez  &lt;cdumez@apple.com&gt;
+
+        URL hash setter does not remove fragment identifier if argument is an empty string
+        https://bugs.webkit.org/show_bug.cgi?id=158869
+        &lt;rdar://problem/26863430&gt;
+
+        Reviewed by Darin Adler.
+
+        URL hash setter and URLUtils hash setter should remove the fragment identifier
+        if set to &quot;#&quot; or &quot;&quot;:
+        - https://url.spec.whatwg.org/#dom-url-hash
+        - https://html.spec.whatwg.org/multipage/semantics.html#dom-hyperlink-hash
+
+        This patch aligns our behavior with the specification and with other browsers
+        (tested Firefox and Chrome).
+
+        This patch also updates HTMLAnchorElement to inherit URLUtils to avoid code
+        duplication. HTMLAnchorElement already implements URLUtils in the IDL, as per
+        the specification:
+        - https://html.spec.whatwg.org/multipage/semantics.html#htmlanchorelement
+
+        No new tests, rebaselined existing tests.
+
+        * html/HTMLAnchorElement.cpp:
+        (WebCore::HTMLAnchorElement::origin): Deleted.
+        (WebCore::HTMLAnchorElement::text): Deleted.
+        (WebCore::HTMLAnchorElement::setText): Deleted.
+        (WebCore::HTMLAnchorElement::toString): Deleted.
+        (WebCore::HTMLAnchorElement::isLiveLink): Deleted.
+        (WebCore::HTMLAnchorElement::sendPings): Deleted.
+        (WebCore::HTMLAnchorElement::handleClick): Deleted.
+        (WebCore::HTMLAnchorElement::eventType): Deleted.
+        (WebCore::HTMLAnchorElement::treatLinkAsLiveForEventType): Deleted.
+        (WebCore::isEnterKeyKeydownEvent): Deleted.
+        (WebCore::shouldProhibitLinks): Deleted.
+        (WebCore::HTMLAnchorElement::willRespondToMouseClickEvents): Deleted.
+        (WebCore::rootEditableElementMap): Deleted.
+        (WebCore::HTMLAnchorElement::rootEditableElementForSelectionOnMouseDown): Deleted.
+        (WebCore::HTMLAnchorElement::clearRootEditableElementForSelectionOnMouseDown): Deleted.
+        (WebCore::HTMLAnchorElement::setRootEditableElementForSelectionOnMouseDown): Deleted.
+        * html/HTMLAnchorElement.h:
+        (WebCore::HTMLAnchorElement::invalidateCachedVisitedLinkHash): Deleted.
+        * html/URLUtils.h:
+        (WebCore::URLUtils&lt;T&gt;::setHash):
+
</ins><span class="cx"> 2016-06-17  John Wilander  &lt;wilander@apple.com&gt;
</span><span class="cx"> 
</span><span class="cx">         Ignore case in the check for security origin inheritance
</span></span></pre></div>
<a id="trunkSourceWebCorehtmlHTMLAnchorElementcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/html/HTMLAnchorElement.cpp (202175 => 202176)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/html/HTMLAnchorElement.cpp        2016-06-17 19:51:33 UTC (rev 202175)
+++ trunk/Source/WebCore/html/HTMLAnchorElement.cpp        2016-06-17 20:18:54 UTC (rev 202176)
</span><span class="lines">@@ -322,193 +322,11 @@
</span><span class="cx">     return getAttribute(targetAttr);
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-String HTMLAnchorElement::hash() const
-{
-    String fragmentIdentifier = href().fragmentIdentifier();
-    if (fragmentIdentifier.isEmpty())
-        return emptyString();
-    return AtomicString(String(&quot;#&quot; + fragmentIdentifier));
-}
-
-void HTMLAnchorElement::setHash(const String&amp; value)
-{
-    URL url = href();
-    if (value[0] == '#')
-        url.setFragmentIdentifier(value.substring(1));
-    else
-        url.setFragmentIdentifier(value);
-    setHref(url.string());
-}
-
-String HTMLAnchorElement::host() const
-{
-    const URL&amp; url = href();
-    if (url.hostEnd() == url.pathStart())
-        return url.host();
-    if (isDefaultPortForProtocol(url.port(), url.protocol()))
-        return url.host();
-    return url.host() + &quot;:&quot; + String::number(url.port());
-}
-
-void HTMLAnchorElement::setHost(const String&amp; value)
-{
-    if (value.isEmpty())
-        return;
-    URL url = href();
-    if (!url.canSetHostOrPort())
-        return;
-
-    size_t separator = value.find(':');
-    if (!separator)
-        return;
-
-    if (separator == notFound)
-        url.setHostAndPort(value);
-    else {
-        unsigned portEnd;
-        unsigned port = parsePortFromStringPosition(value, separator + 1, portEnd);
-        if (!port) {
-            // http://dev.w3.org/html5/spec/infrastructure.html#url-decomposition-idl-attributes
-            // specifically goes against RFC 3986 (p3.2) and
-            // requires setting the port to &quot;0&quot; if it is set to empty string.
-            url.setHostAndPort(value.substring(0, separator + 1) + &quot;0&quot;);
-        } else {
-            if (isDefaultPortForProtocol(port, url.protocol()))
-                url.setHostAndPort(value.substring(0, separator));
-            else
-                url.setHostAndPort(value.substring(0, portEnd));
-        }
-    }
-    setHref(url.string());
-}
-
-String HTMLAnchorElement::username() const
-{
-    return href().encodedUser();
-}
-
-void HTMLAnchorElement::setUsername(const String&amp; value)
-{
-    URL url = href();
-    url.setUser(value);
-    setHref(url.string());
-}
-
-String HTMLAnchorElement::password() const
-{
-    return href().encodedPass();
-}
-
-void HTMLAnchorElement::setPassword(const String&amp; value)
-{
-    URL url = href();
-    url.setPass(value);
-    setHref(url.string());
-}
-
-String HTMLAnchorElement::hostname() const
-{
-    return href().host();
-}
-
-void HTMLAnchorElement::setHostname(const String&amp; value)
-{
-    // Before setting new value:
-    // Remove all leading U+002F SOLIDUS (&quot;/&quot;) characters.
-    unsigned i = 0;
-    unsigned hostLength = value.length();
-    while (value[i] == '/')
-        i++;
-
-    if (i == hostLength)
-        return;
-
-    URL url = href();
-    if (!url.canSetHostOrPort())
-        return;
-
-    url.setHost(value.substring(i));
-    setHref(url.string());
-}
-
-String HTMLAnchorElement::pathname() const
-{
-    return href().path();
-}
-
-void HTMLAnchorElement::setPathname(const String&amp; value)
-{
-    URL url = href();
-    if (!url.canSetPathname())
-        return;
-
-    if (value[0] == '/')
-        url.setPath(value);
-    else
-        url.setPath(&quot;/&quot; + value);
-
-    setHref(url.string());
-}
-
-String HTMLAnchorElement::port() const
-{
-    if (href().hasPort())
-        return String::number(href().port());
-
-    return emptyString();
-}
-
-void HTMLAnchorElement::setPort(const String&amp; value)
-{
-    URL url = href();
-    if (!url.canSetHostOrPort())
-        return;
-
-    // http://dev.w3.org/html5/spec/infrastructure.html#url-decomposition-idl-attributes
-    // specifically goes against RFC 3986 (p3.2) and
-    // requires setting the port to &quot;0&quot; if it is set to empty string.
-    unsigned port = value.toUInt();
-    if (isDefaultPortForProtocol(port, url.protocol()))
-        url.removePort();
-    else
-        url.setPort(port);
-
-    setHref(url.string());
-}
-
-String HTMLAnchorElement::protocol() const
-{
-    return href().protocol() + &quot;:&quot;;
-}
-
-void HTMLAnchorElement::setProtocol(const String&amp; value)
-{
-    URL url = href();
-    url.setProtocol(value);
-    setHref(url.string());
-}
-
-String HTMLAnchorElement::search() const
-{
-    String query = href().query();
-    return query.isEmpty() ? emptyString() : &quot;?&quot; + query;
-}
-
</del><span class="cx"> String HTMLAnchorElement::origin() const
</span><span class="cx"> {
</span><span class="cx">     return SecurityOrigin::create(href()).get().toString();
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-void HTMLAnchorElement::setSearch(const String&amp; value)
-{
-    URL url = href();
-    String newSearch = (value[0] == '?') ? value.substring(1) : value;
-    // Make sure that '#' in the query does not leak to the hash.
-    url.setQuery(newSearch.replaceWithLiteral('#', &quot;%23&quot;));
-
-    setHref(url.string());
-}
-
</del><span class="cx"> String HTMLAnchorElement::text()
</span><span class="cx"> {
</span><span class="cx">     return textContent();
</span></span></pre></div>
<a id="trunkSourceWebCorehtmlHTMLAnchorElementh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/html/HTMLAnchorElement.h (202175 => 202176)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/html/HTMLAnchorElement.h        2016-06-17 19:51:33 UTC (rev 202175)
+++ trunk/Source/WebCore/html/HTMLAnchorElement.h        2016-06-17 20:18:54 UTC (rev 202176)
</span><span class="lines">@@ -27,6 +27,7 @@
</span><span class="cx"> #include &quot;HTMLElement.h&quot;
</span><span class="cx"> #include &quot;HTMLNames.h&quot;
</span><span class="cx"> #include &quot;LinkHash.h&quot;
</span><ins>+#include &quot;URLUtils.h&quot;
</ins><span class="cx"> 
</span><span class="cx"> namespace WebCore {
</span><span class="cx"> 
</span><span class="lines">@@ -55,7 +56,7 @@
</span><span class="cx"> //     RelationUp          = 0x00020000,
</span><span class="cx"> };
</span><span class="cx"> 
</span><del>-class HTMLAnchorElement : public HTMLElement {
</del><ins>+class HTMLAnchorElement : public HTMLElement, public URLUtils&lt;HTMLAnchorElement&gt; {
</ins><span class="cx"> public:
</span><span class="cx">     static Ref&lt;HTMLAnchorElement&gt; create(Document&amp;);
</span><span class="cx">     static Ref&lt;HTMLAnchorElement&gt; create(const QualifiedName&amp;, Document&amp;);
</span><span class="lines">@@ -67,33 +68,6 @@
</span><span class="cx"> 
</span><span class="cx">     const AtomicString&amp; name() const;
</span><span class="cx"> 
</span><del>-    String hash() const;
-    void setHash(const String&amp;);
-
-    String host() const;
-    void setHost(const String&amp;);
-
-    String username() const;
-    void setUsername(const String&amp;);
-
-    String password() const;
-    void setPassword(const String&amp;);
-
-    String hostname() const;
-    void setHostname(const String&amp;);
-
-    String pathname() const;
-    void setPathname(const String&amp;);
-
-    String port() const;
-    void setPort(const String&amp;);
-
-    String protocol() const;
-    void setProtocol(const String&amp;);
-
-    String search() const;
-    void setSearch(const String&amp;);
-
</del><span class="cx">     String origin() const;
</span><span class="cx"> 
</span><span class="cx">     String text();
</span></span></pre></div>
<a id="trunkSourceWebCorehtmlURLUtilsh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/html/URLUtils.h (202175 => 202176)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/html/URLUtils.h        2016-06-17 19:51:33 UTC (rev 202175)
+++ trunk/Source/WebCore/html/URLUtils.h        2016-06-17 20:18:54 UTC (rev 202176)
</span><span class="lines">@@ -284,10 +284,11 @@
</span><span class="cx"> void URLUtils&lt;T&gt;::setHash(const String&amp; value)
</span><span class="cx"> {
</span><span class="cx">     URL url = href();
</span><del>-    if (value[0U] == '#')
-        url.setFragmentIdentifier(value.substring(1));
</del><ins>+    String newFragment = value[0U] == '#' ? value.substring(1) : value;
+    if (newFragment.isEmpty())
+        url.removeFragmentIdentifier();
</ins><span class="cx">     else
</span><del>-        url.setFragmentIdentifier(value);
</del><ins>+        url.setFragmentIdentifier(newFragment);
</ins><span class="cx">     setHref(url.string());
</span><span class="cx"> }
</span><span class="cx"> 
</span></span></pre>
</div>
</div>

</body>
</html>