Bug 1702676 - Change public LookAndFeel API to accept a color scheme. r=mstange

This shouldn't change behavior, but is the biggest cross-platform part
of the change so I'd like to get it landed sooner rather than later.

The two calls like:

  GetColor(ColorID::TextSelectBackground, color);
  if (color == 0x000000) {
    mColorTextSelectForeground = NS_RGB(0xff, 0xff, 0xff);
  } else {
    mColorTextSelectForeground = NS_DONT_CHANGE_COLOR;
  }

that I'm removing are just broken. They were calling the version of
GetColor the function that took a default value when the color wasn't
available, not the version of the color with the outparam.

To prevent such mistakes, add two signatures, GetColor(), returning a
Maybe<nscolor> and Color(), returning a color with a fallback.

Differential Revision: https://phabricator.services.mozilla.com/D110651
This commit is contained in:
Emilio Cobos Álvarez
2021-04-02 12:22:14 +00:00
parent 48d962c043
commit bc6ae36fa1
18 changed files with 243 additions and 218 deletions

View File

@@ -128,8 +128,11 @@ already_AddRefed<nsWebBrowser> nsWebBrowser::Create(
MOZ_ASSERT(browser->mDocShell == docShell);
// get the system default window background colour
LookAndFeel::GetColor(LookAndFeel::ColorID::WindowBackground,
&browser->mBackgroundColor);
//
// TODO(emilio): Can we get the color-scheme from somewhere here?
browser->mBackgroundColor = LookAndFeel::Color(
LookAndFeel::ColorID::WindowBackground, LookAndFeel::ColorScheme::Light,
LookAndFeel::UseStandins::No);
// HACK ALERT - this registration registers the nsDocShellTreeOwner as a
// nsIWebBrowserListener so it can setup its MouseListener in one of the