Diff
Modified: trunk/Source/WebCore/ChangeLog (241270 => 241271)
--- trunk/Source/WebCore/ChangeLog 2019-02-11 18:49:10 UTC (rev 241270)
+++ trunk/Source/WebCore/ChangeLog 2019-02-11 19:00:08 UTC (rev 241271)
@@ -1,3 +1,28 @@
+2019-02-11 Daniel Bates <[email protected]>
+
+ Separate out outline-style: auto user-agent appearance from Mac animated focus ring drawing
+ https://bugs.webkit.org/show_bug.cgi?id=193591
+
+ Reviewed by Simon Fraser.
+
+ Untangle the Mac-specific concept of animated focus ring drawing from the concepts of using
+ the fancy shrink-wrapped focus ring appearance and using the platform focus ring color when
+ outline-style: auto.
+
+ No functionality changed. So, no new tests.
+
+ * platform/graphics/GraphicsContext.h:
+ * platform/graphics/cocoa/GraphicsContextCocoa.mm:
+ (WebCore::drawFocusRing):
+ (WebCore::drawFocusRingToContextAtTime):
+ Change some macro guards.
+
+ * rendering/RenderElement.cpp:
+ (WebCore::usePlatformFocusRingColorForOutlineStyleAuto): Added.
+ (WebCore::useShrinkWrappedFocusRingForOutlineStyleAuto): Added.
+ (WebCore::drawFocusRing): Added.
+ (WebCore::RenderElement::paintFocusRing): Write in terms of drawFocusRing().
+
2019-02-11 Truitt Savell <[email protected]>
Unreviewed, rolling out r241229.
Modified: trunk/Source/WebCore/platform/graphics/GraphicsContext.h (241270 => 241271)
--- trunk/Source/WebCore/platform/graphics/GraphicsContext.h 2019-02-11 18:49:10 UTC (rev 241270)
+++ trunk/Source/WebCore/platform/graphics/GraphicsContext.h 2019-02-11 19:00:08 UTC (rev 241271)
@@ -446,9 +446,7 @@
void drawFocusRing(const Vector<FloatRect>&, float width, float offset, const Color&);
void drawFocusRing(const Path&, float width, float offset, const Color&);
-
- // FIXME: The following functions should only be compiled for Mac. See <https://bugs.webkit.org/show_bug.cgi?id=193591>.
-#if PLATFORM(COCOA)
+#if PLATFORM(MAC)
void drawFocusRing(const Path&, double timeOffset, bool& needsRedraw, const Color&);
void drawFocusRing(const Vector<FloatRect>&, double timeOffset, bool& needsRedraw, const Color&);
#endif
Modified: trunk/Source/WebCore/platform/graphics/cocoa/GraphicsContextCocoa.mm (241270 => 241271)
--- trunk/Source/WebCore/platform/graphics/cocoa/GraphicsContextCocoa.mm 2019-02-11 18:49:10 UTC (rev 241270)
+++ trunk/Source/WebCore/platform/graphics/cocoa/GraphicsContextCocoa.mm 2019-02-11 19:00:08 UTC (rev 241271)
@@ -95,7 +95,7 @@
return needsRepaint;
}
-static void drawFocusRing(CGContextRef context, const Color& color)
+inline static void drawFocusRing(CGContextRef context, const Color& color)
{
drawFocusRingAtTime(context, std::numeric_limits<double>::max(), color);
}
@@ -107,14 +107,6 @@
drawFocusRing(context, color);
}
-static bool drawFocusRingToContextAtTime(CGContextRef context, CGPathRef focusRingPath, double timeOffset, const Color& color)
-{
- UNUSED_PARAM(timeOffset);
- CGContextBeginPath(context);
- CGContextAddPath(context, focusRingPath);
- return drawFocusRingAtTime(context, std::numeric_limits<double>::max(), color);
-}
-
#endif // ENABLE(FULL_KEYBOARD_ACCESS)
void GraphicsContext::drawFocusRing(const Path& path, float width, float offset, const Color& color)
@@ -137,9 +129,16 @@
#endif
}
-// FIXME: The following functions should only be compiled for Mac. See <https://bugs.webkit.org/show_bug.cgi?id=193591>.
-#if ENABLE(FULL_KEYBOARD_ACCESS)
+#if PLATFORM(MAC)
+static bool drawFocusRingToContextAtTime(CGContextRef context, CGPathRef focusRingPath, double timeOffset, const Color& color)
+{
+ UNUSED_PARAM(timeOffset);
+ CGContextBeginPath(context);
+ CGContextAddPath(context, focusRingPath);
+ return drawFocusRingAtTime(context, std::numeric_limits<double>::max(), color);
+}
+
void GraphicsContext::drawFocusRing(const Path& path, double timeOffset, bool& needsRedraw, const Color& color)
{
if (paintingDisabled() || path.isNull())
@@ -166,7 +165,7 @@
needsRedraw = drawFocusRingToContextAtTime(platformContext(), focusRingPath.get(), timeOffset, color);
}
-#endif
+#endif // PLATFORM(MAC)
void GraphicsContext::drawFocusRing(const Vector<FloatRect>& rects, float width, float offset, const Color& color)
{
Modified: trunk/Source/WebCore/rendering/RenderElement.cpp (241270 => 241271)
--- trunk/Source/WebCore/rendering/RenderElement.cpp 2019-02-11 18:49:10 UTC (rev 241270)
+++ trunk/Source/WebCore/rendering/RenderElement.cpp 2019-02-11 19:00:08 UTC (rev 241271)
@@ -1809,6 +1809,51 @@
}
}
+static bool usePlatformFocusRingColorForOutlineStyleAuto()
+{
+#if PLATFORM(COCOA)
+ return true;
+#else
+ return false;
+#endif
+}
+
+static bool useShrinkWrappedFocusRingForOutlineStyleAuto()
+{
+#if PLATFORM(COCOA)
+ return true;
+#else
+ return false;
+#endif
+}
+
+static bool drawFocusRing(GraphicsContext& context, Page& page, const Path& path, const RenderStyle& style, Color focusRingColor)
+{
+ bool needsRepaint = false;
+#if PLATFORM(MAC)
+ context.drawFocusRing(path, page.focusController().timeSinceFocusWasSet().seconds(), needsRepaint, focusRingColor);
+ UNUSED_PARAM(style);
+#else
+ context.drawFocusRing(path, style.outlineWidth(), style.outlineOffset(), focusRingColor);
+ UNUSED_PARAM(page);
+#endif
+ return needsRepaint;
+}
+
+static bool drawFocusRing(GraphicsContext& context, Page& page, Vector<FloatRect> rects, const RenderStyle& style, Color focusRingColor)
+{
+ bool needsRepaint = false;
+#if PLATFORM(MAC)
+ context.drawFocusRing(rects, page.focusController().timeSinceFocusWasSet().seconds(), needsRepaint, focusRingColor);
+ UNUSED_PARAM(style);
+#else
+ context.drawFocusRing(rects, style.outlineWidth(), style.outlineOffset(), focusRingColor);
+ UNUSED_PARAM(page);
+#endif
+ return needsRepaint;
+}
+
+
void RenderElement::paintFocusRing(PaintInfo& paintInfo, const RenderStyle& style, const Vector<LayoutRect>& focusRingRects)
{
ASSERT(style.outlineStyleIsAuto() == OutlineIsAuto::On);
@@ -1819,10 +1864,9 @@
rect.inflate(outlineOffset);
pixelSnappedFocusRingRects.append(snapRectToDevicePixels(rect, deviceScaleFactor));
}
- // FIXME: The following code should only be compiled for Mac. See <https://bugs.webkit.org/show_bug.cgi?id=193591>.
-#if ENABLE(FULL_KEYBOARD_ACCESS)
+ Color focusRingColor = usePlatformFocusRingColorForOutlineStyleAuto() ? RenderTheme::singleton().focusRingColor(styleColorOptions()) : style.visitedDependentColorWithColorFilter(CSSPropertyOutlineColor);
bool needsRepaint;
- if (style.hasBorderRadius()) {
+ if (useShrinkWrappedFocusRingForOutlineStyleAuto() && style.hasBorderRadius()) {
Path path = PathUtilities::pathWithShrinkWrappedRectsForOutline(pixelSnappedFocusRingRects, style.border(), outlineOffset, style.direction(), style.writingMode(),
document().deviceScaleFactor());
if (path.isEmpty()) {
@@ -1829,14 +1873,11 @@
for (auto rect : pixelSnappedFocusRingRects)
path.addRect(rect);
}
- paintInfo.context().drawFocusRing(path, page().focusController().timeSinceFocusWasSet().seconds(), needsRepaint, RenderTheme::singleton().focusRingColor(styleColorOptions()));
+ needsRepaint = drawFocusRing(paintInfo.context(), page(), path, style, focusRingColor);
} else
- paintInfo.context().drawFocusRing(pixelSnappedFocusRingRects, page().focusController().timeSinceFocusWasSet().seconds(), needsRepaint, RenderTheme::singleton().focusRingColor(styleColorOptions()));
+ needsRepaint = drawFocusRing(paintInfo.context(), page(), pixelSnappedFocusRingRects, style, focusRingColor);
if (needsRepaint)
page().focusController().setFocusedElementNeedsRepaint();
-#else
- paintInfo.context().drawFocusRing(pixelSnappedFocusRingRects, style.outlineWidth(), style.outlineOffset(), style.visitedDependentColorWithColorFilter(CSSPropertyOutlineColor));
-#endif
}
void RenderElement::paintOutline(PaintInfo& paintInfo, const LayoutRect& paintRect)