Title: [217907] trunk
Revision
217907
Author
[email protected]
Date
2017-06-07 15:21:30 -0700 (Wed, 07 Jun 2017)

Log Message

Align <col span>/<colgroup span> limits with the latest HTML specification
https://bugs.webkit.org/show_bug.cgi?id=173049

Reviewed by Daniel Bates.

LayoutTests/imported/w3c:

Resync web-platform-tests after:
https://github.com/w3c/web-platform-tests/pull/6172

This helps gain coverage for the change in this patch.

* resources/import-expectations.json:
* web-platform-tests/html/dom/elements-tabular.js:
* web-platform-tests/html/dom/reflection-tabular-expected.txt:
* web-platform-tests/html/semantics/tabular-data/processing-model-1/col-span-limits-expected.txt: Added.
* web-platform-tests/html/semantics/tabular-data/processing-model-1/col-span-limits.html: Added.
* web-platform-tests/html/semantics/tabular-data/processing-model-1/w3c-import.log:

Source/WebCore:

Align <col span>/<colgroup span> limits with the latest HTML specification after:
- https://github.com/whatwg/html/issues/2705
- https://github.com/whatwg/html/pull/2734

In particular, col / colspan's span attribute is now clamped to the [1, 1000] range.

Test: imported/w3c/web-platform-tests/html/semantics/tabular-data/processing-model-1/col-span-limits.html

[1] https://html.spec.whatwg.org/#dom-colgroup-span
[2] https://html.spec.whatwg.org/#clamped-to-the-range
[3] https://github.com/whatwg/html/pull/2734/files

* html/HTMLTableColElement.cpp:
(WebCore::HTMLTableColElement::parseAttribute):
As per [1][2], the span attribute should be clamped to the range [1, 1000] with a default value of 1 (on getting).

(WebCore::HTMLTableColElement::setSpan):
As per [2], on setting, we should behave the same as setting a regular reflected unsigned integer when an attribute
is clamped to a range. Therefore, we now call limitToOnlyHTMLNonNegative() instead of
limitToOnlyHTMLNonNegativeNumbersGreaterThanZero(). We used to call limitToOnlyHTMLNonNegativeNumbersGreaterThanZero()
because the value used to be limited to only non-negative numbers greater than zero with fallback before [3]. Without
this change, "col.span = 0" would set the content attribute to 1 instead of 0, which would be wrong.

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/imported/w3c/ChangeLog (217906 => 217907)


--- trunk/LayoutTests/imported/w3c/ChangeLog	2017-06-07 22:18:56 UTC (rev 217906)
+++ trunk/LayoutTests/imported/w3c/ChangeLog	2017-06-07 22:21:30 UTC (rev 217907)
@@ -1,3 +1,22 @@
+2017-06-07  Chris Dumez  <[email protected]>
+
+        Align <col span>/<colgroup span> limits with the latest HTML specification
+        https://bugs.webkit.org/show_bug.cgi?id=173049
+
+        Reviewed by Daniel Bates.
+
+        Resync web-platform-tests after:
+        https://github.com/w3c/web-platform-tests/pull/6172
+
+        This helps gain coverage for the change in this patch.
+
+        * resources/import-expectations.json:
+        * web-platform-tests/html/dom/elements-tabular.js:
+        * web-platform-tests/html/dom/reflection-tabular-expected.txt:
+        * web-platform-tests/html/semantics/tabular-data/processing-model-1/col-span-limits-expected.txt: Added.
+        * web-platform-tests/html/semantics/tabular-data/processing-model-1/col-span-limits.html: Added.
+        * web-platform-tests/html/semantics/tabular-data/processing-model-1/w3c-import.log:
+
 2017-06-05  Sam Weinig  <[email protected]>
 
         [WebIDL] PutForwards is not implemented to spec as illustrated by the WPT WebIDL/ecmascript-binding/put-forwards.html

Modified: trunk/LayoutTests/imported/w3c/resources/import-expectations.json (217906 => 217907)


--- trunk/LayoutTests/imported/w3c/resources/import-expectations.json	2017-06-07 22:18:56 UTC (rev 217906)
+++ trunk/LayoutTests/imported/w3c/resources/import-expectations.json	2017-06-07 22:21:30 UTC (rev 217907)
@@ -202,6 +202,7 @@
     "web-platform-tests/html/semantics/scripting-1/the-script-element/script-for-event.xhtml": "skip", 
     "web-platform-tests/html/semantics/scripting-1/the-script-element/script-text.xhtml": "skip", 
     "web-platform-tests/html/semantics/tabular-data": "import", 
+    "web-platform-tests/html/semantics/tabular-data/processing-model-1": "import", 
     "web-platform-tests/html/semantics/text-level-semantics/the-data-element": "skip", 
     "web-platform-tests/html/syntax": "import", 
     "web-platform-tests/html/the-xhtml-syntax": "skip", 

Modified: trunk/LayoutTests/imported/w3c/web-platform-tests/html/dom/elements-tabular.js (217906 => 217907)


--- trunk/LayoutTests/imported/w3c/web-platform-tests/html/dom/elements-tabular.js	2017-06-07 22:18:56 UTC (rev 217906)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/html/dom/elements-tabular.js	2017-06-07 22:21:30 UTC (rev 217907)
@@ -17,7 +17,7 @@
     align: "string",
   },
   colgroup: {
-    span: {type: "limited unsigned long with fallback", defaultVal: 1},
+    span: {type: "clamped unsigned long", defaultVal: 1, min: 1, max: 1000},
 
     // Obsolete
     align: "string",
@@ -28,7 +28,7 @@
   },
   col: {
     // Conforming
-    span: {type: "limited unsigned long with fallback", defaultVal: 1},
+    span: {type: "clamped unsigned long", defaultVal: 1, min: 1, max: 1000},
 
     // Obsolete
     align: "string",

Modified: trunk/LayoutTests/imported/w3c/web-platform-tests/html/dom/reflection-tabular-expected.txt (217906 => 217907)


--- trunk/LayoutTests/imported/w3c/web-platform-tests/html/dom/reflection-tabular-expected.txt	2017-06-07 22:18:56 UTC (rev 217906)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/html/dom/reflection-tabular-expected.txt	2017-06-07 22:21:30 UTC (rev 217907)
@@ -1116,11 +1116,17 @@
 PASS colgroup.span: setAttribute() to "\0" 
 PASS colgroup.span: setAttribute() to object "2" 
 PASS colgroup.span: setAttribute() to object "3" 
+PASS colgroup.span: setAttribute() to 1000 
+PASS colgroup.span: setAttribute() to 1001 
 PASS colgroup.span: IDL set to 0 
 PASS colgroup.span: IDL set to 1 
+PASS colgroup.span: IDL set to 257 
 PASS colgroup.span: IDL set to 2147483647 
+PASS colgroup.span: IDL set to "-0" 
 PASS colgroup.span: IDL set to 2147483648 
 PASS colgroup.span: IDL set to 4294967295 
+PASS colgroup.span: IDL set to 1000 
+PASS colgroup.span: IDL set to 1001 
 PASS colgroup.align: typeof IDL attribute 
 PASS colgroup.align: IDL get with DOM attribute unset 
 PASS colgroup.align: setAttribute() to "" 
@@ -1582,11 +1588,17 @@
 PASS col.span: setAttribute() to "\0" 
 PASS col.span: setAttribute() to object "2" 
 PASS col.span: setAttribute() to object "3" 
+PASS col.span: setAttribute() to 1000 
+PASS col.span: setAttribute() to 1001 
 PASS col.span: IDL set to 0 
 PASS col.span: IDL set to 1 
+PASS col.span: IDL set to 257 
 PASS col.span: IDL set to 2147483647 
+PASS col.span: IDL set to "-0" 
 PASS col.span: IDL set to 2147483648 
 PASS col.span: IDL set to 4294967295 
+PASS col.span: IDL set to 1000 
+PASS col.span: IDL set to 1001 
 PASS col.align: typeof IDL attribute 
 PASS col.align: IDL get with DOM attribute unset 
 PASS col.align: setAttribute() to "" 

Added: trunk/LayoutTests/imported/w3c/web-platform-tests/html/semantics/tabular-data/processing-model-1/col-span-limits-expected.txt (0 => 217907)


--- trunk/LayoutTests/imported/w3c/web-platform-tests/html/semantics/tabular-data/processing-model-1/col-span-limits-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/html/semantics/tabular-data/processing-model-1/col-span-limits-expected.txt	2017-06-07 22:21:30 UTC (rev 217907)
@@ -0,0 +1,7 @@
+
+PASS col span of 1000 must work 
+PASS col span of 1001 must be treated as 1000 
+
+These two must look the same, each having 2 cells in one row:
+
+

Added: trunk/LayoutTests/imported/w3c/web-platform-tests/html/semantics/tabular-data/processing-model-1/col-span-limits.html (0 => 217907)


--- trunk/LayoutTests/imported/w3c/web-platform-tests/html/semantics/tabular-data/processing-model-1/col-span-limits.html	                        (rev 0)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/html/semantics/tabular-data/processing-model-1/col-span-limits.html	2017-06-07 22:21:30 UTC (rev 217907)
@@ -0,0 +1,59 @@
+<!DOCTYPE html>
+<title>Limits on col/colgroup.span</title>
+<script src=""
+<script src=""
+<style>
+  div.square {
+    height:20px;
+    width:20px;
+    border:1px solid lime;
+  }
+  main table {
+    border-collapse:collapse;
+    border:1px solid blue;
+  }
+  main table col {
+    border-left:2px solid black;
+  }
+</style>
+<div id=log></div>
+<main>
+<table id=table1>
+  <col span=1000>
+  <tr>
+    <td colspan=999><div class="square"></div></td>
+    <td><div class="square"></div></td>
+  </tr>
+  <tr>
+    <td colspan=1000><div class="square"></div></td>
+  </tr>
+</table>
+<br>
+These two must look the same, each having 2 cells in one row:
+<table id=table2>
+  <col span=1000>
+  <tr>
+    <td colspan=1000><div class="square"></div></td>
+    <td><div class="square"></div></td>
+  </tr>
+</table>
+<br>
+<table id=table3>
+  <col span=1001>
+  <tr>
+    <td colspan=1000><div class="square"></div></td>
+    <td><div class="square"></div></td>
+  </tr>
+</table>
+</main>
+
+<script>
+test(() => {
+    assert_equals(table1.offsetWidth, 53);
+}, "col span of 1000 must work");
+
+test(() => {
+    assert_equals(table2.offsetWidth, 51, "table2 width");
+    assert_equals(table3.offsetWidth, 51, "table3 width");
+}, "col span of 1001 must be treated as 1000");
+</script>

Modified: trunk/LayoutTests/imported/w3c/web-platform-tests/html/semantics/tabular-data/processing-model-1/w3c-import.log (217906 => 217907)


--- trunk/LayoutTests/imported/w3c/web-platform-tests/html/semantics/tabular-data/processing-model-1/w3c-import.log	2017-06-07 22:18:56 UTC (rev 217906)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/html/semantics/tabular-data/processing-model-1/w3c-import.log	2017-06-07 22:21:30 UTC (rev 217907)
@@ -14,5 +14,6 @@
 None
 ------------------------------------------------------------------------
 List of files:
+/LayoutTests/imported/w3c/web-platform-tests/html/semantics/tabular-data/processing-model-1/col-span-limits.html
 /LayoutTests/imported/w3c/web-platform-tests/html/semantics/tabular-data/processing-model-1/contains.json
 /LayoutTests/imported/w3c/web-platform-tests/html/semantics/tabular-data/processing-model-1/span-limits.html

Modified: trunk/Source/WebCore/ChangeLog (217906 => 217907)


--- trunk/Source/WebCore/ChangeLog	2017-06-07 22:18:56 UTC (rev 217906)
+++ trunk/Source/WebCore/ChangeLog	2017-06-07 22:21:30 UTC (rev 217907)
@@ -1,3 +1,33 @@
+2017-06-07  Chris Dumez  <[email protected]>
+
+        Align <col span>/<colgroup span> limits with the latest HTML specification
+        https://bugs.webkit.org/show_bug.cgi?id=173049
+
+        Reviewed by Daniel Bates.
+
+        Align <col span>/<colgroup span> limits with the latest HTML specification after:
+        - https://github.com/whatwg/html/issues/2705
+        - https://github.com/whatwg/html/pull/2734
+
+        In particular, col / colspan's span attribute is now clamped to the [1, 1000] range.
+
+        Test: imported/w3c/web-platform-tests/html/semantics/tabular-data/processing-model-1/col-span-limits.html
+
+        [1] https://html.spec.whatwg.org/#dom-colgroup-span
+        [2] https://html.spec.whatwg.org/#clamped-to-the-range
+        [3] https://github.com/whatwg/html/pull/2734/files
+
+        * html/HTMLTableColElement.cpp:
+        (WebCore::HTMLTableColElement::parseAttribute):
+        As per [1][2], the span attribute should be clamped to the range [1, 1000] with a default value of 1 (on getting).
+
+        (WebCore::HTMLTableColElement::setSpan):
+        As per [2], on setting, we should behave the same as setting a regular reflected unsigned integer when an attribute
+        is clamped to a range. Therefore, we now call limitToOnlyHTMLNonNegative() instead of
+        limitToOnlyHTMLNonNegativeNumbersGreaterThanZero(). We used to call limitToOnlyHTMLNonNegativeNumbersGreaterThanZero()
+        because the value used to be limited to only non-negative numbers greater than zero with fallback before [3]. Without
+        this change, "col.span = 0" would set the content attribute to 1 instead of 0, which would be wrong.
+
 2017-06-07  Jer Noble  <[email protected]>
 
         Exempt exclusively wall-powered devices from hardware codec requirement

Modified: trunk/Source/WebCore/html/HTMLTableColElement.cpp (217906 => 217907)


--- trunk/Source/WebCore/html/HTMLTableColElement.cpp	2017-06-07 22:18:56 UTC (rev 217906)
+++ trunk/Source/WebCore/html/HTMLTableColElement.cpp	2017-06-07 22:21:30 UTC (rev 217907)
@@ -34,6 +34,10 @@
 
 namespace WebCore {
 
+const unsigned defaultSpan { 1 };
+const unsigned minSpan { 1 };
+const unsigned maxSpan { 1000 };
+
 using namespace HTMLNames;
 
 inline HTMLTableColElement::HTMLTableColElement(const QualifiedName& tagName, Document& document)
@@ -65,7 +69,7 @@
 void HTMLTableColElement::parseAttribute(const QualifiedName& name, const AtomicString& value)
 {
     if (name == spanAttr) {
-        m_span = limitToOnlyHTMLNonNegativeNumbersGreaterThanZero(value);
+        m_span = clampHTMLNonNegativeIntegerToRange(value, minSpan, maxSpan, defaultSpan);
         if (is<RenderTableCol>(renderer()))
             downcast<RenderTableCol>(*renderer()).updateFromElement();
     } else if (name == widthAttr) {
@@ -90,9 +94,9 @@
     return nullptr;
 }
 
-void HTMLTableColElement::setSpan(unsigned n)
+void HTMLTableColElement::setSpan(unsigned span)
 {
-    setUnsignedIntegralAttribute(spanAttr, limitToOnlyHTMLNonNegativeNumbersGreaterThanZero(n));
+    setUnsignedIntegralAttribute(spanAttr, limitToOnlyHTMLNonNegative(span, defaultSpan));
 }
 
 String HTMLTableColElement::width() const
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to