Title: [153510] trunk
Revision
153510
Author
[email protected]
Date
2013-07-30 21:59:52 -0700 (Tue, 30 Jul 2013)

Log Message

Dotted borders render w/ artifacts and sometimes as solid lines
https://bugs.webkit.org/show_bug.cgi?id=3964

Patch by Pravin D <[email protected]> on 2013-07-30
Reviewed by Elliott Sprehn.

Source/WebCore:

While drawing the dotted border, the common borders are drawn by the cells sharing them. The dotted borders
become(tend) solid when the starting and the end points of the border drawn by the two cells don't match. This
fixes the same.

Test: fast/table/border-collapsing/dotted-collapsed-border.html

* rendering/RenderTableCell.cpp:
(WebCore::RenderTableCell::alignLeftRightBorderPaintRect):
(WebCore::RenderTableCell::alignTopBottomBorderPaintRect):
 Helper function to decide if border's start point requires any adjustment.

(WebCore::RenderTableCell::paintCollapsedBorders):
Added logic to handle dotted borders so that they do not become solid.

* rendering/RenderTableCell.h:
 Helper function declarations.

LayoutTests:

* fast/table/border-collapsing/dotted-collapsed-border-expected.txt: Added.
* fast/table/border-collapsing/dotted-collapsed-border.html: Added.
* platform/qt/fast/table/border-collapsing/dotted-collapsed-border-expected.png: Added.

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (153509 => 153510)


--- trunk/LayoutTests/ChangeLog	2013-07-31 04:55:02 UTC (rev 153509)
+++ trunk/LayoutTests/ChangeLog	2013-07-31 04:59:52 UTC (rev 153510)
@@ -1,3 +1,14 @@
+2013-07-30  Pravin D  <[email protected]>
+
+        Dotted borders render w/ artifacts and sometimes as solid lines
+        https://bugs.webkit.org/show_bug.cgi?id=3964
+
+        Reviewed by Elliott Sprehn.
+
+        * fast/table/border-collapsing/dotted-collapsed-border-expected.txt: Added.
+        * fast/table/border-collapsing/dotted-collapsed-border.html: Added.
+        * platform/qt/fast/table/border-collapsing/dotted-collapsed-border-expected.png: Added.
+
 2013-07-30  Vani Hegde  <[email protected]>
 
         Gmail reply email - Bold and Italic style  get stuck

Added: trunk/LayoutTests/fast/table/border-collapsing/dotted-collapsed-border-expected.txt (0 => 153510)


--- trunk/LayoutTests/fast/table/border-collapsing/dotted-collapsed-border-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/fast/table/border-collapsing/dotted-collapsed-border-expected.txt	2013-07-31 04:59:52 UTC (rev 153510)
@@ -0,0 +1,2 @@
+Item Description
+Art

Added: trunk/LayoutTests/fast/table/border-collapsing/dotted-collapsed-border.html (0 => 153510)


--- trunk/LayoutTests/fast/table/border-collapsing/dotted-collapsed-border.html	                        (rev 0)
+++ trunk/LayoutTests/fast/table/border-collapsing/dotted-collapsed-border.html	2013-07-31 04:59:52 UTC (rev 153510)
@@ -0,0 +1,29 @@
+<!DOCTYPE html>
+<html>
+<head>
+<style type="text/css">
+  table {
+	border-collapse: collapse;
+  }
+  td.cause {
+	padding: 2px;
+    border-right:2px dotted green;
+  }
+  td.effect {
+	border: 2px dotted green;
+  }
+</style></head>
+<body>
+<script>
+if(window.testRunner)
+    testRunner.dumpAsText(true);
+</script>
+<table>
+<tr><td class="cause">Item Description</td></tr>
+<tr><td class="effect">Art</td></tr>
+</tbody>
+</table>
+
+</body>
+</html>
+

Added: trunk/LayoutTests/platform/qt/fast/table/border-collapsing/dotted-collapsed-border-expected.png


(Binary files differ)
Property changes on: trunk/LayoutTests/platform/qt/fast/table/border-collapsing/dotted-collapsed-border-expected.png ___________________________________________________________________

Added: svn:mime-type

Modified: trunk/Source/WebCore/ChangeLog (153509 => 153510)


--- trunk/Source/WebCore/ChangeLog	2013-07-31 04:55:02 UTC (rev 153509)
+++ trunk/Source/WebCore/ChangeLog	2013-07-31 04:59:52 UTC (rev 153510)
@@ -1,3 +1,27 @@
+2013-07-30  Pravin D  <[email protected]>
+
+        Dotted borders render w/ artifacts and sometimes as solid lines
+        https://bugs.webkit.org/show_bug.cgi?id=3964
+
+        Reviewed by Elliott Sprehn.
+
+        While drawing the dotted border, the common borders are drawn by the cells sharing them. The dotted borders
+        become(tend) solid when the starting and the end points of the border drawn by the two cells don't match. This
+        fixes the same. 
+
+        Test: fast/table/border-collapsing/dotted-collapsed-border.html
+
+        * rendering/RenderTableCell.cpp:
+        (WebCore::RenderTableCell::alignLeftRightBorderPaintRect):
+        (WebCore::RenderTableCell::alignTopBottomBorderPaintRect):
+         Helper function to decide if border's start point requires any adjustment.
+
+        (WebCore::RenderTableCell::paintCollapsedBorders):
+        Added logic to handle dotted borders so that they do not become solid.
+
+        * rendering/RenderTableCell.h:
+         Helper function declarations.
+
 2013-07-30  Vani Hegde  <[email protected]>
 
         Gmail reply email - Bold and Italic style  get stuck

Modified: trunk/Source/WebCore/rendering/RenderTableCell.cpp (153509 => 153510)


--- trunk/Source/WebCore/rendering/RenderTableCell.cpp	2013-07-31 04:55:02 UTC (rev 153509)
+++ trunk/Source/WebCore/rendering/RenderTableCell.cpp	2013-07-31 04:59:52 UTC (rev 153510)
@@ -1101,6 +1101,31 @@
         compareBorderValuesForQSort);
 }
 
+bool RenderTableCell::alignLeftRightBorderPaintRect(int& leftXOffset, int& rightXOffset)
+{
+    const RenderStyle* styleForTopCell = styleForCellFlow();
+    int left = cachedCollapsedLeftBorder(styleForTopCell).width();
+    int right = cachedCollapsedRightBorder(styleForTopCell).width();
+    leftXOffset = max<int>(leftXOffset, left);
+    rightXOffset = 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 = max<int>(topYOffset, top);
+    bottomYOffset = max<int>(bottomYOffset, bottom);
+    if (rowSpan() > 1)
+        return false;
+    return true;
+}
+
+
 void RenderTableCell::paintCollapsedBorders(PaintInfo& paintInfo, const LayoutPoint& paintOffset)
 {
     ASSERT(paintInfo.phase == PaintPhaseCollapsedTableBorders);
@@ -1134,35 +1159,80 @@
     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;
+
+    bool shouldDrawTopBorder = true;
+    bool shouldDrawLeftBorder = true;
+    bool shouldDrawRightBorder = true;
+
+    if (RenderTableCell* top = table()->cellAbove(this)) {
+        shouldDrawTopBorder = top->alignLeftRightBorderPaintRect(leftXOffsetTop, rightXOffsetTop);
+        if (this->colSpan() > 1)
+            shouldDrawTopBorder = false;
+    }
+
+    if (RenderTableCell* bottom = table()->cellBelow(this))
+        bottom->alignLeftRightBorderPaintRect(leftXOffsetBottom, rightXOffsetBottom);
+
+    if (RenderTableCell* left = table()->cellBefore(this))
+        shouldDrawLeftBorder = left->alignTopBottomBorderPaintRect(topYOffsetLeft, bottomYOffsetLeft);
+
+    if (RenderTableCell* right = table()->cellAfter(this))
+        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,
-            paintRect.height() + topWidth / 2 + (bottomWidth + 1) / 2);
+        paintRect.y() - topWidth / 2,
+        paintRect.width() + leftWidth / 2 + (rightWidth + 1) / 2,
+        paintRect.height() + topWidth / 2 + (bottomWidth + 1) / 2);
 
     EBorderStyle topStyle = collapsedBorderStyle(topVal.style());
     EBorderStyle bottomStyle = collapsedBorderStyle(bottomVal.style());
     EBorderStyle leftStyle = collapsedBorderStyle(leftVal.style());
     EBorderStyle rightStyle = collapsedBorderStyle(rightVal.style());
     
-    bool renderTop = topStyle > BHIDDEN && !topVal.isTransparent();
+    bool renderTop = topStyle > BHIDDEN && !topVal.isTransparent() && shouldDrawTopBorder;
     bool renderBottom = bottomStyle > BHIDDEN && !bottomVal.isTransparent();
-    bool renderLeft = leftStyle > BHIDDEN && !leftVal.isTransparent();
-    bool renderRight = rightStyle > BHIDDEN && !rightVal.isTransparent();
+    bool renderLeft = leftStyle > BHIDDEN && !leftVal.isTransparent() && shouldDrawLeftBorder;
+    bool renderRight = rightStyle > BHIDDEN && !rightVal.isTransparent() && shouldDrawRightBorder;
 
     // 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;
-    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);
+    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);
+
     bool antialias = shouldAntialiasLines(graphicsContext);
     
     for (CollapsedBorder* border = borders.nextBorder(); border; border = borders.nextBorder()) {
         if (border->borderValue.isSameIgnoringColor(*table()->currentBorderValue()))
             drawLineForBoxSide(graphicsContext, border->x1, border->y1, border->x2, border->y2, border->side, 
-                               border->borderValue.color(), border->style, 0, 0, antialias);
+                border->borderValue.color(), border->style, 0, 0, antialias);
     }
 }
 

Modified: trunk/Source/WebCore/rendering/RenderTableCell.h (153509 => 153510)


--- trunk/Source/WebCore/rendering/RenderTableCell.h	2013-07-31 04:55:02 UTC (rev 153509)
+++ trunk/Source/WebCore/rendering/RenderTableCell.h	2013-07-31 04:59:52 UTC (rev 153510)
@@ -121,6 +121,8 @@
 
     virtual void paint(PaintInfo&, const LayoutPoint&);
 
+    bool alignLeftRightBorderPaintRect(int& leftXOffset, int& rightXOffset);
+    bool alignTopBottomBorderPaintRect(int& topYOffset, int& bottomYOffset);
     void paintCollapsedBorders(PaintInfo&, const LayoutPoint&);
     void paintBackgroundsBehindCell(PaintInfo&, const LayoutPoint&, RenderObject* backgroundObject);
 
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to