Title: [199727] trunk/Source/WebCore
Revision
199727
Author
[email protected]
Date
2016-04-19 08:10:36 -0700 (Tue, 19 Apr 2016)

Log Message

[Cairo] GraphicsContext::drawFocusRing methods are not consistent to each other
https://bugs.webkit.org/show_bug.cgi?id=156742

Reviewed by Martin Robinson.

We are rendering the focus ring differently depending on whether a path is used or a vector of rectangles. This
is causing that some reftests fail because they assume we always render the focus ring the same way. For example
fast/images/image-map-outline-in-positioned-container.html, when rendering the test
GraphicsContext::drawFocusRing is called with a path, and when rendering the reference it's called with a vector
of rectangles, producing different results.

* platform/graphics/cairo/GraphicsContextCairo.cpp:
(WebCore::GraphicsContext::drawFocusRing): When receiving a vector of rectangles, build a Path from the given
rectangles and call drawFocusRing() with the built path to ensure consistency.

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (199726 => 199727)


--- trunk/Source/WebCore/ChangeLog	2016-04-19 14:11:19 UTC (rev 199726)
+++ trunk/Source/WebCore/ChangeLog	2016-04-19 15:10:36 UTC (rev 199727)
@@ -1,3 +1,20 @@
+2016-04-19  Carlos Garcia Campos  <[email protected]>
+
+        [Cairo] GraphicsContext::drawFocusRing methods are not consistent to each other
+        https://bugs.webkit.org/show_bug.cgi?id=156742
+
+        Reviewed by Martin Robinson.
+
+        We are rendering the focus ring differently depending on whether a path is used or a vector of rectangles. This
+        is causing that some reftests fail because they assume we always render the focus ring the same way. For example
+        fast/images/image-map-outline-in-positioned-container.html, when rendering the test
+        GraphicsContext::drawFocusRing is called with a path, and when rendering the reference it's called with a vector
+        of rectangles, producing different results.
+
+        * platform/graphics/cairo/GraphicsContextCairo.cpp:
+        (WebCore::GraphicsContext::drawFocusRing): When receiving a vector of rectangles, build a Path from the given
+        rectangles and call drawFocusRing() with the built path to ensure consistency.
+
 2016-04-19  Antti Koivisto  <[email protected]>
 
         Move FontSelectorClient to a file of its own

Modified: trunk/Source/WebCore/platform/graphics/cairo/GraphicsContextCairo.cpp (199726 => 199727)


--- trunk/Source/WebCore/platform/graphics/cairo/GraphicsContextCairo.cpp	2016-04-19 14:11:19 UTC (rev 199726)
+++ trunk/Source/WebCore/platform/graphics/cairo/GraphicsContextCairo.cpp	2016-04-19 15:10:36 UTC (rev 199727)
@@ -599,11 +599,21 @@
 
     cairo_t* cr = platformContext()->cr();
     cairo_save(cr);
+    cairo_push_group(cr);
     appendWebCorePathToCairoContext(cr, path);
     setSourceRGBAFromColor(cr, ringColor);
     cairo_set_line_width(cr, width);
     setPlatformStrokeStyle(focusRingStrokeStyle());
-    cairo_stroke(cr);
+    cairo_set_operator(cr, CAIRO_OPERATOR_OVER);
+    cairo_stroke_preserve(cr);
+
+    cairo_set_operator(cr, CAIRO_OPERATOR_CLEAR);
+    cairo_set_fill_rule(cr, CAIRO_FILL_RULE_WINDING);
+    cairo_fill(cr);
+
+    cairo_pop_group_to_source(cr);
+    cairo_set_operator(cr, CAIRO_OPERATOR_OVER);
+    cairo_paint(cr);
     cairo_restore(cr);
 }
 
@@ -612,43 +622,22 @@
     if (paintingDisabled())
         return;
 
-    cairo_t* cr = platformContext()->cr();
-    cairo_save(cr);
-    cairo_push_group(cr);
-    cairo_new_path(cr);
-
+    Path path;
 #if PLATFORM(GTK)
     for (const auto& rect : rects)
-        cairo_rectangle(cr, rect.x(), rect.y(), rect.width(), rect.height());
+        path.addRect(rect);
 #else
     unsigned rectCount = rects.size();
     int radius = (width - 1) / 2;
-    Path path;
+    Path subPath;
     for (unsigned i = 0; i < rectCount; ++i) {
         if (i > 0)
-            path.clear();
-        path.addRoundedRect(rects[i], FloatSize(radius, radius));
-        appendWebCorePathToCairoContext(cr, path);
+            subPath.clear();
+        subPath.addRoundedRect(rects[i], FloatSize(radius, radius));
+        path.addPath(subPath, AffineTransform());
     }
 #endif
-    Color ringColor = color;
-    adjustFocusRingColor(ringColor);
-    adjustFocusRingLineWidth(width);
-    setSourceRGBAFromColor(cr, ringColor);
-    cairo_set_line_width(cr, width);
-    setPlatformStrokeStyle(focusRingStrokeStyle());
-
-    cairo_set_operator(cr, CAIRO_OPERATOR_OVER);
-    cairo_stroke_preserve(cr);
-
-    cairo_set_operator(cr, CAIRO_OPERATOR_CLEAR);
-    cairo_set_fill_rule(cr, CAIRO_FILL_RULE_WINDING);
-    cairo_fill(cr);
-
-    cairo_pop_group_to_source(cr);
-    cairo_set_operator(cr, CAIRO_OPERATOR_OVER);
-    cairo_paint(cr);
-    cairo_restore(cr);
+    drawFocusRing(path, width, 0, color);
 }
 
 void GraphicsContext::drawLineForText(const FloatPoint& origin, float width, bool printing, bool doubleUnderlines)
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to