<!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>[205515] 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/205515">205515</a></dd>
<dt>Author</dt> <dd>cdumez@apple.com</dd>
<dt>Date</dt> <dd>2016-09-06 15:59:29 -0700 (Tue, 06 Sep 2016)</dd>
</dl>
<h3>Log Message</h3>
<pre>Align srcset attribute parsing with the HTML specification
https://bugs.webkit.org/show_bug.cgi?id=161636
Reviewed by Darin Adler.
LayoutTests/imported/w3c:
Rebaseline a couple of W3C tests now that more checks are passing.
* web-platform-tests/html/semantics/embedded-content/the-img-element/current-pixel-density/basic-expected.txt:
* web-platform-tests/html/semantics/embedded-content/the-img-element/srcset/parse-a-srcset-attribute-expected.txt:
Source/WebCore:
Align srcset attribute parsing with the HTML specification:
- https://html.spec.whatwg.org/#parse-a-srcset-attribute
The new behavior is also consistent with Firefox and Chrome
as all 3 browsers now pass 100% of the checks at:
- http://w3c-test.org/html/semantics/embedded-content/the-img-element/srcset/parse-a-srcset-attribute.html
No new tests, rebaselined existing tests.
* html/parser/HTMLParserIdioms.cpp:
(WebCore::parseValidHTMLNonNegativeIntegerInternal):
(WebCore::parseValidHTMLNonNegativeInteger):
(WebCore::parseValidHTMLFloatingPointNumberInternal):
(WebCore::parseValidHTMLFloatingPointNumber):
* html/parser/HTMLParserIdioms.h:
Add convenience for parsing *valid* HTML non-negative integers and
*valid* floating point number values.
* html/parser/HTMLSrcsetParser.cpp:
(WebCore::parseDescriptors):
- Use parseValidHTMLFloatingPointNumber() to parse density so that the value
is parsed as a valid HTML floating point number value, as per the spec.
- Use parseValidHTMLNonNegativeInteger() to parse width and height so that
the value is parsed as a valid HTML non-negative integer value, as per the
spec.
- Return false if descriptor does not have a h, w and x at the end as per:
https://html.spec.whatwg.org/#parse-a-srcset-attribute (step 13: Anything else)
- Return false if height is set but not width, as per:
https://html.spec.whatwg.org/#parse-a-srcset-attribute (step 14)
(WebCore::parseImageCandidatesFromSrcsetAttribute):
- Skip whitespace if URL does not end with a comma instead of assuming there is
a single space character, as per:
https://html.spec.whatwg.org/#parse-a-srcset-attribute (step 8. Otherwise 1.)
LayoutTests:
Re-sync fast/hidpi/image-srcset-invalid-descriptor.html with Blink.
* fast/hidpi/image-srcset-invalid-descriptor-expected.txt:
* fast/hidpi/image-srcset-invalid-descriptor.html:</pre>
<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkLayoutTestsChangeLog">trunk/LayoutTests/ChangeLog</a></li>
<li><a href="#trunkLayoutTestsfasthidpiimagesrcsetinvaliddescriptorexpectedtxt">trunk/LayoutTests/fast/hidpi/image-srcset-invalid-descriptor-expected.txt</a></li>
<li><a href="#trunkLayoutTestsfasthidpiimagesrcsetinvaliddescriptorhtml">trunk/LayoutTests/fast/hidpi/image-srcset-invalid-descriptor.html</a></li>
<li><a href="#trunkLayoutTestsimportedw3cChangeLog">trunk/LayoutTests/imported/w3c/ChangeLog</a></li>
<li><a href="#trunkLayoutTestsimportedw3cwebplatformtestshtmlsemanticsembeddedcontenttheimgelementcurrentpixeldensitybasicexpectedtxt">trunk/LayoutTests/imported/w3c/web-platform-tests/html/semantics/embedded-content/the-img-element/current-pixel-density/basic-expected.txt</a></li>
<li><a href="#trunkLayoutTestsimportedw3cwebplatformtestshtmlsemanticsembeddedcontenttheimgelementsrcsetparseasrcsetattributeexpectedtxt">trunk/LayoutTests/imported/w3c/web-platform-tests/html/semantics/embedded-content/the-img-element/srcset/parse-a-srcset-attribute-expected.txt</a></li>
<li><a href="#trunkSourceWebCoreChangeLog">trunk/Source/WebCore/ChangeLog</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="#trunkSourceWebCorehtmlparserHTMLSrcsetParsercpp">trunk/Source/WebCore/html/parser/HTMLSrcsetParser.cpp</a></li>
</ul>
</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkLayoutTestsChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/ChangeLog (205514 => 205515)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/ChangeLog        2016-09-06 22:19:51 UTC (rev 205514)
+++ trunk/LayoutTests/ChangeLog        2016-09-06 22:59:29 UTC (rev 205515)
</span><span class="lines">@@ -1,3 +1,15 @@
</span><ins>+2016-09-06 Chris Dumez <cdumez@apple.com>
+
+ Align srcset attribute parsing with the HTML specification
+ https://bugs.webkit.org/show_bug.cgi?id=161636
+
+ Reviewed by Darin Adler.
+
+ Re-sync fast/hidpi/image-srcset-invalid-descriptor.html with Blink.
+
+ * fast/hidpi/image-srcset-invalid-descriptor-expected.txt:
+ * fast/hidpi/image-srcset-invalid-descriptor.html:
+
</ins><span class="cx"> 2016-09-06 Ryan Haddad <ryanhaddad@apple.com>
</span><span class="cx">
</span><span class="cx"> Marking storage/indexeddb/objectstore-cursor.html as flaky on mac-wk2 debug.
</span></span></pre></div>
<a id="trunkLayoutTestsfasthidpiimagesrcsetinvaliddescriptorexpectedtxt"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/fast/hidpi/image-srcset-invalid-descriptor-expected.txt (205514 => 205515)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/fast/hidpi/image-srcset-invalid-descriptor-expected.txt        2016-09-06 22:19:51 UTC (rev 205514)
+++ trunk/LayoutTests/fast/hidpi/image-srcset-invalid-descriptor-expected.txt        2016-09-06 22:59:29 UTC (rev 205515)
</span><span class="lines">@@ -1,12 +1,17 @@
</span><del>-PASS document.getElementById("invalid_with_x").clientWidth is 100
-PASS document.getElementById("invalid_without_x").clientWidth is 100
-PASS document.getElementById("future_descriptor").clientWidth is 100
-PASS document.getElementById("future_descriptor_without_x").clientWidth is 100
-PASS document.getElementById("x_with_w_ignored").clientWidth is 200
-PASS document.getElementById("x_with_h_ignored").clientWidth is 200
</del><ins>+PASS document.getElementById("foo").clientWidth==200 is true
+PASS document.getElementById("foo2").clientWidth==200 is true
+PASS document.getElementById("foo3").clientWidth==200 is true
+PASS document.getElementById("foo4").clientWidth==200 is true
+PASS document.getElementById("foo5").clientWidth==200 is true
+PASS document.getElementById("foo6").clientWidth==200 is true
+PASS document.getElementById("foo7").clientWidth==200 is true
+PASS document.getElementById("foo8").clientWidth==200 is true
+PASS document.getElementById("foo9").clientWidth==200 is true
+PASS document.getElementById("foo10").clientWidth==200 is true
</ins><span class="cx"> PASS successfullyParsed is true
</span><span class="cx">
</span><span class="cx"> TEST COMPLETE
</span><del>-This test passes if the image below is a 100px blue square when the deviceScaleFactor is 1.
-It tests that even though the 1x resource contains many invalid descriptors, only the invalid descriptors are ignored (according to the spec).
</del><ins>+This test passes if the image below is a 200px green square when the deviceScaleFactor is 1.
+It tests that the 1x resource is ignored since it contains invalid descriptors.
+The 2x resource has an intrinsic width of 200px, since it's a 400px wide image at 2x DPR.
</ins><span class="cx">
</span></span></pre></div>
<a id="trunkLayoutTestsfasthidpiimagesrcsetinvaliddescriptorhtml"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/fast/hidpi/image-srcset-invalid-descriptor.html (205514 => 205515)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/fast/hidpi/image-srcset-invalid-descriptor.html        2016-09-06 22:19:51 UTC (rev 205514)
+++ trunk/LayoutTests/fast/hidpi/image-srcset-invalid-descriptor.html        2016-09-06 22:59:29 UTC (rev 205515)
</span><span class="lines">@@ -1,31 +1,33 @@
</span><del>-<html>
-<head>
</del><ins>+<!DOCTYPE html>
</ins><span class="cx"> <script>
</span><span class="cx"> window.targetScaleFactor = 1;
</span><span class="cx"> </script>
</span><del>-<script src="../../resources/srcset-helper.js"></script>
</del><ins>+<script src="resources/srcset-helper.js"></script>
</ins><span class="cx"> <script src="../../resources/js-test.js"></script>
</span><span class="cx"> <script>
</span><del>- function runTest() {
- shouldBe('document.getElementById("invalid_with_x").clientWidth', '100');
- shouldBe('document.getElementById("invalid_without_x").clientWidth', '100');
- shouldBe('document.getElementById("future_descriptor").clientWidth', '100');
- shouldBe('document.getElementById("future_descriptor_without_x").clientWidth', '100');
- shouldBe('document.getElementById("x_with_w_ignored").clientWidth', '200');
- shouldBe('document.getElementById("x_with_h_ignored").clientWidth', '200');
- }
</del><ins>+ addEventListener("load", function() {
+ shouldBeTrue('document.getElementById("foo").clientWidth==200');
+ shouldBeTrue('document.getElementById("foo2").clientWidth==200');
+ shouldBeTrue('document.getElementById("foo3").clientWidth==200');
+ shouldBeTrue('document.getElementById("foo4").clientWidth==200');
+ shouldBeTrue('document.getElementById("foo5").clientWidth==200');
+ shouldBeTrue('document.getElementById("foo6").clientWidth==200');
+ shouldBeTrue('document.getElementById("foo7").clientWidth==200');
+ shouldBeTrue('document.getElementById("foo8").clientWidth==200');
+ shouldBeTrue('document.getElementById("foo9").clientWidth==200');
+ shouldBeTrue('document.getElementById("foo10").clientWidth==200');
+ }, false);
</ins><span class="cx"> </script>
</span><del>-</head>
-
-<body id="body">
- <div>This test passes if the image below is a 100px blue square when the deviceScaleFactor is 1.</div>
- <div> It tests that even though the 1x resource contains many invalid descriptors,
- only the invalid descriptors are ignored (according to the spec).</div>
- <img id="invalid_with_x" src="" srcset="resources/blue-100-px-square.png 43q 1x dfs 3dd, resources/green-400-px-square.png 2x">
- <img id="invalid_without_x" src="" srcset="resources/blue-100-px-square.png 300q, resources/green-400-px-square.png 2x">
- <img id="future_descriptor" srcset=",resources/blue-100-px-square.png 1x future-descriptor(3x, 4h, whatever), resources/green-400-px-square.png 2x">
- <img id="future_descriptor_without_x" srcset=",resources/blue-100-px-square.png future-descriptor(3x, 4h, whatever), resources/green-400-px-square.png 2x">
- <img id="x_with_w_ignored" srcset=",resources/blue-100-px-square.png 1x 100w, resources/green-400-px-square.png 2x">
- <img id="x_with_h_ignored" srcset=",resources/blue-100-px-square.png 1x 100h, resources/green-400-px-square.png 2x">
-</body>
-</html>
</del><ins>+<div>This test passes if the image below is a 200px green square when the deviceScaleFactor is 1.</div>
+<div>It tests that the 1x resource is ignored since it contains invalid descriptors.</div>
+<div>The 2x resource has an intrinsic width of 200px, since it's a 400px wide image at 2x DPR.</div>
+<img id="foo" src="" srcset="resources/blue-100-px-square.png 43q 1x dfs 3dd, resources/green-400-px-square.png 2x">
+<img id="foo2" src="" srcset="resources/blue-100-px-square.png 300q, resources/green-400-px-square.png 2x">
+<img id="foo3" src="" srcset="resources/blue-100-px-square.png 100w 100w, resources/green-400-px-square.png 2x">
+<img id="foo4" src="" srcset="resources/blue-100-px-square.png 100h 100h, resources/green-400-px-square.png 2x">
+<img id="foo5" src="" srcset="resources/blue-100-px-square.png 100x 100h, resources/green-400-px-square.png 2x">
+<img id="foo6" src="" srcset="resources/blue-100-px-square.png 100x 100w, resources/green-400-px-square.png 2x">
+<img id="foo7" src="" srcset="resources/blue-100-px-square.png -100w, resources/green-400-px-square.png 2x">
+<img id="foo8" src="" srcset="resources/blue-100-px-square.png -100h, resources/green-400-px-square.png 2x">
+<img id="foo9" src="" srcset="resources/blue-100-px-square.png -1x, resources/green-400-px-square.png 2x">
+<img id="foo10" src="" srcset="resources/blue-100-px-square.png 100h, resources/green-400-px-square.png 2x">
</ins></span></pre></div>
<a id="trunkLayoutTestsimportedw3cChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/imported/w3c/ChangeLog (205514 => 205515)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/imported/w3c/ChangeLog        2016-09-06 22:19:51 UTC (rev 205514)
+++ trunk/LayoutTests/imported/w3c/ChangeLog        2016-09-06 22:59:29 UTC (rev 205515)
</span><span class="lines">@@ -1,3 +1,15 @@
</span><ins>+2016-09-06 Chris Dumez <cdumez@apple.com>
+
+ Align srcset attribute parsing with the HTML specification
+ https://bugs.webkit.org/show_bug.cgi?id=161636
+
+ Reviewed by Darin Adler.
+
+ Rebaseline a couple of W3C tests now that more checks are passing.
+
+ * web-platform-tests/html/semantics/embedded-content/the-img-element/current-pixel-density/basic-expected.txt:
+ * web-platform-tests/html/semantics/embedded-content/the-img-element/srcset/parse-a-srcset-attribute-expected.txt:
+
</ins><span class="cx"> 2016-09-06 Youenn Fablet <youenn@apple.com>
</span><span class="cx">
</span><span class="cx"> CachedResourceLoader is not taking into account fetch options to use or not cached resources
</span></span></pre></div>
<a id="trunkLayoutTestsimportedw3cwebplatformtestshtmlsemanticsembeddedcontenttheimgelementcurrentpixeldensitybasicexpectedtxt"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/imported/w3c/web-platform-tests/html/semantics/embedded-content/the-img-element/current-pixel-density/basic-expected.txt (205514 => 205515)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/imported/w3c/web-platform-tests/html/semantics/embedded-content/the-img-element/current-pixel-density/basic-expected.txt        2016-09-06 22:19:51 UTC (rev 205514)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/html/semantics/embedded-content/the-img-element/current-pixel-density/basic-expected.txt        2016-09-06 22:59:29 UTC (rev 205515)
</span><span class="lines">@@ -4,7 +4,7 @@
</span><span class="cx"> FAIL <img srcset="/images/green-256x256.png 1.6x" data-expect="160"> assert_equals: naturalWidth expected 160 but got 256
</span><span class="cx"> FAIL <img srcset="/images/green-256x256.png 2x" data-expect="128"> assert_equals: naturalWidth expected 128 but got 256
</span><span class="cx"> FAIL <img srcset="/images/green-256x256.png 10000x" data-expect="0"> assert_equals: naturalWidth expected 0 but got 256
</span><del>-FAIL <img srcset="/images/green-256x256.png 9e99999999999999999999999x" data-expect="0"> assert_equals: naturalWidth expected 0 but got 256
</del><ins>+PASS <img srcset="/images/green-256x256.png 9e99999999999999999999999x" data-expect="0">
</ins><span class="cx"> PASS <img srcset="/images/green-256x256.png 256w" sizes="256px" data-expect="256">
</span><span class="cx"> FAIL <img srcset="/images/green-256x256.png 512w" sizes="256px" data-expect="128"> assert_equals: naturalWidth expected 128 but got 256
</span><span class="cx"> FAIL <img srcset="/images/green-256x256.png 256w" sizes="512px" data-expect="512"> assert_equals: naturalWidth expected 512 but got 256
</span></span></pre></div>
<a id="trunkLayoutTestsimportedw3cwebplatformtestshtmlsemanticsembeddedcontenttheimgelementsrcsetparseasrcsetattributeexpectedtxt"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/imported/w3c/web-platform-tests/html/semantics/embedded-content/the-img-element/srcset/parse-a-srcset-attribute-expected.txt (205514 => 205515)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/imported/w3c/web-platform-tests/html/semantics/embedded-content/the-img-element/srcset/parse-a-srcset-attribute-expected.txt        2016-09-06 22:19:51 UTC (rev 205514)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/html/semantics/embedded-content/the-img-element/srcset/parse-a-srcset-attribute-expected.txt        2016-09-06 22:59:29 UTC (rev 205515)
</span><span class="lines">@@ -26,26 +26,26 @@
</span><span class="cx"> PASS "data:,a 1x"
</span><span class="cx"> PASS "data:,a 1x "
</span><span class="cx"> PASS "data:,a 1x,"
</span><del>-FAIL "data:,a ( , data:,b 1x, ), data:,c" assert_equals: expected "data:,c" but got "data:,a"
-FAIL "data:,a ((( , data:,b 1x, ), data:,c" assert_equals: expected "data:,c" but got "data:,a"
-FAIL "data:,a [ , data:,b 1x, ], data:,c" assert_equals: expected "data:,b" but got "data:,a"
-FAIL "data:,a { , data:,b 1x, }, data:,c" assert_equals: expected "data:,b" but got "data:,a"
-FAIL "data:,a \" , data:,b 1x, \", data:,c" assert_equals: expected "data:,b" but got "data:,a"
-FAIL "data:,a \\,data:;\,b, data:,c" assert_equals: expected "data:;\\,b" but got "data:,a"
</del><ins>+PASS "data:,a ( , data:,b 1x, ), data:,c"
+PASS "data:,a ((( , data:,b 1x, ), data:,c"
+PASS "data:,a [ , data:,b 1x, ], data:,c"
+PASS "data:,a { , data:,b 1x, }, data:,c"
+PASS "data:,a \" , data:,b 1x, \", data:,c"
+PASS "data:,a \\,data:;\,b, data:,c"
</ins><span class="cx"> PASS "data:,a, data:,b ("
</span><span class="cx"> PASS "data:,a, data:,b ( "
</span><span class="cx"> PASS "data:,a, data:,b (,"
</span><span class="cx"> PASS "data:,a, data:,b (x"
</span><span class="cx"> PASS "data:,a, data:,b ()"
</span><del>-FAIL "data:,a (, data:,b" assert_equals: expected "" but got "data:,a"
-FAIL "data:,a /*, data:,b, data:,c */" assert_equals: expected "data:,b" but got "data:,a"
-FAIL "data:,a //, data:,b" assert_equals: expected "data:,b" but got "data:,a"
-FAIL "data:,a foo" assert_equals: expected "" but got "data:,a"
-FAIL "data:,a foo foo" assert_equals: expected "" but got "data:,a"
-FAIL "data:,a foo 1x" assert_equals: expected "" but got "data:,a"
-FAIL "data:,a foo 1x foo" assert_equals: expected "" but got "data:,a"
-FAIL "data:,a foo 1w" assert_equals: expected "" but got "data:,a"
-FAIL "data:,a foo 1w foo" assert_equals: expected "" but got "data:,a"
</del><ins>+PASS "data:,a (, data:,b"
+PASS "data:,a /*, data:,b, data:,c */"
+PASS "data:,a //, data:,b"
+PASS "data:,a foo"
+PASS "data:,a foo foo"
+PASS "data:,a foo 1x"
+PASS "data:,a foo 1x foo"
+PASS "data:,a foo 1w"
+PASS "data:,a foo 1w foo"
</ins><span class="cx"> PASS "data:,a 1x 1x"
</span><span class="cx"> PASS "data:,a 1w 1w"
</span><span class="cx"> PASS "data:,a 1w 1x"
</span><span class="lines">@@ -57,22 +57,22 @@
</span><span class="cx"> PASS "data:,a 1h 1w 1x"
</span><span class="cx"> PASS "data:,a 1x 1w 1h"
</span><span class="cx"> PASS "data:,a 1w"
</span><del>-FAIL "data:,a 1h" assert_equals: expected "" but got "data:,a"
-FAIL "data:,a 1h foo" assert_equals: expected "" but got "data:,a"
-FAIL "data:,a foo 1h" assert_equals: expected "" but got "data:,a"
</del><ins>+PASS "data:,a 1h"
+PASS "data:,a 1h foo"
+PASS "data:,a foo 1h"
</ins><span class="cx"> PASS "data:,a 0w"
</span><span class="cx"> PASS "data:,a -1w"
</span><span class="cx"> PASS "data:,a 1w -1w"
</span><del>-FAIL "data:,a 1.0w" assert_equals: expected "" but got "data:,a"
</del><ins>+PASS "data:,a 1.0w"
</ins><span class="cx"> PASS "data:,a 1w 1.0w"
</span><del>-FAIL "data:,a 1e0w" assert_equals: expected "" but got "data:,a"
</del><ins>+PASS "data:,a 1e0w"
</ins><span class="cx"> PASS "data:,a 1w 1e0w"
</span><del>-FAIL "data:,a 1www" assert_equals: expected "" but got "data:,a"
</del><ins>+PASS "data:,a 1www"
</ins><span class="cx"> PASS "data:,a 1w 1www"
</span><del>-FAIL "data:,a +1w" assert_equals: expected "" but got "data:,a"
</del><ins>+PASS "data:,a +1w"
</ins><span class="cx"> PASS "data:,a 1w +1w"
</span><del>-FAIL "data:,a 1W" assert_equals: expected "" but got "data:,a"
-FAIL "data:,a 1w 1W" assert_equals: expected "" but got "data:,a"
</del><ins>+PASS "data:,a 1W"
+PASS "data:,a 1w 1W"
</ins><span class="cx"> PASS "data:,a Infinityw"
</span><span class="cx"> PASS "data:,a 1w Infinityw"
</span><span class="cx"> PASS "data:,a NaNw"
</span><span class="lines">@@ -79,45 +79,45 @@
</span><span class="cx"> PASS "data:,a 1w NaNw"
</span><span class="cx"> PASS "data:,a 0x1w"
</span><span class="cx"> PASS "data:,a 0X1w"
</span><del>-FAIL "data:,a 1\x01w" (trailing U+0001) assert_equals: expected "" but got "data:,a"
-FAIL "data:,a 1 w" (trailing U+00A0) assert_equals: expected "" but got "data:,a"
-FAIL "data:,a 1 w" (trailing U+1680) assert_equals: expected "" but got "data:,a"
-FAIL "data:,a 1 w" (trailing U+2000) assert_equals: expected "" but got "data:,a"
-FAIL "data:,a 1 w" (trailing U+2001) assert_equals: expected "" but got "data:,a"
-FAIL "data:,a 1 w" (trailing U+2002) assert_equals: expected "" but got "data:,a"
-FAIL "data:,a 1 w" (trailing U+2003) assert_equals: expected "" but got "data:,a"
-FAIL "data:,a 1 w" (trailing U+2004) assert_equals: expected "" but got "data:,a"
-FAIL "data:,a 1 w" (trailing U+2005) assert_equals: expected "" but got "data:,a"
-FAIL "data:,a 1 w" (trailing U+2006) assert_equals: expected "" but got "data:,a"
-FAIL "data:,a 1 w" (trailing U+2007) assert_equals: expected "" but got "data:,a"
-FAIL "data:,a 1 w" (trailing U+2008) assert_equals: expected "" but got "data:,a"
-FAIL "data:,a 1 w" (trailing U+2009) assert_equals: expected "" but got "data:,a"
-FAIL "data:,a 1 w" (trailing U+200A) assert_equals: expected "" but got "data:,a"
-FAIL "data:,a 1w" (trailing U+200C) assert_equals: expected "" but got "data:,a"
-FAIL "data:,a 1w" (trailing U+200D) assert_equals: expected "" but got "data:,a"
-FAIL "data:,a 1 w" (trailing U+202F) assert_equals: expected "" but got "data:,a"
-FAIL "data:,a 1 w" (trailing U+205F) assert_equals: expected "" but got "data:,a"
-FAIL "data:,a 1 w" (trailing U+3000) assert_equals: expected "" but got "data:,a"
-FAIL "data:,a 1w" (trailing U+FEFF) assert_equals: expected "" but got "data:,a"
</del><ins>+PASS "data:,a 1\x01w" (trailing U+0001)
+PASS "data:,a 1 w" (trailing U+00A0)
+PASS "data:,a 1 w" (trailing U+1680)
+PASS "data:,a 1 w" (trailing U+2000)
+PASS "data:,a 1 w" (trailing U+2001)
+PASS "data:,a 1 w" (trailing U+2002)
+PASS "data:,a 1 w" (trailing U+2003)
+PASS "data:,a 1 w" (trailing U+2004)
+PASS "data:,a 1 w" (trailing U+2005)
+PASS "data:,a 1 w" (trailing U+2006)
+PASS "data:,a 1 w" (trailing U+2007)
+PASS "data:,a 1 w" (trailing U+2008)
+PASS "data:,a 1 w" (trailing U+2009)
+PASS "data:,a 1 w" (trailing U+200A)
+PASS "data:,a 1w" (trailing U+200C)
+PASS "data:,a 1w" (trailing U+200D)
+PASS "data:,a 1 w" (trailing U+202F)
+PASS "data:,a 1 w" (trailing U+205F)
+PASS "data:,a 1 w" (trailing U+3000)
+PASS "data:,a 1w" (trailing U+FEFF)
</ins><span class="cx"> PASS "data:,a \x011w" (leading U+0001)
</span><span class="cx"> PASS "data:,a 1w" (leading U+00A0)
</span><del>-FAIL "data:,a 1w" (leading U+1680) assert_equals: expected "" but got "data:,a"
-FAIL "data:,a 1w" (leading U+2000) assert_equals: expected "" but got "data:,a"
-FAIL "data:,a 1w" (leading U+2001) assert_equals: expected "" but got "data:,a"
-FAIL "data:,a 1w" (leading U+2002) assert_equals: expected "" but got "data:,a"
-FAIL "data:,a 1w" (leading U+2003) assert_equals: expected "" but got "data:,a"
-FAIL "data:,a 1w" (leading U+2004) assert_equals: expected "" but got "data:,a"
-FAIL "data:,a 1w" (leading U+2005) assert_equals: expected "" but got "data:,a"
-FAIL "data:,a 1w" (leading U+2006) assert_equals: expected "" but got "data:,a"
-FAIL "data:,a 1w" (leading U+2007) assert_equals: expected "" but got "data:,a"
-FAIL "data:,a 1w" (leading U+2008) assert_equals: expected "" but got "data:,a"
-FAIL "data:,a 1w" (leading U+2009) assert_equals: expected "" but got "data:,a"
-FAIL "data:,a 1w" (leading U+200A) assert_equals: expected "" but got "data:,a"
</del><ins>+PASS "data:,a 1w" (leading U+1680)
+PASS "data:,a 1w" (leading U+2000)
+PASS "data:,a 1w" (leading U+2001)
+PASS "data:,a 1w" (leading U+2002)
+PASS "data:,a 1w" (leading U+2003)
+PASS "data:,a 1w" (leading U+2004)
+PASS "data:,a 1w" (leading U+2005)
+PASS "data:,a 1w" (leading U+2006)
+PASS "data:,a 1w" (leading U+2007)
+PASS "data:,a 1w" (leading U+2008)
+PASS "data:,a 1w" (leading U+2009)
+PASS "data:,a 1w" (leading U+200A)
</ins><span class="cx"> PASS "data:,a 1w" (leading U+200C)
</span><span class="cx"> PASS "data:,a 1w" (leading U+200D)
</span><span class="cx"> PASS "data:,a 1w" (leading U+202F)
</span><del>-FAIL "data:,a 1w" (leading U+205F) assert_equals: expected "" but got "data:,a"
-FAIL "data:,a 1w" (leading U+3000) assert_equals: expected "" but got "data:,a"
</del><ins>+PASS "data:,a 1w" (leading U+205F)
+PASS "data:,a 1w" (leading U+3000)
</ins><span class="cx"> PASS "data:,a 1w" (leading U+FEFF)
</span><span class="cx"> PASS "data:,a 0x"
</span><span class="cx"> PASS "data:,a -0x"
</span><span class="lines">@@ -131,7 +131,7 @@
</span><span class="cx"> PASS "data:,a -x"
</span><span class="cx"> PASS "data:,a .x"
</span><span class="cx"> PASS "data:,a -.x"
</span><del>-FAIL "data:,a 1.x" assert_equals: expected "" but got "data:,a"
</del><ins>+PASS "data:,a 1.x"
</ins><span class="cx"> PASS "data:,a .5x"
</span><span class="cx"> PASS "data:,a .5e1x"
</span><span class="cx"> PASS "data:,a 1x 1.5e1x"
</span><span class="lines">@@ -138,8 +138,8 @@
</span><span class="cx"> PASS "data:,a 1x 1e1.5x"
</span><span class="cx"> PASS "data:,a 1.0x"
</span><span class="cx"> PASS "data:,a 1x 1.0x"
</span><del>-FAIL "data:,a +1x" assert_equals: expected "" but got "data:,a"
-FAIL "data:,a 1X" assert_equals: expected "" but got "data:,a"
</del><ins>+PASS "data:,a +1x"
+PASS "data:,a 1X"
</ins><span class="cx"> PASS "data:,a Infinityx"
</span><span class="cx"> PASS "data:,a NaNx"
</span><span class="cx"> PASS "data:,a 0x1x"
</span><span class="lines">@@ -186,53 +186,53 @@
</span><span class="cx"> PASS "data:,a 1x" (leading U+FEFF)
</span><span class="cx"> PASS "data:,a 1w 0h"
</span><span class="cx"> PASS "data:,a 1w -1h"
</span><del>-FAIL "data:,a 1w 1.0h" assert_equals: expected "" but got "data:,a"
-FAIL "data:,a 1w 1e0h" assert_equals: expected "" but got "data:,a"
-FAIL "data:,a 1w 1hhh" assert_equals: expected "" but got "data:,a"
-FAIL "data:,a 1w +1h" assert_equals: expected "" but got "data:,a"
-FAIL "data:,a 1w 1H" assert_equals: expected "" but got "data:,a"
</del><ins>+PASS "data:,a 1w 1.0h"
+PASS "data:,a 1w 1e0h"
+PASS "data:,a 1w 1hhh"
+PASS "data:,a 1w +1h"
+PASS "data:,a 1w 1H"
</ins><span class="cx"> PASS "data:,a 1w Infinityh"
</span><span class="cx"> PASS "data:,a 1w NaNh"
</span><span class="cx"> PASS "data:,a 0x1h"
</span><span class="cx"> PASS "data:,a 0X1h"
</span><del>-FAIL "data:,a 1w 1\x01h" (trailing U+0001) assert_equals: expected "" but got "data:,a"
-FAIL "data:,a 1w 1 h" (trailing U+00A0) assert_equals: expected "" but got "data:,a"
-FAIL "data:,a 1w 1 h" (trailing U+1680) assert_equals: expected "" but got "data:,a"
-FAIL "data:,a 1w 1 h" (trailing U+2000) assert_equals: expected "" but got "data:,a"
-FAIL "data:,a 1w 1 h" (trailing U+2001) assert_equals: expected "" but got "data:,a"
-FAIL "data:,a 1w 1 h" (trailing U+2002) assert_equals: expected "" but got "data:,a"
-FAIL "data:,a 1w 1 h" (trailing U+2003) assert_equals: expected "" but got "data:,a"
-FAIL "data:,a 1w 1 h" (trailing U+2004) assert_equals: expected "" but got "data:,a"
-FAIL "data:,a 1w 1 h" (trailing U+2005) assert_equals: expected "" but got "data:,a"
-FAIL "data:,a 1w 1 h" (trailing U+2006) assert_equals: expected "" but got "data:,a"
-FAIL "data:,a 1w 1 h" (trailing U+2007) assert_equals: expected "" but got "data:,a"
-FAIL "data:,a 1w 1 h" (trailing U+2008) assert_equals: expected "" but got "data:,a"
-FAIL "data:,a 1w 1 h" (trailing U+2009) assert_equals: expected "" but got "data:,a"
-FAIL "data:,a 1w 1 h" (trailing U+200A) assert_equals: expected "" but got "data:,a"
-FAIL "data:,a 1w 1h" (trailing U+200C) assert_equals: expected "" but got "data:,a"
-FAIL "data:,a 1w 1h" (trailing U+200D) assert_equals: expected "" but got "data:,a"
-FAIL "data:,a 1w 1 h" (trailing U+202F) assert_equals: expected "" but got "data:,a"
-FAIL "data:,a 1w 1 h" (trailing U+205F) assert_equals: expected "" but got "data:,a"
-FAIL "data:,a 1w 1 h" (trailing U+3000) assert_equals: expected "" but got "data:,a"
-FAIL "data:,a 1w 1h" (trailing U+FEFF) assert_equals: expected "" but got "data:,a"
</del><ins>+PASS "data:,a 1w 1\x01h" (trailing U+0001)
+PASS "data:,a 1w 1 h" (trailing U+00A0)
+PASS "data:,a 1w 1 h" (trailing U+1680)
+PASS "data:,a 1w 1 h" (trailing U+2000)
+PASS "data:,a 1w 1 h" (trailing U+2001)
+PASS "data:,a 1w 1 h" (trailing U+2002)
+PASS "data:,a 1w 1 h" (trailing U+2003)
+PASS "data:,a 1w 1 h" (trailing U+2004)
+PASS "data:,a 1w 1 h" (trailing U+2005)
+PASS "data:,a 1w 1 h" (trailing U+2006)
+PASS "data:,a 1w 1 h" (trailing U+2007)
+PASS "data:,a 1w 1 h" (trailing U+2008)
+PASS "data:,a 1w 1 h" (trailing U+2009)
+PASS "data:,a 1w 1 h" (trailing U+200A)
+PASS "data:,a 1w 1h" (trailing U+200C)
+PASS "data:,a 1w 1h" (trailing U+200D)
+PASS "data:,a 1w 1 h" (trailing U+202F)
+PASS "data:,a 1w 1 h" (trailing U+205F)
+PASS "data:,a 1w 1 h" (trailing U+3000)
+PASS "data:,a 1w 1h" (trailing U+FEFF)
</ins><span class="cx"> PASS "data:,a 1w \x011h" (leading U+0001)
</span><span class="cx"> PASS "data:,a 1w 1h" (leading U+00A0)
</span><del>-FAIL "data:,a 1w 1h" (leading U+1680) assert_equals: expected "" but got "data:,a"
-FAIL "data:,a 1w 1h" (leading U+2000) assert_equals: expected "" but got "data:,a"
-FAIL "data:,a 1w 1h" (leading U+2001) assert_equals: expected "" but got "data:,a"
-FAIL "data:,a 1w 1h" (leading U+2002) assert_equals: expected "" but got "data:,a"
-FAIL "data:,a 1w 1h" (leading U+2003) assert_equals: expected "" but got "data:,a"
-FAIL "data:,a 1w 1h" (leading U+2004) assert_equals: expected "" but got "data:,a"
-FAIL "data:,a 1w 1h" (leading U+2005) assert_equals: expected "" but got "data:,a"
-FAIL "data:,a 1w 1h" (leading U+2006) assert_equals: expected "" but got "data:,a"
-FAIL "data:,a 1w 1h" (leading U+2007) assert_equals: expected "" but got "data:,a"
-FAIL "data:,a 1w 1h" (leading U+2008) assert_equals: expected "" but got "data:,a"
-FAIL "data:,a 1w 1h" (leading U+2009) assert_equals: expected "" but got "data:,a"
-FAIL "data:,a 1w 1h" (leading U+200A) assert_equals: expected "" but got "data:,a"
</del><ins>+PASS "data:,a 1w 1h" (leading U+1680)
+PASS "data:,a 1w 1h" (leading U+2000)
+PASS "data:,a 1w 1h" (leading U+2001)
+PASS "data:,a 1w 1h" (leading U+2002)
+PASS "data:,a 1w 1h" (leading U+2003)
+PASS "data:,a 1w 1h" (leading U+2004)
+PASS "data:,a 1w 1h" (leading U+2005)
+PASS "data:,a 1w 1h" (leading U+2006)
+PASS "data:,a 1w 1h" (leading U+2007)
+PASS "data:,a 1w 1h" (leading U+2008)
+PASS "data:,a 1w 1h" (leading U+2009)
+PASS "data:,a 1w 1h" (leading U+200A)
</ins><span class="cx"> PASS "data:,a 1w 1h" (leading U+200C)
</span><span class="cx"> PASS "data:,a 1w 1h" (leading U+200D)
</span><span class="cx"> PASS "data:,a 1w 1h" (leading U+202F)
</span><del>-FAIL "data:,a 1w 1h" (leading U+205F) assert_equals: expected "" but got "data:,a"
-FAIL "data:,a 1w 1h" (leading U+3000) assert_equals: expected "" but got "data:,a"
</del><ins>+PASS "data:,a 1w 1h" (leading U+205F)
+PASS "data:,a 1w 1h" (leading U+3000)
</ins><span class="cx"> PASS "data:,a 1w 1h" (leading U+FEFF)
</span><span class="cx">
</span></span></pre></div>
<a id="trunkSourceWebCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/ChangeLog (205514 => 205515)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/ChangeLog        2016-09-06 22:19:51 UTC (rev 205514)
+++ trunk/Source/WebCore/ChangeLog        2016-09-06 22:59:29 UTC (rev 205515)
</span><span class="lines">@@ -1,3 +1,45 @@
</span><ins>+2016-09-06 Chris Dumez <cdumez@apple.com>
+
+ Align srcset attribute parsing with the HTML specification
+ https://bugs.webkit.org/show_bug.cgi?id=161636
+
+ Reviewed by Darin Adler.
+
+ Align srcset attribute parsing with the HTML specification:
+ - https://html.spec.whatwg.org/#parse-a-srcset-attribute
+
+ The new behavior is also consistent with Firefox and Chrome
+ as all 3 browsers now pass 100% of the checks at:
+ - http://w3c-test.org/html/semantics/embedded-content/the-img-element/srcset/parse-a-srcset-attribute.html
+
+ No new tests, rebaselined existing tests.
+
+ * html/parser/HTMLParserIdioms.cpp:
+ (WebCore::parseValidHTMLNonNegativeIntegerInternal):
+ (WebCore::parseValidHTMLNonNegativeInteger):
+ (WebCore::parseValidHTMLFloatingPointNumberInternal):
+ (WebCore::parseValidHTMLFloatingPointNumber):
+ * html/parser/HTMLParserIdioms.h:
+ Add convenience for parsing *valid* HTML non-negative integers and
+ *valid* floating point number values.
+
+ * html/parser/HTMLSrcsetParser.cpp:
+ (WebCore::parseDescriptors):
+ - Use parseValidHTMLFloatingPointNumber() to parse density so that the value
+ is parsed as a valid HTML floating point number value, as per the spec.
+ - Use parseValidHTMLNonNegativeInteger() to parse width and height so that
+ the value is parsed as a valid HTML non-negative integer value, as per the
+ spec.
+ - Return false if descriptor does not have a h, w and x at the end as per:
+ https://html.spec.whatwg.org/#parse-a-srcset-attribute (step 13: Anything else)
+ - Return false if height is set but not width, as per:
+ https://html.spec.whatwg.org/#parse-a-srcset-attribute (step 14)
+
+ (WebCore::parseImageCandidatesFromSrcsetAttribute):
+ - Skip whitespace if URL does not end with a comma instead of assuming there is
+ a single space character, as per:
+ https://html.spec.whatwg.org/#parse-a-srcset-attribute (step 8. Otherwise 1.)
+
</ins><span class="cx"> 2016-09-06 Fujii Hironori <Hironori.Fujii@sony.com>
</span><span class="cx">
</span><span class="cx"> [CMake] Decouple generating bindings of WebCore and WebCoreTestSupport
</span></span></pre></div>
<a id="trunkSourceWebCorehtmlparserHTMLParserIdiomscpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/html/parser/HTMLParserIdioms.cpp (205514 => 205515)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/html/parser/HTMLParserIdioms.cpp        2016-09-06 22:19:51 UTC (rev 205514)
+++ trunk/Source/WebCore/html/parser/HTMLParserIdioms.cpp        2016-09-06 22:59:29 UTC (rev 205515)
</span><span class="lines">@@ -216,6 +216,67 @@
</span><span class="cx"> return signedValue;
</span><span class="cx"> }
</span><span class="cx">
</span><ins>+template <typename CharacterType>
+static Optional<int> parseValidHTMLNonNegativeIntegerInternal(const CharacterType* position, const CharacterType* end)
+{
+ // A string is a valid non-negative integer if it consists of one or more ASCII digits.
+ for (auto* c = position; c < end; ++c) {
+ if (!isASCIIDigit(*c))
+ return Nullopt;
+ }
+
+ Optional<int> signedValue = parseHTMLIntegerInternal(position, end);
+ if (!signedValue || signedValue.value() < 0)
+ return Nullopt;
+
+ return signedValue;
+}
+
+// https://html.spec.whatwg.org/#valid-non-negative-integer
+Optional<int> parseValidHTMLNonNegativeInteger(StringView input)
+{
+ if (input.isEmpty())
+ return Nullopt;
+
+ if (LIKELY(input.is8Bit())) {
+ auto* start = input.characters8();
+ return parseValidHTMLNonNegativeIntegerInternal(start, start + input.length());
+ }
+
+ auto* start = input.characters16();
+ return parseValidHTMLNonNegativeIntegerInternal(start, start + input.length());
+}
+
+template <typename CharacterType>
+static Optional<double> parseValidHTMLFloatingPointNumberInternal(const CharacterType* position, size_t length)
+{
+ ASSERT(length > 0);
+
+ // parseDouble() allows the string to start with a '+' or to end with a '.' but those
+ // are not valid floating point numbers as per HTML.
+ if (*position == '+' || *(position + length - 1) == '.')
+ return Nullopt;
+
+ size_t parsedLength = 0;
+ double number = parseDouble(position, length, parsedLength);
+ return parsedLength == length && std::isfinite(number) ? number : Optional<double>();
+}
+
+// https://html.spec.whatwg.org/#valid-floating-point-number
+Optional<double> parseValidHTMLFloatingPointNumber(StringView input)
+{
+ if (input.isEmpty())
+ return Nullopt;
+
+ if (LIKELY(input.is8Bit())) {
+ auto* start = input.characters8();
+ return parseValidHTMLFloatingPointNumberInternal(start, input.length());
+ }
+
+ auto* start = input.characters16();
+ return parseValidHTMLFloatingPointNumberInternal(start, input.length());
+}
+
</ins><span class="cx"> static inline bool isHTMLSpaceOrDelimiter(UChar character)
</span><span class="cx"> {
</span><span class="cx"> return isHTMLSpace(character) || character == ',' || character == ';';
</span></span></pre></div>
<a id="trunkSourceWebCorehtmlparserHTMLParserIdiomsh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/html/parser/HTMLParserIdioms.h (205514 => 205515)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/html/parser/HTMLParserIdioms.h        2016-09-06 22:19:51 UTC (rev 205514)
+++ trunk/Source/WebCore/html/parser/HTMLParserIdioms.h        2016-09-06 22:59:29 UTC (rev 205515)
</span><span class="lines">@@ -67,6 +67,12 @@
</span><span class="cx"> // http://www.whatwg.org/specs/web-apps/current-work/#rules-for-parsing-non-negative-integers
</span><span class="cx"> WEBCORE_EXPORT Optional<int> parseHTMLNonNegativeInteger(const String&);
</span><span class="cx">
</span><ins>+// https://html.spec.whatwg.org/#valid-non-negative-integer
+Optional<int> parseValidHTMLNonNegativeInteger(StringView);
+
+// https://html.spec.whatwg.org/#valid-floating-point-number
+Optional<double> parseValidHTMLFloatingPointNumber(StringView);
+
</ins><span class="cx"> // https://html.spec.whatwg.org/multipage/infrastructure.html#rules-for-parsing-floating-point-number-values
</span><span class="cx"> Vector<double> parseHTMLListOfOfFloatingPointNumberValues(StringView);
</span><span class="cx">
</span></span></pre></div>
<a id="trunkSourceWebCorehtmlparserHTMLSrcsetParsercpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/html/parser/HTMLSrcsetParser.cpp (205514 => 205515)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/html/parser/HTMLSrcsetParser.cpp        2016-09-06 22:19:51 UTC (rev 205514)
+++ trunk/Source/WebCore/html/parser/HTMLSrcsetParser.cpp        2016-09-06 22:59:29 UTC (rev 205515)
</span><span class="lines">@@ -131,33 +131,33 @@
</span><span class="cx"> unsigned descriptorCharPosition = descriptor.length() - 1;
</span><span class="cx"> UChar descriptorChar = descriptor[descriptorCharPosition];
</span><span class="cx"> descriptor = descriptor.substring(0, descriptorCharPosition);
</span><del>- bool isValid = false;
</del><span class="cx"> if (descriptorChar == 'x') {
</span><span class="cx"> if (result.hasDensity() || result.hasHeight() || result.hasWidth())
</span><span class="cx"> return false;
</span><del>- float density = descriptor.toFloat(isValid);
- if (!isValid || density < 0)
</del><ins>+ Optional<double> density = parseValidHTMLFloatingPointNumber(descriptor);
+ if (!density || density.value() < 0)
</ins><span class="cx"> return false;
</span><del>- result.setDensity(density);
</del><ins>+ result.setDensity(density.value());
</ins><span class="cx"> } else if (descriptorChar == 'w') {
</span><span class="cx"> if (result.hasDensity() || result.hasWidth())
</span><span class="cx"> return false;
</span><del>- int resourceWidth = descriptor.toInt(isValid);
- if (!isValid || resourceWidth <= 0)
</del><ins>+ Optional<int> resourceWidth = parseValidHTMLNonNegativeInteger(descriptor);
+ if (!resourceWidth || resourceWidth.value() <= 0)
</ins><span class="cx"> return false;
</span><del>- result.setResourceWidth(resourceWidth);
</del><ins>+ result.setResourceWidth(resourceWidth.value());
</ins><span class="cx"> } else if (descriptorChar == 'h') {
</span><span class="cx"> // This is here only for future compat purposes.
</span><span class="cx"> // The value of the 'h' descriptor is not used.
</span><span class="cx"> if (result.hasDensity() || result.hasHeight())
</span><span class="cx"> return false;
</span><del>- int resourceHeight = descriptor.toInt(isValid);
- if (!isValid || resourceHeight <= 0)
</del><ins>+ Optional<int> resourceHeight = parseValidHTMLNonNegativeInteger(descriptor);
+ if (!resourceHeight || resourceHeight.value() <= 0)
</ins><span class="cx"> return false;
</span><del>- result.setResourceHeight(resourceHeight);
- }
</del><ins>+ result.setResourceHeight(resourceHeight.value());
+ } else
+ return false;
</ins><span class="cx"> }
</span><del>- return true;
</del><ins>+ return !result.hasHeight() || result.hasWidth();
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> // http://picture.responsiveimages.org/#parse-srcset-attr
</span><span class="lines">@@ -193,9 +193,7 @@
</span><span class="cx"> if (imageURLStart == imageURLEnd)
</span><span class="cx"> continue;
</span><span class="cx"> } else {
</span><del>- // Advancing position here (contrary to spec) to avoid an useless extra state machine step.
- // Filed a spec bug: https://github.com/ResponsiveImagesCG/picture-element/issues/189
- ++position;
</del><ins>+ skipWhile<CharType, isHTMLSpace<CharType>>(position, attributeEnd);
</ins><span class="cx"> Vector<StringView> descriptorTokens;
</span><span class="cx"> tokenizeDescriptors(position, attributeEnd, descriptorTokens);
</span><span class="cx"> // Contrary to spec language - descriptor parsing happens on each candidate.
</span></span></pre>
</div>
</div>
</body>
</html>