[Outline: auto] Fractional radius value could result in non-renderable rounded border.
authorzalan@apple.com <zalan@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 14 Mar 2016 18:01:24 +0000 (18:01 +0000)
committerzalan@apple.com <zalan@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 14 Mar 2016 18:01:24 +0000 (18:01 +0000)
https://bugs.webkit.org/show_bug.cgi?id=155420

Reviewed by Tim Horton.

RoundedRect::pixelSnappedRoundedRectForPainting ensures that the rounded rect is always renderable.

Source/WebCore:

Test: fast/inline/hidpi-outline-auto-with-fractional-radius.html

* platform/graphics/PathUtilities.cpp:
(WebCore::PathUtilities::pathWithShrinkWrappedRectsForOutline):
* platform/graphics/PathUtilities.h:
* rendering/RenderElement.cpp:
(WebCore::RenderElement::paintFocusRing):

LayoutTests:

* fast/inline/hidpi-outline-auto-with-fractional-radius-expected.html: Added.
* fast/inline/hidpi-outline-auto-with-fractional-radius.html: Added.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@198140 268f45cc-cd09-0410-ab3c-d52691b4dbfc

LayoutTests/ChangeLog
LayoutTests/fast/inline/hidpi-outline-auto-with-fractional-radius-expected.html [new file with mode: 0644]
LayoutTests/fast/inline/hidpi-outline-auto-with-fractional-radius.html [new file with mode: 0644]
Source/WebCore/ChangeLog
Source/WebCore/platform/graphics/PathUtilities.cpp
Source/WebCore/platform/graphics/PathUtilities.h
Source/WebCore/rendering/RenderElement.cpp

index a00da30..265d64b 100644 (file)
@@ -1,5 +1,17 @@
 2016-03-14  Zalan Bujtas  <zalan@apple.com>
 
+        [Outline: auto] Fractional radius value could result in non-renderable rounded border.
+        https://bugs.webkit.org/show_bug.cgi?id=155420
+
+        Reviewed by Tim Horton.
+
+        RoundedRect::pixelSnappedRoundedRectForPainting ensures that the rounded rect is always renderable.
+
+        * fast/inline/hidpi-outline-auto-with-fractional-radius-expected.html: Added.
+        * fast/inline/hidpi-outline-auto-with-fractional-radius.html: Added.
+
+2016-03-14  Zalan Bujtas  <zalan@apple.com>
+
         Outline: auto has sharp corners with single line contenteditable.
         https://bugs.webkit.org/show_bug.cgi?id=155418
 
diff --git a/LayoutTests/fast/inline/hidpi-outline-auto-with-fractional-radius-expected.html b/LayoutTests/fast/inline/hidpi-outline-auto-with-fractional-radius-expected.html
new file mode 100644 (file)
index 0000000..ffcef13
--- /dev/null
@@ -0,0 +1,7 @@
+<!DOCTYPE html>
+<html>
+<head>
+<title>This tests hugging outlines with fractional radius.</title>
+</head>
+<body></body>
+</html>
diff --git a/LayoutTests/fast/inline/hidpi-outline-auto-with-fractional-radius.html b/LayoutTests/fast/inline/hidpi-outline-auto-with-fractional-radius.html
new file mode 100644 (file)
index 0000000..f77367c
--- /dev/null
@@ -0,0 +1,35 @@
+<!DOCTYPE html>
+<html>
+<head>
+<title>This tests hugging outlines with fractional radius.</title>
+<style>
+div {
+    position: absolute;
+}
+
+.outline-radius {
+    outline-style: auto;
+    border-top-right-radius: 10px 87.5px;
+    border-bottom-right-radius: 10px;
+    top: 20px;
+    left: 20px;
+       width: 300px;
+       height: 40px;
+}
+
+.cover {
+    border: 7px solid white;
+    border-top-right-radius: 10px 23px;
+    border-bottom-right-radius: 10px;
+    top: 15px;
+    left: 16px;
+    width: 295px;
+    height: 35px;
+}
+</style>
+</head>
+<body>
+<div class=outline-radius></div>
+<div class=cover></div>
+</body>
+</html>
index c987a46..67e83ab 100644 (file)
@@ -1,5 +1,22 @@
 2016-03-14  Zalan Bujtas  <zalan@apple.com>
 
+        [Outline: auto] Fractional radius value could result in non-renderable rounded border.
+        https://bugs.webkit.org/show_bug.cgi?id=155420
+
+        Reviewed by Tim Horton.
+
+        RoundedRect::pixelSnappedRoundedRectForPainting ensures that the rounded rect is always renderable.
+
+        Test: fast/inline/hidpi-outline-auto-with-fractional-radius.html
+
+        * platform/graphics/PathUtilities.cpp:
+        (WebCore::PathUtilities::pathWithShrinkWrappedRectsForOutline):
+        * platform/graphics/PathUtilities.h:
+        * rendering/RenderElement.cpp:
+        (WebCore::RenderElement::paintFocusRing):
+
+2016-03-14  Zalan Bujtas  <zalan@apple.com>
+
         Outline: auto has sharp corners with single line contenteditable.
         https://bugs.webkit.org/show_bug.cgi?id=155418
 
index d7c322c..cf6efde 100644 (file)
@@ -484,7 +484,7 @@ static Optional<FloatRect> rectFromPolygon(const FloatPointGraph::Polygon& poly)
 }
 
 Path PathUtilities::pathWithShrinkWrappedRectsForOutline(const Vector<FloatRect>& rects, const BorderData& borderData, float outlineOffset, TextDirection direction,
-    WritingMode writingMode)
+    WritingMode writingMode, float deviceScaleFactor)
 {
     ASSERT(borderData.hasBorderRadius());
     FloatSize topLeftRadius = FloatSize(borderData.topLeft().width().value(), borderData.topLeft().height().value());
@@ -492,13 +492,14 @@ Path PathUtilities::pathWithShrinkWrappedRectsForOutline(const Vector<FloatRect>
     FloatSize bottomRightRadius = FloatSize(borderData.bottomRight().width().value(), borderData.bottomRight().height().value());
     FloatSize bottomLeftRadius = FloatSize(borderData.bottomLeft().width().value(), borderData.bottomLeft().height().value());
 
-    auto roundedRect = [topLeftRadius, topRightRadius, bottomRightRadius, bottomLeftRadius, outlineOffset] (const FloatRect& rect)
+    auto roundedRect = [topLeftRadius, topRightRadius, bottomRightRadius, bottomLeftRadius, outlineOffset, deviceScaleFactor] (const FloatRect& rect)
     {
         auto radii = adjustedtRadiiForHuggingCurve(topLeftRadius, topRightRadius, bottomLeftRadius, bottomRightRadius, outlineOffset);
         radii.scale(calcBorderRadiiConstraintScaleFor(rect, radii));
-
+        RoundedRect roundedRect(LayoutRect(rect),
+            RoundedRect::Radii(LayoutSize(radii.topLeft()), LayoutSize(radii.topRight()), LayoutSize(radii.bottomLeft()), LayoutSize(radii.bottomRight())));
         Path path;
-        path.addRoundedRect(FloatRoundedRect(rect, radii));
+        path.addRoundedRect(roundedRect.pixelSnappedRoundedRectForPainting(deviceScaleFactor));
         return path;
     };
 
index 43e91da..500041a 100644 (file)
@@ -38,7 +38,7 @@ public:
     WEBCORE_EXPORT static Path pathWithShrinkWrappedRects(const Vector<FloatRect>& rects, float radius);
     WEBCORE_EXPORT static Vector<Path> pathsWithShrinkWrappedRects(const Vector<FloatRect>& rects, float radius);
 
-    static Path pathWithShrinkWrappedRectsForOutline(const Vector<FloatRect>&, const BorderData&, float outlineOffset, TextDirection, WritingMode);
+    static Path pathWithShrinkWrappedRectsForOutline(const Vector<FloatRect>&, const BorderData&, float outlineOffset, TextDirection, WritingMode, float deviceScaleFactor);
 };
 
 }
index 524372f..8c09709 100644 (file)
@@ -2098,7 +2098,8 @@ void RenderElement::paintFocusRing(PaintInfo& paintInfo, const LayoutPoint& pain
 #if PLATFORM(MAC)
     bool needsRepaint;
     if (style.hasBorderRadius()) {
-        Path path = PathUtilities::pathWithShrinkWrappedRectsForOutline(pixelSnappedFocusRingRects, style.border(), outlineOffset, style.direction(), style.writingMode());
+        Path path = PathUtilities::pathWithShrinkWrappedRectsForOutline(pixelSnappedFocusRingRects, style.border(), outlineOffset, style.direction(), style.writingMode(),
+            document().deviceScaleFactor());
         if (path.isEmpty()) {
             for (auto rect : pixelSnappedFocusRingRects)
                 path.addRect(rect);