Title: [131671] trunk
Revision
131671
Author
[email protected]
Date
2012-10-17 17:00:55 -0700 (Wed, 17 Oct 2012)

Log Message

Incorrect rendering of borders on <col> with span > 1
https://bugs.webkit.org/show_bug.cgi?id=76246

Patch by Arpita Bahuguna <[email protected]> on 2012-10-17
Reviewed by Julien Chaffraix.

Source/WebCore:

The HTML5 rendering specification [10.2.2 - Display Types] states that
"For the purposes of the CSS table model, the col element is expected to
be treated as if it was present as many times as its span attribute
specifies."
We should thus apply a col element's border as if the element is present
as many number of times as its span attribute.

Apart from this, we should also treat the col and its enclosing colgroup
separately while computing the collapsed borders.

Test: fast/table/border-collapsing/collapsed-border-with-col-colgroup-span.html

* rendering/RenderTableCell.cpp:
(WebCore::RenderTableCell::computeCollapsedStartBorder):
(WebCore::RenderTableCell::computeCollapsedEndBorder):
Borders from col and its enclosing colgroup element should be handled
separately, while considering the preceeding col's end border (for start
border computation) and the next col's start border (for end border
computation).

Also, have made changes for handling of col elements with span attribute as
per the specification. We now apply the border (start or end) of the col
element irrespective of whether it has any span specified for it or not.

LayoutTests:

* fast/table/border-collapsing/cached-change-colgroup-border-color-expected.png:
* fast/table/border-collapsing/cached-change-colgroup-border-color-expected.txt:
* fast/table/border-collapsing/cached-change-colgroup-border-width-expected.png:
* fast/table/border-collapsing/cached-change-colgroup-border-width-expected.txt:
Existing tests modified. This is because previously, while computing collapsed
start border, we did not take the preceeding col's enclosing colgroup's end border
into consideration. While computing the collapsed start border, only the preceeding
col element's end border was considered.

With this fix, for the above two tests, the last col's width now changes due to
the border being applied to it (the preceeding col's enclosing colgroup's end border)
which causes the table's width to change. Also, we should note that the cell's grow
by half the border's width; which is expected (on account of their being collapsed
borders).

* fast/table/border-collapsing/collapsed-border-with-col-colgroup-span-expected.txt: Added.
* fast/table/border-collapsing/collapsed-border-with-col-colgroup-span.html: Added.
* platform/chromium-linux/fast/table/border-collapsing/collapsed-border-with-col-colgroup-span-expected.png: Added.
Image only test added for verifying the behavior of collapsed borders with
col and colgroup span.
New expected image file added for the chromium-linux port.

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (131670 => 131671)


--- trunk/LayoutTests/ChangeLog	2012-10-17 23:57:05 UTC (rev 131670)
+++ trunk/LayoutTests/ChangeLog	2012-10-18 00:00:55 UTC (rev 131671)
@@ -1,3 +1,32 @@
+2012-10-17  Arpita Bahuguna  <[email protected]>
+
+        Incorrect rendering of borders on <col> with span > 1
+        https://bugs.webkit.org/show_bug.cgi?id=76246
+
+        Reviewed by Julien Chaffraix.
+
+        * fast/table/border-collapsing/cached-change-colgroup-border-color-expected.png:
+        * fast/table/border-collapsing/cached-change-colgroup-border-color-expected.txt:
+        * fast/table/border-collapsing/cached-change-colgroup-border-width-expected.png:
+        * fast/table/border-collapsing/cached-change-colgroup-border-width-expected.txt:
+        Existing tests modified. This is because previously, while computing collapsed
+        start border, we did not take the preceeding col's enclosing colgroup's end border
+        into consideration. While computing the collapsed start border, only the preceeding
+        col element's end border was considered.
+
+        With this fix, for the above two tests, the last col's width now changes due to
+        the border being applied to it (the preceeding col's enclosing colgroup's end border)
+        which causes the table's width to change. Also, we should note that the cell's grow
+        by half the border's width; which is expected (on account of their being collapsed
+        borders).
+
+        * fast/table/border-collapsing/collapsed-border-with-col-colgroup-span-expected.txt: Added.
+        * fast/table/border-collapsing/collapsed-border-with-col-colgroup-span.html: Added.
+        * platform/chromium-linux/fast/table/border-collapsing/collapsed-border-with-col-colgroup-span-expected.png: Added.
+        Image only test added for verifying the behavior of collapsed borders with
+        col and colgroup span.
+        New expected image file added for the chromium-linux port.
+
 2012-10-17  Tom Sepez  <[email protected]>
 
         Crash in ContainerNode::removeAllChildren()

Modified: trunk/LayoutTests/fast/table/border-collapsing/cached-change-colgroup-border-color-expected.png


(Binary files differ)

Modified: trunk/LayoutTests/fast/table/border-collapsing/cached-change-colgroup-border-color-expected.txt (131670 => 131671)


--- trunk/LayoutTests/fast/table/border-collapsing/cached-change-colgroup-border-color-expected.txt	2012-10-17 23:57:05 UTC (rev 131670)
+++ trunk/LayoutTests/fast/table/border-collapsing/cached-change-colgroup-border-color-expected.txt	2012-10-18 00:00:55 UTC (rev 131671)
@@ -3,18 +3,18 @@
 layer at (0,0) size 800x600
   RenderBlock {HTML} at (0,0) size 800x600
     RenderBody {BODY} at (8,8) size 784x584
-      RenderTable {TABLE} at (0,0) size 164x102 [border: (1px solid #0000FF)]
+      RenderTable {TABLE} at (0,0) size 166x102 [border: (1px solid #0000FF)]
         RenderTableCol {COLGROUP} at (0,0) size 0x0 [border: (4px solid #FFFF00)]
           RenderTableCol {COL} at (0,0) size 0x0
           RenderTableCol {COL} at (0,0) size 0x0
         RenderTableCol {COLGROUP} at (0,0) size 0x0
           RenderTableCol {COL} at (0,0) size 0x0
-        RenderTableSection {TBODY} at (1,1) size 162x100
-          RenderTableRow {TR} at (0,0) size 162x50
+        RenderTableSection {TBODY} at (1,1) size 164x100
+          RenderTableRow {TR} at (0,0) size 164x50
             RenderTableCell {TD} at (0,22) size 55x5 [border: (2px solid #00FF00)] [r=0 c=0 rs=1 cs=1]
             RenderTableCell {TD} at (55,23) size 55x4 [border: (2px none #000000)] [r=0 c=1 rs=1 cs=1]
-            RenderTableCell {TD} at (110,23) size 52x3 [border: (1px none #000000)] [r=0 c=2 rs=1 cs=1]
-          RenderTableRow {TR} at (0,50) size 162x50
+            RenderTableCell {TD} at (110,23) size 54x3 [border: (1px none #000000)] [r=0 c=2 rs=1 cs=1]
+          RenderTableRow {TR} at (0,50) size 164x50
             RenderTableCell {TD} at (0,72) size 55x5 [border: (1px none #000000)] [r=1 c=0 rs=1 cs=1]
             RenderTableCell {TD} at (55,73) size 55x4 [border: none] [r=1 c=1 rs=1 cs=1]
-            RenderTableCell {TD} at (110,74) size 52x2 [r=1 c=2 rs=1 cs=1]
+            RenderTableCell {TD} at (110,74) size 54x2 [border: none] [r=1 c=2 rs=1 cs=1]

Modified: trunk/LayoutTests/fast/table/border-collapsing/cached-change-colgroup-border-width-expected.png


(Binary files differ)

Modified: trunk/LayoutTests/fast/table/border-collapsing/cached-change-colgroup-border-width-expected.txt (131670 => 131671)


--- trunk/LayoutTests/fast/table/border-collapsing/cached-change-colgroup-border-width-expected.txt	2012-10-17 23:57:05 UTC (rev 131670)
+++ trunk/LayoutTests/fast/table/border-collapsing/cached-change-colgroup-border-width-expected.txt	2012-10-18 00:00:55 UTC (rev 131671)
@@ -3,18 +3,18 @@
 layer at (0,0) size 800x600
   RenderBlock {HTML} at (0,0) size 800x600
     RenderBody {BODY} at (8,8) size 784x584
-      RenderTable {TABLE} at (0,0) size 161x102 [border: (1px solid #0000FF)]
+      RenderTable {TABLE} at (0,0) size 162x102 [border: (1px solid #0000FF)]
         RenderTableCol {COLGROUP} at (0,0) size 0x0 [border: (4px solid #FFFF00)]
           RenderTableCol {COL} at (0,0) size 0x0
           RenderTableCol {COL} at (0,0) size 0x0
         RenderTableCol {COLGROUP} at (0,0) size 0x0
           RenderTableCol {COL} at (0,0) size 0x0
-        RenderTableSection {TBODY} at (1,1) size 159x100
-          RenderTableRow {TR} at (0,0) size 159x50
+        RenderTableSection {TBODY} at (1,1) size 160x100
+          RenderTableRow {TR} at (0,0) size 160x50
             RenderTableCell {TD} at (0,22) size 53x5 [border: (2px solid #00FF00)] [r=0 c=0 rs=1 cs=1]
             RenderTableCell {TD} at (53,23) size 54x4 [border: (2px none #000000)] [r=0 c=1 rs=1 cs=1]
-            RenderTableCell {TD} at (107,23) size 52x3 [border: (1px none #000000)] [r=0 c=2 rs=1 cs=1]
-          RenderTableRow {TR} at (0,50) size 159x50
+            RenderTableCell {TD} at (107,23) size 53x3 [border: (1px none #000000)] [r=0 c=2 rs=1 cs=1]
+          RenderTableRow {TR} at (0,50) size 160x50
             RenderTableCell {TD} at (0,72) size 53x5 [border: (1px none #000000)] [r=1 c=0 rs=1 cs=1]
             RenderTableCell {TD} at (53,73) size 54x4 [border: none] [r=1 c=1 rs=1 cs=1]
-            RenderTableCell {TD} at (107,74) size 52x2 [r=1 c=2 rs=1 cs=1]
+            RenderTableCell {TD} at (107,74) size 53x2 [border: none] [r=1 c=2 rs=1 cs=1]

Added: trunk/LayoutTests/fast/table/border-collapsing/collapsed-border-with-col-colgroup-span-expected.txt (0 => 131671)


--- trunk/LayoutTests/fast/table/border-collapsing/collapsed-border-with-col-colgroup-span-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/fast/table/border-collapsing/collapsed-border-with-col-colgroup-span-expected.txt	2012-10-18 00:00:55 UTC (rev 131671)
@@ -0,0 +1 @@
+

Added: trunk/LayoutTests/fast/table/border-collapsing/collapsed-border-with-col-colgroup-span.html (0 => 131671)


--- trunk/LayoutTests/fast/table/border-collapsing/collapsed-border-with-col-colgroup-span.html	                        (rev 0)
+++ trunk/LayoutTests/fast/table/border-collapsing/collapsed-border-with-col-colgroup-span.html	2012-10-18 00:00:55 UTC (rev 131671)
@@ -0,0 +1,108 @@
+<!DOCTYPE html>
+<html>
+<style>
+table { border-collapse: collapse; padding: 5px;}
+td { width: 20px; height: 20px;}
+.bordered { border-left: 2px solid orange; border-right: 2px solid blue; border-top: 2px solid green; border-bottom: 2px solid yellow;}
+#space {height: 5px;}
+</style>
+<script>
+if (window.testRunner)
+    testRunner.dumpAsText(true);
+</script>
+<body>
+<!--Test for Bugzilla <a href="" 76246</a>:  Incorrect rendering of borders on <col> with span > 1-->
+<!--The following tests verify the border-collapse behavior on tables with span specified for col/colgroups.-->
+
+<!-- This table has a colgroup with span. Individual borders for the spanned cells should not be painted. -->
+<table>
+<colgroup></colgroup>
+<colgroup span=3 style="border: 1px solid blue;"></colgroup>
+<colgroup></colgroup>
+<tr>
+    <td></td><td></td><td></td><td></td><td></td>
+</tr>
+</table>
+<div id="space"></div>
+<!-- This table has a col with span. As per HTML5 specifications, the col element should be treated as if it was present as many number of times as its span attribute. We should thus expect the individual borders for the spanned cells to be painted for the following table. -->
+<table>
+<colgroup style="border: 1px solid yellow;" >
+<col style="border: 1px solid green;"></col>
+<col span=3 style="border: 1px solid orange;"></col>
+</colgroup>
+<colgroup style="border: 1px solid green;">
+<col style="border: 1px solid blue;"></col>
+</colgroup>
+<tr>
+    <td></td><td></td><td></td><td></td><td></td>
+</tr>
+<!-- No red colored bored should be visible for the following table. -->
+</table>
+<div id="space"></div>
+<table>
+<colgroup>
+    <col style="border-right: 1px solid red;">
+    <col span="3" class="bordered">
+    <col style="border-left: 2px solid red;">
+</colgroup>
+<tr>
+    <td></td>
+    <td></td>
+    <td></td>
+    <td></td>
+    <td></td>    
+</tr>
+<tr>
+    <td></td>
+    <td></td>
+    <td></td>
+    <td></td>
+    <td></td>    
+</tr>
+</table>
+<div id="space"></div>
+<!-- For the following table, the first border displayed should be transparent or invisible, the second in semi-transparent green color, the third in full green color and the fourth in black. No red color should be visible. This verifies the scenario when col element is present inside colgroup and we need to consider the enclosing colgroup's border. -->
+<table>
+    <colgroup style="border-right: 5px solid rgba(0, 127, 0, 0);"><col/></colgroup>
+    <colgroup style="border-left: 5px solid red;"><col/></colgroup>
+    <colgroup style="border-right: 5px solid rgba(0, 127, 0, 0.5);"><col/></colgroup>
+    <colgroup style="border-left: 5px solid red;"><col/></colgroup>
+    <colgroup style="border-right: 5px solid rgba(0, 127, 0, 1);"><col/></colgroup>
+    <colgroup style="border-left: 5px solid red;"><col/></colgroup>
+    <colgroup style="border-right: 5px solid ;"><col/></colgroup>
+    <colgroup style="border-left: 5px solid rgba(225, 0, 0, 1);"><col/></colgroup>        
+    <tr>
+        <td></td>
+        <td></td>    
+        <td></td>
+        <td></td>
+        <td></td>
+        <td></td>
+        <td></td>
+        <td></td>        
+    </tr>
+</table>
+<div id="space"></div>
+<!-- For the following table, the first border displayed should be transparent or invisible, the second in semi-transparent green color, the third in full green color and the fourth in black. No red color should be visible. This verifies the scenario when only colgroup element is present. -->
+<table>
+    <colgroup style="border-right: 5px solid rgba(0, 127, 0, 0);" />
+    <colgroup style="border-left: 5px solid red;" />
+    <colgroup style="border-right: 5px solid rgba(0, 127, 0, 0.5);" />
+    <colgroup style="border-left: 5px solid red;" />
+    <colgroup style="border-right: 5px solid rgba(0, 127, 0, 1);" />
+    <colgroup style="border-left: 5px solid red;" />
+    <colgroup style="border-right: 5px solid ;" />
+    <colgroup style="border-left: 5px solid rgba(225, 0, 0, 1);" />
+    <tr>
+        <td></td>
+        <td></td>    
+        <td></td>
+        <td></td>
+        <td></td>
+        <td></td>
+        <td></td>
+        <td></td>        
+    </tr>
+</table>
+</body>
+</html>

Copied: trunk/LayoutTests/platform/chromium-linux/fast/table/border-collapsing/collapsed-border-with-col-colgroup-span-expected.png (from rev 131670, trunk/LayoutTests/fast/table/border-collapsing/cached-change-colgroup-border-color-expected.png)


(Binary files differ)

Modified: trunk/Source/WebCore/ChangeLog (131670 => 131671)


--- trunk/Source/WebCore/ChangeLog	2012-10-17 23:57:05 UTC (rev 131670)
+++ trunk/Source/WebCore/ChangeLog	2012-10-18 00:00:55 UTC (rev 131671)
@@ -1,3 +1,34 @@
+2012-10-17  Arpita Bahuguna  <[email protected]>
+
+        Incorrect rendering of borders on <col> with span > 1
+        https://bugs.webkit.org/show_bug.cgi?id=76246
+
+        Reviewed by Julien Chaffraix.
+
+        The HTML5 rendering specification [10.2.2 - Display Types] states that
+        "For the purposes of the CSS table model, the col element is expected to
+        be treated as if it was present as many times as its span attribute
+        specifies."
+        We should thus apply a col element's border as if the element is present
+        as many number of times as its span attribute.
+
+        Apart from this, we should also treat the col and its enclosing colgroup
+        separately while computing the collapsed borders.
+
+        Test: fast/table/border-collapsing/collapsed-border-with-col-colgroup-span.html
+
+        * rendering/RenderTableCell.cpp:
+        (WebCore::RenderTableCell::computeCollapsedStartBorder):
+        (WebCore::RenderTableCell::computeCollapsedEndBorder):
+        Borders from col and its enclosing colgroup element should be handled
+        separately, while considering the preceeding col's end border (for start
+        border computation) and the next col's start border (for end border
+        computation).
+
+        Also, have made changes for handling of col elements with span attribute as
+        per the specification. We now apply the border (start or end) of the col
+        element irrespective of whether it has any span specified for it or not.
+
 2012-10-17  Tom Sepez  <[email protected]>
 
         Crash in ContainerNode::removeAllChildren()

Modified: trunk/Source/WebCore/rendering/RenderTableCell.cpp (131670 => 131671)


--- trunk/Source/WebCore/rendering/RenderTableCell.cpp	2012-10-17 23:57:05 UTC (rev 131670)
+++ trunk/Source/WebCore/rendering/RenderTableCell.cpp	2012-10-18 00:00:55 UTC (rev 131671)
@@ -500,26 +500,49 @@
     // (5) Our column and column group's start borders.
     bool startColEdge;
     bool endColEdge;
-    RenderTableCol* colElt = table->colElement(col(), &startColEdge, &endColEdge);
-    if (colElt && startColEdge) {
-        result = chooseBorder(result, CollapsedBorderValue(colElt->borderAdjoiningCellStartBorder(this), includeColor ? colElt->style()->visitedDependentColor(startColorProperty) : Color(), BCOL));
-        if (!result.exists())
-            return result;
-        if (RenderTableCol* enclosingColumnGroup = colElt->enclosingColumnGroupIfAdjacentBefore()) {
-            result = chooseBorder(result, CollapsedBorderValue(enclosingColumnGroup->borderAdjoiningCellStartBorder(this), includeColor ? enclosingColumnGroup->style()->visitedDependentColor(startColorProperty) : Color(), BCOLGROUP));
+    if (RenderTableCol* colElt = table->colElement(col(), &startColEdge, &endColEdge)) {
+        if (colElt->isTableColumnGroup() && startColEdge) {
+            // The |colElt| is a column group and is also the first colgroup (in case of spanned colgroups).
+            result = chooseBorder(result, CollapsedBorderValue(colElt->borderAdjoiningCellStartBorder(this), includeColor ? colElt->style()->visitedDependentColor(startColorProperty) : Color(), BCOLGROUP));
             if (!result.exists())
                 return result;
+        } else if (!colElt->isTableColumnGroup()) {
+            // We first consider the |colElt| and irrespective of whether it is a spanned col or not, we apply
+            // its start border. This is as per HTML5 which states that: "For the purposes of the CSS table model,
+            // the col element is expected to be treated as if it was present as many times as its span attribute specifies".
+            result = chooseBorder(result, CollapsedBorderValue(colElt->borderAdjoiningCellStartBorder(this), includeColor ? colElt->style()->visitedDependentColor(startColorProperty) : Color(), BCOL));
+            if (!result.exists())
+                return result;
+            // Next, apply the start border of the enclosing colgroup but only if it is adjacent to the cell's edge.
+            if (RenderTableCol* enclosingColumnGroup = colElt->enclosingColumnGroupIfAdjacentBefore()) {
+                result = chooseBorder(result, CollapsedBorderValue(enclosingColumnGroup->borderAdjoiningCellStartBorder(this), includeColor ? enclosingColumnGroup->style()->visitedDependentColor(startColorProperty) : Color(), BCOLGROUP));
+                if (!result.exists())
+                    return result;
+            }
         }
     }
     
     // (6) The end border of the preceding column.
     if (cellBefore) {
-        colElt = table->colElement(col() -1, &startColEdge, &endColEdge);
-        if (colElt && endColEdge) {
-            CollapsedBorderValue columnBeforeAdjoiningBorder = CollapsedBorderValue(colElt->borderAdjoiningCellAfter(this), includeColor ? colElt->style()->visitedDependentColor(endColorProperty) : Color(), BCOL);
-            result = chooseBorder(columnBeforeAdjoiningBorder, result);
-            if (!result.exists())
-                return result;
+        if (RenderTableCol* colElt = table->colElement(col() - 1, &startColEdge, &endColEdge)) {
+            if (colElt->isTableColumnGroup() && endColEdge) {
+                // The element is a colgroup and is also the last colgroup (in case of spanned colgroups).
+                result = chooseBorder(CollapsedBorderValue(colElt->borderAdjoiningCellAfter(this), includeColor ? colElt->style()->visitedDependentColor(endColorProperty) : Color(), BCOLGROUP), result);
+                if (!result.exists())
+                    return result;
+            } else if (colElt->isTableColumn()) {
+                // Resolve the collapsing border against the col's border ignoring any 'span' as per HTML5.
+                result = chooseBorder(CollapsedBorderValue(colElt->borderAdjoiningCellAfter(this), includeColor ? colElt->style()->visitedDependentColor(endColorProperty) : Color(), BCOL), result);
+                if (!result.exists())
+                    return result;
+                // Next, if the previous col has a parent colgroup then its end border should be applied
+                // but only if it is adjacent to the cell's edge.
+                if (RenderTableCol* enclosingColumnGroup = colElt->enclosingColumnGroupIfAdjacentAfter()) {
+                    result = chooseBorder(CollapsedBorderValue(enclosingColumnGroup->borderAdjoiningCellEndBorder(this), includeColor ? enclosingColumnGroup->style()->visitedDependentColor(endColorProperty) : Color(), BCOLGROUP), result);
+                    if (!result.exists())
+                        return result;
+                }
+            }
         }
     } else {
         // (7) The table's start border.
@@ -575,26 +598,48 @@
     // (5) Our column and column group's end borders.
     bool startColEdge;
     bool endColEdge;
-    RenderTableCol* colElt = table->colElement(col() + colSpan() - 1, &startColEdge, &endColEdge);
-    if (colElt && endColEdge) {
-        result = chooseBorder(result, CollapsedBorderValue(colElt->borderAdjoiningCellEndBorder(this), includeColor ? colElt->style()->visitedDependentColor(endColorProperty) : Color(), BCOL));
-        if (!result.exists())
-            return result;
-        if (RenderTableCol* enclosingColumnGroup = colElt->enclosingColumnGroupIfAdjacentAfter()) {
-            result = chooseBorder(result, CollapsedBorderValue(enclosingColumnGroup->borderAdjoiningCellEndBorder(this), includeColor ? enclosingColumnGroup->style()->visitedDependentColor(endColorProperty) : Color(), BCOLGROUP));
+    if (RenderTableCol* colElt = table->colElement(col() + colSpan() - 1, &startColEdge, &endColEdge)) {
+        if (colElt->isTableColumnGroup() && endColEdge) {
+            // The element is a colgroup and is also the last colgroup (in case of spanned colgroups).
+            result = chooseBorder(result, CollapsedBorderValue(colElt->borderAdjoiningCellEndBorder(this), includeColor ? colElt->style()->visitedDependentColor(endColorProperty) : Color(), BCOLGROUP));
             if (!result.exists())
                 return result;
+        } else if (!colElt->isTableColumnGroup()) {
+            // First apply the end border of the column irrespective of whether it is spanned or not. This is as per
+            // HTML5 which states that: "For the purposes of the CSS table model, the col element is expected to be
+            // treated as if it was present as many times as its span attribute specifies".
+            result = chooseBorder(result, CollapsedBorderValue(colElt->borderAdjoiningCellEndBorder(this), includeColor ? colElt->style()->visitedDependentColor(endColorProperty) : Color(), BCOL));
+            if (!result.exists())
+                return result;
+            // Next, if it has a parent colgroup then we apply its end border but only if it is adjacent to the cell.
+            if (RenderTableCol* enclosingColumnGroup = colElt->enclosingColumnGroupIfAdjacentAfter()) {
+                result = chooseBorder(result, CollapsedBorderValue(enclosingColumnGroup->borderAdjoiningCellEndBorder(this), includeColor ? enclosingColumnGroup->style()->visitedDependentColor(endColorProperty) : Color(), BCOLGROUP));
+                if (!result.exists())
+                    return result;
+            }
         }
     }
     
     // (6) The start border of the next column.
     if (!isEndColumn) {
-        colElt = table->colElement(col() + colSpan(), &startColEdge, &endColEdge);
-        if (colElt && startColEdge) {
-            CollapsedBorderValue columnAfterAdjoiningBorder = CollapsedBorderValue(colElt->borderAdjoiningCellBefore(this), includeColor ? colElt->style()->visitedDependentColor(startColorProperty) : Color(), BCOL);
-            result = chooseBorder(result, columnAfterAdjoiningBorder);
-            if (!result.exists())
-                return result;
+        if (RenderTableCol* colElt = table->colElement(col() + colSpan(), &startColEdge, &endColEdge)) {
+            if (colElt->isTableColumnGroup() && startColEdge) {
+                // This case is a colgroup without any col, we only compute it if it is adjacent to the cell's edge.
+                result = chooseBorder(result, CollapsedBorderValue(colElt->borderAdjoiningCellBefore(this), includeColor ? colElt->style()->visitedDependentColor(startColorProperty) : Color(), BCOLGROUP));
+                if (!result.exists())
+                    return result;
+            } else if (colElt->isTableColumn()) {
+                // Resolve the collapsing border against the col's border ignoring any 'span' as per HTML5.
+                result = chooseBorder(result, CollapsedBorderValue(colElt->borderAdjoiningCellBefore(this), includeColor ? colElt->style()->visitedDependentColor(startColorProperty) : Color(), BCOL));
+                if (!result.exists())
+                    return result;
+                // If we have a parent colgroup, resolve the border only if it is adjacent to the cell.
+                if (RenderTableCol* enclosingColumnGroup = colElt->enclosingColumnGroupIfAdjacentBefore()) {
+                    result = chooseBorder(result, CollapsedBorderValue(enclosingColumnGroup->borderAdjoiningCellStartBorder(this), includeColor ? enclosingColumnGroup->style()->visitedDependentColor(startColorProperty) : Color(), BCOLGROUP));
+                    if (!result.exists())
+                        return result;
+                }
+            }
         }
     } else {
         // (7) The table's end border.
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to