[tbb-commits] [tor-browser] 26/36: Bug 1789874 - Fix colors used by nsListControlFrame::PaintFocus. r=mstange a=pascalc

gitolite role git at cupani.torproject.org
Thu Oct 13 07:51:14 UTC 2022


This is an automated email from the git hooks/post-receive script.

pierov pushed a commit to annotated tag FIREFOX_102_4_0esr_BUILD1
in repository tor-browser.

commit 913a8d6871eb88349b758e94ea86a7fc28766d14
Author: Emilio Cobos Álvarez <emilio at crisal.io>
AuthorDate: Tue Sep 13 00:43:09 2022 +0000

    Bug 1789874 - Fix colors used by nsListControlFrame::PaintFocus. r=mstange a=pascalc
    
    The regressing bug accidentally swapped the foreground / bg colors in a
    way such that it doesn't look like there's an outline.
    
    Do some adjacent clean-up while at it, and add a test.
    
    Differential Revision: https://phabricator.services.mozilla.com/D156947
---
 layout/forms/nsListControlFrame.cpp                 | 21 ++++++++-------------
 .../reftests/forms/select/listbox-focus-notref.html | 13 +++++++++++++
 layout/reftests/forms/select/listbox-focus.html     | 13 +++++++++++++
 layout/reftests/forms/select/reftest.list           |  1 +
 4 files changed, 35 insertions(+), 13 deletions(-)

diff --git a/layout/forms/nsListControlFrame.cpp b/layout/forms/nsListControlFrame.cpp
index 0208f93ca66e..2d3a3703bd2d 100644
--- a/layout/forms/nsListControlFrame.cpp
+++ b/layout/forms/nsListControlFrame.cpp
@@ -113,8 +113,6 @@ HTMLOptionElement* nsListControlFrame::GetCurrentOption() const {
 void nsListControlFrame::PaintFocus(DrawTarget* aDrawTarget, nsPoint aPt) {
   if (mFocused != this) return;
 
-  nsPresContext* presContext = PresContext();
-
   nsIFrame* containerFrame = GetOptionsContainer();
   if (!containerFrame) return;
 
@@ -144,19 +142,16 @@ void nsListControlFrame::PaintFocus(DrawTarget* aDrawTarget, nsPoint aPt) {
   }
   fRect += aPt;
 
-  bool lastItemIsSelected = false;
-  HTMLOptionElement* domOpt = HTMLOptionElement::FromNodeOrNull(focusedContent);
-  if (domOpt) {
-    lastItemIsSelected = domOpt->Selected();
-  }
+  const auto* domOpt = HTMLOptionElement::FromNodeOrNull(focusedContent);
+  const bool isSelected = domOpt && domOpt->Selected();
 
-  // set up back stop colors and then ask L&F service for the real colors
-  nscolor color = LookAndFeel::Color(
-      lastItemIsSelected ? LookAndFeel::ColorID::Selecteditem
-                         : LookAndFeel::ColorID::Selecteditemtext,
-      this);
+  // Set up back stop colors and then ask L&F service for the real colors
+  nscolor color =
+      LookAndFeel::Color(isSelected ? LookAndFeel::ColorID::Selecteditemtext
+                                    : LookAndFeel::ColorID::Selecteditem,
+                         this);
 
-  nsCSSRendering::PaintFocus(presContext, aDrawTarget, fRect, color);
+  nsCSSRendering::PaintFocus(PresContext(), aDrawTarget, fRect, color);
 }
 
 void nsListControlFrame::InvalidateFocus() {
diff --git a/layout/reftests/forms/select/listbox-focus-notref.html b/layout/reftests/forms/select/listbox-focus-notref.html
new file mode 100644
index 000000000000..d76865abbf01
--- /dev/null
+++ b/layout/reftests/forms/select/listbox-focus-notref.html
@@ -0,0 +1,13 @@
+<!doctype html>
+<style>
+  select {
+    appearance: none;
+    outline: none;
+    border: none;
+  }
+</style>
+<select multiple>
+  <option>First</option>
+  <option>Second</option>
+  <option>Third</option>
+</select>
diff --git a/layout/reftests/forms/select/listbox-focus.html b/layout/reftests/forms/select/listbox-focus.html
new file mode 100644
index 000000000000..0689ed43b8d4
--- /dev/null
+++ b/layout/reftests/forms/select/listbox-focus.html
@@ -0,0 +1,13 @@
+<!doctype html>
+<style>
+  select {
+    appearance: none;
+    outline: none;
+    border: none;
+  }
+</style>
+<select multiple autofocus>
+  <option>First</option>
+  <option>Second</option>
+  <option>Third</option>
+</select>
diff --git a/layout/reftests/forms/select/reftest.list b/layout/reftests/forms/select/reftest.list
index cd4f0febf2d5..975ae114ea62 100644
--- a/layout/reftests/forms/select/reftest.list
+++ b/layout/reftests/forms/select/reftest.list
@@ -24,5 +24,6 @@ test-pref(ui.useOverlayScrollbars,0) ref-pref(ui.useOverlayScrollbars,1) == intr
 
 == listbox-checked-style.html listbox-checked-style-ref.html
 needs-focus != listbox-checked-style.html listbox-checked-style-notref.html
+needs-focus != listbox-focus.html listbox-focus-notref.html
 
 == 1769580.html 1769580-ref.html

-- 
To stop receiving notification emails like this one, please contact
the administrator of this repository.


More information about the tbb-commits mailing list