1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* This Source Code Form is subject to the terms of the Mozilla Public
3  * License, v. 2.0. If a copy of the MPL was not distributed with this
4  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
5 #ifndef __nsLookAndFeel
6 #define __nsLookAndFeel
7 
8 #include "nsXPLookAndFeel.h"
9 
10 namespace mozilla {
11 // The order and number of the members in this structure must correspond
12 // to the attrsAppearance array in GeckoAppShell.getSystemColors()
13 struct AndroidSystemColors {
14   nscolor textColorPrimary;
15   nscolor textColorPrimaryInverse;
16   nscolor textColorSecondary;
17   nscolor textColorSecondaryInverse;
18   nscolor textColorTertiary;
19   nscolor textColorTertiaryInverse;
20   nscolor textColorHighlight;
21   nscolor colorForeground;
22   nscolor colorBackground;
23   nscolor panelColorForeground;
24   nscolor panelColorBackground;
25   nscolor colorAccent;
26 };
27 }  // namespace mozilla
28 
29 class nsLookAndFeel final : public nsXPLookAndFeel {
30  public:
31   explicit nsLookAndFeel();
32   virtual ~nsLookAndFeel();
33 
34   void NativeInit() final;
35   virtual void RefreshImpl() override;
36   nsresult NativeGetInt(IntID, int32_t& aResult) override;
37   nsresult NativeGetFloat(FloatID, float& aResult) override;
38   nsresult NativeGetColor(ColorID, ColorScheme, nscolor& aResult) override;
39   bool NativeGetFont(FontID aID, nsString& aName,
40                      gfxFontStyle& aStyle) override;
41   bool GetEchoPasswordImpl() override;
42   uint32_t GetPasswordMaskDelayImpl() override;
43   char16_t GetPasswordCharacterImpl() override;
44 
45  protected:
46   bool mInitializedSystemColors = false;
47   mozilla::AndroidSystemColors mSystemColors;
48   bool mInitializedShowPassword = false;
49   bool mShowPassword = false;
50 
51   nsresult GetSystemColors();
52 
53   void EnsureInitSystemColors();
54   void EnsureInitShowPassword();
55 };
56 
57 #endif
58