Fix parsing of HTML dimension values to follow spec update and align better with other browsers.

See https://github.com/whatwg/html/pull/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
diff --git a/html/dom/reflection.js b/html/dom/reflection.js
index 4420273..5209762 100644
--- a/html/dom/reflection.js
+++ b/html/dom/reflection.js
@@ -145,7 +145,7 @@
     "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}
@@ -168,7 +168,7 @@
         "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}],
@@ -233,7 +233,7 @@
     "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}]
@@ -249,7 +249,7 @@
     "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}],
@@ -282,7 +282,7 @@
                      "\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;}}],
@@ -321,7 +321,7 @@
                      "\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;}}],
@@ -357,7 +357,7 @@
                      "\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;}}],
@@ -399,7 +399,7 @@
                      "\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;}}],
@@ -439,7 +439,7 @@
                          "\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;}}],
@@ -478,7 +478,7 @@
                      "\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;}}],
@@ -519,7 +519,7 @@
             "\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;}}],
@@ -532,7 +532,7 @@
                         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
diff --git a/html/rendering/dimension-attributes.html b/html/rendering/dimension-attributes.html
index bfc70ec..2c544aa 100644
--- a/html/rendering/dimension-attributes.html
+++ b/html/rendering/dimension-attributes.html
@@ -35,22 +35,16 @@
   [ "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" ],
 ];
 
  /*
@@ -58,9 +52,7 @@
   */
 const zero_values = [
   [ "0", "0px" ],
-  [ "+0", "0px" ],
   [ "0%", "0%" ],
-  [ "+0%", "0%" ],
   [ "0px", "0px" ],
 ];
 
@@ -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 =
diff --git a/html/rendering/non-replaced-elements/the-hr-element-0/width-ref.html b/html/rendering/non-replaced-elements/the-hr-element-0/width-ref.html
index 245fde9..71e7651 100644
--- a/html/rendering/non-replaced-elements/the-hr-element-0/width-ref.html
+++ b/html/rendering/non-replaced-elements/the-hr-element-0/width-ref.html
@@ -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>