Title: [125380] trunk
Revision
125380
Author
[email protected]
Date
2012-08-12 11:14:30 -0700 (Sun, 12 Aug 2012)

Log Message

table cell.cellIndex should return -1 if there is no parent table
https://bugs.webkit.org/show_bug.cgi?id=93738

Patch by Pravin D <[email protected]> on 2012-08-12
Reviewed by Eric Seidel.

Source/WebCore:

According to the HTML5 spec the cellIndex of a table cell(td/th) whose parent is not a table row
must be -1. Currently we are returning zero. This patch fixes this behavior.

Test: fast/table/cellIndex-of-cell-with-different-parents.html

* html/HTMLTableCellElement.cpp:
(WebCore::HTMLTableCellElement::cellIndex):
  If the parent of the cell is not a table row, -1 is returned. Otherwise a value greater
  than or equal to zero is return.

* rendering/RenderTableCell.h:
(RenderTableCell):
 Removed dead code and made minor webkit style related fix.

LayoutTests:

* fast/table/cellIndex-of-cell-with-different-parents-expected.txt: Added.
* fast/table/cellIndex-of-cell-with-different-parents.html: Added.

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (125379 => 125380)


--- trunk/LayoutTests/ChangeLog	2012-08-12 18:05:19 UTC (rev 125379)
+++ trunk/LayoutTests/ChangeLog	2012-08-12 18:14:30 UTC (rev 125380)
@@ -1,3 +1,13 @@
+2012-08-12  Pravin D  <[email protected]>
+
+        table cell.cellIndex should return -1 if there is no parent table
+        https://bugs.webkit.org/show_bug.cgi?id=93738
+
+        Reviewed by Eric Seidel.
+
+        * fast/table/cellIndex-of-cell-with-different-parents-expected.txt: Added.
+        * fast/table/cellIndex-of-cell-with-different-parents.html: Added.
+
 2012-08-12  Mihnea Ovidenie  <[email protected]>
 
         CSSRegions: Crash when using style in region for removed element.

Added: trunk/LayoutTests/fast/table/cellIndex-of-cell-with-different-parents-expected.txt (0 => 125380)


--- trunk/LayoutTests/fast/table/cellIndex-of-cell-with-different-parents-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/fast/table/cellIndex-of-cell-with-different-parents-expected.txt	2012-08-12 18:14:30 UTC (rev 125380)
@@ -0,0 +1,22 @@
+Testcase for bug http://webkit.org/b/93738 . The testcase checks if the cellIndex of a table cell(td/th) is correct when the cell is inside different parents.
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+The cellIndex of a table cell (td/th) must be -1 if its parent is other than a table row. Otherwise the cellIndex must be a value greater than or equal to 0.
+PASS th_with_no_parent.cellIndex is -1
+PASS td_with_no_parent.cellIndex is -1
+PASS th_with_table_parent.cellIndex is -1
+PASS td_with_table_parent.cellIndex is -1
+PASS th_with_thead_parent.cellIndex is -1
+PASS td_with_thead_parent.cellIndex is -1
+PASS th_with_tbody_parent.cellIndex is -1
+PASS td_with_tbody_parent.cellIndex is -1
+PASS th_with_tfoot_parent.cellIndex is -1
+PASS td_with_table_parent.cellIndex is -1
+PASS first_cell_th_with_tr_parent.cellIndex is 0
+PASS second_cell_td_with_tr_parent.cellIndex is 1
+PASS successfullyParsed is true
+
+TEST COMPLETE
+

Added: trunk/LayoutTests/fast/table/cellIndex-of-cell-with-different-parents.html (0 => 125380)


--- trunk/LayoutTests/fast/table/cellIndex-of-cell-with-different-parents.html	                        (rev 0)
+++ trunk/LayoutTests/fast/table/cellIndex-of-cell-with-different-parents.html	2012-08-12 18:14:30 UTC (rev 125380)
@@ -0,0 +1,51 @@
+<!DOCTYPE html>
+<html>
+<head>
+<script src=""
+</head>
+<body>
+<script>
+description('Testcase for bug <a href="" </a>. \
+The testcase checks if the cellIndex of a table cell(td/th) is correct when the cell is inside different parents.');
+
+debug('The cellIndex of a table cell (td/th) must be -1 if its parent is other than a table row. Otherwise \
+the cellIndex must be a value greater than or equal to 0.');
+
+th_with_no_parent = document.createElement("th");
+shouldBe('th_with_no_parent.cellIndex', '-1');
+td_with_no_parent = document.createElement("td");
+shouldBe('td_with_no_parent.cellIndex', '-1');
+
+table = document.createElement("table");
+th_with_table_parent = table.appendChild(document.createElement("th"));
+shouldBe('th_with_table_parent.cellIndex', '-1');
+td_with_table_parent = table.appendChild(document.createElement("td"));
+shouldBe('td_with_table_parent.cellIndex', '-1');
+
+thead = document.createElement("thead");
+th_with_thead_parent = thead.appendChild(document.createElement("th"));
+shouldBe('th_with_thead_parent.cellIndex', '-1');
+td_with_thead_parent = thead.appendChild(document.createElement("td"));
+shouldBe('td_with_thead_parent.cellIndex', '-1');
+
+tbody = document.createElement("tbody");
+th_with_tbody_parent = tbody.appendChild(document.createElement("th"));
+shouldBe('th_with_tbody_parent.cellIndex', '-1');
+td_with_tbody_parent = tbody.appendChild(document.createElement("td"));
+shouldBe('td_with_tbody_parent.cellIndex', '-1');
+
+tfoot = document.createElement("tfoot");
+th_with_tfoot_parent = tfoot.appendChild(document.createElement("th"));
+shouldBe('th_with_tfoot_parent.cellIndex', '-1');
+td_with_tfoot_parent = tfoot.appendChild(document.createElement("td"));
+shouldBe('td_with_table_parent.cellIndex', '-1');
+
+tr = document.createElement("tr");
+first_cell_th_with_tr_parent = tr.appendChild(document.createElement("th"));
+shouldBe('first_cell_th_with_tr_parent.cellIndex', '0');
+second_cell_td_with_tr_parent = tr.appendChild(document.createElement("td"));
+shouldBe('second_cell_td_with_tr_parent.cellIndex', '1');
+</script>
+<script src=""
+</body>
+</html>

Modified: trunk/Source/WebCore/ChangeLog (125379 => 125380)


--- trunk/Source/WebCore/ChangeLog	2012-08-12 18:05:19 UTC (rev 125379)
+++ trunk/Source/WebCore/ChangeLog	2012-08-12 18:14:30 UTC (rev 125380)
@@ -1,3 +1,24 @@
+2012-08-12  Pravin D  <[email protected]>
+
+        table cell.cellIndex should return -1 if there is no parent table
+        https://bugs.webkit.org/show_bug.cgi?id=93738
+
+        Reviewed by Eric Seidel.
+
+        According to the HTML5 spec the cellIndex of a table cell(td/th) whose parent is not a table row
+        must be -1. Currently we are returning zero. This patch fixes this behavior. 
+
+        Test: fast/table/cellIndex-of-cell-with-different-parents.html
+
+        * html/HTMLTableCellElement.cpp:
+        (WebCore::HTMLTableCellElement::cellIndex):
+          If the parent of the cell is not a table row, -1 is returned. Otherwise a value greater
+          than or equal to zero is return.
+
+        * rendering/RenderTableCell.h:
+        (RenderTableCell):
+         Removed dead code and made minor webkit style related fix.
+
 2012-08-12  Leandro Gracia Gil  <[email protected]>
 
         [Chromium] Implement the find-in-page match rects API

Modified: trunk/Source/WebCore/html/HTMLTableCellElement.cpp (125379 => 125380)


--- trunk/Source/WebCore/html/HTMLTableCellElement.cpp	2012-08-12 18:05:19 UTC (rev 125379)
+++ trunk/Source/WebCore/html/HTMLTableCellElement.cpp	2012-08-12 18:14:30 UTC (rev 125380)
@@ -67,6 +67,9 @@
 int HTMLTableCellElement::cellIndex() const
 {
     int index = 0;
+    if (!parentElement() || !parentElement()->hasTagName(trTag))
+        return -1;
+
     for (const Node * node = previousSibling(); node; node = node->previousSibling()) {
         if (node->hasTagName(tdTag) || node->hasTagName(thTag))
             index++;

Modified: trunk/Source/WebCore/rendering/RenderTableCell.h (125379 => 125380)


--- trunk/Source/WebCore/rendering/RenderTableCell.h	2012-08-12 18:05:19 UTC (rev 125379)
+++ trunk/Source/WebCore/rendering/RenderTableCell.h	2012-08-12 18:14:30 UTC (rev 125380)
@@ -38,11 +38,7 @@
 class RenderTableCell : public RenderBlock {
 public:
     explicit RenderTableCell(Node*);
-
-    // FIXME: need to implement cellIndex
-    int cellIndex() const { return 0; }
-    void setCellIndex(int) { }
-
+    
     unsigned colSpan() const;
     unsigned rowSpan() const;
 
@@ -116,7 +112,7 @@
     virtual LayoutUnit paddingLeft() const OVERRIDE;
     virtual LayoutUnit paddingRight() const OVERRIDE;
     
-    // FIXME: For now we just assume the cell has the same block flow direction as the table.  It's likely we'll
+    // FIXME: For now we just assume the cell has the same block flow direction as the table. It's likely we'll
     // create an extra anonymous RenderBlock to handle mixing directionality anyway, in which case we can lock
     // the block flow directionality of the cells to the table's directionality.
     virtual LayoutUnit paddingBefore() const OVERRIDE;
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to