<!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>[163415] 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/163415">163415</a></dd>
<dt>Author</dt> <dd>commit-queue@webkit.org</dd>
<dt>Date</dt> <dd>2014-02-04 16:09:15 -0800 (Tue, 04 Feb 2014)</dd>
</dl>

<h3>Log Message</h3>
<pre>Use srcset's pixel density to determine intrinsic size
https://bugs.webkit.org/show_bug.cgi?id=123832

Patch by Yoav Weiss &lt;yoav@yoav.ws&gt; on 2014-02-04
Reviewed by Dean Jackson.

The patch is a port of a similar Blink patch: https://codereview.chromium.org/25105004
According to the spec &quot;When an img element has a current pixel density that is not 1.0,
the element's image data must be treated as if its resolution, in device pixels per CSS pixels,
was the current pixel density.&quot;

Source/WebCore:

I've added that support using the following changes:
- bestFitSourceForImageAttributes now returns the image candidate to HTMLImageElement.
- HTMLImageElement passes the devicePixelRatio data to RenderImage, which stores it.
- Bitmap images are scaled using the devicePixelRatio at RenderImageResource's intrinsicSize() and imageSize().
- SVG images are scaled using the devicePixelRatio at RenderReplaced::computeAspectRatioInformationForRenderBox.
- Canvas support added at CanvasRenderingContext2D::size.

Tests: fast/hidpi/image-srcset-intrinsic-size.html
       fast/hidpi/image-srcset-png-canvas.html
       fast/hidpi/image-srcset-png.html
       fast/hidpi/image-srcset-relative-svg-canvas-2x.html
       fast/hidpi/image-srcset-relative-svg.html
       fast/hidpi/image-srcset-space-left-nomodifier.html
       fast/hidpi/image-srcset-svg-canvas-2x.html
       fast/hidpi/image-srcset-svg-canvas.html
       fast/hidpi/image-srcset-svg.html
       fast/hidpi/image-srcset-svg2.html

* html/HTMLImageElement.cpp:
(WebCore::HTMLImageElement::HTMLImageElement):
(WebCore::HTMLImageElement::parseAttribute):
(WebCore::HTMLImageElement::createRenderer):
* html/HTMLImageElement.h:
* html/canvas/CanvasRenderingContext2D.cpp:
(WebCore::size):
(WebCore::CanvasRenderingContext2D::drawImage):
* html/parser/HTMLParserIdioms.cpp:
(WebCore::compareByScaleFactor):
(WebCore::parseImagesWithScaleFromSrcsetAttribute):
(WebCore::bestFitSourceForImageAttributes):
* html/parser/HTMLParserIdioms.h:
(WebCore::ImageWithScale::ImageWithScale):
(WebCore::ImageWithScale::imageURL):
(WebCore::ImageWithScale::scaleFactor):
* html/parser/HTMLPreloadScanner.cpp:
(WebCore::TokenPreloadScanner::StartTagScanner::processAttributes):
* rendering/RenderImage.cpp:
(WebCore::RenderImage::RenderImage):
* rendering/RenderImage.h:
(WebCore::RenderImage::setImageDevicePixelRatio):
(WebCore::RenderImage::imageDevicePixelRatio):
* rendering/RenderImageResource.cpp:
(WebCore::RenderImageResource::imageSize):
(WebCore::RenderImageResource::intrinsicSize):
(WebCore::RenderImageResource::getImageSize):
* rendering/RenderImageResource.h:
* rendering/RenderReplaced.cpp:
(WebCore::RenderReplaced::computeAspectRatioInformationForRenderBox):

LayoutTests:

Layout test changes include modifications of existing tests to accomodate the new image dimensions, as well as new tests for this
specific functionality.

* fast/hidpi/image-srcset-change-dynamically-from-js-2x-expected.txt:
* fast/hidpi/image-srcset-change-dynamically-from-js-2x.html:
* fast/hidpi/image-srcset-data-escaped-srcset-expected.txt:
* fast/hidpi/image-srcset-data-escaped-srcset.html:
* fast/hidpi/image-srcset-data-src.html:
* fast/hidpi/image-srcset-data-srcset.html:
* fast/hidpi/image-srcset-fraction.html:
* fast/hidpi/image-srcset-intrinsic-size-expected.txt: Added.
* fast/hidpi/image-srcset-intrinsic-size.html: Added.
* fast/hidpi/image-srcset-invalid-inputs-correct-src-expected.txt:
* fast/hidpi/image-srcset-invalid-inputs-correct-src.html:
* fast/hidpi/image-srcset-invalid-inputs.html:
* fast/hidpi/image-srcset-invalid-inputs-expected.txt: Added.
* fast/hidpi/image-srcset-only-src-attribute-expected.txt: Added.
* fast/hidpi/image-srcset-only-src-attribute.html:
* fast/hidpi/image-srcset-png-canvas-expected.html: Added.
* fast/hidpi/image-srcset-png-canvas.html: Added.
* fast/hidpi/image-srcset-png-expected.html: Added.
* fast/hidpi/image-srcset-png.html: Added.
* fast/hidpi/image-srcset-relative-svg-expected.html: Added.
* fast/hidpi/image-srcset-relative-svg.html: Added.
* fast/hidpi/image-srcset-remove-dynamically-from-js.html:
* fast/hidpi/image-srcset-simple-2x-expected.txt:
* fast/hidpi/image-srcset-simple-2x.html:
* fast/hidpi/image-srcset-space-left-nomodifier-expected.txt: Added.
* fast/hidpi/image-srcset-space-left-nomodifier.html: Copied from LayoutTests/fast/hidpi/image-srcset-data-srcset.html.
* fast/hidpi/image-srcset-svg-expected.html: Added.
* fast/hidpi/image-srcset-svg.html: Added.
* fast/hidpi/image-srcset-svg2-expected.html: Added.
* fast/hidpi/image-srcset-svg2.html: Added.
* fast/hidpi/resources/green-400-px-square.png: Added.
* fast/hidpi/resources/relativesrcset.svg: Added.
* fast/hidpi/resources/srcset-helper.js:
(runTest):
* fast/hidpi/resources/srcset.png: Added.
* fast/hidpi/resources/srcset.svg: Added.
* fast/hidpi/resources/srcset_100px.svg: Added.
* fast/hidpi/resources/svg_canvas_helper.js: Added.
(drawCanvas):
* fast/hidpi/resources/svg_tests.css: Added.
(.test):
(.test img, .test canvas):
(.test .stats):
(.expected, .actual):
* platform/mac/fast/hidpi/image-srcset-only-src-attribute-expected.png: Removed.
* platform/mac/fast/hidpi/image-srcset-only-src-attribute-expected.txt: Removed.

The following tests were added, but skipped, since they reveal an unrelated SVG on canvas rendering issue:
* fast/hidpi/image-srcset-svg-canvas-2x-expected.html: Added.
* fast/hidpi/image-srcset-svg-canvas-2x.html: Added.
* fast/hidpi/image-srcset-svg-canvas-expected.html: Added.
* fast/hidpi/image-srcset-svg-canvas.html: Added.
* fast/hidpi/image-srcset-relative-svg-canvas-2x-expected.html: Added.
* fast/hidpi/image-srcset-relative-svg-canvas-2x.html: Added.
* fast/hidpi/image-srcset-relative-svg-canvas-expected.html: Added.
* fast/hidpi/image-srcset-relative-svg-canvas.html: Added.</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkLayoutTestsChangeLog">trunk/LayoutTests/ChangeLog</a></li>
<li><a href="#trunkLayoutTestsTestExpectations">trunk/LayoutTests/TestExpectations</a></li>
<li><a href="#trunkLayoutTestsfasthidpiimagesrcsetchangedynamicallyfromjs2xexpectedtxt">trunk/LayoutTests/fast/hidpi/image-srcset-change-dynamically-from-js-2x-expected.txt</a></li>
<li><a href="#trunkLayoutTestsfasthidpiimagesrcsetchangedynamicallyfromjs2xhtml">trunk/LayoutTests/fast/hidpi/image-srcset-change-dynamically-from-js-2x.html</a></li>
<li><a href="#trunkLayoutTestsfasthidpiimagesrcsetdataescapedsrcsetexpectedtxt">trunk/LayoutTests/fast/hidpi/image-srcset-data-escaped-srcset-expected.txt</a></li>
<li><a href="#trunkLayoutTestsfasthidpiimagesrcsetdataescapedsrcsethtml">trunk/LayoutTests/fast/hidpi/image-srcset-data-escaped-srcset.html</a></li>
<li><a href="#trunkLayoutTestsfasthidpiimagesrcsetdatasrchtml">trunk/LayoutTests/fast/hidpi/image-srcset-data-src.html</a></li>
<li><a href="#trunkLayoutTestsfasthidpiimagesrcsetdatasrcsethtml">trunk/LayoutTests/fast/hidpi/image-srcset-data-srcset.html</a></li>
<li><a href="#trunkLayoutTestsfasthidpiimagesrcsetfraction15xhtml">trunk/LayoutTests/fast/hidpi/image-srcset-fraction-1.5x.html</a></li>
<li><a href="#trunkLayoutTestsfasthidpiimagesrcsetfractionhtml">trunk/LayoutTests/fast/hidpi/image-srcset-fraction.html</a></li>
<li><a href="#trunkLayoutTestsfasthidpiimagesrcsetinvalidinputscorrectsrcexpectedtxt">trunk/LayoutTests/fast/hidpi/image-srcset-invalid-inputs-correct-src-expected.txt</a></li>
<li><a href="#trunkLayoutTestsfasthidpiimagesrcsetinvalidinputscorrectsrchtml">trunk/LayoutTests/fast/hidpi/image-srcset-invalid-inputs-correct-src.html</a></li>
<li><a href="#trunkLayoutTestsfasthidpiimagesrcsetinvalidinputsexceptonehtml">trunk/LayoutTests/fast/hidpi/image-srcset-invalid-inputs-except-one.html</a></li>
<li><a href="#trunkLayoutTestsfasthidpiimagesrcsetinvalidinputshtml">trunk/LayoutTests/fast/hidpi/image-srcset-invalid-inputs.html</a></li>
<li><a href="#trunkLayoutTestsfasthidpiimagesrcsetonlysrcattributehtml">trunk/LayoutTests/fast/hidpi/image-srcset-only-src-attribute.html</a></li>
<li><a href="#trunkLayoutTestsfasthidpiimagesrcsetremovedynamicallyfromjshtml">trunk/LayoutTests/fast/hidpi/image-srcset-remove-dynamically-from-js.html</a></li>
<li><a href="#trunkLayoutTestsfasthidpiimagesrcsetsimple2xexpectedtxt">trunk/LayoutTests/fast/hidpi/image-srcset-simple-2x-expected.txt</a></li>
<li><a href="#trunkLayoutTestsfasthidpiimagesrcsetsimple2xhtml">trunk/LayoutTests/fast/hidpi/image-srcset-simple-2x.html</a></li>
<li><a href="#trunkLayoutTestsfasthidpiimagesrcsetsrcselection2xhtml">trunk/LayoutTests/fast/hidpi/image-srcset-src-selection-2x.html</a></li>
<li><a href="#trunkLayoutTestsfasthidpiresourcessrcsethelperjs">trunk/LayoutTests/fast/hidpi/resources/srcset-helper.js</a></li>
<li><a href="#trunkSourceWebCoreChangeLog">trunk/Source/WebCore/ChangeLog</a></li>
<li><a href="#trunkSourceWebCorehtmlHTMLImageElementcpp">trunk/Source/WebCore/html/HTMLImageElement.cpp</a></li>
<li><a href="#trunkSourceWebCorehtmlHTMLImageElementh">trunk/Source/WebCore/html/HTMLImageElement.h</a></li>
<li><a href="#trunkSourceWebCorehtmlcanvasCanvasRenderingContext2Dcpp">trunk/Source/WebCore/html/canvas/CanvasRenderingContext2D.cpp</a></li>
<li><a href="#trunkSourceWebCorehtmlparserHTMLParserIdiomscpp">trunk/Source/WebCore/html/parser/HTMLParserIdioms.cpp</a></li>
<li><a href="#trunkSourceWebCorehtmlparserHTMLParserIdiomsh">trunk/Source/WebCore/html/parser/HTMLParserIdioms.h</a></li>
<li><a href="#trunkSourceWebCorehtmlparserHTMLPreloadScannercpp">trunk/Source/WebCore/html/parser/HTMLPreloadScanner.cpp</a></li>
<li><a href="#trunkSourceWebCorerenderingRenderImagecpp">trunk/Source/WebCore/rendering/RenderImage.cpp</a></li>
<li><a href="#trunkSourceWebCorerenderingRenderImageh">trunk/Source/WebCore/rendering/RenderImage.h</a></li>
<li><a href="#trunkSourceWebCorerenderingRenderImageResourcecpp">trunk/Source/WebCore/rendering/RenderImageResource.cpp</a></li>
<li><a href="#trunkSourceWebCorerenderingRenderImageResourceh">trunk/Source/WebCore/rendering/RenderImageResource.h</a></li>
<li><a href="#trunkSourceWebCorerenderingRenderReplacedcpp">trunk/Source/WebCore/rendering/RenderReplaced.cpp</a></li>
</ul>

<h3>Added Paths</h3>
<ul>
<li><a href="#trunkLayoutTestsfasthidpiimagesrcsetintrinsicsizeexpectedtxt">trunk/LayoutTests/fast/hidpi/image-srcset-intrinsic-size-expected.txt</a></li>
<li><a href="#trunkLayoutTestsfasthidpiimagesrcsetintrinsicsizehtml">trunk/LayoutTests/fast/hidpi/image-srcset-intrinsic-size.html</a></li>
<li><a href="#trunkLayoutTestsfasthidpiimagesrcsetinvalidinputsexpectedtxt">trunk/LayoutTests/fast/hidpi/image-srcset-invalid-inputs-expected.txt</a></li>
<li><a href="#trunkLayoutTestsfasthidpiimagesrcsetonlysrcattributeexpectedtxt">trunk/LayoutTests/fast/hidpi/image-srcset-only-src-attribute-expected.txt</a></li>
<li><a href="#trunkLayoutTestsfasthidpiimagesrcsetpngcanvasexpectedhtml">trunk/LayoutTests/fast/hidpi/image-srcset-png-canvas-expected.html</a></li>
<li><a href="#trunkLayoutTestsfasthidpiimagesrcsetpngcanvashtml">trunk/LayoutTests/fast/hidpi/image-srcset-png-canvas.html</a></li>
<li><a href="#trunkLayoutTestsfasthidpiimagesrcsetpngexpectedhtml">trunk/LayoutTests/fast/hidpi/image-srcset-png-expected.html</a></li>
<li><a href="#trunkLayoutTestsfasthidpiimagesrcsetpnghtml">trunk/LayoutTests/fast/hidpi/image-srcset-png.html</a></li>
<li><a href="#trunkLayoutTestsfasthidpiimagesrcsetrelativesvgcanvas2xexpectedhtml">trunk/LayoutTests/fast/hidpi/image-srcset-relative-svg-canvas-2x-expected.html</a></li>
<li><a href="#trunkLayoutTestsfasthidpiimagesrcsetrelativesvgcanvas2xhtml">trunk/LayoutTests/fast/hidpi/image-srcset-relative-svg-canvas-2x.html</a></li>
<li><a href="#trunkLayoutTestsfasthidpiimagesrcsetrelativesvgcanvasexpectedhtml">trunk/LayoutTests/fast/hidpi/image-srcset-relative-svg-canvas-expected.html</a></li>
<li><a href="#trunkLayoutTestsfasthidpiimagesrcsetrelativesvgcanvashtml">trunk/LayoutTests/fast/hidpi/image-srcset-relative-svg-canvas.html</a></li>
<li><a href="#trunkLayoutTestsfasthidpiimagesrcsetrelativesvgexpectedhtml">trunk/LayoutTests/fast/hidpi/image-srcset-relative-svg-expected.html</a></li>
<li><a href="#trunkLayoutTestsfasthidpiimagesrcsetrelativesvghtml">trunk/LayoutTests/fast/hidpi/image-srcset-relative-svg.html</a></li>
<li><a href="#trunkLayoutTestsfasthidpiimagesrcsetspaceleftnomodifierexpectedtxt">trunk/LayoutTests/fast/hidpi/image-srcset-space-left-nomodifier-expected.txt</a></li>
<li><a href="#trunkLayoutTestsfasthidpiimagesrcsetspaceleftnomodifierhtml">trunk/LayoutTests/fast/hidpi/image-srcset-space-left-nomodifier.html</a></li>
<li><a href="#trunkLayoutTestsfasthidpiimagesrcsetsvgcanvas2xexpectedhtml">trunk/LayoutTests/fast/hidpi/image-srcset-svg-canvas-2x-expected.html</a></li>
<li><a href="#trunkLayoutTestsfasthidpiimagesrcsetsvgcanvas2xhtml">trunk/LayoutTests/fast/hidpi/image-srcset-svg-canvas-2x.html</a></li>
<li><a href="#trunkLayoutTestsfasthidpiimagesrcsetsvgcanvasexpectedhtml">trunk/LayoutTests/fast/hidpi/image-srcset-svg-canvas-expected.html</a></li>
<li><a href="#trunkLayoutTestsfasthidpiimagesrcsetsvgcanvashtml">trunk/LayoutTests/fast/hidpi/image-srcset-svg-canvas.html</a></li>
<li><a href="#trunkLayoutTestsfasthidpiimagesrcsetsvgexpectedhtml">trunk/LayoutTests/fast/hidpi/image-srcset-svg-expected.html</a></li>
<li><a href="#trunkLayoutTestsfasthidpiimagesrcsetsvghtml">trunk/LayoutTests/fast/hidpi/image-srcset-svg.html</a></li>
<li><a href="#trunkLayoutTestsfasthidpiimagesrcsetsvg2expectedhtml">trunk/LayoutTests/fast/hidpi/image-srcset-svg2-expected.html</a></li>
<li><a href="#trunkLayoutTestsfasthidpiimagesrcsetsvg2html">trunk/LayoutTests/fast/hidpi/image-srcset-svg2.html</a></li>
<li><a href="#trunkLayoutTestsfasthidpiresourcesgreen400pxsquarepng">trunk/LayoutTests/fast/hidpi/resources/green-400-px-square.png</a></li>
<li><a href="#trunkLayoutTestsfasthidpiresourcesrelativesrcsetsvg">trunk/LayoutTests/fast/hidpi/resources/relativesrcset.svg</a></li>
<li><a href="#trunkLayoutTestsfasthidpiresourcessrcsetpng">trunk/LayoutTests/fast/hidpi/resources/srcset.png</a></li>
<li><a href="#trunkLayoutTestsfasthidpiresourcessrcsetsvg">trunk/LayoutTests/fast/hidpi/resources/srcset.svg</a></li>
<li><a href="#trunkLayoutTestsfasthidpiresourcessrcset_100pxsvg">trunk/LayoutTests/fast/hidpi/resources/srcset_100px.svg</a></li>
<li><a href="#trunkLayoutTestsfasthidpiresourcessvg_canvas_helperjs">trunk/LayoutTests/fast/hidpi/resources/svg_canvas_helper.js</a></li>
<li><a href="#trunkLayoutTestsfasthidpiresourcessvg_testscss">trunk/LayoutTests/fast/hidpi/resources/svg_tests.css</a></li>
<li>trunk/LayoutTests/platform/gtk-wk2/fast/hidpi/</li>
<li><a href="#trunkLayoutTestsplatformgtkwk2fasthidpiimagesrcsetchangedynamicallyfromjs2xexpectedtxt">trunk/LayoutTests/platform/gtk-wk2/fast/hidpi/image-srcset-change-dynamically-from-js-2x-expected.txt</a></li>
</ul>

<h3>Removed Paths</h3>
<ul>
<li><a href="#trunkLayoutTestsplatformmacfasthidpiimagesrcsetinvalidinputscorrectsrcexpectedpng">trunk/LayoutTests/platform/mac/fast/hidpi/image-srcset-invalid-inputs-correct-src-expected.png</a></li>
<li><a href="#trunkLayoutTestsplatformmacfasthidpiimagesrcsetinvalidinputsexceptoneexpectedpng">trunk/LayoutTests/platform/mac/fast/hidpi/image-srcset-invalid-inputs-except-one-expected.png</a></li>
<li><a href="#trunkLayoutTestsplatformmacfasthidpiimagesrcsetinvalidinputsexpectedpng">trunk/LayoutTests/platform/mac/fast/hidpi/image-srcset-invalid-inputs-expected.png</a></li>
<li><a href="#trunkLayoutTestsplatformmacfasthidpiimagesrcsetinvalidinputsexpectedtxt">trunk/LayoutTests/platform/mac/fast/hidpi/image-srcset-invalid-inputs-expected.txt</a></li>
<li><a href="#trunkLayoutTestsplatformmacfasthidpiimagesrcsetonlysrcattributeexpectedpng">trunk/LayoutTests/platform/mac/fast/hidpi/image-srcset-only-src-attribute-expected.png</a></li>
<li><a href="#trunkLayoutTestsplatformmacfasthidpiimagesrcsetonlysrcattributeexpectedtxt">trunk/LayoutTests/platform/mac/fast/hidpi/image-srcset-only-src-attribute-expected.txt</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkLayoutTestsChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/ChangeLog (163414 => 163415)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/ChangeLog        2014-02-05 00:08:40 UTC (rev 163414)
+++ trunk/LayoutTests/ChangeLog        2014-02-05 00:09:15 UTC (rev 163415)
</span><span class="lines">@@ -1,3 +1,75 @@
</span><ins>+2014-02-04  Yoav Weiss  &lt;yoav@yoav.ws&gt;
+
+        Use srcset's pixel density to determine intrinsic size
+        https://bugs.webkit.org/show_bug.cgi?id=123832
+
+        Reviewed by Dean Jackson.
+
+        The patch is a port of a similar Blink patch: https://codereview.chromium.org/25105004
+        According to the spec &quot;When an img element has a current pixel density that is not 1.0,
+        the element's image data must be treated as if its resolution, in device pixels per CSS pixels,
+        was the current pixel density.&quot;
+
+        Layout test changes include modifications of existing tests to accomodate the new image dimensions, as well as new tests for this
+        specific functionality.
+
+        * fast/hidpi/image-srcset-change-dynamically-from-js-2x-expected.txt:
+        * fast/hidpi/image-srcset-change-dynamically-from-js-2x.html:
+        * fast/hidpi/image-srcset-data-escaped-srcset-expected.txt:
+        * fast/hidpi/image-srcset-data-escaped-srcset.html:
+        * fast/hidpi/image-srcset-data-src.html:
+        * fast/hidpi/image-srcset-data-srcset.html:
+        * fast/hidpi/image-srcset-fraction.html:
+        * fast/hidpi/image-srcset-intrinsic-size-expected.txt: Added.
+        * fast/hidpi/image-srcset-intrinsic-size.html: Added.
+        * fast/hidpi/image-srcset-invalid-inputs-correct-src-expected.txt:
+        * fast/hidpi/image-srcset-invalid-inputs-correct-src.html:
+        * fast/hidpi/image-srcset-invalid-inputs.html:
+        * fast/hidpi/image-srcset-invalid-inputs-expected.txt: Added.
+        * fast/hidpi/image-srcset-only-src-attribute-expected.txt: Added.
+        * fast/hidpi/image-srcset-only-src-attribute.html:
+        * fast/hidpi/image-srcset-png-canvas-expected.html: Added.
+        * fast/hidpi/image-srcset-png-canvas.html: Added.
+        * fast/hidpi/image-srcset-png-expected.html: Added.
+        * fast/hidpi/image-srcset-png.html: Added.
+        * fast/hidpi/image-srcset-relative-svg-expected.html: Added.
+        * fast/hidpi/image-srcset-relative-svg.html: Added.
+        * fast/hidpi/image-srcset-remove-dynamically-from-js.html:
+        * fast/hidpi/image-srcset-simple-2x-expected.txt:
+        * fast/hidpi/image-srcset-simple-2x.html:
+        * fast/hidpi/image-srcset-space-left-nomodifier-expected.txt: Added.
+        * fast/hidpi/image-srcset-space-left-nomodifier.html: Copied from LayoutTests/fast/hidpi/image-srcset-data-srcset.html.
+        * fast/hidpi/image-srcset-svg-expected.html: Added.
+        * fast/hidpi/image-srcset-svg.html: Added.
+        * fast/hidpi/image-srcset-svg2-expected.html: Added.
+        * fast/hidpi/image-srcset-svg2.html: Added.
+        * fast/hidpi/resources/green-400-px-square.png: Added.
+        * fast/hidpi/resources/relativesrcset.svg: Added.
+        * fast/hidpi/resources/srcset-helper.js:
+        (runTest):
+        * fast/hidpi/resources/srcset.png: Added.
+        * fast/hidpi/resources/srcset.svg: Added.
+        * fast/hidpi/resources/srcset_100px.svg: Added.
+        * fast/hidpi/resources/svg_canvas_helper.js: Added.
+        (drawCanvas):
+        * fast/hidpi/resources/svg_tests.css: Added.
+        (.test):
+        (.test img, .test canvas):
+        (.test .stats):
+        (.expected, .actual):
+        * platform/mac/fast/hidpi/image-srcset-only-src-attribute-expected.png: Removed.
+        * platform/mac/fast/hidpi/image-srcset-only-src-attribute-expected.txt: Removed.
+
+        The following tests were added, but skipped, since they reveal an unrelated SVG on canvas rendering issue:
+        * fast/hidpi/image-srcset-svg-canvas-2x-expected.html: Added.
+        * fast/hidpi/image-srcset-svg-canvas-2x.html: Added.
+        * fast/hidpi/image-srcset-svg-canvas-expected.html: Added.
+        * fast/hidpi/image-srcset-svg-canvas.html: Added.
+        * fast/hidpi/image-srcset-relative-svg-canvas-2x-expected.html: Added.
+        * fast/hidpi/image-srcset-relative-svg-canvas-2x.html: Added.
+        * fast/hidpi/image-srcset-relative-svg-canvas-expected.html: Added.
+        * fast/hidpi/image-srcset-relative-svg-canvas.html: Added.
+
</ins><span class="cx"> 2014-02-04  Geoffrey Garen  &lt;ggaren@apple.com&gt;
</span><span class="cx"> 
</span><span class="cx">         Rolled out &lt;http://trac.webkit.org/changeset/163280&gt;:
</span></span></pre></div>
<a id="trunkLayoutTestsTestExpectations"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/TestExpectations (163414 => 163415)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/TestExpectations        2014-02-05 00:08:40 UTC (rev 163414)
+++ trunk/LayoutTests/TestExpectations        2014-02-05 00:09:15 UTC (rev 163415)
</span><span class="lines">@@ -58,6 +58,11 @@
</span><span class="cx"> webkit.org/b/120148 [ Release ] webaudio/javascriptaudionode-downmix8-2channel-input.html [ Pass Failure ]
</span><span class="cx"> webkit.org/b/120148 [ Debug ] webaudio/javascriptaudionode-downmix8-2channel-input.html [ Pass Crash ]
</span><span class="cx"> 
</span><ins>+webkit.org/b/124342 fast/hidpi/image-srcset-svg-canvas.html [ Failure ]
+webkit.org/b/124342 fast/hidpi/image-srcset-svg-canvas-2x.html [ Failure ]
+webkit.org/b/124349 fast/hidpi/image-srcset-relative-svg-canvas-2x.html [ Failure ]
+webkit.org/b/124349 fast/hidpi/image-srcset-relative-svg-canvas.html [ Failure ]
+
</ins><span class="cx"> webaudio/javascriptaudionode-downmix8-2channel-input.html
</span><span class="cx"> 
</span><span class="cx"> # The test frequently times out, and is just unsuccessful at detecting incorrect behavior when it passes.
</span></span></pre></div>
<a id="trunkLayoutTestsfasthidpiimagesrcsetchangedynamicallyfromjs2xexpectedtxt"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/fast/hidpi/image-srcset-change-dynamically-from-js-2x-expected.txt (163414 => 163415)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/fast/hidpi/image-srcset-change-dynamically-from-js-2x-expected.txt        2014-02-05 00:08:40 UTC (rev 163414)
+++ trunk/LayoutTests/fast/hidpi/image-srcset-change-dynamically-from-js-2x-expected.txt        2014-02-05 00:09:15 UTC (rev 163415)
</span><span class="lines">@@ -1,4 +1,8 @@
</span><del>-PASS internals.isPreloaded(&quot;resources/blue-100-px-square.png&quot;) is false
</del><ins>+blue-100-px-square.png has MIME type image/png
+image-srcset-change-dynamically-from-js-2x.html has MIME type text/html
+srcset-helper.js has MIME type text/javascript
+js-test-pre.js has MIME type text/javascript
+green-400-px-square.png has MIME type image/png
</ins><span class="cx"> PASS document.getElementById(&quot;foo&quot;).clientWidth==200 is true
</span><span class="cx"> This test passes if this img tag below is a green square when the scale factor is 2. It ensures that attributes can be changed dynamically from javascript, and that only the correct resource is loaded.
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkLayoutTestsfasthidpiimagesrcsetchangedynamicallyfromjs2xhtml"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/fast/hidpi/image-srcset-change-dynamically-from-js-2x.html (163414 => 163415)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/fast/hidpi/image-srcset-change-dynamically-from-js-2x.html        2014-02-05 00:08:40 UTC (rev 163414)
+++ trunk/LayoutTests/fast/hidpi/image-srcset-change-dynamically-from-js-2x.html        2014-02-05 00:09:15 UTC (rev 163415)
</span><span class="lines">@@ -5,12 +5,13 @@
</span><span class="cx"> &lt;script&gt;
</span><span class="cx">     if (window.testRunner) {
</span><span class="cx">         testRunner.dumpAsText();
</span><ins>+        testRunner.dumpResourceResponseMIMETypes();
</ins><span class="cx">     }
</span><span class="cx"> 
</span><span class="cx">     function updateSrc() {
</span><span class="cx">         var img = document.getElementById(&quot;foo&quot;);
</span><span class="cx">         // srcset must be set first, otherwise 'src' is loaded as well
</span><del>-        img.srcset = &quot;resources/green-200-px-square.png 2x&quot;;
</del><ins>+        img.srcset = &quot;resources/blue-100-px-square.png 1x, resources/green-400-px-square.png 2x&quot;;
</ins><span class="cx">         img.src = &quot;resources/blue-100-px-square.png&quot;
</span><span class="cx">     }
</span><span class="cx"> 
</span><span class="lines">@@ -18,8 +19,6 @@
</span><span class="cx">         updateSrc();
</span><span class="cx">     }, false);
</span><span class="cx">     addEventListener(&quot;load&quot;, function() {
</span><del>-        if (internals)
-            shouldBeFalse('internals.isPreloaded(&quot;resources/blue-100-px-square.png&quot;)');
</del><span class="cx">         shouldBeTrue('document.getElementById(&quot;foo&quot;).clientWidth==200');
</span><span class="cx">     }, false);
</span><span class="cx"> &lt;/script&gt;
</span></span></pre></div>
<a id="trunkLayoutTestsfasthidpiimagesrcsetdataescapedsrcsetexpectedtxt"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/fast/hidpi/image-srcset-data-escaped-srcset-expected.txt (163414 => 163415)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/fast/hidpi/image-srcset-data-escaped-srcset-expected.txt        2014-02-05 00:08:40 UTC (rev 163414)
+++ trunk/LayoutTests/fast/hidpi/image-srcset-data-escaped-srcset-expected.txt        2014-02-05 00:09:15 UTC (rev 163415)
</span><span class="lines">@@ -1,3 +1,3 @@
</span><del>-PASS document.getElementById(&quot;foo&quot;).clientWidth==100 is true
</del><ins>+PASS document.getElementById(&quot;foo&quot;).clientWidth==50 is true
</ins><span class="cx"> This test passes if the image below is not empty. It ensures that the srcset attribute support data URI schemes with escaped characters.
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkLayoutTestsfasthidpiimagesrcsetdataescapedsrcsethtml"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/fast/hidpi/image-srcset-data-escaped-srcset.html (163414 => 163415)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/fast/hidpi/image-srcset-data-escaped-srcset.html        2014-02-05 00:08:40 UTC (rev 163414)
+++ trunk/LayoutTests/fast/hidpi/image-srcset-data-escaped-srcset.html        2014-02-05 00:09:15 UTC (rev 163415)
</span><span class="lines">@@ -7,7 +7,7 @@
</span><span class="cx">     }
</span><span class="cx"> 
</span><span class="cx">     addEventListener(&quot;load&quot;, function() {
</span><del>-        shouldBeTrue('document.getElementById(&quot;foo&quot;).clientWidth==100');
</del><ins>+        shouldBeTrue('document.getElementById(&quot;foo&quot;).clientWidth==50');
</ins><span class="cx">     }, false);
</span><span class="cx"> &lt;/script&gt;
</span><span class="cx"> &lt;/head&gt;
</span></span></pre></div>
<a id="trunkLayoutTestsfasthidpiimagesrcsetdatasrchtml"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/fast/hidpi/image-srcset-data-src.html (163414 => 163415)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/fast/hidpi/image-srcset-data-src.html        2014-02-05 00:08:40 UTC (rev 163414)
+++ trunk/LayoutTests/fast/hidpi/image-srcset-data-src.html        2014-02-05 00:09:15 UTC (rev 163415)
</span><span class="lines">@@ -2,10 +2,6 @@
</span><span class="cx"> &lt;head&gt;
</span><span class="cx"> &lt;script src=&quot;../../resources/js-test-pre.js&quot;&gt;&lt;/script&gt;
</span><span class="cx"> &lt;script&gt;
</span><del>-    if (window.testRunner) {
-        testRunner.dumpAsText();
-    }
-
</del><span class="cx">     addEventListener(&quot;load&quot;, function() {
</span><span class="cx">         shouldBeTrue('document.getElementById(&quot;foo&quot;).clientWidth==150');
</span><span class="cx">     }, false);
</span></span></pre></div>
<a id="trunkLayoutTestsfasthidpiimagesrcsetdatasrcsethtml"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/fast/hidpi/image-srcset-data-srcset.html (163414 => 163415)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/fast/hidpi/image-srcset-data-srcset.html        2014-02-05 00:08:40 UTC (rev 163414)
+++ trunk/LayoutTests/fast/hidpi/image-srcset-data-srcset.html        2014-02-05 00:09:15 UTC (rev 163415)
</span><span class="lines">@@ -2,10 +2,6 @@
</span><span class="cx"> &lt;head&gt;
</span><span class="cx"> &lt;script src=&quot;../../resources/js-test-pre.js&quot;&gt;&lt;/script&gt;
</span><span class="cx"> &lt;script&gt;
</span><del>-    if (window.testRunner) {
-        testRunner.dumpAsText();
-    }
-
</del><span class="cx">     addEventListener(&quot;load&quot;, function() {
</span><span class="cx">         shouldBeTrue('document.getElementById(&quot;foo&quot;).clientWidth==150');
</span><span class="cx">     }, false);
</span></span></pre></div>
<a id="trunkLayoutTestsfasthidpiimagesrcsetfraction15xhtml"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/fast/hidpi/image-srcset-fraction-1.5x.html (163414 => 163415)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/fast/hidpi/image-srcset-fraction-1.5x.html        2014-02-05 00:08:40 UTC (rev 163414)
+++ trunk/LayoutTests/fast/hidpi/image-srcset-fraction-1.5x.html        2014-02-05 00:09:15 UTC (rev 163415)
</span><span class="lines">@@ -18,6 +18,6 @@
</span><span class="cx"> &lt;/head&gt;
</span><span class="cx"> &lt;body&gt;
</span><span class="cx"> &lt;div&gt;This test passes if the srcset resource is loaded and displayed as the image&lt;/div&gt;
</span><del>-&lt;img src=&quot;resources/blue-100-px-square.png&quot; srcset=&quot;resources/green-200-px-square.png 2x&quot; id=&quot;testimg&quot;&gt;
</del><ins>+&lt;img src=&quot;resources/blue-100-px-square.png&quot; srcset=&quot;resources/green-400-px-square.png 2x&quot; id=&quot;testimg&quot;&gt;
</ins><span class="cx"> &lt;/body&gt;
</span><span class="cx"> &lt;/html&gt;
</span></span></pre></div>
<a id="trunkLayoutTestsfasthidpiimagesrcsetfractionhtml"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/fast/hidpi/image-srcset-fraction.html (163414 => 163415)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/fast/hidpi/image-srcset-fraction.html        2014-02-05 00:08:40 UTC (rev 163414)
+++ trunk/LayoutTests/fast/hidpi/image-srcset-fraction.html        2014-02-05 00:09:15 UTC (rev 163415)
</span><span class="lines">@@ -6,10 +6,6 @@
</span><span class="cx"> &lt;script src=&quot;resources/srcset-helper.js&quot;&gt;&lt;/script&gt;
</span><span class="cx"> &lt;script src=&quot;../../resources/js-test-pre.js&quot;&gt;&lt;/script&gt;
</span><span class="cx"> &lt;script&gt;
</span><del>-    if (window.testRunner) {
-        testRunner.dumpAsText();
-    }
-
</del><span class="cx">     addEventListener(&quot;load&quot;, function() {
</span><span class="cx">         if (internals)
</span><span class="cx">             shouldBeTrue('document.getElementById(&quot;testimg&quot;).clientWidth==200');
</span><span class="lines">@@ -18,7 +14,7 @@
</span><span class="cx"> &lt;/head&gt;
</span><span class="cx"> &lt;body&gt;
</span><span class="cx"> &lt;div&gt;This test passes if the srcset resource is loaded and displayed as the image&lt;/div&gt;
</span><del>-&lt;img src=&quot;resources/blue-100-px-square.png&quot; srcset=&quot;resources/green-200-px-square.png 2x&quot; id=&quot;testimg&quot;&gt;
</del><ins>+&lt;img src=&quot;resources/blue-100-px-square.png&quot; srcset=&quot;resources/green-400-px-square.png 2x&quot; id=&quot;testimg&quot;&gt;
</ins><span class="cx"> &lt;/body&gt;
</span><span class="cx"> &lt;/html&gt;
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkLayoutTestsfasthidpiimagesrcsetintrinsicsizeexpectedtxt"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/fast/hidpi/image-srcset-intrinsic-size-expected.txt (0 => 163415)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/fast/hidpi/image-srcset-intrinsic-size-expected.txt                                (rev 0)
+++ trunk/LayoutTests/fast/hidpi/image-srcset-intrinsic-size-expected.txt        2014-02-05 00:09:15 UTC (rev 163415)
</span><span class="lines">@@ -0,0 +1,9 @@
</span><ins>+PASS document.getElementById(&quot;foo&quot;).clientWidth==200 is true
+PASS document.getElementById(&quot;foo2&quot;).clientWidth==400 is true
+PASS document.getElementById(&quot;foo3&quot;).clientWidth==100 is true
+PASS document.getElementById(&quot;foo4&quot;).clientWidth==200 is true
+This test passes if the images are all displayed with appropriate dimensions.



+
</ins></span></pre></div>
<a id="trunkLayoutTestsfasthidpiimagesrcsetintrinsicsizehtml"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/fast/hidpi/image-srcset-intrinsic-size.html (0 => 163415)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/fast/hidpi/image-srcset-intrinsic-size.html                                (rev 0)
+++ trunk/LayoutTests/fast/hidpi/image-srcset-intrinsic-size.html        2014-02-05 00:09:15 UTC (rev 163415)
</span><span class="lines">@@ -0,0 +1,33 @@
</span><ins>+&lt;html&gt;
+&lt;head&gt;
+&lt;script&gt;
+    window.targetScaleFactor = 2;
+    if (window.testRunner) {
+        testRunner.dumpAsText();
+    }
+&lt;/script&gt;
+&lt;script src=&quot;resources/srcset-helper.js&quot;&gt;&lt;/script&gt;
+&lt;script src=&quot;../../resources/js-test-pre.js&quot;&gt;&lt;/script&gt;
+&lt;script&gt;
+    addEventListener(&quot;load&quot;, function() {
+        shouldBeTrue('document.getElementById(&quot;foo&quot;).clientWidth==200');
+        shouldBeTrue('document.getElementById(&quot;foo2&quot;).clientWidth==400');
+        shouldBeTrue('document.getElementById(&quot;foo3&quot;).clientWidth==100');
+        shouldBeTrue('document.getElementById(&quot;foo4&quot;).clientWidth==200');
+    }, false);
+&lt;/script&gt;
+&lt;/head&gt;
+
+&lt;body id=&quot;body&quot;&gt;
+    &lt;div&gt;
+        This test passes if the images are all displayed with appropriate dimensions.
+    &lt;/div&gt;
+    &lt;img id=&quot;foo&quot; srcset=&quot;resources/green-400-px-square.png 2x&quot;&gt;
+    &lt;br&gt;
+    &lt;img id=&quot;foo2&quot; src=&quot;resources/green-400-px-square.png&quot;&gt;
+    &lt;br&gt;
+    &lt;img id=&quot;foo3&quot; srcset=&quot;resources/srcset.svg 2x&quot;&gt;
+    &lt;br&gt;
+    &lt;img id=&quot;foo4&quot; src=&quot;resources/srcset.svg&quot;&gt;
+&lt;/body&gt;
+&lt;/html&gt;
</ins></span></pre></div>
<a id="trunkLayoutTestsfasthidpiimagesrcsetinvalidinputscorrectsrcexpectedtxt"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/fast/hidpi/image-srcset-invalid-inputs-correct-src-expected.txt (163414 => 163415)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/fast/hidpi/image-srcset-invalid-inputs-correct-src-expected.txt        2014-02-05 00:08:40 UTC (rev 163414)
+++ trunk/LayoutTests/fast/hidpi/image-srcset-invalid-inputs-correct-src-expected.txt        2014-02-05 00:09:15 UTC (rev 163415)
</span><span class="lines">@@ -1,3 +1,3 @@
</span><del>-PASS document.getElementById(&quot;foo&quot;).clientWidth==200 is true
</del><ins>+PASS document.getElementById(&quot;foo&quot;).clientWidth==400 is true
</ins><span class="cx"> This test passes if this img tag below is a green square regardless of the scale factor. It ensures that invalid inputs from srcset are ignored, and src is selected (since it's the only candidate left)
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkLayoutTestsfasthidpiimagesrcsetinvalidinputscorrectsrchtml"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/fast/hidpi/image-srcset-invalid-inputs-correct-src.html (163414 => 163415)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/fast/hidpi/image-srcset-invalid-inputs-correct-src.html        2014-02-05 00:08:40 UTC (rev 163414)
+++ trunk/LayoutTests/fast/hidpi/image-srcset-invalid-inputs-correct-src.html        2014-02-05 00:09:15 UTC (rev 163415)
</span><span class="lines">@@ -8,7 +8,7 @@
</span><span class="cx">     }
</span><span class="cx"> 
</span><span class="cx">     addEventListener(&quot;load&quot;, function() {
</span><del>-        shouldBeTrue('document.getElementById(&quot;foo&quot;).clientWidth==200');
</del><ins>+        shouldBeTrue('document.getElementById(&quot;foo&quot;).clientWidth==400');
</ins><span class="cx">     }, false);
</span><span class="cx"> &lt;/script&gt;
</span><span class="cx"> &lt;/head&gt;
</span><span class="lines">@@ -16,6 +16,6 @@
</span><span class="cx"> &lt;body id=&quot;body&quot;&gt;
</span><span class="cx">     &lt;div&gt;This test passes if this img tag below is a green square regardless of the scale factor. It ensures that invalid inputs
</span><span class="cx">     from srcset are ignored, and src is selected (since it's the only candidate left)&lt;/div&gt;
</span><del>-    &lt;img id=&quot;foo&quot; src=&quot;resources/green-200-px-square.png&quot; srcset=&quot;1x,,  ,      , 2x ,,&quot;&gt;
</del><ins>+    &lt;img id=&quot;foo&quot; src=&quot;resources/green-400-px-square.png&quot; srcset=&quot;1x,,  ,      , 2x ,,&quot;&gt;
</ins><span class="cx"> &lt;/body&gt;
</span><span class="cx"> &lt;/html&gt;
</span></span></pre></div>
<a id="trunkLayoutTestsfasthidpiimagesrcsetinvalidinputsexceptonehtml"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/fast/hidpi/image-srcset-invalid-inputs-except-one.html (163414 => 163415)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/fast/hidpi/image-srcset-invalid-inputs-except-one.html        2014-02-05 00:08:40 UTC (rev 163414)
+++ trunk/LayoutTests/fast/hidpi/image-srcset-invalid-inputs-except-one.html        2014-02-05 00:09:15 UTC (rev 163415)
</span><span class="lines">@@ -16,6 +16,6 @@
</span><span class="cx"> &lt;body id=&quot;body&quot;&gt;
</span><span class="cx">     &lt;div&gt;This test passes if the img tag below is a green square regardless of the scale factor. It ensures that invalid inputs are
</span><span class="cx">     ignored and well-formed images are chosen regardless of their qualifiers, once they are the only candidate left&lt;/div&gt;
</span><del>-    &lt;img id=&quot;foo&quot; src=&quot;&quot; srcset=&quot;1x,,  ,   x    ,2x  , foo.jpg, 3x, bar.jpg 4x 100h, foo.jpg 5, bar.jpg dx, resources/green-200-px-square.png   2x ,&quot;&gt;&lt;/img&gt;
</del><ins>+    &lt;img id=&quot;foo&quot; src=&quot;&quot; srcset=&quot;1x,,  ,   x    ,2x  , foo.jpg, 3x, bar.jpg 4x 100h, foo.jpg 5, bar.jpg dx, resources/green-400-px-square.png   2x ,&quot;&gt;&lt;/img&gt;
</ins><span class="cx"> &lt;/body&gt;
</span><span class="cx"> &lt;/html&gt;
</span></span></pre></div>
<a id="trunkLayoutTestsfasthidpiimagesrcsetinvalidinputsexpectedtxt"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/fast/hidpi/image-srcset-invalid-inputs-expected.txt (0 => 163415)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/fast/hidpi/image-srcset-invalid-inputs-expected.txt                                (rev 0)
+++ trunk/LayoutTests/fast/hidpi/image-srcset-invalid-inputs-expected.txt        2014-02-05 00:09:15 UTC (rev 163415)
</span><span class="lines">@@ -0,0 +1,3 @@
</span><ins>+PASS did not load invalid inputs
+This test passes if this img tag below is empty and displays nothing. It ensures that the srcset attribute supports invalid inputs
+
</ins></span></pre></div>
<a id="trunkLayoutTestsfasthidpiimagesrcsetinvalidinputshtml"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/fast/hidpi/image-srcset-invalid-inputs.html (163414 => 163415)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/fast/hidpi/image-srcset-invalid-inputs.html        2014-02-05 00:08:40 UTC (rev 163414)
+++ trunk/LayoutTests/fast/hidpi/image-srcset-invalid-inputs.html        2014-02-05 00:09:15 UTC (rev 163415)
</span><span class="lines">@@ -1,10 +1,11 @@
</span><span class="cx"> &lt;html&gt;
</span><span class="cx"> &lt;head&gt;
</span><del>-&lt;script src=&quot;resources/srcset-helper.js&quot;&gt;&lt;/script&gt;
</del><ins>+&lt;script src=&quot;../../resources/js-test-pre.js&quot;&gt;&lt;/script&gt;
</ins><span class="cx"> &lt;/head&gt;
</span><span class="cx"> 
</span><span class="cx"> &lt;body id=&quot;body&quot;&gt;
</span><span class="cx">     &lt;div&gt;This test passes if this img tag below is empty and displays nothing. It ensures that the srcset attribute supports invalid inputs&lt;/div&gt;
</span><del>-    &lt;img height=&quot;100&quot; width=&quot;100&quot; src=&quot;&quot; srcset=&quot;1x,,  ,   x    ,2x  , foo.jpg, 3x, bar.jpg 4x 100h, foo.jpg 5, bar.jpg dx,foo.jpg,bar.jpg,&quot;&gt;&lt;/img&gt;
</del><ins>+    &lt;img id=&quot;foo&quot; src=&quot;&quot; srcset=&quot;1x,,  ,   x    ,2x  &quot; onerror=&quot;testPassed('did not load invalid inputs')&quot; onload=&quot;testFailed('Loaded
+    invalid inputs')&quot;&gt;&lt;/img&gt;
</ins><span class="cx"> &lt;/body&gt;
</span><span class="cx"> &lt;/html&gt;
</span></span></pre></div>
<a id="trunkLayoutTestsfasthidpiimagesrcsetonlysrcattributeexpectedtxt"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/fast/hidpi/image-srcset-only-src-attribute-expected.txt (0 => 163415)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/fast/hidpi/image-srcset-only-src-attribute-expected.txt                                (rev 0)
+++ trunk/LayoutTests/fast/hidpi/image-srcset-only-src-attribute-expected.txt        2014-02-05 00:09:15 UTC (rev 163415)
</span><span class="lines">@@ -0,0 +1,3 @@
</span><ins>+PASS document.getElementById(&quot;foo&quot;).clientWidth==200 is true
+This test passes if this img tag below is a green square when the scale factor is 2. It ensures that the selection algorithm does not change the behavior of the src attribute, even with a scale factor greater than 1
+
</ins></span></pre></div>
<a id="trunkLayoutTestsfasthidpiimagesrcsetonlysrcattributehtml"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/fast/hidpi/image-srcset-only-src-attribute.html (163414 => 163415)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/fast/hidpi/image-srcset-only-src-attribute.html        2014-02-05 00:08:40 UTC (rev 163414)
+++ trunk/LayoutTests/fast/hidpi/image-srcset-only-src-attribute.html        2014-02-05 00:09:15 UTC (rev 163415)
</span><span class="lines">@@ -1,10 +1,18 @@
</span><ins>+&lt;head&gt;
</ins><span class="cx"> &lt;html&gt;
</span><del>-&lt;head&gt;
</del><span class="cx"> &lt;script src=&quot;resources/srcset-helper.js&quot;&gt;&lt;/script&gt;
</span><ins>+&lt;script src=&quot;../../resources/js-test-pre.js&quot;&gt;&lt;/script&gt;
+&lt;script&gt;
+    if (window.testRunner) {
+        testRunner.dumpAsText();
+    }
+    addEventListener(&quot;load&quot;, function() {
+        shouldBeTrue('document.getElementById(&quot;foo&quot;).clientWidth==200');
+    }, false);
+&lt;/script&gt;
</ins><span class="cx"> &lt;/head&gt;
</span><del>-
</del><span class="cx"> &lt;body id=&quot;body&quot;&gt;
</span><span class="cx">     &lt;div&gt;This test passes if this img tag below is a green square when the scale factor is 2. It ensures that the selection algorithm does not change the behavior of the src attribute, even with a scale factor greater than 1&lt;/div&gt;
</span><del>-    &lt;img height=&quot;100&quot; width=&quot;100&quot; src=&quot;resources/green-200-px-square.png&quot;&gt;&lt;/img&gt;
</del><ins>+    &lt;img id=&quot;foo&quot; src=&quot;resources/green-200-px-square.png&quot;&gt;&lt;/img&gt;
</ins><span class="cx"> &lt;/body&gt;
</span><span class="cx"> &lt;/html&gt;
</span></span></pre></div>
<a id="trunkLayoutTestsfasthidpiimagesrcsetpngcanvasexpectedhtml"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/fast/hidpi/image-srcset-png-canvas-expected.html (0 => 163415)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/fast/hidpi/image-srcset-png-canvas-expected.html                                (rev 0)
+++ trunk/LayoutTests/fast/hidpi/image-srcset-png-canvas-expected.html        2014-02-05 00:09:15 UTC (rev 163415)
</span><span class="lines">@@ -0,0 +1,44 @@
</span><ins>+&lt;!DOCTYPE HTML&gt;
+&lt;html&gt;
+&lt;head&gt;
+    &lt;link rel=&quot;stylesheet&quot; href=&quot;resources/svg_tests.css&quot;&gt;
+    &lt;script src=&quot;resources/svg_canvas_helper.js&quot;&gt;&lt;/script&gt;
+    &lt;script&gt;
+        if (window.testRunner)
+            testRunner.waitUntilDone();
+    &lt;/script&gt;
+&lt;/head&gt;
+&lt;body&gt;
+  &lt;h2&gt;&lt;a href=&quot;http://www.w3.org/html/wg/drafts/srcset/w3c-srcset&quot;&gt;srcset&lt;/a&gt; testcases for SVG&lt;/h2&gt;
+  &lt;div class=&quot;test&quot;&gt;
+    &lt;h3&gt;Canvas PNG without explicit dimensions - 1x&lt;/h3&gt;
+    &lt;div class=&quot;expected&quot;&gt;expected&lt;br/&gt;
+      &lt;img id=&quot;png5&quot; src=&quot;&quot; srcset=&quot;resources/srcset.png&quot; width=&quot;200&quot; height=&quot;100&quot;&gt;
+    &lt;/div&gt;
+    &lt;div class=&quot;actual&quot;&gt;actual&lt;br/&gt;
+      &lt;canvas id=&quot;canvas3&quot;&gt;&lt;/canvas&gt;
+    &lt;/div&gt;
+    This test should show a PNG image drawn into a canvas. The canvas and image should look the same and both should be 200x100.&lt;br/&gt;
+    &lt;br clear=&quot;all&quot;/&gt;
+  &lt;/div&gt;
+  &lt;div class=&quot;test&quot;&gt;
+    &lt;h3&gt;Canvas PNG without explicit dimensions - 2x&lt;/h3&gt;
+    &lt;div class=&quot;expected&quot;&gt;expected&lt;br/&gt;
+      &lt;img id=&quot;png6&quot; src=&quot;&quot; srcset=&quot;resources/srcset.png&quot; width=&quot;100&quot; height=&quot;50&quot;&gt;
+    &lt;/div&gt;
+    &lt;div class=&quot;actual&quot;&gt;actual&lt;br/&gt;
+      &lt;canvas id=&quot;canvas4&quot;&gt;&lt;/canvas&gt;
+    &lt;/div&gt;
+    This test should show an SVG image drawn into a canvas. The canvas and image should look the same and both should be 100x50.&lt;br/&gt;
+    &lt;br clear=&quot;all&quot;/&gt;
+  &lt;/div&gt;
+  &lt;script&gt;
+    window.addEventListener('load', function(){
+        drawCanvas('png5', 'canvas3', 200, 100);
+        drawCanvas('png6', 'canvas4', 100, 50);
+        if (window.testRunner)
+            testRunner.notifyDone();
+    });
+  &lt;/script&gt;
+&lt;/body&gt;
+&lt;/html&gt;
</ins></span></pre></div>
<a id="trunkLayoutTestsfasthidpiimagesrcsetpngcanvashtml"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/fast/hidpi/image-srcset-png-canvas.html (0 => 163415)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/fast/hidpi/image-srcset-png-canvas.html                                (rev 0)
+++ trunk/LayoutTests/fast/hidpi/image-srcset-png-canvas.html        2014-02-05 00:09:15 UTC (rev 163415)
</span><span class="lines">@@ -0,0 +1,44 @@
</span><ins>+&lt;!DOCTYPE HTML&gt;
+&lt;html&gt;
+&lt;head&gt;
+    &lt;link rel=&quot;stylesheet&quot; href=&quot;resources/svg_tests.css&quot;&gt;
+    &lt;script src=&quot;resources/svg_canvas_helper.js&quot;&gt;&lt;/script&gt;
+    &lt;script&gt;
+        if (window.testRunner)
+            testRunner.waitUntilDone();
+    &lt;/script&gt;
+&lt;/head&gt;
+&lt;body&gt;
+  &lt;h2&gt;&lt;a href=&quot;http://www.w3.org/html/wg/drafts/srcset/w3c-srcset&quot;&gt;srcset&lt;/a&gt; testcases for SVG&lt;/h2&gt;
+  &lt;div class=&quot;test&quot;&gt;
+    &lt;h3&gt;Canvas PNG without explicit dimensions - 1x&lt;/h3&gt;
+    &lt;div class=&quot;expected&quot;&gt;expected&lt;br/&gt;
+      &lt;img id=&quot;png5&quot; src=&quot;&quot; srcset=&quot;resources/srcset.png&quot;&gt;
+    &lt;/div&gt;
+    &lt;div class=&quot;actual&quot;&gt;actual&lt;br/&gt;
+      &lt;canvas id=&quot;canvas3&quot;&gt;&lt;/canvas&gt;
+    &lt;/div&gt;
+    This test should show a PNG image drawn into a canvas. The canvas and image should look the same and both should be 200x100.&lt;br/&gt;
+    &lt;br clear=&quot;all&quot;/&gt;
+  &lt;/div&gt;
+  &lt;div class=&quot;test&quot;&gt;
+    &lt;h3&gt;Canvas PNG without explicit dimensions - 2x&lt;/h3&gt;
+    &lt;div class=&quot;expected&quot;&gt;expected&lt;br/&gt;
+      &lt;img id=&quot;png6&quot; src=&quot;&quot; srcset=&quot;resources/srcset.png 2x&quot;&gt;
+    &lt;/div&gt;
+    &lt;div class=&quot;actual&quot;&gt;actual&lt;br/&gt;
+      &lt;canvas id=&quot;canvas4&quot;&gt;&lt;/canvas&gt;
+    &lt;/div&gt;
+    This test should show an SVG image drawn into a canvas. The canvas and image should look the same and both should be 100x50.&lt;br/&gt;
+    &lt;br clear=&quot;all&quot;/&gt;
+  &lt;/div&gt;
+  &lt;script&gt;
+    window.addEventListener('load', function(){
+        drawCanvas('png5', 'canvas3', 200, 100);
+        drawCanvas('png6', 'canvas4', 100, 50);
+        if (window.testRunner)
+            testRunner.notifyDone();
+    });
+  &lt;/script&gt;
+&lt;/body&gt;
+&lt;/html&gt;
</ins></span></pre></div>
<a id="trunkLayoutTestsfasthidpiimagesrcsetpngexpectedhtml"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/fast/hidpi/image-srcset-png-expected.html (0 => 163415)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/fast/hidpi/image-srcset-png-expected.html                                (rev 0)
+++ trunk/LayoutTests/fast/hidpi/image-srcset-png-expected.html        2014-02-05 00:09:15 UTC (rev 163415)
</span><span class="lines">@@ -0,0 +1,59 @@
</span><ins>+&lt;!DOCTYPE HTML&gt;
+&lt;html&gt;
+&lt;head&gt;
+    &lt;link rel=&quot;stylesheet&quot; href=&quot;resources/svg_tests.css&quot;&gt;
+&lt;/head&gt;
+&lt;body&gt;
+  &lt;h2&gt;&lt;a href=&quot;http://www.w3.org/html/wg/drafts/srcset/w3c-srcset&quot;&gt;srcset&lt;/a&gt; testcases for SVG&lt;/h2&gt;
+  &lt;div class=&quot;test&quot;&gt;
+    &lt;h3&gt;PNG without explicit dimensions - 1x&lt;/h3&gt;
+    &lt;div class=&quot;expected&quot;&gt;expected&lt;br/&gt;
+      &lt;img src=&quot;resources/srcset.png&quot; width=&quot;200&quot; height=&quot;100&quot;&gt;
+    &lt;/div&gt;
+    &lt;div class=&quot;actual&quot;&gt;actual&lt;br/&gt;
+      &lt;img src=&quot;resources/srcset.png&quot; width=&quot;200&quot; height=&quot;100&quot;&gt;
+    &lt;/div&gt;
+    This test should show a PNG image of size 200x100, and intrinsic/natural size 200x100. The left half of the image should be red and there should be a black circle in the center.&lt;br/&gt;
+    &lt;code class=&quot;stats&quot; id=&quot;code5&quot;&gt;&lt;/code&gt;
+    &lt;br clear=&quot;all&quot;/&gt;
+  &lt;/div&gt;
+  &lt;div class=&quot;test&quot;&gt;
+    &lt;h3&gt;PNG with explicit dimensions - 1x&lt;/h3&gt;
+    &lt;div class=&quot;expected&quot;&gt;expected&lt;br/&gt;
+      &lt;img src=&quot;resources/srcset.png&quot; width=&quot;100&quot; height=&quot;50&quot;&gt;
+    &lt;/div&gt;
+    &lt;div class=&quot;actual&quot;&gt;actual&lt;br/&gt;
+      &lt;img src=&quot;resources/srcset.png&quot; width=&quot;100&quot; height=&quot;50&quot;&gt;
+    &lt;/div&gt;
+    This test should show a PNG image of size 100x50, and intrinsic/natural size 100x50. The left half of the image should be red and there should be a black circle in the center.&lt;br/&gt;
+    &lt;code class=&quot;stats&quot; id=&quot;code6&quot;&gt;&lt;/code&gt;
+    &lt;br clear=&quot;all&quot;/&gt;
+  &lt;/div&gt;
+  &lt;div class=&quot;test&quot;&gt;
+    &lt;h3&gt;PNG without explicit dimensions - 2x&lt;/h3&gt;
+    &lt;div class=&quot;expected&quot;&gt;expected&lt;br/&gt;
+      &lt;img src=&quot;resources/srcset.png&quot; width=&quot;100&quot; height=&quot;50&quot;&gt;
+    &lt;/div&gt;
+    &lt;div class=&quot;actual&quot;&gt;actual&lt;br/&gt;
+      &lt;img src=&quot;resources/srcset.png&quot; width=&quot;100&quot; height=&quot;50&quot;&gt;
+    &lt;/div&gt;
+    This test should show a PNG image of size 100x50, and intrinsic/natural size 100x50. The left half of the image should be red and there should be a black circle in the center.&lt;br/&gt;
+    &lt;code class=&quot;stats&quot; id=&quot;code7&quot;&gt;&lt;/code&gt;
+    &lt;br clear=&quot;all&quot;/&gt;
+  &lt;/div&gt;
+  &lt;div class=&quot;test&quot;&gt;
+    &lt;h3&gt;PNG with explicit dimensions - 4x&lt;/h3&gt;
+    &lt;div class=&quot;expected&quot;&gt;expected&lt;br/&gt;
+      &lt;img src=&quot;resources/srcset.png&quot; width=&quot;100&quot; height=&quot;50&quot;&gt;
+    &lt;/div&gt;
+    &lt;div class=&quot;actual&quot;&gt;actual&lt;br/&gt;
+      &lt;img src=&quot;resources/srcset.png&quot; width=&quot;100&quot; height=&quot;50&quot;&gt;
+    &lt;/div&gt;
+    This test should show a PNG image of size 100x50, and intrinsic/natural size 50x25. The left half of the image should be red and there should be a black circle in the center.&lt;br/&gt;
+    &lt;code class=&quot;stats&quot; id=&quot;code8&quot;&gt;&lt;/code&gt;
+    &lt;br clear=&quot;all&quot;/&gt;
+  &lt;/div&gt;
+
+
+&lt;/body&gt;
+&lt;/html&gt;
</ins></span></pre></div>
<a id="trunkLayoutTestsfasthidpiimagesrcsetpnghtml"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/fast/hidpi/image-srcset-png.html (0 => 163415)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/fast/hidpi/image-srcset-png.html                                (rev 0)
+++ trunk/LayoutTests/fast/hidpi/image-srcset-png.html        2014-02-05 00:09:15 UTC (rev 163415)
</span><span class="lines">@@ -0,0 +1,59 @@
</span><ins>+&lt;!DOCTYPE HTML&gt;
+&lt;html&gt;
+&lt;head&gt;
+    &lt;link rel=&quot;stylesheet&quot; href=&quot;resources/svg_tests.css&quot;&gt;
+&lt;/head&gt;
+&lt;body&gt;
+  &lt;h2&gt;&lt;a href=&quot;http://www.w3.org/html/wg/drafts/srcset/w3c-srcset&quot;&gt;srcset&lt;/a&gt; testcases for SVG&lt;/h2&gt;
+  &lt;div class=&quot;test&quot;&gt;
+    &lt;h3&gt;PNG without explicit dimensions - 1x&lt;/h3&gt;
+    &lt;div class=&quot;expected&quot;&gt;expected&lt;br/&gt;
+      &lt;img src=&quot;resources/srcset.png&quot; width=&quot;200&quot; height=&quot;100&quot;&gt;
+    &lt;/div&gt;
+    &lt;div class=&quot;actual&quot;&gt;actual&lt;br/&gt;
+      &lt;img id=&quot;png1&quot; src=&quot;resources/srcset.png&quot;&gt;
+    &lt;/div&gt;
+    This test should show a PNG image of size 200x100, and intrinsic/natural size 200x100. The left half of the image should be red and there should be a black circle in the center.&lt;br/&gt;
+    &lt;code class=&quot;stats&quot; id=&quot;code5&quot;&gt;&lt;/code&gt;
+    &lt;br clear=&quot;all&quot;/&gt;
+  &lt;/div&gt;
+  &lt;div class=&quot;test&quot;&gt;
+    &lt;h3&gt;PNG with explicit dimensions - 1x&lt;/h3&gt;
+    &lt;div class=&quot;expected&quot;&gt;expected&lt;br/&gt;
+      &lt;img src=&quot;resources/srcset.png&quot; width=&quot;100&quot; height=&quot;50&quot;&gt;
+    &lt;/div&gt;
+    &lt;div class=&quot;actual&quot;&gt;actual&lt;br/&gt;
+      &lt;img id=&quot;png2&quot; src=&quot;resources/srcset.png&quot; width=&quot;100&quot; height=&quot;50&quot;&gt;
+    &lt;/div&gt;
+    This test should show a PNG image of size 100x50, and intrinsic/natural size 100x50. The left half of the image should be red and there should be a black circle in the center.&lt;br/&gt;
+    &lt;code class=&quot;stats&quot; id=&quot;code6&quot;&gt;&lt;/code&gt;
+    &lt;br clear=&quot;all&quot;/&gt;
+  &lt;/div&gt;
+  &lt;div class=&quot;test&quot;&gt;
+    &lt;h3&gt;PNG without explicit dimensions - 2x&lt;/h3&gt;
+    &lt;div class=&quot;expected&quot;&gt;expected&lt;br/&gt;
+      &lt;img src=&quot;resources/srcset.png&quot; width=&quot;100&quot; height=&quot;50&quot;&gt;
+    &lt;/div&gt;
+    &lt;div class=&quot;actual&quot;&gt;actual&lt;br/&gt;
+      &lt;img id=&quot;png3&quot; src=&quot;&quot; srcset=&quot;resources/srcset.png 2x&quot;&gt;
+    &lt;/div&gt;
+    This test should show a PNG image of size 100x50, and intrinsic/natural size 100x50. The left half of the image should be red and there should be a black circle in the center.&lt;br/&gt;
+    &lt;code class=&quot;stats&quot; id=&quot;code7&quot;&gt;&lt;/code&gt;
+    &lt;br clear=&quot;all&quot;/&gt;
+  &lt;/div&gt;
+  &lt;div class=&quot;test&quot;&gt;
+    &lt;h3&gt;PNG with explicit dimensions - 4x&lt;/h3&gt;
+    &lt;div class=&quot;expected&quot;&gt;expected&lt;br/&gt;
+      &lt;img src=&quot;resources/srcset.png&quot; width=&quot;100&quot; height=&quot;50&quot;&gt;
+    &lt;/div&gt;
+    &lt;div class=&quot;actual&quot;&gt;actual&lt;br/&gt;
+      &lt;img id=&quot;png4&quot; src=&quot;&quot; srcset=&quot;resources/srcset.png 4x&quot; width=&quot;100&quot; height=&quot;50&quot;&gt;
+    &lt;/div&gt;
+    This test should show a PNG image of size 100x50, and intrinsic/natural size 50x25. The left half of the image should be red and there should be a black circle in the center.&lt;br/&gt;
+    &lt;code class=&quot;stats&quot; id=&quot;code8&quot;&gt;&lt;/code&gt;
+    &lt;br clear=&quot;all&quot;/&gt;
+  &lt;/div&gt;
+
+
+&lt;/body&gt;
+&lt;/html&gt;
</ins></span></pre></div>
<a id="trunkLayoutTestsfasthidpiimagesrcsetrelativesvgcanvas2xexpectedhtml"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/fast/hidpi/image-srcset-relative-svg-canvas-2x-expected.html (0 => 163415)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/fast/hidpi/image-srcset-relative-svg-canvas-2x-expected.html                                (rev 0)
+++ trunk/LayoutTests/fast/hidpi/image-srcset-relative-svg-canvas-2x-expected.html        2014-02-05 00:09:15 UTC (rev 163415)
</span><span class="lines">@@ -0,0 +1,33 @@
</span><ins>+&lt;!DOCTYPE HTML&gt;
+&lt;html&gt;
+&lt;head&gt;
+    &lt;link rel=&quot;stylesheet&quot; href=&quot;resources/svg_tests.css&quot;&gt;
+    &lt;script src=&quot;resources/svg_canvas_helper.js&quot;&gt;&lt;/script&gt;
+    &lt;script&gt;
+        if (window.testRunner)
+            testRunner.waitUntilDone();
+    &lt;/script&gt;
+&lt;/head&gt;
+&lt;body&gt;
+  &lt;h2&gt;&lt;a href=&quot;http://www.w3.org/html/wg/drafts/srcset/w3c-srcset&quot;&gt;srcset&lt;/a&gt; testcases for SVG&lt;/h2&gt;
+  &lt;div class=&quot;test&quot;&gt;
+    &lt;h3&gt;Canvas relative SVG with explicit dimensions - 2x&lt;/h3&gt;
+    &lt;div class=&quot;expected&quot;&gt;expected&lt;br/&gt;
+      &lt;img id=&quot;svg10&quot; src=&quot;resources/relativesrcset.svg&quot; width=&quot;100&quot; height=&quot;50&quot;&gt;
+    &lt;/div&gt;
+    &lt;div class=&quot;actual&quot;&gt;actual&lt;br/&gt;
+      &lt;canvas id=&quot;canvas6&quot;&gt;&lt;/canvas&gt;
+    &lt;/div&gt;
+    This test should show an SVG image drawn into a canvas. The canvas and image should look the same and both should be 100x50.&lt;br/&gt;
+    &lt;br clear=&quot;all&quot;/&gt;
+  &lt;/div&gt;
+  &lt;script&gt;
+    window.addEventListener('load', function(){
+        drawCanvas('svg10', 'canvas6', 100, 50);
+        if (window.testRunner)
+            testRunner.notifyDone();
+    });
+  &lt;/script&gt;
+
+&lt;/body&gt;
+&lt;/html&gt;
</ins></span></pre></div>
<a id="trunkLayoutTestsfasthidpiimagesrcsetrelativesvgcanvas2xhtml"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/fast/hidpi/image-srcset-relative-svg-canvas-2x.html (0 => 163415)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/fast/hidpi/image-srcset-relative-svg-canvas-2x.html                                (rev 0)
+++ trunk/LayoutTests/fast/hidpi/image-srcset-relative-svg-canvas-2x.html        2014-02-05 00:09:15 UTC (rev 163415)
</span><span class="lines">@@ -0,0 +1,34 @@
</span><ins>+&lt;!DOCTYPE HTML&gt;
+&lt;html&gt;
+&lt;head&gt;
+    &lt;link rel=&quot;stylesheet&quot; href=&quot;resources/svg_tests.css&quot;&gt;
+    &lt;script src=&quot;resources/svg_canvas_helper.js&quot;&gt;&lt;/script&gt;
+    &lt;script&gt;
+        if (window.testRunner)
+            testRunner.waitUntilDone();
+    &lt;/script&gt;
+&lt;/head&gt;
+&lt;body&gt;
+  &lt;h2&gt;&lt;a href=&quot;http://www.w3.org/html/wg/drafts/srcset/w3c-srcset&quot;&gt;srcset&lt;/a&gt; testcases for SVG&lt;/h2&gt;
+  &lt;div class=&quot;test&quot;&gt;
+    &lt;h3&gt;Canvas relative SVG with explicit dimensions - 2x&lt;/h3&gt;
+    &lt;div class=&quot;expected&quot;&gt;expected&lt;br/&gt;
+      &lt;img id=&quot;svg10&quot; src=&quot;&quot; srcset=&quot;resources/relativesrcset.svg 2x&quot; width=&quot;100&quot; height=&quot;50&quot;&gt;
+    &lt;/div&gt;
+    &lt;div class=&quot;actual&quot;&gt;actual&lt;br/&gt;
+      &lt;canvas id=&quot;canvas6&quot;&gt;&lt;/canvas&gt;
+    &lt;/div&gt;
+    This test should show an SVG image drawn into a canvas. The canvas and image should look the same and both should be 100x50.&lt;br/&gt;
+    &lt;code class=&quot;stats&quot; id=&quot;code16&quot;&gt;&lt;/code&gt;
+    &lt;br clear=&quot;all&quot;/&gt;
+  &lt;/div&gt;
+  &lt;script&gt;
+    window.addEventListener('load', function(){
+        drawCanvas('svg10', 'canvas6', 100, 50);
+        if (window.testRunner)
+            testRunner.notifyDone();
+    });
+  &lt;/script&gt;
+
+&lt;/body&gt;
+&lt;/html&gt;
</ins></span></pre></div>
<a id="trunkLayoutTestsfasthidpiimagesrcsetrelativesvgcanvasexpectedhtml"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/fast/hidpi/image-srcset-relative-svg-canvas-expected.html (0 => 163415)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/fast/hidpi/image-srcset-relative-svg-canvas-expected.html                                (rev 0)
+++ trunk/LayoutTests/fast/hidpi/image-srcset-relative-svg-canvas-expected.html        2014-02-05 00:09:15 UTC (rev 163415)
</span><span class="lines">@@ -0,0 +1,33 @@
</span><ins>+&lt;!DOCTYPE HTML&gt;
+&lt;html&gt;
+&lt;head&gt;
+    &lt;link rel=&quot;stylesheet&quot; href=&quot;resources/svg_tests.css&quot;&gt;
+    &lt;script src=&quot;resources/svg_canvas_helper.js&quot;&gt;&lt;/script&gt;
+    &lt;script&gt;
+        if (window.testRunner)
+            testRunner.waitUntilDone();
+    &lt;/script&gt;
+&lt;/head&gt;
+&lt;body&gt;
+  &lt;h2&gt;&lt;a href=&quot;http://www.w3.org/html/wg/drafts/srcset/w3c-srcset&quot;&gt;srcset&lt;/a&gt; testcases for SVG&lt;/h2&gt;
+  &lt;div class=&quot;test&quot;&gt;
+    &lt;h3&gt;Canvas relative SVG with explicit dimensions - 1x&lt;/h3&gt;
+    &lt;div class=&quot;expected&quot;&gt;expected&lt;br/&gt;
+      &lt;img id=&quot;svg10&quot; src=&quot;resources/relativesrcset.svg&quot; width=&quot;100&quot; height=&quot;50&quot;&gt;
+    &lt;/div&gt;
+    &lt;div class=&quot;actual&quot;&gt;actual&lt;br/&gt;
+      &lt;canvas id=&quot;canvas6&quot;&gt;&lt;/canvas&gt;
+    &lt;/div&gt;
+    This test should show an SVG image drawn into a canvas. The canvas and image should look the same and both should be 100x50.&lt;br/&gt;
+    &lt;br clear=&quot;all&quot;/&gt;
+  &lt;/div&gt;
+  &lt;script&gt;
+    window.addEventListener('load', function(){
+        drawCanvas('svg10', 'canvas6', 100, 50);
+        if (window.testRunner)
+            testRunner.notifyDone();
+    });
+  &lt;/script&gt;
+
+&lt;/body&gt;
+&lt;/html&gt;
</ins></span></pre></div>
<a id="trunkLayoutTestsfasthidpiimagesrcsetrelativesvgcanvashtml"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/fast/hidpi/image-srcset-relative-svg-canvas.html (0 => 163415)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/fast/hidpi/image-srcset-relative-svg-canvas.html                                (rev 0)
+++ trunk/LayoutTests/fast/hidpi/image-srcset-relative-svg-canvas.html        2014-02-05 00:09:15 UTC (rev 163415)
</span><span class="lines">@@ -0,0 +1,34 @@
</span><ins>+&lt;!DOCTYPE HTML&gt;
+&lt;html&gt;
+&lt;head&gt;
+    &lt;link rel=&quot;stylesheet&quot; href=&quot;resources/svg_tests.css&quot;&gt;
+    &lt;script src=&quot;resources/svg_canvas_helper.js&quot;&gt;&lt;/script&gt;
+    &lt;script&gt;
+        if (window.testRunner)
+            testRunner.waitUntilDone();
+    &lt;/script&gt;
+&lt;/head&gt;
+&lt;body&gt;
+  &lt;h2&gt;&lt;a href=&quot;http://www.w3.org/html/wg/drafts/srcset/w3c-srcset&quot;&gt;srcset&lt;/a&gt; testcases for SVG&lt;/h2&gt;
+  &lt;div class=&quot;test&quot;&gt;
+    &lt;h3&gt;Canvas relative SVG with explicit dimensions - 1x&lt;/h3&gt;
+    &lt;div class=&quot;expected&quot;&gt;expected&lt;br/&gt;
+      &lt;img id=&quot;svg10&quot; src=&quot;resources/relativesrcset.svg&quot; width=&quot;100&quot; height=&quot;50&quot;&gt;
+    &lt;/div&gt;
+    &lt;div class=&quot;actual&quot;&gt;actual&lt;br/&gt;
+      &lt;canvas id=&quot;canvas6&quot;&gt;&lt;/canvas&gt;
+    &lt;/div&gt;
+    This test should show an SVG image drawn into a canvas. The canvas and image should look the same and both should be 100x50.&lt;br/&gt;
+    &lt;code class=&quot;stats&quot; id=&quot;code16&quot;&gt;&lt;/code&gt;
+    &lt;br clear=&quot;all&quot;/&gt;
+  &lt;/div&gt;
+  &lt;script&gt;
+    window.addEventListener('load', function(){
+        drawCanvas('svg10', 'canvas6', 100, 50);
+        if (window.testRunner)
+            testRunner.notifyDone();
+    });
+  &lt;/script&gt;
+
+&lt;/body&gt;
+&lt;/html&gt;
</ins></span></pre></div>
<a id="trunkLayoutTestsfasthidpiimagesrcsetrelativesvgexpectedhtml"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/fast/hidpi/image-srcset-relative-svg-expected.html (0 => 163415)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/fast/hidpi/image-srcset-relative-svg-expected.html                                (rev 0)
+++ trunk/LayoutTests/fast/hidpi/image-srcset-relative-svg-expected.html        2014-02-05 00:09:15 UTC (rev 163415)
</span><span class="lines">@@ -0,0 +1,32 @@
</span><ins>+&lt;!DOCTYPE HTML&gt;
+&lt;html&gt;
+&lt;head&gt;
+    &lt;link rel=&quot;stylesheet&quot; href=&quot;resources/svg_tests.css&quot;&gt;
+&lt;/head&gt;
+&lt;body&gt;
+  &lt;h2&gt;&lt;a href=&quot;http://www.w3.org/html/wg/drafts/srcset/w3c-srcset&quot;&gt;srcset&lt;/a&gt; testcases for SVG&lt;/h2&gt;
+  &lt;div class=&quot;test&quot;&gt;
+    &lt;h3&gt;Relative SVG with explicit dimensions - 1x&lt;/h3&gt;
+    &lt;div class=&quot;expected&quot;&gt;expected&lt;br/&gt;
+      &lt;img src=&quot;resources/relativesrcset.svg&quot; width=&quot;100&quot; height=&quot;50&quot;&gt;
+    &lt;/div&gt;
+    &lt;div class=&quot;actual&quot;&gt;actual&lt;br/&gt;
+      &lt;img id=&quot;svg5&quot; src=&quot;resources/relativesrcset.svg&quot; width=&quot;100&quot; height=&quot;50&quot;&gt;
+    &lt;/div&gt;
+    This test should show an SVG image of size 100x50, and intrinsic/natural size 100x50.The left half of the image should be pink and there should be a purple circle in the center.&lt;br/&gt;
+    &lt;br clear=&quot;all&quot;/&gt;
+  &lt;/div&gt;
+  &lt;div class=&quot;test&quot;&gt;
+    &lt;h3&gt;Relative SVG with explicit dimensions - 4x&lt;/h3&gt;
+    &lt;div class=&quot;expected&quot;&gt;expected&lt;br/&gt;
+      &lt;img src=&quot;resources/relativesrcset.svg&quot; width=&quot;100&quot; height=&quot;50&quot;&gt;
+    &lt;/div&gt;
+    &lt;div class=&quot;actual&quot;&gt;actual&lt;br/&gt;
+      &lt;img src=&quot;resources/relativesrcset.svg&quot; width=&quot;100&quot; height=&quot;50&quot;&gt;
+    &lt;/div&gt;
+    This test should show an SVG image of size 100x50, and intrinsic/natural size 50x25. The left half of the image should be pink and there should be a purple circle in the center.&lt;br/&gt;
+    &lt;br clear=&quot;all&quot;/&gt;
+  &lt;/div&gt;
+
+&lt;/body&gt;
+&lt;/html&gt;
</ins></span></pre></div>
<a id="trunkLayoutTestsfasthidpiimagesrcsetrelativesvghtml"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/fast/hidpi/image-srcset-relative-svg.html (0 => 163415)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/fast/hidpi/image-srcset-relative-svg.html                                (rev 0)
+++ trunk/LayoutTests/fast/hidpi/image-srcset-relative-svg.html        2014-02-05 00:09:15 UTC (rev 163415)
</span><span class="lines">@@ -0,0 +1,32 @@
</span><ins>+&lt;!DOCTYPE HTML&gt;
+&lt;html&gt;
+&lt;head&gt;
+    &lt;link rel=&quot;stylesheet&quot; href=&quot;resources/svg_tests.css&quot;&gt;
+&lt;/head&gt;
+&lt;body&gt;
+  &lt;h2&gt;&lt;a href=&quot;http://www.w3.org/html/wg/drafts/srcset/w3c-srcset&quot;&gt;srcset&lt;/a&gt; testcases for SVG&lt;/h2&gt;
+  &lt;div class=&quot;test&quot;&gt;
+    &lt;h3&gt;Relative SVG with explicit dimensions - 1x&lt;/h3&gt;
+    &lt;div class=&quot;expected&quot;&gt;expected&lt;br/&gt;
+      &lt;img src=&quot;resources/relativesrcset.svg&quot; width=&quot;100&quot; height=&quot;50&quot;&gt;
+    &lt;/div&gt;
+    &lt;div class=&quot;actual&quot;&gt;actual&lt;br/&gt;
+      &lt;img id=&quot;svg5&quot; src=&quot;resources/relativesrcset.svg&quot; width=&quot;100&quot; height=&quot;50&quot;&gt;
+    &lt;/div&gt;
+    This test should show an SVG image of size 100x50, and intrinsic/natural size 100x50.The left half of the image should be pink and there should be a purple circle in the center.&lt;br/&gt;
+    &lt;br clear=&quot;all&quot;/&gt;
+  &lt;/div&gt;
+  &lt;div class=&quot;test&quot;&gt;
+    &lt;h3&gt;Relative SVG with explicit dimensions - 4x&lt;/h3&gt;
+    &lt;div class=&quot;expected&quot;&gt;expected&lt;br/&gt;
+      &lt;img src=&quot;resources/relativesrcset.svg&quot; width=&quot;100&quot; height=&quot;50&quot;&gt;
+    &lt;/div&gt;
+    &lt;div class=&quot;actual&quot;&gt;actual&lt;br/&gt;
+      &lt;img id=&quot;svg6&quot; src=&quot;&quot; srcset=&quot;resources/relativesrcset.svg 4x&quot; width=&quot;100&quot; height=&quot;50&quot;&gt;
+    &lt;/div&gt;
+    This test should show an SVG image of size 100x50, and intrinsic/natural size 50x25. The left half of the image should be pink and there should be a purple circle in the center.&lt;br/&gt;
+    &lt;br clear=&quot;all&quot;/&gt;
+  &lt;/div&gt;
+
+&lt;/body&gt;
+&lt;/html&gt;
</ins></span></pre></div>
<a id="trunkLayoutTestsfasthidpiimagesrcsetremovedynamicallyfromjshtml"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/fast/hidpi/image-srcset-remove-dynamically-from-js.html (163414 => 163415)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/fast/hidpi/image-srcset-remove-dynamically-from-js.html        2014-02-05 00:08:40 UTC (rev 163414)
+++ trunk/LayoutTests/fast/hidpi/image-srcset-remove-dynamically-from-js.html        2014-02-05 00:09:15 UTC (rev 163415)
</span><span class="lines">@@ -26,6 +26,6 @@
</span><span class="cx"> &lt;/head&gt;
</span><span class="cx"> &lt;body id=&quot;body&quot;&gt;
</span><span class="cx">     &lt;div&gt;This test passes if this img tag below is a green square. It ensures that attributes can be removed dynamically from javascript&lt;/div&gt;
</span><del>-    &lt;img id=&quot;foo&quot; src=&quot;resources/blue-100-px-square.png&quot; srcset=&quot;resources/green-200-px-square.png 2x&quot;&gt;
</del><ins>+    &lt;img id=&quot;foo&quot; src=&quot;resources/blue-100-px-square.png&quot; srcset=&quot;resources/green-400-px-square.png 2x&quot;&gt;
</ins><span class="cx"> &lt;/body&gt;
</span><span class="cx"> &lt;/html&gt;
</span></span></pre></div>
<a id="trunkLayoutTestsfasthidpiimagesrcsetsimple2xexpectedtxt"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/fast/hidpi/image-srcset-simple-2x-expected.txt (163414 => 163415)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/fast/hidpi/image-srcset-simple-2x-expected.txt        2014-02-05 00:08:40 UTC (rev 163414)
+++ trunk/LayoutTests/fast/hidpi/image-srcset-simple-2x-expected.txt        2014-02-05 00:09:15 UTC (rev 163415)
</span><span class="lines">@@ -1,3 +1,3 @@
</span><del>-PASS document.getElementById(&quot;foo&quot;).clientWidth==800 is true
</del><ins>+PASS document.getElementById(&quot;foo&quot;).clientWidth==200 is true
</ins><span class="cx"> This test passes if the image below says 1x with a reddish background when the deviceScaleFactor is 1, and if says 2x with a greenish background when the deviceScaleFactor is 2.
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkLayoutTestsfasthidpiimagesrcsetsimple2xhtml"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/fast/hidpi/image-srcset-simple-2x.html (163414 => 163415)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/fast/hidpi/image-srcset-simple-2x.html        2014-02-05 00:08:40 UTC (rev 163414)
+++ trunk/LayoutTests/fast/hidpi/image-srcset-simple-2x.html        2014-02-05 00:09:15 UTC (rev 163415)
</span><span class="lines">@@ -6,18 +6,14 @@
</span><span class="cx"> &lt;script src=&quot;resources/srcset-helper.js&quot;&gt;&lt;/script&gt;
</span><span class="cx"> &lt;script src=&quot;../../resources/js-test-pre.js&quot;&gt;&lt;/script&gt;
</span><span class="cx"> &lt;script&gt;
</span><del>-    if (window.testRunner) {
-        testRunner.dumpAsText();
-    }
-
</del><span class="cx">     addEventListener(&quot;load&quot;, function() {
</span><del>-        shouldBeTrue('document.getElementById(&quot;foo&quot;).clientWidth==800');
</del><ins>+        shouldBeTrue('document.getElementById(&quot;foo&quot;).clientWidth==200');
</ins><span class="cx">     }, false);
</span><span class="cx"> &lt;/script&gt;
</span><span class="cx"> &lt;/head&gt;
</span><span class="cx"> 
</span><span class="cx"> &lt;body id=&quot;body&quot;&gt;
</span><span class="cx">     &lt;div&gt;This test passes if the image below says 1x with a reddish background when the deviceScaleFactor is 1, and if says 2x with a greenish background when the deviceScaleFactor is 2.&lt;/div&gt;
</span><del>-    &lt;img id=&quot;foo&quot; src=&quot;&quot; srcset=&quot;resources/image-set-1x.png 1x, resources/deleteButton.png 3x, resources/image-set-2x.png 2x&quot;&gt;
</del><ins>+    &lt;img id=&quot;foo&quot; src=&quot;&quot; srcset=&quot;resources/blue-100-px-square.png 1x, resources/deleteButton.png 3x, resources/green-400-px-square.png 2x&quot;&gt;
</ins><span class="cx"> &lt;/body&gt;
</span><span class="cx"> &lt;/html&gt;
</span></span></pre></div>
<a id="trunkLayoutTestsfasthidpiimagesrcsetspaceleftnomodifierexpectedtxt"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/fast/hidpi/image-srcset-space-left-nomodifier-expected.txt (0 => 163415)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/fast/hidpi/image-srcset-space-left-nomodifier-expected.txt                                (rev 0)
+++ trunk/LayoutTests/fast/hidpi/image-srcset-space-left-nomodifier-expected.txt        2014-02-05 00:09:15 UTC (rev 163415)
</span><span class="lines">@@ -0,0 +1,3 @@
</span><ins>+PASS document.getElementById(&quot;foo&quot;).clientWidth==150 is true
+This test passes if the image below is not empty. It ensures that a candidate without scale modifier get a default one, even with space left at the end.
+
</ins></span></pre></div>
<a id="trunkLayoutTestsfasthidpiimagesrcsetspaceleftnomodifierhtmlfromrev163413trunkLayoutTestsfasthidpiimagesrcsetdatasrcsethtml"></a>
<div class="copfile"><h4>Copied: trunk/LayoutTests/fast/hidpi/image-srcset-space-left-nomodifier.html (from rev 163413, trunk/LayoutTests/fast/hidpi/image-srcset-data-srcset.html) (0 => 163415)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/fast/hidpi/image-srcset-space-left-nomodifier.html                                (rev 0)
+++ trunk/LayoutTests/fast/hidpi/image-srcset-space-left-nomodifier.html        2014-02-05 00:09:15 UTC (rev 163415)
</span><span class="lines">@@ -0,0 +1,20 @@
</span><ins>+&lt;html&gt;
+&lt;head&gt;
+&lt;script src=&quot;resources/srcset-helper.js&quot;&gt;&lt;/script&gt;
+&lt;script src=&quot;../../resources/js-test-pre.js&quot;&gt;&lt;/script&gt;
+&lt;script&gt;
+    if (window.testRunner) {
+        testRunner.dumpAsText();
+    }
+
+    addEventListener(&quot;load&quot;, function() {
+        shouldBeTrue('document.getElementById(&quot;foo&quot;).clientWidth==150');
+    }, false);
+&lt;/script&gt;
+&lt;/head&gt;
+
+&lt;body id=&quot;body&quot;&gt;
+    &lt;div&gt;This test passes if the image below is not empty. It ensures that a candidate without scale modifier get a default one, even with space left at the end.&lt;/div&gt;
+    &lt;img id=&quot;foo&quot; src=&quot;&quot; srcset=&quot;data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAJYAAAA8CAIAAAAL5NQ9AAAACXBIWXMAAAsTAAALEwEAmpwYAAAAB3RJTUUH2woaBQc4oLEFpAAAABl0RVh0Q29tbWVudABDcmVhdGVkIHdpdGggR0lNUFeBDhcAAACMSURBVHja7dNBEYAgFEVRPhHMYgAzUIsmVnFvB/fsoQb+ObfBmzMvxneW1D1vzz2wFiEUQiFEKIRCKIQIhVAIhRChEAqhECIUQiEUQoRCKIRCiFAIhVAIEep3xTWTLzzu5oVCKIRCiFAIhVAIEQqhEAohQiEUQiFEKIRCKIQIhVAIhRChEAqhECLUZi3VEwcBMGr1NgAAAABJRU5ErkJggg==  &quot;&gt;
+&lt;/body&gt;
+&lt;/html&gt;
</ins></span></pre></div>
<a id="trunkLayoutTestsfasthidpiimagesrcsetsrcselection2xhtml"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/fast/hidpi/image-srcset-src-selection-2x.html (163414 => 163415)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/fast/hidpi/image-srcset-src-selection-2x.html        2014-02-05 00:08:40 UTC (rev 163414)
+++ trunk/LayoutTests/fast/hidpi/image-srcset-src-selection-2x.html        2014-02-05 00:09:15 UTC (rev 163415)
</span><span class="lines">@@ -18,6 +18,6 @@
</span><span class="cx"> 
</span><span class="cx"> &lt;body id=&quot;body&quot;&gt;
</span><span class="cx">     &lt;div&gt;This test passes if the div below is a green 200px square when the deviceScaleFactor is 2. It simply ensures that the src attribute is taken into account by the selection algorithm when this one is processing the images candidates&lt;/div&gt;
</span><del>-    &lt;img id=&quot;foo&quot; src=&quot;resources/blue-100-px-square.png&quot; srcset=&quot;resources/green-200-px-square.png 2x&quot;&gt;
</del><ins>+    &lt;img id=&quot;foo&quot; src=&quot;resources/blue-100-px-square.png&quot; srcset=&quot;resources/green-400-px-square.png 2x&quot;&gt;
</ins><span class="cx"> &lt;/body&gt;
</span><span class="cx"> &lt;/html&gt;
</span></span></pre></div>
<a id="trunkLayoutTestsfasthidpiimagesrcsetsvgcanvas2xexpectedhtml"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/fast/hidpi/image-srcset-svg-canvas-2x-expected.html (0 => 163415)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/fast/hidpi/image-srcset-svg-canvas-2x-expected.html                                (rev 0)
+++ trunk/LayoutTests/fast/hidpi/image-srcset-svg-canvas-2x-expected.html        2014-02-05 00:09:15 UTC (rev 163415)
</span><span class="lines">@@ -0,0 +1,32 @@
</span><ins>+&lt;!DOCTYPE HTML&gt;
+&lt;html&gt;
+&lt;head&gt;
+    &lt;link rel=&quot;stylesheet&quot; href=&quot;resources/svg_tests.css&quot;&gt;
+    &lt;script src=&quot;resources/svg_canvas_helper.js&quot;&gt;&lt;/script&gt;
+    &lt;script&gt;
+        if (window.testRunner)
+            testRunner.waitUntilDone();
+    &lt;/script&gt;
+&lt;/head&gt;
+&lt;body&gt;
+  &lt;h2&gt;&lt;a href=&quot;http://www.w3.org/html/wg/drafts/srcset/w3c-srcset&quot;&gt;srcset&lt;/a&gt; testcases for SVG&lt;/h2&gt;
+  &lt;div class=&quot;test&quot;&gt;
+    &lt;h3&gt;Canvas SVG without explicit dimensions - 2x&lt;/h3&gt;
+    &lt;div class=&quot;expected&quot;&gt;expected&lt;br/&gt;
+      &lt;img id=&quot;svg8&quot; src=&quot;resources/srcset_100px.svg&quot;&gt;
+    &lt;/div&gt;
+    &lt;div class=&quot;actual&quot;&gt;actual&lt;br/&gt;
+      &lt;canvas id=&quot;canvas2&quot;&gt;&lt;/canvas&gt;
+    &lt;/div&gt;
+    This test should show an SVG image drawn into a canvas. The canvas and image should look the same and both should be 100x50.&lt;br/&gt;
+    &lt;br clear=&quot;all&quot;/&gt;
+  &lt;/div&gt;
+  &lt;script&gt;
+    window.addEventListener('load', function(){
+        drawCanvas('svg8', 'canvas2', 100, 50);
+        if (window.testRunner)
+            testRunner.notifyDone();
+    });
+  &lt;/script&gt;
+&lt;/body&gt;
+&lt;/html&gt;
</ins></span></pre></div>
<a id="trunkLayoutTestsfasthidpiimagesrcsetsvgcanvas2xhtml"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/fast/hidpi/image-srcset-svg-canvas-2x.html (0 => 163415)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/fast/hidpi/image-srcset-svg-canvas-2x.html                                (rev 0)
+++ trunk/LayoutTests/fast/hidpi/image-srcset-svg-canvas-2x.html        2014-02-05 00:09:15 UTC (rev 163415)
</span><span class="lines">@@ -0,0 +1,38 @@
</span><ins>+&lt;!DOCTYPE HTML&gt;
+&lt;html&gt;
+&lt;head&gt;
+    &lt;link rel=&quot;stylesheet&quot; href=&quot;resources/svg_tests.css&quot;&gt;
+    &lt;!--
+    &lt;script&gt;
+        window.targetScaleFactor = 1;
+    &lt;/script&gt;
+    &lt;script src=&quot;resources/srcset_helper.js&quot;&gt;&lt;/script&gt;
+    --&gt;
+    &lt;script src=&quot;resources/svg_canvas_helper.js&quot;&gt;&lt;/script&gt;
+    &lt;script&gt;
+        if (window.testRunner)
+            testRunner.waitUntilDone();
+    &lt;/script&gt;
+&lt;/head&gt;
+&lt;body&gt;
+  &lt;h2&gt;&lt;a href=&quot;http://www.w3.org/html/wg/drafts/srcset/w3c-srcset&quot;&gt;srcset&lt;/a&gt; testcases for SVG&lt;/h2&gt;
+  &lt;div class=&quot;test&quot;&gt;
+    &lt;h3&gt;Canvas SVG without explicit dimensions - 2x&lt;/h3&gt;
+    &lt;div class=&quot;expected&quot;&gt;expected&lt;br/&gt;
+      &lt;img id=&quot;svg8&quot; srcset=&quot;resources/srcset.svg 2x&quot;&gt;
+    &lt;/div&gt;
+    &lt;div class=&quot;actual&quot;&gt;actual&lt;br/&gt;
+      &lt;canvas id=&quot;canvas2&quot;&gt;&lt;/canvas&gt;
+    &lt;/div&gt;
+    This test should show an SVG image drawn into a canvas. The canvas and image should look the same and both should be 100x50.&lt;br/&gt;
+    &lt;br clear=&quot;all&quot;/&gt;
+  &lt;/div&gt;
+  &lt;script&gt;
+    window.addEventListener('load', function(){
+        drawCanvas('svg8', 'canvas2', 100, 50);
+        if (window.testRunner)
+            testRunner.notifyDone();
+    });
+  &lt;/script&gt;
+&lt;/body&gt;
+&lt;/html&gt;
</ins></span></pre></div>
<a id="trunkLayoutTestsfasthidpiimagesrcsetsvgcanvasexpectedhtml"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/fast/hidpi/image-srcset-svg-canvas-expected.html (0 => 163415)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/fast/hidpi/image-srcset-svg-canvas-expected.html                                (rev 0)
+++ trunk/LayoutTests/fast/hidpi/image-srcset-svg-canvas-expected.html        2014-02-05 00:09:15 UTC (rev 163415)
</span><span class="lines">@@ -0,0 +1,32 @@
</span><ins>+&lt;!DOCTYPE HTML&gt;
+&lt;html&gt;
+&lt;head&gt;
+    &lt;link rel=&quot;stylesheet&quot; href=&quot;resources/svg_tests.css&quot;&gt;
+    &lt;script src=&quot;resources/svg_canvas_helper.js&quot;&gt;&lt;/script&gt;
+    &lt;script&gt;
+        if (window.testRunner)
+            testRunner.waitUntilDone();
+    &lt;/script&gt;
+&lt;/head&gt;
+&lt;body&gt;
+  &lt;h2&gt;&lt;a href=&quot;http://www.w3.org/html/wg/drafts/srcset/w3c-srcset&quot;&gt;srcset&lt;/a&gt; testcases for SVG&lt;/h2&gt;
+  &lt;div class=&quot;test&quot;&gt;
+    &lt;h3&gt;Canvas SVG without explicit dimensions - 1x&lt;/h3&gt;
+    &lt;div class=&quot;expected&quot;&gt;expected&lt;br/&gt;
+      &lt;img id=&quot;svg7&quot; src=&quot;resources/srcset.svg&quot;&gt;
+    &lt;/div&gt;
+    &lt;div class=&quot;actual&quot;&gt;actual&lt;br/&gt;
+      &lt;canvas id=&quot;canvas1&quot;&gt;&lt;/canvas&gt;
+    &lt;/div&gt;
+    This test should show an SVG image drawn into a canvas. The canvas and image should look the same and both should be 200x100.&lt;br/&gt;
+    &lt;br clear=&quot;all&quot;/&gt;
+  &lt;/div&gt;
+  &lt;script&gt;
+    window.addEventListener('load', function(){
+        drawCanvas('svg7', 'canvas1', 200, 100);
+        if (window.testRunner)
+            testRunner.notifyDone();
+    });
+  &lt;/script&gt;
+&lt;/body&gt;
+&lt;/html&gt;
</ins></span></pre></div>
<a id="trunkLayoutTestsfasthidpiimagesrcsetsvgcanvashtml"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/fast/hidpi/image-srcset-svg-canvas.html (0 => 163415)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/fast/hidpi/image-srcset-svg-canvas.html                                (rev 0)
+++ trunk/LayoutTests/fast/hidpi/image-srcset-svg-canvas.html        2014-02-05 00:09:15 UTC (rev 163415)
</span><span class="lines">@@ -0,0 +1,32 @@
</span><ins>+&lt;!DOCTYPE HTML&gt;
+&lt;html&gt;
+&lt;head&gt;
+    &lt;link rel=&quot;stylesheet&quot; href=&quot;resources/svg_tests.css&quot;&gt;
+    &lt;script src=&quot;resources/svg_canvas_helper.js&quot;&gt;&lt;/script&gt;
+    &lt;script&gt;
+        if (window.testRunner)
+            testRunner.waitUntilDone();
+    &lt;/script&gt;
+&lt;/head&gt;
+&lt;body&gt;
+  &lt;h2&gt;&lt;a href=&quot;http://www.w3.org/html/wg/drafts/srcset/w3c-srcset&quot;&gt;srcset&lt;/a&gt; testcases for SVG&lt;/h2&gt;
+  &lt;div class=&quot;test&quot;&gt;
+    &lt;h3&gt;Canvas SVG without explicit dimensions - 1x&lt;/h3&gt;
+    &lt;div class=&quot;expected&quot;&gt;expected&lt;br/&gt;
+      &lt;img id=&quot;svg7&quot; srcset=&quot;resources/srcset.svg&quot;&gt;
+    &lt;/div&gt;
+    &lt;div class=&quot;actual&quot;&gt;actual&lt;br/&gt;
+      &lt;canvas id=&quot;canvas1&quot;&gt;&lt;/canvas&gt;
+    &lt;/div&gt;
+    This test should show an SVG image drawn into a canvas. The canvas and image should look the same and both should be 200x100.&lt;br/&gt;
+    &lt;br clear=&quot;all&quot;/&gt;
+  &lt;/div&gt;
+  &lt;script&gt;
+    window.addEventListener('load', function(){
+        drawCanvas('svg7', 'canvas1', 200, 100);
+        if (window.testRunner)
+            testRunner.notifyDone();
+    });
+  &lt;/script&gt;
+&lt;/body&gt;
+&lt;/html&gt;
</ins></span></pre></div>
<a id="trunkLayoutTestsfasthidpiimagesrcsetsvgexpectedhtml"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/fast/hidpi/image-srcset-svg-expected.html (0 => 163415)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/fast/hidpi/image-srcset-svg-expected.html                                (rev 0)
+++ trunk/LayoutTests/fast/hidpi/image-srcset-svg-expected.html        2014-02-05 00:09:15 UTC (rev 163415)
</span><span class="lines">@@ -0,0 +1,33 @@
</span><ins>+&lt;!DOCTYPE HTML&gt;
+&lt;html&gt;
+&lt;head&gt;
+    &lt;link rel=&quot;stylesheet&quot; href=&quot;resources/svg_tests.css&quot;&gt;
+&lt;/head&gt;
+&lt;body&gt;
+  &lt;h2&gt;&lt;a href=&quot;http://www.w3.org/html/wg/drafts/srcset/w3c-srcset&quot;&gt;srcset&lt;/a&gt; testcases for SVG&lt;/h2&gt;
+  &lt;div class=&quot;test&quot;&gt;
+    &lt;h3&gt;SVG without explicit dimensions - 1x&lt;/h3&gt;
+    &lt;div class=&quot;expected&quot;&gt;expected&lt;br/&gt;
+      &lt;img src=&quot;resources/srcset.svg&quot; width=&quot;200&quot; height=&quot;100&quot;&gt;
+    &lt;/div&gt;
+    &lt;div class=&quot;actual&quot;&gt;actual&lt;br/&gt;
+      &lt;img src=&quot;resources/srcset.svg&quot; width=&quot;200&quot; height=&quot;100&quot;&gt;
+    &lt;/div&gt;
+    This test should show an SVG image of size 200x100, and intrinsic/natural size 200x100. The left half of the image should be green and there should be a blue circle in the center.&lt;br/&gt;
+    &lt;code class=&quot;stats&quot; id=&quot;code1&quot;&gt;&lt;/code&gt;
+    &lt;br clear=&quot;all&quot;/&gt;
+  &lt;/div&gt;
+  &lt;div class=&quot;test&quot;&gt;
+    &lt;h3&gt;SVG with explicit dimensions - 1x&lt;/h3&gt;
+    &lt;div class=&quot;expected&quot;&gt;expected&lt;br/&gt;
+      &lt;img src=&quot;resources/srcset.svg&quot; width=&quot;100&quot; height=&quot;50&quot;&gt;
+    &lt;/div&gt;
+    &lt;div class=&quot;actual&quot;&gt;actual&lt;br/&gt;
+      &lt;img src=&quot;resources/srcset.svg&quot; width=&quot;100&quot; height=&quot;50&quot;&gt;
+    &lt;/div&gt;
+    This test should show an SVG image of size 100x50, and intrinsic/natural size 100x50. The left half of the image should be green and there should be a blue circle in the center.&lt;br/&gt;
+    &lt;code class=&quot;stats&quot; id=&quot;code2&quot;&gt;&lt;/code&gt;
+    &lt;br clear=&quot;all&quot;/&gt;
+  &lt;/div&gt;
+&lt;/body&gt;
+&lt;/html&gt;
</ins></span></pre></div>
<a id="trunkLayoutTestsfasthidpiimagesrcsetsvghtml"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/fast/hidpi/image-srcset-svg.html (0 => 163415)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/fast/hidpi/image-srcset-svg.html                                (rev 0)
+++ trunk/LayoutTests/fast/hidpi/image-srcset-svg.html        2014-02-05 00:09:15 UTC (rev 163415)
</span><span class="lines">@@ -0,0 +1,33 @@
</span><ins>+&lt;!DOCTYPE HTML&gt;
+&lt;html&gt;
+&lt;head&gt;
+    &lt;link rel=&quot;stylesheet&quot; href=&quot;resources/svg_tests.css&quot;&gt;
+&lt;/head&gt;
+&lt;body&gt;
+  &lt;h2&gt;&lt;a href=&quot;http://www.w3.org/html/wg/drafts/srcset/w3c-srcset&quot;&gt;srcset&lt;/a&gt; testcases for SVG&lt;/h2&gt;
+  &lt;div class=&quot;test&quot;&gt;
+    &lt;h3&gt;SVG without explicit dimensions - 1x&lt;/h3&gt;
+    &lt;div class=&quot;expected&quot;&gt;expected&lt;br/&gt;
+      &lt;img src=&quot;resources/srcset.svg&quot; width=&quot;200&quot; height=&quot;100&quot;&gt;
+    &lt;/div&gt;
+    &lt;div class=&quot;actual&quot;&gt;actual&lt;br/&gt;
+      &lt;img id='svg1' src=&quot;resources/srcset.svg&quot;&gt;
+    &lt;/div&gt;
+    This test should show an SVG image of size 200x100, and intrinsic/natural size 200x100. The left half of the image should be green and there should be a blue circle in the center.&lt;br/&gt;
+    &lt;code class=&quot;stats&quot; id=&quot;code1&quot;&gt;&lt;/code&gt;
+    &lt;br clear=&quot;all&quot;/&gt;
+  &lt;/div&gt;
+  &lt;div class=&quot;test&quot;&gt;
+    &lt;h3&gt;SVG with explicit dimensions - 1x&lt;/h3&gt;
+    &lt;div class=&quot;expected&quot;&gt;expected&lt;br/&gt;
+      &lt;img src=&quot;resources/srcset.svg&quot; width=&quot;100&quot; height=&quot;50&quot;&gt;
+    &lt;/div&gt;
+    &lt;div class=&quot;actual&quot;&gt;actual&lt;br/&gt;
+      &lt;img id=&quot;svg2&quot; src=&quot;resources/srcset.svg&quot; width=&quot;100&quot; height=&quot;50&quot;&gt;
+    &lt;/div&gt;
+    This test should show an SVG image of size 100x50, and intrinsic/natural size 100x50. The left half of the image should be green and there should be a blue circle in the center.&lt;br/&gt;
+    &lt;code class=&quot;stats&quot; id=&quot;code2&quot;&gt;&lt;/code&gt;
+    &lt;br clear=&quot;all&quot;/&gt;
+  &lt;/div&gt;
+&lt;/body&gt;
+&lt;/html&gt;
</ins></span></pre></div>
<a id="trunkLayoutTestsfasthidpiimagesrcsetsvg2expectedhtml"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/fast/hidpi/image-srcset-svg2-expected.html (0 => 163415)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/fast/hidpi/image-srcset-svg2-expected.html                                (rev 0)
+++ trunk/LayoutTests/fast/hidpi/image-srcset-svg2-expected.html        2014-02-05 00:09:15 UTC (rev 163415)
</span><span class="lines">@@ -0,0 +1,31 @@
</span><ins>+&lt;!DOCTYPE HTML&gt;
+&lt;html&gt;
+&lt;head&gt;
+    &lt;link rel=&quot;stylesheet&quot; href=&quot;resources/svg_tests.css&quot;&gt;
+&lt;/head&gt;
+&lt;body&gt;
+  &lt;h2&gt;&lt;a href=&quot;http://www.w3.org/html/wg/drafts/srcset/w3c-srcset&quot;&gt;srcset&lt;/a&gt; testcases for SVG&lt;/h2&gt;
+  &lt;div class=&quot;test&quot;&gt;
+    &lt;h3&gt;SVG without explicit dimensions - 2x&lt;/h3&gt;
+    &lt;div class=&quot;expected&quot;&gt;expected&lt;br/&gt;
+      &lt;img src=&quot;resources/srcset.svg&quot; width=&quot;100&quot; height=&quot;50&quot;&gt;
+    &lt;/div&gt;
+    &lt;div class=&quot;actual&quot;&gt;actual&lt;br/&gt;
+      &lt;img src=&quot;resources/srcset.svg&quot; width=&quot;100&quot; height=&quot;50&quot;&gt;
+    &lt;/div&gt;
+    This test should show an SVG image of size 100x50, and intrinsic/natural size 100x50. The left half of the image should be green and there should be a blue circle in the center.&lt;br/&gt;
+    &lt;br clear=&quot;all&quot;/&gt;
+  &lt;/div&gt;
+  &lt;div class=&quot;test&quot;&gt;
+    &lt;h3&gt;SVG with explicit dimensions - 4x&lt;/h3&gt;
+    &lt;div class=&quot;expected&quot;&gt;expected&lt;br/&gt;
+      &lt;img src=&quot;resources/srcset.svg&quot; width=&quot;100&quot; height=&quot;50&quot;&gt;
+    &lt;/div&gt;
+    &lt;div class=&quot;actual&quot;&gt;actual&lt;br/&gt;
+      &lt;img src=&quot;resources/srcset.svg&quot; width=&quot;100&quot; height=&quot;50&quot;&gt;
+    &lt;/div&gt;
+    This test should show an SVG image of size 100x50, and intrinsic/natural size 50x25. The left half of the image should be green and there should be a blue circle in the center.&lt;br/&gt;
+    &lt;br clear=&quot;all&quot;/&gt;
+  &lt;/div&gt;
+&lt;/body&gt;
+&lt;/html&gt;
</ins></span></pre></div>
<a id="trunkLayoutTestsfasthidpiimagesrcsetsvg2html"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/fast/hidpi/image-srcset-svg2.html (0 => 163415)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/fast/hidpi/image-srcset-svg2.html                                (rev 0)
+++ trunk/LayoutTests/fast/hidpi/image-srcset-svg2.html        2014-02-05 00:09:15 UTC (rev 163415)
</span><span class="lines">@@ -0,0 +1,31 @@
</span><ins>+&lt;!DOCTYPE HTML&gt;
+&lt;html&gt;
+&lt;head&gt;
+    &lt;link rel=&quot;stylesheet&quot; href=&quot;resources/svg_tests.css&quot;&gt;
+&lt;/head&gt;
+&lt;body&gt;
+  &lt;h2&gt;&lt;a href=&quot;http://www.w3.org/html/wg/drafts/srcset/w3c-srcset&quot;&gt;srcset&lt;/a&gt; testcases for SVG&lt;/h2&gt;
+  &lt;div class=&quot;test&quot;&gt;
+    &lt;h3&gt;SVG without explicit dimensions - 2x&lt;/h3&gt;
+    &lt;div class=&quot;expected&quot;&gt;expected&lt;br/&gt;
+      &lt;img src=&quot;resources/srcset.svg&quot; width=&quot;100&quot; height=&quot;50&quot;&gt;
+    &lt;/div&gt;
+    &lt;div class=&quot;actual&quot;&gt;actual&lt;br/&gt;
+      &lt;img id=&quot;svg3&quot; src=&quot;&quot; srcset=&quot;resources/srcset.svg 2x&quot;&gt;
+    &lt;/div&gt;
+    This test should show an SVG image of size 100x50, and intrinsic/natural size 100x50. The left half of the image should be green and there should be a blue circle in the center.&lt;br/&gt;
+    &lt;br clear=&quot;all&quot;/&gt;
+  &lt;/div&gt;
+  &lt;div class=&quot;test&quot;&gt;
+    &lt;h3&gt;SVG with explicit dimensions - 4x&lt;/h3&gt;
+    &lt;div class=&quot;expected&quot;&gt;expected&lt;br/&gt;
+      &lt;img src=&quot;resources/srcset.svg&quot; width=&quot;100&quot; height=&quot;50&quot;&gt;
+    &lt;/div&gt;
+    &lt;div class=&quot;actual&quot;&gt;actual&lt;br/&gt;
+      &lt;img id=&quot;svg4&quot; src=&quot;&quot; srcset=&quot;resources/srcset.svg 4x&quot; width=&quot;100&quot; height=&quot;50&quot;&gt;
+    &lt;/div&gt;
+    This test should show an SVG image of size 100x50, and intrinsic/natural size 50x25. The left half of the image should be green and there should be a blue circle in the center.&lt;br/&gt;
+    &lt;br clear=&quot;all&quot;/&gt;
+  &lt;/div&gt;
+&lt;/body&gt;
+&lt;/html&gt;
</ins></span></pre></div>
<a id="trunkLayoutTestsfasthidpiresourcesgreen400pxsquarepng"></a>
<div class="binary"><h4>Added: trunk/LayoutTests/fast/hidpi/resources/green-400-px-square.png</h4>
<pre class="diff"><span>
<span class="cx">(Binary files differ)
</span></span></pre></div>
<span class="cx">Property changes on: trunk/LayoutTests/fast/hidpi/resources/green-400-px-square.png
</span><span class="cx">___________________________________________________________________
</span><a id="svnmimetype"></a>
<div class="addfile"><h4>Added: svn:mime-type</h4></div>
<a id="trunkLayoutTestsfasthidpiresourcesrelativesrcsetsvg"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/fast/hidpi/resources/relativesrcset.svg (0 => 163415)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/fast/hidpi/resources/relativesrcset.svg                                (rev 0)
+++ trunk/LayoutTests/fast/hidpi/resources/relativesrcset.svg        2014-02-05 00:09:15 UTC (rev 163415)
</span><span class="lines">@@ -0,0 +1,4 @@
</span><ins>+&lt;svg xmlns='http://www.w3.org/2000/svg' width='100%' height='100%'&gt;
+  &lt;rect fill='pink' width='50%' height='100%'/&gt;
+  &lt;circle fill='purple' cx='50' cy='25' r='15'/&gt;
+&lt;/svg&gt;
</ins><span class="cx">\ No newline at end of file
</span></span></pre></div>
<a id="trunkLayoutTestsfasthidpiresourcessrcsethelperjs"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/fast/hidpi/resources/srcset-helper.js (163414 => 163415)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/fast/hidpi/resources/srcset-helper.js        2014-02-05 00:08:40 UTC (rev 163414)
+++ trunk/LayoutTests/fast/hidpi/resources/srcset-helper.js        2014-02-05 00:09:15 UTC (rev 163415)
</span><span class="lines">@@ -13,7 +13,8 @@
</span><span class="cx">     if (sessionStorage.pageReloaded &amp;&amp; sessionStorage.scaleFactorIsSet) {
</span><span class="cx">         delete sessionStorage.pageReloaded;
</span><span class="cx">         delete sessionStorage.scaleFactorIsSet;
</span><del>-        testRunner.notifyDone();
</del><ins>+        if (!window.manualNotifyDone)
+            testRunner.notifyDone();
</ins><span class="cx">     } else {
</span><span class="cx">         // Right now there is a bug that srcset does not properly deal with dynamic changes to the scale factor,
</span><span class="cx">         // so to work around that, we must reload the page to get the new image.
</span></span></pre></div>
<a id="trunkLayoutTestsfasthidpiresourcessrcsetpng"></a>
<div class="binary"><h4>Added: trunk/LayoutTests/fast/hidpi/resources/srcset.png</h4>
<pre class="diff"><span>
<span class="cx">(Binary files differ)
</span></span></pre></div>
<span class="cx">Property changes on: trunk/LayoutTests/fast/hidpi/resources/srcset.png
</span><span class="cx">___________________________________________________________________
</span><a id="svnmimetype"></a>
<div class="addfile"><h4>Added: svn:mime-type</h4></div>
<a id="trunkLayoutTestsfasthidpiresourcessrcsetsvg"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/fast/hidpi/resources/srcset.svg (0 => 163415)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/fast/hidpi/resources/srcset.svg                                (rev 0)
+++ trunk/LayoutTests/fast/hidpi/resources/srcset.svg        2014-02-05 00:09:15 UTC (rev 163415)
</span><span class="lines">@@ -0,0 +1,4 @@
</span><ins>+&lt;svg xmlns='http://www.w3.org/2000/svg' width='200' height='100'&gt;
+  &lt;rect fill='green' width='50%' height='100%'/&gt;
+  &lt;circle fill='blue' cx='100' cy='50' r='30'/&gt;
+&lt;/svg&gt;
</ins><span class="cx">\ No newline at end of file
</span></span></pre></div>
<a id="trunkLayoutTestsfasthidpiresourcessrcset_100pxsvg"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/fast/hidpi/resources/srcset_100px.svg (0 => 163415)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/fast/hidpi/resources/srcset_100px.svg                                (rev 0)
+++ trunk/LayoutTests/fast/hidpi/resources/srcset_100px.svg        2014-02-05 00:09:15 UTC (rev 163415)
</span><span class="lines">@@ -0,0 +1,4 @@
</span><ins>+&lt;svg xmlns='http://www.w3.org/2000/svg' width='100' height='50'&gt;
+  &lt;rect fill='green' width='50%' height='100%'/&gt;
+  &lt;circle fill='blue' cx='50' cy='25' r='15'/&gt;
+&lt;/svg&gt;
</ins></span></pre></div>
<a id="trunkLayoutTestsfasthidpiresourcessvg_canvas_helperjs"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/fast/hidpi/resources/svg_canvas_helper.js (0 => 163415)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/fast/hidpi/resources/svg_canvas_helper.js                                (rev 0)
+++ trunk/LayoutTests/fast/hidpi/resources/svg_canvas_helper.js        2014-02-05 00:09:15 UTC (rev 163415)
</span><span class="lines">@@ -0,0 +1,8 @@
</span><ins>+function drawCanvas(imageId, canvasId, canvasWidth, canvasHeight) {
+  var image = document.getElementById(imageId);
+  var canvas = document.getElementById(canvasId);
+  canvas.width = canvasWidth;
+  canvas.height = canvasHeight;
+  var context = canvas.getContext('2d');
+  context.drawImage(image, 0, 0, canvasWidth, canvasHeight);
+}
</ins></span></pre></div>
<a id="trunkLayoutTestsfasthidpiresourcessvg_testscss"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/fast/hidpi/resources/svg_tests.css (0 => 163415)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/fast/hidpi/resources/svg_tests.css                                (rev 0)
+++ trunk/LayoutTests/fast/hidpi/resources/svg_tests.css        2014-02-05 00:09:15 UTC (rev 163415)
</span><span class="lines">@@ -0,0 +1,20 @@
</span><ins>+  .test {
+    border: 1px solid gray;
+    padding: 1em;
+    margin-bottom: 1em;
+  }
+  .test img, .test canvas {
+    border: 1px solid black;
+  }
+  .test .stats {
+    display: inline-block;
+    margin-top: 1em;
+    font-style: italic;
+  }
+  .expected, .actual {
+    float: right;
+    background-color: #eee;
+    border: 1px solid #ccc;
+    padding: 0.4em;
+    margin-left: 1em;
+  }
</ins></span></pre></div>
<a id="trunkLayoutTestsplatformgtkwk2fasthidpiimagesrcsetchangedynamicallyfromjs2xexpectedtxt"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/platform/gtk-wk2/fast/hidpi/image-srcset-change-dynamically-from-js-2x-expected.txt (0 => 163415)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/platform/gtk-wk2/fast/hidpi/image-srcset-change-dynamically-from-js-2x-expected.txt                                (rev 0)
+++ trunk/LayoutTests/platform/gtk-wk2/fast/hidpi/image-srcset-change-dynamically-from-js-2x-expected.txt        2014-02-05 00:09:15 UTC (rev 163415)
</span><span class="lines">@@ -0,0 +1,8 @@
</span><ins>+blue-100-px-square.png has MIME type image/png
+image-srcset-change-dynamically-from-js-2x.html has MIME type text/html
+srcset-helper.js has MIME type application/javascript
+js-test-pre.js has MIME type application/javascript
+green-400-px-square.png has MIME type image/png
+PASS document.getElementById(&quot;foo&quot;).clientWidth==200 is true
+This test passes if this img tag below is a green square when the scale factor is 2. It ensures that attributes can be changed dynamically from javascript, and that only the correct resource is loaded.
+
</ins></span></pre></div>
<a id="trunkLayoutTestsplatformmacfasthidpiimagesrcsetinvalidinputscorrectsrcexpectedpng"></a>
<div class="binary"><h4>Deleted: trunk/LayoutTests/platform/mac/fast/hidpi/image-srcset-invalid-inputs-correct-src-expected.png</h4>
<pre class="diff"><span>
<span class="cx">(Binary files differ)
</span></span></pre></div>
<a id="trunkLayoutTestsplatformmacfasthidpiimagesrcsetinvalidinputsexceptoneexpectedpng"></a>
<div class="binary"><h4>Deleted: trunk/LayoutTests/platform/mac/fast/hidpi/image-srcset-invalid-inputs-except-one-expected.png</h4>
<pre class="diff"><span>
<span class="cx">(Binary files differ)
</span></span></pre></div>
<a id="trunkLayoutTestsplatformmacfasthidpiimagesrcsetinvalidinputsexpectedpng"></a>
<div class="binary"><h4>Deleted: trunk/LayoutTests/platform/mac/fast/hidpi/image-srcset-invalid-inputs-expected.png</h4>
<pre class="diff"><span>
<span class="cx">(Binary files differ)
</span></span></pre></div>
<a id="trunkLayoutTestsplatformmacfasthidpiimagesrcsetinvalidinputsexpectedtxt"></a>
<div class="delfile"><h4>Deleted: trunk/LayoutTests/platform/mac/fast/hidpi/image-srcset-invalid-inputs-expected.txt (163414 => 163415)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/platform/mac/fast/hidpi/image-srcset-invalid-inputs-expected.txt        2014-02-05 00:08:40 UTC (rev 163414)
+++ trunk/LayoutTests/platform/mac/fast/hidpi/image-srcset-invalid-inputs-expected.txt        2014-02-05 00:09:15 UTC (rev 163415)
</span><span class="lines">@@ -1,11 +0,0 @@
</span><del>-layer at (0,0) size 800x600
-  RenderView at (0,0) size 800x600
-layer at (0,0) size 800x600
-  RenderBlock {HTML} at (0,0) size 800x600
-    RenderBody {BODY} at (8,8) size 784x584
-      RenderBlock {DIV} at (0,0) size 784x18
-        RenderText {#text} at (0,0) size 779x18
-          text run at (0,0) width 779: &quot;This test passes if this img tag below is empty and displays nothing. It ensures that the srcset attribute supports invalid inputs&quot;
-      RenderBlock (anonymous) at (0,18) size 784x100
-        RenderImage {IMG} at (0,0) size 100x100
-        RenderText {#text} at (0,0) size 0x0
</del></span></pre></div>
<a id="trunkLayoutTestsplatformmacfasthidpiimagesrcsetonlysrcattributeexpectedpng"></a>
<div class="binary"><h4>Deleted: trunk/LayoutTests/platform/mac/fast/hidpi/image-srcset-only-src-attribute-expected.png</h4>
<pre class="diff"><span>
<span class="cx">(Binary files differ)
</span></span></pre></div>
<a id="trunkLayoutTestsplatformmacfasthidpiimagesrcsetonlysrcattributeexpectedtxt"></a>
<div class="delfile"><h4>Deleted: trunk/LayoutTests/platform/mac/fast/hidpi/image-srcset-only-src-attribute-expected.txt (163414 => 163415)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/platform/mac/fast/hidpi/image-srcset-only-src-attribute-expected.txt        2014-02-05 00:08:40 UTC (rev 163414)
+++ trunk/LayoutTests/platform/mac/fast/hidpi/image-srcset-only-src-attribute-expected.txt        2014-02-05 00:09:15 UTC (rev 163415)
</span><span class="lines">@@ -1,12 +0,0 @@
</span><del>-layer at (0,0) size 800x600
-  RenderView at (0,0) size 800x600
-layer at (0,0) size 800x600
-  RenderBlock {HTML} at (0,0) size 800x600
-    RenderBody {BODY} at (8,8) size 784x584
-      RenderBlock {DIV} at (0,0) size 784x36
-        RenderText {#text} at (0,0) size 776x36
-          text run at (0,0) width 776: &quot;This test passes if this img tag below is a green square when the scale factor is 2. It ensures that the selection algorithm does&quot;
-          text run at (0,18) width 514: &quot;not change the behavior of the src attribute, even with a scale factor greater than 1&quot;
-      RenderBlock (anonymous) at (0,36) size 784x100
-        RenderImage {IMG} at (0,0) size 100x100
-        RenderText {#text} at (0,0) size 0x0
</del></span></pre></div>
<a id="trunkSourceWebCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/ChangeLog (163414 => 163415)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/ChangeLog        2014-02-05 00:08:40 UTC (rev 163414)
+++ trunk/Source/WebCore/ChangeLog        2014-02-05 00:09:15 UTC (rev 163415)
</span><span class="lines">@@ -1,3 +1,64 @@
</span><ins>+2014-02-04  Yoav Weiss  &lt;yoav@yoav.ws&gt;
+
+        Use srcset's pixel density to determine intrinsic size
+        https://bugs.webkit.org/show_bug.cgi?id=123832
+
+        Reviewed by Dean Jackson.
+
+        The patch is a port of a similar Blink patch: https://codereview.chromium.org/25105004
+        According to the spec &quot;When an img element has a current pixel density that is not 1.0,
+        the element's image data must be treated as if its resolution, in device pixels per CSS pixels,
+        was the current pixel density.&quot;
+
+        I've added that support using the following changes:
+        - bestFitSourceForImageAttributes now returns the image candidate to HTMLImageElement.
+        - HTMLImageElement passes the devicePixelRatio data to RenderImage, which stores it.
+        - Bitmap images are scaled using the devicePixelRatio at RenderImageResource's intrinsicSize() and imageSize().
+        - SVG images are scaled using the devicePixelRatio at RenderReplaced::computeAspectRatioInformationForRenderBox.
+        - Canvas support added at CanvasRenderingContext2D::size.
+
+        Tests: fast/hidpi/image-srcset-intrinsic-size.html
+               fast/hidpi/image-srcset-png-canvas.html
+               fast/hidpi/image-srcset-png.html
+               fast/hidpi/image-srcset-relative-svg-canvas-2x.html
+               fast/hidpi/image-srcset-relative-svg.html
+               fast/hidpi/image-srcset-space-left-nomodifier.html
+               fast/hidpi/image-srcset-svg-canvas-2x.html
+               fast/hidpi/image-srcset-svg-canvas.html
+               fast/hidpi/image-srcset-svg.html
+               fast/hidpi/image-srcset-svg2.html
+
+        * html/HTMLImageElement.cpp:
+        (WebCore::HTMLImageElement::HTMLImageElement):
+        (WebCore::HTMLImageElement::parseAttribute):
+        (WebCore::HTMLImageElement::createRenderer):
+        * html/HTMLImageElement.h:
+        * html/canvas/CanvasRenderingContext2D.cpp:
+        (WebCore::size):
+        (WebCore::CanvasRenderingContext2D::drawImage):
+        * html/parser/HTMLParserIdioms.cpp:
+        (WebCore::compareByScaleFactor):
+        (WebCore::parseImagesWithScaleFromSrcsetAttribute):
+        (WebCore::bestFitSourceForImageAttributes):
+        * html/parser/HTMLParserIdioms.h:
+        (WebCore::ImageWithScale::ImageWithScale):
+        (WebCore::ImageWithScale::imageURL):
+        (WebCore::ImageWithScale::scaleFactor):
+        * html/parser/HTMLPreloadScanner.cpp:
+        (WebCore::TokenPreloadScanner::StartTagScanner::processAttributes):
+        * rendering/RenderImage.cpp:
+        (WebCore::RenderImage::RenderImage):
+        * rendering/RenderImage.h:
+        (WebCore::RenderImage::setImageDevicePixelRatio):
+        (WebCore::RenderImage::imageDevicePixelRatio):
+        * rendering/RenderImageResource.cpp:
+        (WebCore::RenderImageResource::imageSize):
+        (WebCore::RenderImageResource::intrinsicSize):
+        (WebCore::RenderImageResource::getImageSize):
+        * rendering/RenderImageResource.h:
+        * rendering/RenderReplaced.cpp:
+        (WebCore::RenderReplaced::computeAspectRatioInformationForRenderBox):
+
</ins><span class="cx"> 2014-02-04  Geoffrey Garen  &lt;ggaren@apple.com&gt;
</span><span class="cx"> 
</span><span class="cx">         Rolled out &lt;http://trac.webkit.org/changeset/163280&gt;:
</span></span></pre></div>
<a id="trunkSourceWebCorehtmlHTMLImageElementcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/html/HTMLImageElement.cpp (163414 => 163415)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/html/HTMLImageElement.cpp        2014-02-05 00:08:40 UTC (rev 163414)
+++ trunk/Source/WebCore/html/HTMLImageElement.cpp        2014-02-05 00:09:15 UTC (rev 163415)
</span><span class="lines">@@ -45,6 +45,7 @@
</span><span class="cx">     , m_imageLoader(this)
</span><span class="cx">     , m_form(form)
</span><span class="cx">     , m_compositeOperator(CompositeSourceOver)
</span><ins>+    , m_imageDevicePixelRatio(1.0f)
</ins><span class="cx"> {
</span><span class="cx">     ASSERT(hasTagName(imgTag));
</span><span class="cx">     setHasCustomStyleResolveCallbacks();
</span><span class="lines">@@ -118,7 +119,13 @@
</span><span class="cx">         if (renderer() &amp;&amp; renderer()-&gt;isRenderImage())
</span><span class="cx">             toRenderImage(renderer())-&gt;updateAltText();
</span><span class="cx">     } else if (name == srcAttr || name == srcsetAttr) {
</span><del>-        m_bestFitImageURL = bestFitSourceForImageAttributes(document().deviceScaleFactor(), fastGetAttribute(srcAttr), fastGetAttribute(srcsetAttr));
</del><ins>+        ImageWithScale candidate = bestFitSourceForImageAttributes(document().deviceScaleFactor(), fastGetAttribute(srcAttr), fastGetAttribute(srcsetAttr));
+        m_bestFitImageURL = candidate.imageURL(fastGetAttribute(srcAttr), fastGetAttribute(srcsetAttr));
+        float candidateScaleFactor = candidate.scaleFactor();
+        if (candidateScaleFactor &gt; 0)
+            m_imageDevicePixelRatio = 1 / candidateScaleFactor;
+        if (renderer() &amp;&amp; renderer()-&gt;isImage())
+            toRenderImage(renderer())-&gt;setImageDevicePixelRatio(m_imageDevicePixelRatio);
</ins><span class="cx">         m_imageLoader.updateFromElementIgnoringPreviousError();
</span><span class="cx">     } else if (name == usemapAttr) {
</span><span class="cx">         setIsLink(!value.isNull() &amp;&amp; !shouldProhibitLinks(this));
</span><span class="lines">@@ -179,7 +186,7 @@
</span><span class="cx">     if (style.get().hasContent())
</span><span class="cx">         return RenderElement::createFor(*this, std::move(style));
</span><span class="cx"> 
</span><del>-    return createRenderer&lt;RenderImage&gt;(*this, std::move(style));
</del><ins>+    return createRenderer&lt;RenderImage&gt;(*this, std::move(style), nullptr, m_imageDevicePixelRatio);
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> bool HTMLImageElement::canStartSelection() const
</span></span></pre></div>
<a id="trunkSourceWebCorehtmlHTMLImageElementh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/html/HTMLImageElement.h (163414 => 163415)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/html/HTMLImageElement.h        2014-02-05 00:08:40 UTC (rev 163414)
+++ trunk/Source/WebCore/html/HTMLImageElement.h        2014-02-05 00:09:15 UTC (rev 163415)
</span><span class="lines">@@ -121,6 +121,7 @@
</span><span class="cx">     CompositeOperator m_compositeOperator;
</span><span class="cx">     AtomicString m_bestFitImageURL;
</span><span class="cx">     AtomicString m_lowercasedUsemap;
</span><ins>+    float m_imageDevicePixelRatio;
</ins><span class="cx"> };
</span><span class="cx"> 
</span><span class="cx"> NODE_TYPE_CASTS(HTMLImageElement)
</span></span></pre></div>
<a id="trunkSourceWebCorehtmlcanvasCanvasRenderingContext2Dcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/html/canvas/CanvasRenderingContext2D.cpp (163414 => 163415)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/html/canvas/CanvasRenderingContext2D.cpp        2014-02-05 00:08:40 UTC (rev 163414)
+++ trunk/Source/WebCore/html/canvas/CanvasRenderingContext2D.cpp        2014-02-05 00:09:15 UTC (rev 163415)
</span><span class="lines">@@ -48,6 +48,7 @@
</span><span class="cx"> #include &quot;HTMLVideoElement.h&quot;
</span><span class="cx"> #include &quot;ImageData.h&quot;
</span><span class="cx"> #include &quot;RenderElement.h&quot;
</span><ins>+#include &quot;RenderImage.h&quot;
</ins><span class="cx"> #include &quot;RenderLayer.h&quot;
</span><span class="cx"> #include &quot;SecurityOrigin.h&quot;
</span><span class="cx"> #include &quot;StrokeStyleApplier.h&quot;
</span><span class="lines">@@ -1196,11 +1197,21 @@
</span><span class="cx">     return alphaChannel(state().m_shadowColor) &amp;&amp; (state().m_shadowBlur || !state().m_shadowOffset.isZero());
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-static LayoutSize size(HTMLImageElement* image)
</del><ins>+enum ImageSizeType {
+    ImageSizeAfterDevicePixelRatio,
+    ImageSizeBeforeDevicePixelRatio
+};
+
+static LayoutSize size(HTMLImageElement* image, ImageSizeType sizeType)
</ins><span class="cx"> {
</span><del>-    if (CachedImage* cachedImage = image-&gt;cachedImage())
-        return cachedImage-&gt;imageSizeForRenderer(image-&gt;renderer(), 1.0f); // FIXME: Not sure about this.
-    return IntSize();
</del><ins>+    LayoutSize size;
+    if (CachedImage* cachedImage = image-&gt;cachedImage()) {
+        size = cachedImage-&gt;imageSizeForRenderer(image-&gt;renderer(), 1.0f); // FIXME: Not sure about this.
+
+        if (sizeType == ImageSizeAfterDevicePixelRatio &amp;&amp; image-&gt;renderer() &amp;&amp; image-&gt;renderer()-&gt;isRenderImage() &amp;&amp; cachedImage-&gt;image() &amp;&amp; !cachedImage-&gt;image()-&gt;hasRelativeWidth())
+            size.scale(toRenderImage(image-&gt;renderer())-&gt;imageDevicePixelRatio());
+    }
+    return size;
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> #if ENABLE(VIDEO)
</span><span class="lines">@@ -1226,8 +1237,8 @@
</span><span class="cx">         ec = TYPE_MISMATCH_ERR;
</span><span class="cx">         return;
</span><span class="cx">     }
</span><del>-    LayoutSize s = size(image);
-    drawImage(image, x, y, s.width(), s.height(), ec);
</del><ins>+    LayoutSize destRectSize = size(image, ImageSizeAfterDevicePixelRatio);
+    drawImage(image, x, y, destRectSize.width(), destRectSize.height(), ec);
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void CanvasRenderingContext2D::drawImage(HTMLImageElement* image,
</span><span class="lines">@@ -1237,8 +1248,8 @@
</span><span class="cx">         ec = TYPE_MISMATCH_ERR;
</span><span class="cx">         return;
</span><span class="cx">     }
</span><del>-    LayoutSize s = size(image);
-    drawImage(image, FloatRect(0, 0, s.width(), s.height()), FloatRect(x, y, width, height), ec);
</del><ins>+    LayoutSize sourceRectSize = size(image, ImageSizeBeforeDevicePixelRatio);
+    drawImage(image, FloatRect(0, 0, sourceRectSize.width(), sourceRectSize.height()), FloatRect(x, y, width, height), ec);
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void CanvasRenderingContext2D::drawImage(HTMLImageElement* image,
</span><span class="lines">@@ -1275,7 +1286,7 @@
</span><span class="cx">     FloatRect normalizedSrcRect = normalizeRect(srcRect);
</span><span class="cx">     FloatRect normalizedDstRect = normalizeRect(dstRect);
</span><span class="cx"> 
</span><del>-    FloatRect imageRect = FloatRect(FloatPoint(), size(image));
</del><ins>+    FloatRect imageRect = FloatRect(FloatPoint(), size(image, ImageSizeBeforeDevicePixelRatio));
</ins><span class="cx">     if (!srcRect.width() || !srcRect.height()) {
</span><span class="cx">         ec = INDEX_SIZE_ERR;
</span><span class="cx">         return;
</span></span></pre></div>
<a id="trunkSourceWebCorehtmlparserHTMLParserIdiomscpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/html/parser/HTMLParserIdioms.cpp (163414 => 163415)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/html/parser/HTMLParserIdioms.cpp        2014-02-05 00:08:40 UTC (rev 163414)
+++ trunk/Source/WebCore/html/parser/HTMLParserIdioms.cpp        2014-02-05 00:09:15 UTC (rev 163415)
</span><span class="lines">@@ -290,28 +290,11 @@
</span><span class="cx">     return threadSafeEqual(*a.localName().impl(), *b.localName().impl());
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-struct ImageWithScale {
-    unsigned imageURLStart;
-    unsigned imageURLLength;
-    float scaleFactor;
-
-    ImageWithScale()
-        : imageURLStart(0)
-        , imageURLLength(0)
-        , scaleFactor(1)
-    { 
-    }
-
-    bool hasImageURL() const
-    {
-        return imageURLLength;
-    }
-};
</del><span class="cx"> typedef Vector&lt;ImageWithScale&gt; ImageCandidates;
</span><span class="cx"> 
</span><span class="cx"> static inline bool compareByScaleFactor(const ImageWithScale&amp; first, const ImageWithScale&amp; second)
</span><span class="cx"> {
</span><del>-    return first.scaleFactor &lt; second.scaleFactor;
</del><ins>+    return first.scaleFactor() &lt; second.scaleFactor();
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> static inline bool isHTMLSpaceOrComma(UChar character)
</span><span class="lines">@@ -389,18 +372,14 @@
</span><span class="cx">                 }
</span><span class="cx">             }
</span><span class="cx">         }
</span><del>-        ImageWithScale image;
-        image.imageURLStart = imageURLStart;
-        image.imageURLLength = imageURLEnd - imageURLStart;
-        image.scaleFactor = imageScaleFactor;
-
</del><ins>+        ImageWithScale image(imageURLStart, imageURLEnd - imageURLStart, imageScaleFactor);
</ins><span class="cx">         imageCandidates.append(image);
</span><span class="cx">         // 11. Return to the step labeled splitting loop.
</span><span class="cx">         imageCandidateStart = separator + 1;
</span><span class="cx">     }
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-String bestFitSourceForImageAttributes(float deviceScaleFactor, const String&amp; srcAttribute, const String&amp; srcsetAttribute)
</del><ins>+ImageWithScale bestFitSourceForImageAttributes(float deviceScaleFactor, const String&amp; srcAttribute, const String&amp; srcsetAttribute)
</ins><span class="cx"> {
</span><span class="cx">     ImageCandidates imageCandidates;
</span><span class="cx"> 
</span><span class="lines">@@ -412,16 +391,16 @@
</span><span class="cx">     }
</span><span class="cx"> 
</span><span class="cx">     if (imageCandidates.isEmpty())
</span><del>-        return String();
</del><ins>+        return ImageWithScale();
</ins><span class="cx"> 
</span><span class="cx">     std::stable_sort(imageCandidates.begin(), imageCandidates.end(), compareByScaleFactor);
</span><span class="cx"> 
</span><span class="cx">     for (size_t i = 0; i &lt; imageCandidates.size() - 1; ++i) {
</span><del>-        if (imageCandidates[i].scaleFactor &gt;= deviceScaleFactor)
-            return imageCandidates[i].hasImageURL() ? srcsetAttribute.substringSharingImpl(imageCandidates[i].imageURLStart, imageCandidates[i].imageURLLength) : srcAttribute;
</del><ins>+        if (imageCandidates[i].scaleFactor() &gt;= deviceScaleFactor)
+            return imageCandidates[i];
</ins><span class="cx">     }
</span><span class="cx">     const ImageWithScale&amp; lastCandidate = imageCandidates.last();
</span><del>-    return lastCandidate.hasImageURL() ? srcsetAttribute.substringSharingImpl(lastCandidate.imageURLStart, lastCandidate.imageURLLength) : srcAttribute;
</del><ins>+    return lastCandidate;
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> }
</span></span></pre></div>
<a id="trunkSourceWebCorehtmlparserHTMLParserIdiomsh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/html/parser/HTMLParserIdioms.h (163414 => 163415)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/html/parser/HTMLParserIdioms.h        2014-02-05 00:08:40 UTC (rev 163414)
+++ trunk/Source/WebCore/html/parser/HTMLParserIdioms.h        2014-02-05 00:09:15 UTC (rev 163415)
</span><span class="lines">@@ -33,6 +33,38 @@
</span><span class="cx"> 
</span><span class="cx"> class Decimal;
</span><span class="cx"> 
</span><ins>+class ImageWithScale {
+public:
+    ImageWithScale()
+        : m_imageURLStart(0)
+        , m_imageURLLength(0)
+        , m_scaleFactor(1)
+    {
+    }
+
+    ImageWithScale(unsigned start, unsigned length, float scaleFactor)
+        : m_imageURLStart(start)
+        , m_imageURLLength(length)
+        , m_scaleFactor(scaleFactor)
+    {
+    }
+
+    String imageURL(const String&amp; srcAttribute, const String&amp; srcsetAttribute) const
+    {
+        return m_imageURLLength ? srcsetAttribute.substringSharingImpl(m_imageURLStart, m_imageURLLength) : srcAttribute;
+    }
+
+    float scaleFactor() const
+    {
+        return m_scaleFactor;
+    }
+
+private:
+    unsigned m_imageURLStart;
+    unsigned m_imageURLLength;
+    float m_scaleFactor;
+};
+
</ins><span class="cx"> // Space characters as defined by the HTML specification.
</span><span class="cx"> bool isHTMLSpace(UChar);
</span><span class="cx"> bool isHTMLLineBreak(UChar);
</span><span class="lines">@@ -99,7 +131,7 @@
</span><span class="cx"> 
</span><span class="cx"> bool threadSafeMatch(const QualifiedName&amp;, const QualifiedName&amp;);
</span><span class="cx"> 
</span><del>-String bestFitSourceForImageAttributes(float deviceScaleFactor, const String&amp; srcAttribute, const String&amp; sourceSetAttribute);
</del><ins>+ImageWithScale bestFitSourceForImageAttributes(float deviceScaleFactor, const String&amp; srcAttribute, const String&amp; sourceSetAttribute);
</ins><span class="cx"> 
</span><span class="cx"> }
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceWebCorehtmlparserHTMLPreloadScannercpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/html/parser/HTMLPreloadScanner.cpp (163414 => 163415)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/html/parser/HTMLPreloadScanner.cpp        2014-02-05 00:08:40 UTC (rev 163414)
+++ trunk/Source/WebCore/html/parser/HTMLPreloadScanner.cpp        2014-02-05 00:09:15 UTC (rev 163415)
</span><span class="lines">@@ -104,7 +104,8 @@
</span><span class="cx"> 
</span><span class="cx">         // Resolve between src and srcSet if we have them.
</span><span class="cx">         if (!m_srcSetAttribute.isEmpty()) {
</span><del>-            String srcMatchingScale = bestFitSourceForImageAttributes(m_deviceScaleFactor, m_urlToLoad, m_srcSetAttribute);
</del><ins>+            ImageWithScale imageCandidate = bestFitSourceForImageAttributes(m_deviceScaleFactor, m_urlToLoad, m_srcSetAttribute);
+            String srcMatchingScale = imageCandidate.imageURL(m_urlToLoad, m_srcSetAttribute);
</ins><span class="cx">             setUrlToLoad(srcMatchingScale, true);
</span><span class="cx">         }
</span><span class="cx">     }
</span></span></pre></div>
<a id="trunkSourceWebCorerenderingRenderImagecpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/rendering/RenderImage.cpp (163414 => 163415)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/rendering/RenderImage.cpp        2014-02-05 00:08:40 UTC (rev 163414)
+++ trunk/Source/WebCore/rendering/RenderImage.cpp        2014-02-05 00:09:15 UTC (rev 163415)
</span><span class="lines">@@ -116,12 +116,13 @@
</span><span class="cx"> 
</span><span class="cx"> using namespace HTMLNames;
</span><span class="cx"> 
</span><del>-RenderImage::RenderImage(Element&amp; element, PassRef&lt;RenderStyle&gt; style, StyleImage* styleImage)
</del><ins>+RenderImage::RenderImage(Element&amp; element, PassRef&lt;RenderStyle&gt; style, StyleImage* styleImage, const float imageDevicePixelRatio)
</ins><span class="cx">     : RenderReplaced(element, std::move(style), IntSize())
</span><span class="cx">     , m_imageResource(styleImage ? std::make_unique&lt;RenderImageResourceStyleImage&gt;(*styleImage) : std::make_unique&lt;RenderImageResource&gt;())
</span><span class="cx">     , m_needsToSetSizeForAltText(false)
</span><span class="cx">     , m_didIncrementVisuallyNonEmptyPixelCount(false)
</span><span class="cx">     , m_isGeneratedContent(false)
</span><ins>+    , m_imageDevicePixelRatio(imageDevicePixelRatio)
</ins><span class="cx"> {
</span><span class="cx">     updateAltText();
</span><span class="cx">     imageResource().initialize(this);
</span><span class="lines">@@ -133,6 +134,7 @@
</span><span class="cx">     , m_needsToSetSizeForAltText(false)
</span><span class="cx">     , m_didIncrementVisuallyNonEmptyPixelCount(false)
</span><span class="cx">     , m_isGeneratedContent(false)
</span><ins>+    , m_imageDevicePixelRatio(1.0f)
</ins><span class="cx"> {
</span><span class="cx">     imageResource().initialize(this);
</span><span class="cx"> }
</span></span></pre></div>
<a id="trunkSourceWebCorerenderingRenderImageh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/rendering/RenderImage.h (163414 => 163415)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/rendering/RenderImage.h        2014-02-05 00:08:40 UTC (rev 163414)
+++ trunk/Source/WebCore/rendering/RenderImage.h        2014-02-05 00:09:15 UTC (rev 163415)
</span><span class="lines">@@ -35,7 +35,7 @@
</span><span class="cx"> 
</span><span class="cx"> class RenderImage : public RenderReplaced {
</span><span class="cx"> public:
</span><del>-    RenderImage(Element&amp;, PassRef&lt;RenderStyle&gt;, StyleImage* = nullptr);
</del><ins>+    RenderImage(Element&amp;, PassRef&lt;RenderStyle&gt;, StyleImage* = nullptr, const float = 1.0f);
</ins><span class="cx">     RenderImage(Document&amp;, PassRef&lt;RenderStyle&gt;, StyleImage* = nullptr);
</span><span class="cx">     virtual ~RenderImage();
</span><span class="cx"> 
</span><span class="lines">@@ -62,7 +62,10 @@
</span><span class="cx"> 
</span><span class="cx">     const String&amp; altText() const { return m_altText; }
</span><span class="cx">     void setAltText(const String&amp; altText) { m_altText = altText; }
</span><del>-    
</del><ins>+
+    inline void setImageDevicePixelRatio(float factor) { m_imageDevicePixelRatio = factor; }
+    float imageDevicePixelRatio() const { return m_imageDevicePixelRatio; }
+
</ins><span class="cx"> protected:
</span><span class="cx">     virtual bool needsPreferredWidthsRecalculation() const override final;
</span><span class="cx">     virtual RenderBox* embeddedContentBox() const override final;
</span><span class="lines">@@ -113,6 +116,7 @@
</span><span class="cx">     bool m_needsToSetSizeForAltText;
</span><span class="cx">     bool m_didIncrementVisuallyNonEmptyPixelCount;
</span><span class="cx">     bool m_isGeneratedContent;
</span><ins>+    float m_imageDevicePixelRatio;
</ins><span class="cx"> 
</span><span class="cx">     friend class RenderImageScaleObserver;
</span><span class="cx"> };
</span></span></pre></div>
<a id="trunkSourceWebCorerenderingRenderImageResourcecpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/rendering/RenderImageResource.cpp (163414 => 163415)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/rendering/RenderImageResource.cpp        2014-02-05 00:08:40 UTC (rev 163414)
+++ trunk/Source/WebCore/rendering/RenderImageResource.cpp        2014-02-05 00:09:15 UTC (rev 163415)
</span><span class="lines">@@ -31,6 +31,7 @@
</span><span class="cx"> #include &quot;CachedImage.h&quot;
</span><span class="cx"> #include &quot;Image.h&quot;
</span><span class="cx"> #include &quot;RenderElement.h&quot;
</span><ins>+#include &quot;RenderImage.h&quot;
</ins><span class="cx"> #include &quot;RenderImageResourceStyleImage.h&quot;
</span><span class="cx"> 
</span><span class="cx"> namespace WebCore {
</span><span class="lines">@@ -118,12 +119,22 @@
</span><span class="cx"> 
</span><span class="cx"> LayoutSize RenderImageResource::imageSize(float multiplier) const
</span><span class="cx"> {
</span><del>-    return m_cachedImage ? m_cachedImage-&gt;imageSizeForRenderer(m_renderer, multiplier) : LayoutSize();
</del><ins>+    return getImageSize(multiplier, CachedImage::UsedSize);
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> LayoutSize RenderImageResource::intrinsicSize(float multiplier) const
</span><span class="cx"> {
</span><del>-    return m_cachedImage ? m_cachedImage-&gt;imageSizeForRenderer(m_renderer, multiplier, CachedImage::IntrinsicSize) : LayoutSize();
</del><ins>+    return getImageSize(multiplier, CachedImage::IntrinsicSize);
</ins><span class="cx"> }
</span><span class="cx"> 
</span><ins>+LayoutSize RenderImageResource::getImageSize(float multiplier, CachedImage::SizeType type) const
+{
+    if (!m_cachedImage)
+        return LayoutSize();
+    LayoutSize size = m_cachedImage-&gt;imageSizeForRenderer(m_renderer, multiplier, type);
+    if (m_renderer &amp;&amp; m_renderer-&gt;isRenderImage())
+        size.scale(toRenderImage(m_renderer)-&gt;imageDevicePixelRatio());
+    return size;
+}
+
</ins><span class="cx"> } // namespace WebCore
</span></span></pre></div>
<a id="trunkSourceWebCorerenderingRenderImageResourceh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/rendering/RenderImageResource.h (163414 => 163415)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/rendering/RenderImageResource.h        2014-02-05 00:08:40 UTC (rev 163414)
+++ trunk/Source/WebCore/rendering/RenderImageResource.h        2014-02-05 00:09:15 UTC (rev 163415)
</span><span class="lines">@@ -26,6 +26,7 @@
</span><span class="cx"> #ifndef RenderImageResource_h
</span><span class="cx"> #define RenderImageResource_h
</span><span class="cx"> 
</span><ins>+#include &quot;CachedImage.h&quot;
</ins><span class="cx"> #include &quot;CachedResourceHandle.h&quot;
</span><span class="cx"> #include &quot;StyleImage.h&quot;
</span><span class="cx"> #include &lt;wtf/PassOwnPtr.h&gt;
</span><span class="lines">@@ -65,6 +66,9 @@
</span><span class="cx"> protected:
</span><span class="cx">     RenderElement* m_renderer;
</span><span class="cx">     CachedResourceHandle&lt;CachedImage&gt; m_cachedImage;
</span><ins>+
+private:
+    LayoutSize getImageSize(float multiplier, CachedImage::SizeType) const;
</ins><span class="cx"> };
</span><span class="cx"> 
</span><span class="cx"> } // namespace WebCore
</span></span></pre></div>
<a id="trunkSourceWebCorerenderingRenderReplacedcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/rendering/RenderReplaced.cpp (163414 => 163415)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/rendering/RenderReplaced.cpp        2014-02-05 00:08:40 UTC (rev 163414)
+++ trunk/Source/WebCore/rendering/RenderReplaced.cpp        2014-02-05 00:09:15 UTC (rev 163415)
</span><span class="lines">@@ -31,6 +31,7 @@
</span><span class="cx"> #include &quot;Page.h&quot;
</span><span class="cx"> #include &quot;RenderBlock.h&quot;
</span><span class="cx"> #include &quot;RenderFlowThread.h&quot;
</span><ins>+#include &quot;RenderImage.h&quot;
</ins><span class="cx"> #include &quot;RenderLayer.h&quot;
</span><span class="cx"> #include &quot;RenderRegion.h&quot;
</span><span class="cx"> #include &quot;RenderTheme.h&quot;
</span><span class="lines">@@ -270,8 +271,11 @@
</span><span class="cx">             ASSERT(!isPercentageIntrinsicSize);
</span><span class="cx"> 
</span><span class="cx">         // Handle zoom &amp; vertical writing modes here, as the embedded document doesn't know about them.
</span><del>-        if (!isPercentageIntrinsicSize)
</del><ins>+        if (!isPercentageIntrinsicSize) {
</ins><span class="cx">             intrinsicSize.scale(style().effectiveZoom());
</span><ins>+            if (isRenderImage())
+                intrinsicSize.scale(toRenderImage(this)-&gt;imageDevicePixelRatio());
+        }
</ins><span class="cx"> 
</span><span class="cx">         if (hasAspectRatio() &amp;&amp; isPercentageIntrinsicSize)
</span><span class="cx">             intrinsicRatio = 1;
</span></span></pre>
</div>
</div>

</body>
</html>