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/. */
9 #ifndef MOZILLA_INTERNAL_API
10 # error "This header is only usable from within libxul (MOZILLA_INTERNAL_API)."
19 struct LookAndFeelInt
{
31 // When modifying this list, also modify nsXPLookAndFeel::sColorPrefs
32 // in widget/xpwidgts/nsXPLookAndFeel.cpp.
33 enum ColorID
: uint8_t {
35 // WARNING : NO NEGATIVE VALUE IN THIS ENUMERATION
36 // see patch in bug 57757 for more information
38 eColorID_WindowBackground
,
39 eColorID_WindowForeground
,
40 eColorID_WidgetBackground
,
41 eColorID_WidgetForeground
,
42 eColorID_WidgetSelectBackground
,
43 eColorID_WidgetSelectForeground
,
44 eColorID_Widget3DHighlight
,
45 eColorID_Widget3DShadow
,
46 eColorID_TextBackground
,
47 eColorID_TextForeground
,
48 eColorID_TextSelectBackground
,
49 eColorID_TextSelectForeground
,
50 eColorID_TextSelectForegroundCustom
,
51 eColorID_TextSelectBackgroundDisabled
,
52 eColorID_TextSelectBackgroundAttention
,
53 eColorID_TextHighlightBackground
,
54 eColorID_TextHighlightForeground
,
56 eColorID_IMERawInputBackground
,
57 eColorID_IMERawInputForeground
,
58 eColorID_IMERawInputUnderline
,
59 eColorID_IMESelectedRawTextBackground
,
60 eColorID_IMESelectedRawTextForeground
,
61 eColorID_IMESelectedRawTextUnderline
,
62 eColorID_IMEConvertedTextBackground
,
63 eColorID_IMEConvertedTextForeground
,
64 eColorID_IMEConvertedTextUnderline
,
65 eColorID_IMESelectedConvertedTextBackground
,
66 eColorID_IMESelectedConvertedTextForeground
,
67 eColorID_IMESelectedConvertedTextUnderline
,
69 eColorID_SpellCheckerUnderline
,
71 // New CSS 2 color definitions
72 eColorID_activeborder
,
73 eColorID_activecaption
,
74 eColorID_appworkspace
,
77 eColorID_buttonhighlight
,
78 eColorID_buttonshadow
,
83 eColorID_highlighttext
,
84 eColorID_inactiveborder
,
85 eColorID_inactivecaption
,
86 eColorID_inactivecaptiontext
,
87 eColorID_infobackground
,
92 eColorID_threeddarkshadow
,
94 eColorID_threedhighlight
,
95 eColorID_threedlightshadow
,
96 eColorID_threedshadow
,
101 eColorID__moz_buttondefault
,
102 // Colors which will hopefully become CSS3
104 eColorID__moz_fieldtext
,
105 eColorID__moz_dialog
,
106 eColorID__moz_dialogtext
,
107 // used to highlight valid regions to drop something onto
108 eColorID__moz_dragtargetzone
,
110 // used to cell text background, selected but not focus.
111 // It is not necessarily a system color, but it is
112 // distinct from -moz-appearance: listbox; and Highlight
113 eColorID__moz_cellhighlight
,
114 // used to cell text, selected but not focus
115 eColorID__moz_cellhighlighttext
,
116 // used to html select cell text background, selected but not focus
117 eColorID__moz_html_cellhighlight
,
118 // used to html select cell text, selected but not focus
119 eColorID__moz_html_cellhighlighttext
,
120 // used to button text background, when mouse is over
121 eColorID__moz_buttonhoverface
,
122 // used to button text, when mouse is over
123 eColorID__moz_buttonhovertext
,
124 // used to menu item background, when mouse is over
125 eColorID__moz_menuhover
,
126 // used to menu item text, when mouse is over
127 eColorID__moz_menuhovertext
,
128 // used to menu bar item text
129 eColorID__moz_menubartext
,
130 // used to menu bar item text, when mouse is over
131 eColorID__moz_menubarhovertext
,
132 // On platforms where these colors are the same as
133 // -moz-field, use -moz-fieldtext as foreground color
134 eColorID__moz_eventreerow
,
135 eColorID__moz_oddtreerow
,
137 // colors needed by the Mac OS X theme
139 // foreground color of :hover:active buttons
140 eColorID__moz_mac_buttonactivetext
,
141 // background color of chrome toolbars in active windows
142 eColorID__moz_mac_chrome_active
,
143 // background color of chrome toolbars in inactive windows
144 eColorID__moz_mac_chrome_inactive
,
145 // foreground color of default buttons
146 eColorID__moz_mac_defaultbuttontext
,
147 // ring around text fields and lists
148 eColorID__moz_mac_focusring
,
149 // colour used when mouse is over a menu item
150 eColorID__moz_mac_menuselect
,
151 // colour used to do shadows on menu items
152 eColorID__moz_mac_menushadow
,
153 // color used to display text for disabled menu items
154 eColorID__moz_mac_menutextdisable
,
155 // colour used to display text while mouse is over a menu item
156 eColorID__moz_mac_menutextselect
,
157 // text color of disabled text on toolbars
158 eColorID__moz_mac_disabledtoolbartext
,
159 // inactive light hightlight
160 eColorID__moz_mac_secondaryhighlight
,
162 // Font smoothing background colors needed by the Mac OS X theme, based
163 // on -moz-appearance names
164 eColorID__moz_mac_vibrancy_light
,
165 eColorID__moz_mac_vibrancy_dark
,
166 eColorID__moz_mac_vibrant_titlebar_light
,
167 eColorID__moz_mac_vibrant_titlebar_dark
,
168 eColorID__moz_mac_menupopup
,
169 eColorID__moz_mac_menuitem
,
170 eColorID__moz_mac_active_menuitem
,
171 eColorID__moz_mac_source_list
,
172 eColorID__moz_mac_source_list_selection
,
173 eColorID__moz_mac_active_source_list_selection
,
174 eColorID__moz_mac_tooltip
,
178 // accent color for title bar
179 eColorID__moz_win_accentcolor
,
180 // color from drawing text over the accent color
181 eColorID__moz_win_accentcolortext
,
183 eColorID__moz_win_mediatext
,
184 // communications rebar text
185 eColorID__moz_win_communicationstext
,
187 // Hyperlink color extracted from the system, not affected by the
188 // browser.anchor_color user pref.
189 // There is no OS-specified safe background color for this text,
190 // but it is used regularly within Windows and the Gnome DE on Dialog and
192 eColorID__moz_nativehyperlinktext
,
195 eColorID__moz_comboboxtext
,
196 eColorID__moz_combobox
,
199 eColorID__moz_gtk_info_bar_text
,
201 // keep this one last, please
205 // When modifying this list, also modify nsXPLookAndFeel::sIntPrefs
206 // in widget/xpwidgts/nsXPLookAndFeel.cpp.
208 // default, may be overriden by OS
209 eIntID_CaretBlinkTime
,
210 // pixel width of caret
212 // show the caret when text is selected?
213 eIntID_ShowCaretDuringSelection
,
214 // select textfields when focused via tab/accesskey?
215 eIntID_SelectTextfieldsOnKeyFocus
,
216 // delay before submenus open
218 // can popups overlap menu/task bar?
219 eIntID_MenusCanOverlapOSBar
,
220 // should overlay scrollbars be used?
221 eIntID_UseOverlayScrollbars
,
222 // allow H and V overlay scrollbars to overlap?
223 eIntID_AllowOverlayScrollbarsOverlap
,
224 // show/hide scrollbars based on activity
225 eIntID_ShowHideScrollbars
,
226 // skip navigating to disabled menu item?
227 eIntID_SkipNavigatingDisabledMenuItem
,
228 // begin a drag if the mouse is moved further than the threshold while the
230 eIntID_DragThresholdX
,
231 eIntID_DragThresholdY
,
232 // Accessibility theme being used?
233 eIntID_UseAccessibilityTheme
,
235 // position of scroll arrows in a scrollbar
236 eIntID_ScrollArrowStyle
,
237 // is scroll thumb proportional or fixed?
238 eIntID_ScrollSliderStyle
,
240 // each button can take one of four values:
241 eIntID_ScrollButtonLeftMouseButtonAction
,
242 // 0 - scrolls one line, 1 - scrolls one page
243 eIntID_ScrollButtonMiddleMouseButtonAction
,
244 // 2 - scrolls to end, 3 - button ignored
245 eIntID_ScrollButtonRightMouseButtonAction
,
247 // delay for opening spring loaded folders
248 eIntID_TreeOpenDelay
,
249 // delay for closing spring loaded folders
250 eIntID_TreeCloseDelay
,
251 // delay for triggering the tree scrolling
252 eIntID_TreeLazyScrollDelay
,
253 // delay for scrolling the tree
254 eIntID_TreeScrollDelay
,
255 // the maximum number of lines to be scrolled at ones
256 eIntID_TreeScrollLinesMax
,
257 // What type of tab-order to use
258 eIntID_TabFocusModel
,
259 // Should menu items blink when they're chosen?
260 eIntID_ChosenMenuItemsShouldBlink
,
263 * A Boolean value to determine whether the Windows accent color
264 * should be applied to the title bar.
266 * The value of this metric is not used on other platforms. These platforms
267 * should return NS_ERROR_NOT_IMPLEMENTED when queried for this metric.
269 eIntID_WindowsAccentColorInTitlebar
,
272 * A Boolean value to determine whether the Windows default theme is
275 * The value of this metric is not used on other platforms. These platforms
276 * should return NS_ERROR_NOT_IMPLEMENTED when queried for this metric.
278 eIntID_WindowsDefaultTheme
,
281 * A Boolean value to determine whether the DWM compositor is being used
283 * This metric is not used on non-Windows platforms. These platforms
284 * should return NS_ERROR_NOT_IMPLEMENTED when queried for this metric.
286 eIntID_DWMCompositor
,
289 * A Boolean value to determine whether Windows is themed (Classic vs.
292 * This is Windows-specific and is not implemented on other platforms
293 * (will return the default of NS_ERROR_FAILURE).
295 eIntID_WindowsClassic
,
298 * A Boolean value to determine whether the current Windows desktop theme
299 * supports Aero Glass.
301 * This is Windows-specific and is not implemented on other platforms
302 * (will return the default of NS_ERROR_FAILURE).
307 * A Boolean value to determine whether the device is a touch enabled
308 * device. Currently this is only supported by the Windows 7 Touch API.
310 * Platforms that do not support this metric should return
311 * NS_ERROR_NOT_IMPLEMENTED when queried for this metric.
316 * A Boolean value to determine whether the Mac graphite theme is
319 * The value of this metric is not used on other platforms. These platforms
320 * should return NS_ERROR_NOT_IMPLEMENTED when queried for this metric.
322 eIntID_MacGraphiteTheme
,
325 * A Boolean value to determine whether the Mac OS X Yosemite-specific
326 * theming should be used.
328 * The value of this metric is not used on non-Mac platforms. These
329 * platforms should return NS_ERROR_NOT_IMPLEMENTED when queried for this
332 eIntID_MacYosemiteTheme
,
335 * eIntID_AlertNotificationOrigin indicates from which corner of the
336 * screen alerts slide in, and from which direction (horizontal/vertical).
337 * 0, the default, represents bottom right, sliding vertically.
338 * Use any bitwise combination of the following constants:
339 * NS_ALERT_HORIZONTAL (1), NS_ALERT_LEFT (2), NS_ALERT_TOP (4).
349 eIntID_AlertNotificationOrigin
,
352 * If true, clicking on a scrollbar (not as in dragging the thumb) defaults
353 * to scrolling the view corresponding to the clicked point. Otherwise, we
354 * only do so if the scrollbar is clicked using the middle mouse button or
355 * if shift is pressed when the scrollbar is clicked.
357 eIntID_ScrollToClick
,
360 * IME and spell checker underline styles, the values should be
361 * NS_DECORATION_LINE_STYLE_*. They are defined below.
363 eIntID_IMERawInputUnderlineStyle
,
364 eIntID_IMESelectedRawTextUnderlineStyle
,
365 eIntID_IMEConvertedTextUnderlineStyle
,
366 eIntID_IMESelectedConvertedTextUnderline
,
367 eIntID_SpellCheckerUnderlineStyle
,
370 * If this metric != 0, support window dragging on the menubar.
374 * Return the appropriate WindowsThemeIdentifier for the current theme.
376 eIntID_WindowsThemeIdentifier
,
378 * Return an appropriate os version identifier.
380 eIntID_OperatingSystemVersionIdentifier
,
382 * 0: scrollbar button repeats to scroll only when cursor is on the button.
383 * 1: scrollbar button repeats to scroll even if cursor is outside of it.
385 eIntID_ScrollbarButtonAutoRepeatBehavior
,
387 * Delay before showing a tooltip.
391 * A Boolean value to determine whether Mac OS X Lion style swipe animations
394 eIntID_SwipeAnimationEnabled
,
397 * Controls whether overlay scrollbars display when the user moves
398 * the mouse in a scrollable frame.
400 eIntID_ScrollbarDisplayOnMouseMove
,
403 * Overlay scrollbar animation constants.
405 eIntID_ScrollbarFadeBeginDelay
,
406 eIntID_ScrollbarFadeDuration
,
409 * Distance in pixels to offset the context menu from the cursor
412 eIntID_ContextMenuOffsetVertical
,
413 eIntID_ContextMenuOffsetHorizontal
,
416 * A boolean value indicating whether client-side decorations are
417 * supported by the user's GTK version.
419 eIntID_GTKCSDAvailable
,
422 * A boolean value indicating whether GTK+ system titlebar should be
423 * disabled by default.
425 eIntID_GTKCSDHideTitlebarByDefault
,
428 * A boolean value indicating whether client-side decorations should
429 * have transparent background.
431 eIntID_GTKCSDTransparentBackground
,
434 * A boolean value indicating whether client-side decorations should
435 * contain a minimize button.
437 eIntID_GTKCSDMinimizeButton
,
440 * A boolean value indicating whether client-side decorations should
441 * contain a maximize button.
443 eIntID_GTKCSDMaximizeButton
,
446 * A boolean value indicating whether client-side decorations should
447 * contain a close button.
449 eIntID_GTKCSDCloseButton
,
452 * A boolean value indicating whether titlebar buttons are located
453 * in left titlebar corner.
455 eIntID_GTKCSDReversedPlacement
,
458 * A boolean value indicating whether or not the OS is using a dark theme,
459 * which we may want to switch to as well if not overridden by the user.
461 eIntID_SystemUsesDarkTheme
,
464 * Corresponding to prefers-reduced-motion.
465 * https://drafts.csswg.org/mediaqueries-5/#prefers-reduced-motion
470 eIntID_PrefersReducedMotion
,
472 * Corresponding to PointerCapabilities in ServoTypes.h
478 eIntID_PrimaryPointerCapabilities
,
480 * Corresponding to union of PointerCapabilities values in ServoTypes.h
481 * E.g. if there is a mouse and a digitizer, the value will be
482 * 'Coarse | Fine | Hover'.
484 eIntID_AllPointerCapabilities
,
488 * Windows themes we currently detect.
491 eWindowsTheme_Generic
= 0, // unrecognized theme
492 eWindowsTheme_Classic
,
494 eWindowsTheme_LunaBlue
,
495 eWindowsTheme_LunaOlive
,
496 eWindowsTheme_LunaSilver
,
497 eWindowsTheme_Royale
,
499 eWindowsTheme_AeroLite
503 * Operating system versions.
505 enum OperatingSystemVersion
{
506 eOperatingSystemVersion_Windows7
= 2,
507 eOperatingSystemVersion_Windows8
,
508 eOperatingSystemVersion_Windows10
,
509 eOperatingSystemVersion_Unknown
513 eScrollArrow_None
= 0,
514 eScrollArrow_StartBackward
= 0x1000,
515 eScrollArrow_StartForward
= 0x0100,
516 eScrollArrow_EndBackward
= 0x0010,
517 eScrollArrow_EndForward
= 0x0001
521 // single arrow at each end
522 eScrollArrowStyle_Single
=
523 eScrollArrow_StartBackward
| eScrollArrow_EndForward
,
524 // both arrows at bottom/right, none at top/left
525 eScrollArrowStyle_BothAtBottom
=
526 eScrollArrow_EndBackward
| eScrollArrow_EndForward
,
527 // both arrows at both ends
528 eScrollArrowStyle_BothAtEachEnd
=
529 eScrollArrow_EndBackward
| eScrollArrow_EndForward
|
530 eScrollArrow_StartBackward
| eScrollArrow_StartForward
,
531 // both arrows at top/left, none at bottom/right
532 eScrollArrowStyle_BothAtTop
=
533 eScrollArrow_StartBackward
| eScrollArrow_StartForward
536 enum { eScrollThumbStyle_Normal
, eScrollThumbStyle_Proportional
};
538 // When modifying this list, also modify nsXPLookAndFeel::sFloatPrefs
539 // in widget/xpwidgts/nsXPLookAndFeel.cpp.
541 eFloatID_IMEUnderlineRelativeSize
,
542 eFloatID_SpellCheckerUnderlineRelativeSize
,
544 // The width/height ratio of the cursor. If used, the CaretWidth int metric
545 // should be added to the calculated caret width.
546 eFloatID_CaretAspectRatio
549 // These constants must be kept in 1:1 correspondence with the
550 // NS_STYLE_FONT_* system font constants.
552 eFont_Caption
= 1, // css2
553 FontID_MINIMUM
= eFont_Caption
,
560 eFont_Window
, // css3
571 eFont_Tooltips
, // moz
573 FontID_MAXIMUM
= eFont_Widget
577 * GetColor() return a native color value (might be overwritten by prefs) for
578 * aID. Some platforms don't return an error even if the index doesn't
579 * match any system colors. And also some platforms may initialize the
580 * return value even when it returns an error. Therefore, if you want to
581 * use a color for the default value, you should use the other GetColor()
582 * which returns nscolor directly.
585 * eColorID_TextSelectForeground might return NS_DONT_CHANGE_COLOR.
586 * eColorID_IME* might return NS_TRANSPARENT, NS_SAME_AS_FOREGROUND_COLOR or
587 * NS_40PERCENT_FOREGROUND_COLOR.
588 * These values have particular meaning. Then, they are not an actual
591 static nsresult
GetColor(ColorID aID
, nscolor
* aResult
);
594 * This variant of GetColor() takes an extra Boolean parameter that allows
595 * the caller to ask that hard-coded color values be substituted for
596 * native colors (used when it is desireable to hide system colors to
597 * avoid system fingerprinting).
599 static nsresult
GetColor(ColorID aID
, bool aUseStandinsForNativeColors
,
603 * GetInt() and GetFloat() return a int or float value for aID. The result
604 * might be distance, time, some flags or a int value which has particular
605 * meaning. See each document at definition of each ID for the detail.
606 * The result is always 0 when they return error. Therefore, if you want to
607 * use a value for the default value, you should use the other method which
608 * returns int or float directly.
610 static nsresult
GetInt(IntID aID
, int32_t* aResult
);
611 static nsresult
GetFloat(FloatID aID
, float* aResult
);
613 static nscolor
GetColor(ColorID aID
, nscolor aDefault
= NS_RGB(0, 0, 0)) {
614 nscolor result
= NS_RGB(0, 0, 0);
615 if (NS_FAILED(GetColor(aID
, &result
))) {
621 static nscolor
GetColorUsingStandins(ColorID aID
,
622 nscolor aDefault
= NS_RGB(0, 0, 0)) {
623 nscolor result
= NS_RGB(0, 0, 0);
624 if (NS_FAILED(GetColor(aID
,
625 true, // aUseStandinsForNativeColors
632 static int32_t GetInt(IntID aID
, int32_t aDefault
= 0) {
634 if (NS_FAILED(GetInt(aID
, &result
))) {
640 static float GetFloat(FloatID aID
, float aDefault
= 0.0f
) {
642 if (NS_FAILED(GetFloat(aID
, &result
))) {
649 * Retrieve the name and style of a system-theme font. Returns true
650 * if the system theme specifies this font, false if a default should
651 * be used. In the latter case neither aName nor aStyle is modified.
653 * Size of the font should be in CSS pixels, not device pixels.
655 * @param aID Which system-theme font is wanted.
656 * @param aName The name of the font to use.
657 * @param aStyle Styling to apply to the font.
659 static bool GetFont(FontID aID
, nsString
& aName
, gfxFontStyle
& aStyle
);
662 * GetPasswordCharacter() returns a unicode character which should be used
663 * for a masked character in password editor. E.g., '*'.
665 static char16_t
GetPasswordCharacter();
668 * If the latest character in password field shouldn't be hidden by the
669 * result of GetPasswordCharacter(), GetEchoPassword() returns TRUE.
672 static bool GetEchoPassword();
675 * The millisecond to mask password value.
676 * This value is only valid when GetEchoPassword() returns true.
678 static uint32_t GetPasswordMaskDelay();
681 * When system look and feel is changed, Refresh() must be called. Then,
682 * cached data would be released.
684 static void Refresh();
687 * GTK's initialization code can't be run off main thread, call this
688 * if you plan on using LookAndFeel off main thread later.
690 * This initialized state may get reset due to theme changes, so it
691 * must be called prior to each potential off-main-thread LookAndFeel
692 * call, not just once.
694 static void NativeInit();
697 * If the implementation is caching values, these accessors allow the
698 * cache to be exported and imported.
700 static nsTArray
<LookAndFeelInt
> GetIntCache();
701 static void SetIntCache(const nsTArray
<LookAndFeelInt
>& aLookAndFeelIntCache
);
703 * Set a flag indicating whether the cache should be cleared in RefreshImpl()
706 static void SetShouldRetainCacheForTest(bool aValue
);
709 } // namespace mozilla
711 // On the Mac, GetColor(eColorID_TextSelectForeground, color) returns this
712 // constant to specify that the foreground color should not be changed
713 // (ie. a colored text keeps its colors when selected).
714 // Of course if other plaforms work like the Mac, they can use it too.
715 #define NS_DONT_CHANGE_COLOR NS_RGB(0x01, 0x01, 0x01)
717 // Similar with NS_DONT_CHANGE_COLOR, except NS_DONT_CHANGE_COLOR would returns
718 // complementary color if fg color is same as bg color.
719 // NS_CHANGE_COLOR_IF_SAME_AS_BG would returns
720 // eColorID_TextSelectForegroundCustom if fg and bg color are the same.
721 #define NS_CHANGE_COLOR_IF_SAME_AS_BG NS_RGB(0x02, 0x02, 0x02)
723 // ---------------------------------------------------------------------
724 // Special colors for eColorID_IME* and eColorID_SpellCheckerUnderline
725 // ---------------------------------------------------------------------
727 // For background color only.
728 #define NS_TRANSPARENT NS_RGBA(0x01, 0x00, 0x00, 0x00)
729 // For foreground color only.
730 #define NS_SAME_AS_FOREGROUND_COLOR NS_RGBA(0x02, 0x00, 0x00, 0x00)
731 #define NS_40PERCENT_FOREGROUND_COLOR NS_RGBA(0x03, 0x00, 0x00, 0x00)
733 #define NS_IS_SELECTION_SPECIAL_COLOR(c) \
734 ((c) == NS_TRANSPARENT || (c) == NS_SAME_AS_FOREGROUND_COLOR || \
735 (c) == NS_40PERCENT_FOREGROUND_COLOR)
737 // ------------------------------------------
738 // Bits for eIntID_AlertNotificationOrigin
739 // ------------------------------------------
741 #define NS_ALERT_HORIZONTAL 1
742 #define NS_ALERT_LEFT 2
743 #define NS_ALERT_TOP 4
745 #endif /* __LookAndFeel */