Title: [157579] trunk
Revision
157579
Author
rob...@webkit.org
Date
2013-10-17 10:44:20 -0700 (Thu, 17 Oct 2013)

Log Message

"border-collapse: collapse;" for table removes part of its border (was: Border disappears when close to some elements)
https://bugs.webkit.org/show_bug.cgi?id=8914

Reviewed by David Hyatt.

Source/WebCore:

The table section's side of a collapsed border won't get painted if there are no cells there to paint it. So instead
of relying solely on cells to paint the collapsed border paint the appropriate section of the border if there's no
cell to take care of it.

Tests: fast/table/paint-section-borders-without-cells-rtl.html
       fast/table/paint-section-borders-without-cells-vertical-lr-rtl.html
       fast/table/paint-section-borders-without-cells-vertical-lr.html
       fast/table/paint-section-borders-without-cells-vertical-rl.html
       fast/table/paint-section-borders-without-cells.html

* rendering/RenderTableSection.cpp:
(WebCore::RenderTableSection::paintRowGroupBorder):
(WebCore::RenderTableSection::offsetLeftForRowGroupBorder):
(WebCore::RenderTableSection::offsetTopForRowGroupBorder):
(WebCore::RenderTableSection::verticalRowGroupBorderHeight):
(WebCore::RenderTableSection::horizontalRowGroupBorderWidth):
(WebCore::RenderTableSection::paintRowGroupBorderIfRequired):
(WebCore::physicalBorderForDirection):
(WebCore::RenderTableSection::paintObject):
* rendering/RenderTableSection.h:

LayoutTests:

* fast/table/paint-section-borders-without-cells-expected.html: Added.
* fast/table/paint-section-borders-without-cells-rtl-expected.html: Added.
* fast/table/paint-section-borders-without-cells-rtl.html: Added.
* fast/table/paint-section-borders-without-cells-vertical-lr-expected.html: Added.
* fast/table/paint-section-borders-without-cells-vertical-lr-rtl-expected.html: Added.
* fast/table/paint-section-borders-without-cells-vertical-lr-rtl.html: Added.
* fast/table/paint-section-borders-without-cells-vertical-lr.html: Added.
* fast/table/paint-section-borders-without-cells-vertical-rl-expected.html: Added.
* fast/table/paint-section-borders-without-cells-vertical-rl.html: Added.
* fast/table/paint-section-borders-without-cells.html: Added.

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (157578 => 157579)


--- trunk/LayoutTests/ChangeLog	2013-10-17 16:57:47 UTC (rev 157578)
+++ trunk/LayoutTests/ChangeLog	2013-10-17 17:44:20 UTC (rev 157579)
@@ -1,3 +1,21 @@
+2013-10-17  Robert Hogan  <rob...@webkit.org>
+
+        "border-collapse: collapse;" for table removes part of its border (was: Border disappears when close to some elements)
+        https://bugs.webkit.org/show_bug.cgi?id=8914
+
+        Reviewed by David Hyatt.
+
+        * fast/table/paint-section-borders-without-cells-expected.html: Added.
+        * fast/table/paint-section-borders-without-cells-rtl-expected.html: Added.
+        * fast/table/paint-section-borders-without-cells-rtl.html: Added.
+        * fast/table/paint-section-borders-without-cells-vertical-lr-expected.html: Added.
+        * fast/table/paint-section-borders-without-cells-vertical-lr-rtl-expected.html: Added.
+        * fast/table/paint-section-borders-without-cells-vertical-lr-rtl.html: Added.
+        * fast/table/paint-section-borders-without-cells-vertical-lr.html: Added.
+        * fast/table/paint-section-borders-without-cells-vertical-rl-expected.html: Added.
+        * fast/table/paint-section-borders-without-cells-vertical-rl.html: Added.
+        * fast/table/paint-section-borders-without-cells.html: Added.
+
 2013-10-17  Andres Gomez  <ago...@igalia.com>
 
         certain http media tests doesn't receive the expected "Content-Length" header

Added: trunk/LayoutTests/fast/table/paint-section-borders-without-cells-expected.html (0 => 157579)


--- trunk/LayoutTests/fast/table/paint-section-borders-without-cells-expected.html	                        (rev 0)
+++ trunk/LayoutTests/fast/table/paint-section-borders-without-cells-expected.html	2013-10-17 17:44:20 UTC (rev 157579)
@@ -0,0 +1,39 @@
+<!doctype html>
+<head>
+<style>
+table  {
+    border: solid 20px red; 
+    border-collapse: collapse;
+}
+#tbody1  {
+    border: solid 20px rgba(0,0,255,0.5); 
+}
+td  {
+    height: 20px;
+    width: 20px;
+}
+</style>
+</head>
+<body>
+<table>
+    <p> webkit.org/b/8914: Paint collapsed section borders even when the sections don't contain cells.
+	<tbody id="tbody1">
+        <tr>
+            <td></td>
+            <td></td>
+            <td></td>
+        </tr>
+        <tr>
+            <td></td>
+            <td></td>
+            <td></td>
+        </tr>
+        <tr>
+            <td></td>
+            <td></td>
+            <td></td>
+        </tr>
+    </tbody>
+</table>
+</body
+</html>

Added: trunk/LayoutTests/fast/table/paint-section-borders-without-cells-rtl-expected.html (0 => 157579)


--- trunk/LayoutTests/fast/table/paint-section-borders-without-cells-rtl-expected.html	                        (rev 0)
+++ trunk/LayoutTests/fast/table/paint-section-borders-without-cells-rtl-expected.html	2013-10-17 17:44:20 UTC (rev 157579)
@@ -0,0 +1,35 @@
+<!doctype html>
+<head>
+<style>
+table  {
+    border: solid 20px red; 
+    border-collapse: collapse;
+}
+#tbody1  {
+    border: solid 20px rgba(0,0,255,0.5); 
+}
+td  {
+    height: 20px;
+    width: 20px;
+}
+</style>
+</head>
+<body>
+<table>
+    <p> webkit.org/b/8914: Paint collapsed section borders even when the sections don't contain cells.
+	<tbody id="tbody1">
+        <tr>
+            <td></td>
+        </tr>
+        <tr>
+            <td></td>
+            <td></td>
+            <td></td>
+        </tr>
+        <tr>
+            <td></td>
+        </tr>
+    </tbody>
+</table>
+</body
+</html>

Added: trunk/LayoutTests/fast/table/paint-section-borders-without-cells-rtl.html (0 => 157579)


--- trunk/LayoutTests/fast/table/paint-section-borders-without-cells-rtl.html	                        (rev 0)
+++ trunk/LayoutTests/fast/table/paint-section-borders-without-cells-rtl.html	2013-10-17 17:44:20 UTC (rev 157579)
@@ -0,0 +1,36 @@
+<!doctype html>
+<head>
+<style>
+table  {
+    border: solid 20px red; 
+    border-collapse: collapse;
+    direction: rtl;
+}
+#tbody1  {
+    border: solid 20px rgba(0,0,255,0.5); 
+}
+td  {
+    height: 20px;
+    width: 20px;
+}
+</style>
+</head>
+<body>
+<table>
+    <p> webkit.org/b/8914: Paint collapsed section borders even when the sections don't contain cells.
+	<tbody id="tbody1">
+        <tr>
+            <td></td>
+        </tr>
+        <tr>
+            <td></td>
+            <td></td>
+            <td></td>
+        </tr>
+        <tr>
+            <td></td>
+        </tr>
+    </tbody>
+</table>
+</body
+</html>

Added: trunk/LayoutTests/fast/table/paint-section-borders-without-cells-vertical-lr-expected.html (0 => 157579)


--- trunk/LayoutTests/fast/table/paint-section-borders-without-cells-vertical-lr-expected.html	                        (rev 0)
+++ trunk/LayoutTests/fast/table/paint-section-borders-without-cells-vertical-lr-expected.html	2013-10-17 17:44:20 UTC (rev 157579)
@@ -0,0 +1,35 @@
+<!doctype html>
+<head>
+<style>
+table  {
+    border: solid 20px red; 
+    border-collapse: collapse;
+}
+#tbody1  {
+    border: solid 20px rgba(0,0,255,0.5); 
+}
+td  {
+    height: 20px;
+    width: 20px;
+}
+</style>
+</head>
+<body>
+<table>
+    <p> webkit.org/b/8914: Paint collapsed section borders even when the sections don't contain cells.
+	<tbody id="tbody1">
+        <tr>
+            <td></td>
+        </tr>
+        <tr>
+            <td></td>
+            <td></td>
+            <td></td>
+        </tr>
+        <tr>
+            <td></td>
+        </tr>
+    </tbody>
+</table>
+</body
+</html>

Added: trunk/LayoutTests/fast/table/paint-section-borders-without-cells-vertical-lr-rtl-expected.html (0 => 157579)


--- trunk/LayoutTests/fast/table/paint-section-borders-without-cells-vertical-lr-rtl-expected.html	                        (rev 0)
+++ trunk/LayoutTests/fast/table/paint-section-borders-without-cells-vertical-lr-rtl-expected.html	2013-10-17 17:44:20 UTC (rev 157579)
@@ -0,0 +1,35 @@
+<!doctype html>
+<head>
+<style>
+table  {
+    border: solid 20px red; 
+    border-collapse: collapse;
+}
+#tbody1  {
+    border: solid 20px rgba(0,0,255,0.5); 
+}
+td  {
+    height: 20px;
+    width: 20px;
+}
+</style>
+</head>
+<body>
+<table>
+    <p> webkit.org/b/8914: Paint collapsed section borders even when the sections don't contain cells.
+	<tbody id="tbody1">
+        <tr>
+            <td></td>
+        </tr>
+        <tr>
+            <td></td>
+            <td></td>
+            <td></td>
+        </tr>
+        <tr>
+            <td></td>
+        </tr>
+    </tbody>
+</table>
+</body
+</html>

Added: trunk/LayoutTests/fast/table/paint-section-borders-without-cells-vertical-lr-rtl.html (0 => 157579)


--- trunk/LayoutTests/fast/table/paint-section-borders-without-cells-vertical-lr-rtl.html	                        (rev 0)
+++ trunk/LayoutTests/fast/table/paint-section-borders-without-cells-vertical-lr-rtl.html	2013-10-17 17:44:20 UTC (rev 157579)
@@ -0,0 +1,35 @@
+<!doctype html>
+<head>
+<style>
+table  {
+    border: solid 20px red; 
+    border-collapse: collapse;
+}
+#tbody1  {
+    border: solid 20px rgba(0,0,255,0.5); 
+}
+td  {
+    height: 20px;
+    width: 20px;
+}
+</style>
+</head>
+<body>
+<table>
+    <p> webkit.org/b/8914: Paint collapsed section borders even when the sections don't contain cells.
+	<tbody id="tbody1">
+        <tr>
+            <td></td>
+        </tr>
+        <tr>
+            <td></td>
+            <td></td>
+            <td></td>
+        </tr>
+        <tr>
+            <td></td>
+        </tr>
+    </tbody>
+</table>
+</body
+</html>

Added: trunk/LayoutTests/fast/table/paint-section-borders-without-cells-vertical-lr.html (0 => 157579)


--- trunk/LayoutTests/fast/table/paint-section-borders-without-cells-vertical-lr.html	                        (rev 0)
+++ trunk/LayoutTests/fast/table/paint-section-borders-without-cells-vertical-lr.html	2013-10-17 17:44:20 UTC (rev 157579)
@@ -0,0 +1,36 @@
+<!doctype html>
+<head>
+<style>
+table  {
+    border: solid 20px red; 
+    border-collapse: collapse;
+    -webkit-writing-mode: vertical-lr;
+}
+#tbody1  {
+    border: solid 20px rgba(0,0,255,0.5); 
+}
+td  {
+    height: 20px;
+    width: 20px;
+}
+</style>
+</head>
+<body>
+<table>
+    <p> webkit.org/b/8914: Paint collapsed section borders even when the sections don't contain cells.
+	<tbody id="tbody1">
+        <tr>
+            <td></td>
+        </tr>
+        <tr>
+            <td></td>
+            <td></td>
+            <td></td>
+        </tr>
+        <tr>
+            <td></td>
+        </tr>
+    </tbody>
+</table>
+</body
+</html>

Added: trunk/LayoutTests/fast/table/paint-section-borders-without-cells-vertical-rl-expected.html (0 => 157579)


--- trunk/LayoutTests/fast/table/paint-section-borders-without-cells-vertical-rl-expected.html	                        (rev 0)
+++ trunk/LayoutTests/fast/table/paint-section-borders-without-cells-vertical-rl-expected.html	2013-10-17 17:44:20 UTC (rev 157579)
@@ -0,0 +1,35 @@
+<!doctype html>
+<head>
+<style>
+table  {
+    border: solid 20px red; 
+    border-collapse: collapse;
+}
+#tbody1  {
+    border: solid 20px rgba(0,0,255,0.5); 
+}
+td  {
+    height: 20px;
+    width: 20px;
+}
+</style>
+</head>
+<body>
+<table>
+    <p> webkit.org/b/8914: Paint collapsed section borders even when the sections don't contain cells.
+	<tbody id="tbody1">
+        <tr>
+            <td></td>
+        </tr>
+        <tr>
+            <td></td>
+            <td></td>
+            <td></td>
+        </tr>
+        <tr>
+            <td></td>
+        </tr>
+    </tbody>
+</table>
+</body
+</html>

Added: trunk/LayoutTests/fast/table/paint-section-borders-without-cells-vertical-rl.html (0 => 157579)


--- trunk/LayoutTests/fast/table/paint-section-borders-without-cells-vertical-rl.html	                        (rev 0)
+++ trunk/LayoutTests/fast/table/paint-section-borders-without-cells-vertical-rl.html	2013-10-17 17:44:20 UTC (rev 157579)
@@ -0,0 +1,36 @@
+<!doctype html>
+<head>
+<style>
+table  {
+    border: solid 20px red; 
+    border-collapse: collapse;
+    -webkit-writing-mode: vertical-rl;
+}
+#tbody1  {
+    border: solid 20px rgba(0,0,255,0.5); 
+}
+td  {
+    height: 20px;
+    width: 20px;
+}
+</style>
+</head>
+<body>
+<table>
+    <p> webkit.org/b/8914: Paint collapsed section borders even when the sections don't contain cells.
+	<tbody id="tbody1">
+        <tr>
+            <td></td>
+        </tr>
+        <tr>
+            <td></td>
+            <td></td>
+            <td></td>
+        </tr>
+        <tr>
+            <td></td>
+        </tr>
+    </tbody>
+</table>
+</body
+</html>

Added: trunk/LayoutTests/fast/table/paint-section-borders-without-cells.html (0 => 157579)


--- trunk/LayoutTests/fast/table/paint-section-borders-without-cells.html	                        (rev 0)
+++ trunk/LayoutTests/fast/table/paint-section-borders-without-cells.html	2013-10-17 17:44:20 UTC (rev 157579)
@@ -0,0 +1,35 @@
+<!doctype html>
+<head>
+<style>
+table  {
+    border: solid 20px red; 
+    border-collapse: collapse;
+}
+#tbody1  {
+    border: solid 20px rgba(0,0,255,0.5); 
+}
+td  {
+    height: 20px;
+    width: 20px;
+}
+</style>
+</head>
+<body>
+<table>
+    <p> webkit.org/b/8914: Paint collapsed section borders even when the sections don't contain cells.
+	<tbody id="tbody1">
+        <tr>
+            <td></td>
+        </tr>
+        <tr>
+            <td></td>
+            <td></td>
+            <td></td>
+        </tr>
+        <tr>
+            <td></td>
+        </tr>
+    </tbody>
+</table>
+</body
+</html>

Modified: trunk/Source/WebCore/ChangeLog (157578 => 157579)


--- trunk/Source/WebCore/ChangeLog	2013-10-17 16:57:47 UTC (rev 157578)
+++ trunk/Source/WebCore/ChangeLog	2013-10-17 17:44:20 UTC (rev 157579)
@@ -1,3 +1,31 @@
+2013-10-17  Robert Hogan  <rob...@webkit.org>
+
+        "border-collapse: collapse;" for table removes part of its border (was: Border disappears when close to some elements)
+        https://bugs.webkit.org/show_bug.cgi?id=8914
+
+        Reviewed by David Hyatt.
+
+        The table section's side of a collapsed border won't get painted if there are no cells there to paint it. So instead
+        of relying solely on cells to paint the collapsed border paint the appropriate section of the border if there's no
+        cell to take care of it.
+
+        Tests: fast/table/paint-section-borders-without-cells-rtl.html
+               fast/table/paint-section-borders-without-cells-vertical-lr-rtl.html
+               fast/table/paint-section-borders-without-cells-vertical-lr.html
+               fast/table/paint-section-borders-without-cells-vertical-rl.html
+               fast/table/paint-section-borders-without-cells.html
+
+        * rendering/RenderTableSection.cpp:
+        (WebCore::RenderTableSection::paintRowGroupBorder):
+        (WebCore::RenderTableSection::offsetLeftForRowGroupBorder):
+        (WebCore::RenderTableSection::offsetTopForRowGroupBorder):
+        (WebCore::RenderTableSection::verticalRowGroupBorderHeight):
+        (WebCore::RenderTableSection::horizontalRowGroupBorderWidth):
+        (WebCore::RenderTableSection::paintRowGroupBorderIfRequired):
+        (WebCore::physicalBorderForDirection):
+        (WebCore::RenderTableSection::paintObject):
+        * rendering/RenderTableSection.h:
+
 2013-10-17  Andreas Kling  <akl...@apple.com>
 
         StyleRuleFoo::mutableProperties() should return a reference.

Modified: trunk/Source/WebCore/rendering/RenderTableSection.cpp (157578 => 157579)


--- trunk/Source/WebCore/rendering/RenderTableSection.cpp	2013-10-17 16:57:47 UTC (rev 157578)
+++ trunk/Source/WebCore/rendering/RenderTableSection.cpp	2013-10-17 17:44:20 UTC (rev 157579)
@@ -1114,7 +1114,119 @@
     return CellSpan(startColumn, endColumn);
 }
 
+void RenderTableSection::paintRowGroupBorder(const PaintInfo& paintInfo, bool antialias, LayoutRect rect, BoxSide side, CSSPropertyID borderColor, EBorderStyle borderStyle, EBorderStyle tableBorderStyle)
+{
+    if (tableBorderStyle == BHIDDEN)
+        return;
+    rect.intersect(paintInfo.rect);
+    if (rect.isEmpty())
+        return;
+    drawLineForBoxSide(paintInfo.context, rect.x(), rect.y(), rect.x() + rect.width(), rect.y() + rect.height(), side, style()->visitedDependentColor(borderColor), borderStyle, 0, 0, antialias);
+}
 
+int RenderTableSection::offsetLeftForRowGroupBorder(RenderTableCell* cell, const LayoutRect& rowGroupRect, unsigned row)
+{
+    if (style()->isHorizontalWritingMode()) {
+        if (style()->isLeftToRightDirection())
+            return cell ? cell->x().toInt() + cell->width().toInt() : 0; 
+        return -outerBorderLeft(style());
+    }
+    bool isLastRow = row + 1 == m_grid.size();
+    return rowGroupRect.width().toInt() - m_rowPos[row + 1] + (isLastRow ? -outerBorderLeft(style()) : 0);
+}
+
+int RenderTableSection::offsetTopForRowGroupBorder(RenderTableCell* cell, BoxSide borderSide, unsigned row)
+{
+    bool isLastRow = row + 1 == m_grid.size();
+    if (style()->isHorizontalWritingMode())
+        return m_rowPos[row] + (!row && borderSide == BSRight ? -outerBorderTop(style()) : isLastRow && borderSide == BSLeft ? outerBorderTop(style()) : 0);
+    if (style()->isLeftToRightDirection())
+        return (cell ? cell->y().toInt() + cell->height().toInt() : 0) + (borderSide == BSLeft ? outerBorderTop(style()) : 0);
+    return borderSide == BSRight ? -outerBorderTop(style()) : 0;
+}
+
+int RenderTableSection::verticalRowGroupBorderHeight(RenderTableCell* cell, const LayoutRect& rowGroupRect, unsigned row)
+{
+    bool isLastRow = row + 1 == m_grid.size();
+    if (style()->isHorizontalWritingMode())
+        return m_rowPos[row + 1] - m_rowPos[row] + (!row ? outerBorderTop(style()) : isLastRow ? outerBorderBottom(style()) : 0);
+    if (style()->isLeftToRightDirection())
+        return rowGroupRect.height().toInt() - (cell ? cell->y().toInt() + cell->height().toInt() : 0) + outerBorderBottom(style());
+    return cell ? rowGroupRect.height().toInt() - (cell->y().toInt() - cell->height().toInt()) : 0;
+}
+
+int RenderTableSection::horizontalRowGroupBorderWidth(RenderTableCell* cell, const LayoutRect& rowGroupRect, unsigned row, unsigned column)
+{
+    if (style()->isHorizontalWritingMode()) {
+        if (style()->isLeftToRightDirection())
+            return rowGroupRect.width().toInt() - (cell ? cell->x().toInt() + cell->width().toInt() : 0) + (!column ? outerBorderLeft(style()) : column == table()->numEffCols() ? outerBorderRight(style()) : 0);
+        return cell ? rowGroupRect.width().toInt() - (cell->x().toInt() - cell->width().toInt()) : 0;
+    }
+    bool isLastRow = row + 1 == m_grid.size();
+    return m_rowPos[row + 1] - m_rowPos[row] + (isLastRow ? outerBorderLeft(style()) : !row ? outerBorderRight(style()) : 0);
+}
+
+void RenderTableSection::paintRowGroupBorderIfRequired(const PaintInfo& paintInfo, const LayoutPoint& paintOffset, unsigned row, unsigned column, BoxSide borderSide, RenderTableCell* cell)
+{
+    if (table()->currentBorderValue()->precedence() > BROWGROUP)
+        return;
+    if (paintInfo.context->paintingDisabled())
+        return;
+
+    RenderStyle* style = this->style();
+    bool antialias = shouldAntialiasLines(paintInfo.context);
+    LayoutRect rowGroupRect = LayoutRect(paintOffset, size());
+    rowGroupRect.moveBy(-LayoutPoint(outerBorderLeft(style), (borderSide == BSRight) ? 0 : outerBorderTop(style)));
+
+    switch (borderSide) {
+    case BSTop:
+        paintRowGroupBorder(paintInfo, antialias, LayoutRect(paintOffset.x() + offsetLeftForRowGroupBorder(cell, rowGroupRect, row), rowGroupRect.y(), 
+            horizontalRowGroupBorderWidth(cell, rowGroupRect, row, column), style->borderTop().width()), BSTop, CSSPropertyBorderTopColor, style->borderTopStyle(), table()->style()->borderTopStyle());
+        break;
+    case BSBottom:
+        paintRowGroupBorder(paintInfo, antialias, LayoutRect(paintOffset.x() + offsetLeftForRowGroupBorder(cell, rowGroupRect, row), rowGroupRect.y() + rowGroupRect.height(), 
+            horizontalRowGroupBorderWidth(cell, rowGroupRect, row, column), style->borderBottom().width()), BSBottom, CSSPropertyBorderBottomColor, style->borderBottomStyle(), table()->style()->borderBottomStyle());
+        break;
+    case BSLeft:
+        paintRowGroupBorder(paintInfo, antialias, LayoutRect(rowGroupRect.x(), rowGroupRect.y() + offsetTopForRowGroupBorder(cell, borderSide, row), style->borderLeft().width(), 
+            verticalRowGroupBorderHeight(cell, rowGroupRect, row)), BSLeft, CSSPropertyBorderLeftColor, style->borderLeftStyle(), table()->style()->borderLeftStyle());
+        break;
+    case BSRight:
+        paintRowGroupBorder(paintInfo, antialias, LayoutRect(rowGroupRect.x() + rowGroupRect.width(), rowGroupRect.y() + offsetTopForRowGroupBorder(cell, borderSide, row), style->borderRight().width(), 
+            verticalRowGroupBorderHeight(cell, rowGroupRect, row)), BSRight, CSSPropertyBorderRightColor, style->borderRightStyle(), table()->style()->borderRightStyle());
+        break;
+    default:
+        break;
+    }
+
+}
+
+static BoxSide physicalBorderForDirection(RenderStyle* styleForCellFlow, CollapsedBorderSide side)
+{
+
+    switch (side) {
+    case CBSStart:
+        if (styleForCellFlow->isHorizontalWritingMode())
+            return styleForCellFlow->isLeftToRightDirection() ? BSLeft : BSRight;
+        return styleForCellFlow->isLeftToRightDirection() ? BSTop : BSBottom;
+    case CBSEnd:
+        if (styleForCellFlow->isHorizontalWritingMode())
+            return styleForCellFlow->isLeftToRightDirection() ? BSRight : BSLeft;
+        return styleForCellFlow->isLeftToRightDirection() ? BSBottom : BSTop;
+    case CBSBefore:
+        if (styleForCellFlow->isHorizontalWritingMode())
+            return BSTop;
+        return styleForCellFlow->isLeftToRightDirection() ? BSRight : BSLeft;
+    case CBSAfter:
+        if (styleForCellFlow->isHorizontalWritingMode())
+            return BSBottom;
+        return styleForCellFlow->isLeftToRightDirection() ? BSLeft : BSRight;
+    default:
+        ASSERT_NOT_REACHED();
+        return BSLeft;
+    }
+}
+
 void RenderTableSection::paintObject(PaintInfo& paintInfo, const LayoutPoint& paintOffset)
 {
     PaintPhase paintPhase = paintInfo.phase;
@@ -1137,12 +1249,32 @@
                 unsigned startRow = dirtiedRows.start() ? dirtiedRows.start() - 1 : 0;
                 for (unsigned r = dirtiedRows.end(); r > startRow; r--) {
                     unsigned row = r - 1;
+                    bool shouldPaintRowGroupBorder = false;
                     for (unsigned c = dirtiedColumns.end(); c > dirtiedColumns.start(); c--) {
                         unsigned col = c - 1;
                         CellStruct& current = cellAt(row, col);
                         RenderTableCell* cell = current.primaryCell();
-                        if (!cell || (row > dirtiedRows.start() && primaryCellAt(row - 1, col) == cell) || (col > dirtiedColumns.start() && primaryCellAt(row, col - 1) == cell))
+                        if (!cell) {
+                            if (!c)
+                                paintRowGroupBorderIfRequired(paintInfo, paintOffset, row, col, physicalBorderForDirection(style(), CBSStart));
+                            else if (c == table()->numEffCols())
+                                paintRowGroupBorderIfRequired(paintInfo, paintOffset, row, col, physicalBorderForDirection(style(), CBSEnd));
+                            shouldPaintRowGroupBorder = true;
                             continue;
+                        }
+                        if ((row > dirtiedRows.start() && primaryCellAt(row - 1, col) == cell) || (col > dirtiedColumns.start() && primaryCellAt(row, col - 1) == cell))
+                            continue;
+                        
+                        // If we had a run of null cells paint their corresponding section of the row group's border if necessary. Note that
+                        // this will only happen once within a row as the null cells will always be clustered together on one end of the row.
+                        if (shouldPaintRowGroupBorder) {
+                            if (r == m_grid.size())
+                                paintRowGroupBorderIfRequired(paintInfo, paintOffset, row, col, physicalBorderForDirection(style(), CBSAfter), cell);
+                            else if (!row && !table()->sectionAbove(this))
+                                paintRowGroupBorderIfRequired(paintInfo, paintOffset, row, col, physicalBorderForDirection(style(), CBSBefore), cell);
+                            shouldPaintRowGroupBorder = false;
+                        }
+
                         LayoutPoint cellPoint = flipForWritingModeForChild(cell, paintOffset);
                         cell->paintCollapsedBorders(paintInfo, cellPoint);
                     }

Modified: trunk/Source/WebCore/rendering/RenderTableSection.h (157578 => 157579)


--- trunk/Source/WebCore/rendering/RenderTableSection.h	2013-10-17 16:57:47 UTC (rev 157578)
+++ trunk/Source/WebCore/rendering/RenderTableSection.h	2013-10-17 17:44:20 UTC (rev 157579)
@@ -166,6 +166,34 @@
     int outerBorderStart() const { return m_outerBorderStart; }
     int outerBorderEnd() const { return m_outerBorderEnd; }
 
+    int outerBorderLeft(const RenderStyle* styleForCellFlow) const
+    {
+    if (styleForCellFlow->isHorizontalWritingMode())
+        return styleForCellFlow->isLeftToRightDirection() ? outerBorderStart() : outerBorderEnd();
+    return styleForCellFlow->isFlippedBlocksWritingMode() ? outerBorderAfter() : outerBorderBefore();
+    }
+
+    int outerBorderRight(const RenderStyle* styleForCellFlow) const
+    {
+    if (styleForCellFlow->isHorizontalWritingMode())
+        return styleForCellFlow->isLeftToRightDirection() ? outerBorderEnd() : outerBorderStart();
+    return styleForCellFlow->isFlippedBlocksWritingMode() ? outerBorderBefore() : outerBorderAfter();
+    }
+
+    int outerBorderTop(const RenderStyle* styleForCellFlow) const
+    {
+    if (styleForCellFlow->isHorizontalWritingMode())
+        return styleForCellFlow->isFlippedBlocksWritingMode() ? outerBorderAfter() : outerBorderBefore();
+    return styleForCellFlow->isLeftToRightDirection() ? outerBorderStart() : outerBorderEnd();
+    }
+
+    int outerBorderBottom(const RenderStyle* styleForCellFlow) const
+    {
+    if (styleForCellFlow->isHorizontalWritingMode())
+        return styleForCellFlow->isFlippedBlocksWritingMode() ? outerBorderBefore() : outerBorderAfter();
+    return styleForCellFlow->isLeftToRightDirection() ? outerBorderEnd() : outerBorderStart();
+    }
+
     unsigned numRows() const { return m_grid.size(); }
     unsigned numColumns() const;
     void recalcCells();
@@ -214,7 +242,14 @@
 
     void paintCell(RenderTableCell*, PaintInfo&, const LayoutPoint&);
     virtual void paintObject(PaintInfo&, const LayoutPoint&) OVERRIDE;
+    void paintRowGroupBorder(const PaintInfo&, bool antialias, LayoutRect, BoxSide, CSSPropertyID borderColor, EBorderStyle, EBorderStyle tableBorderStyle);
+    void paintRowGroupBorderIfRequired(const PaintInfo&, const LayoutPoint& paintOffset, unsigned row, unsigned col, BoxSide, RenderTableCell* = 0);
+    int offsetLeftForRowGroupBorder(RenderTableCell*, const LayoutRect& rowGroupRect, unsigned row);
 
+    int offsetTopForRowGroupBorder(RenderTableCell*, BoxSide borderSide, unsigned row);
+    int verticalRowGroupBorderHeight(RenderTableCell*, const LayoutRect& rowGroupRect, unsigned row);
+    int horizontalRowGroupBorderWidth(RenderTableCell*, const LayoutRect& rowGroupRect, unsigned row, unsigned column);
+
     virtual void imageChanged(WrappedImagePtr, const IntRect* = 0) OVERRIDE;
 
     virtual bool nodeAtPoint(const HitTestRequest&, HitTestResult&, const HitTestLocation& locationInContainer, const LayoutPoint& accumulatedOffset, HitTestAction) OVERRIDE;
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to