Coverage Report

Created: 2018-09-25 14:53

/work/obj-fuzz/dist/include/mozilla/LookAndFeel.h
Line
Count
Source (jump to first uncovered line)
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
    // It is not necessarily a system color, but it is
111
    // distinct from -moz-appearance: listbox; and Highlight
112
    eColorID__moz_cellhighlight,
113
    // used to cell text, selected but not focus
114
    eColorID__moz_cellhighlighttext,
115
    // used to html select cell text background, selected but not focus
116
    eColorID__moz_html_cellhighlight,
117
    // used to html select cell text, selected but not focus
118
    eColorID__moz_html_cellhighlighttext,
119
    // used to button text background, when mouse is over
120
    eColorID__moz_buttonhoverface,
121
    // used to button text, when mouse is over
122
    eColorID__moz_buttonhovertext,
123
    // used to menu item background, when mouse is over
124
    eColorID__moz_menuhover,
125
    // used to menu item text, when mouse is over
126
    eColorID__moz_menuhovertext,
127
    // used to menu bar item text
128
    eColorID__moz_menubartext,
129
    // used to menu bar item text, when mouse is over
130
    eColorID__moz_menubarhovertext,
131
    // On platforms where these colors are the same as
132
    // -moz-field, use -moz-fieldtext as foreground color
133
    eColorID__moz_eventreerow,
134
    eColorID__moz_oddtreerow,
135
136
    // colors needed by the Mac OS X theme
137
138
    // foreground color of :hover:active buttons
139
    eColorID__moz_mac_buttonactivetext,
140
    // background color of chrome toolbars in active windows
141
    eColorID__moz_mac_chrome_active,
142
    // background color of chrome toolbars in inactive windows
143
    eColorID__moz_mac_chrome_inactive,
144
    // foreground color of default buttons
145
    eColorID__moz_mac_defaultbuttontext,
146
    //ring around text fields and lists
147
    eColorID__moz_mac_focusring,
148
    //colour used when mouse is over a menu item
149
    eColorID__moz_mac_menuselect,
150
    //colour used to do shadows on menu items
151
    eColorID__moz_mac_menushadow,
152
    // color used to display text for disabled menu items
153
    eColorID__moz_mac_menutextdisable,
154
    //colour used to display text while mouse is over a menu item
155
    eColorID__moz_mac_menutextselect,
156
    // text color of disabled text on toolbars
157
    eColorID__moz_mac_disabledtoolbartext,
158
    //inactive light hightlight
159
    eColorID__moz_mac_secondaryhighlight,
160
161
    // Font smoothing background colors needed by the Mac OS X theme, based
162
    // on -moz-appearance names
163
    eColorID__moz_mac_vibrancy_light,
164
    eColorID__moz_mac_vibrancy_dark,
165
    eColorID__moz_mac_vibrant_titlebar_light,
166
    eColorID__moz_mac_vibrant_titlebar_dark,
167
    eColorID__moz_mac_menupopup,
168
    eColorID__moz_mac_menuitem,
169
    eColorID__moz_mac_active_menuitem,
170
    eColorID__moz_mac_source_list,
171
    eColorID__moz_mac_source_list_selection,
172
    eColorID__moz_mac_active_source_list_selection,
173
    eColorID__moz_mac_tooltip,
174
175
    // vista rebars
176
177
    // accent color for title bar
178
    eColorID__moz_win_accentcolor,
179
    // color from drawing text over the accent color
180
    eColorID__moz_win_accentcolortext,
181
    // media rebar text
182
    eColorID__moz_win_mediatext,
183
    // communications rebar text
184
    eColorID__moz_win_communicationstext,
185
186
    // Hyperlink color extracted from the system, not affected by the
187
    // browser.anchor_color user pref.
188
    // There is no OS-specified safe background color for this text,
189
    // but it is used regularly within Windows and the Gnome DE on Dialog and
190
    // Window colors.
191
    eColorID__moz_nativehyperlinktext,
192
193
    // Combo box widgets
194
    eColorID__moz_comboboxtext,
195
    eColorID__moz_combobox,
196
197
    // GtkInfoBar
198
    eColorID__moz_gtk_info_bar_text,
199
200
    // keep this one last, please
201
    eColorID_LAST_COLOR
202
  };
203
204
  // When modifying this list, also modify nsXPLookAndFeel::sIntPrefs
205
  // in widget/xpwidgts/nsXPLookAndFeel.cpp.
206
  enum IntID {
207
    // default, may be overriden by OS
208
    eIntID_CaretBlinkTime,
209
    // pixel width of caret
210
    eIntID_CaretWidth,
211
    // show the caret when text is selected?
212
    eIntID_ShowCaretDuringSelection,
213
    // select textfields when focused via tab/accesskey?
214
    eIntID_SelectTextfieldsOnKeyFocus,
215
    // delay before submenus open
216
    eIntID_SubmenuDelay,
217
    // can popups overlap menu/task bar?
218
    eIntID_MenusCanOverlapOSBar,
219
    // should overlay scrollbars be used?
220
    eIntID_UseOverlayScrollbars,
221
    // allow H and V overlay scrollbars to overlap?
222
    eIntID_AllowOverlayScrollbarsOverlap,
223
    // show/hide scrollbars based on activity
224
    eIntID_ShowHideScrollbars,
225
    // skip navigating to disabled menu item?
226
    eIntID_SkipNavigatingDisabledMenuItem,
227
    // begin a drag if the mouse is moved further than the threshold while the
228
    // button is down
229
    eIntID_DragThresholdX,
230
    eIntID_DragThresholdY,
231
    // Accessibility theme being used?
232
    eIntID_UseAccessibilityTheme,
233
234
    // position of scroll arrows in a scrollbar
235
    eIntID_ScrollArrowStyle,
236
    // is scroll thumb proportional or fixed?
237
    eIntID_ScrollSliderStyle,
238
239
    // each button can take one of four values:
240
    eIntID_ScrollButtonLeftMouseButtonAction,
241
    // 0 - scrolls one  line, 1 - scrolls one page
242
    eIntID_ScrollButtonMiddleMouseButtonAction,
243
    // 2 - scrolls to end, 3 - button ignored
244
    eIntID_ScrollButtonRightMouseButtonAction,
245
246
    // delay for opening spring loaded folders
247
    eIntID_TreeOpenDelay,
248
    // delay for closing spring loaded folders
249
    eIntID_TreeCloseDelay,
250
    // delay for triggering the tree scrolling
251
    eIntID_TreeLazyScrollDelay,
252
    // delay for scrolling the tree
253
    eIntID_TreeScrollDelay,
254
    // the maximum number of lines to be scrolled at ones
255
    eIntID_TreeScrollLinesMax,
256
    // What type of tab-order to use
257
    eIntID_TabFocusModel,
258
    // Should menu items blink when they're chosen?
259
    eIntID_ChosenMenuItemsShouldBlink,
260
261
    /*
262
     * A Boolean value to determine whether the Windows accent color
263
     * should be applied to the title bar.
264
     *
265
     * The value of this metric is not used on other platforms. These platforms
266
     * should return NS_ERROR_NOT_IMPLEMENTED when queried for this metric.
267
     */
268
    eIntID_WindowsAccentColorInTitlebar,
269
270
    /*
271
     * A Boolean value to determine whether the Windows default theme is
272
     * being used.
273
     *
274
     * The value of this metric is not used on other platforms. These platforms
275
     * should return NS_ERROR_NOT_IMPLEMENTED when queried for this metric.
276
     */
277
    eIntID_WindowsDefaultTheme,
278
279
    /*
280
     * A Boolean value to determine whether the DWM compositor is being used
281
     *
282
     * This metric is not used on non-Windows platforms. These platforms
283
     * should return NS_ERROR_NOT_IMPLEMENTED when queried for this metric.
284
     */
285
    eIntID_DWMCompositor,
286
287
    /*
288
     * A Boolean value to determine whether Windows is themed (Classic vs.
289
     * uxtheme)
290
     *
291
     * This is Windows-specific and is not implemented on other platforms
292
     * (will return the default of NS_ERROR_FAILURE).
293
     */
294
    eIntID_WindowsClassic,
295
296
    /*
297
     * A Boolean value to determine whether the current Windows desktop theme
298
     * supports Aero Glass.
299
     *
300
     * This is Windows-specific and is not implemented on other platforms
301
     * (will return the default of NS_ERROR_FAILURE).
302
     */
303
    eIntID_WindowsGlass,
304
305
    /*
306
     * A Boolean value to determine whether the device is a touch enabled
307
     * device. Currently this is only supported by the Windows 7 Touch API.
308
     *
309
     * Platforms that do not support this metric should return
310
     * NS_ERROR_NOT_IMPLEMENTED when queried for this metric.
311
     */
312
    eIntID_TouchEnabled,
313
314
    /*
315
     * A Boolean value to determine whether the Mac graphite theme is
316
     * being used.
317
     *
318
     * The value of this metric is not used on other platforms. These platforms
319
     * should return NS_ERROR_NOT_IMPLEMENTED when queried for this metric.
320
     */
321
    eIntID_MacGraphiteTheme,
322
323
   /*
324
    * A Boolean value to determine whether the Mac OS X Yosemite-specific theming
325
    * should be used.
326
    *
327
    * The value of this metric is not used on non-Mac platforms. These
328
    * platforms should return NS_ERROR_NOT_IMPLEMENTED when queried for this
329
    * metric.
330
    */
331
   eIntID_MacYosemiteTheme,
332
333
    /*
334
     * eIntID_AlertNotificationOrigin indicates from which corner of the
335
     * screen alerts slide in, and from which direction (horizontal/vertical).
336
     * 0, the default, represents bottom right, sliding vertically.
337
     * Use any bitwise combination of the following constants:
338
     * NS_ALERT_HORIZONTAL (1), NS_ALERT_LEFT (2), NS_ALERT_TOP (4).
339
     *
340
     *       6       4
341
     *     +-----------+
342
     *    7|           |5
343
     *     |           |
344
     *    3|           |1
345
     *     +-----------+
346
     *       2       0
347
     */
348
    eIntID_AlertNotificationOrigin,
349
350
    /**
351
     * If true, clicking on a scrollbar (not as in dragging the thumb) defaults
352
     * to scrolling the view corresponding to the clicked point. Otherwise, we
353
     * only do so if the scrollbar is clicked using the middle mouse button or
354
     * if shift is pressed when the scrollbar is clicked.
355
     */
356
    eIntID_ScrollToClick,
357
358
    /**
359
     * IME and spell checker underline styles, the values should be
360
     * NS_DECORATION_LINE_STYLE_*.  They are defined below.
361
     */
362
    eIntID_IMERawInputUnderlineStyle,
363
    eIntID_IMESelectedRawTextUnderlineStyle,
364
    eIntID_IMEConvertedTextUnderlineStyle,
365
    eIntID_IMESelectedConvertedTextUnderline,
366
    eIntID_SpellCheckerUnderlineStyle,
367
368
    /**
369
     * If this metric != 0, support window dragging on the menubar.
370
     */
371
    eIntID_MenuBarDrag,
372
    /**
373
     * Return the appropriate WindowsThemeIdentifier for the current theme.
374
     */
375
    eIntID_WindowsThemeIdentifier,
376
    /**
377
     * Return an appropriate os version identifier.
378
     */
379
    eIntID_OperatingSystemVersionIdentifier,
380
    /**
381
     * 0: scrollbar button repeats to scroll only when cursor is on the button.
382
     * 1: scrollbar button repeats to scroll even if cursor is outside of it.
383
     */
384
    eIntID_ScrollbarButtonAutoRepeatBehavior,
385
    /**
386
     * Delay before showing a tooltip.
387
     */
388
    eIntID_TooltipDelay,
389
    /*
390
     * A Boolean value to determine whether Mac OS X Lion style swipe animations
391
     * should be used.
392
     */
393
    eIntID_SwipeAnimationEnabled,
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
      * A boolean value indicating whether client-side decorations are
416
      * supported by the user's GTK version.
417
      */
418
     eIntID_GTKCSDAvailable,
419
420
     /*
421
      * A boolean value indicating whether client-side decorations should
422
      * contain a minimize button.
423
      */
424
     eIntID_GTKCSDMinimizeButton,
425
426
     /*
427
      * A boolean value indicating whether client-side decorations should
428
      * contain a maximize button.
429
      */
430
     eIntID_GTKCSDMaximizeButton,
431
432
     /*
433
      * A boolean value indicating whether client-side decorations should
434
      * contain a close button.
435
      */
436
     eIntID_GTKCSDCloseButton,
437
438
     /*
439
      * A boolean value indicating whether or not the OS is using a dark theme,
440
      * which we may want to switch to as well if not overridden by the user.
441
      */
442
     eIntID_SystemUsesDarkTheme,
443
444
     /**
445
      * Corresponding to prefers-reduced-motion.
446
      * https://drafts.csswg.org/mediaqueries-5/#prefers-reduced-motion
447
      * 0: no-preference
448
      * 1: reduce
449
      */
450
451
     eIntID_PrefersReducedMotion,
452
     /**
453
      * Corresponding to PointerCapabilities in ServoTypes.h
454
      * 0: None
455
      * 1: Coarse
456
      * 2: Fine
457
      * 4: Hover
458
      */
459
     eIntID_PrimaryPointerCapabilities,
460
     /**
461
      * Corresponding to union of PointerCapabilities values in ServoTypes.h
462
      * E.g. if there is a mouse and a digitizer, the value will be
463
      * 'Coarse | Fine | Hover'.
464
      */
465
     eIntID_AllPointerCapabilities,
466
  };
467
468
  /**
469
   * Windows themes we currently detect.
470
   */
471
  enum WindowsTheme {
472
    eWindowsTheme_Generic = 0, // unrecognized theme
473
    eWindowsTheme_Classic,
474
    eWindowsTheme_Aero,
475
    eWindowsTheme_LunaBlue,
476
    eWindowsTheme_LunaOlive,
477
    eWindowsTheme_LunaSilver,
478
    eWindowsTheme_Royale,
479
    eWindowsTheme_Zune,
480
    eWindowsTheme_AeroLite
481
  };
482
483
  /**
484
   * Operating system versions.
485
   */
486
  enum OperatingSystemVersion {
487
    eOperatingSystemVersion_Windows7 = 2,
488
    eOperatingSystemVersion_Windows8,
489
    eOperatingSystemVersion_Windows10,
490
    eOperatingSystemVersion_Unknown
491
  };
492
493
  enum {
494
    eScrollArrow_None = 0,
495
    eScrollArrow_StartBackward = 0x1000,
496
    eScrollArrow_StartForward = 0x0100,
497
    eScrollArrow_EndBackward = 0x0010,
498
    eScrollArrow_EndForward = 0x0001
499
  };
500
501
  enum {
502
    // single arrow at each end
503
    eScrollArrowStyle_Single =
504
      eScrollArrow_StartBackward | eScrollArrow_EndForward,
505
    // both arrows at bottom/right, none at top/left
506
    eScrollArrowStyle_BothAtBottom =
507
      eScrollArrow_EndBackward | eScrollArrow_EndForward,
508
    // both arrows at both ends
509
    eScrollArrowStyle_BothAtEachEnd =
510
      eScrollArrow_EndBackward | eScrollArrow_EndForward |
511
      eScrollArrow_StartBackward | eScrollArrow_StartForward,
512
    // both arrows at top/left, none at bottom/right
513
    eScrollArrowStyle_BothAtTop =
514
      eScrollArrow_StartBackward | eScrollArrow_StartForward
515
  };
516
517
  enum {
518
    eScrollThumbStyle_Normal,
519
    eScrollThumbStyle_Proportional
520
  };
521
522
  // When modifying this list, also modify nsXPLookAndFeel::sFloatPrefs
523
  // in widget/xpwidgts/nsXPLookAndFeel.cpp.
524
  enum FloatID {
525
    eFloatID_IMEUnderlineRelativeSize,
526
    eFloatID_SpellCheckerUnderlineRelativeSize,
527
528
    // The width/height ratio of the cursor. If used, the CaretWidth int metric
529
    // should be added to the calculated caret width.
530
    eFloatID_CaretAspectRatio
531
  };
532
533
  // These constants must be kept in 1:1 correspondence with the
534
  // NS_STYLE_FONT_* system font constants.
535
  enum FontID {
536
    eFont_Caption = 1,     // css2
537
    FontID_MINIMUM = eFont_Caption,
538
    eFont_Icon,
539
    eFont_Menu,
540
    eFont_MessageBox,
541
    eFont_SmallCaption,
542
    eFont_StatusBar,
543
544
    eFont_Window,          // css3
545
    eFont_Document,
546
    eFont_Workspace,
547
    eFont_Desktop,
548
    eFont_Info,
549
    eFont_Dialog,
550
    eFont_Button,
551
    eFont_PullDownMenu,
552
    eFont_List,
553
    eFont_Field,
554
555
    eFont_Tooltips,        // moz
556
    eFont_Widget,
557
    FontID_MAXIMUM = eFont_Widget
558
  };
559
560
  /**
561
   * GetColor() return a native color value (might be overwritten by prefs) for
562
   * aID.  Some platforms don't return an error even if the index doesn't
563
   * match any system colors.  And also some platforms may initialize the
564
   * return value even when it returns an error.  Therefore, if you want to
565
   * use a color for the default value, you should use the other GetColor()
566
   * which returns nscolor directly.
567
   *
568
   * NOTE:
569
   *   eColorID_TextSelectForeground might return NS_DONT_CHANGE_COLOR.
570
   *   eColorID_IME* might return NS_TRANSPARENT, NS_SAME_AS_FOREGROUND_COLOR or
571
   *   NS_40PERCENT_FOREGROUND_COLOR.
572
   *   These values have particular meaning.  Then, they are not an actual
573
   *   color value.
574
   */
575
  static nsresult GetColor(ColorID aID, nscolor* aResult);
576
577
   /**
578
   * This variant of GetColor() takes an extra Boolean parameter that allows
579
   * the caller to ask that hard-coded color values be substituted for
580
   * native colors (used when it is desireable to hide system colors to
581
   * avoid system fingerprinting).
582
   */
583
  static nsresult GetColor(ColorID aID, bool aUseStandinsForNativeColors,
584
                           nscolor* aResult);
585
586
  /**
587
   * GetInt() and GetFloat() return a int or float value for aID.  The result
588
   * might be distance, time, some flags or a int value which has particular
589
   * meaning.  See each document at definition of each ID for the detail.
590
   * The result is always 0 when they return error.  Therefore, if you want to
591
   * use a value for the default value, you should use the other method which
592
   * returns int or float directly.
593
   */
594
  static nsresult GetInt(IntID aID, int32_t* aResult);
595
  static nsresult GetFloat(FloatID aID, float* aResult);
596
597
  static nscolor GetColor(ColorID aID, nscolor aDefault = NS_RGB(0, 0, 0))
598
0
  {
599
0
    nscolor result = NS_RGB(0, 0, 0);
600
0
    if (NS_FAILED(GetColor(aID, &result))) {
601
0
      return aDefault;
602
0
    }
603
0
    return result;
604
0
  }
605
606
  static nscolor GetColorUsingStandins(ColorID aID,
607
                                       nscolor aDefault = NS_RGB(0, 0, 0))
608
0
  {
609
0
    nscolor result = NS_RGB(0, 0, 0);
610
0
    if (NS_FAILED(GetColor(aID,
611
0
                           true, // aUseStandinsForNativeColors
612
0
                           &result))) {
613
0
      return aDefault;
614
0
    }
615
0
    return result;
616
0
  }
617
618
  static int32_t GetInt(IntID aID, int32_t aDefault = 0)
619
0
  {
620
0
    int32_t result;
621
0
    if (NS_FAILED(GetInt(aID, &result))) {
622
0
      return aDefault;
623
0
    }
624
0
    return result;
625
0
  }
626
627
  static float GetFloat(FloatID aID, float aDefault = 0.0f)
628
0
  {
629
0
    float result;
630
0
    if (NS_FAILED(GetFloat(aID, &result))) {
631
0
      return aDefault;
632
0
    }
633
0
    return result;
634
0
  }
635
636
  /**
637
   * Retrieve the name and style of a system-theme font.  Returns true
638
   * if the system theme specifies this font, false if a default should
639
   * be used.  In the latter case neither aName nor aStyle is modified.
640
   *
641
   * @param aID    Which system-theme font is wanted.
642
   * @param aName  The name of the font to use.
643
   * @param aStyle Styling to apply to the font.
644
   * @param aDevPixPerCSSPixel  Ratio of device pixels to CSS pixels
645
   */
646
  static bool GetFont(FontID aID, nsString& aName, gfxFontStyle& aStyle,
647
                      float aDevPixPerCSSPixel);
648
649
  /**
650
   * GetPasswordCharacter() returns a unicode character which should be used
651
   * for a masked character in password editor.  E.g., '*'.
652
   */
653
  static char16_t GetPasswordCharacter();
654
655
  /**
656
   * If the latest character in password field shouldn't be hidden by the
657
   * result of GetPasswordCharacter(), GetEchoPassword() returns TRUE.
658
   * Otherwise, FALSE.
659
   */
660
  static bool GetEchoPassword();
661
662
  /**
663
   * The millisecond to mask password value.
664
   * This value is only valid when GetEchoPassword() returns true.
665
   */
666
  static uint32_t GetPasswordMaskDelay();
667
668
  /**
669
   * When system look and feel is changed, Refresh() must be called.  Then,
670
   * cached data would be released.
671
   */
672
  static void Refresh();
673
674
  /**
675
   * GTK's initialization code can't be run off main thread, call this
676
   * if you plan on using LookAndFeel off main thread later.
677
   *
678
   * This initialized state may get reset due to theme changes, so it
679
   * must be called prior to each potential off-main-thread LookAndFeel
680
   * call, not just once.
681
   */
682
  static void NativeInit();
683
684
  /**
685
   * If the implementation is caching values, these accessors allow the
686
   * cache to be exported and imported.
687
   */
688
  static nsTArray<LookAndFeelInt> GetIntCache();
689
  static void SetIntCache(const nsTArray<LookAndFeelInt>& aLookAndFeelIntCache);
690
  /**
691
   * Set a flag indicating whether the cache should be cleared in RefreshImpl()
692
   * or not.
693
   */
694
  static void SetShouldRetainCacheForTest(bool aValue);
695
};
696
697
} // namespace mozilla
698
699
// On the Mac, GetColor(eColorID_TextSelectForeground, color) returns this
700
// constant to specify that the foreground color should not be changed
701
// (ie. a colored text keeps its colors  when selected).
702
// Of course if other plaforms work like the Mac, they can use it too.
703
0
#define NS_DONT_CHANGE_COLOR  NS_RGB(0x01, 0x01, 0x01)
704
705
// Similar with NS_DONT_CHANGE_COLOR, except NS_DONT_CHANGE_COLOR would returns
706
// complementary color if fg color is same as bg color.
707
// NS_CHANGE_COLOR_IF_SAME_AS_BG would returns eColorID_TextSelectForegroundCustom if
708
// fg and bg color are the same.
709
0
#define NS_CHANGE_COLOR_IF_SAME_AS_BG NS_RGB(0x02, 0x02, 0x02)
710
711
// ---------------------------------------------------------------------
712
//  Special colors for eColorID_IME* and eColorID_SpellCheckerUnderline
713
// ---------------------------------------------------------------------
714
715
// For background color only.
716
0
#define NS_TRANSPARENT                NS_RGBA(0x01, 0x00, 0x00, 0x00)
717
// For foreground color only.
718
0
#define NS_SAME_AS_FOREGROUND_COLOR   NS_RGBA(0x02, 0x00, 0x00, 0x00)
719
0
#define NS_40PERCENT_FOREGROUND_COLOR NS_RGBA(0x03, 0x00, 0x00, 0x00)
720
721
0
#define NS_IS_SELECTION_SPECIAL_COLOR(c) ((c) == NS_TRANSPARENT || \
722
0
                                          (c) == NS_SAME_AS_FOREGROUND_COLOR || \
723
0
                                          (c) == NS_40PERCENT_FOREGROUND_COLOR)
724
725
// ------------------------------------------
726
//  Bits for eIntID_AlertNotificationOrigin
727
// ------------------------------------------
728
729
#define NS_ALERT_HORIZONTAL 1
730
#define NS_ALERT_LEFT       2
731
0
#define NS_ALERT_TOP        4
732
733
#endif /* __LookAndFeel */