Changeset 241271 in webkit


Ignore:
Timestamp:
Feb 11, 2019 11:00:08 AM (5 years ago)
Author:
dbates@webkit.org
Message:

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().

Location:
trunk/Source/WebCore
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r241268 r241271  
     12019-02-11  Daniel Bates  <dabates@apple.com>
     2
     3        Separate out outline-style: auto user-agent appearance from Mac animated focus ring drawing
     4        https://bugs.webkit.org/show_bug.cgi?id=193591
     5
     6        Reviewed by Simon Fraser.
     7
     8        Untangle the Mac-specific concept of animated focus ring drawing from the concepts of using
     9        the fancy shrink-wrapped focus ring appearance and using the platform focus ring color when
     10        outline-style: auto.
     11
     12        No functionality changed. So, no new tests.
     13
     14        * platform/graphics/GraphicsContext.h:
     15        * platform/graphics/cocoa/GraphicsContextCocoa.mm:
     16        (WebCore::drawFocusRing):
     17        (WebCore::drawFocusRingToContextAtTime):
     18        Change some macro guards.
     19
     20        * rendering/RenderElement.cpp:
     21        (WebCore::usePlatformFocusRingColorForOutlineStyleAuto): Added.
     22        (WebCore::useShrinkWrappedFocusRingForOutlineStyleAuto): Added.
     23        (WebCore::drawFocusRing): Added.
     24        (WebCore::RenderElement::paintFocusRing): Write in terms of drawFocusRing().
     25
    1262019-02-11  Truitt Savell  <tsavell@apple.com>
    227
  • trunk/Source/WebCore/platform/graphics/GraphicsContext.h

    r240174 r241271  
    447447    void drawFocusRing(const Vector<FloatRect>&, float width, float offset, const Color&);
    448448    void drawFocusRing(const Path&, float width, float offset, const Color&);
    449 
    450     // FIXME: The following functions should only be compiled for Mac. See <https://bugs.webkit.org/show_bug.cgi?id=193591>.
    451 #if PLATFORM(COCOA)
     449#if PLATFORM(MAC)
    452450    void drawFocusRing(const Path&, double timeOffset, bool& needsRedraw, const Color&);
    453451    void drawFocusRing(const Vector<FloatRect>&, double timeOffset, bool& needsRedraw, const Color&);
  • trunk/Source/WebCore/platform/graphics/cocoa/GraphicsContextCocoa.mm

    r240174 r241271  
    9696}
    9797
    98 static void drawFocusRing(CGContextRef context, const Color& color)
     98inline static void drawFocusRing(CGContextRef context, const Color& color)
    9999{
    100100    drawFocusRingAtTime(context, std::numeric_limits<double>::max(), color);
     
    106106    CGContextAddPath(context, focusRingPath);
    107107    drawFocusRing(context, color);
    108 }
    109 
    110 static bool drawFocusRingToContextAtTime(CGContextRef context, CGPathRef focusRingPath, double timeOffset, const Color& color)
    111 {
    112     UNUSED_PARAM(timeOffset);
    113     CGContextBeginPath(context);
    114     CGContextAddPath(context, focusRingPath);
    115     return drawFocusRingAtTime(context, std::numeric_limits<double>::max(), color);
    116108}
    117109
     
    138130}
    139131
    140 // FIXME: The following functions should only be compiled for Mac. See <https://bugs.webkit.org/show_bug.cgi?id=193591>.
    141 #if ENABLE(FULL_KEYBOARD_ACCESS)
     132#if PLATFORM(MAC)
     133
     134static bool drawFocusRingToContextAtTime(CGContextRef context, CGPathRef focusRingPath, double timeOffset, const Color& color)
     135{
     136    UNUSED_PARAM(timeOffset);
     137    CGContextBeginPath(context);
     138    CGContextAddPath(context, focusRingPath);
     139    return drawFocusRingAtTime(context, std::numeric_limits<double>::max(), color);
     140}
    142141
    143142void GraphicsContext::drawFocusRing(const Path& path, double timeOffset, bool& needsRedraw, const Color& color)
     
    167166}
    168167
    169 #endif
     168#endif // PLATFORM(MAC)
    170169
    171170void GraphicsContext::drawFocusRing(const Vector<FloatRect>& rects, float width, float offset, const Color& color)
  • trunk/Source/WebCore/rendering/RenderElement.cpp

    r240185 r241271  
    18101810}
    18111811
     1812static bool usePlatformFocusRingColorForOutlineStyleAuto()
     1813{
     1814#if PLATFORM(COCOA)
     1815    return true;
     1816#else
     1817    return false;
     1818#endif
     1819}
     1820
     1821static bool useShrinkWrappedFocusRingForOutlineStyleAuto()
     1822{
     1823#if PLATFORM(COCOA)
     1824    return true;
     1825#else
     1826    return false;
     1827#endif
     1828}
     1829
     1830static bool drawFocusRing(GraphicsContext& context, Page& page, const Path& path, const RenderStyle& style, Color focusRingColor)
     1831{
     1832    bool needsRepaint = false;
     1833#if PLATFORM(MAC)
     1834    context.drawFocusRing(path, page.focusController().timeSinceFocusWasSet().seconds(), needsRepaint, focusRingColor);
     1835    UNUSED_PARAM(style);
     1836#else
     1837    context.drawFocusRing(path, style.outlineWidth(), style.outlineOffset(), focusRingColor);
     1838    UNUSED_PARAM(page);
     1839#endif
     1840    return needsRepaint;
     1841}
     1842
     1843static bool drawFocusRing(GraphicsContext& context, Page& page, Vector<FloatRect> rects, const RenderStyle& style, Color focusRingColor)
     1844{
     1845    bool needsRepaint = false;
     1846#if PLATFORM(MAC)
     1847    context.drawFocusRing(rects, page.focusController().timeSinceFocusWasSet().seconds(), needsRepaint, focusRingColor);
     1848    UNUSED_PARAM(style);
     1849#else
     1850    context.drawFocusRing(rects, style.outlineWidth(), style.outlineOffset(), focusRingColor);
     1851    UNUSED_PARAM(page);
     1852#endif
     1853    return needsRepaint;
     1854}
     1855
     1856
    18121857void RenderElement::paintFocusRing(PaintInfo& paintInfo, const RenderStyle& style, const Vector<LayoutRect>& focusRingRects)
    18131858{
     
    18201865        pixelSnappedFocusRingRects.append(snapRectToDevicePixels(rect, deviceScaleFactor));
    18211866    }
    1822     // FIXME: The following code should only be compiled for Mac. See <https://bugs.webkit.org/show_bug.cgi?id=193591>.
    1823 #if ENABLE(FULL_KEYBOARD_ACCESS)
     1867    Color focusRingColor = usePlatformFocusRingColorForOutlineStyleAuto() ? RenderTheme::singleton().focusRingColor(styleColorOptions()) : style.visitedDependentColorWithColorFilter(CSSPropertyOutlineColor);
    18241868    bool needsRepaint;
    1825     if (style.hasBorderRadius()) {
     1869    if (useShrinkWrappedFocusRingForOutlineStyleAuto() && style.hasBorderRadius()) {
    18261870        Path path = PathUtilities::pathWithShrinkWrappedRectsForOutline(pixelSnappedFocusRingRects, style.border(), outlineOffset, style.direction(), style.writingMode(),
    18271871            document().deviceScaleFactor());
     
    18301874                path.addRect(rect);
    18311875        }
    1832         paintInfo.context().drawFocusRing(path, page().focusController().timeSinceFocusWasSet().seconds(), needsRepaint, RenderTheme::singleton().focusRingColor(styleColorOptions()));
     1876        needsRepaint = drawFocusRing(paintInfo.context(), page(), path, style, focusRingColor);
    18331877    } else
    1834         paintInfo.context().drawFocusRing(pixelSnappedFocusRingRects, page().focusController().timeSinceFocusWasSet().seconds(), needsRepaint, RenderTheme::singleton().focusRingColor(styleColorOptions()));
     1878        needsRepaint = drawFocusRing(paintInfo.context(), page(), pixelSnappedFocusRingRects, style, focusRingColor);
    18351879    if (needsRepaint)
    18361880        page().focusController().setFocusedElementNeedsRepaint();
    1837 #else
    1838     paintInfo.context().drawFocusRing(pixelSnappedFocusRingRects, style.outlineWidth(), style.outlineOffset(), style.visitedDependentColorWithColorFilter(CSSPropertyOutlineColor));
    1839 #endif
    18401881}
    18411882
Note: See TracChangeset for help on using the changeset viewer.