Skip to content

Commit

Permalink
Fix parsing of HTML dimension values to follow spec update and align …
Browse files Browse the repository at this point in the history
…better with other browsers.

See whatwg/html#4747 for the spec changes

Differential Revision: https://phabricator.services.mozilla.com/D36643

bugzilla-url: https://bugzilla.mozilla.org/show_bug.cgi?id=1562690
gecko-commit: 0db6b1468cc36416a86f9a8a70da14f878281929
gecko-integration-branch: central
gecko-reviewers: mccr8
  • Loading branch information
bzbarsky authored and moz-wptsync-bot committed Jul 11, 2019
1 parent ef6e66c commit f44e4be
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 26 deletions.
24 changes: 12 additions & 12 deletions html/dom/reflection.js
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ ReflectionTests.typeMap = {
"string": {
"jsType": "string",
"defaultVal": "",
"domTests": ["", " " + binaryString + " foo ", undefined, 7, 1.5, "5%", true,
"domTests": ["", " " + binaryString + " foo ", undefined, 7, 1.5, "5%", "+100", ".5", true,
false, {"test": 6}, NaN, +Infinity, -Infinity, "\0", null,
{"toString":function(){return "test-toString";}},
{"valueOf":function(){return "test-valueOf";}, toString:null}
Expand All @@ -168,7 +168,7 @@ ReflectionTests.typeMap = {
"jsType": "string",
"defaultVal": "",
"domTests": ["", " foo ", "http://site.example/",
"//site.example/path???@#l", binaryString, undefined, 7, 1.5, "5%", true,
"//site.example/path???@#l", binaryString, undefined, 7, 1.5, "5%", "+100", ".5", true,
false, {"test": 6}, NaN, +Infinity, -Infinity, "\0", null,
{"toString":function(){return "test-toString";}},
{"valueOf":function(){return "test-valueOf";}, toString:null}],
Expand Down Expand Up @@ -233,7 +233,7 @@ ReflectionTests.typeMap = {
"enum": {
"jsType": "string",
"defaultVal": "",
"domTests": ["", " " + binaryString + " foo ", undefined, 7, 1.5, "5%", true,
"domTests": ["", " " + binaryString + " foo ", undefined, 7, 1.5, "5%", "+100", ".5", true,
false, {"test": 6}, NaN, +Infinity, -Infinity, "\0", null,
{"toString":function(){return "test-toString";}},
{"valueOf":function(){return "test-valueOf";}, toString:null}]
Expand All @@ -249,7 +249,7 @@ ReflectionTests.typeMap = {
"boolean": {
"jsType": "boolean",
"defaultVal": false,
"domTests": ["", " foo ", undefined, null, 7, 1.5, "5%", true, false,
"domTests": ["", " foo ", undefined, null, 7, 1.5, "5%", "+100", ".5", true, false,
{"test": 6}, NaN, +Infinity, -Infinity, "\0",
{"toString":function(){return "test-toString";}},
{"valueOf":function(){return "test-valueOf";}, toString:null}],
Expand Down Expand Up @@ -282,7 +282,7 @@ ReflectionTests.typeMap = {
"\u20007", "\u20017", "\u20027", "\u20037", "\u20047", "\u20057",
"\u20067", "\u20077", "\u20087", "\u20097", "\u200A7", "\u202F7",
"\u30007",
undefined, 1.5, "5%", true, false, {"test": 6}, NaN, +Infinity,
undefined, 1.5, "5%", "+100", ".5", true, false, {"test": 6}, NaN, +Infinity,
-Infinity, "\0",
{toString:function() {return 2;}, valueOf: null},
{valueOf:function() {return 3;}}],
Expand Down Expand Up @@ -321,7 +321,7 @@ ReflectionTests.typeMap = {
"\u20007", "\u20017", "\u20027", "\u20037", "\u20047", "\u20057",
"\u20067", "\u20077", "\u20087", "\u20097", "\u200A7", "\u202F7",
"\u30007",
undefined, 1.5, "5%", true, false, {"test": 6}, NaN, +Infinity,
undefined, 1.5, "5%", "+100", ".5", true, false, {"test": 6}, NaN, +Infinity,
-Infinity, "\0",
{toString:function() {return 2;}, valueOf: null},
{valueOf:function() {return 3;}}],
Expand Down Expand Up @@ -357,7 +357,7 @@ ReflectionTests.typeMap = {
"\u20007", "\u20017", "\u20027", "\u20037", "\u20047", "\u20057",
"\u20067", "\u20077", "\u20087", "\u20097", "\u200A7", "\u202F7",
"\u30007",
" " + binaryString + " foo ", undefined, 1.5, "5%", true, false,
" " + binaryString + " foo ", undefined, 1.5, "5%", "+100", ".5", true, false,
{"test": 6}, NaN, +Infinity, -Infinity, "\0",
{toString:function() {return 2;}, valueOf: null},
{valueOf:function() {return 3;}}],
Expand Down Expand Up @@ -399,7 +399,7 @@ ReflectionTests.typeMap = {
"\u20007", "\u20017", "\u20027", "\u20037", "\u20047", "\u20057",
"\u20067", "\u20077", "\u20087", "\u20097", "\u200A7", "\u202F7",
"\u30007",
" " + binaryString + " foo ", undefined, 1.5, "5%", true, false,
" " + binaryString + " foo ", undefined, 1.5, "5%", "+100", ".5", true, false,
{"test": 6}, NaN, +Infinity, -Infinity, "\0",
{toString:function() {return 2;}, valueOf: null},
{valueOf:function() {return 3;}}],
Expand Down Expand Up @@ -439,7 +439,7 @@ ReflectionTests.typeMap = {
"\u20007", "\u20017", "\u20027", "\u20037", "\u20047", "\u20057",
"\u20067", "\u20077", "\u20087", "\u20097", "\u200A7", "\u202F7",
"\u30007",
" " + binaryString + " foo ", undefined, 1.5, "5%", true, false,
" " + binaryString + " foo ", undefined, 1.5, "5%", "+100", ".5", true, false,
{"test": 6}, NaN, +Infinity, -Infinity, "\0",
{toString:function() {return 2;}, valueOf: null},
{valueOf:function() {return 3;}}],
Expand Down Expand Up @@ -478,7 +478,7 @@ ReflectionTests.typeMap = {
"\u20007", "\u20017", "\u20027", "\u20037", "\u20047", "\u20057",
"\u20067", "\u20077", "\u20087", "\u20097", "\u200A7", "\u202F7",
"\u30007",
" " + binaryString + " foo ", undefined, 1.5, "5%", true, false,
" " + binaryString + " foo ", undefined, 1.5, "5%", "+100", ".5", true, false,
{"test": 6}, NaN, +Infinity, -Infinity, "\0",
{toString:function() {return 2;}, valueOf: null},
{valueOf:function() {return 3;}}],
Expand Down Expand Up @@ -519,7 +519,7 @@ ReflectionTests.typeMap = {
"\u20007", "\u20017", "\u20027", "\u20037", "\u20047", "\u20057",
"\u20067", "\u20077", "\u20087", "\u20097", "\u200A7", "\u202F7",
"\u30007",
" " + binaryString + " foo ", undefined, 1.5, "5%", true, false,
" " + binaryString + " foo ", undefined, 1.5, "5%", "+100", ".5", true, false,
{"test": 6}, NaN, +Infinity, -Infinity, "\0",
{toString:function() {return 2;}, valueOf: null},
{valueOf:function() {return 3;}}],
Expand All @@ -532,7 +532,7 @@ ReflectionTests.typeMap = {
null, null, null, null, null, null,
null,
// End leading whitespace tests
null, null, 1.5, 5, null, null,
null, null, 1.5, 5, 100, 0.5, null, null,
null, null, null, null, null,
2, 3],
// I checked that ES ToString is well-defined for all of these (I
Expand Down
29 changes: 17 additions & 12 deletions html/rendering/dimension-attributes.html
Original file line number Diff line number Diff line change
Expand Up @@ -35,32 +35,24 @@
[ "200.25", "200.25px" ],
[ "200.7", "200.7px" ],
[ "200.", "200px" ],
[ "+200", "200px" ],
[ "200in", "200px" ],
[ "200.25in", "200.25px" ],
[ " +200in ", "200px" ],
[ " +200.25in ", "200.25px" ],
[ "200 %", "200px" ],
[ "200 abc", "200px" ],
[ "200%", "200%" ],
[ "200%abc", "200%" ],
[ "+200%", "200%" ],
[ "200.25%", "200.25%" ],
// https://github.com/whatwg/html/issues/4736 tracks the fact that "200.%"
// should probably be mapped as "200%", not "200px".
[ "200.%", "200px" ],
[ " +200.25% ", "200.25%" ],
[ " +200.25%abc", "200.25%" ],
[ "200.%", "200%" ],
[ "20.25e2", "20.25px" ],
[ "20.25E2", "20.25px" ],
];

/*
* Values that are only valid for the not-ignoring-zero case.
*/
const zero_values = [
[ "0", "0px" ],
[ "+0", "0px" ],
[ "0%", "0%" ],
[ "+0%", "0%" ],
[ "0px", "0px" ],
];

Expand All @@ -76,7 +68,20 @@
" -200",
"+-200",
"-+200",
"-200%"
"-200%",
"+200",
" +200in ",
" +200.25in ",
"+200%",
" +200.25% ",
" +200.25%abc",
"+0",
"+0%",
".",
".%",
".x",
".5",
".5%"
];

const valid_values_with_0 =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,6 @@
<div class=hr style="width: 100.99px"></div>
<div class=hr style="width: 0%"></div>
<div class=hr style="width: 0%"></div>
<div class=hr style="width: 0%"></div>
<div class=hr style="width: 0%"></div>
<div class=hr></div>
<div class=hr></div>
<div class=hr></div>

0 comments on commit f44e4be

Please sign in to comment.