Commit 2d7e2dd9 authored by Ionel Popescu's avatar Ionel Popescu Committed by Commit Bot

Use the system accent color on Mac.

Prior to this CL the focus ring color wasn't impacted by the system accent
color.
The new behavior is that if the system accent color is changed then
it is going to be used as the focus ring color.

Not being able to use the default system accent color as the focus ring
color is a known trade-off we're taking for having a consistent default
black & white focus ring across all platforms.

Bug: 1022120
Change-Id: Iacd35404530e190b45e5866c7a11cf86d5001ffb
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2031863
Commit-Queue: Ionel Popescu <iopopesc@microsoft.com>
Reviewed-by: default avatarRobert Sesek <rsesek@chromium.org>
Reviewed-by: default avatarKent Tamura <tkent@chromium.org>
Reviewed-by: default avatarMason Freed <masonfreed@chromium.org>
Cr-Commit-Position: refs/heads/master@{#738734}
parent 8b38ff4f
......@@ -341,6 +341,28 @@ void ThemeHelperMac::LoadSystemColors() {
case blink::MacSystemColorID::kAlternateSelectedControl:
values[i] = NSColorToSkColor([NSColor alternateSelectedControlColor]);
break;
case blink::MacSystemColorID::kControlAccentBlueColor: {
NSColor* color =
[NSColor colorWithCatalogName:@"System"
colorName:@"controlAccentBlueColor"];
if (color) {
values[i] = NSColorToSkColor(color);
} else {
// If the controlAccentBlueColor isn't available just set a dummy
// black value.
values[i] = SK_ColorBLACK;
}
break;
}
case blink::MacSystemColorID::kControlAccentColor:
if (@available(macOS 10.14, *)) {
values[i] = NSColorToSkColor([NSColor controlAccentColor]);
} else {
// controlAccentColor property is not available before macOS 10.14,
// so keyboardFocusIndicatorColor is used instead.
values[i] = NSColorToSkColor([NSColor keyboardFocusIndicatorColor]);
}
break;
case blink::MacSystemColorID::kControlBackground:
values[i] = NSColorToSkColor([NSColor controlBackgroundColor]);
break;
......
......@@ -11,6 +11,8 @@ namespace blink {
// NSColor.
enum class MacSystemColorID {
kAlternateSelectedControl,
kControlAccentBlueColor,
kControlAccentColor,
kControlBackground,
kControlDarkShadow,
kControlHighlight,
......
......@@ -1027,4 +1027,12 @@ void LayoutTheme::AdjustControlPartStyle(ComputedStyle& style) {
}
}
bool LayoutTheme::HasCustomFocusRingColor() const {
return has_custom_focus_ring_color_;
}
Color LayoutTheme::GetCustomFocusRingColor() const {
return custom_focus_ring_color_;
}
} // namespace blink
......@@ -170,7 +170,7 @@ class CORE_EXPORT LayoutTheme : public RefCounted<LayoutTheme> {
WebColorScheme color_scheme) const;
virtual bool IsFocusRingOutset() const;
Color FocusRingColor() const;
virtual Color FocusRingColor() const;
virtual Color PlatformFocusRingColor() const { return Color(0, 0, 0); }
void SetCustomFocusRingColor(const Color&);
static Color TapHighlightColor();
......@@ -349,6 +349,10 @@ class CORE_EXPORT LayoutTheme : public RefCounted<LayoutTheme> {
static bool IsSpinUpButtonPartHovered(const Node*);
static bool IsReadOnlyControl(const Node*);
protected:
bool HasCustomFocusRingColor() const;
Color GetCustomFocusRingColor() const;
private:
// This function is to be implemented in your platform-specific theme
// implementation to hand back the appropriate platform theme.
......
......@@ -154,11 +154,16 @@ class LayoutThemeMacRefresh final : public LayoutThemeDefault {
WebColorScheme color_scheme) const override;
Color PlatformSpellingMarkerUnderlineColor() const override;
Color PlatformGrammarMarkerUnderlineColor() const override;
Color FocusRingColor() const override;
String DisplayNameForFile(const File& file) const override {
if (file.GetUserVisibility() == File::kIsUserVisible)
return [[NSFileManager defaultManager] displayNameAtPath:file.GetPath()];
return file.name();
}
protected:
// Controls color values returned from FocusRingColor().
bool UsesTestModeFocusRingColor() const;
};
// Inflate an IntRect to account for specific padding around margins.
......@@ -312,6 +317,37 @@ Color LayoutThemeMacRefresh::PlatformGrammarMarkerUnderlineColor() const {
return Color(107, 107, 107);
}
Color LayoutThemeMacRefresh::FocusRingColor() const {
static const RGBA32 kDefaultFocusRingColor = 0xFF101010;
if (UsesTestModeFocusRingColor())
return kDefaultFocusRingColor;
if (!HasCustomFocusRingColor())
return GetSystemColor(MacSystemColorID::kKeyboardFocusIndicator);
// Use the custom focus ring color when the system accent color wasn't
// changed.
if (@available(macOS 10.14, *)) {
static const Color kControlBlueAccentColor =
GetSystemColor(MacSystemColorID::kControlAccentBlueColor);
if (kControlBlueAccentColor ==
GetSystemColor(MacSystemColorID::kControlAccentColor)) {
return GetCustomFocusRingColor();
}
} else {
if (NSBlueControlTint == [[NSUserDefaults standardUserDefaults]
integerForKey:@"AppleAquaColorVariant"]) {
return GetCustomFocusRingColor();
}
}
return GetSystemColor(MacSystemColorID::kKeyboardFocusIndicator);
}
bool LayoutThemeMacRefresh::UsesTestModeFocusRingColor() const {
return WebTestSupport::IsRunningWebTest();
}
static FontSelectionValue ToFontWeight(NSInteger app_kit_font_weight) {
DCHECK_GT(app_kit_font_weight, 0);
DCHECK_LT(app_kit_font_weight, 15);
......
......@@ -383,6 +383,11 @@ void DrawPlatformFocusRing(const PrimitiveType& primitive,
flags.setColor(color);
flags.setStrokeWidth(width);
if (::features::IsFormControlsRefreshEnabled()) {
DrawFocusRingPrimitive(primitive, canvas, flags, border_radius);
return;
}
#if defined(OS_MACOSX)
flags.setAlpha(64);
const float corner_radius = (width - 1) * 0.5f;
......@@ -390,11 +395,6 @@ void DrawPlatformFocusRing(const PrimitiveType& primitive,
const float corner_radius = width;
#endif
if (::features::IsFormControlsRefreshEnabled()) {
DrawFocusRingPrimitive(primitive, canvas, flags, border_radius);
return;
}
DrawFocusRingPrimitive(primitive, canvas, flags, corner_radius);
#if defined(OS_MACOSX)
......
Content-Type: text/plain
#EOF
ActualHash: f399a9e0117c5e32bfed8538f483905b
ExpectedHash: f399a9e0117c5e32bfed8538f483905b
#EOF
Tests that oopif iframes are rendered inline.
Dump tree
- <html>
<head></head>
- <body>
- <div>
- <iframe id="page-iframe" src="http://127.0.0.1:8000/devtools/oopif/resources/inner-iframe.html">
- #document
- <html>
<head></head>
<body>IFRAME\n</body>
</html>
</iframe>
</div>
</body>
</html>
Dump tree
- <html>
<head></head>
- <body>
- <div>
- <iframe id="page-iframe" src="http://devtools.oopif.test:8000/devtools/oopif/resources/inner-iframe.html">
- #document
- <html>
<head></head>
<body>IFRAME\n</body>
</html>
</iframe>
</div>
</body>
</html>
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment