WebKit Bugzilla
Attachment 359536 Details for
Bug 193591
: Separate out outline-style: auto user-agent appearance from Mac animated focus ring drawing
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
[patch]
Patch
bug-193591-20190118140109.patch (text/plain), 10.24 KB, created by
Daniel Bates
on 2019-01-18 14:01:10 PST
(
hide
)
Description:
Patch
Filename:
MIME Type:
Creator:
Daniel Bates
Created:
2019-01-18 14:01:10 PST
Size:
10.24 KB
patch
obsolete
>Subversion Revision: 240041 >diff --git a/Source/WebCore/ChangeLog b/Source/WebCore/ChangeLog >index 87a748a0ebc047e43157d29a237ad6e902bf0ad1..51d9222942ffb18b953ef730b3957c181ffc6811 100644 >--- a/Source/WebCore/ChangeLog >+++ b/Source/WebCore/ChangeLog >@@ -1,3 +1,37 @@ >+2019-01-18 Daniel Bates <dabates@apple.com> >+ >+ 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 NOBODY (OOPS!). >+ >+ 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. >+ >+ * page/Settings.yaml: >+ * page/SettingsBase.cpp: >+ (WebCore::SettingsBase::defaultUsePlatformFocusRingColorForOutlineStyleAuto): Use the platform >+ focus ring color on Cocoa-based platforms. All other platforms will use the CSS outline-color. >+ (WebCore::SettingsBase::defaultUseShrinkWrappedFocusRingForOutlineStyleAuto): Enable the fancy >+ shrink wrapped focus ring appearance on Cocoa-based platforms. Disable it - use a plain rectangle - >+ on all other platforms. >+ * page/SettingsBase.h: >+ >+ * platform/graphics/GraphicsContext.h: >+ * platform/graphics/cocoa/GraphicsContextCocoa.mm: >+ (WebCore::drawFocusRing): >+ (WebCore::drawFocusRingToContextAtTime): >+ Change some macro guards. >+ >+ * rendering/RenderElement.cpp: >+ (WebCore::RenderElement::paintFocusRing): Query the settings to determine whether to perform >+ fancy shrink-wrapping and whether to use the platform focus ring color over the CSS outline-color. >+ Only compile calls to the animated drawFocusRing() variants when building on Mac as this is the >+ only platform that supports them at the time of writing. >+ > 2019-01-18 Daniel Bates <dabates@apple.com> > > CSS auto focus-ring outlines don't render on iOS >diff --git a/Source/WebCore/page/Settings.yaml b/Source/WebCore/page/Settings.yaml >index 2b187e13593b4679c15a3b3c3d048d3aa2ba024c..bb4e92a49dcb924b07ca947ac385e9f9c4e5efa5 100644 >--- a/Source/WebCore/page/Settings.yaml >+++ b/Source/WebCore/page/Settings.yaml >@@ -791,3 +791,9 @@ videoQualityIncludesDisplayCompositingEnabled: > > editableImagesEnabled: > initial: false >+ >+usePlatformFocusRingColorForOutlineStyleAuto: >+ initial: defaultUsePlatformFocusRingColorForOutlineStyleAuto() >+ >+useShrinkWrappedFocusRingForOutlineStyleAuto: >+ initial: defaultUseShrinkWrappedFocusRingForOutlineStyleAuto() >diff --git a/Source/WebCore/page/SettingsBase.cpp b/Source/WebCore/page/SettingsBase.cpp >index cd4c4e8118f151520a2c02b2b41343fcedd2e782..4efe246cadbef788850585a52887b7c800c41c70 100644 >--- a/Source/WebCore/page/SettingsBase.cpp >+++ b/Source/WebCore/page/SettingsBase.cpp >@@ -103,6 +103,24 @@ bool SettingsBase::defaultDownloadableBinaryFontsEnabled() > #endif > } > >+bool SettingsBase::defaultUsePlatformFocusRingColorForOutlineStyleAuto() >+{ >+#if PLATFORM(COCOA) >+ return true; >+#else >+ return false; >+#endif >+} >+ >+bool SettingsBase::defaultUseShrinkWrappedFocusRingForOutlineStyleAuto() >+{ >+#if PLATFORM(COCOA) >+ return true; >+#else >+ return false; >+#endif >+} >+ > #if !PLATFORM(COCOA) > const String& SettingsBase::defaultMediaContentTypesRequiringHardwareSupport() > { >diff --git a/Source/WebCore/page/SettingsBase.h b/Source/WebCore/page/SettingsBase.h >index d6471c24d9ebc70da937afab59bcbad01e119dfd..dbd69301c8afa830de99acb0152c7b6bf56d11e3 100644 >--- a/Source/WebCore/page/SettingsBase.h >+++ b/Source/WebCore/page/SettingsBase.h >@@ -116,6 +116,9 @@ public: > WEBCORE_EXPORT static float defaultMinimumZoomFontSize(); > WEBCORE_EXPORT static bool defaultDownloadableBinaryFontsEnabled(); > >+ WEBCORE_EXPORT static bool defaultUsePlatformFocusRingColorForOutlineStyleAuto(); >+ WEBCORE_EXPORT static bool defaultUseShrinkWrappedFocusRingForOutlineStyleAuto(); >+ > static const unsigned defaultMaximumHTMLParserDOMTreeDepth = 512; > static const unsigned defaultMaximumRenderTreeDepth = 512; > >diff --git a/Source/WebCore/platform/graphics/GraphicsContext.h b/Source/WebCore/platform/graphics/GraphicsContext.h >index 9592143500def675b6e53149749f6fc3905c34ab..f1618b570c876283e2be8fd495066949134635d0 100644 >--- a/Source/WebCore/platform/graphics/GraphicsContext.h >+++ b/Source/WebCore/platform/graphics/GraphicsContext.h >@@ -447,9 +447,7 @@ public: > 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. Once we fix <https://bugs.webkit.org/show_bug.cgi?id=193581> >- // we will be in a position to only call these functions for Mac. >-#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 >diff --git a/Source/WebCore/platform/graphics/cocoa/GraphicsContextCocoa.mm b/Source/WebCore/platform/graphics/cocoa/GraphicsContextCocoa.mm >index 69860ee9d3feccbf7275cfcd39ff8dfbcd93a0f4..7e70e4649f2170617478bdba6f3eacd4cf71bb37 100644 >--- a/Source/WebCore/platform/graphics/cocoa/GraphicsContextCocoa.mm >+++ b/Source/WebCore/platform/graphics/cocoa/GraphicsContextCocoa.mm >@@ -95,7 +95,7 @@ static bool drawFocusRingAtTime(CGContextRef context, NSTimeInterval timeOffset, > 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 @@ static void drawFocusRingToContext(CGContextRef context, CGPathRef focusRingPath > 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,15 @@ void GraphicsContext::drawFocusRing(const Path& path, float width, float offset, > #endif > } > >-// FIXME: The following functions should only be compiled for Mac. Once we fix <https://bugs.webkit.org/show_bug.cgi?id=193581> >-// we will be in a position to only call these functions for Mac. >-#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) > { >diff --git a/Source/WebCore/rendering/RenderElement.cpp b/Source/WebCore/rendering/RenderElement.cpp >index 3641dd9ae2dd7ba986d5c115024f9f591e498c12..194abda2670b58c2ea813f0d49cb73a067b70875 100644 >--- a/Source/WebCore/rendering/RenderElement.cpp >+++ b/Source/WebCore/rendering/RenderElement.cpp >@@ -1819,26 +1819,29 @@ void RenderElement::paintFocusRing(PaintInfo& paintInfo, const RenderStyle& styl > rect.inflate(outlineOffset); > pixelSnappedFocusRingRects.append(snapRectToDevicePixels(rect, deviceScaleFactor)); > } >- // FIXME: The following code should only be compiled for Mac. Once we fix <https://bugs.webkit.org/show_bug.cgi?id=193581> >- // we can extract the platform-independent shrink-wrapping logic and only guard the calls to the repaint-aware drawFocusRing() >- // variants in PLATFORM(MAC). >-#if PLATFORM(COCOA) >- bool needsRepaint; >- if (style.hasBorderRadius()) { >+ Color focusRingColor = settings().usePlatformFocusRingColorForOutlineStyleAuto() ? RenderTheme::singleton().focusRingColor(styleColorOptions()) : style.visitedDependentColorWithColorFilter(CSSPropertyOutlineColor); >+ bool needsRepaint = false; >+ if (settings().useShrinkWrappedFocusRingForOutlineStyleAuto() && style.hasBorderRadius()) { > Path path = PathUtilities::pathWithShrinkWrappedRectsForOutline(pixelSnappedFocusRingRects, style.border(), outlineOffset, style.direction(), style.writingMode(), > document().deviceScaleFactor()); > if (path.isEmpty()) { > for (auto rect : pixelSnappedFocusRingRects) > path.addRect(rect); > } >- paintInfo.context().drawFocusRing(path, page().focusController().timeSinceFocusWasSet().seconds(), needsRepaint, RenderTheme::singleton().focusRingColor(styleColorOptions())); >- } else >- paintInfo.context().drawFocusRing(pixelSnappedFocusRingRects, page().focusController().timeSinceFocusWasSet().seconds(), needsRepaint, RenderTheme::singleton().focusRingColor(styleColorOptions())); >- if (needsRepaint) >- page().focusController().setFocusedElementNeedsRepaint(); >+#if PLATFORM(MAC) >+ paintInfo.context().drawFocusRing(path, page().focusController().timeSinceFocusWasSet().seconds(), needsRepaint, focusRingColor); >+#else >+ paintInfo.context().drawFocusRing(path, style.outlineWidth(), style.outlineOffset(), focusRingColor); >+#endif >+ } else { >+#if PLATFORM(MAC) >+ paintInfo.context().drawFocusRing(pixelSnappedFocusRingRects, page().focusController().timeSinceFocusWasSet().seconds(), needsRepaint, focusRingColor); > #else >- paintInfo.context().drawFocusRing(pixelSnappedFocusRingRects, style.outlineWidth(), style.outlineOffset(), style.visitedDependentColorWithColorFilter(CSSPropertyOutlineColor)); >+ paintInfo.context().drawFocusRing(pixelSnappedFocusRingRects, style.outlineWidth(), style.outlineOffset(), focusRingColor); > #endif >+ } >+ if (needsRepaint) >+ page().focusController().setFocusedElementNeedsRepaint(); > } > > void RenderElement::paintOutline(PaintInfo& paintInfo, const LayoutRect& paintRect)
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Formatted Diff
|
Diff
Attachments on
bug 193591
:
359536
|
359540
|
361633