Changeset 241271 in webkit
- Timestamp:
- Feb 11, 2019 11:00:08 AM (5 years ago)
- Location:
- trunk/Source/WebCore
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r241268 r241271 1 2019-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 1 26 2019-02-11 Truitt Savell <tsavell@apple.com> 2 27 -
trunk/Source/WebCore/platform/graphics/GraphicsContext.h
r240174 r241271 447 447 void drawFocusRing(const Vector<FloatRect>&, float width, float offset, const Color&); 448 448 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) 452 450 void drawFocusRing(const Path&, double timeOffset, bool& needsRedraw, const Color&); 453 451 void drawFocusRing(const Vector<FloatRect>&, double timeOffset, bool& needsRedraw, const Color&); -
trunk/Source/WebCore/platform/graphics/cocoa/GraphicsContextCocoa.mm
r240174 r241271 96 96 } 97 97 98 static void drawFocusRing(CGContextRef context, const Color& color)98 inline static void drawFocusRing(CGContextRef context, const Color& color) 99 99 { 100 100 drawFocusRingAtTime(context, std::numeric_limits<double>::max(), color); … … 106 106 CGContextAddPath(context, focusRingPath); 107 107 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);116 108 } 117 109 … … 138 130 } 139 131 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 134 static 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 } 142 141 143 142 void GraphicsContext::drawFocusRing(const Path& path, double timeOffset, bool& needsRedraw, const Color& color) … … 167 166 } 168 167 169 #endif 168 #endif // PLATFORM(MAC) 170 169 171 170 void GraphicsContext::drawFocusRing(const Vector<FloatRect>& rects, float width, float offset, const Color& color) -
trunk/Source/WebCore/rendering/RenderElement.cpp
r240185 r241271 1810 1810 } 1811 1811 1812 static bool usePlatformFocusRingColorForOutlineStyleAuto() 1813 { 1814 #if PLATFORM(COCOA) 1815 return true; 1816 #else 1817 return false; 1818 #endif 1819 } 1820 1821 static bool useShrinkWrappedFocusRingForOutlineStyleAuto() 1822 { 1823 #if PLATFORM(COCOA) 1824 return true; 1825 #else 1826 return false; 1827 #endif 1828 } 1829 1830 static 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 1843 static 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 1812 1857 void RenderElement::paintFocusRing(PaintInfo& paintInfo, const RenderStyle& style, const Vector<LayoutRect>& focusRingRects) 1813 1858 { … … 1820 1865 pixelSnappedFocusRingRects.append(snapRectToDevicePixels(rect, deviceScaleFactor)); 1821 1866 } 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); 1824 1868 bool needsRepaint; 1825 if ( style.hasBorderRadius()) {1869 if (useShrinkWrappedFocusRingForOutlineStyleAuto() && style.hasBorderRadius()) { 1826 1870 Path path = PathUtilities::pathWithShrinkWrappedRectsForOutline(pixelSnappedFocusRingRects, style.border(), outlineOffset, style.direction(), style.writingMode(), 1827 1871 document().deviceScaleFactor()); … … 1830 1874 path.addRect(rect); 1831 1875 } 1832 paintInfo.context().drawFocusRing(path, page().focusController().timeSinceFocusWasSet().seconds(), needsRepaint, RenderTheme::singleton().focusRingColor(styleColorOptions()));1876 needsRepaint = drawFocusRing(paintInfo.context(), page(), path, style, focusRingColor); 1833 1877 } else 1834 paintInfo.context().drawFocusRing(pixelSnappedFocusRingRects, page().focusController().timeSinceFocusWasSet().seconds(), needsRepaint, RenderTheme::singleton().focusRingColor(styleColorOptions()));1878 needsRepaint = drawFocusRing(paintInfo.context(), page(), pixelSnappedFocusRingRects, style, focusRingColor); 1835 1879 if (needsRepaint) 1836 1880 page().focusController().setFocusedElementNeedsRepaint(); 1837 #else1838 paintInfo.context().drawFocusRing(pixelSnappedFocusRingRects, style.outlineWidth(), style.outlineOffset(), style.visitedDependentColorWithColorFilter(CSSPropertyOutlineColor));1839 #endif1840 1881 } 1841 1882
Note: See TracChangeset
for help on using the changeset viewer.