tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

commit 16cadbc98e9a1eafc0d7e88e4abafb91ae3d1d9a
parent 9377e20f5db3fbc483e0fe69caa127deaa8fb18e
Author: Jan-Niklas Jaeschke <jjaschke@mozilla.com>
Date:   Thu,  9 Oct 2025 13:40:54 +0000

Bug 1974121, part 1 - Text Fragments: Change HCM colors to `SelectedItem`. r=ayeddi,layout-reviewers,emilio,accessibility-frontend-reviewers,win-reviewers,gstoll

Differential Revision: https://phabricator.services.mozilla.com/D259689

Diffstat:
Mlayout/generic/nsTextPaintStyle.cpp | 14+++++---------
Mlayout/reftests/high-contrast/reftest.list | 3+--
Dlayout/reftests/high-contrast/target-text-001-ref.html | 12------------
Dlayout/reftests/high-contrast/target-text-001.html | 10----------
Dlayout/reftests/high-contrast/target-text-002.html | 16----------------
Alayout/reftests/high-contrast/target-text-ref.html | 9+++++++++
Alayout/reftests/high-contrast/target-text.html | 16++++++++++++++++
Mwidget/windows/nsLookAndFeel.cpp | 17++++++++++-------
8 files changed, 41 insertions(+), 56 deletions(-)

diff --git a/layout/generic/nsTextPaintStyle.cpp b/layout/generic/nsTextPaintStyle.cpp @@ -226,15 +226,11 @@ void nsTextPaintStyle::GetTargetTextColors(nscolor* aForeColor, &nsStyleBackground::mBackgroundColor); return; } - if (PresContext()->ForcingColors()) { - *aBackColor = LookAndFeel::Color(LookAndFeel::ColorID::Mark, mFrame); - *aForeColor = LookAndFeel::Color(LookAndFeel::ColorID::Marktext, mFrame); - } else { - *aBackColor = - LookAndFeel::Color(LookAndFeel::ColorID::TargetTextBackground, mFrame); - *aForeColor = - LookAndFeel::Color(LookAndFeel::ColorID::TargetTextForeground, mFrame); - } + + *aBackColor = + LookAndFeel::Color(LookAndFeel::ColorID::TargetTextBackground, mFrame); + *aForeColor = + LookAndFeel::Color(LookAndFeel::ColorID::TargetTextForeground, mFrame); } bool nsTextPaintStyle::GetCustomHighlightTextColor(nsAtom* aHighlightName, diff --git a/layout/reftests/high-contrast/reftest.list b/layout/reftests/high-contrast/reftest.list @@ -34,8 +34,7 @@ test-pref(browser.display.suppress_canvas_background_image_on_forced_colors,fals needs-focus == selection-001.html selection-001-ref.html pref(browser.display.document_color_use,0) needs-focus != selection-001.html selection-001-ref.html -pref(dom.text_fragments.enabled,true) == target-text-001.html target-text-001-ref.html -pref(dom.text_fragments.enabled,true) == target-text-002.html target-text-001-ref.html +pref(dom.text_fragments.enabled,true) == target-text.html target-text-ref.html == color-transparent-001.html about:blank != color-transparent-002.html about:blank diff --git a/layout/reftests/high-contrast/target-text-001-ref.html b/layout/reftests/high-contrast/target-text-001-ref.html @@ -1,12 +0,0 @@ -<!doctype html> -<html> -<style> -span { - background-color: mark; - color: marktext; -} -</style> -<body> -<span>Some selected text</span> -</body> -</html> diff --git a/layout/reftests/high-contrast/target-text-001.html b/layout/reftests/high-contrast/target-text-001.html @@ -1,10 +0,0 @@ -<!doctype html> -<html> -<title>::target-text without custom colors should be replaced with mark/marktext</title> -<script> -location.hash = ':~:text=Some selected text'; -</script> -<body> -<span>Some selected text</span> -</body> -</html> diff --git a/layout/reftests/high-contrast/target-text-002.html b/layout/reftests/high-contrast/target-text-002.html @@ -1,16 +0,0 @@ -<!doctype html> -<html> -<title>::target-text with custom colors should be replaced with mark/marktext</title> -<style> -::target-text { - background: #FF0000; - color: #0000FF; -} -</style> -<script> -location.hash = ':~:text=Some selected text'; -</script> -<body> -<span>Some selected text</span> -</body> -</html> diff --git a/layout/reftests/high-contrast/target-text-ref.html b/layout/reftests/high-contrast/target-text-ref.html @@ -0,0 +1,9 @@ +<!doctype html> +<html> +<body> +<span>Some selected text</span> +<script> +location.hash = ':~:text=Some selected text'; +</script> +</body> +</html> diff --git a/layout/reftests/high-contrast/target-text.html b/layout/reftests/high-contrast/target-text.html @@ -0,0 +1,16 @@ +<!doctype html> +<html> +<title>custom colors for ::target-text should be replaced with forced-colors colors</title> +<style> +::target-text { + background: #FF0000; + color: #0000FF; +} +</style> +<script> +location.hash = ':~:text=Some selected text'; +</script> +<body> +<span>Some selected text</span> +</body> +</html> diff --git a/widget/windows/nsLookAndFeel.cpp b/widget/windows/nsLookAndFeel.cpp @@ -264,13 +264,6 @@ nsresult nsLookAndFeel::NativeGetColor(ColorID aID, ColorScheme aScheme, break; } - if (aScheme == ColorScheme::Dark) { - if (auto color = GenericDarkColor(aID)) { - aColor = *color; - return NS_OK; - } - } - if (mHighContrastOn) { switch (aID) { case ColorID::MozButtonhoverborder: @@ -278,12 +271,14 @@ nsresult nsLookAndFeel::NativeGetColor(ColorID aID, ColorScheme aScheme, case ColorID::MozColheaderhover: case ColorID::MozButtonactivetext: case ColorID::MozColheaderactivetext: + case ColorID::TargetTextBackground: aColor = GetColorForSysColorIndex(COLOR_HIGHLIGHT); return NS_OK; case ColorID::MozButtonhovertext: case ColorID::MozColheaderhovertext: case ColorID::MozButtonactiveface: case ColorID::MozColheaderactive: + case ColorID::TargetTextForeground: aColor = GetColorForSysColorIndex(COLOR_HIGHLIGHTTEXT); return NS_OK; case ColorID::MozButtondisabledborder: @@ -318,6 +313,14 @@ nsresult nsLookAndFeel::NativeGetColor(ColorID aID, ColorScheme aScheme, default: break; } + + } + + if (aScheme == ColorScheme::Dark) { + if (auto color = GenericDarkColor(aID)) { + aColor = *color; + return NS_OK; + } } static constexpr auto kNonNativeMenuText = NS_RGB(0x15, 0x14, 0x1a);