Changeset 227295 in webkit
- Timestamp:
- Jan 22, 2018 8:07:13 AM (6 years ago)
- Location:
- trunk
- Files:
-
- 57 added
- 1 deleted
- 21 edited
- 2 copied
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r227280 r227295 1 2018-01-22 Chris Nardi <csnardi1@gmail.com> 2 3 Parse calc() in CSS media queries 4 https://bugs.webkit.org/show_bug.cgi?id=181716 5 6 Imported CSS mediaqueries tests from WPT, deleting our (old) copy of one test. Updated 7 expectations. 8 9 Reviewed by Antti Koivisto. 10 11 * TestExpectations: 12 * fast/dom/HTMLImageElement/sizes/image-sizes-w3c-1-expected.txt: 13 * fast/dom/HTMLImageElement/sizes/image-sizes-w3c-2-expected.txt: 14 * fast/dom/HTMLImageElement/sizes/image-sizes-w3c-3-expected.txt: 15 * fast/dom/HTMLImageElement/sizes/image-sizes-w3c-4-expected.txt: 16 * fast/media/w3c/README: Removed. 17 * fast/media/w3c/test_media_queries-expected.txt: Removed. 18 * platform/ios/TestExpectations: 19 * platform/ios/fast/dom/HTMLImageElement/sizes/image-sizes-w3c-1-expected.txt: 20 * platform/ios/fast/dom/HTMLImageElement/sizes/image-sizes-w3c-2-expected.txt: 21 * platform/ios/fast/dom/HTMLImageElement/sizes/image-sizes-w3c-3-expected.txt: 22 * platform/ios/fast/dom/HTMLImageElement/sizes/image-sizes-w3c-4-expected.txt: 23 1 24 2018-01-19 Ryosuke Niwa <rniwa@webkit.org> 2 25 -
trunk/LayoutTests/TestExpectations
r227264 r227295 517 517 imported/w3c/web-platform-tests/css/selectors4/selector-read-write-type-change-002.html [ ImageOnlyFailure ] 518 518 imported/w3c/web-platform-tests/css/selectors4/selector-required-type-change-002.html [ ImageOnlyFailure ] 519 520 # https://github.com/w3c/web-platform-tests/issues/8547 521 imported/w3c/web-platform-tests/css/mediaqueries/device-aspect-ratio-001.html [ Skip ] 522 imported/w3c/web-platform-tests/css/mediaqueries/device-aspect-ratio-005.html [ Skip ] 523 524 imported/w3c/web-platform-tests/css/mediaqueries/min-width-001.xht [ ImageOnlyFailure ] 525 webkit.org/b/156684 imported/w3c/web-platform-tests/css/mediaqueries/relative-units-001.html [ ImageOnlyFailure ] 526 webkit.org/b/156684 imported/w3c/web-platform-tests/css/mediaqueries/mq-calc-005.html [ ImageOnlyFailure ] 519 527 520 528 # nth-child tests takes long time and Debug build sometimes timeouts because there are many test cases. -
trunk/LayoutTests/fast/dom/HTMLImageElement/sizes/image-sizes-w3c-1-expected.txt
r205905 r227295 39 39 PASS "green-1x1.png" is "green-1x1.png" 40 40 PASS "green-1x1.png" is "green-1x1.png" 41 FAIL "green-16x16.png" should be green-1x1.png. Was green-16x16.png. 41 PASS "green-1x1.png" is "green-1x1.png" 42 42 PASS "green-1x1.png" is "green-1x1.png" 43 43 PASS "green-1x1.png" is "green-1x1.png" -
trunk/LayoutTests/fast/dom/HTMLImageElement/sizes/image-sizes-w3c-2-expected.txt
r205905 r227295 39 39 PASS "green-1x1.png" is "green-1x1.png" 40 40 PASS "green-1x1.png" is "green-1x1.png" 41 FAIL "green-16x16.png" should be green-1x1.png. Was green-16x16.png. 41 PASS "green-1x1.png" is "green-1x1.png" 42 42 PASS "green-1x1.png" is "green-1x1.png" 43 43 PASS "green-1x1.png" is "green-1x1.png" -
trunk/LayoutTests/fast/dom/HTMLImageElement/sizes/image-sizes-w3c-3-expected.txt
r205905 r227295 39 39 PASS "green-1x1.png" is "green-1x1.png" 40 40 PASS "green-1x1.png" is "green-1x1.png" 41 FAIL "green-16x16.png" should be green-1x1.png. Was green-16x16.png. 41 PASS "green-1x1.png" is "green-1x1.png" 42 42 PASS "green-1x1.png" is "green-1x1.png" 43 43 PASS "green-1x1.png" is "green-1x1.png" -
trunk/LayoutTests/fast/dom/HTMLImageElement/sizes/image-sizes-w3c-4-expected.txt
r205905 r227295 39 39 PASS "green-1x1.png" is "green-1x1.png" 40 40 PASS "green-1x1.png" is "green-1x1.png" 41 FAIL "green-16x16.png" should be green-1x1.png. Was green-16x16.png. 41 PASS "green-1x1.png" is "green-1x1.png" 42 42 PASS "green-1x1.png" is "green-1x1.png" 43 43 PASS "green-1x1.png" is "green-1x1.png" -
trunk/LayoutTests/imported/w3c/ChangeLog
r227288 r227295 1 2018-01-22 Chris Nardi <csnardi1@gmail.com> 2 3 Parse calc() in CSS media queries 4 https://bugs.webkit.org/show_bug.cgi?id=181716 5 6 Reviewed by Antti Koivisto. 7 8 * resources/import-expectations.json: 9 * resources/resource-files.json: 10 * web-platform-tests/css/mediaqueries/OWNERS: Added. 11 * web-platform-tests/css/mediaqueries/aspect-ratio-001-expected.xht: Added. 12 * web-platform-tests/css/mediaqueries/aspect-ratio-001.html: Added. 13 * web-platform-tests/css/mediaqueries/aspect-ratio-002-expected.xht: Added. 14 * web-platform-tests/css/mediaqueries/aspect-ratio-002.html: Added. 15 * web-platform-tests/css/mediaqueries/aspect-ratio-003-expected.xht: Added. 16 * web-platform-tests/css/mediaqueries/aspect-ratio-003.html: Added. 17 * web-platform-tests/css/mediaqueries/aspect-ratio-004-expected.xht: Added. 18 * web-platform-tests/css/mediaqueries/aspect-ratio-004.html: Added. 19 * web-platform-tests/css/mediaqueries/device-aspect-ratio-001-expected.xht: Added. 20 * web-platform-tests/css/mediaqueries/device-aspect-ratio-001.html: Added. 21 * web-platform-tests/css/mediaqueries/device-aspect-ratio-002-expected.xht: Added. 22 * web-platform-tests/css/mediaqueries/device-aspect-ratio-002.html: Added. 23 * web-platform-tests/css/mediaqueries/device-aspect-ratio-003-expected.xht: Added. 24 * web-platform-tests/css/mediaqueries/device-aspect-ratio-003.html: Added. 25 * web-platform-tests/css/mediaqueries/device-aspect-ratio-004-expected.xht: Added. 26 * web-platform-tests/css/mediaqueries/device-aspect-ratio-004.html: Added. 27 * web-platform-tests/css/mediaqueries/device-aspect-ratio-005-expected.xht: Added. 28 * web-platform-tests/css/mediaqueries/device-aspect-ratio-005.html: Added. 29 * web-platform-tests/css/mediaqueries/device-aspect-ratio-006-expected.xht: Added. 30 * web-platform-tests/css/mediaqueries/device-aspect-ratio-006.html: Added. 31 * web-platform-tests/css/mediaqueries/min-width-001-expected.xht: Added. 32 * web-platform-tests/css/mediaqueries/min-width-001.xht: Added. 33 * web-platform-tests/css/mediaqueries/min-width-tables-001-expected.xht: Added. 34 * web-platform-tests/css/mediaqueries/min-width-tables-001.html: Added. 35 * web-platform-tests/css/mediaqueries/mq-calc-001-expected.xht: Added. 36 * web-platform-tests/css/mediaqueries/mq-calc-001.html: Added. 37 * web-platform-tests/css/mediaqueries/mq-calc-002-expected.xht: Added. 38 * web-platform-tests/css/mediaqueries/mq-calc-002.html: Added. 39 * web-platform-tests/css/mediaqueries/mq-calc-003-expected.xht: Added. 40 * web-platform-tests/css/mediaqueries/mq-calc-003.html: Added. 41 * web-platform-tests/css/mediaqueries/mq-calc-004-expected.xht: Added. 42 * web-platform-tests/css/mediaqueries/mq-calc-004.html: Added. 43 * web-platform-tests/css/mediaqueries/mq-calc-005-expected.xht: Added. 44 * web-platform-tests/css/mediaqueries/mq-calc-005.html: Added. 45 * web-platform-tests/css/mediaqueries/mq-invalid-media-type-001-expected.xht: Added. 46 * web-platform-tests/css/mediaqueries/mq-invalid-media-type-001.html: Added. 47 * web-platform-tests/css/mediaqueries/mq-invalid-media-type-002-expected.xht: Added. 48 * web-platform-tests/css/mediaqueries/mq-invalid-media-type-002.html: Added. 49 * web-platform-tests/css/mediaqueries/mq-invalid-media-type-003-expected.xht: Added. 50 * web-platform-tests/css/mediaqueries/mq-invalid-media-type-003.html: Added. 51 * web-platform-tests/css/mediaqueries/mq-invalid-media-type-004-expected.xht: Added. 52 * web-platform-tests/css/mediaqueries/mq-invalid-media-type-004.html: Added. 53 * web-platform-tests/css/mediaqueries/relative-units-001-expected.xht: Added. 54 * web-platform-tests/css/mediaqueries/relative-units-001.html: Added. 55 * web-platform-tests/css/mediaqueries/relative-units-002-expected.xht: Added. 56 * web-platform-tests/css/mediaqueries/relative-units-002.html: Added. 57 * web-platform-tests/css/mediaqueries/relative-units-003-expected.xht: Added. 58 * web-platform-tests/css/mediaqueries/relative-units-003.html: Added. 59 * web-platform-tests/css/mediaqueries/relative-units-004-expected.xht: Added. 60 * web-platform-tests/css/mediaqueries/relative-units-004.html: Added. 61 * web-platform-tests/css/mediaqueries/support/media_queries_iframe.html: Renamed from LayoutTests/fast/media/w3c/resources/media_queries_iframe.html. 62 * web-platform-tests/css/mediaqueries/support/min-width-tables-001-iframe.html: Added. 63 * web-platform-tests/css/mediaqueries/support/w3c-import.log: Added. 64 * web-platform-tests/css/mediaqueries/test_media_queries-expected.txt: Renamed from LayoutTests/fast/media/w3c/test_media_queries-expected.txt. 65 * web-platform-tests/css/mediaqueries/test_media_queries.html: Renamed from LayoutTests/fast/media/w3c/test_media_queries.html. 66 * web-platform-tests/css/mediaqueries/w3c-import.log: Added. 67 1 68 2018-01-22 Manuel Rego Casasnovas <rego@igalia.com> 2 69 -
trunk/LayoutTests/imported/w3c/resources/import-expectations.json
r227054 r227295 68 68 "web-platform-tests/css/css-ui-3": "import", 69 69 "web-platform-tests/css/geometry-1/": "import", 70 "web-platform-tests/css/mediaqueries": "import", 70 71 "web-platform-tests/css/reference": "import", 71 72 "web-platform-tests/css/resources": "import", -
trunk/LayoutTests/imported/w3c/resources/resource-files.json
r225593 r227295 278 278 "web-platform-tests/css/css-ui-3/text-overflow-018.html", 279 279 "web-platform-tests/css/css-ui-3/text-overflow-019.html", 280 "web-platform-tests/css/mediaqueries/support/media_queries_iframe.html", 281 "web-platform-tests/css/mediaqueries/support/min-width-tables-001-iframe.html", 280 282 "web-platform-tests/cssom-view/iframe.html", 281 283 "web-platform-tests/cssom/support/xmlss-pi.xhtml", -
trunk/LayoutTests/imported/w3c/web-platform-tests/css/mediaqueries/support/media_queries_iframe.html
r227294 r227295 5 5 <title>Media Queries Test inner frame</title> 6 6 <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> 7 <link rel="author" title="L. David Baron" href="http://dbaron.org/"> 8 <link rel="help" href="http://www.w3.org/TR/css3-mediaqueries/"> 7 <link rel="author" title="L. David Baron" href="https://dbaron.org/"> 9 8 <meta http-equiv="Content-Style-Type" content="text/css"> 10 9 <style type="text/css" id="style" media="all"> -
trunk/LayoutTests/imported/w3c/web-platform-tests/css/mediaqueries/test_media_queries.html
r227294 r227295 3 3 <head> 4 4 <title>Media Queries Self-Contained Test Suite</title> 5 <link rel="author" title="L. David Baron" href="http ://dbaron.org/">5 <link rel="author" title="L. David Baron" href="https://dbaron.org/"> 6 6 <link rel="author" title="Anne van Kesteren" href="http://annevankesteren.nl/"> 7 7 <link rel="author" title="Ms2ger" href="mailto:Ms2ger@gmail.com"> 8 8 <link rel="help" href="http://www.w3.org/TR/css3-mediaqueries/"> 9 <script type="text/javascript" src=" ../../../resources/testharness.js"></script>10 <script type="text/javascript" src=" ../../../resources/testharnessreport.js"></script>9 <script type="text/javascript" src="/resources/testharness.js"></script> 10 <script type="text/javascript" src="/resources/testharnessreport.js"></script> 11 11 </head> 12 12 <body onload="run()"> 13 13 <div id=log></div> 14 <iframe id="subdoc" src=" resources/media_queries_iframe.html"></iframe>14 <iframe id="subdoc" src="support/media_queries_iframe.html"></iframe> 15 15 <div id="content" style="display: none"></div> 16 16 17 17 <script type="text/javascript"> 18 18 setup({ "explicit_done": true }); 19 20 function assert_false_wrapper(fnc) {21 try {22 assert_false(fnc);23 } catch (e) {24 throw {message: e.message, stack: undefined};25 }26 }27 28 function assert_true_wrapper(fnc) {29 try {30 assert_true(fnc);31 } catch (e) {32 throw {message: e.message, stack: undefined};33 }34 }35 36 19 37 20 function run() { … … 41 24 var iframe_style = document.getElementById("subdoc").style; 42 25 var body_cs = subdoc.defaultView.getComputedStyle(subdoc.body, ""); 26 var testNum = 0; 43 27 44 28 function query_applies(q) { 45 29 style.setAttribute("media", q); 46 return body_cs.getPropertyValue("text-decoration ") == "underline";47 } 48 49 function should_apply(q , message) {50 test(function() { 51 assert_true _wrapper(query_applies(q));52 }, (message !== undefined ? message : q) + " should apply");53 } 54 55 function should_not_apply(q , message) {56 test(function() { 57 assert_false _wrapper(query_applies(q));58 }, (message !== undefined ? message : q) + " should not apply");30 return body_cs.getPropertyValue("text-decoration-line") == "underline"; 31 } 32 33 function should_apply(q) { 34 test(function() { 35 assert_true(query_applies(q)); 36 }, "subtest_" + ++testNum, {assert: q + " should apply"}); 37 } 38 39 function should_not_apply(q) { 40 test(function() { 41 assert_false(query_applies(q)); 42 }, "subtest_" + ++testNum, {assert: q + " should not apply"}); 59 43 } 60 44 … … 84 68 function query_should_be_parseable(q) { 85 69 test(function() { 86 assert_true _wrapper(query_is_parseable(q))87 }, "query " + q + " should be parseable");70 assert_true(query_is_parseable(q)) 71 }, "subtest_" + ++testNum, {assert: "query " + q + " should be parseable"}); 88 72 } 89 73 90 74 function query_should_not_be_parseable(q) { 91 75 test(function() { 92 assert_false _wrapper(query_is_parseable(q))93 }, "query " + q + " should not be parseable");76 assert_false(query_is_parseable(q)) 77 }, "subtest_" + ++testNum, {assert: "query " + q + " should not be parseable"}); 94 78 } 95 79 … … 104 88 function expression_should_be_parseable(e) { 105 89 test(function() { 106 assert_true _wrapper(expression_is_parseable(e));107 }, "expression " + e + " should be parseable");90 assert_true(expression_is_parseable(e)); 91 }, "subtest_" + ++testNum, {assert: "expression " + e + " should be parseable"}); 108 92 } 109 93 110 94 function expression_should_not_be_parseable(e) { 111 95 test(function() { 112 assert_false _wrapper(expression_is_parseable(e));113 }, "expression " + e + " should not be parseable");96 assert_false(expression_is_parseable(e)); 97 }, "subtest_" + ++testNum, {assert: "expression " + e + " should not be parseable"}); 114 98 } 115 99 … … 120 104 query_should_be_parseable("all and (orientation)"); 121 105 query_should_be_parseable("not all and (orientation)"); 122 query_should_be_parseable("only all and (orientation)") 123 query_should_not_be_parseable("(orientation: 'landscape')"); 106 query_should_be_parseable("only all and (orientation)"); 124 107 125 108 var features = [ "width", "height", "device-width", "device-height" ]; … … 140 123 expression_should_be_parseable(feature + ": 100000px"); 141 124 expression_should_not_be_parseable(feature + ": -1px"); 142 expression_should_not_be_parseable(feature + ": '20px'");143 125 expression_should_not_be_parseable("min-" + feature + ": -1px"); 144 126 expression_should_not_be_parseable("max-" + feature + ": -1px"); 145 expression_should_not_be_parseable("min-" + feature + ": '10px'");146 expression_should_not_be_parseable("max-" + feature + ": '10px'");147 127 expression_should_not_be_parseable(feature + ": -0.00001mm"); 148 128 expression_should_not_be_parseable(feature + ": -100000em"); … … 169 149 for (feature in features) { 170 150 var value = features[feature]; 171 should_apply("all and (" + feature + ": " + value + "px)" , "all and (" + feature + ": " + feature + " px)");172 should_not_apply("all and (" + feature + ": " + (value + 1) + "px)" , "all and (" + feature + ": " + feature + " +1 px)");173 should_not_apply("all and (" + feature + ": " + (value - 1) + "px)" , "all and (" + feature + ": " + feature + " -1 px)");174 should_apply("all and (min-" + feature + ": " + value + "px)" , "all and (min-" + feature + ": " + feature + " px)");175 should_not_apply("all and (min-" + feature + ": " + (value + 1) + "px)" , "all and (min-" + feature + ": " + feature + " +1 px)");176 should_apply("all and (min-" + feature + ": " + (value - 1) + "px)" , "all and (min-" + feature + ": " + feature + " -1 px)");177 should_apply("all and (max-" + feature + ": " + value + "px)" , "all and (max-" + feature + ": " + feature + " px)");178 should_apply("all and (max-" + feature + ": " + (value + 1) + "px)" , "all and (max-" + feature + ": " + feature + " +1 px)");179 should_not_apply("all and (max-" + feature + ": " + (value - 1) + "px)" , "all and (max-" + feature + ": " + feature + " +1 px)");151 should_apply("all and (" + feature + ": " + value + "px)"); 152 should_not_apply("all and (" + feature + ": " + (value + 1) + "px)"); 153 should_not_apply("all and (" + feature + ": " + (value - 1) + "px)"); 154 should_apply("all and (min-" + feature + ": " + value + "px)"); 155 should_not_apply("all and (min-" + feature + ": " + (value + 1) + "px)"); 156 should_apply("all and (min-" + feature + ": " + (value - 1) + "px)"); 157 should_apply("all and (max-" + feature + ": " + value + "px)"); 158 should_apply("all and (max-" + feature + ": " + (value + 1) + "px)"); 159 should_not_apply("all and (max-" + feature + ": " + (value - 1) + "px)"); 180 160 should_not_apply("all and (min-" + feature + ": " + 181 (Math.ceil(value/em_size) + 1) + "em)" , "all and (min-" + feature + ": " + feature + " +1 em)");161 (Math.ceil(value/em_size) + 1) + "em)"); 182 162 should_apply("all and (min-" + feature + ": " + 183 (Math.floor(value/em_size) - 1) + "em)" , "all and (min-" + feature + ": " + feature + " -1 em)");163 (Math.floor(value/em_size) - 1) + "em)"); 184 164 should_apply("all and (max-" + feature + ": " + 185 (Math.ceil(value/em_size) + 1) + "em)" , "all and (max-" + feature + ": " + feature + " +1 em)");165 (Math.ceil(value/em_size) + 1) + "em)"); 186 166 should_not_apply("all and (max-" + feature + ": " + 187 (Math.floor(value/em_size) - 1) + "em)" , "all and (max-" + feature + ": " + feature + " -1 em)");167 (Math.floor(value/em_size) - 1) + "em)"); 188 168 } 189 169 … … 259 239 var low_dar_1 = (device_width - 1) + "/" + device_height; 260 240 var low_dar_2 = device_width + "/" + (device_height + 1); 261 should_apply("(device-aspect-ratio: " + real_dar + ")" , "(device-aspect-ratio: device-width / device-height)");262 should_apply("not all and (device-aspect-ratio: " + high_dar_1 + ")" , "not all and (device-aspect-ratio: device-width + 1 / device-height)");263 should_not_apply("all and (device-aspect-ratio: " + high_dar_2 + ")" , "all and (device-aspect-ratio: device-width / device-height - 1)");264 should_not_apply("all and (device-aspect-ratio: " + low_dar_1 + ")" , "all and (device-aspect-ratio: device-width - 1 / device-height)");265 should_apply("not all and (device-aspect-ratio: " + low_dar_2 + ")" , "not all and (device-aspect-ratio: device-width / device-height + 1)");241 should_apply("(device-aspect-ratio: " + real_dar + ")"); 242 should_apply("not all and (device-aspect-ratio: " + high_dar_1 + ")"); 243 should_not_apply("all and (device-aspect-ratio: " + high_dar_2 + ")"); 244 should_not_apply("all and (device-aspect-ratio: " + low_dar_1 + ")"); 245 should_apply("not all and (device-aspect-ratio: " + low_dar_2 + ")"); 266 246 should_apply("(device-aspect-ratio)"); 267 247 268 should_apply("(min-device-aspect-ratio: " + real_dar + ")" , "(min-device-aspect-ratio: device-width / device-height)");269 should_not_apply("all and (min-device-aspect-ratio: " + high_dar_1 + ")" , "not all and (device-aspect-ratio: device-width + 1 / device-height)");270 should_apply("not all and (min-device-aspect-ratio: " + high_dar_2 + ")" , "not all and (min-device-aspect-ratio: device-width / device-height - 1)");271 should_not_apply("not all and (min-device-aspect-ratio: " + low_dar_1 + ")" , "not all and (min-device-aspect-ratio: device-width - 1 / device-height)");272 should_apply("all and (min-device-aspect-ratio: " + low_dar_2 + ")" , "all and (min-device-aspect-ratio: device-width / device-height + 1)");248 should_apply("(min-device-aspect-ratio: " + real_dar + ")"); 249 should_not_apply("all and (min-device-aspect-ratio: " + high_dar_1 + ")"); 250 should_apply("not all and (min-device-aspect-ratio: " + high_dar_2 + ")"); 251 should_not_apply("not all and (min-device-aspect-ratio: " + low_dar_1 + ")"); 252 should_apply("all and (min-device-aspect-ratio: " + low_dar_2 + ")"); 273 253 expression_should_not_be_parseable("min-device-aspect-ratio"); 274 254 275 should_apply("all and (max-device-aspect-ratio: " + real_dar + ")" , "all and (max-device-aspect-ratio: device-width / device-height)");276 should_apply("(max-device-aspect-ratio: " + high_dar_1 + ")" , "(max-device-aspect-ratio: device-width + 1 / device-height)");277 should_apply("(max-device-aspect-ratio: " + high_dar_2 + ")" , "(max-device-aspect-ratio: device-width / device-height - 1");278 should_not_apply("all and (max-device-aspect-ratio: " + low_dar_1 + ")" , "all and (max-device-aspect-ratio: device-width - 1 / device-height)");279 should_apply("not all and (max-device-aspect-ratio: " + low_dar_2 + ")" , "not all and (max-device-aspect-ratio: device-width / device-height + 1)");255 should_apply("all and (max-device-aspect-ratio: " + real_dar + ")"); 256 should_apply("(max-device-aspect-ratio: " + high_dar_1 + ")"); 257 should_apply("(max-device-aspect-ratio: " + high_dar_2 + ")"); 258 should_not_apply("all and (max-device-aspect-ratio: " + low_dar_1 + ")"); 259 should_apply("not all and (max-device-aspect-ratio: " + low_dar_2 + ")"); 280 260 expression_should_not_be_parseable("max-device-aspect-ratio"); 281 261 … … 302 282 var is_monochrome = query_applies("all and (min-monochrome: 1)"); 303 283 var is_color = query_applies("all and (min-color: 1)"); 304 var colorString = is_color ? "color" : "monochrome";305 284 test(function() { 306 285 assert_not_equals(is_monochrome, is_color, "should be either monochrome or color"); … … 308 287 309 288 function depth_query(prefix, depth) { 310 return "all and (" + prefix + colorString+289 return "all and (" + prefix + (is_color ? "color" : "monochrome") + 311 290 ":" + depth + ")"; 312 291 } … … 319 298 } while (query_applies(depth_query("min-", ++depth))); 320 299 test(function() { 321 assert_false _wrapper(50 < depth);300 assert_false(50 < depth); 322 301 }, "find_depth"); 323 302 --depth; 324 303 325 should_apply(depth_query("", depth) , "all and (" + colorString + ": depth)");326 should_not_apply(depth_query("", depth - 1) , "all and (" + colorString + ": depth - 1)");327 should_not_apply(depth_query("", depth + 1) , "all and (" + colorString + ": depth + 1)");328 should_apply(depth_query("max-", depth) , "all and (max-" + colorString + ": depth)");329 should_not_apply(depth_query("max-", depth - 1) , "all and (max-" + colorString + ": depth - 1)");330 should_apply(depth_query("max-", depth + 1) , "all and (max-" + colorString + ": depth + 1)");304 should_apply(depth_query("", depth)); 305 should_not_apply(depth_query("", depth - 1)); 306 should_not_apply(depth_query("", depth + 1)); 307 should_apply(depth_query("max-", depth)); 308 should_not_apply(depth_query("max-", depth - 1)); 309 should_apply(depth_query("max-", depth + 1)); 331 310 332 311 (is_color ? should_apply : should_not_apply)("all and (color)"); … … 341 320 (is_color ? should_not_apply : should_apply)("only all and (monochrome)"); 342 321 343 features = [ "color", "min-monochrome" ];322 features = [ "color", "min-monochrome", "max-color-index" ]; 344 323 for (i in features) { 345 324 feature = features[i]; … … 352 331 } 353 332 333 // Presume that we never support indexed color (at least not usefully 334 // enough to call it indexed color). 335 should_apply("(color-index: 0)"); 336 should_not_apply("(color-index: 1)"); 337 should_apply("(min-color-index: 0)"); 338 should_not_apply("(min-color-index: 1)"); 339 should_apply("(max-color-index: 0)"); 340 should_apply("(max-color-index: 1)"); 341 should_apply("(max-color-index: 157)"); 342 343 features = [ "resolution", "min-resolution", "max-resolution" ]; 344 for (i in features) { 345 feature = features[i]; 346 expression_should_be_parseable(feature + ": 3dpi"); 347 expression_should_be_parseable(feature + ":3dpi"); 348 expression_should_be_parseable(feature + ": 3.0dpi"); 349 expression_should_be_parseable(feature + ": 3.4dpi"); 350 expression_should_be_parseable(feature + "\t: 120dpcm"); 351 expression_should_not_be_parseable(feature + ": 0dpi"); 352 expression_should_not_be_parseable(feature + ": -3dpi"); 353 } 354 354 355 // Find the resolution using max-resolution 355 356 var resolution = 0; 356 var max_resolution = 1000; 357 358 if (query_applies("(resolution)")) { 359 do { 360 ++resolution; 361 if (resolution > max_resolution) { 362 break; 363 } 364 } while (!query_applies("(max-resolution: " + resolution + "dpi)")); 365 } else { 366 resolution = max_resolution + 1; 367 } 368 357 do { 358 ++resolution; 359 if (resolution > 10000) { 360 break; 361 } 362 } while (!query_applies("(max-resolution: " + resolution + "dpi)")); 369 363 test(function() { 370 assert_false _wrapper(max_resolution< resolution);364 assert_false(10000 < resolution); 371 365 }, "find_resolution"); 372 366 … … 374 368 var dpi_high; 375 369 var dpi_low = resolution - 1; 376 var dpi_low_str = "dpi - 1";377 var dpi_high_str = "dpi + 1";378 370 if (query_applies("(min-resolution: " + resolution + "dpi)")) { 379 371 // It's exact! 380 should_apply("(resolution: " + resolution + "dpi)" , "(resolution: dpi)");381 should_not_apply("(resolution: " + (resolution + 1) + "dpi)" , "(resolution: dpi + 1)");382 should_not_apply("(resolution: " + (resolution - 1) + "dpi)" , "(resolution: dpi - 1)");372 should_apply("(resolution: " + resolution + "dpi)"); 373 should_not_apply("(resolution: " + (resolution + 1) + "dpi)"); 374 should_not_apply("(resolution: " + (resolution - 1) + "dpi)"); 383 375 dpi_high = resolution + 1; 384 376 } else { 385 377 // We have no way to test resolution applying since it need not be 386 378 // an integer. 387 should_not_apply("(resolution: " + resolution + "dpi)" , "(resolution: dpi)");388 should_not_apply("(resolution: " + (resolution - 1) + "dpi)" , "(resolution: dpi + 1)");379 should_not_apply("(resolution: " + resolution + "dpi)"); 380 should_not_apply("(resolution: " + (resolution - 1) + "dpi)"); 389 381 dpi_high = resolution; 390 382 } 391 383 392 should_apply("(min-resolution: " + dpi_low + "dpi)" , "(min-resolution: " + dpi_low_str + " )");393 should_not_apply("not all and (min-resolution: " + dpi_low + "dpi)" , "not all and (min-resolution: " + dpi_low_str + " )");394 should_apply("not all and (min-resolution: " + dpi_high + "dpi)" , "not all and (min-resolution: " + dpi_high_str + " )");395 should_not_apply("all and (min-resolution: " + dpi_high + "dpi)" , "all and (min-resolution: " + dpi_high_str + " )");384 should_apply("(min-resolution: " + dpi_low + "dpi)"); 385 should_not_apply("not all and (min-resolution: " + dpi_low + "dpi)"); 386 should_apply("not all and (min-resolution: " + dpi_high + "dpi)"); 387 should_not_apply("all and (min-resolution: " + dpi_high + "dpi)"); 396 388 397 389 // Test dpcm units based on what we computed in dpi. 398 390 var dpcm_high = Math.ceil(dpi_high / 2.54); 399 391 var dpcm_low = Math.floor(dpi_low / 2.54); 400 should_apply("(min-resolution: " + dpcm_low + "dpcm)", "(min-resolution: dpcm (" + dpi_low_str + ") )"); 401 should_apply("(max-resolution: " + dpcm_high + "dpcm)", "(max-resolution: dpcm (" + dpi_high_str + ") )"); 402 should_not_apply("(max-resolution: " + dpcm_low + "dpcm)", "(max-resolution: dpcm (" + dpi_low_str + ") )"); 403 should_apply("not all and (min-resolution: " + dpcm_high + "dpcm)", "not all and (min-resolution: dpcm (" + dpi_high_str + ") )"); 392 should_apply("(min-resolution: " + dpcm_low + "dpcm)"); 393 should_apply("(max-resolution: " + dpcm_high + "dpcm)"); 394 should_not_apply("(max-resolution: " + dpcm_low + "dpcm)"); 395 should_apply("not all and (min-resolution: " + dpcm_high + "dpcm)"); 396 397 expression_should_be_parseable("scan"); 398 expression_should_be_parseable("scan: progressive"); 399 expression_should_be_parseable("scan:interlace"); 400 expression_should_not_be_parseable("min-scan:interlace"); 401 expression_should_not_be_parseable("scan: 1"); 402 expression_should_not_be_parseable("max-scan"); 403 expression_should_not_be_parseable("max-scan: progressive"); 404 // Assume we don't support tv devices. 405 should_not_apply("(scan)"); 406 should_not_apply("(scan: progressive)"); 407 should_not_apply("(scan: interlace)"); 408 should_apply("not all and (scan)"); 409 should_apply("not all and (scan: progressive)"); 410 should_apply("not all and (scan: interlace)"); 404 411 405 412 expression_should_be_parseable("grid"); … … 420 427 should_not_apply("(grid: -1)"); 421 428 429 // Parsing tests 430 // bug 454227 431 should_apply("(orientation"); 432 should_not_apply("not all and (orientation"); 433 should_not_apply("(orientation:"); 434 should_apply("all,(orientation:"); 435 should_not_apply("(orientation:,all"); 436 should_apply("not all and (grid"); 437 should_not_apply("only all and (grid"); 438 should_not_apply("(grid"); 439 should_apply("all,(grid"); 440 should_not_apply("(grid,all"); 441 // bug 454226 442 should_apply(",all"); 443 should_apply("all,"); 444 should_apply(",all,"); 445 should_apply("all,badmedium"); 446 should_apply("badmedium,all"); 447 should_not_apply(",badmedium,"); 448 should_apply("all,(badexpression)"); 449 should_apply("(badexpression),all"); 450 should_not_apply("(badexpression),badmedium"); 451 should_not_apply("badmedium,(badexpression)"); 452 should_apply("all,[badsyntax]"); 453 should_apply("[badsyntax],all"); 454 should_not_apply("badmedium,[badsyntax]"); 455 should_not_apply("[badsyntax],badmedium"); 456 457 // Parsing tests based on Acid3 458 query_should_not_be_parseable("all and color :"); 459 query_should_not_be_parseable("all and color : 1"); 460 should_not_apply("all and min-color : 1"); 461 should_not_apply("(bogus)"); 462 should_not_apply("not all and (bogus)") 463 should_not_apply("only all and (bogus)") 464 422 465 done(); 423 466 } -
trunk/LayoutTests/platform/ios/TestExpectations
r227272 r227295 3025 3025 webkit.org/b/175353 imported/w3c/web-platform-tests/css/css-ui-3/outline-style-014.html [ ImageOnlyFailure ] 3026 3026 3027 imported/w3c/web-platform-tests/css/mediaqueries/device-aspect-ratio-003.html [ ImageOnlyFailure ] 3028 3027 3029 webkit.org/b/170698 [ Release ] imported/w3c/web-platform-tests/IndexedDB/interleaved-cursors.html [ Pass Failure ] 3028 3030 -
trunk/LayoutTests/platform/ios/fast/dom/HTMLImageElement/sizes/image-sizes-w3c-1-expected.txt
r205911 r227295 39 39 PASS "green-1x1.png" is "green-1x1.png" 40 40 PASS "green-1x1.png" is "green-1x1.png" 41 FAIL "green-16x16.png" should be green-1x1.png. Was green-16x16.png. 41 PASS "green-1x1.png" is "green-1x1.png" 42 42 PASS "green-1x1.png" is "green-1x1.png" 43 43 PASS "green-1x1.png" is "green-1x1.png" -
trunk/LayoutTests/platform/ios/fast/dom/HTMLImageElement/sizes/image-sizes-w3c-2-expected.txt
r205911 r227295 39 39 PASS "green-1x1.png" is "green-1x1.png" 40 40 PASS "green-1x1.png" is "green-1x1.png" 41 FAIL "green-16x16.png" should be green-1x1.png. Was green-16x16.png. 41 PASS "green-1x1.png" is "green-1x1.png" 42 42 PASS "green-1x1.png" is "green-1x1.png" 43 43 PASS "green-1x1.png" is "green-1x1.png" -
trunk/LayoutTests/platform/ios/fast/dom/HTMLImageElement/sizes/image-sizes-w3c-3-expected.txt
r205911 r227295 39 39 PASS "green-1x1.png" is "green-1x1.png" 40 40 PASS "green-1x1.png" is "green-1x1.png" 41 FAIL "green-16x16.png" should be green-1x1.png. Was green-16x16.png. 41 PASS "green-1x1.png" is "green-1x1.png" 42 42 PASS "green-1x1.png" is "green-1x1.png" 43 43 PASS "green-1x1.png" is "green-1x1.png" -
trunk/LayoutTests/platform/ios/fast/dom/HTMLImageElement/sizes/image-sizes-w3c-4-expected.txt
r205911 r227295 39 39 PASS "green-1x1.png" is "green-1x1.png" 40 40 PASS "green-1x1.png" is "green-1x1.png" 41 FAIL "green-16x16.png" should be green-1x1.png. Was green-16x16.png. 41 PASS "green-1x1.png" is "green-1x1.png" 42 42 PASS "green-1x1.png" is "green-1x1.png" 43 43 PASS "green-1x1.png" is "green-1x1.png" -
trunk/Source/WebCore/ChangeLog
r227292 r227295 1 2018-01-22 Chris Nardi <csnardi1@gmail.com> 2 3 Parse calc() in CSS media queries 4 https://bugs.webkit.org/show_bug.cgi?id=181716 5 6 calc() was previously unsupported inside of media queries. This change 7 adds in support for parsing calc inside of media queries. 8 9 Reviewed by Antti Koivisto. 10 11 Tests: Imported web-platform-tests/css/mediaqueries 12 13 * css/MediaQueryExpression.cpp: 14 (WebCore::featureWithValidIdent): Updated function to take a CSSPrimitiveValue. 15 (WebCore::featureWithValidDensity): Updated function to take a CSSPrimitiveValue instead of a CSSParserToken. 16 (WebCore::featureWithValidPositiveLength): Ditto. 17 (WebCore::featureExpectingPositiveInteger): Ditto. 18 (WebCore::featureWithPositiveInteger): Ditto. 19 (WebCore::featureWithPositiveNumber): Ditto. 20 (WebCore::featureWithZeroOrOne): Ditto. 21 (WebCore::MediaQueryExpression::MediaQueryExpression): Use CSSPropertyParserHelpers for consuming. 22 * css/MediaQueryExpression.h: 23 * css/parser/CSSPropertyParserHelpers.cpp: 24 (WebCore::CSSPropertyParserHelpers::consumeResolution): Added function for use in media query expression parsing. 25 * css/parser/CSSPropertyParserHelpers.h: 26 * css/parser/MediaQueryParser.cpp: 27 (WebCore::MediaQueryParser::readRestrictor): Updated functions to take a CSSParserTokenRange in order to use CSSPropertyParserHelpers. 28 (WebCore::MediaQueryParser::readMediaNot): Ditto. 29 (WebCore::MediaQueryParser::readMediaType): Ditto. 30 (WebCore::MediaQueryParser::readAnd): Ditto. 31 (WebCore::MediaQueryParser::readFeatureStart): Ditto. 32 (WebCore::MediaQueryParser::readFeature): Ditto. 33 (WebCore::MediaQueryParser::readFeatureColon): Ditto. 34 (WebCore::MediaQueryParser::readFeatureValue): Ditto. 35 (WebCore::MediaQueryParser::readFeatureEnd): Ditto. 36 (WebCore::MediaQueryParser::skipUntilComma): Ditto. 37 (WebCore::MediaQueryParser::skipUntilBlockEnd): Ditto. 38 (WebCore::MediaQueryParser::processToken): Ditto. 39 (WebCore::MediaQueryParser::parseInternal): Ditto. 40 (WebCore::MediaQueryData::clear): Removed reference to m_valueList 41 (WebCore::MediaQueryData::addExpression): Use CSSParserTokenRange. 42 (WebCore::MediaQueryData::lastExpressionValid): New helper function. 43 (WebCore::MediaQueryData::removeLastExpression): New helper function. 44 * css/parser/MediaQueryParser.h: 45 1 46 2018-01-22 Zan Dobersek <zdobersek@igalia.com> 2 47 -
trunk/Source/WebCore/css/MediaQueryExpression.cpp
r225639 r227295 30 30 31 31 #include "CSSAspectRatioValue.h" 32 #include "CSSParserToken.h"33 32 #include "CSSPrimitiveValue.h" 33 #include "CSSPropertyParserHelpers.h" 34 34 #include "MediaFeatureNames.h" 35 35 #include <wtf/text/TextStream.h> … … 38 38 namespace WebCore { 39 39 40 static inline bool featureWithValidIdent(const AtomicString& mediaFeature) 41 { 40 static inline bool featureWithValidIdent(const AtomicString& mediaFeature, const CSSPrimitiveValue& value) 41 { 42 if (value.primitiveType() != CSSPrimitiveValue::UnitType::CSS_IDENT) 43 return false; 44 42 45 return mediaFeature == MediaFeatureNames::orientation 43 46 || mediaFeature == MediaFeatureNames::colorGamut … … 53 56 } 54 57 55 static inline bool featureWithValidDensity(const String& mediaFeature, const CSSP arserToken& token)56 { 57 if (! CSSPrimitiveValue::isResolution(static_cast<CSSPrimitiveValue::UnitType>(token.unitType())) || token.numericValue() <= 0)58 static inline bool featureWithValidDensity(const String& mediaFeature, const CSSPrimitiveValue& value) 59 { 60 if (!value.isResolution() || value.doubleValue() <= 0) 58 61 return false; 59 62 … … 63 66 } 64 67 65 static inline bool featureWithValidPositiveLength(const String& mediaFeature, const CSSParserToken& token) 66 { 67 if (!(CSSPrimitiveValue::isLength(token.unitType()) || (token.type() == NumberToken && !token.numericValue())) || token.numericValue() < 0) 68 return false; 69 68 static inline bool featureWithValidPositiveLength(const String& mediaFeature, const CSSPrimitiveValue& value) 69 { 70 if (!(value.isLength() || (value.isNumber() && !value.doubleValue())) || value.doubleValue() < 0) 71 return false; 70 72 71 73 return mediaFeature == MediaFeatureNames::height … … 83 85 } 84 86 85 static inline bool featureWithPositiveInteger(const String& mediaFeature, const CSSParserToken& token) 86 { 87 if (token.numericValueType() != IntegerValueType || token.numericValue() < 0) 88 return false; 89 87 static inline bool featureExpectingPositiveInteger(const String& mediaFeature) 88 { 90 89 return mediaFeature == MediaFeatureNames::color 91 || mediaFeature == MediaFeatureNames:: 92 || mediaFeature == MediaFeatureNames:: 90 || mediaFeature == MediaFeatureNames::maxColor 91 || mediaFeature == MediaFeatureNames::minColor 93 92 || mediaFeature == MediaFeatureNames::colorIndex 94 93 || mediaFeature == MediaFeatureNames::maxColorIndex … … 99 98 } 100 99 101 static inline bool featureWithPositiveNumber(const String& mediaFeature, const CSSParserToken& token) 102 { 103 if (token.type() != NumberToken || token.numericValue() < 0) 100 static inline bool featureWithPositiveInteger(const String& mediaFeature, const CSSPrimitiveValue& value) 101 { 102 if (!value.isNumber()) 103 return false; 104 return featureExpectingPositiveInteger(mediaFeature); 105 } 106 107 static inline bool featureWithPositiveNumber(const String& mediaFeature, const CSSPrimitiveValue& value) 108 { 109 if (!value.isNumber()) 104 110 return false; 105 111 … … 113 119 } 114 120 115 static inline bool featureWithZeroOrOne(const String& mediaFeature, const CSSP arserToken& token)116 { 117 if ( token.numericValueType() != IntegerValueType || !(token.numericValue() == 1 || !token.numericValue()))121 static inline bool featureWithZeroOrOne(const String& mediaFeature, const CSSPrimitiveValue& value) 122 { 123 if (!value.isNumber() || !(value.doubleValue() == 1 || !value.doubleValue())) 118 124 return false; 119 125 … … 163 169 } 164 170 165 MediaQueryExpression::MediaQueryExpression(const String& feature, const Vector<CSSParserToken, 4>& tokenList) 171 inline RefPtr<CSSPrimitiveValue> consumeFirstValue(const String& mediaFeature, CSSParserTokenRange& range) 172 { 173 if (auto value = CSSPropertyParserHelpers::consumeInteger(range, 0)) 174 return value; 175 176 if (!featureExpectingPositiveInteger(mediaFeature) && !isAspectRatioFeature(mediaFeature)) { 177 if (auto value = CSSPropertyParserHelpers::consumeNumber(range, ValueRangeNonNegative)) 178 return value; 179 } 180 181 if (auto value = CSSPropertyParserHelpers::consumeLength(range, HTMLStandardMode, ValueRangeNonNegative)) 182 return value; 183 184 if (auto value = CSSPropertyParserHelpers::consumeResolution(range)) 185 return value; 186 187 if (auto value = CSSPropertyParserHelpers::consumeIdent(range)) 188 return value; 189 190 return nullptr; 191 } 192 193 MediaQueryExpression::MediaQueryExpression(const String& feature, CSSParserTokenRange& range) 166 194 : m_mediaFeature(feature.convertToASCIILowercase()) 167 195 , m_isValid(false) 168 196 { 197 RefPtr<CSSPrimitiveValue> firstValue = consumeFirstValue(m_mediaFeature, range); 198 if (!firstValue) { 199 if (isFeatureValidWithoutValue(m_mediaFeature)) { 200 // Valid, creates a MediaQueryExp with an 'invalid' MediaQueryExpValue 201 m_isValid = true; 202 } 203 return; 204 } 169 205 // Create value for media query expression that must have 1 or more values. 170 if (!tokenList.size() && isFeatureValidWithoutValue(m_mediaFeature)) { 171 // Valid, creates a MediaQueryExp with an 'invalid' MediaQueryExpValue 206 if (isAspectRatioFeature(m_mediaFeature)) { 207 if (!firstValue->isNumber() || !firstValue->doubleValue()) 208 return; 209 if (!CSSPropertyParserHelpers::consumeSlashIncludingWhitespace(range)) 210 return; 211 RefPtr<CSSPrimitiveValue> denominatorValue = CSSPropertyParserHelpers::consumePositiveInteger(range); 212 if (!denominatorValue) 213 return; 214 215 unsigned numerator = clampTo<unsigned>(firstValue->doubleValue()); 216 unsigned denominator = clampTo<unsigned>(denominatorValue->doubleValue()); 217 m_value = CSSAspectRatioValue::create(numerator, denominator); 172 218 m_isValid = true; 173 } else if (tokenList.size() == 1) { 174 CSSParserToken token = tokenList.first(); 175 if (token.type() == IdentToken) { 176 CSSValueID ident = token.id(); 177 if (!featureWithValidIdent(m_mediaFeature)) 178 return; 179 m_value = CSSPrimitiveValue::createIdentifier(ident); 180 m_isValid = true; 181 } else if (token.type() == NumberToken || token.type() == PercentageToken || token.type() == DimensionToken) { 182 // Check for numeric token types since it is only safe for these types to call numericValue. 183 if (featureWithValidDensity(m_mediaFeature, token) 184 || featureWithValidPositiveLength(m_mediaFeature, token)) { 185 // Media features that must have non-negative <density>, ie. dppx, dpi or dpcm, 186 // or Media features that must have non-negative <length> or number value. 187 m_value = CSSPrimitiveValue::create(token.numericValue(), (CSSPrimitiveValue::UnitType) token.unitType()); 188 m_isValid = true; 189 } else if (featureWithPositiveInteger(m_mediaFeature, token) 190 || featureWithPositiveNumber(m_mediaFeature, token) 191 || featureWithZeroOrOne(m_mediaFeature, token)) { 192 // Media features that must have non-negative integer value, 193 // or media features that must have non-negative number value, 194 // or media features that must have (0|1) value. 195 m_value = CSSPrimitiveValue::create(token.numericValue(), CSSPrimitiveValue::UnitType::CSS_NUMBER); 196 m_isValid = true; 197 } 198 } 199 } else if (tokenList.size() == 3 && isAspectRatioFeature(m_mediaFeature)) { 200 // FIXME: <ratio> is supposed to allow whitespace around the '/' 201 // Applicable to device-aspect-ratio and aspect-ratio. 202 const CSSParserToken& numerator = tokenList[0]; 203 const CSSParserToken& delimiter = tokenList[1]; 204 const CSSParserToken& denominator = tokenList[2]; 205 if (delimiter.type() != DelimiterToken || delimiter.delimiter() != '/') 206 return; 207 if (numerator.type() != NumberToken || numerator.numericValue() <= 0 || numerator.numericValueType() != IntegerValueType) 208 return; 209 if (denominator.type() != NumberToken || denominator.numericValue() <= 0 || denominator.numericValueType() != IntegerValueType) 210 return; 211 212 m_value = CSSAspectRatioValue::create(numerator.numericValue(), denominator.numericValue()); 219 return; 220 } 221 if (featureWithPositiveInteger(m_mediaFeature, *firstValue) || featureWithPositiveNumber(m_mediaFeature, *firstValue) 222 || featureWithZeroOrOne(m_mediaFeature, *firstValue) || featureWithValidDensity(m_mediaFeature, *firstValue) 223 || featureWithValidPositiveLength(m_mediaFeature, *firstValue) || featureWithValidIdent(m_mediaFeature, *firstValue)) { 224 m_value = firstValue; 213 225 m_isValid = true; 226 return; 214 227 } 215 228 } -
trunk/Source/WebCore/css/MediaQueryExpression.h
r220812 r227295 28 28 #pragma once 29 29 30 #include "CSSParserToken .h"30 #include "CSSParserTokenRange.h" 31 31 #include "CSSValue.h" 32 32 #include <memory> … … 41 41 WTF_MAKE_FAST_ALLOCATED; 42 42 public: 43 explicit MediaQueryExpression(const String& mediaFeature, const Vector<CSSParserToken, 4>& tokenList);43 explicit MediaQueryExpression(const String& mediaFeature, CSSParserTokenRange&); 44 44 45 45 const AtomicString& mediaFeature() const; -
trunk/Source/WebCore/css/parser/CSSPropertyParserHelpers.cpp
r224165 r227295 404 404 return calcParser.consumeValue(); 405 405 } 406 return nullptr; 407 } 408 409 RefPtr<CSSPrimitiveValue> consumeResolution(CSSParserTokenRange& range) 410 { 411 const CSSParserToken& token = range.peek(); 412 // Unlike the other types, calc() does not work with <resolution>. 413 if (token.type() != DimensionToken) 414 return nullptr; 415 CSSPrimitiveValue::UnitType unit = token.unitType(); 416 if (unit == CSSPrimitiveValue::UnitType::CSS_DPPX || unit == CSSPrimitiveValue::UnitType::CSS_DPI || unit == CSSPrimitiveValue::UnitType::CSS_DPCM) 417 return CSSValuePool::singleton().createValue(range.consumeIncludingWhitespace().numericValue(), unit); 406 418 return nullptr; 407 419 } -
trunk/Source/WebCore/css/parser/CSSPropertyParserHelpers.h
r218588 r227295 68 68 RefPtr<CSSPrimitiveValue> consumeAngle(CSSParserTokenRange&, CSSParserMode, UnitlessQuirk = UnitlessQuirk::Forbid); 69 69 RefPtr<CSSPrimitiveValue> consumeTime(CSSParserTokenRange&, CSSParserMode, ValueRange, UnitlessQuirk = UnitlessQuirk::Forbid); 70 RefPtr<CSSPrimitiveValue> consumeResolution(CSSParserTokenRange&); 70 71 71 72 RefPtr<CSSPrimitiveValue> consumeIdent(CSSParserTokenRange&); -
trunk/Source/WebCore/css/parser/MediaQueryParser.cpp
r223728 r227295 84 84 85 85 // State machine member functions start here 86 void MediaQueryParser::readRestrictor(CSSParserTokenType type, const CSSParserToken& token )87 { 88 readMediaType(type, token );89 } 90 91 void MediaQueryParser::readMediaNot(CSSParserTokenType type, const CSSParserToken& token )86 void MediaQueryParser::readRestrictor(CSSParserTokenType type, const CSSParserToken& token, CSSParserTokenRange& range) 87 { 88 readMediaType(type, token, range); 89 } 90 91 void MediaQueryParser::readMediaNot(CSSParserTokenType type, const CSSParserToken& token, CSSParserTokenRange& range) 92 92 { 93 93 if (type == IdentToken && equalIgnoringASCIICase(token.value(), "not")) 94 94 setStateAndRestrict(ReadFeatureStart, MediaQuery::Not); 95 95 else 96 readFeatureStart(type, token );96 readFeatureStart(type, token, range); 97 97 } 98 98 … … 106 106 } 107 107 108 void MediaQueryParser::readMediaType(CSSParserTokenType type, const CSSParserToken& token )108 void MediaQueryParser::readMediaType(CSSParserTokenType type, const CSSParserToken& token, CSSParserTokenRange& range) 109 109 { 110 110 if (type == LeftParenthesisToken) { … … 130 130 m_state = SkipUntilComma; 131 131 if (type == CommaToken) 132 skipUntilComma(type, token );132 skipUntilComma(type, token, range); 133 133 } 134 134 } … … 143 143 } 144 144 145 void MediaQueryParser::readAnd(CSSParserTokenType type, const CSSParserToken& token )145 void MediaQueryParser::readAnd(CSSParserTokenType type, const CSSParserToken& token, CSSParserTokenRange& /*range*/) 146 146 { 147 147 if (type == IdentToken && equalIgnoringASCIICase(token.value(), "and")) { … … 156 156 } 157 157 158 void MediaQueryParser::readFeatureStart(CSSParserTokenType type, const CSSParserToken& /*token*/ )158 void MediaQueryParser::readFeatureStart(CSSParserTokenType type, const CSSParserToken& /*token*/, CSSParserTokenRange& /*range*/) 159 159 { 160 160 if (type == LeftParenthesisToken) … … 164 164 } 165 165 166 void MediaQueryParser::readFeature(CSSParserTokenType type, const CSSParserToken& token )166 void MediaQueryParser::readFeature(CSSParserTokenType type, const CSSParserToken& token, CSSParserTokenRange& /*range*/) 167 167 { 168 168 if (type == IdentToken) { … … 173 173 } 174 174 175 void MediaQueryParser::readFeatureColon(CSSParserTokenType type, const CSSParserToken& token) 176 { 177 if (type == ColonToken) 178 m_state = ReadFeatureValue; 179 else if (type == RightParenthesisToken || type == EOFToken) 180 readFeatureEnd(type, token); 181 else 175 void MediaQueryParser::readFeatureColon(CSSParserTokenType type, const CSSParserToken& token, CSSParserTokenRange& range) 176 { 177 if (type == ColonToken) { 178 while (range.peek().type() == WhitespaceToken) 179 range.consume(); 180 if (range.peek().type() == RightParenthesisToken || range.peek().type() == EOFToken) 181 m_state = SkipUntilBlockEnd; 182 else 183 m_state = ReadFeatureValue; 184 } else if (type == RightParenthesisToken || type == EOFToken) { 185 m_mediaQueryData.addExpression(range); 186 readFeatureEnd(type, token, range); 187 } else 182 188 m_state = SkipUntilBlockEnd; 183 189 } 184 190 185 void MediaQueryParser::readFeatureValue(CSSParserTokenType type, const CSSParserToken& token) 186 { 187 if (type == DimensionToken && token.unitType() == CSSPrimitiveValue::UnitType::CSS_UNKNOWN) 188 m_state = SkipUntilComma; 189 else { 190 if (m_mediaQueryData.tryAddParserToken(type, token)) 191 m_state = ReadFeatureEnd; 192 else 193 m_state = SkipUntilBlockEnd; 194 } 195 } 196 197 void MediaQueryParser::readFeatureEnd(CSSParserTokenType type, const CSSParserToken& token) 191 void MediaQueryParser::readFeatureValue(CSSParserTokenType type, const CSSParserToken& token, CSSParserTokenRange& range) 192 { 193 if (type == DimensionToken && token.unitType() == CSSPrimitiveValue::UnitType::CSS_UNKNOWN) { 194 range.consume(); 195 m_state = SkipUntilComma; 196 } else { 197 m_mediaQueryData.addExpression(range); 198 m_state = ReadFeatureEnd; 199 } 200 } 201 202 void MediaQueryParser::readFeatureEnd(CSSParserTokenType type, const CSSParserToken& /*token*/, CSSParserTokenRange& /*range*/) 198 203 { 199 204 if (type == RightParenthesisToken || type == EOFToken) { 200 if (type != EOFToken && m_mediaQueryData. addExpression())205 if (type != EOFToken && m_mediaQueryData.lastExpressionValid()) 201 206 m_state = ReadAnd; 202 207 else 203 208 m_state = SkipUntilComma; 204 } else if (type == DelimiterToken && token.delimiter() == '/') { 205 m_mediaQueryData.tryAddParserToken(type, token); 206 m_state = ReadFeatureValue; 207 } else 209 } else { 210 m_mediaQueryData.removeLastExpression(); 208 211 m_state = SkipUntilBlockEnd; 209 } 210 211 void MediaQueryParser::skipUntilComma(CSSParserTokenType type, const CSSParserToken& /*token*/) 212 } 213 } 214 215 void MediaQueryParser::skipUntilComma(CSSParserTokenType type, const CSSParserToken& /*token*/, CSSParserTokenRange& /*range*/) 212 216 { 213 217 if ((type == CommaToken && !m_blockWatcher.blockLevel()) || type == EOFToken) { … … 219 223 } 220 224 221 void MediaQueryParser::skipUntilBlockEnd(CSSParserTokenType /*type */, const CSSParserToken& token )225 void MediaQueryParser::skipUntilBlockEnd(CSSParserTokenType /*type */, const CSSParserToken& token, CSSParserTokenRange& /*range*/) 222 226 { 223 227 if (token.getBlockType() == CSSParserToken::BlockEnd && !m_blockWatcher.blockLevel()) … … 225 229 } 226 230 227 void MediaQueryParser::done(CSSParserTokenType /*type*/, const CSSParserToken& /*token*/ ) { }231 void MediaQueryParser::done(CSSParserTokenType /*type*/, const CSSParserToken& /*token*/, CSSParserTokenRange& /*range*/) { } 228 232 229 233 void MediaQueryParser::handleBlocks(const CSSParserToken& token) … … 234 238 } 235 239 236 void MediaQueryParser::processToken(const CSSParserToken& token )240 void MediaQueryParser::processToken(const CSSParserToken& token, CSSParserTokenRange& range) 237 241 { 238 242 CSSParserTokenType type = token.type(); 239 243 240 handleBlocks(token); 241 m_blockWatcher.handleToken(token); 244 if (m_state != ReadFeatureValue || type == WhitespaceToken) { 245 handleBlocks(token); 246 m_blockWatcher.handleToken(token); 247 range.consume(); 248 } 242 249 243 250 // Call the function that handles current state 244 251 if (type != WhitespaceToken) 245 ((this)->*(m_state))(type, token );252 ((this)->*(m_state))(type, token, range); 246 253 } 247 254 … … 250 257 { 251 258 while (!range.atEnd()) 252 processToken(range. consume());259 processToken(range.peek(), range); 253 260 254 261 // FIXME: Can we get rid of this special case? 255 262 if (m_parserType == MediaQuerySetParser) 256 processToken(CSSParserToken(EOFToken) );263 processToken(CSSParserToken(EOFToken), range); 257 264 258 265 if (m_state != ReadAnd && m_state != ReadRestrictor && m_state != Done && m_state != ReadMediaNot) { … … 278 285 m_mediaTypeSet = false; 279 286 m_mediaFeature = String(); 280 m_valueList.clear();281 287 m_expressions.clear(); 282 288 } 283 289 284 bool MediaQueryData::addExpression() 285 { 286 MediaQueryExpression expression = MediaQueryExpression(m_mediaFeature, m_valueList); 287 bool isValid = expression.isValid(); 290 void MediaQueryData::addExpression(CSSParserTokenRange& range) 291 { 292 MediaQueryExpression expression = MediaQueryExpression(m_mediaFeature, range); 288 293 m_expressions.append(WTFMove(expression)); 289 m_valueList.clear(); 290 return isValid; 291 } 292 293 bool MediaQueryData::tryAddParserToken(CSSParserTokenType type, const CSSParserToken& token) 294 { 295 if (type == NumberToken || type == PercentageToken || type == DimensionToken 296 || type == DelimiterToken || type == IdentToken) { 297 m_valueList.append(token); 298 return true; 299 } 300 301 return false; 294 } 295 296 bool MediaQueryData::lastExpressionValid() 297 { 298 return m_expressions.last().isValid(); 299 } 300 301 void MediaQueryData::removeLastExpression() 302 { 303 m_expressions.removeLast(); 302 304 } 303 305 -
trunk/Source/WebCore/css/parser/MediaQueryParser.h
r218588 r227295 46 46 MediaQueryData(); 47 47 void clear(); 48 bool addExpression(); 49 bool tryAddParserToken(CSSParserTokenType, const CSSParserToken&); 48 void addExpression(CSSParserTokenRange&); 49 bool lastExpressionValid(); 50 void removeLastExpression(); 50 51 void setMediaType(const String&); 51 52 … … 69 70 Vector<MediaQueryExpression> m_expressions; 70 71 String m_mediaFeature; 71 Vector<CSSParserToken, 4> m_valueList;72 72 bool m_mediaTypeSet; 73 73 }; … … 91 91 RefPtr<MediaQuerySet> parseInternal(CSSParserTokenRange); 92 92 93 void processToken(const CSSParserToken& );93 void processToken(const CSSParserToken&, CSSParserTokenRange&); 94 94 95 void readRestrictor(CSSParserTokenType, const CSSParserToken& );96 void readMediaNot(CSSParserTokenType, const CSSParserToken& );97 void readMediaType(CSSParserTokenType, const CSSParserToken& );98 void readAnd(CSSParserTokenType, const CSSParserToken& );99 void readFeatureStart(CSSParserTokenType, const CSSParserToken& );100 void readFeature(CSSParserTokenType, const CSSParserToken& );101 void readFeatureColon(CSSParserTokenType, const CSSParserToken& );102 void readFeatureValue(CSSParserTokenType, const CSSParserToken& );103 void readFeatureEnd(CSSParserTokenType, const CSSParserToken& );104 void skipUntilComma(CSSParserTokenType, const CSSParserToken& );105 void skipUntilBlockEnd(CSSParserTokenType, const CSSParserToken& );106 void done(CSSParserTokenType, const CSSParserToken& );95 void readRestrictor(CSSParserTokenType, const CSSParserToken&, CSSParserTokenRange&); 96 void readMediaNot(CSSParserTokenType, const CSSParserToken&, CSSParserTokenRange&); 97 void readMediaType(CSSParserTokenType, const CSSParserToken&, CSSParserTokenRange&); 98 void readAnd(CSSParserTokenType, const CSSParserToken&, CSSParserTokenRange&); 99 void readFeatureStart(CSSParserTokenType, const CSSParserToken&, CSSParserTokenRange&); 100 void readFeature(CSSParserTokenType, const CSSParserToken&, CSSParserTokenRange&); 101 void readFeatureColon(CSSParserTokenType, const CSSParserToken&, CSSParserTokenRange&); 102 void readFeatureValue(CSSParserTokenType, const CSSParserToken&, CSSParserTokenRange&); 103 void readFeatureEnd(CSSParserTokenType, const CSSParserToken&, CSSParserTokenRange&); 104 void skipUntilComma(CSSParserTokenType, const CSSParserToken&, CSSParserTokenRange&); 105 void skipUntilBlockEnd(CSSParserTokenType, const CSSParserToken&, CSSParserTokenRange&); 106 void done(CSSParserTokenType, const CSSParserToken&, CSSParserTokenRange&); 107 107 108 using State = void (MediaQueryParser::*)(CSSParserTokenType, const CSSParserToken& );108 using State = void (MediaQueryParser::*)(CSSParserTokenType, const CSSParserToken&, CSSParserTokenRange&); 109 109 110 110 void setStateAndRestrict(State, MediaQuery::Restrictor);
Note: See TracChangeset
for help on using the changeset viewer.