[SCM] WebKit Debian packaging branch, debian/experimental, updated. upstream/1.3.3-9427-gc2be6fc

jamesr at google.com jamesr at google.com
Wed Dec 22 11:26:50 UTC 2010


The following commit has been merged in the debian/experimental branch:
commit 36623a353fba0670bd5bac74eafbe486ad2f0274
Author: jamesr at google.com <jamesr at google.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date:   Fri Jul 23 20:22:29 2010 +0000

    2010-07-23  fsamuel at chromium.org  <fsamuel at chromium.org>
    
            Reviewed by David Hyatt.
    
            Updated table painting to draw cell layers in the correct order.
    
            Table Cell Layering
            https://bugs.webkit.org/show_bug.cgi?id=40775
    
            Tests: tables/layering/paint-test-layering-1.html
                   tables/layering/paint-test-layering-2.html
    
            * accessibility/AccessibilityTable.cpp:
            (WebCore::AccessibilityTable::isTableExposableThroughAccessibility):
            (WebCore::AccessibilityTable::addChildren):
            (WebCore::AccessibilityTable::cellForColumnAndRow):
            * accessibility/AccessibilityTableCell.cpp:
            (WebCore::AccessibilityTableCell::titleUIElement):
            * accessibility/AccessibilityTableColumn.cpp:
            (WebCore::AccessibilityTableColumn::headerObjectForSection):
            * rendering/AutoTableLayout.cpp:
            (WebCore::AutoTableLayout::recalcColumn):
            * rendering/RenderTable.cpp:
            (WebCore::RenderTable::splitColumn):
            (WebCore::RenderTable::calcBorderLeft):
            (WebCore::RenderTable::calcBorderRight):
            (WebCore::RenderTable::cellAbove):
            (WebCore::RenderTable::cellBelow):
            (WebCore::RenderTable::cellBefore):
            (WebCore::RenderTable::cellAfter):
            * rendering/RenderTableSection.cpp:
            (WebCore::RenderTableSection::RenderTableSection):
            (WebCore::RenderTableSection::ensureRows):
            (WebCore::RenderTableSection::addCell):
            (WebCore::RenderTableSection::setCellWidths):
            (WebCore::RenderTableSection::calcRowHeight):
            (WebCore::RenderTableSection::layoutRows):
            (WebCore::RenderTableSection::calcOuterBorderTop):
            (WebCore::RenderTableSection::calcOuterBorderBottom):
            (WebCore::RenderTableSection::calcOuterBorderLeft):
            (WebCore::RenderTableSection::calcOuterBorderRight):
            (WebCore::RenderTableSection::firstLineBoxBaseline):
            (WebCore::compareCellPositions):
            (WebCore::RenderTableSection::paintCell):
            (WebCore::RenderTableSection::paintObject):
            (WebCore::RenderTableSection::numColumns):
            (WebCore::RenderTableSection::appendColumn):
            (WebCore::RenderTableSection::splitColumn):
            (WebCore::RenderTableSection::nodeAtPoint):
            * rendering/RenderTableSection.h:
            (WebCore::RenderTableSection::CellStruct::CellStruct):
            (WebCore::RenderTableSection::CellStruct::primaryCell):
            (WebCore::RenderTableSection::CellStruct::hasCells):
            (WebCore::RenderTableSection::primaryCellAt):
    2010-07-23  fsamuel at chromium.org  <fsamuel at chromium.org>
    
            Reviewed by David Hyatt.
    
            Updated table painting to draw cell layers in the correct order.
    
            Table Cell Layering
            https://bugs.webkit.org/show_bug.cgi?id=40775
    
            * platform/chromium-linux/tables/layering/paint-test-layering-1-expected.checksum: Added.
            * platform/chromium-linux/tables/layering/paint-test-layering-1-expected.png: Added.
            * platform/chromium-linux/tables/layering/paint-test-layering-1-expected.txt: Added.
            * platform/chromium-linux/tables/layering/paint-test-layering-2-expected.checksum: Added.
            * platform/chromium-linux/tables/layering/paint-test-layering-2-expected.png: Added.
            * platform/chromium-linux/tables/layering/paint-test-layering-2-expected.txt: Added.
            * platform/chromium-mac/tables/layering/paint-test-layering-1-expected.checksum: Added.
            * platform/chromium-mac/tables/layering/paint-test-layering-1-expected.png: Added.
            * platform/chromium-mac/tables/layering/paint-test-layering-1-expected.txt: Added.
            * platform/chromium-mac/tables/layering/paint-test-layering-2-expected.checksum: Added.
            * platform/chromium-mac/tables/layering/paint-test-layering-2-expected.png: Added.
            * platform/chromium-mac/tables/layering/paint-test-layering-2-expected.txt: Added.
            * platform/gtk/tables/layering/paint-test-layering-1-expected.checksum: Added.
            * platform/gtk/tables/layering/paint-test-layering-1-expected.png: Added.
            * platform/gtk/tables/layering/paint-test-layering-1-expected.txt: Added.
            * platform/gtk/tables/layering/paint-test-layering-2-expected.checksum: Added.
            * platform/gtk/tables/layering/paint-test-layering-2-expected.png: Added.
            * platform/gtk/tables/layering/paint-test-layering-2-expected.txt: Added.
            * platform/mac/tables/layering/paint-test-layering-1-expected.checksum: Added.
            * platform/mac/tables/layering/paint-test-layering-1-expected.png: Added.
            * platform/mac/tables/layering/paint-test-layering-1-expected.txt: Added.
            * platform/mac/tables/layering/paint-test-layering-2-expected.checksum: Added.
            * platform/mac/tables/layering/paint-test-layering-2-expected.png: Added.
            * platform/mac/tables/layering/paint-test-layering-2-expected.txt: Added.
            * tables/layering/paint-test-layering-1.html: Added.
            * tables/layering/paint-test-layering-2.html: Added.
    
    
    git-svn-id: http://svn.webkit.org/repository/webkit/trunk@63994 268f45cc-cd09-0410-ab3c-d52691b4dbfc

diff --git a/LayoutTests/ChangeLog b/LayoutTests/ChangeLog
index 001a9a1..26c7e55 100644
--- a/LayoutTests/ChangeLog
+++ b/LayoutTests/ChangeLog
@@ -1,3 +1,39 @@
+2010-07-23  fsamuel at chromium.org  <fsamuel at chromium.org>
+
+        Reviewed by David Hyatt.
+
+        Updated table painting to draw cell layers in the correct order.
+
+        Table Cell Layering
+        https://bugs.webkit.org/show_bug.cgi?id=40775
+
+        * platform/chromium-linux/tables/layering/paint-test-layering-1-expected.checksum: Added.
+        * platform/chromium-linux/tables/layering/paint-test-layering-1-expected.png: Added.
+        * platform/chromium-linux/tables/layering/paint-test-layering-1-expected.txt: Added.
+        * platform/chromium-linux/tables/layering/paint-test-layering-2-expected.checksum: Added.
+        * platform/chromium-linux/tables/layering/paint-test-layering-2-expected.png: Added.
+        * platform/chromium-linux/tables/layering/paint-test-layering-2-expected.txt: Added.
+        * platform/chromium-mac/tables/layering/paint-test-layering-1-expected.checksum: Added.
+        * platform/chromium-mac/tables/layering/paint-test-layering-1-expected.png: Added.
+        * platform/chromium-mac/tables/layering/paint-test-layering-1-expected.txt: Added.
+        * platform/chromium-mac/tables/layering/paint-test-layering-2-expected.checksum: Added.
+        * platform/chromium-mac/tables/layering/paint-test-layering-2-expected.png: Added.
+        * platform/chromium-mac/tables/layering/paint-test-layering-2-expected.txt: Added.
+        * platform/gtk/tables/layering/paint-test-layering-1-expected.checksum: Added.
+        * platform/gtk/tables/layering/paint-test-layering-1-expected.png: Added.
+        * platform/gtk/tables/layering/paint-test-layering-1-expected.txt: Added.
+        * platform/gtk/tables/layering/paint-test-layering-2-expected.checksum: Added.
+        * platform/gtk/tables/layering/paint-test-layering-2-expected.png: Added.
+        * platform/gtk/tables/layering/paint-test-layering-2-expected.txt: Added.
+        * platform/mac/tables/layering/paint-test-layering-1-expected.checksum: Added.
+        * platform/mac/tables/layering/paint-test-layering-1-expected.png: Added.
+        * platform/mac/tables/layering/paint-test-layering-1-expected.txt: Added.
+        * platform/mac/tables/layering/paint-test-layering-2-expected.checksum: Added.
+        * platform/mac/tables/layering/paint-test-layering-2-expected.png: Added.
+        * platform/mac/tables/layering/paint-test-layering-2-expected.txt: Added.
+        * tables/layering/paint-test-layering-1.html: Added.
+        * tables/layering/paint-test-layering-2.html: Added.
+
 2010-07-23  Stephen White  <senorblanco at chromium.org>
 
         Unreviewed; chromium test expectations fix.
diff --git a/LayoutTests/platform/chromium-linux/tables/layering/paint-test-layering-1-expected.checksum b/LayoutTests/platform/chromium-linux/tables/layering/paint-test-layering-1-expected.checksum
new file mode 100644
index 0000000..8546b26
--- /dev/null
+++ b/LayoutTests/platform/chromium-linux/tables/layering/paint-test-layering-1-expected.checksum
@@ -0,0 +1 @@
+1c6d20ec57caf2d7b6a4ae1885715e3e
\ No newline at end of file
diff --git a/LayoutTests/platform/chromium-linux/tables/layering/paint-test-layering-1-expected.png b/LayoutTests/platform/chromium-linux/tables/layering/paint-test-layering-1-expected.png
new file mode 100644
index 0000000..7b4123c
Binary files /dev/null and b/LayoutTests/platform/chromium-linux/tables/layering/paint-test-layering-1-expected.png differ
diff --git a/LayoutTests/platform/chromium-linux/tables/layering/paint-test-layering-1-expected.txt b/LayoutTests/platform/chromium-linux/tables/layering/paint-test-layering-1-expected.txt
new file mode 100644
index 0000000..fb3626b
--- /dev/null
+++ b/LayoutTests/platform/chromium-linux/tables/layering/paint-test-layering-1-expected.txt
@@ -0,0 +1,54 @@
+layer at (0,0) size 800x600
+  RenderView at (0,0) size 800x600
+layer at (0,0) size 800x600
+  RenderBlock {HTML} at (0,0) size 800x600
+    RenderBody {BODY} at (8,8) size 784x584
+      RenderBlock {P} at (0,0) size 784x60
+        RenderText {#text} at (0,0) size 746x39
+          text run at (0,0) width 746: "This test checks the renderer's ability to layer multiple cells in a table on top of one another. This test has three cells that span"
+          text run at (0,20) width 172: "multiple table grid slots. The "
+        RenderInline {SPAN} at (0,0) size 22x19 [color=#FF0000]
+          RenderText {#text} at (172,20) size 22x19
+            text run at (172,20) width 22: "red"
+        RenderText {#text} at (194,20) size 367x19
+          text run at (194,20) width 367: " cell starts at row 1 and column 3 and spans three rows. The "
+        RenderInline {SPAN} at (0,0) size 28x19 [color=#0000FF]
+          RenderText {#text} at (561,20) size 28x19
+            text run at (561,20) width 28: "blue"
+        RenderText {#text} at (589,20) size 781x39
+          text run at (589,20) width 192: " cell starts at row 2, and column"
+          text run at (0,40) width 278: "2, and spans two columns and two rows. The "
+        RenderInline {SPAN} at (0,0) size 38x19 [color=#008000]
+          RenderText {#text} at (278,40) size 38x19
+            text run at (278,40) width 38: "green"
+        RenderText {#text} at (316,40) size 187x19
+          text run at (316,40) width 187: " cell spans 4 columns of row 3."
+      RenderBlock {P} at (0,76) size 784x20
+        RenderText {#text} at (0,0) size 771x19
+          text run at (0,0) width 771: "If the test succeeds then you should see no text inside the table. If you see the text 'FAIL' inside the table, then the test has failed."
+      RenderTable {TABLE} at (0,112) size 102x82 [border: (1px outset #808080)]
+        RenderTableSection {TBODY} at (1,1) size 100x80
+          RenderTableRow {TR} at (0,2) size 100x24
+            RenderTableCell {TD} at (2,2) size 20x24 [border: (1px inset #808080)] [r=0 c=0 rs=1 cs=1]
+              RenderText {#text} at (2,2) size 16x19
+                text run at (2,2) width 16: "    "
+            RenderTableCell {TD} at (24,2) size 20x24 [border: (1px inset #808080)] [r=0 c=1 rs=1 cs=1]
+              RenderText {#text} at (2,2) size 16x19
+                text run at (2,2) width 16: "    "
+            RenderTableCell {TD} at (46,54) size 52x24 [bgcolor=#FF0000] [border: (1px inset #808080)] [r=0 c=2 rs=3 cs=1]
+              RenderBlock {DIV} at (2,2) size 48x20
+                RenderText {#text} at (0,0) size 48x19
+                  text run at (0,0) width 48: "            "
+          RenderTableRow {TR} at (0,28) size 100x24
+            RenderTableCell {TD} at (2,28) size 20x24 [border: (1px inset #808080)] [r=1 c=0 rs=1 cs=1]
+              RenderText {#text} at (2,2) size 16x19
+                text run at (2,2) width 16: "    "
+            RenderTableCell {TD} at (24,54) size 74x24 [bgcolor=#0000FF] [border: (1px inset #808080)] [r=1 c=1 rs=2 cs=2]
+              RenderBlock {DIV} at (2,2) size 70x20 [color=#008000]
+                RenderText {#text} at (16,0) size 54x19
+                  text run at (16,0) width 54: "   FAIL  "
+          RenderTableRow {TR} at (0,54) size 100x24
+            RenderTableCell {TD} at (2,54) size 96x24 [bgcolor=#008000] [border: (1px inset #808080)] [r=2 c=0 rs=1 cs=3]
+              RenderBlock {DIV} at (2,2) size 92x20
+                RenderText {#text} at (84,0) size 8x19
+                  text run at (84,0) width 8: "  "
diff --git a/LayoutTests/platform/chromium-linux/tables/layering/paint-test-layering-2-expected.checksum b/LayoutTests/platform/chromium-linux/tables/layering/paint-test-layering-2-expected.checksum
new file mode 100644
index 0000000..4e916a7
--- /dev/null
+++ b/LayoutTests/platform/chromium-linux/tables/layering/paint-test-layering-2-expected.checksum
@@ -0,0 +1 @@
+0acf4a6bdbd8bc0e2182e19cf6a21763
\ No newline at end of file
diff --git a/LayoutTests/platform/chromium-linux/tables/layering/paint-test-layering-2-expected.png b/LayoutTests/platform/chromium-linux/tables/layering/paint-test-layering-2-expected.png
new file mode 100644
index 0000000..de16244
Binary files /dev/null and b/LayoutTests/platform/chromium-linux/tables/layering/paint-test-layering-2-expected.png differ
diff --git a/LayoutTests/platform/chromium-linux/tables/layering/paint-test-layering-2-expected.txt b/LayoutTests/platform/chromium-linux/tables/layering/paint-test-layering-2-expected.txt
new file mode 100644
index 0000000..fa23112
--- /dev/null
+++ b/LayoutTests/platform/chromium-linux/tables/layering/paint-test-layering-2-expected.txt
@@ -0,0 +1,64 @@
+layer at (0,0) size 800x600
+  RenderView at (0,0) size 800x600
+layer at (0,0) size 800x600
+  RenderBlock {HTML} at (0,0) size 800x600
+    RenderBody {BODY} at (8,8) size 784x584
+      RenderBlock {P} at (0,0) size 784x60
+        RenderText {#text} at (0,0) size 746x39
+          text run at (0,0) width 746: "This test checks the renderer's ability to layer multiple cells in a table on top of one another. This test has three cells that span"
+          text run at (0,20) width 172: "multiple table grid slots. The "
+        RenderInline {SPAN} at (0,0) size 22x19 [color=#FF0000]
+          RenderText {#text} at (172,20) size 22x19
+            text run at (172,20) width 22: "red"
+        RenderText {#text} at (194,20) size 361x19
+          text run at (194,20) width 361: " cell starts at row 1 and column 4 and spans four rows. The "
+        RenderInline {SPAN} at (0,0) size 28x19 [color=#0000FF]
+          RenderText {#text} at (555,20) size 28x19
+            text run at (555,20) width 28: "blue"
+        RenderText {#text} at (583,20) size 775x39
+          text run at (583,20) width 192: " cell starts at row 2, and column"
+          text run at (0,40) width 192: "1, and spans four columns. The "
+        RenderInline {SPAN} at (0,0) size 38x19 [color=#008000]
+          RenderText {#text} at (192,40) size 38x19
+            text run at (192,40) width 38: "green"
+        RenderText {#text} at (230,40) size 187x19
+          text run at (230,40) width 187: " cell spans 4 columns of row 4."
+      RenderBlock {P} at (0,76) size 784x20
+        RenderText {#text} at (0,0) size 771x19
+          text run at (0,0) width 771: "If the test succeeds then you should see no text inside the table. If you see the text 'FAIL' inside the table, then the test has failed."
+      RenderTable {TABLE} at (0,112) size 188x108 [border: (1px outset #808080)]
+        RenderTableSection {TBODY} at (1,1) size 186x106
+          RenderTableRow {TR} at (0,2) size 186x24
+            RenderTableCell {TD} at (2,2) size 44x24 [border: (1px inset #808080)] [r=0 c=0 rs=1 cs=1]
+              RenderText {#text} at (2,2) size 16x19
+                text run at (2,2) width 16: "    "
+            RenderTableCell {TD} at (48,2) size 44x24 [border: (1px inset #808080)] [r=0 c=1 rs=1 cs=1]
+              RenderText {#text} at (2,2) size 16x19
+                text run at (2,2) width 16: "    "
+            RenderTableCell {TD} at (94,2) size 44x24 [border: (1px inset #808080)] [r=0 c=2 rs=1 cs=1]
+              RenderText {#text} at (2,2) size 16x19
+                text run at (2,2) width 16: "    "
+            RenderTableCell {TD} at (140,41) size 44x24 [bgcolor=#FF0000] [border: (1px inset #808080)] [r=0 c=3 rs=4 cs=1]
+              RenderBlock {DIV} at (2,2) size 40x20
+                RenderText {#text} at (0,0) size 40x19
+                  text run at (0,0) width 40: "          "
+          RenderTableRow {TR} at (0,28) size 186x24
+            RenderTableCell {TD} at (2,28) size 182x24 [bgcolor=#0000FF] [border: (1px inset #808080)] [r=1 c=0 rs=1 cs=4]
+              RenderBlock {DIV} at (2,2) size 178x20
+                RenderText {#text} at (138,0) size 40x19
+                  text run at (138,0) width 40: "          "
+          RenderTableRow {TR} at (0,54) size 186x24
+            RenderTableCell {TD} at (2,54) size 44x24 [border: (1px inset #808080)] [r=2 c=0 rs=1 cs=1]
+              RenderText {#text} at (2,2) size 40x19
+                text run at (2,2) width 40: "          "
+            RenderTableCell {TD} at (48,54) size 44x24 [border: (1px inset #808080)] [r=2 c=1 rs=1 cs=1]
+              RenderText {#text} at (2,2) size 40x19
+                text run at (2,2) width 40: "          "
+            RenderTableCell {TD} at (94,54) size 44x24 [border: (1px inset #808080)] [r=2 c=2 rs=1 cs=1]
+              RenderText {#text} at (2,2) size 40x19
+                text run at (2,2) width 40: "          "
+          RenderTableRow {TR} at (0,80) size 186x24
+            RenderTableCell {TD} at (2,80) size 182x24 [bgcolor=#008000] [border: (1px inset #808080)] [r=3 c=0 rs=1 cs=4]
+              RenderBlock {DIV} at (2,2) size 178x20 [color=#008000]
+                RenderText {#text} at (140,0) size 38x19
+                  text run at (140,0) width 38: "FAIL "
diff --git a/LayoutTests/platform/chromium-mac/tables/layering/paint-test-layering-1-expected.checksum b/LayoutTests/platform/chromium-mac/tables/layering/paint-test-layering-1-expected.checksum
new file mode 100644
index 0000000..663a3d4
--- /dev/null
+++ b/LayoutTests/platform/chromium-mac/tables/layering/paint-test-layering-1-expected.checksum
@@ -0,0 +1 @@
+74f85aff0ca32f568d65d23112496aef
\ No newline at end of file
diff --git a/LayoutTests/platform/chromium-mac/tables/layering/paint-test-layering-1-expected.png b/LayoutTests/platform/chromium-mac/tables/layering/paint-test-layering-1-expected.png
new file mode 100644
index 0000000..a590c92
Binary files /dev/null and b/LayoutTests/platform/chromium-mac/tables/layering/paint-test-layering-1-expected.png differ
diff --git a/LayoutTests/platform/chromium-mac/tables/layering/paint-test-layering-1-expected.txt b/LayoutTests/platform/chromium-mac/tables/layering/paint-test-layering-1-expected.txt
new file mode 100644
index 0000000..daa9896
--- /dev/null
+++ b/LayoutTests/platform/chromium-mac/tables/layering/paint-test-layering-1-expected.txt
@@ -0,0 +1,55 @@
+layer at (0,0) size 800x600
+  RenderView at (0,0) size 800x600
+layer at (0,0) size 800x600
+  RenderBlock {HTML} at (0,0) size 800x600
+    RenderBody {BODY} at (8,8) size 784x584
+      RenderBlock {P} at (0,0) size 784x54
+        RenderText {#text} at (0,0) size 782x36
+          text run at (0,0) width 782: "This test checks the renderer's ability to layer multiple cells in a table on top of one another. This test has three cells that span"
+          text run at (0,18) width 183: "multiple table grid slots. The "
+        RenderInline {SPAN} at (0,0) size 23x18 [color=#FF0000]
+          RenderText {#text} at (183,18) size 23x18
+            text run at (183,18) width 23: "red"
+        RenderText {#text} at (206,18) size 381x18
+          text run at (206,18) width 381: " cell starts at row 1 and column 3 and spans three rows. The "
+        RenderInline {SPAN} at (0,0) size 29x18 [color=#0000FF]
+          RenderText {#text} at (587,18) size 29x18
+            text run at (587,18) width 29: "blue"
+        RenderText {#text} at (616,18) size 765x36
+          text run at (616,18) width 149: " cell starts at row 2, and"
+          text run at (0,36) width 341: "column 2, and spans two columns and two rows. The "
+        RenderInline {SPAN} at (0,0) size 38x18 [color=#008000]
+          RenderText {#text} at (341,36) size 38x18
+            text run at (341,36) width 38: "green"
+        RenderText {#text} at (379,36) size 196x18
+          text run at (379,36) width 196: " cell spans 4 columns of row 3."
+      RenderBlock {P} at (0,70) size 784x36
+        RenderText {#text} at (0,0) size 764x36
+          text run at (0,0) width 764: "If the test succeeds then you should see no text inside the table. If you see the text 'FAIL' inside the table, then the test has"
+          text run at (0,18) width 39: "failed."
+      RenderTable {TABLE} at (0,122) size 102x76 [border: (1px outset #808080)]
+        RenderTableSection {TBODY} at (1,1) size 100x74
+          RenderTableRow {TR} at (0,2) size 100x22
+            RenderTableCell {TD} at (2,2) size 20x22 [border: (1px inset #808080)] [r=0 c=0 rs=1 cs=1]
+              RenderText {#text} at (2,2) size 16x18
+                text run at (2,2) width 16: "    "
+            RenderTableCell {TD} at (24,2) size 20x22 [border: (1px inset #808080)] [r=0 c=1 rs=1 cs=1]
+              RenderText {#text} at (2,2) size 16x18
+                text run at (2,2) width 16: "    "
+            RenderTableCell {TD} at (46,50) size 52x22 [bgcolor=#FF0000] [border: (1px inset #808080)] [r=0 c=2 rs=3 cs=1]
+              RenderBlock {DIV} at (2,2) size 48x18
+                RenderText {#text} at (0,0) size 48x18
+                  text run at (0,0) width 48: "            "
+          RenderTableRow {TR} at (0,26) size 100x22
+            RenderTableCell {TD} at (2,26) size 20x22 [border: (1px inset #808080)] [r=1 c=0 rs=1 cs=1]
+              RenderText {#text} at (2,2) size 16x18
+                text run at (2,2) width 16: "    "
+            RenderTableCell {TD} at (24,50) size 74x22 [bgcolor=#0000FF] [border: (1px inset #808080)] [r=1 c=1 rs=2 cs=2]
+              RenderBlock {DIV} at (2,2) size 70x18 [color=#008000]
+                RenderText {#text} at (14,0) size 56x18
+                  text run at (14,0) width 56: "   FAIL  "
+          RenderTableRow {TR} at (0,50) size 100x22
+            RenderTableCell {TD} at (2,50) size 96x22 [bgcolor=#008000] [border: (1px inset #808080)] [r=2 c=0 rs=1 cs=3]
+              RenderBlock {DIV} at (2,2) size 92x18
+                RenderText {#text} at (84,0) size 8x18
+                  text run at (84,0) width 8: "  "
diff --git a/LayoutTests/platform/chromium-mac/tables/layering/paint-test-layering-2-expected.checksum b/LayoutTests/platform/chromium-mac/tables/layering/paint-test-layering-2-expected.checksum
new file mode 100644
index 0000000..bc3ff1e
--- /dev/null
+++ b/LayoutTests/platform/chromium-mac/tables/layering/paint-test-layering-2-expected.checksum
@@ -0,0 +1 @@
+d3aa1e78efe6c6e3063272d385ee0134
\ No newline at end of file
diff --git a/LayoutTests/platform/chromium-mac/tables/layering/paint-test-layering-2-expected.png b/LayoutTests/platform/chromium-mac/tables/layering/paint-test-layering-2-expected.png
new file mode 100644
index 0000000..d0e126e
Binary files /dev/null and b/LayoutTests/platform/chromium-mac/tables/layering/paint-test-layering-2-expected.png differ
diff --git a/LayoutTests/platform/chromium-mac/tables/layering/paint-test-layering-2-expected.txt b/LayoutTests/platform/chromium-mac/tables/layering/paint-test-layering-2-expected.txt
new file mode 100644
index 0000000..96434f3
--- /dev/null
+++ b/LayoutTests/platform/chromium-mac/tables/layering/paint-test-layering-2-expected.txt
@@ -0,0 +1,65 @@
+layer at (0,0) size 800x600
+  RenderView at (0,0) size 800x600
+layer at (0,0) size 800x600
+  RenderBlock {HTML} at (0,0) size 800x600
+    RenderBody {BODY} at (8,8) size 784x584
+      RenderBlock {P} at (0,0) size 784x54
+        RenderText {#text} at (0,0) size 782x36
+          text run at (0,0) width 782: "This test checks the renderer's ability to layer multiple cells in a table on top of one another. This test has three cells that span"
+          text run at (0,18) width 183: "multiple table grid slots. The "
+        RenderInline {SPAN} at (0,0) size 23x18 [color=#FF0000]
+          RenderText {#text} at (183,18) size 23x18
+            text run at (183,18) width 23: "red"
+        RenderText {#text} at (206,18) size 376x18
+          text run at (206,18) width 376: " cell starts at row 1 and column 4 and spans four rows. The "
+        RenderInline {SPAN} at (0,0) size 29x18 [color=#0000FF]
+          RenderText {#text} at (582,18) size 29x18
+            text run at (582,18) width 29: "blue"
+        RenderText {#text} at (611,18) size 760x36
+          text run at (611,18) width 149: " cell starts at row 2, and"
+          text run at (0,36) width 253: "column 1, and spans four columns. The "
+        RenderInline {SPAN} at (0,0) size 38x18 [color=#008000]
+          RenderText {#text} at (253,36) size 38x18
+            text run at (253,36) width 38: "green"
+        RenderText {#text} at (291,36) size 196x18
+          text run at (291,36) width 196: " cell spans 4 columns of row 4."
+      RenderBlock {P} at (0,70) size 784x36
+        RenderText {#text} at (0,0) size 764x36
+          text run at (0,0) width 764: "If the test succeeds then you should see no text inside the table. If you see the text 'FAIL' inside the table, then the test has"
+          text run at (0,18) width 39: "failed."
+      RenderTable {TABLE} at (0,122) size 188x100 [border: (1px outset #808080)]
+        RenderTableSection {TBODY} at (1,1) size 186x98
+          RenderTableRow {TR} at (0,2) size 186x22
+            RenderTableCell {TD} at (2,2) size 44x22 [border: (1px inset #808080)] [r=0 c=0 rs=1 cs=1]
+              RenderText {#text} at (2,2) size 16x18
+                text run at (2,2) width 16: "    "
+            RenderTableCell {TD} at (48,2) size 44x22 [border: (1px inset #808080)] [r=0 c=1 rs=1 cs=1]
+              RenderText {#text} at (2,2) size 16x18
+                text run at (2,2) width 16: "    "
+            RenderTableCell {TD} at (94,2) size 44x22 [border: (1px inset #808080)] [r=0 c=2 rs=1 cs=1]
+              RenderText {#text} at (2,2) size 16x18
+                text run at (2,2) width 16: "    "
+            RenderTableCell {TD} at (140,38) size 44x22 [bgcolor=#FF0000] [border: (1px inset #808080)] [r=0 c=3 rs=4 cs=1]
+              RenderBlock {DIV} at (2,2) size 40x18
+                RenderText {#text} at (0,0) size 40x18
+                  text run at (0,0) width 40: "          "
+          RenderTableRow {TR} at (0,26) size 186x22
+            RenderTableCell {TD} at (2,26) size 182x22 [bgcolor=#0000FF] [border: (1px inset #808080)] [r=1 c=0 rs=1 cs=4]
+              RenderBlock {DIV} at (2,2) size 178x18
+                RenderText {#text} at (138,0) size 40x18
+                  text run at (138,0) width 40: "          "
+          RenderTableRow {TR} at (0,50) size 186x22
+            RenderTableCell {TD} at (2,50) size 44x22 [border: (1px inset #808080)] [r=2 c=0 rs=1 cs=1]
+              RenderText {#text} at (2,2) size 40x18
+                text run at (2,2) width 40: "          "
+            RenderTableCell {TD} at (48,50) size 44x22 [border: (1px inset #808080)] [r=2 c=1 rs=1 cs=1]
+              RenderText {#text} at (2,2) size 40x18
+                text run at (2,2) width 40: "          "
+            RenderTableCell {TD} at (94,50) size 44x22 [border: (1px inset #808080)] [r=2 c=2 rs=1 cs=1]
+              RenderText {#text} at (2,2) size 40x18
+                text run at (2,2) width 40: "          "
+          RenderTableRow {TR} at (0,74) size 186x22
+            RenderTableCell {TD} at (2,74) size 182x22 [bgcolor=#008000] [border: (1px inset #808080)] [r=3 c=0 rs=1 cs=4]
+              RenderBlock {DIV} at (2,2) size 178x18 [color=#008000]
+                RenderText {#text} at (138,0) size 40x18
+                  text run at (138,0) width 40: "FAIL "
diff --git a/LayoutTests/platform/gtk/tables/layering/paint-test-layering-1-expected.checksum b/LayoutTests/platform/gtk/tables/layering/paint-test-layering-1-expected.checksum
new file mode 100644
index 0000000..2a319f2
--- /dev/null
+++ b/LayoutTests/platform/gtk/tables/layering/paint-test-layering-1-expected.checksum
@@ -0,0 +1 @@
+b87f0dd73bcdd145e6dca9443f4da910
\ No newline at end of file
diff --git a/LayoutTests/platform/gtk/tables/layering/paint-test-layering-1-expected.png b/LayoutTests/platform/gtk/tables/layering/paint-test-layering-1-expected.png
new file mode 100644
index 0000000..df7ca39
Binary files /dev/null and b/LayoutTests/platform/gtk/tables/layering/paint-test-layering-1-expected.png differ
diff --git a/LayoutTests/platform/gtk/tables/layering/paint-test-layering-1-expected.txt b/LayoutTests/platform/gtk/tables/layering/paint-test-layering-1-expected.txt
new file mode 100644
index 0000000..a0f56a2
--- /dev/null
+++ b/LayoutTests/platform/gtk/tables/layering/paint-test-layering-1-expected.txt
@@ -0,0 +1,55 @@
+layer at (0,0) size 800x600
+  RenderView at (0,0) size 800x600
+layer at (0,0) size 800x600
+  RenderBlock {HTML} at (0,0) size 800x600
+    RenderBody {BODY} at (8,8) size 784x584
+      RenderBlock {P} at (0,0) size 784x64
+        RenderText {#text} at (0,0) size 782x41
+          text run at (0,0) width 782: "This test checks the renderer's ability to layer multiple cells in a table on top of one another. This test has three cells that span"
+          text run at (0,21) width 183: "multiple table grid slots. The "
+        RenderInline {SPAN} at (0,0) size 23x22 [color=#FF0000]
+          RenderText {#text} at (183,20) size 23x22
+            text run at (183,20) width 23: "red"
+        RenderText {#text} at (206,21) size 381x20
+          text run at (206,21) width 381: " cell starts at row 1 and column 3 and spans three rows. The "
+        RenderInline {SPAN} at (0,0) size 29x22 [color=#0000FF]
+          RenderText {#text} at (587,20) size 29x22
+            text run at (587,20) width 29: "blue"
+        RenderText {#text} at (616,21) size 765x42
+          text run at (616,21) width 149: " cell starts at row 2, and"
+          text run at (0,43) width 341: "column 2, and spans two columns and two rows. The "
+        RenderInline {SPAN} at (0,0) size 38x22 [color=#008000]
+          RenderText {#text} at (341,42) size 38x22
+            text run at (341,42) width 38: "green"
+        RenderText {#text} at (379,43) size 196x20
+          text run at (379,43) width 196: " cell spans 4 columns of row 3."
+      RenderBlock {P} at (0,80) size 784x40
+        RenderText {#text} at (0,0) size 764x40
+          text run at (0,0) width 764: "If the test succeeds then you should see no text inside the table. If you see the text 'FAIL' inside the table, then the test has"
+          text run at (0,20) width 39: "failed."
+      RenderTable {TABLE} at (0,136) size 102x82 [border: (1px outset #808080)]
+        RenderTableSection {TBODY} at (1,1) size 100x80
+          RenderTableRow {TR} at (0,2) size 100x24
+            RenderTableCell {TD} at (2,2) size 20x24 [border: (1px inset #808080)] [r=0 c=0 rs=1 cs=1]
+              RenderText {#text} at (2,2) size 16x20
+                text run at (2,2) width 16: "    "
+            RenderTableCell {TD} at (24,2) size 20x24 [border: (1px inset #808080)] [r=0 c=1 rs=1 cs=1]
+              RenderText {#text} at (2,2) size 16x20
+                text run at (2,2) width 16: "    "
+            RenderTableCell {TD} at (46,54) size 52x24 [bgcolor=#FF0000] [border: (1px inset #808080)] [r=0 c=2 rs=3 cs=1]
+              RenderBlock {DIV} at (2,2) size 48x20
+                RenderText {#text} at (0,0) size 48x20
+                  text run at (0,0) width 48: "            "
+          RenderTableRow {TR} at (0,28) size 100x24
+            RenderTableCell {TD} at (2,28) size 20x24 [border: (1px inset #808080)] [r=1 c=0 rs=1 cs=1]
+              RenderText {#text} at (2,2) size 16x20
+                text run at (2,2) width 16: "    "
+            RenderTableCell {TD} at (24,54) size 74x24 [bgcolor=#0000FF] [border: (1px inset #808080)] [r=1 c=1 rs=2 cs=2]
+              RenderBlock {DIV} at (2,2) size 70x20 [color=#008000]
+                RenderText {#text} at (14,0) size 56x20
+                  text run at (14,0) width 56: "   FAIL  "
+          RenderTableRow {TR} at (0,54) size 100x24
+            RenderTableCell {TD} at (2,54) size 96x24 [bgcolor=#008000] [border: (1px inset #808080)] [r=2 c=0 rs=1 cs=3]
+              RenderBlock {DIV} at (2,2) size 92x20
+                RenderText {#text} at (84,0) size 8x20
+                  text run at (84,0) width 8: "  "
diff --git a/LayoutTests/platform/gtk/tables/layering/paint-test-layering-2-expected.checksum b/LayoutTests/platform/gtk/tables/layering/paint-test-layering-2-expected.checksum
new file mode 100644
index 0000000..4c0497c
--- /dev/null
+++ b/LayoutTests/platform/gtk/tables/layering/paint-test-layering-2-expected.checksum
@@ -0,0 +1 @@
+7ab3158057c5f13dc77965e312b2549f
\ No newline at end of file
diff --git a/LayoutTests/platform/gtk/tables/layering/paint-test-layering-2-expected.png b/LayoutTests/platform/gtk/tables/layering/paint-test-layering-2-expected.png
new file mode 100644
index 0000000..92e9f73
Binary files /dev/null and b/LayoutTests/platform/gtk/tables/layering/paint-test-layering-2-expected.png differ
diff --git a/LayoutTests/platform/gtk/tables/layering/paint-test-layering-2-expected.txt b/LayoutTests/platform/gtk/tables/layering/paint-test-layering-2-expected.txt
new file mode 100644
index 0000000..aced1e8
--- /dev/null
+++ b/LayoutTests/platform/gtk/tables/layering/paint-test-layering-2-expected.txt
@@ -0,0 +1,65 @@
+layer at (0,0) size 800x600
+  RenderView at (0,0) size 800x600
+layer at (0,0) size 800x600
+  RenderBlock {HTML} at (0,0) size 800x600
+    RenderBody {BODY} at (8,8) size 784x584
+      RenderBlock {P} at (0,0) size 784x64
+        RenderText {#text} at (0,0) size 782x41
+          text run at (0,0) width 782: "This test checks the renderer's ability to layer multiple cells in a table on top of one another. This test has three cells that span"
+          text run at (0,21) width 183: "multiple table grid slots. The "
+        RenderInline {SPAN} at (0,0) size 23x22 [color=#FF0000]
+          RenderText {#text} at (183,20) size 23x22
+            text run at (183,20) width 23: "red"
+        RenderText {#text} at (206,21) size 376x20
+          text run at (206,21) width 376: " cell starts at row 1 and column 4 and spans four rows. The "
+        RenderInline {SPAN} at (0,0) size 29x22 [color=#0000FF]
+          RenderText {#text} at (582,20) size 29x22
+            text run at (582,20) width 29: "blue"
+        RenderText {#text} at (611,21) size 760x42
+          text run at (611,21) width 149: " cell starts at row 2, and"
+          text run at (0,43) width 253: "column 1, and spans four columns. The "
+        RenderInline {SPAN} at (0,0) size 38x22 [color=#008000]
+          RenderText {#text} at (253,42) size 38x22
+            text run at (253,42) width 38: "green"
+        RenderText {#text} at (291,43) size 196x20
+          text run at (291,43) width 196: " cell spans 4 columns of row 4."
+      RenderBlock {P} at (0,80) size 784x40
+        RenderText {#text} at (0,0) size 764x40
+          text run at (0,0) width 764: "If the test succeeds then you should see no text inside the table. If you see the text 'FAIL' inside the table, then the test has"
+          text run at (0,20) width 39: "failed."
+      RenderTable {TABLE} at (0,136) size 188x108 [border: (1px outset #808080)]
+        RenderTableSection {TBODY} at (1,1) size 186x106
+          RenderTableRow {TR} at (0,2) size 186x24
+            RenderTableCell {TD} at (2,2) size 44x24 [border: (1px inset #808080)] [r=0 c=0 rs=1 cs=1]
+              RenderText {#text} at (2,2) size 16x20
+                text run at (2,2) width 16: "    "
+            RenderTableCell {TD} at (48,2) size 44x24 [border: (1px inset #808080)] [r=0 c=1 rs=1 cs=1]
+              RenderText {#text} at (2,2) size 16x20
+                text run at (2,2) width 16: "    "
+            RenderTableCell {TD} at (94,2) size 44x24 [border: (1px inset #808080)] [r=0 c=2 rs=1 cs=1]
+              RenderText {#text} at (2,2) size 16x20
+                text run at (2,2) width 16: "    "
+            RenderTableCell {TD} at (140,41) size 44x24 [bgcolor=#FF0000] [border: (1px inset #808080)] [r=0 c=3 rs=4 cs=1]
+              RenderBlock {DIV} at (2,2) size 40x20
+                RenderText {#text} at (0,0) size 40x20
+                  text run at (0,0) width 40: "          "
+          RenderTableRow {TR} at (0,28) size 186x24
+            RenderTableCell {TD} at (2,28) size 182x24 [bgcolor=#0000FF] [border: (1px inset #808080)] [r=1 c=0 rs=1 cs=4]
+              RenderBlock {DIV} at (2,2) size 178x20
+                RenderText {#text} at (138,0) size 40x20
+                  text run at (138,0) width 40: "          "
+          RenderTableRow {TR} at (0,54) size 186x24
+            RenderTableCell {TD} at (2,54) size 44x24 [border: (1px inset #808080)] [r=2 c=0 rs=1 cs=1]
+              RenderText {#text} at (2,2) size 40x20
+                text run at (2,2) width 40: "          "
+            RenderTableCell {TD} at (48,54) size 44x24 [border: (1px inset #808080)] [r=2 c=1 rs=1 cs=1]
+              RenderText {#text} at (2,2) size 40x20
+                text run at (2,2) width 40: "          "
+            RenderTableCell {TD} at (94,54) size 44x24 [border: (1px inset #808080)] [r=2 c=2 rs=1 cs=1]
+              RenderText {#text} at (2,2) size 40x20
+                text run at (2,2) width 40: "          "
+          RenderTableRow {TR} at (0,80) size 186x24
+            RenderTableCell {TD} at (2,80) size 182x24 [bgcolor=#008000] [border: (1px inset #808080)] [r=3 c=0 rs=1 cs=4]
+              RenderBlock {DIV} at (2,2) size 178x20 [color=#008000]
+                RenderText {#text} at (138,0) size 40x20
+                  text run at (138,0) width 40: "FAIL "
diff --git a/LayoutTests/platform/mac/tables/layering/paint-test-layering-1-expected.checksum b/LayoutTests/platform/mac/tables/layering/paint-test-layering-1-expected.checksum
new file mode 100644
index 0000000..663a3d4
--- /dev/null
+++ b/LayoutTests/platform/mac/tables/layering/paint-test-layering-1-expected.checksum
@@ -0,0 +1 @@
+74f85aff0ca32f568d65d23112496aef
\ No newline at end of file
diff --git a/LayoutTests/platform/mac/tables/layering/paint-test-layering-1-expected.png b/LayoutTests/platform/mac/tables/layering/paint-test-layering-1-expected.png
new file mode 100644
index 0000000..3488cfc
Binary files /dev/null and b/LayoutTests/platform/mac/tables/layering/paint-test-layering-1-expected.png differ
diff --git a/LayoutTests/platform/mac/tables/layering/paint-test-layering-1-expected.txt b/LayoutTests/platform/mac/tables/layering/paint-test-layering-1-expected.txt
new file mode 100644
index 0000000..daa9896
--- /dev/null
+++ b/LayoutTests/platform/mac/tables/layering/paint-test-layering-1-expected.txt
@@ -0,0 +1,55 @@
+layer at (0,0) size 800x600
+  RenderView at (0,0) size 800x600
+layer at (0,0) size 800x600
+  RenderBlock {HTML} at (0,0) size 800x600
+    RenderBody {BODY} at (8,8) size 784x584
+      RenderBlock {P} at (0,0) size 784x54
+        RenderText {#text} at (0,0) size 782x36
+          text run at (0,0) width 782: "This test checks the renderer's ability to layer multiple cells in a table on top of one another. This test has three cells that span"
+          text run at (0,18) width 183: "multiple table grid slots. The "
+        RenderInline {SPAN} at (0,0) size 23x18 [color=#FF0000]
+          RenderText {#text} at (183,18) size 23x18
+            text run at (183,18) width 23: "red"
+        RenderText {#text} at (206,18) size 381x18
+          text run at (206,18) width 381: " cell starts at row 1 and column 3 and spans three rows. The "
+        RenderInline {SPAN} at (0,0) size 29x18 [color=#0000FF]
+          RenderText {#text} at (587,18) size 29x18
+            text run at (587,18) width 29: "blue"
+        RenderText {#text} at (616,18) size 765x36
+          text run at (616,18) width 149: " cell starts at row 2, and"
+          text run at (0,36) width 341: "column 2, and spans two columns and two rows. The "
+        RenderInline {SPAN} at (0,0) size 38x18 [color=#008000]
+          RenderText {#text} at (341,36) size 38x18
+            text run at (341,36) width 38: "green"
+        RenderText {#text} at (379,36) size 196x18
+          text run at (379,36) width 196: " cell spans 4 columns of row 3."
+      RenderBlock {P} at (0,70) size 784x36
+        RenderText {#text} at (0,0) size 764x36
+          text run at (0,0) width 764: "If the test succeeds then you should see no text inside the table. If you see the text 'FAIL' inside the table, then the test has"
+          text run at (0,18) width 39: "failed."
+      RenderTable {TABLE} at (0,122) size 102x76 [border: (1px outset #808080)]
+        RenderTableSection {TBODY} at (1,1) size 100x74
+          RenderTableRow {TR} at (0,2) size 100x22
+            RenderTableCell {TD} at (2,2) size 20x22 [border: (1px inset #808080)] [r=0 c=0 rs=1 cs=1]
+              RenderText {#text} at (2,2) size 16x18
+                text run at (2,2) width 16: "    "
+            RenderTableCell {TD} at (24,2) size 20x22 [border: (1px inset #808080)] [r=0 c=1 rs=1 cs=1]
+              RenderText {#text} at (2,2) size 16x18
+                text run at (2,2) width 16: "    "
+            RenderTableCell {TD} at (46,50) size 52x22 [bgcolor=#FF0000] [border: (1px inset #808080)] [r=0 c=2 rs=3 cs=1]
+              RenderBlock {DIV} at (2,2) size 48x18
+                RenderText {#text} at (0,0) size 48x18
+                  text run at (0,0) width 48: "            "
+          RenderTableRow {TR} at (0,26) size 100x22
+            RenderTableCell {TD} at (2,26) size 20x22 [border: (1px inset #808080)] [r=1 c=0 rs=1 cs=1]
+              RenderText {#text} at (2,2) size 16x18
+                text run at (2,2) width 16: "    "
+            RenderTableCell {TD} at (24,50) size 74x22 [bgcolor=#0000FF] [border: (1px inset #808080)] [r=1 c=1 rs=2 cs=2]
+              RenderBlock {DIV} at (2,2) size 70x18 [color=#008000]
+                RenderText {#text} at (14,0) size 56x18
+                  text run at (14,0) width 56: "   FAIL  "
+          RenderTableRow {TR} at (0,50) size 100x22
+            RenderTableCell {TD} at (2,50) size 96x22 [bgcolor=#008000] [border: (1px inset #808080)] [r=2 c=0 rs=1 cs=3]
+              RenderBlock {DIV} at (2,2) size 92x18
+                RenderText {#text} at (84,0) size 8x18
+                  text run at (84,0) width 8: "  "
diff --git a/LayoutTests/platform/mac/tables/layering/paint-test-layering-2-expected.checksum b/LayoutTests/platform/mac/tables/layering/paint-test-layering-2-expected.checksum
new file mode 100644
index 0000000..bc3ff1e
--- /dev/null
+++ b/LayoutTests/platform/mac/tables/layering/paint-test-layering-2-expected.checksum
@@ -0,0 +1 @@
+d3aa1e78efe6c6e3063272d385ee0134
\ No newline at end of file
diff --git a/LayoutTests/platform/mac/tables/layering/paint-test-layering-2-expected.png b/LayoutTests/platform/mac/tables/layering/paint-test-layering-2-expected.png
new file mode 100644
index 0000000..046e3d3
Binary files /dev/null and b/LayoutTests/platform/mac/tables/layering/paint-test-layering-2-expected.png differ
diff --git a/LayoutTests/platform/mac/tables/layering/paint-test-layering-2-expected.txt b/LayoutTests/platform/mac/tables/layering/paint-test-layering-2-expected.txt
new file mode 100644
index 0000000..96434f3
--- /dev/null
+++ b/LayoutTests/platform/mac/tables/layering/paint-test-layering-2-expected.txt
@@ -0,0 +1,65 @@
+layer at (0,0) size 800x600
+  RenderView at (0,0) size 800x600
+layer at (0,0) size 800x600
+  RenderBlock {HTML} at (0,0) size 800x600
+    RenderBody {BODY} at (8,8) size 784x584
+      RenderBlock {P} at (0,0) size 784x54
+        RenderText {#text} at (0,0) size 782x36
+          text run at (0,0) width 782: "This test checks the renderer's ability to layer multiple cells in a table on top of one another. This test has three cells that span"
+          text run at (0,18) width 183: "multiple table grid slots. The "
+        RenderInline {SPAN} at (0,0) size 23x18 [color=#FF0000]
+          RenderText {#text} at (183,18) size 23x18
+            text run at (183,18) width 23: "red"
+        RenderText {#text} at (206,18) size 376x18
+          text run at (206,18) width 376: " cell starts at row 1 and column 4 and spans four rows. The "
+        RenderInline {SPAN} at (0,0) size 29x18 [color=#0000FF]
+          RenderText {#text} at (582,18) size 29x18
+            text run at (582,18) width 29: "blue"
+        RenderText {#text} at (611,18) size 760x36
+          text run at (611,18) width 149: " cell starts at row 2, and"
+          text run at (0,36) width 253: "column 1, and spans four columns. The "
+        RenderInline {SPAN} at (0,0) size 38x18 [color=#008000]
+          RenderText {#text} at (253,36) size 38x18
+            text run at (253,36) width 38: "green"
+        RenderText {#text} at (291,36) size 196x18
+          text run at (291,36) width 196: " cell spans 4 columns of row 4."
+      RenderBlock {P} at (0,70) size 784x36
+        RenderText {#text} at (0,0) size 764x36
+          text run at (0,0) width 764: "If the test succeeds then you should see no text inside the table. If you see the text 'FAIL' inside the table, then the test has"
+          text run at (0,18) width 39: "failed."
+      RenderTable {TABLE} at (0,122) size 188x100 [border: (1px outset #808080)]
+        RenderTableSection {TBODY} at (1,1) size 186x98
+          RenderTableRow {TR} at (0,2) size 186x22
+            RenderTableCell {TD} at (2,2) size 44x22 [border: (1px inset #808080)] [r=0 c=0 rs=1 cs=1]
+              RenderText {#text} at (2,2) size 16x18
+                text run at (2,2) width 16: "    "
+            RenderTableCell {TD} at (48,2) size 44x22 [border: (1px inset #808080)] [r=0 c=1 rs=1 cs=1]
+              RenderText {#text} at (2,2) size 16x18
+                text run at (2,2) width 16: "    "
+            RenderTableCell {TD} at (94,2) size 44x22 [border: (1px inset #808080)] [r=0 c=2 rs=1 cs=1]
+              RenderText {#text} at (2,2) size 16x18
+                text run at (2,2) width 16: "    "
+            RenderTableCell {TD} at (140,38) size 44x22 [bgcolor=#FF0000] [border: (1px inset #808080)] [r=0 c=3 rs=4 cs=1]
+              RenderBlock {DIV} at (2,2) size 40x18
+                RenderText {#text} at (0,0) size 40x18
+                  text run at (0,0) width 40: "          "
+          RenderTableRow {TR} at (0,26) size 186x22
+            RenderTableCell {TD} at (2,26) size 182x22 [bgcolor=#0000FF] [border: (1px inset #808080)] [r=1 c=0 rs=1 cs=4]
+              RenderBlock {DIV} at (2,2) size 178x18
+                RenderText {#text} at (138,0) size 40x18
+                  text run at (138,0) width 40: "          "
+          RenderTableRow {TR} at (0,50) size 186x22
+            RenderTableCell {TD} at (2,50) size 44x22 [border: (1px inset #808080)] [r=2 c=0 rs=1 cs=1]
+              RenderText {#text} at (2,2) size 40x18
+                text run at (2,2) width 40: "          "
+            RenderTableCell {TD} at (48,50) size 44x22 [border: (1px inset #808080)] [r=2 c=1 rs=1 cs=1]
+              RenderText {#text} at (2,2) size 40x18
+                text run at (2,2) width 40: "          "
+            RenderTableCell {TD} at (94,50) size 44x22 [border: (1px inset #808080)] [r=2 c=2 rs=1 cs=1]
+              RenderText {#text} at (2,2) size 40x18
+                text run at (2,2) width 40: "          "
+          RenderTableRow {TR} at (0,74) size 186x22
+            RenderTableCell {TD} at (2,74) size 182x22 [bgcolor=#008000] [border: (1px inset #808080)] [r=3 c=0 rs=1 cs=4]
+              RenderBlock {DIV} at (2,2) size 178x18 [color=#008000]
+                RenderText {#text} at (138,0) size 40x18
+                  text run at (138,0) width 40: "FAIL "
diff --git a/LayoutTests/tables/layering/paint-test-layering-1.html b/LayoutTests/tables/layering/paint-test-layering-1.html
new file mode 100644
index 0000000..b20a8c4
--- /dev/null
+++ b/LayoutTests/tables/layering/paint-test-layering-1.html
@@ -0,0 +1,45 @@
+<html>
+<head>
+<title>Table Repaint Test</title>
+
+</head>
+<script type="text/javascript">
+<!--
+    function Setup() { 
+        setTimeout('RepaintBug()', 10);
+        if (window.layoutTestController)
+            layoutTestController.waitUntilDone();
+    }
+    function RepaintBug() {
+        var div1 = document.getElementById("bug2");
+        div1.style.color = 'green';
+        if (window.layoutTestController)
+            layoutTestController.notifyDone();
+    }
+//-->
+</script>
+  <body onLoad="Setup()">
+    <p>
+        This test checks the renderer's ability to layer multiple cells in a table on top of one another. This test has three cells that span multiple table grid slots. The <span style="color: red; font-weight: bold;">red</span> cell starts at row 1 and column 3 and spans three rows. The <span style="color: blue; font-weight: bold;">blue</span> cell starts at row 2, and column 2, and spans two columns and two rows. The <span style="color: green; font-weight: bold;">green</span> cell spans 4 columns of row 3.
+    </p>
+    <p>
+        If the test succeeds then you should see no text inside the table. If you see the text 'FAIL' inside the table, then the test has failed.
+    </p>
+  <table border="1">
+    <tbody>
+    <tr>
+      <td>&nbsp;&nbsp;&nbsp;&nbsp;</td>
+      <td>&nbsp;&nbsp;&nbsp;&nbsp;</td>
+      <td rowspan="3" valign="bottom" style="background-color:red;"><div id="bug1">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</div></td>
+    </tr>
+    <tr>
+      <td>&nbsp;&nbsp;&nbsp;&nbsp;</td>
+      <td rowspan="2" colspan="2" align="right" valign="bottom" style="background-color:blue;"><div id="bug2">&nbsp;&nbsp;&nbsp;FAIL&nbsp;&nbsp;</div></td>
+    </tr>
+    <tr>
+      <td colspan="3" align="right" style="background-color:green;"><div id="bug3">&nbsp;&nbsp;</div></td>
+    </tr>
+    </tbody>
+  </table>
+  </body>
+</html>
diff --git a/LayoutTests/tables/layering/paint-test-layering-2.html b/LayoutTests/tables/layering/paint-test-layering-2.html
new file mode 100644
index 0000000..938d489
--- /dev/null
+++ b/LayoutTests/tables/layering/paint-test-layering-2.html
@@ -0,0 +1,67 @@
+<html>
+<head>
+<title>Table Repaint Test</title>
+</head>
+<script type="text/javascript">
+<!--
+    function Setup() { 
+        setTimeout('RepaintBug()', 10);
+        if (window.layoutTestController)
+            layoutTestController.waitUntilDone();
+    }
+    function RepaintBug() {
+        var div2 = document.getElementById("bug2");
+        div2.style.color = 'green';
+        if (window.layoutTestController)
+            layoutTestController.notifyDone();
+    }
+//-->
+</script>
+<body onLoad="Setup()">
+    <p>
+        This test checks the renderer's ability to layer multiple cells in a table on top of one another. This test has three cells that span multiple table grid slots. The <span style="color: red; font-weight: bold;">red</span> cell starts at row 1 and column 4 and spans four rows. The <span style="color: blue; font-weight: bold;">blue</span> cell starts at row 2, and column 1, and spans four columns. The <span style="color: green; font-weight: bold;">green</span> cell spans 4 columns of row 4.
+    </p>
+    <p>
+        If the test succeeds then you should see no text inside the table. If you see the text 'FAIL' inside the table, then the test has failed.
+    </p>
+    <table border="1">
+        <tr>
+            <td>
+                &nbsp;&nbsp;&nbsp;&nbsp;
+            </td>
+            <td> 
+                &nbsp;&nbsp;&nbsp;&nbsp;
+            </td>
+            <td>
+                &nbsp;&nbsp;&nbsp;&nbsp;
+            </td>
+            <td rowspan="4" style="background-color: red;">
+                <div>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</div>
+            </td>
+        </tr>
+        <tr>
+            <td colspan="4" style="background-color: blue;" align="right">
+                <div>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</div>
+            </td>
+        </tr>
+        <tr>
+            <td>
+                &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
+            </td>
+            <td>
+                &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
+            </td>
+            <td>
+                &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
+            </td>                
+        </tr>
+        <tr>
+            <td colspan="4" align="right" style="background-color: green;">
+                <div id="bug2">
+                    FAIL&nbsp;
+                </div>
+            </td>
+        </tr>
+    </table>
+</body>
+</html>
diff --git a/WebCore/ChangeLog b/WebCore/ChangeLog
index c952ccc..6d24e14 100644
--- a/WebCore/ChangeLog
+++ b/WebCore/ChangeLog
@@ -1,3 +1,58 @@
+2010-07-23  fsamuel at chromium.org  <fsamuel at chromium.org>
+
+        Reviewed by David Hyatt.
+
+        Updated table painting to draw cell layers in the correct order.
+
+        Table Cell Layering
+        https://bugs.webkit.org/show_bug.cgi?id=40775
+
+        Tests: tables/layering/paint-test-layering-1.html
+               tables/layering/paint-test-layering-2.html
+
+        * accessibility/AccessibilityTable.cpp:
+        (WebCore::AccessibilityTable::isTableExposableThroughAccessibility):
+        (WebCore::AccessibilityTable::addChildren):
+        (WebCore::AccessibilityTable::cellForColumnAndRow):
+        * accessibility/AccessibilityTableCell.cpp:
+        (WebCore::AccessibilityTableCell::titleUIElement):
+        * accessibility/AccessibilityTableColumn.cpp:
+        (WebCore::AccessibilityTableColumn::headerObjectForSection):
+        * rendering/AutoTableLayout.cpp:
+        (WebCore::AutoTableLayout::recalcColumn):
+        * rendering/RenderTable.cpp:
+        (WebCore::RenderTable::splitColumn):
+        (WebCore::RenderTable::calcBorderLeft):
+        (WebCore::RenderTable::calcBorderRight):
+        (WebCore::RenderTable::cellAbove):
+        (WebCore::RenderTable::cellBelow):
+        (WebCore::RenderTable::cellBefore):
+        (WebCore::RenderTable::cellAfter):
+        * rendering/RenderTableSection.cpp:
+        (WebCore::RenderTableSection::RenderTableSection):
+        (WebCore::RenderTableSection::ensureRows):
+        (WebCore::RenderTableSection::addCell):
+        (WebCore::RenderTableSection::setCellWidths):
+        (WebCore::RenderTableSection::calcRowHeight):
+        (WebCore::RenderTableSection::layoutRows):
+        (WebCore::RenderTableSection::calcOuterBorderTop):
+        (WebCore::RenderTableSection::calcOuterBorderBottom):
+        (WebCore::RenderTableSection::calcOuterBorderLeft):
+        (WebCore::RenderTableSection::calcOuterBorderRight):
+        (WebCore::RenderTableSection::firstLineBoxBaseline):
+        (WebCore::compareCellPositions):
+        (WebCore::RenderTableSection::paintCell):
+        (WebCore::RenderTableSection::paintObject):
+        (WebCore::RenderTableSection::numColumns):
+        (WebCore::RenderTableSection::appendColumn):
+        (WebCore::RenderTableSection::splitColumn):
+        (WebCore::RenderTableSection::nodeAtPoint):
+        * rendering/RenderTableSection.h:
+        (WebCore::RenderTableSection::CellStruct::CellStruct):
+        (WebCore::RenderTableSection::CellStruct::primaryCell):
+        (WebCore::RenderTableSection::CellStruct::hasCells):
+        (WebCore::RenderTableSection::primaryCellAt):
+
 2010-07-23  Patrick Gansterer  <paroga at paroga.com>
 
         Reviewed by Adam Roben.
diff --git a/WebCore/accessibility/AccessibilityTable.cpp b/WebCore/accessibility/AccessibilityTable.cpp
index a0bb655..04ecac3 100644
--- a/WebCore/accessibility/AccessibilityTable.cpp
+++ b/WebCore/accessibility/AccessibilityTable.cpp
@@ -145,7 +145,7 @@ bool AccessibilityTable::isTableExposableThroughAccessibility()
     
         int headersInFirstRowCount = 0;
         for (int col = 0; col < numCols; ++col) {    
-            RenderTableCell* cell = firstBody->cellAt(row, col).cell;
+            RenderTableCell* cell = firstBody->primaryCellAt(row, col);
             if (!cell)
                 continue;
             Node* cellNode = cell->node();
@@ -287,7 +287,7 @@ void AccessibilityTable::addChildren()
         for (unsigned rowIndex = 0; rowIndex < numRows; ++rowIndex) {
             for (unsigned colIndex = 0; colIndex < numCols; ++colIndex) {
                 
-                RenderTableCell* cell = tableSection->cellAt(rowIndex, colIndex).cell;
+                RenderTableCell* cell = tableSection->primaryCellAt(rowIndex, colIndex);
                 if (!cell)
                     continue;
                 
@@ -441,7 +441,7 @@ AccessibilityTableCell* AccessibilityTable::cellForColumnAndRow(unsigned column,
         
         unsigned sectionSpecificRow = row - rowOffset;            
         if (row < rowCount && column < numCols && sectionSpecificRow < numRows) {
-            cell = tableSection->cellAt(sectionSpecificRow, column).cell;
+            cell = tableSection->primaryCellAt(sectionSpecificRow, column);
             
             // we didn't find the cell, which means there's spanning happening
             // search backwards to find the spanning cell
@@ -449,7 +449,7 @@ AccessibilityTableCell* AccessibilityTable::cellForColumnAndRow(unsigned column,
                 
                 // first try rows
                 for (int testRow = sectionSpecificRow-1; testRow >= 0; --testRow) {
-                    cell = tableSection->cellAt(testRow, column).cell;
+                    cell = tableSection->primaryCellAt(testRow, column);
                     // cell overlapped. use this one
                     if (cell && ((cell->row() + (cell->rowSpan()-1)) >= (int)sectionSpecificRow))
                         break;
@@ -459,7 +459,7 @@ AccessibilityTableCell* AccessibilityTable::cellForColumnAndRow(unsigned column,
                 if (!cell) {
                     // try cols
                     for (int testCol = column-1; testCol >= 0; --testCol) {
-                        cell = tableSection->cellAt(sectionSpecificRow, testCol).cell;
+                        cell = tableSection->primaryCellAt(sectionSpecificRow, testCol);
                         // cell overlapped. use this one
                         if (cell && ((cell->col() + (cell->colSpan()-1)) >= (int)column))
                             break;
diff --git a/WebCore/accessibility/AccessibilityTableCell.cpp b/WebCore/accessibility/AccessibilityTableCell.cpp
index 28e66ad..e2efb5e 100644
--- a/WebCore/accessibility/AccessibilityTableCell.cpp
+++ b/WebCore/accessibility/AccessibilityTableCell.cpp
@@ -165,7 +165,7 @@ AccessibilityObject* AccessibilityTableCell::titleUIElement() const
     if (!section)
         return 0;
     
-    RenderTableCell* headerCell = section->cellAt(row, 0).cell;
+    RenderTableCell* headerCell = section->primaryCellAt(row, 0);
     if (!headerCell || headerCell == renderCell)
         return 0;
 
diff --git a/WebCore/accessibility/AccessibilityTableColumn.cpp b/WebCore/accessibility/AccessibilityTableColumn.cpp
index 45137ff..f776e40 100644
--- a/WebCore/accessibility/AccessibilityTableColumn.cpp
+++ b/WebCore/accessibility/AccessibilityTableColumn.cpp
@@ -136,7 +136,7 @@ AccessibilityObject* AccessibilityTableColumn::headerObjectForSection(RenderTabl
     RenderTableCell* cell = 0;
     // also account for cells that have a span
     for (int testCol = m_columnIndex; testCol >= 0; --testCol) {
-        RenderTableCell* testCell = section->cellAt(0, testCol).cell;
+        RenderTableCell* testCell = section->primaryCellAt(0, testCol);
         if (!testCell)
             continue;
         
diff --git a/WebCore/rendering/AutoTableLayout.cpp b/WebCore/rendering/AutoTableLayout.cpp
index e6a1cc0..0715caa 100644
--- a/WebCore/rendering/AutoTableLayout.cpp
+++ b/WebCore/rendering/AutoTableLayout.cpp
@@ -66,9 +66,9 @@ void AutoTableLayout::recalcColumn(int effCol)
             int numRows = section->numRows();
             for (int i = 0; i < numRows; i++) {
                 RenderTableSection::CellStruct current = section->cellAt(i, effCol);
-                RenderTableCell* cell = current.cell;
+                RenderTableCell* cell = current.primaryCell();
                 
-                bool cellHasContent = cell && (cell->firstChild() || cell->style()->hasBorder() || cell->style()->hasPadding());
+                bool cellHasContent = cell && !current.inColSpan && (cell->firstChild() || cell->style()->hasBorder() || cell->style()->hasPadding());
                 if (cellHasContent)
                     l.emptyCellsOnly = false;
                     
@@ -125,7 +125,7 @@ void AutoTableLayout::recalcColumn(int effCol)
                         break;
                     }
                 } else {
-                    if (cell && (!effCol || section->cellAt(i, effCol-1).cell != cell)) {
+                    if (cell && (!effCol || cell->section()->primaryCellAt(i, effCol-1) != cell)) {
                         // This spanning cell originates in this column.  Ensure we have
                         // a min/max width of at least 1px for this column now.
                         l.minWidth = max(l.minWidth, cellHasContent ? 1 : 0);
diff --git a/WebCore/rendering/RenderTable.cpp b/WebCore/rendering/RenderTable.cpp
index fd90990..658fd9c 100644
--- a/WebCore/rendering/RenderTable.cpp
+++ b/WebCore/rendering/RenderTable.cpp
@@ -556,7 +556,7 @@ void RenderTable::splitColumn(int pos, int firstSpan)
     // change width of all rows.
     for (RenderObject* child = firstChild(); child; child = child->nextSibling()) {
         if (child->isTableSection())
-            toRenderTableSection(child)->splitColumn(pos, oldSize + 1);
+            toRenderTableSection(child)->splitColumn(pos, firstSpan);
     }
 
     m_columnPos.grow(numEffCols() + 1);
@@ -750,12 +750,12 @@ int RenderTable::calcBorderLeft() const
 
             const RenderTableSection::CellStruct& cs = firstNonEmptySection->cellAt(0, leftmostColumn);
             
-            if (cs.cell) {
-                const BorderValue& cb = cs.cell->style()->borderLeft();
+            if (cs.hasCells()) {
+                const BorderValue& cb = cs.primaryCell()->style()->borderLeft();
                 if (cb.style() == BHIDDEN)
                     return 0;
 
-                const BorderValue& rb = cs.cell->parent()->style()->borderLeft();
+                const BorderValue& rb = cs.primaryCell()->parent()->style()->borderLeft();
                 if (rb.style() == BHIDDEN)
                     return 0;
 
@@ -809,12 +809,12 @@ int RenderTable::calcBorderRight() const
 
             const RenderTableSection::CellStruct& cs = firstNonEmptySection->cellAt(0, rightmostColumn);
             
-            if (cs.cell) {
-                const BorderValue& cb = cs.cell->style()->borderRight();
+            if (cs.hasCells()) {
+                const BorderValue& cb = cs.primaryCell()->style()->borderRight();
                 if (cb.style() == BHIDDEN)
                     return 0;
 
-                const BorderValue& rb = cs.cell->parent()->style()->borderRight();
+                const BorderValue& rb = cs.primaryCell()->parent()->style()->borderRight();
                 if (rb.style() == BHIDDEN)
                     return 0;
 
@@ -1024,8 +1024,8 @@ RenderTableCell* RenderTable::cellAbove(const RenderTableCell* cell) const
         do {
             aboveCell = section->cellAt(rAbove, effCol);
             effCol--;
-        } while (!aboveCell.cell && aboveCell.inColSpan && effCol >= 0);
-        return aboveCell.cell;
+        } while (!aboveCell.hasCells() && aboveCell.inColSpan && effCol >= 0);
+        return aboveCell.primaryCell();
     } else
         return 0;
 }
@@ -1056,8 +1056,8 @@ RenderTableCell* RenderTable::cellBelow(const RenderTableCell* cell) const
         do {
             belowCell = section->cellAt(rBelow, effCol);
             effCol--;
-        } while (!belowCell.cell && belowCell.inColSpan && effCol >= 0);
-        return belowCell.cell;
+        } while (!belowCell.hasCells() && belowCell.inColSpan && effCol >= 0);
+        return belowCell.primaryCell();
     } else
         return 0;
 }
@@ -1076,8 +1076,8 @@ RenderTableCell* RenderTable::cellBefore(const RenderTableCell* cell) const
     do {
         prevCell = section->cellAt(cell->row(), effCol - 1);
         effCol--;
-    } while (!prevCell.cell && prevCell.inColSpan && effCol >= 0);
-    return prevCell.cell;
+    } while (!prevCell.hasCells() && prevCell.inColSpan && effCol >= 0);
+    return prevCell.primaryCell();
 }
 
 RenderTableCell* RenderTable::cellAfter(const RenderTableCell* cell) const
@@ -1087,7 +1087,7 @@ RenderTableCell* RenderTable::cellAfter(const RenderTableCell* cell) const
     int effCol = colToEffCol(cell->col() + cell->colSpan());
     if (effCol >= numEffCols())
         return 0;
-    return cell->section()->cellAt(cell->row(), effCol).cell;
+    return cell->section()->primaryCellAt(cell->row(), effCol);
 }
 
 RenderBlock* RenderTable::firstLineBlock() const
diff --git a/WebCore/rendering/RenderTableSection.cpp b/WebCore/rendering/RenderTableSection.cpp
index b25d3e6..8c8d130 100644
--- a/WebCore/rendering/RenderTableSection.cpp
+++ b/WebCore/rendering/RenderTableSection.cpp
@@ -34,6 +34,7 @@
 #include "RenderTableRow.h"
 #include "RenderView.h"
 #include <limits>
+#include <wtf/HashSet.h>
 #include <wtf/Vector.h>
 
 using namespace std;
@@ -61,9 +62,10 @@ RenderTableSection::RenderTableSection(Node* node)
     , m_outerBorderBottom(0)
     , m_needsCellRecalc(false)
     , m_hasOverflowingCell(false)
+    , m_hasMultipleCellLevels(false)
 {
     // init RenderObject attributes
-    setInline(false);   // our object is not Inline
+    setInline(false); // our object is not Inline
 }
 
 RenderTableSection::~RenderTableSection()
@@ -160,8 +162,8 @@ bool RenderTableSection::ensureRows(int numRows)
         m_gridRows = numRows;
         int nCols = max(1, table()->numEffCols());
         CellStruct emptyCellStruct;
-        emptyCellStruct.cell = 0;
         emptyCellStruct.inColSpan = false;
+        emptyCellStruct.empty = false;
         for (int r = nRows; r < numRows; r++) {
             m_grid[r].row = new Row(nCols);
             m_grid[r].row->fill(emptyCellStruct);
@@ -187,10 +189,8 @@ void RenderTableSection::addCell(RenderTableCell* cell, RenderTableRow* row)
     // <TR><TD>1 <TD rowspan="2">2 <TD>3 <TD>4
     // <TR><TD colspan="2">5
     // </TABLE>
-
-    while (m_cCol < nCols && (cellAt(m_cRow, m_cCol).cell || cellAt(m_cRow, m_cCol).inColSpan))
+    while (m_cCol < nCols && (cellAt(m_cRow, m_cCol).hasCells() || cellAt(m_cRow, m_cCol).inColSpan))
         m_cCol++;
-
     if (rSpan == 1) {
         // we ignore height settings on rowspan cells
         Length height = cell->style()->height();
@@ -222,31 +222,30 @@ void RenderTableSection::addCell(RenderTableCell* cell, RenderTableRow* row)
 
     int col = m_cCol;
     // tell the cell where it is
-    CellStruct currentCell;
-    currentCell.cell = cell;
-    currentCell.inColSpan = false;
+    bool inColSpan = false;
     while (cSpan) {
-        int currentSpan;
-        if (m_cCol >= nCols) {
-            table()->appendColumn(cSpan);
-            currentSpan = cSpan;
-        } else {
-            if (cSpan < static_cast<int>(columns[m_cCol].span))
-                table()->splitColumn(m_cCol, cSpan);
-            currentSpan = columns[m_cCol].span;
-        }
-
-        for (int r = 0; r < rSpan; r++) {
-            CellStruct& c = cellAt(m_cRow + r, m_cCol);
-            if (!c.cell)
-                c.cell = currentCell.cell;
-            if (currentCell.inColSpan)
-                c.inColSpan = true;
-        }
-        m_cCol++;
-        cSpan -= currentSpan;
-        currentCell.cell = 0;
-        currentCell.inColSpan = true;
+      int currentSpan;
+      if (m_cCol >= nCols) {
+          table()->appendColumn(cSpan);
+          currentSpan = cSpan;
+      } else {
+          if (cSpan < (int)columns[m_cCol].span)
+              table()->splitColumn(m_cCol, cSpan);
+          currentSpan = columns[m_cCol].span;
+      }
+      for (int r = 0; r < rSpan; r++) {
+          CellStruct& c = cellAt(m_cRow + r, m_cCol);
+          ASSERT(cell);
+          c.cells.append(cell);
+          // If cells overlap then we take the slow path for painting.
+          if (c.cells.size() > 1)
+              m_hasMultipleCellLevels = true;
+          if (inColSpan)
+              c.inColSpan = true;
+      }
+      m_cCol++;
+      cSpan -= currentSpan;
+      inColSpan = true;
     }
     cell->setRow(m_cRow);
     cell->setCol(table()->effColToCol(col));
@@ -261,15 +260,25 @@ void RenderTableSection::setCellWidths()
     for (int i = 0; i < m_gridRows; i++) {
         Row& row = *m_grid[i].row;
         int cols = row.size();
+        RenderTableCell* lastCell = 0;
         for (int j = 0; j < cols; j++) {
-            CellStruct current = row[j];
-            RenderTableCell* cell = current.cell;
-
-            if (!cell)
-                continue;
+            CellStruct& current = row[j];
+            RenderTableCell* cell = current.primaryCell();
+            if (!cell) {
+              ASSERT(lastCell || !current.inColSpan);
+              if (lastCell)
+                current.cells.append(lastCell);
+              if (!current.inColSpan)
+                current.empty = true;
+              continue;
+            }
+            if (current.inColSpan || current.empty)
+              continue;
+            lastCell = cell;
             int endCol = j;
             int cspan = cell->colSpan();
             while (cspan && endCol < cols) {
+                ASSERT(endCol < (int)table()->columns().size());
                 cspan -= table()->columns()[endCol].span;
                 endCol++;
             }
@@ -290,7 +299,7 @@ void RenderTableSection::setCellWidths()
         }
     }
     
-    statePusher.pop();  // only pops if we pushed
+    statePusher.pop(); // only pops if we pushed
 }
 
 int RenderTableSection::calcRowHeight()
@@ -324,11 +333,13 @@ int RenderTableSection::calcRowHeight()
         int totalCols = row->size();
 
         for (int c = 0; c < totalCols; c++) {
-            CellStruct current = cellAt(r, c);
-            cell = current.cell;
-            if (!cell || current.inColSpan)
+            CellStruct& current = cellAt(r, c);
+            cell = current.primaryCell();
+            ASSERT(cell || current.empty);
+            if (!cell || current.empty || current.inColSpan)
                 continue;
-            if (r < m_gridRows - 1 && cellAt(r + 1, c).cell == cell)
+
+            if ((cell->row() + cell->rowSpan() - 1) > r)
                 continue;
 
             int indx = max(r - cell->rowSpan() + 1, 0);
@@ -370,7 +381,7 @@ int RenderTableSection::calcRowHeight()
             }
         }
 
-        //do we have baseline aligned elements?
+        // do we have baseline aligned elements?
         if (baseline) {
             // increase rowheight if baseline requires
             m_rowPos[r + 1] = max(m_rowPos[r + 1], baseline + bdesc + (m_grid[r].rowRenderer ? spacing : 0));
@@ -474,7 +485,7 @@ int RenderTableSection::layoutRows(int toAdd)
             int add = 0;
             int prev = m_rowPos[0];
             for (int r = 0; r < totalRows; r++) {
-                //weight with the original height
+                // weight with the original height
                 add += dh * (m_rowPos[r + 1] - prev) / tot;
                 prev = m_rowPos[r + 1];
                 m_rowPos[r + 1] += add;
@@ -497,16 +508,14 @@ int RenderTableSection::layoutRows(int toAdd)
         }
 
         for (int c = 0; c < nEffCols; c++) {
-            RenderTableCell* cell = cellAt(r, c).cell;
-            
-            if (!cell)
-                continue;
-            if (r < totalRows - 1 && cell == cellAt(r + 1, c).cell)
-                continue;
+            CellStruct& cs = cellAt(r, c);
+            RenderTableCell* cell = cs.primaryCell();
 
-            rindx = max(0, r - cell->rowSpan() + 1);
+            if (!cell || cs.empty || cs.inColSpan)
+                continue;
 
-            rHeight = m_rowPos[r + 1] - m_rowPos[rindx] - vspacing;
+            rindx = cell->row();
+            rHeight = m_rowPos[rindx + cell->rowSpan()] - m_rowPos[rindx] - vspacing;
             
             // Force percent height children to lay themselves out again.
             // This will cause these children to grow to fill the cell.
@@ -522,8 +531,8 @@ int RenderTableSection::layoutRows(int toAdd)
             // match the behavior perfectly, but we'll continue to refine it as we discover new
             // bugs. :)
             bool cellChildrenFlex = false;
-            bool flexAllChildren = cell->style()->height().isFixed() || 
-                (!table()->style()->height().isAuto() && rHeight != cell->height());
+            bool flexAllChildren = cell->style()->height().isFixed()
+                || (!table()->style()->height().isAuto() && rHeight != cell->height());
 
             for (RenderObject* o = cell->firstChild(); o; o = o->nextSibling()) {
                 if (!o->isText() && o->style()->height().isPercent() && (flexAllChildren || o->isReplaced() || (o->isBox() && toRenderBox(o)->scrollsOverflow()))) {
@@ -616,9 +625,9 @@ int RenderTableSection::layoutRows(int toAdd)
             
             IntRect oldCellRect(cell->x(), cell->y() , cell->width(), cell->height());
         
-            if (style()->direction() == RTL) {
+            if (style()->direction() == RTL)
                 cell->setLocation(table()->columnPositions()[nEffCols] - table()->columnPositions()[table()->colToEffCol(cell->col() + cell->colSpan())] + hspacing, m_rowPos[rindx]);
-            } else
+            else
                 cell->setLocation(table()->columnPositions()[c] + hspacing, m_rowPos[rindx]);
 
             // If the cell moved, we have to repaint it as well as any floating/positioned
@@ -640,10 +649,11 @@ int RenderTableSection::layoutRows(int toAdd)
     // Now that our height has been determined, add in overflow from cells.
     for (int r = 0; r < totalRows; r++) {
         for (int c = 0; c < nEffCols; c++) {
-            RenderTableCell* cell = cellAt(r, c).cell;
-            if (!cell)
+            CellStruct& cs = cellAt(r, c);
+            RenderTableCell* cell = cs.primaryCell();
+            if (!cell || cs.empty || cs.inColSpan)
                 continue;
-            if (r < totalRows - 1 && cell == cellAt(r + 1, c).cell)
+            if (r < totalRows - 1 && cell == primaryCellAt(r + 1, c))
                 continue;
             addOverflowFromChild(cell);
             m_hasOverflowingCell |= cell->hasVisibleOverflow();
@@ -731,17 +741,16 @@ int RenderTableSection::calcOuterBorderTop() const
     bool allHidden = true;
     for (int c = 0; c < totalCols; c++) {
         const CellStruct& current = cellAt(0, c);
-        if (current.inColSpan || !current.cell)
+        if (current.inColSpan || !current.hasCells())
             continue;
-        const BorderValue& cb = current.cell->style()->borderTop();
+        const BorderValue& cb = current.primaryCell()->style()->borderTop();
         // FIXME: Don't repeat for the same col group
         RenderTableCol* colGroup = table()->colElement(c);
         if (colGroup) {
             const BorderValue& gb = colGroup->style()->borderTop();
             if (gb.style() == BHIDDEN || cb.style() == BHIDDEN)
                 continue;
-            else
-                allHidden = false;
+            allHidden = false;
             if (gb.style() > BHIDDEN && gb.width() > borderWidth)
                 borderWidth = gb.width();
             if (cb.style() > BHIDDEN && cb.width() > borderWidth)
@@ -749,8 +758,7 @@ int RenderTableSection::calcOuterBorderTop() const
         } else {
             if (cb.style() == BHIDDEN)
                 continue;
-            else
-                allHidden = false;
+            allHidden = false;
             if (cb.style() > BHIDDEN && cb.width() > borderWidth)
                 borderWidth = cb.width();
         }
@@ -784,17 +792,16 @@ int RenderTableSection::calcOuterBorderBottom() const
     bool allHidden = true;
     for (int c = 0; c < totalCols; c++) {
         const CellStruct& current = cellAt(m_gridRows - 1, c);
-        if (current.inColSpan || !current.cell)
+        if (current.inColSpan || !current.hasCells())
             continue;
-        const BorderValue& cb = current.cell->style()->borderBottom();
+        const BorderValue& cb = current.primaryCell()->style()->borderBottom();
         // FIXME: Don't repeat for the same col group
         RenderTableCol* colGroup = table()->colElement(c);
         if (colGroup) {
             const BorderValue& gb = colGroup->style()->borderBottom();
             if (gb.style() == BHIDDEN || cb.style() == BHIDDEN)
                 continue;
-            else
-                allHidden = false;
+            allHidden = false;
             if (gb.style() > BHIDDEN && gb.width() > borderWidth)
                 borderWidth = gb.width();
             if (cb.style() > BHIDDEN && cb.width() > borderWidth)
@@ -802,8 +809,7 @@ int RenderTableSection::calcOuterBorderBottom() const
         } else {
             if (cb.style() == BHIDDEN)
                 continue;
-            else
-                allHidden = false;
+            allHidden = false;
             if (cb.style() > BHIDDEN && cb.width() > borderWidth)
                 borderWidth = cb.width();
         }
@@ -841,15 +847,14 @@ int RenderTableSection::calcOuterBorderLeft(bool rtl) const
     bool allHidden = true;
     for (int r = 0; r < m_gridRows; r++) {
         const CellStruct& current = cellAt(r, leftmostColumn);
-        if (!current.cell)
+        if (!current.hasCells())
             continue;
         // FIXME: Don't repeat for the same cell
-        const BorderValue& cb = current.cell->style()->borderLeft();
-        const BorderValue& rb = current.cell->parent()->style()->borderLeft();
+        const BorderValue& cb = current.primaryCell()->style()->borderLeft();
+        const BorderValue& rb = current.primaryCell()->parent()->style()->borderLeft();
         if (cb.style() == BHIDDEN || rb.style() == BHIDDEN)
             continue;
-        else
-            allHidden = false;
+        allHidden = false;
         if (cb.style() > BHIDDEN && cb.width() > borderWidth)
             borderWidth = cb.width();
         if (rb.style() > BHIDDEN && rb.width() > borderWidth)
@@ -888,15 +893,14 @@ int RenderTableSection::calcOuterBorderRight(bool rtl) const
     bool allHidden = true;
     for (int r = 0; r < m_gridRows; r++) {
         const CellStruct& current = cellAt(r, rightmostColumn);
-        if (!current.cell)
+        if (!current.hasCells())
             continue;
         // FIXME: Don't repeat for the same cell
-        const BorderValue& cb = current.cell->style()->borderRight();
-        const BorderValue& rb = current.cell->parent()->style()->borderRight();
+        const BorderValue& cb = current.primaryCell()->style()->borderRight();
+        const BorderValue& rb = current.primaryCell()->parent()->style()->borderRight();
         if (cb.style() == BHIDDEN || rb.style() == BHIDDEN)
             continue;
-        else
-            allHidden = false;
+        allHidden = false;
         if (cb.style() > BHIDDEN && cb.width() > borderWidth)
             borderWidth = cb.width();
         if (rb.style() > BHIDDEN && rb.width() > borderWidth)
@@ -929,7 +933,8 @@ int RenderTableSection::firstLineBoxBaseline() const
     firstLineBaseline = -1;
     Row* firstRow = m_grid[0].row;
     for (size_t i = 0; i < firstRow->size(); ++i) {
-        RenderTableCell* cell = firstRow->at(i).cell;
+        CellStruct& cs = firstRow->at(i);
+        RenderTableCell* cell = cs.primaryCell();
         if (cell)
             firstLineBaseline = max(firstLineBaseline, cell->y() + cell->paddingTop() + cell->borderTop() + cell->contentHeight());
     }
@@ -961,6 +966,45 @@ void RenderTableSection::paint(PaintInfo& paintInfo, int tx, int ty)
         popContentsClip(paintInfo, phase, tx, ty);
 }
 
+static inline bool compareCellPositions(RenderTableCell* elem1, RenderTableCell* elem2)
+{
+    return elem1->row() < elem2->row();
+}
+
+void RenderTableSection::paintCell(RenderTableCell* cell, PaintInfo& paintInfo, int tx, int ty)
+{
+    PaintPhase paintPhase = paintInfo.phase;
+    RenderTableRow* row = toRenderTableRow(cell->parent());
+
+    if (paintPhase == PaintPhaseBlockBackground || paintPhase == PaintPhaseChildBlockBackground) {
+        // We need to handle painting a stack of backgrounds.  This stack (from bottom to top) consists of
+        // the column group, column, row group, row, and then the cell.
+        RenderObject* col = table()->colElement(cell->col());
+        RenderObject* colGroup = 0;
+        if (col && col->parent()->style()->display() == TABLE_COLUMN_GROUP)
+            colGroup = col->parent();
+
+        // Column groups and columns first.
+        // FIXME: Columns and column groups do not currently support opacity, and they are being painted "too late" in
+        // the stack, since we have already opened a transparency layer (potentially) for the table row group.
+        // Note that we deliberately ignore whether or not the cell has a layer, since these backgrounds paint "behind" the
+        // cell.
+        cell->paintBackgroundsBehindCell(paintInfo, tx, ty, colGroup);
+        cell->paintBackgroundsBehindCell(paintInfo, tx, ty, col);
+
+        // Paint the row group next.
+        cell->paintBackgroundsBehindCell(paintInfo, tx, ty, this);
+
+        // Paint the row next, but only if it doesn't have a layer.  If a row has a layer, it will be responsible for
+        // painting the row background for the cell.
+        if (!row->hasSelfPaintingLayer())
+            cell->paintBackgroundsBehindCell(paintInfo, tx, ty, row);
+    }
+    if ((!cell->hasSelfPaintingLayer() && !row->hasSelfPaintingLayer()) || paintInfo.phase == PaintPhaseCollapsedTableBorders)
+        cell->paint(paintInfo, tx, ty);
+
+}
+
 void RenderTableSection::paintObject(PaintInfo& paintInfo, int tx, int ty)
 {
     // Check which rows and cols are visible and only paint these.
@@ -1013,54 +1057,43 @@ void RenderTableSection::paintObject(PaintInfo& paintInfo, int tx, int ty)
         if (!endcol && tx + table()->columnPositions()[0] - table()->outerBorderLeft() <= y + w + os)
             endcol++;
     }
-
     if (startcol < endcol) {
-        // draw the cells
-        for (unsigned r = startrow; r < endrow; r++) {
-            unsigned c = startcol;
-            // since a cell can be -1 (indicating a colspan) we might have to search backwards to include it
-            while (c && cellAt(r, c).inColSpan)
-                c--;
-            for (; c < endcol; c++) {
-                CellStruct current = cellAt(r, c);
-                RenderTableCell* cell = current.cell;
-                    
-                // Cells must always paint in the order in which they appear taking into account
-                // their upper left originating row/column.  For cells with rowspans, avoid repainting
-                // if we've already seen the cell.
-                if (!cell || (r > startrow && (cellAt(r - 1, c).cell == cell)))
-                    continue;
-
-                RenderTableRow* row = toRenderTableRow(cell->parent());
-
-                if (paintPhase == PaintPhaseBlockBackground || paintPhase == PaintPhaseChildBlockBackground) {
-                    // We need to handle painting a stack of backgrounds.  This stack (from bottom to top) consists of
-                    // the column group, column, row group, row, and then the cell.
-                    RenderObject* col = table()->colElement(c);
-                    RenderObject* colGroup = 0;
-                    if (col && col->parent()->style()->display() == TABLE_COLUMN_GROUP)
-                        colGroup = col->parent();
-
-                    // Column groups and columns first.
-                    // FIXME: Columns and column groups do not currently support opacity, and they are being painted "too late" in
-                    // the stack, since we have already opened a transparency layer (potentially) for the table row group.
-                    // Note that we deliberately ignore whether or not the cell has a layer, since these backgrounds paint "behind" the
-                    // cell.
-                    cell->paintBackgroundsBehindCell(paintInfo, tx, ty, colGroup);
-                    cell->paintBackgroundsBehindCell(paintInfo, tx, ty, col);
-
-                    // Paint the row group next.
-                    cell->paintBackgroundsBehindCell(paintInfo, tx, ty, this);
-
-                    // Paint the row next, but only if it doesn't have a layer.  If a row has a layer, it will be responsible for
-                    // painting the row background for the cell.
-                    if (!row->hasSelfPaintingLayer())
-                        cell->paintBackgroundsBehindCell(paintInfo, tx, ty, row);
+        if (!m_hasMultipleCellLevels) {
+            // Draw the dirty cells in the order that they appear.
+            for (unsigned r = startrow; r < endrow; r++) {
+                for (unsigned c = startcol; c < endcol; c++) {
+                    CellStruct& current = cellAt(r, c);
+                    RenderTableCell* cell = current.primaryCell();
+                    if (current.empty || (r > startrow && primaryCellAt(r - 1, c) == cell) || (c > startcol && primaryCellAt(r, c - 1) == cell))
+                        continue;
+                    paintCell(cell, paintInfo, tx, ty);
                 }
-
-                if ((!cell->hasSelfPaintingLayer() && !row->hasSelfPaintingLayer()) || paintInfo.phase == PaintPhaseCollapsedTableBorders)
-                    cell->paint(paintInfo, tx, ty);
             }
+        } else {
+            // Draw the cells in the correct paint order.
+            Vector<RenderTableCell*> cells;
+            HashSet<RenderTableCell*> spanningCells;
+            for (unsigned r = startrow; r < endrow; r++) {
+                for (unsigned c = startcol; c < endcol; c++) {
+                    CellStruct& current = cellAt(r, c);
+                    if (current.empty)
+                        continue;
+                    for (unsigned i = 0; i < current.cells.size(); ++i) {
+                        if (current.cells[i]->rowSpan() > 1 || current.cells[i]->colSpan() > 1) {
+                            if (spanningCells.contains(current.cells[i]))
+                                continue;
+                            spanningCells.add(current.cells[i]);
+                        }
+                        cells.append(current.cells[i]);
+                    }
+                }
+            }
+            // Sort the dirty cells by paint order.
+            std::stable_sort(cells.begin(), cells.end(), compareCellPositions);
+            int size = cells.size();
+            // Paint the cells.
+            for (int i = 0; i < size; ++i)
+                paintCell(cells[i], paintInfo, tx, ty);
         }
     }
 }
@@ -1113,7 +1146,7 @@ int RenderTableSection::numColumns() const
     for (int r = 0; r < m_gridRows; ++r) {
         for (int c = result; c < table()->numEffCols(); ++c) {
             const CellStruct& cell = cellAt(r, c);
-            if (cell.cell || cell.inColSpan)
+            if (cell.hasCells() || cell.inColSpan)
                 result = c;
         }
     }
@@ -1126,21 +1159,31 @@ void RenderTableSection::appendColumn(int pos)
     for (int row = 0; row < m_gridRows; ++row) {
         m_grid[row].row->resize(pos + 1);
         CellStruct& c = cellAt(row, pos);
-        c.cell = 0;
         c.inColSpan = false;
+        c.empty = false;
     }
 }
 
-void RenderTableSection::splitColumn(int pos, int newSize)
+void RenderTableSection::splitColumn(int pos, int first)
 {
     if (m_cCol > pos)
         m_cCol++;
     for (int row = 0; row < m_gridRows; ++row) {
-        m_grid[row].row->resize(newSize);
         Row& r = *m_grid[row].row;
-        memmove(r.data() + pos + 1, r.data() + pos, (newSize - 1 - pos) * sizeof(CellStruct));
-        r[pos + 1].cell = 0;
-        r[pos + 1].inColSpan = r[pos].inColSpan || r[pos].cell;
+        r.insert(pos + 1, CellStruct());
+        if (r[pos].hasCells()) {
+            r[pos + 1].cells.append(r[pos].cells);
+            RenderTableCell* cell = r[pos].primaryCell();
+            ASSERT(cell);
+            int colleft = cell->colSpan() - r[pos].inColSpan;
+            if (first > colleft)
+              r[pos + 1].inColSpan = 0;
+            else
+              r[pos + 1].inColSpan = first + r[pos].inColSpan;
+        } else {
+            r[pos + 1].inColSpan = 0;
+        }
+        r[pos + 1].empty = false;
     }
 }
 
@@ -1165,7 +1208,6 @@ bool RenderTableSection::nodeAtPoint(const HitTestRequest& request, HitTestResul
             return true;
         }
     }
-    
     return false;
 }
 
diff --git a/WebCore/rendering/RenderTableSection.h b/WebCore/rendering/RenderTableSection.h
index 9f6d5ea..e3c09bc 100644
--- a/WebCore/rendering/RenderTableSection.h
+++ b/WebCore/rendering/RenderTableSection.h
@@ -54,8 +54,30 @@ public:
     RenderTable* table() const { return toRenderTable(parent()); }
 
     struct CellStruct {
-        RenderTableCell* cell;
+        Vector<RenderTableCell*, 1> cells; 
         bool inColSpan; // true for columns after the first in a colspan
+        bool empty;
+
+        CellStruct():
+          inColSpan(false),
+          empty(false) {}
+
+        CellStruct(const CellStruct& other):
+            cells(other.cells),
+            inColSpan(other.inColSpan),
+            empty(other.empty) {}
+        
+        RenderTableCell* primaryCell()
+        {
+            return hasCells() ? cells[cells.size() - 1] : 0;
+        }
+
+        const RenderTableCell* primaryCell() const
+        {
+            return hasCells() ? cells[cells.size() - 1] : 0;
+        }
+
+        bool hasCells() const { return cells.size() > 0; }
     };
 
     typedef Vector<CellStruct> Row;
@@ -69,9 +91,14 @@ public:
 
     CellStruct& cellAt(int row,  int col) { return (*m_grid[row].row)[col]; }
     const CellStruct& cellAt(int row, int col) const { return (*m_grid[row].row)[col]; }
+    RenderTableCell* primaryCellAt(int row, int col)
+    {
+        CellStruct& c = (*m_grid[row].row)[col];
+        return c.primaryCell();
+    }
 
     void appendColumn(int pos);
-    void splitColumn(int pos, int newSize);
+    void splitColumn(int pos, int first);
 
     int calcOuterBorderTop() const;
     int calcOuterBorderBottom() const;
@@ -121,6 +148,7 @@ private:
     virtual int leftmostPosition(bool includeOverflowInterior, bool includeSelf) const;
 
     virtual void paint(PaintInfo&, int tx, int ty);
+    virtual void paintCell(RenderTableCell*, PaintInfo&, int tx, int ty);
     virtual void paintObject(PaintInfo&, int tx, int ty);
 
     virtual void imageChanged(WrappedImagePtr, const IntRect* = 0);
@@ -150,6 +178,8 @@ private:
 
     bool m_needsCellRecalc;
     bool m_hasOverflowingCell;
+
+    bool m_hasMultipleCellLevels;
 };
 
 inline RenderTableSection* toRenderTableSection(RenderObject* object)

-- 
WebKit Debian packaging



More information about the Pkg-webkit-commits mailing list