Commit 1ccf4c36 authored by Daniel Clark's avatar Daniel Clark Committed by Commit Bot

Make LayoutThemeMacRefresh preserve Mac text selection/underline color

When the controls refresh is enabled, LayoutThemeMacRefresh is used
instead of LayoutThemeMac.  The former inherits from LayoutThemeDefault
but implements no functionality of its own, whereas the latter inherits
directly from LayoutTheme and implements various mac-specific styling.

Most of LayoutThemeMac applies to the old form control implementations,
and will eventually be discarded in favor of platform-agnostic
implementations in LayoutThemeDefault.  However, text selection color
is also specified in LayoutThemeMac, and this was not replicated in
LayoutThemeMacRefresh, with the result that switching on the
controls refresh flag changes text selection color.

This CL resolves the issue by reproducing the non-controls-related theming
functions from LayoutThemeMac in LayoutThemeMacRefresh.  The code
duplication looks suspicious at first glance but should be acceptable
for the time being because all of LayoutThemeMac is destined for deletion
once the new controls have been permanently enabled.

Bug: 994290
Change-Id: I1b881b2ca2fe718cd89a49535e36dd99ea65b9a1
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1947443Reviewed-by: default avatarSanket Joshi <sajos@microsoft.com>
Reviewed-by: default avatarKent Tamura <tkent@chromium.org>
Commit-Queue: Dan Clark <daniec@microsoft.com>
Cr-Commit-Position: refs/heads/master@{#723485}
parent dd8930f8
...@@ -146,6 +146,15 @@ class LayoutThemeMacRefresh final : public LayoutThemeDefault { ...@@ -146,6 +146,15 @@ class LayoutThemeMacRefresh final : public LayoutThemeDefault {
static scoped_refptr<LayoutTheme> Create() { static scoped_refptr<LayoutTheme> Create() {
return base::AdoptRef(new LayoutThemeMacRefresh()); return base::AdoptRef(new LayoutThemeMacRefresh());
} }
Color PlatformActiveSelectionBackgroundColor(
WebColorScheme color_scheme) const override;
Color PlatformInactiveSelectionBackgroundColor(
WebColorScheme color_scheme) const override;
Color PlatformActiveSelectionForegroundColor(
WebColorScheme color_scheme) const override;
Color PlatformSpellingMarkerUnderlineColor() const override;
Color PlatformGrammarMarkerUnderlineColor() const override;
}; };
// Inflate an IntRect to account for specific padding around margins. // Inflate an IntRect to account for specific padding around margins.
...@@ -276,6 +285,29 @@ Color LayoutThemeMac::PlatformInactiveListBoxSelectionBackgroundColor( ...@@ -276,6 +285,29 @@ Color LayoutThemeMac::PlatformInactiveListBoxSelectionBackgroundColor(
return PlatformInactiveSelectionBackgroundColor(color_scheme); return PlatformInactiveSelectionBackgroundColor(color_scheme);
} }
Color LayoutThemeMacRefresh::PlatformActiveSelectionBackgroundColor(
WebColorScheme color_scheme) const {
return GetSystemColor(MacSystemColorID::kSelectedTextBackground);
}
Color LayoutThemeMacRefresh::PlatformInactiveSelectionBackgroundColor(
WebColorScheme color_scheme) const {
return GetSystemColor(MacSystemColorID::kSecondarySelectedControl);
}
Color LayoutThemeMacRefresh::PlatformActiveSelectionForegroundColor(
WebColorScheme color_scheme) const {
return Color::kBlack;
}
Color LayoutThemeMacRefresh::PlatformSpellingMarkerUnderlineColor() const {
return Color(251, 45, 29);
}
Color LayoutThemeMacRefresh::PlatformGrammarMarkerUnderlineColor() const {
return Color(107, 107, 107);
}
static FontSelectionValue ToFontWeight(NSInteger app_kit_font_weight) { static FontSelectionValue ToFontWeight(NSInteger app_kit_font_weight) {
DCHECK_GT(app_kit_font_weight, 0); DCHECK_GT(app_kit_font_weight, 0);
DCHECK_LT(app_kit_font_weight, 15); DCHECK_LT(app_kit_font_weight, 15);
......
<!DOCTYPE html>
<body>
<div id="target">This is some basic text that we are going to select.</div>
<script>
let targetText = document.querySelector("#target").firstChild;
let selectionRange = window.getSelection();
selectionRange.setBaseAndExtent(targetText, 5, targetText, 35);
</script>
</body>
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