Title: [125285] trunk
Revision
125285
Author
[email protected]
Date
2012-08-10 08:56:55 -0700 (Fri, 10 Aug 2012)

Log Message

[Qt] Dotted borders not drawn with rounded dots
https://bugs.webkit.org/show_bug.cgi?id=92383

Patch by Martin Leutelt <[email protected]> on 2012-08-10
Reviewed by Noam Rosenthal.

The dots in borders with dotted style were previously drawn with
rectangular dots. The CSS spec specifies that the dots should be
rounded dots. This patch fixes this behavior for the Qt port.

No new tests, existing ones have been updated with new expected
results.

Source/WebCore:

* platform/graphics/qt/GraphicsContextQt.cpp:
(WebCore::adjustPointsForDottedLine):
(WebCore):
(WebCore::drawLineEndpointsForStyle):
(WebCore::GraphicsContext::drawLine):

LayoutTests:

* platform/qt/css2.1/t170602-bdr-conflct-w-04-d-expected.png:
* platform/qt/css2.1/t170602-bdr-conflct-w-14-d-expected.png:
* platform/qt/css2.1/t170602-bdr-conflct-w-24-d-expected.png:
* platform/qt/css2.1/t170602-bdr-conflct-w-34-d-expected.png:
* platform/qt/css2.1/t170602-bdr-conflct-w-41-d-expected.png:
* platform/qt/css2.1/t170602-bdr-conflct-w-42-d-expected.png:
* platform/qt/css2.1/t170602-bdr-conflct-w-43-d-expected.png:
* platform/qt/css2.1/t170602-bdr-conflct-w-44-d-expected.png:
* platform/qt/css2.1/t170602-bdr-conflct-w-49-d-expected.png:
* platform/qt/css2.1/t170602-bdr-conflct-w-94-d-expected.png:
* platform/qt/editing/inserting/editing-empty-divs-expected.png:
* platform/qt/fast/backgrounds/repeat/negative-offset-repeat-expected.png:
* platform/qt/fast/css/margin-top-bottom-dynamic-expected.png:
* platform/qt/fast/layers/opacity-outline-expected.png:
* platform/qt/fast/lists/ordered-list-with-no-ol-tag-expected.png:
* platform/qt/fast/multicol/progression-reverse-expected.png:
* platform/qt/fast/overflow/overflow-with-local-background-attachment-expected.png:
* platform/qt/fast/table/border-collapsing/001-expected.png:
* platform/qt/fast/table/border-collapsing/001-vertical-expected.png:
* platform/qt/svg/custom/no-inherited-dashed-stroke-expected.png:
* platform/qt/svg/transforms/svg-css-transforms-expected.png:
* platform/qt/tables/mozilla/bugs/bug22019-expected.png:
* platform/qt/tables/mozilla/bugs/bug2947-expected.png:
* platform/qt/tables/mozilla/bugs/bug6674-expected.png:
* platform/qt/tables/mozilla/marvin/backgr_layers-opacity-expected.png:
* platform/qt/tables/mozilla/marvin/backgr_position-table-expected.png:
* platform/qt/tables/mozilla/marvin/backgr_simple-table-cell-expected.png:
* platform/qt/tables/mozilla/marvin/backgr_simple-table-column-expected.png:
* platform/qt/tables/mozilla/marvin/backgr_simple-table-column-group-expected.png:
* platform/qt/tables/mozilla/marvin/backgr_simple-table-expected.png:
* platform/qt/tables/mozilla/marvin/backgr_simple-table-row-expected.png:
* platform/qt/tables/mozilla/marvin/backgr_simple-table-row-group-expected.png:
* platform/qt/tables/mozilla_expected_failures/marvin/backgr_border-table-cell-expected.png:
* platform/qt/tables/mozilla_expected_failures/marvin/backgr_border-table-column-expected.png:
* platform/qt/tables/mozilla_expected_failures/marvin/backgr_border-table-column-group-expected.png:
* platform/qt/tables/mozilla_expected_failures/marvin/backgr_border-table-expected.png:
* platform/qt/tables/mozilla_expected_failures/marvin/backgr_border-table-quirks-expected.png:
* platform/qt/tables/mozilla_expected_failures/marvin/backgr_border-table-row-expected.png:
* platform/qt/tables/mozilla_expected_failures/marvin/backgr_border-table-row-group-expected.png:
* platform/qt/tables/mozilla_expected_failures/marvin/backgr_fixed-bg-expected.png:
* platform/qt/tables/mozilla_expected_failures/marvin/backgr_layers-hide-expected.png:
* platform/qt/tables/mozilla_expected_failures/marvin/backgr_position-table-cell-expected.png:
* platform/qt/tables/mozilla_expected_failures/marvin/backgr_position-table-column-expected.png:
* platform/qt/tables/mozilla_expected_failures/marvin/backgr_position-table-column-group-expected.png:
* platform/qt/tables/mozilla_expected_failures/marvin/backgr_position-table-row-expected.png:
* platform/qt/tables/mozilla_expected_failures/marvin/backgr_position-table-row-group-expected.png:
* platform/qt/transforms/svg-vs-css-expected.png:

Modified Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (125284 => 125285)


--- trunk/LayoutTests/ChangeLog	2012-08-10 15:42:23 UTC (rev 125284)
+++ trunk/LayoutTests/ChangeLog	2012-08-10 15:56:55 UTC (rev 125285)
@@ -1,3 +1,65 @@
+2012-08-10  Martin Leutelt  <[email protected]>
+
+        [Qt] Dotted borders not drawn with rounded dots
+        https://bugs.webkit.org/show_bug.cgi?id=92383
+
+        Reviewed by Noam Rosenthal.
+
+        The dots in borders with dotted style were previously drawn with
+        rectangular dots. The CSS spec specifies that the dots should be
+        rounded dots. This patch fixes this behavior for the Qt port.
+
+        No new tests, existing ones have been updated with new expected
+        results.
+
+        * platform/qt/css2.1/t170602-bdr-conflct-w-04-d-expected.png:
+        * platform/qt/css2.1/t170602-bdr-conflct-w-14-d-expected.png:
+        * platform/qt/css2.1/t170602-bdr-conflct-w-24-d-expected.png:
+        * platform/qt/css2.1/t170602-bdr-conflct-w-34-d-expected.png:
+        * platform/qt/css2.1/t170602-bdr-conflct-w-41-d-expected.png:
+        * platform/qt/css2.1/t170602-bdr-conflct-w-42-d-expected.png:
+        * platform/qt/css2.1/t170602-bdr-conflct-w-43-d-expected.png:
+        * platform/qt/css2.1/t170602-bdr-conflct-w-44-d-expected.png:
+        * platform/qt/css2.1/t170602-bdr-conflct-w-49-d-expected.png:
+        * platform/qt/css2.1/t170602-bdr-conflct-w-94-d-expected.png:
+        * platform/qt/editing/inserting/editing-empty-divs-expected.png:
+        * platform/qt/fast/backgrounds/repeat/negative-offset-repeat-expected.png:
+        * platform/qt/fast/css/margin-top-bottom-dynamic-expected.png:
+        * platform/qt/fast/layers/opacity-outline-expected.png:
+        * platform/qt/fast/lists/ordered-list-with-no-ol-tag-expected.png:
+        * platform/qt/fast/multicol/progression-reverse-expected.png:
+        * platform/qt/fast/overflow/overflow-with-local-background-attachment-expected.png:
+        * platform/qt/fast/table/border-collapsing/001-expected.png:
+        * platform/qt/fast/table/border-collapsing/001-vertical-expected.png:
+        * platform/qt/svg/custom/no-inherited-dashed-stroke-expected.png:
+        * platform/qt/svg/transforms/svg-css-transforms-expected.png:
+        * platform/qt/tables/mozilla/bugs/bug22019-expected.png:
+        * platform/qt/tables/mozilla/bugs/bug2947-expected.png:
+        * platform/qt/tables/mozilla/bugs/bug6674-expected.png:
+        * platform/qt/tables/mozilla/marvin/backgr_layers-opacity-expected.png:
+        * platform/qt/tables/mozilla/marvin/backgr_position-table-expected.png:
+        * platform/qt/tables/mozilla/marvin/backgr_simple-table-cell-expected.png:
+        * platform/qt/tables/mozilla/marvin/backgr_simple-table-column-expected.png:
+        * platform/qt/tables/mozilla/marvin/backgr_simple-table-column-group-expected.png:
+        * platform/qt/tables/mozilla/marvin/backgr_simple-table-expected.png:
+        * platform/qt/tables/mozilla/marvin/backgr_simple-table-row-expected.png:
+        * platform/qt/tables/mozilla/marvin/backgr_simple-table-row-group-expected.png:
+        * platform/qt/tables/mozilla_expected_failures/marvin/backgr_border-table-cell-expected.png:
+        * platform/qt/tables/mozilla_expected_failures/marvin/backgr_border-table-column-expected.png:
+        * platform/qt/tables/mozilla_expected_failures/marvin/backgr_border-table-column-group-expected.png:
+        * platform/qt/tables/mozilla_expected_failures/marvin/backgr_border-table-expected.png:
+        * platform/qt/tables/mozilla_expected_failures/marvin/backgr_border-table-quirks-expected.png:
+        * platform/qt/tables/mozilla_expected_failures/marvin/backgr_border-table-row-expected.png:
+        * platform/qt/tables/mozilla_expected_failures/marvin/backgr_border-table-row-group-expected.png:
+        * platform/qt/tables/mozilla_expected_failures/marvin/backgr_fixed-bg-expected.png:
+        * platform/qt/tables/mozilla_expected_failures/marvin/backgr_layers-hide-expected.png:
+        * platform/qt/tables/mozilla_expected_failures/marvin/backgr_position-table-cell-expected.png:
+        * platform/qt/tables/mozilla_expected_failures/marvin/backgr_position-table-column-expected.png:
+        * platform/qt/tables/mozilla_expected_failures/marvin/backgr_position-table-column-group-expected.png:
+        * platform/qt/tables/mozilla_expected_failures/marvin/backgr_position-table-row-expected.png:
+        * platform/qt/tables/mozilla_expected_failures/marvin/backgr_position-table-row-group-expected.png:
+        * platform/qt/transforms/svg-vs-css-expected.png:
+
 2012-08-10  Pavel Feldman  <[email protected]>
 
         Web Inspector: render arrays as dir in case they were logged into console prior to the front-end opening.

Modified: trunk/LayoutTests/platform/qt/css2.1/t170602-bdr-conflct-w-04-d-expected.png


(Binary files differ)

Modified: trunk/LayoutTests/platform/qt/css2.1/t170602-bdr-conflct-w-14-d-expected.png


(Binary files differ)

Modified: trunk/LayoutTests/platform/qt/css2.1/t170602-bdr-conflct-w-24-d-expected.png


(Binary files differ)

Modified: trunk/LayoutTests/platform/qt/css2.1/t170602-bdr-conflct-w-34-d-expected.png


(Binary files differ)

Modified: trunk/LayoutTests/platform/qt/css2.1/t170602-bdr-conflct-w-41-d-expected.png


(Binary files differ)

Modified: trunk/LayoutTests/platform/qt/css2.1/t170602-bdr-conflct-w-42-d-expected.png


(Binary files differ)

Modified: trunk/LayoutTests/platform/qt/css2.1/t170602-bdr-conflct-w-43-d-expected.png


(Binary files differ)

Modified: trunk/LayoutTests/platform/qt/css2.1/t170602-bdr-conflct-w-44-d-expected.png


(Binary files differ)

Modified: trunk/LayoutTests/platform/qt/css2.1/t170602-bdr-conflct-w-49-d-expected.png


(Binary files differ)

Modified: trunk/LayoutTests/platform/qt/css2.1/t170602-bdr-conflct-w-94-d-expected.png


(Binary files differ)

Modified: trunk/LayoutTests/platform/qt/editing/inserting/editing-empty-divs-expected.png


(Binary files differ)

Modified: trunk/LayoutTests/platform/qt/fast/backgrounds/repeat/negative-offset-repeat-expected.png


(Binary files differ)

Modified: trunk/LayoutTests/platform/qt/fast/css/margin-top-bottom-dynamic-expected.png


(Binary files differ)

Modified: trunk/LayoutTests/platform/qt/fast/layers/opacity-outline-expected.png


(Binary files differ)

Modified: trunk/LayoutTests/platform/qt/fast/lists/ordered-list-with-no-ol-tag-expected.png


(Binary files differ)

Modified: trunk/LayoutTests/platform/qt/fast/multicol/progression-reverse-expected.png


(Binary files differ)

Modified: trunk/LayoutTests/platform/qt/fast/overflow/overflow-with-local-background-attachment-expected.png


(Binary files differ)

Modified: trunk/LayoutTests/platform/qt/fast/table/border-collapsing/001-expected.png


(Binary files differ)

Modified: trunk/LayoutTests/platform/qt/fast/table/border-collapsing/001-vertical-expected.png


(Binary files differ)

Modified: trunk/LayoutTests/platform/qt/svg/custom/no-inherited-dashed-stroke-expected.png


(Binary files differ)

Modified: trunk/LayoutTests/platform/qt/svg/transforms/svg-css-transforms-expected.png


(Binary files differ)

Modified: trunk/LayoutTests/platform/qt/tables/mozilla/bugs/bug22019-expected.png


(Binary files differ)

Modified: trunk/LayoutTests/platform/qt/tables/mozilla/bugs/bug2947-expected.png


(Binary files differ)

Modified: trunk/LayoutTests/platform/qt/tables/mozilla/bugs/bug6674-expected.png


(Binary files differ)

Modified: trunk/LayoutTests/platform/qt/tables/mozilla/marvin/backgr_layers-opacity-expected.png


(Binary files differ)

Modified: trunk/LayoutTests/platform/qt/tables/mozilla/marvin/backgr_position-table-expected.png


(Binary files differ)

Modified: trunk/LayoutTests/platform/qt/tables/mozilla/marvin/backgr_simple-table-cell-expected.png


(Binary files differ)

Modified: trunk/LayoutTests/platform/qt/tables/mozilla/marvin/backgr_simple-table-column-expected.png


(Binary files differ)

Modified: trunk/LayoutTests/platform/qt/tables/mozilla/marvin/backgr_simple-table-column-group-expected.png


(Binary files differ)

Modified: trunk/LayoutTests/platform/qt/tables/mozilla/marvin/backgr_simple-table-expected.png


(Binary files differ)

Modified: trunk/LayoutTests/platform/qt/tables/mozilla/marvin/backgr_simple-table-row-expected.png


(Binary files differ)

Modified: trunk/LayoutTests/platform/qt/tables/mozilla/marvin/backgr_simple-table-row-group-expected.png


(Binary files differ)

Modified: trunk/LayoutTests/platform/qt/tables/mozilla_expected_failures/marvin/backgr_border-table-cell-expected.png


(Binary files differ)

Modified: trunk/LayoutTests/platform/qt/tables/mozilla_expected_failures/marvin/backgr_border-table-column-expected.png


(Binary files differ)

Modified: trunk/LayoutTests/platform/qt/tables/mozilla_expected_failures/marvin/backgr_border-table-column-group-expected.png


(Binary files differ)

Modified: trunk/LayoutTests/platform/qt/tables/mozilla_expected_failures/marvin/backgr_border-table-expected.png


(Binary files differ)

Modified: trunk/LayoutTests/platform/qt/tables/mozilla_expected_failures/marvin/backgr_border-table-quirks-expected.png


(Binary files differ)

Modified: trunk/LayoutTests/platform/qt/tables/mozilla_expected_failures/marvin/backgr_border-table-row-expected.png


(Binary files differ)

Modified: trunk/LayoutTests/platform/qt/tables/mozilla_expected_failures/marvin/backgr_border-table-row-group-expected.png


(Binary files differ)

Modified: trunk/LayoutTests/platform/qt/tables/mozilla_expected_failures/marvin/backgr_fixed-bg-expected.png


(Binary files differ)

Modified: trunk/LayoutTests/platform/qt/tables/mozilla_expected_failures/marvin/backgr_layers-hide-expected.png


(Binary files differ)

Modified: trunk/LayoutTests/platform/qt/tables/mozilla_expected_failures/marvin/backgr_position-table-cell-expected.png


(Binary files differ)

Modified: trunk/LayoutTests/platform/qt/tables/mozilla_expected_failures/marvin/backgr_position-table-column-expected.png


(Binary files differ)

Modified: trunk/LayoutTests/platform/qt/tables/mozilla_expected_failures/marvin/backgr_position-table-column-group-expected.png


(Binary files differ)

Modified: trunk/LayoutTests/platform/qt/tables/mozilla_expected_failures/marvin/backgr_position-table-row-expected.png


(Binary files differ)

Modified: trunk/LayoutTests/platform/qt/tables/mozilla_expected_failures/marvin/backgr_position-table-row-group-expected.png


(Binary files differ)

Modified: trunk/LayoutTests/platform/qt/transforms/svg-vs-css-expected.png


(Binary files differ)

Modified: trunk/Source/WebCore/ChangeLog (125284 => 125285)


--- trunk/Source/WebCore/ChangeLog	2012-08-10 15:42:23 UTC (rev 125284)
+++ trunk/Source/WebCore/ChangeLog	2012-08-10 15:56:55 UTC (rev 125285)
@@ -1,3 +1,23 @@
+2012-08-10  Martin Leutelt  <[email protected]>
+
+        [Qt] Dotted borders not drawn with rounded dots
+        https://bugs.webkit.org/show_bug.cgi?id=92383
+
+        Reviewed by Noam Rosenthal.
+
+        The dots in borders with dotted style were previously drawn with
+        rectangular dots. The CSS spec specifies that the dots should be
+        rounded dots. This patch fixes this behavior for the Qt port.
+
+        No new tests, existing ones have been updated with new expected
+        results.
+
+        * platform/graphics/qt/GraphicsContextQt.cpp:
+        (WebCore::adjustPointsForDottedLine):
+        (WebCore):
+        (WebCore::drawLineEndpointsForStyle):
+        (WebCore::GraphicsContext::drawLine):
+
 2012-08-10  Pavel Feldman  <[email protected]>
 
         Web Inspector: render arrays as dir in case they were logged into console prior to the front-end opening.

Modified: trunk/Source/WebCore/platform/graphics/qt/GraphicsContextQt.cpp (125284 => 125285)


--- trunk/Source/WebCore/platform/graphics/qt/GraphicsContextQt.cpp	2012-08-10 15:42:23 UTC (rev 125284)
+++ trunk/Source/WebCore/platform/graphics/qt/GraphicsContextQt.cpp	2012-08-10 15:56:55 UTC (rev 125285)
@@ -181,6 +181,41 @@
     return Qt::OddEvenFill;
 }
 
+static inline void adjustPointsForDottedLine(FloatPoint& p1, FloatPoint& p2, float width, bool isVerticalLine)
+{
+    if (isVerticalLine) {
+        p1.setY(p1.y() - width / 2);
+        p2.setY(p2.y() + width / 2);
+    } else {
+        p1.setX(p1.x() - width / 2);
+        p2.setX(p2.x() + width / 2);
+    }
+}
+
+static inline void drawLineEndpointsForStyle(QPainter *painter, const FloatPoint& p1, const FloatPoint& p2, float width, bool isVerticalLine, StrokeStyle style, Color color)
+{
+    // Do a rect fill of our endpoints. This ensures we always have the
+    // appearance of being a border.
+    if (style == DashedStroke) {
+        if (isVerticalLine) {
+            painter->fillRect(FloatRect(p1.x() - width / 2, p1.y() - width, width, width), QColor(color));
+            painter->fillRect(FloatRect(p2.x() - width / 2, p2.y(), width, width), QColor(color));
+        } else {
+            painter->fillRect(FloatRect(p1.x() - width, p1.y() - width / 2, width, width), QColor(color));
+            painter->fillRect(FloatRect(p2.x(), p2.y() - width / 2, width, width), QColor(color));
+        }
+    }
+
+    // As per css spec a dotted stroke should be made of circles so we're
+    // drawing circles as endpoints.
+    if (style == DottedStroke) {
+        painter->setPen(Qt::NoPen);
+        painter->setBrush(QColor(color));
+        painter->drawEllipse(p1.x() - width / 2, p1.y() - width / 2, width, width);
+        painter->drawEllipse(p2.x() - width / 2, p2.y() - width / 2, width, width);
+    }
+}
+
 class GraphicsContextPlatformPrivate {
     WTF_MAKE_NONCOPYABLE(GraphicsContextPlatformPrivate); WTF_MAKE_FAST_ALLOCATED;
 public:
@@ -357,32 +392,40 @@
     p->setRenderHint(QPainter::Antialiasing, m_data->antiAliasingForRectsAndLines);
     adjustLineToPixelBoundaries(p1, p2, width, style);
 
+    Qt::PenCapStyle capStyle = Qt::FlatCap;
+    QVector<qreal> dashes;
     int patWidth = 0;
+
     switch (style) {
     case NoStroke:
     case SolidStroke:
         break;
-    case DottedStroke:
+    case DottedStroke: {
+        capStyle = Qt::RoundCap;
         patWidth = static_cast<int>(width);
+        // The actual length of one line element can not be set to zero and at 0.1 the dots
+        // are still slightly elongated. Setting it to 0.01 will make it look like the
+        // line endings are being stuck together, close enough to look like a circle.
+        // For the distance of the line elements we subtract the small amount again.
+        const qreal lineElementLength = 0.01;
+        dashes << lineElementLength << qreal(2 * patWidth) / width - lineElementLength;
+        adjustPointsForDottedLine(p1, p2, width, isVerticalLine);
         break;
+    }
     case DashedStroke:
+        capStyle = Qt::FlatCap;
         patWidth = 3 * static_cast<int>(width);
+        dashes << qreal(patWidth) / width << qreal(patWidth) / width;
         break;
     }
 
     if (patWidth) {
         p->save();
 
-        // Do a rect fill of our endpoints.  This ensures we always have the
-        // appearance of being a border.  We then draw the actual dotted/dashed line.
-        if (isVerticalLine) {
-            p->fillRect(FloatRect(p1.x() - width / 2, p1.y() - width, width, width), QColor(color));
-            p->fillRect(FloatRect(p2.x() - width / 2, p2.y(), width, width), QColor(color));
-        } else {
-            p->fillRect(FloatRect(p1.x() - width, p1.y() - width / 2, width, width), QColor(color));
-            p->fillRect(FloatRect(p2.x(), p2.y() - width / 2, width, width), QColor(color));
-        }
+        QPen pen = p->pen();
 
+        drawLineEndpointsForStyle(p, p1, p2, width, isVerticalLine, style, color);
+
         // Example: 80 pixels with a width of 30 pixels.
         // Remainder is 20.  The maximum pixels of line we could paint
         // will be 50 pixels.
@@ -411,12 +454,8 @@
             }
         }
 
-        QVector<qreal> dashes;
-        dashes << qreal(patWidth) / width << qreal(patWidth) / width;
-
-        QPen pen = p->pen();
         pen.setWidthF(width);
-        pen.setCapStyle(Qt::FlatCap);
+        pen.setCapStyle(capStyle);
         pen.setDashPattern(dashes);
         pen.setDashOffset(patternOffset / width);
         p->setPen(pen);
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to