<!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>[178735] branches/safari-600.1.4.15-branch</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/178735">178735</a></dd>
<dt>Author</dt> <dd>bshafiei@apple.com</dd>
<dt>Date</dt> <dd>2015-01-20 12:40:00 -0800 (Tue, 20 Jan 2015)</dd>
</dl>

<h3>Log Message</h3>
<pre>Merged <a href="http://trac.webkit.org/projects/webkit/changeset/171941">r171941</a>.  rdar://problem/19419871</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#branchessafari6001415branchLayoutTestsChangeLog">branches/safari-600.1.4.15-branch/LayoutTests/ChangeLog</a></li>
<li><a href="#branchessafari6001415branchSourceWebCoreChangeLog">branches/safari-600.1.4.15-branch/Source/WebCore/ChangeLog</a></li>
<li><a href="#branchessafari6001415branchSourceWebCoredomElementcpp">branches/safari-600.1.4.15-branch/Source/WebCore/dom/Element.cpp</a></li>
<li><a href="#branchessafari6001415branchSourceWebCoredomElementh">branches/safari-600.1.4.15-branch/Source/WebCore/dom/Element.h</a></li>
<li><a href="#branchessafari6001415branchSourceWebCoreeditingmarkupcpp">branches/safari-600.1.4.15-branch/Source/WebCore/editing/markup.cpp</a></li>
<li><a href="#branchessafari6001415branchSourceWebCorehtmlHTMLImageElementcpp">branches/safari-600.1.4.15-branch/Source/WebCore/html/HTMLImageElement.cpp</a></li>
<li><a href="#branchessafari6001415branchSourceWebCorehtmlHTMLImageElementh">branches/safari-600.1.4.15-branch/Source/WebCore/html/HTMLImageElement.h</a></li>
<li><a href="#branchessafari6001415branchSourceWebCorehtmlparserHTMLSrcsetParsercpp">branches/safari-600.1.4.15-branch/Source/WebCore/html/parser/HTMLSrcsetParser.cpp</a></li>
<li><a href="#branchessafari6001415branchSourceWebCorehtmlparserHTMLSrcsetParserh">branches/safari-600.1.4.15-branch/Source/WebCore/html/parser/HTMLSrcsetParser.h</a></li>
</ul>

<h3>Added Paths</h3>
<ul>
<li><a href="#branchessafari6001415branchLayoutTestseditingpasteboardimgsrcsetcopypastecanonicalizationexpectedtxt">branches/safari-600.1.4.15-branch/LayoutTests/editing/pasteboard/img-srcset-copy-paste-canonicalization-expected.txt</a></li>
<li><a href="#branchessafari6001415branchLayoutTestseditingpasteboardimgsrcsetcopypastecanonicalizationhtml">branches/safari-600.1.4.15-branch/LayoutTests/editing/pasteboard/img-srcset-copy-paste-canonicalization.html</a></li>
<li><a href="#branchessafari6001415branchLayoutTestseditingpasteboardresourcesimgsrcsetcopypastecanonicalizationiframehtml">branches/safari-600.1.4.15-branch/LayoutTests/editing/pasteboard/resources/img-srcset-copy-paste-canonicalization-iframe.html</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="branchessafari6001415branchLayoutTestsChangeLog"></a>
<div class="modfile"><h4>Modified: branches/safari-600.1.4.15-branch/LayoutTests/ChangeLog (178734 => 178735)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-600.1.4.15-branch/LayoutTests/ChangeLog        2015-01-20 20:37:35 UTC (rev 178734)
+++ branches/safari-600.1.4.15-branch/LayoutTests/ChangeLog        2015-01-20 20:40:00 UTC (rev 178735)
</span><span class="lines">@@ -1,5 +1,27 @@
</span><span class="cx"> 2015-01-20  Babak Shafiei  &lt;bshafiei@apple.com&gt;
</span><span class="cx"> 
</span><ins>+        Merge r171941.
+
+    2014-07-30  Myles C. Maxfield  &lt;mmaxfield@apple.com&gt;
+
+            URLs in srcset attributes are not made absolute upon copy and paste
+            https://bugs.webkit.org/show_bug.cgi?id=135448
+
+            Reviewed by Ryosuke Niwa.
+
+            Copy and paste a srcset image with relative URLs, and make sure that the
+            pasted srcset attribute doesn't match what it was before. I can't actually
+            dump the new srcset because it will include a full path of the file on the
+            user's system, and would therefore be machine-specific.
+
+            * editing/pasteboard/img-srcset-copy-paste-canonicalization-expected.txt:
+            * editing/pasteboard/img-srcset-copy-paste-canonicalization.html: Paste and check.
+            * editing/pasteboard/resources/img-srcset-copy-paste-canonicalization-iframe.html:
+            This has to be an iframe because we don't perform any url canonicalization if we
+            are copying and pasting from a document into itself.
+
+2015-01-20  Babak Shafiei  &lt;bshafiei@apple.com&gt;
+
</ins><span class="cx">         Merge r171692.
</span><span class="cx"> 
</span><span class="cx">     2014-07-28  Andreas Kling  &lt;akling@apple.com&gt;
</span></span></pre></div>
<a id="branchessafari6001415branchLayoutTestseditingpasteboardimgsrcsetcopypastecanonicalizationexpectedtxtfromrev171941trunkLayoutTestseditingpasteboardimgsrcsetcopypastecanonicalizationexpectedtxt"></a>
<div class="copfile"><h4>Copied: branches/safari-600.1.4.15-branch/LayoutTests/editing/pasteboard/img-srcset-copy-paste-canonicalization-expected.txt (from rev 171941, trunk/LayoutTests/editing/pasteboard/img-srcset-copy-paste-canonicalization-expected.txt) (0 => 178735)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-600.1.4.15-branch/LayoutTests/editing/pasteboard/img-srcset-copy-paste-canonicalization-expected.txt                                (rev 0)
+++ branches/safari-600.1.4.15-branch/LayoutTests/editing/pasteboard/img-srcset-copy-paste-canonicalization-expected.txt        2015-01-20 20:40:00 UTC (rev 178735)
</span><span class="lines">@@ -0,0 +1,18 @@
</span><ins>+The following test does a copy and a paste of an image with the srcset attribute. The test is successful if the value of the srcset attribute has been canonicalized. To run the test manually, copy the green square into the contentediable area above the iframe.
+
+On success, you will see a series of &quot;PASS&quot; messages, followed by &quot;TEST COMPLETE&quot;.
+
+
+PASS canonicalize(iframeHref, sourceImageSegments[0]) is destinationImageSegments[0]
+PASS canonicalize(iframeHref, sourceImageSegments[2]) is destinationImageSegments[2]
+PASS sourceImageSegments.length is 4
+PASS destinationImageSegments.length is 4
+PASS sourceImageSegments[1] is &quot;2x,&quot;
+PASS destinationImageSegments[1] is &quot;2x,&quot;
+PASS sourceImageSegments[3] is &quot;1x&quot;
+PASS destinationImageSegments[3] is &quot;1x&quot;
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
+
</ins></span></pre></div>
<a id="branchessafari6001415branchLayoutTestseditingpasteboardimgsrcsetcopypastecanonicalizationhtmlfromrev171941trunkLayoutTestseditingpasteboardimgsrcsetcopypastecanonicalizationhtml"></a>
<div class="copfile"><h4>Copied: branches/safari-600.1.4.15-branch/LayoutTests/editing/pasteboard/img-srcset-copy-paste-canonicalization.html (from rev 171941, trunk/LayoutTests/editing/pasteboard/img-srcset-copy-paste-canonicalization.html) (0 => 178735)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-600.1.4.15-branch/LayoutTests/editing/pasteboard/img-srcset-copy-paste-canonicalization.html                                (rev 0)
+++ branches/safari-600.1.4.15-branch/LayoutTests/editing/pasteboard/img-srcset-copy-paste-canonicalization.html        2015-01-20 20:40:00 UTC (rev 178735)
</span><span class="lines">@@ -0,0 +1,76 @@
</span><ins>+&lt;!DOCTYPE html&gt;
+&lt;html&gt;
+&lt;body&gt;
+&lt;script src=&quot;../../resources/js-test-pre.js&quot;&gt;&lt;/script&gt;
+&lt;div id=&quot;destination&quot; contenteditable=&quot;true&quot;&gt;&lt;/div&gt;
+&lt;iframe id=&quot;iframe&quot; src=&quot;resources/img-srcset-copy-paste-canonicalization-iframe.html&quot;&gt;&lt;/iframe&gt;
+&lt;script&gt;
+    window.jsTestIsAsync = true;
+
+    description(&quot;The following test does a copy and a paste of an image with the srcset attribute. The test is successful if the value of the srcset attribute has been canonicalized. To run the test manually, copy the green square into the contentediable area above the iframe.&quot;);
+    
+    function canonicalize(href, relativeURL) {
+        var hrefSegments = href.split(&quot;/&quot;);
+
+        // Remove the filename from the href
+        hrefSegments.splice(hrefSegments.length - 1, 1);
+
+        var relativeURLSegments = relativeURL.split(&quot;/&quot;);
+        while (relativeURLSegments.length &gt; 0 &amp;&amp; relativeURLSegments[0] == &quot;..&quot;) {
+            hrefSegments.splice(hrefSegments.length - 1, 1);
+            relativeURLSegments.splice(0, 1);
+        }
+        return hrefSegments.concat(relativeURLSegments).join(&quot;/&quot;);
+    }
+
+    var iframeHref;
+    var sourceImageSegments;
+    var destinationImageSegments;
+
+    function runTests(href) {
+        iframeHref = href;
+
+        var iframe = document.getElementById(&quot;iframe&quot;);
+        var iframeDocument = iframe.contentDocument;
+
+        var source = iframeDocument.getElementById(&quot;source&quot;);
+        var destination = document.getElementById(&quot;destination&quot;);
+
+        source.focus();
+        iframeDocument.execCommand(&quot;SelectAll&quot;);
+        iframeDocument.execCommand(&quot;Copy&quot;);
+        destination.focus();
+        document.execCommand(&quot;SelectAll&quot;);
+        document.execCommand(&quot;Paste&quot;);
+
+        var sourceImage = iframeDocument.getElementById(&quot;image&quot;);
+        var destinationImage = document.getElementById(&quot;image&quot;);
+        if (!destinationImage) {
+            testFailed(&quot;Image was not pasted&quot;);
+            finishJSTest();
+            return;
+        }
+
+        destinationImage.onerror = function() {
+            testFailed(&quot;Image should not fail to load&quot;);
+            finishJSTest();
+        }
+        image.onload = function() {
+            finishJSTest();
+        }
+
+        sourceImageSegments = sourceImage.getAttribute(&quot;srcset&quot;).split(&quot; &quot;);
+        destinationImageSegments = destinationImage.getAttribute(&quot;srcset&quot;).split(&quot; &quot;);
+        shouldBe(&quot;canonicalize(iframeHref, sourceImageSegments[0])&quot;, &quot;destinationImageSegments[0]&quot;);
+        shouldBe(&quot;canonicalize(iframeHref, sourceImageSegments[2])&quot;, &quot;destinationImageSegments[2]&quot;);
+        shouldBe(&quot;sourceImageSegments.length&quot;, &quot;4&quot;);
+        shouldBe(&quot;destinationImageSegments.length&quot;, &quot;4&quot;);
+        shouldBe(&quot;sourceImageSegments[1]&quot;, &quot;\&quot;2x,\&quot;&quot;);
+        shouldBe(&quot;destinationImageSegments[1]&quot;, &quot;\&quot;2x,\&quot;&quot;);
+        shouldBe(&quot;sourceImageSegments[3]&quot;, &quot;\&quot;1x\&quot;&quot;);
+        shouldBe(&quot;destinationImageSegments[3]&quot;, &quot;\&quot;1x\&quot;&quot;);
+    }
+&lt;/script&gt;
+&lt;script src=&quot;../../resources/js-test-post.js&quot;&gt;&lt;/script&gt;
+&lt;/body&gt;
+&lt;/html&gt;
</ins></span></pre></div>
<a id="branchessafari6001415branchLayoutTestseditingpasteboardresourcesimgsrcsetcopypastecanonicalizationiframehtmlfromrev171941trunkLayoutTestseditingpasteboardresourcesimgsrcsetcopypastecanonicalizationiframehtml"></a>
<div class="copfile"><h4>Copied: branches/safari-600.1.4.15-branch/LayoutTests/editing/pasteboard/resources/img-srcset-copy-paste-canonicalization-iframe.html (from rev 171941, trunk/LayoutTests/editing/pasteboard/resources/img-srcset-copy-paste-canonicalization-iframe.html) (0 => 178735)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-600.1.4.15-branch/LayoutTests/editing/pasteboard/resources/img-srcset-copy-paste-canonicalization-iframe.html                                (rev 0)
+++ branches/safari-600.1.4.15-branch/LayoutTests/editing/pasteboard/resources/img-srcset-copy-paste-canonicalization-iframe.html        2015-01-20 20:40:00 UTC (rev 178735)
</span><span class="lines">@@ -0,0 +1,10 @@
</span><ins>+&lt;!DOCTYPE html&gt;
+&lt;html&gt;
+&lt;head&gt;
+&lt;/head&gt;
+&lt;body onload=&quot;window.parent.runTests(window.location.href);&quot;&gt;
+&lt;div id=&quot;source&quot; contenteditable=&quot;true&quot;&gt;
+    &lt;img id=&quot;image&quot; src=&quot;../../../fast/hidpi/resources/srcset.png&quot; srcset=&quot;../../../fast/hidpi/resources/green-400-px-square.png 2x, ../../../fast/hidpi/resources/green-200-px-square.png 1x&quot;&gt;
+&lt;/div&gt;
+&lt;/body&gt;
+&lt;/html&gt;
</ins></span></pre></div>
<a id="branchessafari6001415branchSourceWebCoreChangeLog"></a>
<div class="modfile"><h4>Modified: branches/safari-600.1.4.15-branch/Source/WebCore/ChangeLog (178734 => 178735)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-600.1.4.15-branch/Source/WebCore/ChangeLog        2015-01-20 20:37:35 UTC (rev 178734)
+++ branches/safari-600.1.4.15-branch/Source/WebCore/ChangeLog        2015-01-20 20:40:00 UTC (rev 178735)
</span><span class="lines">@@ -1,5 +1,42 @@
</span><span class="cx"> 2015-01-20  Babak Shafiei  &lt;bshafiei@apple.com&gt;
</span><span class="cx"> 
</span><ins>+        Merge r171941.
+
+    2014-07-30  Myles C. Maxfield  &lt;mmaxfield@apple.com&gt;
+
+            URLs in srcset attributes are not made absolute upon copy and paste
+            https://bugs.webkit.org/show_bug.cgi?id=135448
+
+            Reviewed by Ryosuke Niwa.
+
+            When pasting, canonicalize URLs in srcset the same way we do with src.
+
+            Test: editing/pasteboard/img-srcset-copy-paste-canonicalization.html
+
+            * dom/Element.cpp:
+            (WebCore::Element::completeURLsInAttributeValue): Initial implemention, moved from markup.cpp.
+            * dom/Element.h:
+            (WebCore::Element::attributeContainsURL): New function for completeURLs to call.
+            (WebCore::Element::completeURLsInAttributeValue): Only called if attributeContainsURL returns
+            true. Default implementation simply calls isURLAttribute().
+            * editing/markup.cpp:
+            (WebCore::completeURLs): Call attributeContainsURL() and completeURLsInAttributeValue() to
+            complete the URL, so nodes can perform their own behavior.
+            * html/HTMLImageElement.cpp:
+            (WebCore::HTMLImageElement::attributeContainsURL): Return true for srcset.
+            (WebCore::HTMLImageElement::completeUrlAttributeValue): Use our existing srcset parser to
+            parse the srcset attribute, then use its output to canonicalize URLs, and build it back up
+            into a string.
+            * html/HTMLImageElement.h:
+            (WebCore::HTMLImageElement::attributeContainsURL):
+            (WebCore::HTMLImageElement::completeUrlAttributeValue):
+            * html/parser/HTMLSrcsetParser.cpp: Make parseImageCandidatesFromSrcsetAttribute() public
+            and change its signature to return its result.
+            (WebCore::parseImageCandidatesFromSrcsetAttribute):
+            * html/parser/HTMLSrcsetParser.h: Ditto.
+
+2015-01-20  Babak Shafiei  &lt;bshafiei@apple.com&gt;
+
</ins><span class="cx">         Merge r171708.
</span><span class="cx"> 
</span><span class="cx">     2014-07-28  Brady Eidson  &lt;beidson@apple.com&gt;
</span></span></pre></div>
<a id="branchessafari6001415branchSourceWebCoredomElementcpp"></a>
<div class="modfile"><h4>Modified: branches/safari-600.1.4.15-branch/Source/WebCore/dom/Element.cpp (178734 => 178735)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-600.1.4.15-branch/Source/WebCore/dom/Element.cpp        2015-01-20 20:37:35 UTC (rev 178734)
+++ branches/safari-600.1.4.15-branch/Source/WebCore/dom/Element.cpp        2015-01-20 20:40:00 UTC (rev 178735)
</span><span class="lines">@@ -3022,4 +3022,9 @@
</span><span class="cx">     return !equalIgnoringCase(fastGetAttribute(roleAttr), &quot;img&quot;);
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+String Element::completeURLsInAttributeValue(const URL&amp; base, const Attribute&amp; attribute) const
+{
+    return URL(base, attribute.value()).string();
+}
+
</ins><span class="cx"> } // namespace WebCore
</span></span></pre></div>
<a id="branchessafari6001415branchSourceWebCoredomElementh"></a>
<div class="modfile"><h4>Modified: branches/safari-600.1.4.15-branch/Source/WebCore/dom/Element.h (178734 => 178735)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-600.1.4.15-branch/Source/WebCore/dom/Element.h        2015-01-20 20:37:35 UTC (rev 178734)
+++ branches/safari-600.1.4.15-branch/Source/WebCore/dom/Element.h        2015-01-20 20:40:00 UTC (rev 178735)
</span><span class="lines">@@ -393,6 +393,8 @@
</span><span class="cx">     virtual void accessKeyAction(bool /*sendToAnyEvent*/) { }
</span><span class="cx"> 
</span><span class="cx">     virtual bool isURLAttribute(const Attribute&amp;) const { return false; }
</span><ins>+    virtual bool attributeContainsURL(const Attribute&amp; attribute) const { return isURLAttribute(attribute); }
+    virtual String completeURLsInAttributeValue(const URL&amp; base, const Attribute&amp;) const;
</ins><span class="cx">     virtual bool isHTMLContentAttribute(const Attribute&amp;) const { return false; }
</span><span class="cx"> 
</span><span class="cx">     URL getURLAttribute(const QualifiedName&amp;) const;
</span></span></pre></div>
<a id="branchessafari6001415branchSourceWebCoreeditingmarkupcpp"></a>
<div class="modfile"><h4>Modified: branches/safari-600.1.4.15-branch/Source/WebCore/editing/markup.cpp (178734 => 178735)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-600.1.4.15-branch/Source/WebCore/editing/markup.cpp        2015-01-20 20:37:35 UTC (rev 178734)
+++ branches/safari-600.1.4.15-branch/Source/WebCore/editing/markup.cpp        2015-01-20 20:40:00 UTC (rev 178735)
</span><span class="lines">@@ -104,8 +104,8 @@
</span><span class="cx">         if (!element.hasAttributes())
</span><span class="cx">             continue;
</span><span class="cx">         for (const Attribute&amp; attribute : element.attributesIterator()) {
</span><del>-            if (element.isURLAttribute(attribute) &amp;&amp; !attribute.value().isEmpty())
-                changes.append(AttributeChange(&amp;element, attribute.name(), URL(parsedBaseURL, attribute.value()).string()));
</del><ins>+            if (element.attributeContainsURL(attribute) &amp;&amp; !attribute.value().isEmpty())
+                changes.append(AttributeChange(&amp;element, attribute.name(), element.completeURLsInAttributeValue(parsedBaseURL, attribute)));
</ins><span class="cx">         }
</span><span class="cx">     }
</span><span class="cx"> 
</span></span></pre></div>
<a id="branchessafari6001415branchSourceWebCorehtmlHTMLImageElementcpp"></a>
<div class="modfile"><h4>Modified: branches/safari-600.1.4.15-branch/Source/WebCore/html/HTMLImageElement.cpp (178734 => 178735)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-600.1.4.15-branch/Source/WebCore/html/HTMLImageElement.cpp        2015-01-20 20:37:35 UTC (rev 178734)
+++ branches/safari-600.1.4.15-branch/Source/WebCore/html/HTMLImageElement.cpp        2015-01-20 20:40:00 UTC (rev 178735)
</span><span class="lines">@@ -39,6 +39,7 @@
</span><span class="cx"> #include &quot;Settings.h&quot;
</span><span class="cx"> #include &quot;ShadowRoot.h&quot;
</span><span class="cx"> #include &quot;SourceSizeList.h&quot;
</span><ins>+#include &lt;wtf/text/StringBuilder.h&gt;
</ins><span class="cx"> 
</span><span class="cx"> #if ENABLE(SERVICE_CONTROLS)
</span><span class="cx"> #include &quot;ImageControlsRootElement.h&quot;
</span><span class="lines">@@ -353,6 +354,37 @@
</span><span class="cx">         || HTMLElement::isURLAttribute(attribute);
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+bool HTMLImageElement::attributeContainsURL(const Attribute&amp; attribute) const
+{
+    return attribute.name() == srcsetAttr
+        || HTMLElement::attributeContainsURL(attribute);
+}
+
+String HTMLImageElement::completeURLsInAttributeValue(const URL&amp; base, const Attribute&amp; attribute) const
+{
+    if (attribute.name() == srcsetAttr) {
+        Vector&lt;ImageCandidate&gt; imageCandidates = parseImageCandidatesFromSrcsetAttribute(StringView(attribute.value()));
+        StringBuilder result;
+        for (const auto&amp; candidate : imageCandidates) {
+            if (&amp;candidate != &amp;imageCandidates[0])
+                result.appendLiteral(&quot;, &quot;);
+            result.append(URL(base, candidate.string.toString()).string());
+            if (candidate.density != UninitializedDescriptor) {
+                result.append(' ');
+                result.appendNumber(candidate.density);
+                result.append('x');
+            }
+            if (candidate.resourceWidth != UninitializedDescriptor) {
+                result.append(' ');
+                result.appendNumber(candidate.resourceWidth);
+                result.append('x');
+            }
+        }
+        return result.toString();
+    }
+    return HTMLElement::completeURLsInAttributeValue(base, attribute);
+}
+
</ins><span class="cx"> bool HTMLImageElement::matchesLowercasedUsemap(const AtomicStringImpl&amp; name) const
</span><span class="cx"> {
</span><span class="cx">     ASSERT(String(&amp;const_cast&lt;AtomicStringImpl&amp;&gt;(name)).lower().impl() == &amp;name);
</span></span></pre></div>
<a id="branchessafari6001415branchSourceWebCorehtmlHTMLImageElementh"></a>
<div class="modfile"><h4>Modified: branches/safari-600.1.4.15-branch/Source/WebCore/html/HTMLImageElement.h (178734 => 178735)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-600.1.4.15-branch/Source/WebCore/html/HTMLImageElement.h        2015-01-20 20:37:35 UTC (rev 178734)
+++ branches/safari-600.1.4.15-branch/Source/WebCore/html/HTMLImageElement.h        2015-01-20 20:40:00 UTC (rev 178735)
</span><span class="lines">@@ -108,6 +108,8 @@
</span><span class="cx">     virtual bool canStartSelection() const override;
</span><span class="cx"> 
</span><span class="cx">     virtual bool isURLAttribute(const Attribute&amp;) const override;
</span><ins>+    virtual bool attributeContainsURL(const Attribute&amp;) const override;
+    virtual String completeURLsInAttributeValue(const URL&amp; base, const Attribute&amp;) const override;
</ins><span class="cx"> 
</span><span class="cx">     virtual bool draggable() const override;
</span><span class="cx"> 
</span></span></pre></div>
<a id="branchessafari6001415branchSourceWebCorehtmlparserHTMLSrcsetParsercpp"></a>
<div class="modfile"><h4>Modified: branches/safari-600.1.4.15-branch/Source/WebCore/html/parser/HTMLSrcsetParser.cpp (178734 => 178735)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-600.1.4.15-branch/Source/WebCore/html/parser/HTMLSrcsetParser.cpp        2015-01-20 20:37:35 UTC (rev 178734)
+++ branches/safari-600.1.4.15-branch/Source/WebCore/html/parser/HTMLSrcsetParser.cpp        2015-01-20 20:40:00 UTC (rev 178735)
</span><span class="lines">@@ -162,8 +162,10 @@
</span><span class="cx"> 
</span><span class="cx"> // http://picture.responsiveimages.org/#parse-srcset-attr
</span><span class="cx"> template&lt;typename CharType&gt;
</span><del>-static void parseImageCandidatesFromSrcsetAttribute(const CharType* attributeStart, unsigned length, Vector&lt;ImageCandidate&gt;&amp; imageCandidates)
</del><ins>+static Vector&lt;ImageCandidate&gt; parseImageCandidatesFromSrcsetAttribute(const CharType* attributeStart, unsigned length)
</ins><span class="cx"> {
</span><ins>+    Vector&lt;ImageCandidate&gt; imageCandidates;
+
</ins><span class="cx">     const CharType* attributeEnd = attributeStart + length;
</span><span class="cx"> 
</span><span class="cx">     for (const CharType* position = attributeStart; position &lt; attributeEnd;) {
</span><span class="lines">@@ -207,15 +209,16 @@
</span><span class="cx">         imageCandidates.append(ImageCandidate(StringView(imageURLStart, imageURLLength), result, ImageCandidate::SrcsetOrigin));
</span><span class="cx">         // 11. Return to the step labeled splitting loop.
</span><span class="cx">     }
</span><ins>+    return imageCandidates;
</ins><span class="cx"> }
</span><span class="cx"> 
</span><del>-static void parseImageCandidatesFromSrcsetAttribute(StringView attribute, Vector&lt;ImageCandidate&gt;&amp; imageCandidates)
</del><ins>+Vector&lt;ImageCandidate&gt; parseImageCandidatesFromSrcsetAttribute(StringView attribute)
</ins><span class="cx"> {
</span><span class="cx">     // FIXME: We should consider replacing the direct pointers in the parsing process with StringView and positions.
</span><span class="cx">     if (attribute.is8Bit())
</span><del>-        parseImageCandidatesFromSrcsetAttribute&lt;LChar&gt;(attribute.characters8(), attribute.length(), imageCandidates);
</del><ins>+        return parseImageCandidatesFromSrcsetAttribute&lt;LChar&gt;(attribute.characters8(), attribute.length());
</ins><span class="cx">     else
</span><del>-        parseImageCandidatesFromSrcsetAttribute&lt;UChar&gt;(attribute.characters16(), attribute.length(), imageCandidates);
</del><ins>+        return parseImageCandidatesFromSrcsetAttribute&lt;UChar&gt;(attribute.characters16(), attribute.length());
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> static ImageCandidate pickBestImageCandidate(float deviceScaleFactor, Vector&lt;ImageCandidate&gt;&amp; imageCandidates
</span><span class="lines">@@ -275,10 +278,8 @@
</span><span class="cx">         return ImageCandidate(StringView(srcAttribute), DescriptorParsingResult(), ImageCandidate::SrcOrigin);
</span><span class="cx">     }
</span><span class="cx"> 
</span><del>-    Vector&lt;ImageCandidate&gt; imageCandidates;
</del><ins>+    Vector&lt;ImageCandidate&gt; imageCandidates = parseImageCandidatesFromSrcsetAttribute(StringView(srcsetAttribute));
</ins><span class="cx"> 
</span><del>-    parseImageCandidatesFromSrcsetAttribute(StringView(srcsetAttribute), imageCandidates);
-
</del><span class="cx">     if (!srcAttribute.isEmpty())
</span><span class="cx">         imageCandidates.append(ImageCandidate(StringView(srcAttribute), DescriptorParsingResult(), ImageCandidate::SrcOrigin));
</span><span class="cx"> 
</span></span></pre></div>
<a id="branchessafari6001415branchSourceWebCorehtmlparserHTMLSrcsetParserh"></a>
<div class="modfile"><h4>Modified: branches/safari-600.1.4.15-branch/Source/WebCore/html/parser/HTMLSrcsetParser.h (178734 => 178735)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-600.1.4.15-branch/Source/WebCore/html/parser/HTMLSrcsetParser.h        2015-01-20 20:37:35 UTC (rev 178734)
+++ branches/safari-600.1.4.15-branch/Source/WebCore/html/parser/HTMLSrcsetParser.h        2015-01-20 20:40:00 UTC (rev 178735)
</span><span class="lines">@@ -104,6 +104,8 @@
</span><span class="cx"> #endif
</span><span class="cx">     );
</span><span class="cx"> 
</span><ins>+Vector&lt;ImageCandidate&gt; parseImageCandidatesFromSrcsetAttribute(StringView attribute);
+
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> #endif
</span></span></pre>
</div>
</div>

</body>
</html>