changeset 9488:ae75f92d5e53

8146512: Table Borders are not drawn properly Reviewed-by: kcr, azvegint Contributed-by: murali.billa@oracle.com
author kcr
date Thu, 07 Jan 2016 14:31:34 -0800
parents 04ec31c357be
children 01c29b32f1c9
files modules/web/src/main/native/Source/WebCore/rendering/RenderTableCell.cpp modules/web/src/main/native/Source/WebCore/rendering/RenderTableCell.h
diffstat 2 files changed, 7 insertions(+), 81 deletions(-) [+]
line wrap: on
line diff
--- a/modules/web/src/main/native/Source/WebCore/rendering/RenderTableCell.cpp	Thu Jan 07 09:36:24 2016 -0800
+++ b/modules/web/src/main/native/Source/WebCore/rendering/RenderTableCell.cpp	Thu Jan 07 14:31:34 2016 -0800
@@ -1136,31 +1136,6 @@
         compareBorderValuesForQSort);
 }
 
-bool RenderTableCell::alignLeftRightBorderPaintRect(int& leftXOffset, int& rightXOffset)
-{
-    const RenderStyle& styleForTopCell = styleForCellFlow();
-    int left = cachedCollapsedLeftBorder(&styleForTopCell).width();
-    int right = cachedCollapsedRightBorder(&styleForTopCell).width();
-    leftXOffset = std::max<int>(leftXOffset, left);
-    rightXOffset = std::max<int>(rightXOffset, right);
-    if (colSpan() > 1)
-        return false;
-    return true;
-}
-
-bool RenderTableCell::alignTopBottomBorderPaintRect(int& topYOffset, int& bottomYOffset)
-{
-    const RenderStyle& styleForBottomCell = styleForCellFlow();
-    int top = cachedCollapsedTopBorder(&styleForBottomCell).width();
-    int bottom = cachedCollapsedBottomBorder(&styleForBottomCell).width();
-    topYOffset = std::max<int>(topYOffset, top);
-    bottomYOffset = std::max<int>(bottomYOffset, bottom);
-    if (rowSpan() > 1)
-        return false;
-    return true;
-}
-
-
 void RenderTableCell::paintCollapsedBorders(PaintInfo& paintInfo, const LayoutPoint& paintOffset)
 {
     ASSERT(paintInfo.phase == PaintPhaseCollapsedTableBorders);
@@ -1194,38 +1169,6 @@
     int leftWidth = leftVal.width();
     int rightWidth = rightVal.width();
 
-    int leftXOffsetTop = leftWidth;
-    int leftXOffsetBottom = leftWidth;
-    int rightXOffsetTop = rightWidth;
-    int rightXOffsetBottom = rightWidth;
-    int topYOffsetLeft = topWidth;
-    int topYOffsetRight = topWidth;
-    int bottomYOffsetLeft = bottomWidth;
-    int bottomYOffsetRight = bottomWidth;
-
-    // We use the direction/writing-mode given by the section here because we want to know if we're
-    // at the section's edge.
-    bool shouldDrawTopBorder = !cellAtTop(&section()->style());
-    bool shouldDrawLeftBorder = !cellAtLeft(&section()->style());
-    bool shouldDrawRightBorder = true;
-
-    if (RenderTableCell* top = cellAtTop(&styleForCellFlow)) {
-        shouldDrawTopBorder = shouldDrawTopBorder && top->alignLeftRightBorderPaintRect(leftXOffsetTop, rightXOffsetTop);
-        if (this->colSpan() > 1)
-            shouldDrawTopBorder = false;
-    }
-
-    if (RenderTableCell* bottom = cellAtBottom(&styleForCellFlow))
-        bottom->alignLeftRightBorderPaintRect(leftXOffsetBottom, rightXOffsetBottom);
-
-    if (RenderTableCell* left = cellAtLeft(&styleForCellFlow))
-        shouldDrawLeftBorder = shouldDrawLeftBorder && left->alignTopBottomBorderPaintRect(topYOffsetLeft, bottomYOffsetLeft);
-
-    if (RenderTableCell* right = cellAtRight(&styleForCellFlow))
-        shouldDrawRightBorder = right->alignTopBottomBorderPaintRect(topYOffsetRight, bottomYOffsetRight);
-
-    IntRect cellRect = pixelSnappedIntRect(paintRect.x(), paintRect.y(), paintRect.width(), paintRect.height());
-
     IntRect borderRect = pixelSnappedIntRect(paintRect.x() - leftWidth / 2,
         paintRect.y() - topWidth / 2,
         paintRect.width() + leftWidth / 2 + (rightWidth + 1) / 2,
@@ -1236,33 +1179,18 @@
     EBorderStyle leftStyle = collapsedBorderStyle(leftVal.style());
     EBorderStyle rightStyle = collapsedBorderStyle(rightVal.style());
     
-    bool renderTop = topStyle > BHIDDEN && !topVal.isTransparent() && shouldDrawTopBorder;
+    bool renderTop = topStyle > BHIDDEN && !topVal.isTransparent();
     bool renderBottom = bottomStyle > BHIDDEN && !bottomVal.isTransparent();
-    bool renderLeft = leftStyle > BHIDDEN && !leftVal.isTransparent() && shouldDrawLeftBorder;
-    bool renderRight = rightStyle > BHIDDEN && !rightVal.isTransparent() && shouldDrawRightBorder;
+    bool renderLeft = leftStyle > BHIDDEN && !leftVal.isTransparent();
+    bool renderRight = rightStyle > BHIDDEN && !rightVal.isTransparent();
 
     // We never paint diagonals at the joins.  We simply let the border with the highest
     // precedence paint on top of borders with lower precedence.  
     CollapsedBorders borders;
-    if (topVal.style() == DOTTED)
-        borders.addBorder(topVal, BSTop, renderTop, cellRect.x() - leftXOffsetTop / 2, cellRect.y() - topWidth / 2, cellRect.maxX() + rightXOffsetTop / 2, cellRect.y() + topWidth / 2 + topWidth % 2, topStyle);
-    else
-        borders.addBorder(topVal, BSTop, renderTop, borderRect.x(), borderRect.y(), borderRect.maxX(), borderRect.y() + topWidth, topStyle);
-
-    if (bottomVal.style() == DOTTED)
-        borders.addBorder(bottomVal, BSBottom, renderBottom, cellRect.x() - leftXOffsetBottom / 2, cellRect.maxY() - bottomWidth / 2, cellRect.maxX() + rightXOffsetBottom / 2, cellRect.maxY() + bottomWidth / 2 + bottomWidth % 2, bottomStyle);
-    else
-        borders.addBorder(bottomVal, BSBottom, renderBottom, borderRect.x(), borderRect.maxY() - bottomWidth, borderRect.maxX(), borderRect.maxY(), bottomStyle);
-
-    if (leftVal.style() == DOTTED)
-        borders.addBorder(leftVal, BSLeft, renderLeft, cellRect.x() - leftWidth / 2, cellRect.y() - topYOffsetLeft / 2, cellRect.x() + leftWidth / 2 + leftWidth % 2, cellRect.maxY() + bottomYOffsetLeft / 2 + bottomYOffsetLeft % 2, leftStyle);
-    else
-        borders.addBorder(leftVal, BSLeft, renderLeft, borderRect.x(), borderRect.y(), borderRect.x() + leftWidth, borderRect.maxY(), leftStyle);
-
-    if (rightVal.style() == DOTTED)
-        borders.addBorder(rightVal, BSRight, renderRight, cellRect.maxX() - rightWidth / 2, cellRect.y()  - topYOffsetRight / 2, cellRect.maxX() + rightWidth / 2 + rightWidth % 2, cellRect.maxY()  + bottomYOffsetRight / 2 + bottomYOffsetRight % 2, rightStyle);
-    else
-        borders.addBorder(rightVal, BSRight, renderRight, borderRect.maxX() - rightWidth, borderRect.y(), borderRect.maxX(), borderRect.maxY(), rightStyle);
+    borders.addBorder(topVal, BSTop, renderTop, borderRect.x(), borderRect.y(), borderRect.maxX(), borderRect.y() + topWidth, topStyle);
+    borders.addBorder(bottomVal, BSBottom, renderBottom, borderRect.x(), borderRect.maxY() - bottomWidth, borderRect.maxX(), borderRect.maxY(), bottomStyle);
+    borders.addBorder(leftVal, BSLeft, renderLeft, borderRect.x(), borderRect.y(), borderRect.x() + leftWidth, borderRect.maxY(), leftStyle);
+    borders.addBorder(rightVal, BSRight, renderRight, borderRect.maxX() - rightWidth, borderRect.y(), borderRect.maxX(), borderRect.maxY(), rightStyle);
 
     bool antialias = shouldAntialiasLines(graphicsContext);
     
--- a/modules/web/src/main/native/Source/WebCore/rendering/RenderTableCell.h	Thu Jan 07 09:36:24 2016 -0800
+++ b/modules/web/src/main/native/Source/WebCore/rendering/RenderTableCell.h	Thu Jan 07 14:31:34 2016 -0800
@@ -126,8 +126,6 @@
 
     virtual void paint(PaintInfo&, const LayoutPoint&) override;
 
-    bool alignLeftRightBorderPaintRect(int& leftXOffset, int& rightXOffset);
-    bool alignTopBottomBorderPaintRect(int& topYOffset, int& bottomYOffset);
     void paintCollapsedBorders(PaintInfo&, const LayoutPoint&);
     void paintBackgroundsBehindCell(PaintInfo&, const LayoutPoint&, RenderElement* backgroundObject);