Commit f7e6a1c1 authored by rob.buis's avatar rob.buis Committed by Commit bot

Adapt to changes in html5 spec related to tfoot

When setting tFoot or using createTFoot the new
element should be inserted at the end.

This patch also changes behavior so we throw a
HierarchyRequestError [1] when setting tFoot with
a new element not of type tfoot.

Behavior matches Safari, Firefox and Edge.

[1] https://html.spec.whatwg.org/#dom-table-tfoot

BUG=641338

Review-Url: https://codereview.chromium.org/2338013007
Cr-Commit-Position: refs/heads/master@{#419468}
parent 80cf9541
......@@ -1264,3 +1264,5 @@ crbug.com/646598 [ Mac ] virtual/gpu/fast/canvas/text-rendering-frameless-canvas
crbug.com/646598 [ Mac ] fast/canvas/text-rendering-frameless-canvas.html [ Failure ]
crbug.com/492785 virtual/rootlayerscrolls/scrollbars/custom-scrollbar-reconstruction-on-inserting-style-sheet.html [ Failure ]
crbug.com/641338 tables/mozilla/bugs/bug30418.html [ NeedsRebaseline ]
......@@ -7,7 +7,10 @@ PASS t.caption = null threw exception NotFoundError: Failed to set the 'caption'
PASS t.caption = document.body threw exception TypeError: Failed to set the 'caption' property on 'HTMLTableElement': The provided value is not of type 'HTMLTableCaptionElement'..
PASS t.tHead = null threw exception NotFoundError: Failed to set the 'tHead' property on 'HTMLTableElement': The new child element is null..
PASS t.tHead = document.body threw exception TypeError: Failed to set the 'tHead' property on 'HTMLTableElement': The provided value is not of type 'HTMLTableSectionElement'..
PASS t.tFoot = null threw exception NotFoundError: Failed to set the 'tFoot' property on 'HTMLTableElement': The new child element is null..
PASS t.createTFoot() is t.tFoot
PASS t.tFoot is non-null.
PASS t.tFoot = null did not throw exception.
PASS t.tFoot is null
PASS t.tFoot = document.body threw exception TypeError: Failed to set the 'tFoot' property on 'HTMLTableElement': The provided value is not of type 'HTMLTableSectionElement'..
PASS t.insertRow(-2) threw exception IndexSizeError: Failed to execute 'insertRow' on 'HTMLTableElement': The index provided (-2) is less than -1..
PASS t.insertRow(1) threw exception IndexSizeError: Failed to execute 'insertRow' on 'HTMLTableElement': The index provided (1) is greater than the number of rows in the table (0)..
......
......@@ -9,15 +9,18 @@
var t = document.createElement('table');
// TODO(foolip): Setting caption/tHead/tFoot to null should not throw
// an exception, it should just remove the old caption/thead/tfoot.
// TODO(foolip): Setting caption/tHead to null should not throw
// an exception, it should just remove the old caption/thead.
shouldThrow("t.caption = null");
shouldThrow("t.caption = document.body");
shouldThrow("t.tHead = null");
shouldThrow("t.tHead = document.body");
shouldThrow("t.tFoot = null");
shouldBe("t.createTFoot()", "t.tFoot");
shouldBeNonNull("t.tFoot");
shouldNotThrow("t.tFoot = null");
shouldBeNull("t.tFoot");
shouldThrow("t.tFoot = document.body");
shouldThrow("t.insertRow(-2)");
......
......@@ -30,32 +30,6 @@ layer at (0,0) size 800x104
LayoutTableCell {TD} at (240,2) size 32x24 [border: (1px inset #808080)] [r=0 c=7 rs=1 cs=1]
LayoutText {#text} at (2,2) size 15x19
text run at (2,2) width 15: "h7"
LayoutTableSection {TFOOT} at (4,58) size 274x26
LayoutTableRow {TR} at (0,0) size 274x24
LayoutTableCell {TD} at (2,0) size 32x24 [border: (1px inset #808080)] [r=0 c=0 rs=1 cs=1]
LayoutText {#text} at (2,2) size 12x19
text run at (2,2) width 12: "f0"
LayoutTableCell {TD} at (36,0) size 32x24 [border: (1px inset #808080)] [r=0 c=1 rs=1 cs=1]
LayoutText {#text} at (2,2) size 12x19
text run at (2,2) width 12: "f1"
LayoutTableCell {TD} at (70,0) size 32x24 [border: (1px inset #808080)] [r=0 c=2 rs=1 cs=1]
LayoutText {#text} at (2,2) size 12x19
text run at (2,2) width 12: "f2"
LayoutTableCell {TD} at (104,0) size 32x24 [border: (1px inset #808080)] [r=0 c=3 rs=1 cs=1]
LayoutText {#text} at (2,2) size 12x19
text run at (2,2) width 12: "f3"
LayoutTableCell {TD} at (138,0) size 32x24 [border: (1px inset #808080)] [r=0 c=4 rs=1 cs=1]
LayoutText {#text} at (2,2) size 12x19
text run at (2,2) width 12: "f4"
LayoutTableCell {TD} at (172,0) size 32x24 [border: (1px inset #808080)] [r=0 c=5 rs=1 cs=1]
LayoutText {#text} at (2,2) size 12x19
text run at (2,2) width 12: "f5"
LayoutTableCell {TD} at (206,0) size 32x24 [border: (1px inset #808080)] [r=0 c=6 rs=1 cs=1]
LayoutText {#text} at (2,2) size 12x19
text run at (2,2) width 12: "f6"
LayoutTableCell {TD} at (240,0) size 32x24 [border: (1px inset #808080)] [r=0 c=7 rs=1 cs=1]
LayoutText {#text} at (2,2) size 12x19
text run at (2,2) width 12: "f7"
LayoutTableSection {TBODY} at (4,32) size 274x26
LayoutTableRow {TR} at (0,0) size 274x24
LayoutTableCell {TD} at (2,0) size 32x24 [border: (1px inset #808080)] [r=0 c=0 rs=1 cs=1]
......@@ -82,3 +56,29 @@ layer at (0,0) size 800x104
LayoutTableCell {TD} at (240,0) size 32x24 [border: (1px inset #808080)] [r=0 c=7 rs=1 cs=1]
LayoutText {#text} at (2,2) size 28x19
text run at (2,2) width 28: "r0c7"
LayoutTableSection {TFOOT} at (4,58) size 274x26
LayoutTableRow {TR} at (0,0) size 274x24
LayoutTableCell {TD} at (2,0) size 32x24 [border: (1px inset #808080)] [r=0 c=0 rs=1 cs=1]
LayoutText {#text} at (2,2) size 12x19
text run at (2,2) width 12: "f0"
LayoutTableCell {TD} at (36,0) size 32x24 [border: (1px inset #808080)] [r=0 c=1 rs=1 cs=1]
LayoutText {#text} at (2,2) size 12x19
text run at (2,2) width 12: "f1"
LayoutTableCell {TD} at (70,0) size 32x24 [border: (1px inset #808080)] [r=0 c=2 rs=1 cs=1]
LayoutText {#text} at (2,2) size 12x19
text run at (2,2) width 12: "f2"
LayoutTableCell {TD} at (104,0) size 32x24 [border: (1px inset #808080)] [r=0 c=3 rs=1 cs=1]
LayoutText {#text} at (2,2) size 12x19
text run at (2,2) width 12: "f3"
LayoutTableCell {TD} at (138,0) size 32x24 [border: (1px inset #808080)] [r=0 c=4 rs=1 cs=1]
LayoutText {#text} at (2,2) size 12x19
text run at (2,2) width 12: "f4"
LayoutTableCell {TD} at (172,0) size 32x24 [border: (1px inset #808080)] [r=0 c=5 rs=1 cs=1]
LayoutText {#text} at (2,2) size 12x19
text run at (2,2) width 12: "f5"
LayoutTableCell {TD} at (206,0) size 32x24 [border: (1px inset #808080)] [r=0 c=6 rs=1 cs=1]
LayoutText {#text} at (2,2) size 12x19
text run at (2,2) width 12: "f6"
LayoutTableCell {TD} at (240,0) size 32x24 [border: (1px inset #808080)] [r=0 c=7 rs=1 cs=1]
LayoutText {#text} at (2,2) size 12x19
text run at (2,2) width 12: "f7"
......@@ -108,15 +108,15 @@ HTMLTableSectionElement* HTMLTableElement::tFoot() const
void HTMLTableElement::setTFoot(HTMLTableSectionElement* newFoot, ExceptionState& exceptionState)
{
deleteTFoot();
HTMLElement* child;
for (child = Traversal<HTMLElement>::firstChild(*this); child; child = Traversal<HTMLElement>::nextSibling(*child)) {
if (!child->hasTagName(captionTag) && !child->hasTagName(colgroupTag) && !child->hasTagName(theadTag))
break;
if (newFoot && !newFoot->hasTagName(tfootTag)) {
exceptionState.throwDOMException(HierarchyRequestError, "Not a tfoot element.");
return;
}
insertBefore(newFoot, child, exceptionState);
deleteTFoot();
if (newFoot)
appendChild(newFoot, exceptionState);
}
HTMLTableSectionElement* HTMLTableElement::createTHead()
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment