LCOV - code coverage report
Current view: top level - widget - nsXPLookAndFeel.h (source / functions) Hit Total Coverage
Test: output.info Lines: 1 7 14.3 %
Date: 2017-07-14 16:53:18 Functions: 1 4 25.0 %
Legend: Lines: hit not hit

          Line data    Source code
       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             : 
       6             : #ifndef __nsXPLookAndFeel
       7             : #define __nsXPLookAndFeel
       8             : 
       9             : #include "mozilla/LookAndFeel.h"
      10             : #include "nsTArray.h"
      11             : 
      12             : class nsLookAndFeel;
      13             : 
      14             : struct nsLookAndFeelIntPref
      15             : {
      16             :   const char* name;
      17             :   mozilla::LookAndFeel::IntID id;
      18             :   bool isSet;
      19             :   int32_t intVar;
      20             : };
      21             : 
      22             : struct nsLookAndFeelFloatPref
      23             : {
      24             :   const char* name;
      25             :   mozilla::LookAndFeel::FloatID id;
      26             :   bool isSet;
      27             :   float floatVar;
      28             : };
      29             : 
      30             : #define CACHE_BLOCK(x)     ((x) >> 5)
      31             : #define CACHE_BIT(x)       (1 << ((x) & 31))
      32             : 
      33             : #define COLOR_CACHE_SIZE   (CACHE_BLOCK(LookAndFeel::eColorID_LAST_COLOR) + 1)
      34             : #define IS_COLOR_CACHED(x) (CACHE_BIT(x) & nsXPLookAndFeel::sCachedColorBits[CACHE_BLOCK(x)])
      35             : #define CLEAR_COLOR_CACHE(x) nsXPLookAndFeel::sCachedColors[(x)] =0; \
      36             :               nsXPLookAndFeel::sCachedColorBits[CACHE_BLOCK(x)] &= ~(CACHE_BIT(x));
      37             : #define CACHE_COLOR(x, y)  nsXPLookAndFeel::sCachedColors[(x)] = y; \
      38             :               nsXPLookAndFeel::sCachedColorBits[CACHE_BLOCK(x)] |= CACHE_BIT(x);
      39             : 
      40             : class nsXPLookAndFeel: public mozilla::LookAndFeel
      41             : {
      42             : public:
      43             :   virtual ~nsXPLookAndFeel();
      44             : 
      45             :   static nsXPLookAndFeel* GetInstance();
      46             :   static void Shutdown();
      47             : 
      48             :   void Init();
      49             : 
      50             :   //
      51             :   // All these routines will return NS_OK if they have a value,
      52             :   // in which case the nsLookAndFeel should use that value;
      53             :   // otherwise we'll return NS_ERROR_NOT_AVAILABLE, in which case, the
      54             :   // platform-specific nsLookAndFeel should use its own values instead.
      55             :   //
      56             :   nsresult GetColorImpl(ColorID aID, bool aUseStandinsForNativeColors,
      57             :                         nscolor &aResult);
      58             :   virtual nsresult GetIntImpl(IntID aID, int32_t &aResult);
      59             :   virtual nsresult GetFloatImpl(FloatID aID, float &aResult);
      60             : 
      61             :   // This one is different: there are no override prefs (fixme?), so
      62             :   // there is no XP implementation, only per-system impls.
      63             :   virtual bool GetFontImpl(FontID aID, nsString& aName,
      64             :                            gfxFontStyle& aStyle,
      65             :                            float aDevPixPerCSSPixel) = 0;
      66             : 
      67             :   virtual void RefreshImpl();
      68             : 
      69           0 :   virtual char16_t GetPasswordCharacterImpl()
      70             :   {
      71           0 :     return char16_t('*');
      72             :   }
      73             : 
      74           0 :   virtual bool GetEchoPasswordImpl()
      75             :   {
      76           0 :     return false;
      77             :   }
      78             : 
      79           0 :   virtual uint32_t GetPasswordMaskDelayImpl()
      80             :   {
      81           0 :     return 600;
      82             :   }
      83             : 
      84             :   virtual nsTArray<LookAndFeelInt> GetIntCacheImpl();
      85           1 :   virtual void SetIntCacheImpl(const nsTArray<LookAndFeelInt>& aLookAndFeelIntCache) {}
      86             : 
      87             : protected:
      88             :   nsXPLookAndFeel();
      89             : 
      90             :   static void IntPrefChanged(nsLookAndFeelIntPref *data);
      91             :   static void FloatPrefChanged(nsLookAndFeelFloatPref *data);
      92             :   static void ColorPrefChanged(unsigned int index, const char *prefName);
      93             :   void InitFromPref(nsLookAndFeelIntPref* aPref);
      94             :   void InitFromPref(nsLookAndFeelFloatPref* aPref);
      95             :   void InitColorFromPref(int32_t aIndex);
      96             :   virtual nsresult NativeGetColor(ColorID aID, nscolor &aResult) = 0;
      97             :   bool IsSpecialColor(ColorID aID, nscolor &aColor);
      98             :   bool ColorIsNotCSSAccessible(ColorID aID);
      99             :   nscolor GetStandinForNativeColor(ColorID aID);
     100             : 
     101             :   static void OnPrefChanged(const char* aPref, void* aClosure);
     102             : 
     103             :   static bool sInitialized;
     104             :   static nsLookAndFeelIntPref sIntPrefs[];
     105             :   static nsLookAndFeelFloatPref sFloatPrefs[];
     106             :   /* this length must not be shorter than the length of the longest string in the array
     107             :    * see nsXPLookAndFeel.cpp
     108             :    */
     109             :   static const char sColorPrefs[][38];
     110             :   static int32_t sCachedColors[LookAndFeel::eColorID_LAST_COLOR];
     111             :   static int32_t sCachedColorBits[COLOR_CACHE_SIZE];
     112             :   static bool sUseNativeColors;
     113             :   static bool sUseStandinsForNativeColors;
     114             :   static bool sFindbarModalHighlight;
     115             : 
     116             :   static nsXPLookAndFeel* sInstance;
     117             :   static bool sShutdown;
     118             : };
     119             : 
     120             : #endif

Generated by: LCOV version 1.13