2011-09-09 06:27:11 +04:00
|
|
|
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
2012-05-21 15:12:37 +04:00
|
|
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
1998-07-29 22:54:36 +04:00
|
|
|
|
2011-09-09 06:27:12 +04:00
|
|
|
#ifndef __LookAndFeel
|
|
|
|
#define __LookAndFeel
|
2011-09-09 06:27:11 +04:00
|
|
|
|
|
|
|
#ifndef MOZILLA_INTERNAL_API
|
|
|
|
# error "This header is only usable from within libxul (MOZILLA_INTERNAL_API)."
|
|
|
|
#endif
|
|
|
|
|
2011-09-09 06:27:13 +04:00
|
|
|
#include "nsDebug.h"
|
1998-07-29 22:54:36 +04:00
|
|
|
#include "nsColor.h"
|
2020-07-31 20:32:57 +03:00
|
|
|
#include "nsString.h"
|
2015-04-22 17:58:15 +03:00
|
|
|
#include "nsTArray.h"
|
2021-04-02 15:22:14 +03:00
|
|
|
#include "mozilla/Maybe.h"
|
2020-10-27 13:24:40 +03:00
|
|
|
#include "mozilla/widget/ThemeChangeKind.h"
|
2021-10-29 22:58:25 +03:00
|
|
|
#include "mozilla/ColorScheme.h"
|
1998-07-29 22:54:36 +04:00
|
|
|
|
2012-02-21 03:19:48 +04:00
|
|
|
struct gfxFontStyle;
|
1999-10-19 15:34:00 +04:00
|
|
|
|
2021-04-02 15:22:14 +03:00
|
|
|
class nsIFrame;
|
|
|
|
|
2011-09-09 06:27:11 +04:00
|
|
|
namespace mozilla {
|
|
|
|
|
2021-07-27 18:50:48 +03:00
|
|
|
struct StyleColorSchemeFlags;
|
|
|
|
|
2021-04-02 15:22:14 +03:00
|
|
|
namespace dom {
|
|
|
|
class Document;
|
|
|
|
}
|
|
|
|
|
2020-11-12 02:26:51 +03:00
|
|
|
namespace widget {
|
2020-12-16 07:17:36 +03:00
|
|
|
class FullLookAndFeel;
|
2020-11-12 02:26:51 +03:00
|
|
|
} // namespace widget
|
|
|
|
|
2019-05-26 16:10:00 +03:00
|
|
|
enum class StyleSystemColor : uint8_t;
|
2021-06-14 18:01:25 +03:00
|
|
|
enum class StyleSystemColorScheme : uint8_t;
|
2021-03-25 01:57:37 +03:00
|
|
|
enum class StyleSystemFont : uint8_t;
|
2019-05-26 16:10:00 +03:00
|
|
|
|
2011-09-09 06:27:11 +04:00
|
|
|
class LookAndFeel {
|
|
|
|
public:
|
2019-05-26 16:10:00 +03:00
|
|
|
using ColorID = StyleSystemColor;
|
2021-10-08 19:28:29 +03:00
|
|
|
using ColorScheme = mozilla::ColorScheme;
|
2011-09-09 06:27:11 +04:00
|
|
|
|
|
|
|
// When modifying this list, also modify nsXPLookAndFeel::sIntPrefs
|
2012-01-04 07:09:29 +04:00
|
|
|
// in widget/xpwidgts/nsXPLookAndFeel.cpp.
|
2020-06-11 14:27:43 +03:00
|
|
|
enum class IntID {
|
2011-09-09 06:27:11 +04:00
|
|
|
// default, may be overriden by OS
|
2020-06-11 14:27:43 +03:00
|
|
|
CaretBlinkTime,
|
2021-08-10 17:39:27 +03:00
|
|
|
// Amount of blinks that happen before the caret stops blinking.
|
|
|
|
CaretBlinkCount,
|
2011-09-09 06:27:11 +04:00
|
|
|
// pixel width of caret
|
2020-06-11 14:27:43 +03:00
|
|
|
CaretWidth,
|
2011-09-09 06:27:11 +04:00
|
|
|
// show the caret when text is selected?
|
2020-06-11 14:27:43 +03:00
|
|
|
ShowCaretDuringSelection,
|
2011-09-09 06:27:11 +04:00
|
|
|
// select textfields when focused via tab/accesskey?
|
2020-06-11 14:27:43 +03:00
|
|
|
SelectTextfieldsOnKeyFocus,
|
2011-09-09 06:27:11 +04:00
|
|
|
// delay before submenus open
|
2020-06-11 14:27:43 +03:00
|
|
|
SubmenuDelay,
|
2011-09-09 06:27:11 +04:00
|
|
|
// can popups overlap menu/task bar?
|
2020-06-11 14:27:43 +03:00
|
|
|
MenusCanOverlapOSBar,
|
2013-05-02 18:58:00 +04:00
|
|
|
// should overlay scrollbars be used?
|
2020-06-11 14:27:43 +03:00
|
|
|
UseOverlayScrollbars,
|
2013-05-24 01:14:00 +04:00
|
|
|
// allow H and V overlay scrollbars to overlap?
|
2020-06-11 14:27:43 +03:00
|
|
|
AllowOverlayScrollbarsOverlap,
|
2011-09-09 06:27:11 +04:00
|
|
|
// skip navigating to disabled menu item?
|
2020-06-11 14:27:43 +03:00
|
|
|
SkipNavigatingDisabledMenuItem,
|
2011-09-09 06:27:11 +04:00
|
|
|
// begin a drag if the mouse is moved further than the threshold while the
|
|
|
|
// button is down
|
2020-06-11 14:27:43 +03:00
|
|
|
DragThresholdX,
|
|
|
|
DragThresholdY,
|
2011-09-09 06:27:11 +04:00
|
|
|
// Accessibility theme being used?
|
2020-06-11 14:27:43 +03:00
|
|
|
UseAccessibilityTheme,
|
2011-09-09 06:27:11 +04:00
|
|
|
|
|
|
|
// position of scroll arrows in a scrollbar
|
2020-06-11 14:27:43 +03:00
|
|
|
ScrollArrowStyle,
|
2011-09-09 06:27:11 +04:00
|
|
|
// is scroll thumb proportional or fixed?
|
2020-06-11 14:27:43 +03:00
|
|
|
ScrollSliderStyle,
|
2011-09-09 06:27:11 +04:00
|
|
|
|
|
|
|
// each button can take one of four values:
|
2020-06-11 14:27:43 +03:00
|
|
|
ScrollButtonLeftMouseButtonAction,
|
2011-09-09 06:27:11 +04:00
|
|
|
// 0 - scrolls one line, 1 - scrolls one page
|
2020-06-11 14:27:43 +03:00
|
|
|
ScrollButtonMiddleMouseButtonAction,
|
2011-09-09 06:27:11 +04:00
|
|
|
// 2 - scrolls to end, 3 - button ignored
|
2020-06-11 14:27:43 +03:00
|
|
|
ScrollButtonRightMouseButtonAction,
|
2011-09-09 06:27:11 +04:00
|
|
|
|
|
|
|
// delay for opening spring loaded folders
|
2020-06-11 14:27:43 +03:00
|
|
|
TreeOpenDelay,
|
2011-09-09 06:27:11 +04:00
|
|
|
// delay for closing spring loaded folders
|
2020-06-11 14:27:43 +03:00
|
|
|
TreeCloseDelay,
|
2011-09-09 06:27:11 +04:00
|
|
|
// delay for triggering the tree scrolling
|
2020-06-11 14:27:43 +03:00
|
|
|
TreeLazyScrollDelay,
|
2011-09-09 06:27:11 +04:00
|
|
|
// delay for scrolling the tree
|
2020-06-11 14:27:43 +03:00
|
|
|
TreeScrollDelay,
|
2011-09-09 06:27:11 +04:00
|
|
|
// the maximum number of lines to be scrolled at ones
|
2020-06-11 14:27:43 +03:00
|
|
|
TreeScrollLinesMax,
|
2011-09-09 06:27:11 +04:00
|
|
|
// What type of tab-order to use
|
2020-06-11 14:27:43 +03:00
|
|
|
TabFocusModel,
|
2011-09-09 06:27:11 +04:00
|
|
|
// Should menu items blink when they're chosen?
|
2020-06-11 14:27:43 +03:00
|
|
|
ChosenMenuItemsShouldBlink,
|
2011-09-09 06:27:11 +04:00
|
|
|
|
2017-06-08 16:49:21 +03:00
|
|
|
/*
|
|
|
|
* A Boolean value to determine whether the Windows accent color
|
|
|
|
* should be applied to the title bar.
|
|
|
|
*
|
|
|
|
* The value of this metric is not used on other platforms. These platforms
|
|
|
|
* should return NS_ERROR_NOT_IMPLEMENTED when queried for this metric.
|
|
|
|
*/
|
2020-06-11 14:27:43 +03:00
|
|
|
WindowsAccentColorInTitlebar,
|
2017-06-08 16:49:21 +03:00
|
|
|
|
2011-09-09 06:27:11 +04:00
|
|
|
/*
|
|
|
|
* A Boolean value to determine whether the Windows default theme is
|
|
|
|
* being used.
|
|
|
|
*
|
|
|
|
* The value of this metric is not used on other platforms. These platforms
|
|
|
|
* should return NS_ERROR_NOT_IMPLEMENTED when queried for this metric.
|
|
|
|
*/
|
2020-06-11 14:27:43 +03:00
|
|
|
WindowsDefaultTheme,
|
2011-09-09 06:27:11 +04:00
|
|
|
|
|
|
|
/*
|
|
|
|
* A Boolean value to determine whether the DWM compositor is being used
|
|
|
|
*
|
|
|
|
* This metric is not used on non-Windows platforms. These platforms
|
|
|
|
* should return NS_ERROR_NOT_IMPLEMENTED when queried for this metric.
|
|
|
|
*/
|
2020-06-11 14:27:43 +03:00
|
|
|
DWMCompositor,
|
2011-09-09 06:27:11 +04:00
|
|
|
|
|
|
|
/*
|
|
|
|
* A Boolean value to determine whether Windows is themed (Classic vs.
|
|
|
|
* uxtheme)
|
|
|
|
*
|
|
|
|
* This is Windows-specific and is not implemented on other platforms
|
|
|
|
* (will return the default of NS_ERROR_FAILURE).
|
|
|
|
*/
|
2020-06-11 14:27:43 +03:00
|
|
|
WindowsClassic,
|
2011-09-09 06:27:11 +04:00
|
|
|
|
2013-01-17 07:27:16 +04:00
|
|
|
/*
|
|
|
|
* A Boolean value to determine whether the current Windows desktop theme
|
|
|
|
* supports Aero Glass.
|
|
|
|
*
|
|
|
|
* This is Windows-specific and is not implemented on other platforms
|
|
|
|
* (will return the default of NS_ERROR_FAILURE).
|
|
|
|
*/
|
2020-06-11 14:27:43 +03:00
|
|
|
WindowsGlass,
|
2013-01-17 07:27:16 +04:00
|
|
|
|
2011-09-09 06:27:11 +04:00
|
|
|
/*
|
|
|
|
* A Boolean value to determine whether the Mac graphite theme is
|
|
|
|
* being used.
|
|
|
|
*/
|
2020-06-11 14:27:43 +03:00
|
|
|
MacGraphiteTheme,
|
2011-09-09 06:27:11 +04:00
|
|
|
|
2014-06-06 02:02:46 +04:00
|
|
|
/*
|
2020-11-16 23:43:35 +03:00
|
|
|
* A Boolean value to determine whether the macOS Big Sur-specific
|
2014-06-06 02:02:46 +04:00
|
|
|
* theming should be used.
|
|
|
|
*/
|
2020-11-16 23:43:35 +03:00
|
|
|
MacBigSurTheme,
|
2014-06-06 02:02:46 +04:00
|
|
|
|
2021-09-22 21:51:20 +03:00
|
|
|
/*
|
|
|
|
* A Boolean value to determine whether macOS is in RTL mode or not.
|
|
|
|
*/
|
|
|
|
MacRTL,
|
|
|
|
|
2011-09-09 06:27:11 +04:00
|
|
|
/*
|
2020-06-11 14:27:43 +03:00
|
|
|
* AlertNotificationOrigin indicates from which corner of the
|
2011-09-09 06:27:11 +04:00
|
|
|
* screen alerts slide in, and from which direction (horizontal/vertical).
|
|
|
|
* 0, the default, represents bottom right, sliding vertically.
|
|
|
|
* Use any bitwise combination of the following constants:
|
|
|
|
* NS_ALERT_HORIZONTAL (1), NS_ALERT_LEFT (2), NS_ALERT_TOP (4).
|
|
|
|
*
|
|
|
|
* 6 4
|
|
|
|
* +-----------+
|
|
|
|
* 7| |5
|
|
|
|
* | |
|
|
|
|
* 3| |1
|
|
|
|
* +-----------+
|
|
|
|
* 2 0
|
|
|
|
*/
|
2020-06-11 14:27:43 +03:00
|
|
|
AlertNotificationOrigin,
|
2011-09-09 06:27:11 +04:00
|
|
|
|
|
|
|
/**
|
|
|
|
* If true, clicking on a scrollbar (not as in dragging the thumb) defaults
|
|
|
|
* to scrolling the view corresponding to the clicked point. Otherwise, we
|
|
|
|
* only do so if the scrollbar is clicked using the middle mouse button or
|
|
|
|
* if shift is pressed when the scrollbar is clicked.
|
|
|
|
*/
|
2020-06-11 14:27:43 +03:00
|
|
|
ScrollToClick,
|
2011-09-09 06:27:11 +04:00
|
|
|
|
|
|
|
/**
|
|
|
|
* IME and spell checker underline styles, the values should be
|
|
|
|
* NS_DECORATION_LINE_STYLE_*. They are defined below.
|
|
|
|
*/
|
2020-06-11 14:27:43 +03:00
|
|
|
IMERawInputUnderlineStyle,
|
|
|
|
IMESelectedRawTextUnderlineStyle,
|
|
|
|
IMEConvertedTextUnderlineStyle,
|
|
|
|
IMESelectedConvertedTextUnderline,
|
|
|
|
SpellCheckerUnderlineStyle,
|
2011-09-09 06:27:11 +04:00
|
|
|
|
|
|
|
/**
|
|
|
|
* If this metric != 0, support window dragging on the menubar.
|
|
|
|
*/
|
2020-06-11 14:27:43 +03:00
|
|
|
MenuBarDrag,
|
2011-11-18 03:41:35 +04:00
|
|
|
/**
|
|
|
|
* 0: scrollbar button repeats to scroll only when cursor is on the button.
|
|
|
|
* 1: scrollbar button repeats to scroll even if cursor is outside of it.
|
|
|
|
*/
|
2020-06-11 14:27:43 +03:00
|
|
|
ScrollbarButtonAutoRepeatBehavior,
|
2011-12-16 13:18:48 +04:00
|
|
|
/**
|
2013-07-02 14:02:21 +04:00
|
|
|
* Delay before showing a tooltip.
|
2011-12-16 13:18:48 +04:00
|
|
|
*/
|
2020-06-11 14:27:43 +03:00
|
|
|
TooltipDelay,
|
2013-04-09 23:44:01 +04:00
|
|
|
/*
|
2022-01-05 12:08:08 +03:00
|
|
|
* A Boolean value to determine whether swipe animations should be used.
|
2013-04-09 23:44:01 +04:00
|
|
|
*/
|
2020-06-11 14:27:43 +03:00
|
|
|
SwipeAnimationEnabled,
|
2013-06-06 06:42:02 +04:00
|
|
|
|
2013-07-02 14:02:21 +04:00
|
|
|
/*
|
|
|
|
* Controls whether overlay scrollbars display when the user moves
|
|
|
|
* the mouse in a scrollable frame.
|
|
|
|
*/
|
2020-06-11 14:27:43 +03:00
|
|
|
ScrollbarDisplayOnMouseMove,
|
2018-11-30 13:46:48 +03:00
|
|
|
|
2013-07-02 14:02:21 +04:00
|
|
|
/*
|
|
|
|
* Overlay scrollbar animation constants.
|
|
|
|
*/
|
2020-06-11 14:27:43 +03:00
|
|
|
ScrollbarFadeBeginDelay,
|
|
|
|
ScrollbarFadeDuration,
|
2018-11-30 13:46:48 +03:00
|
|
|
|
2015-08-04 23:41:00 +03:00
|
|
|
/**
|
|
|
|
* Distance in pixels to offset the context menu from the cursor
|
|
|
|
* on open.
|
|
|
|
*/
|
2020-06-11 14:27:43 +03:00
|
|
|
ContextMenuOffsetVertical,
|
|
|
|
ContextMenuOffsetHorizontal,
|
2018-11-30 13:46:48 +03:00
|
|
|
|
2017-10-17 22:12:21 +03:00
|
|
|
/*
|
|
|
|
* A boolean value indicating whether client-side decorations are
|
|
|
|
* supported by the user's GTK version.
|
|
|
|
*/
|
2020-06-11 14:27:43 +03:00
|
|
|
GTKCSDAvailable,
|
2018-11-30 13:46:48 +03:00
|
|
|
|
2017-10-17 22:12:21 +03:00
|
|
|
/*
|
|
|
|
* A boolean value indicating whether client-side decorations should
|
|
|
|
* contain a minimize button.
|
|
|
|
*/
|
2020-06-11 14:27:43 +03:00
|
|
|
GTKCSDMinimizeButton,
|
2018-11-30 13:46:48 +03:00
|
|
|
|
2017-10-17 22:12:21 +03:00
|
|
|
/*
|
|
|
|
* A boolean value indicating whether client-side decorations should
|
|
|
|
* contain a maximize button.
|
|
|
|
*/
|
2020-06-11 14:27:43 +03:00
|
|
|
GTKCSDMaximizeButton,
|
2018-11-30 13:46:48 +03:00
|
|
|
|
2017-10-17 22:12:21 +03:00
|
|
|
/*
|
|
|
|
* A boolean value indicating whether client-side decorations should
|
|
|
|
* contain a close button.
|
|
|
|
*/
|
2020-06-11 14:27:43 +03:00
|
|
|
GTKCSDCloseButton,
|
2018-11-30 13:46:48 +03:00
|
|
|
|
2021-04-02 19:34:32 +03:00
|
|
|
/**
|
|
|
|
* An Integer value that will represent the position of the Minimize button
|
2021-11-26 14:37:52 +03:00
|
|
|
* in GTK Client side decoration header.
|
2021-04-02 19:34:32 +03:00
|
|
|
*/
|
|
|
|
GTKCSDMinimizeButtonPosition,
|
|
|
|
|
|
|
|
/**
|
|
|
|
* An Integer value that will represent the position of the Maximize button
|
2021-11-26 14:37:52 +03:00
|
|
|
* in GTK Client side decoration header.
|
2021-04-02 19:34:32 +03:00
|
|
|
*/
|
|
|
|
GTKCSDMaximizeButtonPosition,
|
|
|
|
|
|
|
|
/**
|
|
|
|
* An Integer value that will represent the position of the Close button
|
2021-11-26 14:37:52 +03:00
|
|
|
* in GTK Client side decoration header.
|
2021-04-02 19:34:32 +03:00
|
|
|
*/
|
|
|
|
GTKCSDCloseButtonPosition,
|
|
|
|
|
2019-01-18 16:52:29 +03:00
|
|
|
/*
|
|
|
|
* A boolean value indicating whether titlebar buttons are located
|
|
|
|
* in left titlebar corner.
|
|
|
|
*/
|
2020-06-11 14:27:43 +03:00
|
|
|
GTKCSDReversedPlacement,
|
2019-01-18 16:52:29 +03:00
|
|
|
|
2018-06-27 20:59:21 +03:00
|
|
|
/*
|
|
|
|
* A boolean value indicating whether or not the OS is using a dark theme,
|
|
|
|
* which we may want to switch to as well if not overridden by the user.
|
|
|
|
*/
|
2020-06-11 14:27:43 +03:00
|
|
|
SystemUsesDarkTheme,
|
2018-11-30 13:46:48 +03:00
|
|
|
|
2018-07-24 10:50:47 +03:00
|
|
|
/**
|
|
|
|
* Corresponding to prefers-reduced-motion.
|
|
|
|
* https://drafts.csswg.org/mediaqueries-5/#prefers-reduced-motion
|
|
|
|
* 0: no-preference
|
|
|
|
* 1: reduce
|
|
|
|
*/
|
2018-11-30 13:46:48 +03:00
|
|
|
|
2020-06-11 14:27:43 +03:00
|
|
|
PrefersReducedMotion,
|
2018-08-14 11:13:04 +03:00
|
|
|
/**
|
|
|
|
* Corresponding to PointerCapabilities in ServoTypes.h
|
|
|
|
* 0: None
|
|
|
|
* 1: Coarse
|
|
|
|
* 2: Fine
|
|
|
|
* 4: Hover
|
|
|
|
*/
|
2020-06-11 14:27:43 +03:00
|
|
|
PrimaryPointerCapabilities,
|
2018-08-14 11:13:04 +03:00
|
|
|
/**
|
|
|
|
* Corresponding to union of PointerCapabilities values in ServoTypes.h
|
|
|
|
* E.g. if there is a mouse and a digitizer, the value will be
|
|
|
|
* 'Coarse | Fine | Hover'.
|
|
|
|
*/
|
2020-06-11 14:27:43 +03:00
|
|
|
AllPointerCapabilities,
|
2021-03-18 22:12:49 +03:00
|
|
|
/** The vertical scrollbar width, in CSS pixels. */
|
|
|
|
SystemVerticalScrollbarWidth,
|
|
|
|
|
|
|
|
/** The horizontal scrollbar height, in CSS pixels. */
|
|
|
|
SystemHorizontalScrollbarHeight,
|
|
|
|
|
2021-08-25 17:32:13 +03:00
|
|
|
/** A boolean value to determine whether a touch device is present */
|
|
|
|
TouchDeviceSupportPresent,
|
|
|
|
|
2021-10-20 21:01:02 +03:00
|
|
|
/** GTK titlebar radius */
|
|
|
|
TitlebarRadius,
|
|
|
|
|
2021-10-28 13:52:31 +03:00
|
|
|
/** GTK menu radius */
|
|
|
|
GtkMenuRadius,
|
|
|
|
|
2020-11-12 02:26:51 +03:00
|
|
|
/*
|
|
|
|
* Not an ID; used to define the range of valid IDs. Must be last.
|
|
|
|
*/
|
|
|
|
End,
|
2013-07-02 04:28:44 +04:00
|
|
|
};
|
2011-09-09 06:27:11 +04:00
|
|
|
|
2021-04-01 23:34:34 +03:00
|
|
|
// This is a common enough integer that seems worth the shortcut.
|
|
|
|
static bool UseOverlayScrollbars() {
|
|
|
|
return GetInt(IntID::UseOverlayScrollbars);
|
|
|
|
}
|
|
|
|
|
2011-09-09 06:27:11 +04:00
|
|
|
enum {
|
|
|
|
eScrollArrow_None = 0,
|
|
|
|
eScrollArrow_StartBackward = 0x1000,
|
|
|
|
eScrollArrow_StartForward = 0x0100,
|
|
|
|
eScrollArrow_EndBackward = 0x0010,
|
|
|
|
eScrollArrow_EndForward = 0x0001
|
|
|
|
};
|
|
|
|
|
|
|
|
enum {
|
|
|
|
// single arrow at each end
|
|
|
|
eScrollArrowStyle_Single =
|
2015-05-21 13:16:00 +03:00
|
|
|
eScrollArrow_StartBackward | eScrollArrow_EndForward,
|
2011-09-09 06:27:11 +04:00
|
|
|
// both arrows at bottom/right, none at top/left
|
|
|
|
eScrollArrowStyle_BothAtBottom =
|
|
|
|
eScrollArrow_EndBackward | eScrollArrow_EndForward,
|
|
|
|
// both arrows at both ends
|
|
|
|
eScrollArrowStyle_BothAtEachEnd =
|
|
|
|
eScrollArrow_EndBackward | eScrollArrow_EndForward |
|
|
|
|
eScrollArrow_StartBackward | eScrollArrow_StartForward,
|
|
|
|
// both arrows at top/left, none at bottom/right
|
|
|
|
eScrollArrowStyle_BothAtTop =
|
|
|
|
eScrollArrow_StartBackward | eScrollArrow_StartForward
|
|
|
|
};
|
|
|
|
|
|
|
|
enum { eScrollThumbStyle_Normal, eScrollThumbStyle_Proportional };
|
|
|
|
|
|
|
|
// When modifying this list, also modify nsXPLookAndFeel::sFloatPrefs
|
2020-05-24 12:22:58 +03:00
|
|
|
// in widget/nsXPLookAndFeel.cpp.
|
2020-06-11 14:27:43 +03:00
|
|
|
enum class FloatID {
|
|
|
|
IMEUnderlineRelativeSize,
|
|
|
|
SpellCheckerUnderlineRelativeSize,
|
2011-09-09 06:27:11 +04:00
|
|
|
|
|
|
|
// The width/height ratio of the cursor. If used, the CaretWidth int metric
|
|
|
|
// should be added to the calculated caret width.
|
2020-06-11 14:27:43 +03:00
|
|
|
CaretAspectRatio,
|
2020-12-16 07:17:36 +03:00
|
|
|
|
2021-03-22 19:11:33 +03:00
|
|
|
// GTK text scale factor.
|
|
|
|
TextScaleFactor,
|
|
|
|
|
2021-10-28 15:25:23 +03:00
|
|
|
// Mouse pointer scaling factor.
|
|
|
|
CursorScale,
|
|
|
|
|
2020-12-16 07:17:36 +03:00
|
|
|
// Not an ID; used to define the range of valid IDs. Must be last.
|
|
|
|
End,
|
2011-09-09 06:27:11 +04:00
|
|
|
};
|
|
|
|
|
2021-03-25 01:57:37 +03:00
|
|
|
using FontID = mozilla::StyleSystemFont;
|
2012-02-21 03:19:48 +04:00
|
|
|
|
2021-04-03 04:16:59 +03:00
|
|
|
static ColorScheme SystemColorScheme() {
|
|
|
|
return GetInt(IntID::SystemUsesDarkTheme) ? ColorScheme::Dark
|
|
|
|
: ColorScheme::Light;
|
|
|
|
}
|
|
|
|
|
2021-10-20 11:25:57 +03:00
|
|
|
enum class ChromeColorSchemeSetting { Light, Dark, System };
|
|
|
|
static ChromeColorSchemeSetting ColorSchemeSettingForChrome();
|
2022-03-04 16:08:30 +03:00
|
|
|
static ColorScheme ThemeDerivedColorSchemeForContent();
|
2021-10-20 11:25:57 +03:00
|
|
|
|
2021-11-24 19:50:38 +03:00
|
|
|
static ColorScheme ColorSchemeForChrome() {
|
|
|
|
MOZ_ASSERT(sColorSchemeInitialized);
|
|
|
|
return sChromeColorScheme;
|
|
|
|
}
|
2021-10-20 11:25:57 +03:00
|
|
|
static ColorScheme PreferredColorSchemeForContent() {
|
2021-11-24 19:50:38 +03:00
|
|
|
MOZ_ASSERT(sColorSchemeInitialized);
|
2021-10-20 11:25:57 +03:00
|
|
|
return sContentColorScheme;
|
|
|
|
}
|
|
|
|
|
2021-07-27 18:50:48 +03:00
|
|
|
static ColorScheme ColorSchemeForStyle(const dom::Document&,
|
|
|
|
const StyleColorSchemeFlags&);
|
|
|
|
static ColorScheme ColorSchemeForFrame(const nsIFrame*);
|
2021-04-04 18:48:02 +03:00
|
|
|
|
2021-04-02 15:22:14 +03:00
|
|
|
// Whether standins for native colors should be used (that is, colors faked,
|
|
|
|
// taken from win7, mostly). This forces light appearance, effectively.
|
|
|
|
enum class UseStandins : bool { No, Yes };
|
2021-06-14 18:01:25 +03:00
|
|
|
static UseStandins ShouldUseStandins(const dom::Document&, ColorID);
|
2021-04-02 15:22:14 +03:00
|
|
|
|
|
|
|
// Returns a native color value (might be overwritten by prefs) for a given
|
|
|
|
// color id.
|
|
|
|
//
|
|
|
|
// NOTE:
|
2021-05-06 12:57:19 +03:00
|
|
|
// ColorID::TextSelectForeground might return NS_SAME_AS_FOREGROUND_COLOR.
|
2021-04-02 15:22:14 +03:00
|
|
|
// ColorID::IME* might return NS_TRANSPARENT, NS_SAME_AS_FOREGROUND_COLOR or
|
|
|
|
// NS_40PERCENT_FOREGROUND_COLOR.
|
|
|
|
// These values have particular meaning. Then, they are not an actual
|
|
|
|
// color value.
|
|
|
|
static Maybe<nscolor> GetColor(ColorID, ColorScheme, UseStandins);
|
|
|
|
|
|
|
|
// Gets the color with appropriate defaults for UseStandins, ColorScheme etc
|
|
|
|
// for a given frame.
|
|
|
|
static Maybe<nscolor> GetColor(ColorID, const nsIFrame*);
|
|
|
|
|
|
|
|
// Versions of the above which returns the color if found, or a default (which
|
|
|
|
// defaults to opaque black) otherwise.
|
|
|
|
static nscolor Color(ColorID aId, ColorScheme aScheme,
|
|
|
|
UseStandins aUseStandins,
|
|
|
|
nscolor aDefault = NS_RGB(0, 0, 0)) {
|
|
|
|
return GetColor(aId, aScheme, aUseStandins).valueOr(aDefault);
|
|
|
|
}
|
2021-04-02 03:21:37 +03:00
|
|
|
|
2021-04-02 15:22:14 +03:00
|
|
|
static nscolor Color(ColorID aId, nsIFrame* aFrame,
|
|
|
|
nscolor aDefault = NS_RGB(0, 0, 0)) {
|
|
|
|
return GetColor(aId, aFrame).valueOr(aDefault);
|
|
|
|
}
|
2015-09-25 01:59:00 +03:00
|
|
|
|
2011-09-09 06:27:11 +04:00
|
|
|
/**
|
|
|
|
* GetInt() and GetFloat() return a int or float value for aID. The result
|
|
|
|
* might be distance, time, some flags or a int value which has particular
|
|
|
|
* meaning. See each document at definition of each ID for the detail.
|
|
|
|
* The result is always 0 when they return error. Therefore, if you want to
|
|
|
|
* use a value for the default value, you should use the other method which
|
|
|
|
* returns int or float directly.
|
|
|
|
*/
|
2021-04-02 15:22:14 +03:00
|
|
|
static nsresult GetInt(IntID, int32_t* aResult);
|
2011-09-09 06:27:11 +04:00
|
|
|
static nsresult GetFloat(FloatID aID, float* aResult);
|
|
|
|
|
2012-08-22 19:56:38 +04:00
|
|
|
static int32_t GetInt(IntID aID, int32_t aDefault = 0) {
|
|
|
|
int32_t result;
|
2011-09-09 06:27:11 +04:00
|
|
|
if (NS_FAILED(GetInt(aID, &result))) {
|
|
|
|
return aDefault;
|
|
|
|
}
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
|
|
|
static float GetFloat(FloatID aID, float aDefault = 0.0f) {
|
|
|
|
float result;
|
|
|
|
if (NS_FAILED(GetFloat(aID, &result))) {
|
|
|
|
return aDefault;
|
|
|
|
}
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
2012-02-21 03:19:48 +04:00
|
|
|
/**
|
|
|
|
* Retrieve the name and style of a system-theme font. Returns true
|
|
|
|
* if the system theme specifies this font, false if a default should
|
|
|
|
* be used. In the latter case neither aName nor aStyle is modified.
|
|
|
|
*
|
2019-02-08 16:22:11 +03:00
|
|
|
* Size of the font should be in CSS pixels, not device pixels.
|
|
|
|
*
|
2012-02-21 03:19:48 +04:00
|
|
|
* @param aID Which system-theme font is wanted.
|
|
|
|
* @param aName The name of the font to use.
|
|
|
|
* @param aStyle Styling to apply to the font.
|
|
|
|
*/
|
2019-02-08 16:22:11 +03:00
|
|
|
static bool GetFont(FontID aID, nsString& aName, gfxFontStyle& aStyle);
|
2012-02-21 03:19:48 +04:00
|
|
|
|
2011-09-09 06:27:11 +04:00
|
|
|
/**
|
|
|
|
* GetPasswordCharacter() returns a unicode character which should be used
|
|
|
|
* for a masked character in password editor. E.g., '*'.
|
|
|
|
*/
|
2014-01-04 19:02:17 +04:00
|
|
|
static char16_t GetPasswordCharacter();
|
2011-09-09 06:27:11 +04:00
|
|
|
|
|
|
|
/**
|
|
|
|
* If the latest character in password field shouldn't be hidden by the
|
|
|
|
* result of GetPasswordCharacter(), GetEchoPassword() returns TRUE.
|
|
|
|
* Otherwise, FALSE.
|
|
|
|
*/
|
2011-09-29 10:19:26 +04:00
|
|
|
static bool GetEchoPassword();
|
2011-09-09 06:27:11 +04:00
|
|
|
|
2021-10-21 12:07:12 +03:00
|
|
|
/**
|
|
|
|
* Whether we should be drawing in the titlebar by default.
|
|
|
|
*/
|
|
|
|
static bool DrawInTitlebar();
|
|
|
|
|
2012-07-13 06:26:20 +04:00
|
|
|
/**
|
|
|
|
* The millisecond to mask password value.
|
|
|
|
* This value is only valid when GetEchoPassword() returns true.
|
|
|
|
*/
|
2012-08-22 19:56:38 +04:00
|
|
|
static uint32_t GetPasswordMaskDelay();
|
2012-07-13 06:26:20 +04:00
|
|
|
|
2021-07-20 23:09:09 +03:00
|
|
|
/** Gets theme information for about:support */
|
|
|
|
static void GetThemeInfo(nsACString&);
|
|
|
|
|
2011-09-09 06:27:11 +04:00
|
|
|
/**
|
|
|
|
* When system look and feel is changed, Refresh() must be called. Then,
|
|
|
|
* cached data would be released.
|
|
|
|
*/
|
|
|
|
static void Refresh();
|
2015-04-22 17:58:15 +03:00
|
|
|
|
2017-08-03 23:16:31 +03:00
|
|
|
/**
|
|
|
|
* GTK's initialization code can't be run off main thread, call this
|
|
|
|
* if you plan on using LookAndFeel off main thread later.
|
|
|
|
*
|
|
|
|
* This initialized state may get reset due to theme changes, so it
|
|
|
|
* must be called prior to each potential off-main-thread LookAndFeel
|
|
|
|
* call, not just once.
|
|
|
|
*/
|
|
|
|
static void NativeInit();
|
|
|
|
|
2020-12-16 07:17:36 +03:00
|
|
|
static void SetData(widget::FullLookAndFeel&& aTables);
|
2020-10-27 13:24:40 +03:00
|
|
|
static void NotifyChangedAllWindows(widget::ThemeChangeKind);
|
2022-01-31 20:00:21 +03:00
|
|
|
static bool HasPendingGlobalThemeChange() { return sGlobalThemeChanged; }
|
2022-01-17 19:34:11 +03:00
|
|
|
static void HandleGlobalThemeChange() {
|
|
|
|
if (MOZ_UNLIKELY(HasPendingGlobalThemeChange())) {
|
|
|
|
DoHandleGlobalThemeChange();
|
|
|
|
}
|
|
|
|
}
|
2021-11-24 19:50:38 +03:00
|
|
|
static void EnsureColorSchemesInitialized() {
|
|
|
|
if (!sColorSchemeInitialized) {
|
|
|
|
RecomputeColorSchemes();
|
|
|
|
}
|
|
|
|
MOZ_ASSERT(sColorSchemeInitialized);
|
|
|
|
}
|
|
|
|
|
2021-10-20 11:25:57 +03:00
|
|
|
static ColorScheme sChromeColorScheme;
|
|
|
|
static ColorScheme sContentColorScheme;
|
2021-11-24 19:50:38 +03:00
|
|
|
|
|
|
|
protected:
|
|
|
|
static void RecomputeColorSchemes();
|
|
|
|
static bool sColorSchemeInitialized;
|
2022-01-17 19:34:11 +03:00
|
|
|
|
|
|
|
static void DoHandleGlobalThemeChange();
|
2022-01-31 20:00:21 +03:00
|
|
|
// Set to true when ThemeChanged needs to be called on mTheme (and other
|
|
|
|
// global LookAndFeel. This is used because mTheme is a service, so there's
|
|
|
|
// no need to notify it from more than one prescontext.
|
2022-01-17 19:34:11 +03:00
|
|
|
static bool sGlobalThemeChanged;
|
2011-09-09 06:27:11 +04:00
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace mozilla
|
2005-11-11 17:36:26 +03:00
|
|
|
|
2011-09-09 06:27:11 +04:00
|
|
|
// ---------------------------------------------------------------------
|
2019-05-26 16:10:00 +03:00
|
|
|
// Special colors for ColorID::IME* and ColorID::SpellCheckerUnderline
|
2011-09-09 06:27:11 +04:00
|
|
|
// ---------------------------------------------------------------------
|
2005-09-17 15:34:27 +04:00
|
|
|
|
|
|
|
// For background color only.
|
2021-06-14 18:01:26 +03:00
|
|
|
constexpr nscolor NS_TRANSPARENT = NS_RGBA(0x01, 0x00, 0x00, 0x00);
|
2005-09-17 15:34:27 +04:00
|
|
|
// For foreground color only.
|
2021-06-14 18:01:26 +03:00
|
|
|
constexpr nscolor NS_SAME_AS_FOREGROUND_COLOR = NS_RGBA(0x02, 0x00, 0x00, 0x00);
|
|
|
|
constexpr nscolor NS_40PERCENT_FOREGROUND_COLOR =
|
|
|
|
NS_RGBA(0x03, 0x00, 0x00, 0x00);
|
2005-09-17 15:34:27 +04:00
|
|
|
|
2009-04-03 11:26:28 +04:00
|
|
|
#define NS_IS_SELECTION_SPECIAL_COLOR(c) \
|
|
|
|
((c) == NS_TRANSPARENT || (c) == NS_SAME_AS_FOREGROUND_COLOR || \
|
|
|
|
(c) == NS_40PERCENT_FOREGROUND_COLOR)
|
2000-04-04 13:07:41 +04:00
|
|
|
|
2006-07-19 23:47:19 +04:00
|
|
|
// ------------------------------------------
|
2020-06-11 14:27:43 +03:00
|
|
|
// Bits for IntID::AlertNotificationOrigin
|
2006-07-19 23:47:19 +04:00
|
|
|
// ------------------------------------------
|
|
|
|
|
|
|
|
#define NS_ALERT_HORIZONTAL 1
|
|
|
|
#define NS_ALERT_LEFT 2
|
|
|
|
#define NS_ALERT_TOP 4
|
|
|
|
|
2011-09-09 06:27:12 +04:00
|
|
|
#endif /* __LookAndFeel */
|