LCOV - code coverage report
Current view: top level - widget - LookAndFeel.h (source / functions) Hit Total Coverage
Test: output.info Lines: 8 18 44.4 %
Date: 2017-07-14 16:53:18 Functions: 2 4 50.0 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /* -*- Mode: C++; tab-width: 2; 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 __LookAndFeel
       7             : #define __LookAndFeel
       8             : 
       9             : #ifndef MOZILLA_INTERNAL_API
      10             : #error "This header is only usable from within libxul (MOZILLA_INTERNAL_API)."
      11             : #endif
      12             : 
      13             : #include "nsDebug.h"
      14             : #include "nsColor.h"
      15             : #include "nsTArray.h"
      16             : 
      17             : struct gfxFontStyle;
      18             : 
      19             : struct LookAndFeelInt
      20             : {
      21             :   int32_t id;
      22             :   int32_t value;
      23             : };
      24             : 
      25             : namespace mozilla {
      26             : 
      27             : class LookAndFeel
      28             : {
      29             : public:
      30             :   // When modifying this list, also modify nsXPLookAndFeel::sColorPrefs
      31             :   // in widget/xpwidgts/nsXPLookAndFeel.cpp.
      32             :   enum ColorID : uint8_t {
      33             : 
      34             :     // WARNING : NO NEGATIVE VALUE IN THIS ENUMERATION
      35             :     // see patch in bug 57757 for more information
      36             : 
      37             :     eColorID_WindowBackground,
      38             :     eColorID_WindowForeground,
      39             :     eColorID_WidgetBackground,
      40             :     eColorID_WidgetForeground,
      41             :     eColorID_WidgetSelectBackground,
      42             :     eColorID_WidgetSelectForeground,
      43             :     eColorID_Widget3DHighlight,
      44             :     eColorID_Widget3DShadow,
      45             :     eColorID_TextBackground,
      46             :     eColorID_TextForeground,
      47             :     eColorID_TextSelectBackground,
      48             :     eColorID_TextSelectForeground,
      49             :     eColorID_TextSelectForegroundCustom,
      50             :     eColorID_TextSelectBackgroundDisabled,
      51             :     eColorID_TextSelectBackgroundAttention,
      52             :     eColorID_TextHighlightBackground,
      53             :     eColorID_TextHighlightForeground,
      54             : 
      55             :     eColorID_IMERawInputBackground,
      56             :     eColorID_IMERawInputForeground,
      57             :     eColorID_IMERawInputUnderline,
      58             :     eColorID_IMESelectedRawTextBackground,
      59             :     eColorID_IMESelectedRawTextForeground,
      60             :     eColorID_IMESelectedRawTextUnderline,
      61             :     eColorID_IMEConvertedTextBackground,
      62             :     eColorID_IMEConvertedTextForeground,
      63             :     eColorID_IMEConvertedTextUnderline,
      64             :     eColorID_IMESelectedConvertedTextBackground,
      65             :     eColorID_IMESelectedConvertedTextForeground,
      66             :     eColorID_IMESelectedConvertedTextUnderline,
      67             : 
      68             :     eColorID_SpellCheckerUnderline,
      69             : 
      70             :     // New CSS 2 color definitions
      71             :     eColorID_activeborder,
      72             :     eColorID_activecaption,
      73             :     eColorID_appworkspace,
      74             :     eColorID_background,
      75             :     eColorID_buttonface,
      76             :     eColorID_buttonhighlight,
      77             :     eColorID_buttonshadow,
      78             :     eColorID_buttontext,
      79             :     eColorID_captiontext,
      80             :     eColorID_graytext,
      81             :     eColorID_highlight,
      82             :     eColorID_highlighttext,
      83             :     eColorID_inactiveborder,
      84             :     eColorID_inactivecaption,
      85             :     eColorID_inactivecaptiontext,
      86             :     eColorID_infobackground,
      87             :     eColorID_infotext,
      88             :     eColorID_menu,
      89             :     eColorID_menutext,
      90             :     eColorID_scrollbar,
      91             :     eColorID_threeddarkshadow,
      92             :     eColorID_threedface,
      93             :     eColorID_threedhighlight,
      94             :     eColorID_threedlightshadow,
      95             :     eColorID_threedshadow,
      96             :     eColorID_window,
      97             :     eColorID_windowframe,
      98             :     eColorID_windowtext,
      99             : 
     100             :     eColorID__moz_buttondefault,
     101             :     // Colors which will hopefully become CSS3
     102             :     eColorID__moz_field,
     103             :     eColorID__moz_fieldtext,
     104             :     eColorID__moz_dialog,
     105             :     eColorID__moz_dialogtext,
     106             :     // used to highlight valid regions to drop something onto
     107             :     eColorID__moz_dragtargetzone,
     108             : 
     109             :     // used to cell text background, selected but not focus
     110             :     eColorID__moz_cellhighlight,
     111             :     // used to cell text, selected but not focus
     112             :     eColorID__moz_cellhighlighttext,
     113             :     // used to html select cell text background, selected but not focus
     114             :     eColorID__moz_html_cellhighlight,
     115             :     // used to html select cell text, selected but not focus
     116             :     eColorID__moz_html_cellhighlighttext,
     117             :     // used to button text background, when mouse is over
     118             :     eColorID__moz_buttonhoverface,
     119             :     // used to button text, when mouse is over
     120             :     eColorID__moz_buttonhovertext,
     121             :     // used to menu item background, when mouse is over
     122             :     eColorID__moz_menuhover,
     123             :     // used to menu item text, when mouse is over
     124             :     eColorID__moz_menuhovertext,
     125             :     // used to menu bar item text
     126             :     eColorID__moz_menubartext,
     127             :     // used to menu bar item text, when mouse is over
     128             :     eColorID__moz_menubarhovertext,
     129             :     // On platforms where these colors are the same as
     130             :     // -moz-field, use -moz-fieldtext as foreground color
     131             :     eColorID__moz_eventreerow,
     132             :     eColorID__moz_oddtreerow,
     133             : 
     134             :     // colors needed by the Mac OS X theme
     135             : 
     136             :     // foreground color of :hover:active buttons
     137             :     eColorID__moz_mac_buttonactivetext,
     138             :     // background color of chrome toolbars in active windows
     139             :     eColorID__moz_mac_chrome_active,
     140             :     // background color of chrome toolbars in inactive windows
     141             :     eColorID__moz_mac_chrome_inactive,
     142             :     // foreground color of default buttons
     143             :     eColorID__moz_mac_defaultbuttontext,
     144             :     //ring around text fields and lists
     145             :     eColorID__moz_mac_focusring,
     146             :     //colour used when mouse is over a menu item
     147             :     eColorID__moz_mac_menuselect,
     148             :     //colour used to do shadows on menu items
     149             :     eColorID__moz_mac_menushadow,
     150             :     // color used to display text for disabled menu items
     151             :     eColorID__moz_mac_menutextdisable,
     152             :     //colour used to display text while mouse is over a menu item
     153             :     eColorID__moz_mac_menutextselect,
     154             :     // text color of disabled text on toolbars
     155             :     eColorID__moz_mac_disabledtoolbartext,
     156             :     //inactive light hightlight
     157             :     eColorID__moz_mac_secondaryhighlight,
     158             : 
     159             :     // vista rebars
     160             : 
     161             :     // accent color for title bar
     162             :     eColorID__moz_win_accentcolor,
     163             :     // color from drawing text over the accent color
     164             :     eColorID__moz_win_accentcolortext,
     165             :     // media rebar text
     166             :     eColorID__moz_win_mediatext,
     167             :     // communications rebar text
     168             :     eColorID__moz_win_communicationstext,
     169             : 
     170             :     // Hyperlink color extracted from the system, not affected by the
     171             :     // browser.anchor_color user pref.
     172             :     // There is no OS-specified safe background color for this text,
     173             :     // but it is used regularly within Windows and the Gnome DE on Dialog and
     174             :     // Window colors.
     175             :     eColorID__moz_nativehyperlinktext,
     176             : 
     177             :     // Combo box widgets
     178             :     eColorID__moz_comboboxtext,
     179             :     eColorID__moz_combobox,
     180             : 
     181             :     // GtkInfoBar
     182             :     eColorID__moz_gtk_info_bar_text,
     183             : 
     184             :     // keep this one last, please
     185             :     eColorID_LAST_COLOR
     186             :   };
     187             : 
     188             :   // When modifying this list, also modify nsXPLookAndFeel::sIntPrefs
     189             :   // in widget/xpwidgts/nsXPLookAndFeel.cpp.
     190             :   enum IntID {
     191             :     // default, may be overriden by OS
     192             :     eIntID_CaretBlinkTime,
     193             :     // pixel width of caret
     194             :     eIntID_CaretWidth,
     195             :     // show the caret when text is selected?
     196             :     eIntID_ShowCaretDuringSelection,
     197             :     // select textfields when focused via tab/accesskey?
     198             :     eIntID_SelectTextfieldsOnKeyFocus,
     199             :     // delay before submenus open
     200             :     eIntID_SubmenuDelay,
     201             :     // can popups overlap menu/task bar?
     202             :     eIntID_MenusCanOverlapOSBar,
     203             :     // should overlay scrollbars be used?
     204             :     eIntID_UseOverlayScrollbars,
     205             :     // allow H and V overlay scrollbars to overlap?
     206             :     eIntID_AllowOverlayScrollbarsOverlap,
     207             :     // show/hide scrollbars based on activity
     208             :     eIntID_ShowHideScrollbars,
     209             :     // skip navigating to disabled menu item?
     210             :     eIntID_SkipNavigatingDisabledMenuItem,
     211             :     // begin a drag if the mouse is moved further than the threshold while the
     212             :     // button is down
     213             :     eIntID_DragThresholdX,
     214             :     eIntID_DragThresholdY,
     215             :     // Accessibility theme being used?
     216             :     eIntID_UseAccessibilityTheme,
     217             : 
     218             :     // position of scroll arrows in a scrollbar
     219             :     eIntID_ScrollArrowStyle,
     220             :     // is scroll thumb proportional or fixed?
     221             :     eIntID_ScrollSliderStyle,
     222             : 
     223             :     // each button can take one of four values:
     224             :     eIntID_ScrollButtonLeftMouseButtonAction,
     225             :     // 0 - scrolls one  line, 1 - scrolls one page
     226             :     eIntID_ScrollButtonMiddleMouseButtonAction,
     227             :     // 2 - scrolls to end, 3 - button ignored
     228             :     eIntID_ScrollButtonRightMouseButtonAction,
     229             : 
     230             :     // delay for opening spring loaded folders
     231             :     eIntID_TreeOpenDelay,
     232             :     // delay for closing spring loaded folders
     233             :     eIntID_TreeCloseDelay,
     234             :     // delay for triggering the tree scrolling
     235             :     eIntID_TreeLazyScrollDelay,
     236             :     // delay for scrolling the tree
     237             :     eIntID_TreeScrollDelay,
     238             :     // the maximum number of lines to be scrolled at ones
     239             :     eIntID_TreeScrollLinesMax,
     240             :     // What type of tab-order to use
     241             :     eIntID_TabFocusModel,
     242             :     // Should menu items blink when they're chosen?
     243             :     eIntID_ChosenMenuItemsShouldBlink,
     244             : 
     245             :     /*
     246             :      * A Boolean value to determine whether the Windows accent color
     247             :      * should be applied to the title bar.
     248             :      *
     249             :      * The value of this metric is not used on other platforms. These platforms
     250             :      * should return NS_ERROR_NOT_IMPLEMENTED when queried for this metric.
     251             :      */
     252             :     eIntID_WindowsAccentColorApplies,
     253             : 
     254             :     /*
     255             :      * A Boolean value to determine whether the Windows default theme is
     256             :      * being used.
     257             :      *
     258             :      * The value of this metric is not used on other platforms. These platforms
     259             :      * should return NS_ERROR_NOT_IMPLEMENTED when queried for this metric.
     260             :      */
     261             :     eIntID_WindowsDefaultTheme,
     262             : 
     263             :     /*
     264             :      * A Boolean value to determine whether the DWM compositor is being used
     265             :      *
     266             :      * This metric is not used on non-Windows platforms. These platforms
     267             :      * should return NS_ERROR_NOT_IMPLEMENTED when queried for this metric.
     268             :      */
     269             :     eIntID_DWMCompositor,
     270             : 
     271             :     /*
     272             :      * A Boolean value to determine whether Windows is themed (Classic vs.
     273             :      * uxtheme)
     274             :      *
     275             :      * This is Windows-specific and is not implemented on other platforms
     276             :      * (will return the default of NS_ERROR_FAILURE).
     277             :      */
     278             :     eIntID_WindowsClassic,
     279             : 
     280             :     /*
     281             :      * A Boolean value to determine whether the current Windows desktop theme
     282             :      * supports Aero Glass.
     283             :      *
     284             :      * This is Windows-specific and is not implemented on other platforms
     285             :      * (will return the default of NS_ERROR_FAILURE).
     286             :      */
     287             :     eIntID_WindowsGlass,
     288             : 
     289             :     /*
     290             :      * A Boolean value to determine whether the device is a touch enabled
     291             :      * device. Currently this is only supported by the Windows 7 Touch API.
     292             :      *
     293             :      * Platforms that do not support this metric should return
     294             :      * NS_ERROR_NOT_IMPLEMENTED when queried for this metric.
     295             :      */
     296             :     eIntID_TouchEnabled,
     297             : 
     298             :     /*
     299             :      * A Boolean value to determine whether the Mac graphite theme is
     300             :      * being used.
     301             :      *
     302             :      * The value of this metric is not used on other platforms. These platforms
     303             :      * should return NS_ERROR_NOT_IMPLEMENTED when queried for this metric.
     304             :      */
     305             :     eIntID_MacGraphiteTheme,
     306             : 
     307             :    /*
     308             :     * A Boolean value to determine whether the Mac OS X Yosemite-specific theming
     309             :     * should be used.
     310             :     *
     311             :     * The value of this metric is not used on non-Mac platforms. These
     312             :     * platforms should return NS_ERROR_NOT_IMPLEMENTED when queried for this
     313             :     * metric.
     314             :     */
     315             :    eIntID_MacYosemiteTheme,
     316             : 
     317             :     /*
     318             :      * eIntID_AlertNotificationOrigin indicates from which corner of the
     319             :      * screen alerts slide in, and from which direction (horizontal/vertical).
     320             :      * 0, the default, represents bottom right, sliding vertically.
     321             :      * Use any bitwise combination of the following constants:
     322             :      * NS_ALERT_HORIZONTAL (1), NS_ALERT_LEFT (2), NS_ALERT_TOP (4).
     323             :      *
     324             :      *       6       4
     325             :      *     +-----------+
     326             :      *    7|           |5
     327             :      *     |           |
     328             :      *    3|           |1
     329             :      *     +-----------+
     330             :      *       2       0
     331             :      */
     332             :     eIntID_AlertNotificationOrigin,
     333             : 
     334             :     /**
     335             :      * If true, clicking on a scrollbar (not as in dragging the thumb) defaults
     336             :      * to scrolling the view corresponding to the clicked point. Otherwise, we
     337             :      * only do so if the scrollbar is clicked using the middle mouse button or
     338             :      * if shift is pressed when the scrollbar is clicked.
     339             :      */
     340             :     eIntID_ScrollToClick,
     341             : 
     342             :     /**
     343             :      * IME and spell checker underline styles, the values should be
     344             :      * NS_DECORATION_LINE_STYLE_*.  They are defined below.
     345             :      */
     346             :     eIntID_IMERawInputUnderlineStyle,
     347             :     eIntID_IMESelectedRawTextUnderlineStyle,
     348             :     eIntID_IMEConvertedTextUnderlineStyle,
     349             :     eIntID_IMESelectedConvertedTextUnderline,
     350             :     eIntID_SpellCheckerUnderlineStyle,
     351             : 
     352             :     /**
     353             :      * If this metric != 0, support window dragging on the menubar.
     354             :      */
     355             :     eIntID_MenuBarDrag,
     356             :     /**
     357             :      * Return the appropriate WindowsThemeIdentifier for the current theme.
     358             :      */
     359             :     eIntID_WindowsThemeIdentifier,
     360             :     /**
     361             :      * Return an appropriate os version identifier.
     362             :      */
     363             :     eIntID_OperatingSystemVersionIdentifier,
     364             :     /**
     365             :      * 0: scrollbar button repeats to scroll only when cursor is on the button.
     366             :      * 1: scrollbar button repeats to scroll even if cursor is outside of it.
     367             :      */
     368             :     eIntID_ScrollbarButtonAutoRepeatBehavior,
     369             :     /**
     370             :      * Delay before showing a tooltip.
     371             :      */
     372             :     eIntID_TooltipDelay,
     373             :     /*
     374             :      * A Boolean value to determine whether Mac OS X Lion style swipe animations
     375             :      * should be used.
     376             :      */
     377             :     eIntID_SwipeAnimationEnabled,
     378             : 
     379             :     /*
     380             :      * A Boolean value to determine whether we have a color picker available
     381             :      * for <input type="color"> to hook into.
     382             :      *
     383             :      * This lets us selectively enable the style for <input type="color">
     384             :      * based on whether it's functional or not.
     385             :      */
     386             :     eIntID_ColorPickerAvailable,
     387             : 
     388             :     /*
     389             :      * A boolean value indicating whether or not the device has a hardware
     390             :      * home button. Used on gaia to determine whether a home button
     391             :      * is shown.
     392             :      */
     393             :      eIntID_PhysicalHomeButton,
     394             : 
     395             :      /*
     396             :       * Controls whether overlay scrollbars display when the user moves
     397             :       * the mouse in a scrollable frame.
     398             :       */
     399             :      eIntID_ScrollbarDisplayOnMouseMove,
     400             : 
     401             :      /*
     402             :       * Overlay scrollbar animation constants.
     403             :       */
     404             :      eIntID_ScrollbarFadeBeginDelay,
     405             :      eIntID_ScrollbarFadeDuration,
     406             :       
     407             :      /**
     408             :       * Distance in pixels to offset the context menu from the cursor
     409             :       * on open.
     410             :       */
     411             :      eIntID_ContextMenuOffsetVertical,
     412             :      eIntID_ContextMenuOffsetHorizontal
     413             :   };
     414             : 
     415             :   /**
     416             :    * Windows themes we currently detect.
     417             :    */
     418             :   enum WindowsTheme {
     419             :     eWindowsTheme_Generic = 0, // unrecognized theme
     420             :     eWindowsTheme_Classic,
     421             :     eWindowsTheme_Aero,
     422             :     eWindowsTheme_LunaBlue,
     423             :     eWindowsTheme_LunaOlive,
     424             :     eWindowsTheme_LunaSilver,
     425             :     eWindowsTheme_Royale,
     426             :     eWindowsTheme_Zune,
     427             :     eWindowsTheme_AeroLite
     428             :   };
     429             : 
     430             :   /**
     431             :    * Operating system versions.
     432             :    */
     433             :   enum OperatingSystemVersion {
     434             :     eOperatingSystemVersion_Windows7 = 2,
     435             :     eOperatingSystemVersion_Windows8,
     436             :     eOperatingSystemVersion_Windows10,
     437             :     eOperatingSystemVersion_Unknown
     438             :   };
     439             : 
     440             :   enum {
     441             :     eScrollArrow_None = 0,
     442             :     eScrollArrow_StartBackward = 0x1000,
     443             :     eScrollArrow_StartForward = 0x0100,
     444             :     eScrollArrow_EndBackward = 0x0010,
     445             :     eScrollArrow_EndForward = 0x0001
     446             :   };
     447             : 
     448             :   enum {
     449             :     // single arrow at each end
     450             :     eScrollArrowStyle_Single =
     451             :       eScrollArrow_StartBackward | eScrollArrow_EndForward,
     452             :     // both arrows at bottom/right, none at top/left
     453             :     eScrollArrowStyle_BothAtBottom =
     454             :       eScrollArrow_EndBackward | eScrollArrow_EndForward,
     455             :     // both arrows at both ends
     456             :     eScrollArrowStyle_BothAtEachEnd =
     457             :       eScrollArrow_EndBackward | eScrollArrow_EndForward |
     458             :       eScrollArrow_StartBackward | eScrollArrow_StartForward,
     459             :     // both arrows at top/left, none at bottom/right
     460             :     eScrollArrowStyle_BothAtTop =
     461             :       eScrollArrow_StartBackward | eScrollArrow_StartForward
     462             :   };
     463             : 
     464             :   enum {
     465             :     eScrollThumbStyle_Normal,
     466             :     eScrollThumbStyle_Proportional
     467             :   };
     468             : 
     469             :   // When modifying this list, also modify nsXPLookAndFeel::sFloatPrefs
     470             :   // in widget/xpwidgts/nsXPLookAndFeel.cpp.
     471             :   enum FloatID {
     472             :     eFloatID_IMEUnderlineRelativeSize,
     473             :     eFloatID_SpellCheckerUnderlineRelativeSize,
     474             : 
     475             :     // The width/height ratio of the cursor. If used, the CaretWidth int metric
     476             :     // should be added to the calculated caret width.
     477             :     eFloatID_CaretAspectRatio
     478             :   };
     479             : 
     480             :   // These constants must be kept in 1:1 correspondence with the
     481             :   // NS_STYLE_FONT_* system font constants.
     482             :   enum FontID {
     483             :     eFont_Caption = 1,     // css2
     484             :     FontID_MINIMUM = eFont_Caption,
     485             :     eFont_Icon,
     486             :     eFont_Menu,
     487             :     eFont_MessageBox,
     488             :     eFont_SmallCaption,
     489             :     eFont_StatusBar,
     490             : 
     491             :     eFont_Window,          // css3
     492             :     eFont_Document,
     493             :     eFont_Workspace,
     494             :     eFont_Desktop,
     495             :     eFont_Info,
     496             :     eFont_Dialog,
     497             :     eFont_Button,
     498             :     eFont_PullDownMenu,
     499             :     eFont_List,
     500             :     eFont_Field,
     501             : 
     502             :     eFont_Tooltips,        // moz
     503             :     eFont_Widget,
     504             :     FontID_MAXIMUM = eFont_Widget
     505             :   };
     506             : 
     507             :   /**
     508             :    * GetColor() return a native color value (might be overwritten by prefs) for
     509             :    * aID.  Some platforms don't return an error even if the index doesn't
     510             :    * match any system colors.  And also some platforms may initialize the
     511             :    * return value even when it returns an error.  Therefore, if you want to
     512             :    * use a color for the default value, you should use the other GetColor()
     513             :    * which returns nscolor directly.
     514             :    *
     515             :    * NOTE:
     516             :    *   eColorID_TextSelectForeground might return NS_DONT_CHANGE_COLOR.
     517             :    *   eColorID_IME* might return NS_TRANSPARENT, NS_SAME_AS_FOREGROUND_COLOR or
     518             :    *   NS_40PERCENT_FOREGROUND_COLOR.
     519             :    *   These values have particular meaning.  Then, they are not an actual
     520             :    *   color value.
     521             :    */
     522             :   static nsresult GetColor(ColorID aID, nscolor* aResult);
     523             : 
     524             :    /**
     525             :    * This variant of GetColor() takes an extra Boolean parameter that allows
     526             :    * the caller to ask that hard-coded color values be substituted for
     527             :    * native colors (used when it is desireable to hide system colors to
     528             :    * avoid system fingerprinting).
     529             :    */
     530             :   static nsresult GetColor(ColorID aID, bool aUseStandinsForNativeColors,
     531             :                            nscolor* aResult);
     532             : 
     533             :   /**
     534             :    * GetInt() and GetFloat() return a int or float value for aID.  The result
     535             :    * might be distance, time, some flags or a int value which has particular
     536             :    * meaning.  See each document at definition of each ID for the detail.
     537             :    * The result is always 0 when they return error.  Therefore, if you want to
     538             :    * use a value for the default value, you should use the other method which
     539             :    * returns int or float directly.
     540             :    */
     541             :   static nsresult GetInt(IntID aID, int32_t* aResult);
     542             :   static nsresult GetFloat(FloatID aID, float* aResult);
     543             : 
     544          63 :   static nscolor GetColor(ColorID aID, nscolor aDefault = NS_RGB(0, 0, 0))
     545             :   {
     546          63 :     nscolor result = NS_RGB(0, 0, 0);
     547          63 :     if (NS_FAILED(GetColor(aID, &result))) {
     548           0 :       return aDefault;
     549             :     }
     550          63 :     return result;
     551             :   }
     552             : 
     553           0 :   static nscolor GetColorUsingStandins(ColorID aID,
     554             :                                        nscolor aDefault = NS_RGB(0, 0, 0))
     555             :   {
     556           0 :     nscolor result = NS_RGB(0, 0, 0);
     557           0 :     if (NS_FAILED(GetColor(aID,
     558             :                            true, // aUseStandinsForNativeColors
     559             :                            &result))) {
     560           0 :       return aDefault;
     561             :     }
     562           0 :     return result;
     563             :   }
     564             : 
     565         915 :   static int32_t GetInt(IntID aID, int32_t aDefault = 0)
     566             :   {
     567             :     int32_t result;
     568         915 :     if (NS_FAILED(GetInt(aID, &result))) {
     569         833 :       return aDefault;
     570             :     }
     571          82 :     return result;
     572             :   }
     573             : 
     574           0 :   static float GetFloat(FloatID aID, float aDefault = 0.0f)
     575             :   {
     576             :     float result;
     577           0 :     if (NS_FAILED(GetFloat(aID, &result))) {
     578           0 :       return aDefault;
     579             :     }
     580           0 :     return result;
     581             :   }
     582             : 
     583             :   /**
     584             :    * Retrieve the name and style of a system-theme font.  Returns true
     585             :    * if the system theme specifies this font, false if a default should
     586             :    * be used.  In the latter case neither aName nor aStyle is modified.
     587             :    *
     588             :    * @param aID    Which system-theme font is wanted.
     589             :    * @param aName  The name of the font to use.
     590             :    * @param aStyle Styling to apply to the font.
     591             :    * @param aDevPixPerCSSPixel  Ratio of device pixels to CSS pixels
     592             :    */
     593             :   static bool GetFont(FontID aID, nsString& aName, gfxFontStyle& aStyle,
     594             :                       float aDevPixPerCSSPixel);
     595             : 
     596             :   /**
     597             :    * GetPasswordCharacter() returns a unicode character which should be used
     598             :    * for a masked character in password editor.  E.g., '*'.
     599             :    */
     600             :   static char16_t GetPasswordCharacter();
     601             : 
     602             :   /**
     603             :    * If the latest character in password field shouldn't be hidden by the
     604             :    * result of GetPasswordCharacter(), GetEchoPassword() returns TRUE.
     605             :    * Otherwise, FALSE.
     606             :    */
     607             :   static bool GetEchoPassword();
     608             : 
     609             :   /**
     610             :    * The millisecond to mask password value.
     611             :    * This value is only valid when GetEchoPassword() returns true.
     612             :    */
     613             :   static uint32_t GetPasswordMaskDelay();
     614             : 
     615             :   /**
     616             :    * When system look and feel is changed, Refresh() must be called.  Then,
     617             :    * cached data would be released.
     618             :    */
     619             :   static void Refresh();
     620             : 
     621             :   /**
     622             :    * If the implementation is caching values, these accessors allow the
     623             :    * cache to be exported and imported.
     624             :    */
     625             :   static nsTArray<LookAndFeelInt> GetIntCache();
     626             :   static void SetIntCache(const nsTArray<LookAndFeelInt>& aLookAndFeelIntCache);
     627             : };
     628             : 
     629             : } // namespace mozilla
     630             : 
     631             : // On the Mac, GetColor(eColorID_TextSelectForeground, color) returns this
     632             : // constant to specify that the foreground color should not be changed
     633             : // (ie. a colored text keeps its colors  when selected).
     634             : // Of course if other plaforms work like the Mac, they can use it too.
     635             : #define NS_DONT_CHANGE_COLOR    NS_RGB(0x01, 0x01, 0x01)
     636             : 
     637             : // Similar with NS_DONT_CHANGE_COLOR, except NS_DONT_CHANGE_COLOR would returns
     638             : // complementary color if fg color is same as bg color.
     639             : // NS_CHANGE_COLOR_IF_SAME_AS_BG would returns eColorID_TextSelectForegroundCustom if
     640             : // fg and bg color are the same.
     641             : #define NS_CHANGE_COLOR_IF_SAME_AS_BG NS_RGB(0x02, 0x02, 0x02)
     642             : 
     643             : // ---------------------------------------------------------------------
     644             : //  Special colors for eColorID_IME* and eColorID_SpellCheckerUnderline
     645             : // ---------------------------------------------------------------------
     646             : 
     647             : // For background color only.
     648             : #define NS_TRANSPARENT                NS_RGBA(0x01, 0x00, 0x00, 0x00)
     649             : // For foreground color only.
     650             : #define NS_SAME_AS_FOREGROUND_COLOR   NS_RGBA(0x02, 0x00, 0x00, 0x00)
     651             : #define NS_40PERCENT_FOREGROUND_COLOR NS_RGBA(0x03, 0x00, 0x00, 0x00)
     652             : 
     653             : #define NS_IS_SELECTION_SPECIAL_COLOR(c) ((c) == NS_TRANSPARENT || \
     654             :                                           (c) == NS_SAME_AS_FOREGROUND_COLOR || \
     655             :                                           (c) == NS_40PERCENT_FOREGROUND_COLOR)
     656             : 
     657             : // ------------------------------------------
     658             : //  Bits for eIntID_AlertNotificationOrigin
     659             : // ------------------------------------------
     660             : 
     661             : #define NS_ALERT_HORIZONTAL 1
     662             : #define NS_ALERT_LEFT       2
     663             : #define NS_ALERT_TOP        4
     664             : 
     665             : #endif /* __LookAndFeel */

Generated by: LCOV version 1.13