Skip to content
Permalink
Browse files
[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.

Canonical link: https://commits.webkit.org/174862@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@199727 268f45cc-cd09-0410-ab3c-d52691b4dbfc
  • Loading branch information
carlosgcampos committed Apr 19, 2016
1 parent 06485fd commit 20ddae2366efa452ea593d638896421d6c096682
Showing 2 changed files with 35 additions and 29 deletions.
@@ -1,3 +1,20 @@
2016-04-19 Carlos Garcia Campos <cgarcia@igalia.com>

[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 <antti@apple.com>

Move FontSelectorClient to a file of its own
@@ -599,11 +599,21 @@ void GraphicsContext::drawFocusRing(const Path& path, float width, float /* offs

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 @@ void GraphicsContext::drawFocusRing(const Vector<FloatRect>& rects, float width,
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)

0 comments on commit 20ddae2

Please sign in to comment.