2001-09-29 00:14:13 +04:00
|
|
|
/* -*- mode: C++; tab-width: 4; 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/. */
|
2000-03-31 02:32:18 +04:00
|
|
|
|
2013-12-09 06:52:54 +04:00
|
|
|
#include "mozilla/ArrayUtils.h"
|
2011-10-11 09:50:08 +04:00
|
|
|
|
2001-11-06 11:23:51 +03:00
|
|
|
#include "nscore.h"
|
|
|
|
|
2000-03-31 02:32:18 +04:00
|
|
|
#include "nsXPLookAndFeel.h"
|
2011-09-09 06:27:11 +04:00
|
|
|
#include "nsLookAndFeel.h"
|
2017-04-04 17:22:00 +03:00
|
|
|
#include "HeadlessLookAndFeel.h"
|
2020-07-15 15:45:07 +03:00
|
|
|
#include "nsContentUtils.h"
|
2002-05-15 22:55:21 +04:00
|
|
|
#include "nsCRT.h"
|
2004-10-25 23:34:45 +04:00
|
|
|
#include "nsFont.h"
|
2020-06-09 02:00:21 +03:00
|
|
|
#include "nsIXULRuntime.h"
|
2015-05-07 20:32:01 +03:00
|
|
|
#include "mozilla/dom/ContentChild.h"
|
2011-05-23 18:54:03 +04:00
|
|
|
#include "mozilla/Preferences.h"
|
2019-09-19 22:05:01 +03:00
|
|
|
#include "mozilla/Services.h"
|
2017-03-23 05:52:53 +03:00
|
|
|
#include "mozilla/ServoStyleSet.h"
|
2019-07-26 04:10:23 +03:00
|
|
|
#include "mozilla/StaticPrefs_editor.h"
|
2019-08-27 03:09:29 +03:00
|
|
|
#include "mozilla/StaticPrefs_findbar.h"
|
2019-08-27 03:07:34 +03:00
|
|
|
#include "mozilla/StaticPrefs_ui.h"
|
2013-10-08 03:15:59 +04:00
|
|
|
#include "mozilla/gfx/2D.h"
|
2015-04-22 17:58:15 +03:00
|
|
|
#include "mozilla/widget/WidgetMessageUtils.h"
|
2019-12-20 22:05:12 +03:00
|
|
|
#include "mozilla/Telemetry.h"
|
|
|
|
#include "mozilla/TelemetryScalarEnums.h"
|
2001-11-06 05:41:04 +03:00
|
|
|
|
2013-09-07 07:08:36 +04:00
|
|
|
#include "gfxPlatform.h"
|
2019-05-26 17:31:53 +03:00
|
|
|
|
2009-04-07 20:02:11 +04:00
|
|
|
#include "qcms.h"
|
2007-08-30 20:21:16 +04:00
|
|
|
|
2002-01-24 04:18:36 +03:00
|
|
|
#ifdef DEBUG
|
2001-11-06 05:41:04 +03:00
|
|
|
# include "nsSize.h"
|
|
|
|
#endif
|
2009-02-10 22:25:00 +03:00
|
|
|
|
2011-05-23 18:54:03 +04:00
|
|
|
using namespace mozilla;
|
|
|
|
|
2020-07-29 23:27:42 +03:00
|
|
|
// To make one of these prefs toggleable from a reftest add a user
|
|
|
|
// pref in testing/profiles/reftest/user.js. For example, to make
|
|
|
|
// ui.useAccessibilityTheme toggleable, add:
|
|
|
|
//
|
|
|
|
// user_pref("ui.useAccessibilityTheme", 0);
|
|
|
|
//
|
2000-03-31 02:32:18 +04:00
|
|
|
nsLookAndFeelIntPref nsXPLookAndFeel::sIntPrefs[] = {
|
2020-06-11 14:27:43 +03:00
|
|
|
{"ui.caretBlinkTime", IntID::CaretBlinkTime, false, 0},
|
|
|
|
{"ui.caretWidth", IntID::CaretWidth, false, 0},
|
|
|
|
{"ui.caretVisibleWithSelection", IntID::ShowCaretDuringSelection, false, 0},
|
|
|
|
{"ui.submenuDelay", IntID::SubmenuDelay, false, 0},
|
|
|
|
{"ui.dragThresholdX", IntID::DragThresholdX, false, 0},
|
|
|
|
{"ui.dragThresholdY", IntID::DragThresholdY, false, 0},
|
|
|
|
{"ui.useAccessibilityTheme", IntID::UseAccessibilityTheme, false, 0},
|
|
|
|
{"ui.menusCanOverlapOSBar", IntID::MenusCanOverlapOSBar, false, 0},
|
|
|
|
{"ui.useOverlayScrollbars", IntID::UseOverlayScrollbars, false, 0},
|
|
|
|
{"ui.scrollbarDisplayOnMouseMove", IntID::ScrollbarDisplayOnMouseMove,
|
2013-07-02 14:02:21 +04:00
|
|
|
false, 0},
|
2020-06-11 14:27:43 +03:00
|
|
|
{"ui.scrollbarFadeBeginDelay", IntID::ScrollbarFadeBeginDelay, false, 0},
|
|
|
|
{"ui.scrollbarFadeDuration", IntID::ScrollbarFadeDuration, false, 0},
|
|
|
|
{"ui.showHideScrollbars", IntID::ShowHideScrollbars, false, 0},
|
|
|
|
{"ui.skipNavigatingDisabledMenuItem", IntID::SkipNavigatingDisabledMenuItem,
|
2011-10-17 18:59:28 +04:00
|
|
|
false, 0},
|
2020-06-11 14:27:43 +03:00
|
|
|
{"ui.treeOpenDelay", IntID::TreeOpenDelay, false, 0},
|
|
|
|
{"ui.treeCloseDelay", IntID::TreeCloseDelay, false, 0},
|
|
|
|
{"ui.treeLazyScrollDelay", IntID::TreeLazyScrollDelay, false, 0},
|
|
|
|
{"ui.treeScrollDelay", IntID::TreeScrollDelay, false, 0},
|
|
|
|
{"ui.treeScrollLinesMax", IntID::TreeScrollLinesMax, false, 0},
|
|
|
|
{"accessibility.tabfocus", IntID::TabFocusModel, false, 0},
|
|
|
|
{"ui.alertNotificationOrigin", IntID::AlertNotificationOrigin, false, 0},
|
|
|
|
{"ui.scrollToClick", IntID::ScrollToClick, false, 0},
|
|
|
|
{"ui.IMERawInputUnderlineStyle", IntID::IMERawInputUnderlineStyle, false,
|
2011-10-17 18:59:28 +04:00
|
|
|
0},
|
2007-08-17 00:35:18 +04:00
|
|
|
{"ui.IMESelectedRawTextUnderlineStyle",
|
2020-06-11 14:27:43 +03:00
|
|
|
IntID::IMESelectedRawTextUnderlineStyle, false, 0},
|
|
|
|
{"ui.IMEConvertedTextUnderlineStyle", IntID::IMEConvertedTextUnderlineStyle,
|
2011-10-17 18:59:28 +04:00
|
|
|
false, 0},
|
2007-08-17 00:35:18 +04:00
|
|
|
{"ui.IMESelectedConvertedTextUnderlineStyle",
|
2020-06-11 14:27:43 +03:00
|
|
|
IntID::IMESelectedConvertedTextUnderline, false, 0},
|
|
|
|
{"ui.SpellCheckerUnderlineStyle", IntID::SpellCheckerUnderlineStyle, false,
|
2011-10-17 18:59:28 +04:00
|
|
|
0},
|
2011-11-18 03:41:35 +04:00
|
|
|
{"ui.scrollbarButtonAutoRepeatBehavior",
|
2020-06-11 14:27:43 +03:00
|
|
|
IntID::ScrollbarButtonAutoRepeatBehavior, false, 0},
|
|
|
|
{"ui.tooltipDelay", IntID::TooltipDelay, false, 0},
|
|
|
|
{"ui.contextMenuOffsetVertical", IntID::ContextMenuOffsetVertical, false,
|
2015-08-04 23:41:00 +03:00
|
|
|
0},
|
2020-06-11 14:27:43 +03:00
|
|
|
{"ui.contextMenuOffsetHorizontal", IntID::ContextMenuOffsetHorizontal,
|
2017-10-17 22:12:21 +03:00
|
|
|
false, 0},
|
2020-06-11 14:27:43 +03:00
|
|
|
{"ui.GtkCSDAvailable", IntID::GTKCSDAvailable, false, 0},
|
|
|
|
{"ui.GtkCSDHideTitlebarByDefault", IntID::GTKCSDHideTitlebarByDefault,
|
2019-01-17 15:44:49 +03:00
|
|
|
false, 0},
|
2020-06-11 14:27:43 +03:00
|
|
|
{"ui.GtkCSDTransparentBackground", IntID::GTKCSDTransparentBackground,
|
2018-09-25 14:53:04 +03:00
|
|
|
false, 0},
|
2020-06-11 14:27:43 +03:00
|
|
|
{"ui.GtkCSDMinimizeButton", IntID::GTKCSDMinimizeButton, false, 0},
|
|
|
|
{"ui.GtkCSDMaximizeButton", IntID::GTKCSDMaximizeButton, false, 0},
|
|
|
|
{"ui.GtkCSDCloseButton", IntID::GTKCSDCloseButton, false, 0},
|
|
|
|
{"ui.systemUsesDarkTheme", IntID::SystemUsesDarkTheme, false, 0},
|
|
|
|
{"ui.prefersReducedMotion", IntID::PrefersReducedMotion, false, 0},
|
|
|
|
{"ui.primaryPointerCapabilities", IntID::PrimaryPointerCapabilities, false,
|
2018-08-14 11:13:04 +03:00
|
|
|
6 /* fine and hover-capable pointer, i.e. mouse-type */},
|
2020-06-11 14:27:43 +03:00
|
|
|
{"ui.allPointerCapabilities", IntID::AllPointerCapabilities, false,
|
2018-08-14 11:13:04 +03:00
|
|
|
6 /* fine and hover-capable pointer, i.e. mouse-type */},
|
2000-03-31 02:32:18 +04:00
|
|
|
};
|
|
|
|
|
|
|
|
nsLookAndFeelFloatPref nsXPLookAndFeel::sFloatPrefs[] = {
|
2020-06-11 14:27:43 +03:00
|
|
|
{"ui.IMEUnderlineRelativeSize", FloatID::IMEUnderlineRelativeSize, false,
|
2011-10-17 18:59:28 +04:00
|
|
|
0},
|
2009-04-03 11:26:28 +04:00
|
|
|
{"ui.SpellCheckerUnderlineRelativeSize",
|
2020-06-11 14:27:43 +03:00
|
|
|
FloatID::SpellCheckerUnderlineRelativeSize, false, 0},
|
|
|
|
{"ui.caretAspectRatio", FloatID::CaretAspectRatio, false, 0},
|
2000-04-12 02:34:55 +04:00
|
|
|
};
|
|
|
|
|
2019-05-26 16:10:00 +03:00
|
|
|
// This array MUST be kept in the same order as the color list in
|
|
|
|
// specified/color.rs
|
2004-03-02 06:44:26 +03:00
|
|
|
/* XXX If you add any strings longer than
|
2017-09-13 14:48:07 +03:00
|
|
|
* "ui.-moz-mac-active-source-list-selection"
|
2004-03-02 06:44:26 +03:00
|
|
|
* to the following array then you MUST update the
|
|
|
|
* sizes of the sColorPrefs array in nsXPLookAndFeel.h
|
|
|
|
*/
|
2017-09-13 14:48:07 +03:00
|
|
|
const char nsXPLookAndFeel::sColorPrefs[][41] = {
|
2001-11-06 05:41:04 +03:00
|
|
|
"ui.windowBackground",
|
|
|
|
"ui.windowForeground",
|
|
|
|
"ui.widgetBackground",
|
|
|
|
"ui.widgetForeground",
|
|
|
|
"ui.widgetSelectBackground",
|
|
|
|
"ui.widgetSelectForeground",
|
|
|
|
"ui.widget3DHighlight",
|
|
|
|
"ui.widget3DShadow",
|
|
|
|
"ui.textBackground",
|
|
|
|
"ui.textForeground",
|
|
|
|
"ui.textSelectBackground",
|
|
|
|
"ui.textSelectForeground",
|
2014-07-28 04:13:00 +04:00
|
|
|
"ui.textSelectForegroundCustom",
|
2002-09-06 11:30:45 +04:00
|
|
|
"ui.textSelectBackgroundDisabled",
|
|
|
|
"ui.textSelectBackgroundAttention",
|
2008-07-31 00:48:56 +04:00
|
|
|
"ui.textHighlightBackground",
|
2008-09-02 10:28:44 +04:00
|
|
|
"ui.textHighlightForeground",
|
2005-09-17 15:34:27 +04:00
|
|
|
"ui.IMERawInputBackground",
|
|
|
|
"ui.IMERawInputForeground",
|
|
|
|
"ui.IMERawInputUnderline",
|
|
|
|
"ui.IMESelectedRawTextBackground",
|
|
|
|
"ui.IMESelectedRawTextForeground",
|
|
|
|
"ui.IMESelectedRawTextUnderline",
|
|
|
|
"ui.IMEConvertedTextBackground",
|
|
|
|
"ui.IMEConvertedTextForeground",
|
|
|
|
"ui.IMEConvertedTextUnderline",
|
|
|
|
"ui.IMESelectedConvertedTextBackground",
|
|
|
|
"ui.IMESelectedConvertedTextForeground",
|
|
|
|
"ui.IMESelectedConvertedTextUnderline",
|
2009-04-03 11:26:28 +04:00
|
|
|
"ui.SpellCheckerUnderline",
|
2001-11-06 05:41:04 +03:00
|
|
|
"ui.activeborder",
|
|
|
|
"ui.activecaption",
|
|
|
|
"ui.appworkspace",
|
|
|
|
"ui.background",
|
|
|
|
"ui.buttonface",
|
|
|
|
"ui.buttonhighlight",
|
|
|
|
"ui.buttonshadow",
|
|
|
|
"ui.buttontext",
|
|
|
|
"ui.captiontext",
|
2019-11-03 00:28:49 +03:00
|
|
|
"ui.-moz-field",
|
|
|
|
"ui.-moz-fieldtext",
|
2001-11-06 05:41:04 +03:00
|
|
|
"ui.graytext",
|
|
|
|
"ui.highlight",
|
|
|
|
"ui.highlighttext",
|
|
|
|
"ui.inactiveborder",
|
|
|
|
"ui.inactivecaption",
|
|
|
|
"ui.inactivecaptiontext",
|
|
|
|
"ui.infobackground",
|
|
|
|
"ui.infotext",
|
|
|
|
"ui.menu",
|
|
|
|
"ui.menutext",
|
|
|
|
"ui.scrollbar",
|
|
|
|
"ui.threeddarkshadow",
|
|
|
|
"ui.threedface",
|
|
|
|
"ui.threedhighlight",
|
|
|
|
"ui.threedlightshadow",
|
|
|
|
"ui.threedshadow",
|
|
|
|
"ui.window",
|
|
|
|
"ui.windowframe",
|
|
|
|
"ui.windowtext",
|
2003-06-19 01:16:29 +04:00
|
|
|
"ui.-moz-buttondefault",
|
2019-11-14 03:17:23 +03:00
|
|
|
"ui.-moz-default-color",
|
|
|
|
"ui.-moz-default-background-color",
|
2001-11-06 05:41:04 +03:00
|
|
|
"ui.-moz-dialog",
|
|
|
|
"ui.-moz-dialogtext",
|
|
|
|
"ui.-moz-dragtargetzone",
|
2008-04-24 12:08:33 +04:00
|
|
|
"ui.-moz-cellhighlight",
|
|
|
|
"ui.-moz_cellhighlighttext",
|
2008-01-24 12:31:44 +03:00
|
|
|
"ui.-moz-html-cellhighlight",
|
|
|
|
"ui.-moz-html-cellhighlighttext",
|
2008-04-24 12:08:33 +04:00
|
|
|
"ui.-moz-buttonhoverface",
|
|
|
|
"ui.-moz_buttonhovertext",
|
|
|
|
"ui.-moz_menuhover",
|
|
|
|
"ui.-moz_menuhovertext",
|
2009-06-15 01:58:14 +04:00
|
|
|
"ui.-moz_menubartext",
|
2008-04-24 12:08:33 +04:00
|
|
|
"ui.-moz_menubarhovertext",
|
|
|
|
"ui.-moz_eventreerow",
|
|
|
|
"ui.-moz_oddtreerow",
|
2019-05-24 11:51:48 +03:00
|
|
|
"ui.-moz-gtk-buttonactivetext",
|
2014-09-12 03:31:15 +04:00
|
|
|
"ui.-moz-mac-buttonactivetext",
|
2009-04-01 00:02:55 +04:00
|
|
|
"ui.-moz_mac_chrome_active",
|
|
|
|
"ui.-moz_mac_chrome_inactive",
|
2014-09-12 03:31:15 +04:00
|
|
|
"ui.-moz-mac-defaultbuttontext",
|
2001-11-06 05:41:04 +03:00
|
|
|
"ui.-moz-mac-focusring",
|
|
|
|
"ui.-moz-mac-menuselect",
|
|
|
|
"ui.-moz-mac-menushadow",
|
2006-07-14 23:54:08 +04:00
|
|
|
"ui.-moz-mac-menutextdisable",
|
2001-11-06 05:41:04 +03:00
|
|
|
"ui.-moz-mac-menutextselect",
|
2009-04-01 00:02:55 +04:00
|
|
|
"ui.-moz_mac_disabledtoolbartext",
|
2008-04-29 23:27:23 +04:00
|
|
|
"ui.-moz-mac-secondaryhighlight",
|
2017-09-13 14:48:07 +03:00
|
|
|
"ui.-moz-mac-vibrancy-light",
|
|
|
|
"ui.-moz-mac-vibrancy-dark",
|
2017-11-16 19:50:09 +03:00
|
|
|
"ui.-moz-mac-vibrant-titlebar-light",
|
|
|
|
"ui.-moz-mac-vibrant-titlebar-dark",
|
2017-09-13 14:48:07 +03:00
|
|
|
"ui.-moz-mac-menupopup",
|
|
|
|
"ui.-moz-mac-menuitem",
|
|
|
|
"ui.-moz-mac-active-menuitem",
|
|
|
|
"ui.-moz-mac-source-list",
|
|
|
|
"ui.-moz-mac-source-list-selection",
|
|
|
|
"ui.-moz-mac-active-source-list-selection",
|
|
|
|
"ui.-moz-mac-tooltip",
|
2019-01-09 19:37:34 +03:00
|
|
|
"ui.-moz-win-accentcolor",
|
|
|
|
"ui.-moz-win-accentcolortext",
|
2008-04-29 23:27:23 +04:00
|
|
|
"ui.-moz-win-mediatext",
|
2008-07-11 22:34:53 +04:00
|
|
|
"ui.-moz-win-communicationstext",
|
2009-01-16 11:18:49 +03:00
|
|
|
"ui.-moz-nativehyperlinktext",
|
2019-11-14 03:17:23 +03:00
|
|
|
"ui.-moz-hyperlinktext",
|
|
|
|
"ui.-moz-activehyperlinktext",
|
|
|
|
"ui.-moz-visitedhyperlinktext",
|
2009-01-16 11:18:49 +03:00
|
|
|
"ui.-moz-comboboxtext",
|
2019-01-09 19:37:34 +03:00
|
|
|
"ui.-moz-combobox",
|
2020-06-03 23:52:55 +03:00
|
|
|
"ui.-moz-gtk-info-bar-text",
|
|
|
|
"ui.-moz-colheadertext",
|
|
|
|
"ui.-moz-colheaderhovertext"};
|
|
|
|
|
2019-05-26 16:10:00 +03:00
|
|
|
int32_t nsXPLookAndFeel::sCachedColors[size_t(LookAndFeel::ColorID::End)] = {0};
|
2012-08-22 19:56:38 +04:00
|
|
|
int32_t nsXPLookAndFeel::sCachedColorBits[COLOR_CACHE_SIZE] = {0};
|
2001-11-06 05:41:04 +03:00
|
|
|
|
2011-09-29 10:19:26 +04:00
|
|
|
bool nsXPLookAndFeel::sInitialized = false;
|
2000-03-31 02:32:18 +04:00
|
|
|
|
2017-04-04 17:22:00 +03:00
|
|
|
nsXPLookAndFeel* nsXPLookAndFeel::sInstance = nullptr;
|
2011-09-29 10:19:26 +04:00
|
|
|
bool nsXPLookAndFeel::sShutdown = false;
|
2011-09-09 06:27:11 +04:00
|
|
|
|
|
|
|
// static
|
|
|
|
nsXPLookAndFeel* nsXPLookAndFeel::GetInstance() {
|
|
|
|
if (sInstance) {
|
2011-09-09 06:27:13 +04:00
|
|
|
return sInstance;
|
2011-09-09 06:27:11 +04:00
|
|
|
}
|
|
|
|
|
2012-07-30 18:20:58 +04:00
|
|
|
NS_ENSURE_TRUE(!sShutdown, nullptr);
|
2011-09-09 06:27:11 +04:00
|
|
|
|
2017-04-04 17:22:00 +03:00
|
|
|
if (gfxPlatform::IsHeadless()) {
|
|
|
|
sInstance = new widget::HeadlessLookAndFeel();
|
|
|
|
} else {
|
|
|
|
sInstance = new nsLookAndFeel();
|
|
|
|
}
|
2011-09-09 06:27:13 +04:00
|
|
|
return sInstance;
|
2011-09-09 06:27:11 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
// static
|
|
|
|
void nsXPLookAndFeel::Shutdown() {
|
|
|
|
if (sShutdown) {
|
|
|
|
return;
|
|
|
|
}
|
2011-10-17 18:59:28 +04:00
|
|
|
sShutdown = true;
|
2011-09-09 06:27:13 +04:00
|
|
|
delete sInstance;
|
2012-07-30 18:20:58 +04:00
|
|
|
sInstance = nullptr;
|
2011-09-09 06:27:11 +04:00
|
|
|
}
|
|
|
|
|
2011-09-09 06:27:11 +04:00
|
|
|
// static
|
2011-09-09 06:27:13 +04:00
|
|
|
void nsXPLookAndFeel::IntPrefChanged(nsLookAndFeelIntPref* data) {
|
2011-05-23 18:54:03 +04:00
|
|
|
if (!data) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2012-08-22 19:56:38 +04:00
|
|
|
int32_t intpref;
|
2011-05-23 18:54:03 +04:00
|
|
|
nsresult rv = Preferences::GetInt(data->name, &intpref);
|
|
|
|
if (NS_FAILED(rv)) {
|
2019-09-19 22:05:01 +03:00
|
|
|
data->isSet = false;
|
|
|
|
|
2019-09-11 21:35:44 +03:00
|
|
|
#ifdef DEBUG_akkana
|
2019-09-19 22:05:01 +03:00
|
|
|
printf("====== Cleared int pref %s\n", data->name);
|
2019-09-11 21:35:44 +03:00
|
|
|
#endif
|
2019-09-19 22:05:01 +03:00
|
|
|
} else {
|
|
|
|
data->intVar = intpref;
|
|
|
|
data->isSet = true;
|
|
|
|
|
|
|
|
#ifdef DEBUG_akkana
|
|
|
|
printf("====== Changed int pref %s to %d\n", data->name, data->intVar);
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
2020-05-23 02:03:43 +03:00
|
|
|
NotifyChangedAllWindows();
|
2000-03-31 02:32:18 +04:00
|
|
|
}
|
|
|
|
|
2011-09-09 06:27:11 +04:00
|
|
|
// static
|
2011-09-09 06:27:13 +04:00
|
|
|
void nsXPLookAndFeel::FloatPrefChanged(nsLookAndFeelFloatPref* data) {
|
2011-05-23 18:54:03 +04:00
|
|
|
if (!data) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2012-08-22 19:56:38 +04:00
|
|
|
int32_t intpref;
|
2011-05-23 18:54:03 +04:00
|
|
|
nsresult rv = Preferences::GetInt(data->name, &intpref);
|
|
|
|
if (NS_FAILED(rv)) {
|
2019-09-19 22:05:01 +03:00
|
|
|
data->isSet = false;
|
|
|
|
|
|
|
|
#ifdef DEBUG_akkana
|
|
|
|
printf("====== Cleared float pref %s\n", data->name);
|
|
|
|
#endif
|
|
|
|
} else {
|
|
|
|
data->floatVar = (float)intpref / 100.0f;
|
|
|
|
data->isSet = true;
|
|
|
|
|
2000-03-31 02:32:18 +04:00
|
|
|
#ifdef DEBUG_akkana
|
2019-09-19 22:05:01 +03:00
|
|
|
printf("====== Changed float pref %s to %f\n", data->name);
|
2000-03-31 02:32:18 +04:00
|
|
|
#endif
|
2019-09-19 22:05:01 +03:00
|
|
|
}
|
|
|
|
|
2020-05-23 02:03:43 +03:00
|
|
|
NotifyChangedAllWindows();
|
2000-03-31 02:32:18 +04:00
|
|
|
}
|
|
|
|
|
2011-09-09 06:27:11 +04:00
|
|
|
// static
|
2005-09-12 16:36:11 +04:00
|
|
|
void nsXPLookAndFeel::ColorPrefChanged(unsigned int index,
|
|
|
|
const char* prefName) {
|
2011-05-23 18:54:03 +04:00
|
|
|
nsAutoString colorStr;
|
2017-07-31 03:52:51 +03:00
|
|
|
nsresult rv = Preferences::GetString(prefName, colorStr);
|
2019-09-19 22:05:01 +03:00
|
|
|
if (NS_SUCCEEDED(rv) && !colorStr.IsEmpty()) {
|
2011-05-23 18:54:03 +04:00
|
|
|
nscolor thecolor;
|
2014-01-04 19:02:17 +04:00
|
|
|
if (colorStr[0] == char16_t('#')) {
|
2016-05-09 08:16:41 +03:00
|
|
|
if (NS_HexToRGBA(nsDependentString(colorStr, 1), nsHexColorType::NoAlpha,
|
|
|
|
&thecolor)) {
|
2012-08-22 19:56:38 +04:00
|
|
|
int32_t id = NS_PTR_TO_INT32(index);
|
2001-11-06 05:41:04 +03:00
|
|
|
CACHE_COLOR(id, thecolor);
|
2000-04-12 02:34:55 +04:00
|
|
|
}
|
2011-05-23 18:54:03 +04:00
|
|
|
} else if (NS_ColorNameToRGB(colorStr, &thecolor)) {
|
2012-08-22 19:56:38 +04:00
|
|
|
int32_t id = NS_PTR_TO_INT32(index);
|
2011-05-23 18:54:03 +04:00
|
|
|
CACHE_COLOR(id, thecolor);
|
|
|
|
#ifdef DEBUG_akkana
|
|
|
|
printf("====== Changed color pref %s to 0x%lx\n", prefName, thecolor);
|
|
|
|
#endif
|
2000-04-12 02:34:55 +04:00
|
|
|
}
|
2011-05-23 18:54:03 +04:00
|
|
|
} else {
|
|
|
|
// Reset to the default color, by clearing the cache
|
|
|
|
// to force lookup when the color is next used
|
2012-08-22 19:56:38 +04:00
|
|
|
int32_t id = NS_PTR_TO_INT32(index);
|
2011-05-23 18:54:03 +04:00
|
|
|
CLEAR_COLOR_CACHE(id);
|
2019-09-19 22:05:01 +03:00
|
|
|
|
|
|
|
#ifdef DEBUG_akkana
|
|
|
|
printf("====== Cleared color pref %s\n", prefName);
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
2020-05-23 02:03:43 +03:00
|
|
|
NotifyChangedAllWindows();
|
2000-04-12 02:34:55 +04:00
|
|
|
}
|
|
|
|
|
2011-05-23 18:54:03 +04:00
|
|
|
void nsXPLookAndFeel::InitFromPref(nsLookAndFeelIntPref* aPref) {
|
2012-08-22 19:56:38 +04:00
|
|
|
int32_t intpref;
|
2011-05-23 18:54:03 +04:00
|
|
|
nsresult rv = Preferences::GetInt(aPref->name, &intpref);
|
|
|
|
if (NS_SUCCEEDED(rv)) {
|
2011-10-17 18:59:28 +04:00
|
|
|
aPref->isSet = true;
|
2000-03-31 02:32:18 +04:00
|
|
|
aPref->intVar = intpref;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-05-23 18:54:03 +04:00
|
|
|
void nsXPLookAndFeel::InitFromPref(nsLookAndFeelFloatPref* aPref) {
|
2012-08-22 19:56:38 +04:00
|
|
|
int32_t intpref;
|
2011-05-23 18:54:03 +04:00
|
|
|
nsresult rv = Preferences::GetInt(aPref->name, &intpref);
|
|
|
|
if (NS_SUCCEEDED(rv)) {
|
2011-10-17 18:59:28 +04:00
|
|
|
aPref->isSet = true;
|
2011-09-09 06:27:13 +04:00
|
|
|
aPref->floatVar = (float)intpref / 100.0f;
|
2000-03-31 02:32:18 +04:00
|
|
|
}
|
2000-04-12 02:34:55 +04:00
|
|
|
}
|
|
|
|
|
2012-08-22 19:56:38 +04:00
|
|
|
void nsXPLookAndFeel::InitColorFromPref(int32_t i) {
|
2019-05-26 16:10:00 +03:00
|
|
|
static_assert(ArrayLength(sColorPrefs) == size_t(ColorID::End),
|
|
|
|
"Should have a pref for each color value");
|
|
|
|
|
2011-05-23 18:54:03 +04:00
|
|
|
nsAutoString colorStr;
|
2017-07-31 03:52:51 +03:00
|
|
|
nsresult rv = Preferences::GetString(sColorPrefs[i], colorStr);
|
2011-05-23 18:54:03 +04:00
|
|
|
if (NS_FAILED(rv) || colorStr.IsEmpty()) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
nscolor thecolor;
|
2014-01-04 19:02:17 +04:00
|
|
|
if (colorStr[0] == char16_t('#')) {
|
2011-05-23 18:54:03 +04:00
|
|
|
nsAutoString hexString;
|
|
|
|
colorStr.Right(hexString, colorStr.Length() - 1);
|
2016-05-09 08:16:41 +03:00
|
|
|
if (NS_HexToRGBA(hexString, nsHexColorType::NoAlpha, &thecolor)) {
|
2001-11-06 05:41:04 +03:00
|
|
|
CACHE_COLOR(i, thecolor);
|
2005-09-12 16:36:11 +04:00
|
|
|
}
|
2011-05-23 18:54:03 +04:00
|
|
|
} else if (NS_ColorNameToRGB(colorStr, &thecolor)) {
|
|
|
|
CACHE_COLOR(i, thecolor);
|
2005-09-12 16:36:11 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-09-09 06:27:11 +04:00
|
|
|
// static
|
|
|
|
void nsXPLookAndFeel::OnPrefChanged(const char* aPref, void* aClosure) {
|
2005-09-12 16:36:11 +04:00
|
|
|
// looping in the same order as in ::Init
|
|
|
|
|
2011-09-09 06:27:11 +04:00
|
|
|
nsDependentCString prefName(aPref);
|
2005-09-12 16:36:11 +04:00
|
|
|
unsigned int i;
|
2011-10-11 09:50:08 +04:00
|
|
|
for (i = 0; i < ArrayLength(sIntPrefs); ++i) {
|
2011-09-09 06:27:11 +04:00
|
|
|
if (prefName.Equals(sIntPrefs[i].name)) {
|
2005-09-12 16:36:11 +04:00
|
|
|
IntPrefChanged(&sIntPrefs[i]);
|
2013-12-11 03:10:01 +04:00
|
|
|
return;
|
2005-09-12 16:36:11 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-10-11 09:50:08 +04:00
|
|
|
for (i = 0; i < ArrayLength(sFloatPrefs); ++i) {
|
2011-09-09 06:27:11 +04:00
|
|
|
if (prefName.Equals(sFloatPrefs[i].name)) {
|
2005-09-12 16:36:11 +04:00
|
|
|
FloatPrefChanged(&sFloatPrefs[i]);
|
2013-12-11 03:10:01 +04:00
|
|
|
return;
|
2005-09-12 16:36:11 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-10-11 09:50:08 +04:00
|
|
|
for (i = 0; i < ArrayLength(sColorPrefs); ++i) {
|
2011-09-09 06:27:11 +04:00
|
|
|
if (prefName.Equals(sColorPrefs[i])) {
|
2005-09-12 16:36:11 +04:00
|
|
|
ColorPrefChanged(i, sColorPrefs[i]);
|
2013-12-11 03:10:01 +04:00
|
|
|
return;
|
2000-04-12 02:34:55 +04:00
|
|
|
}
|
|
|
|
}
|
2000-03-31 02:32:18 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
//
|
|
|
|
// Read values from the user's preferences.
|
|
|
|
// This is done once at startup, but since the user's preferences
|
|
|
|
// haven't actually been read yet at that time, we also have to
|
|
|
|
// set a callback to inform us of changes to each pref.
|
|
|
|
//
|
|
|
|
void nsXPLookAndFeel::Init() {
|
2017-03-23 05:52:53 +03:00
|
|
|
MOZ_RELEASE_ASSERT(NS_IsMainThread());
|
|
|
|
|
2000-03-31 02:32:18 +04:00
|
|
|
// Say we're already initialized, and take the chance that it might fail;
|
|
|
|
// protects against some other process writing to our static variables.
|
2011-10-17 18:59:28 +04:00
|
|
|
sInitialized = true;
|
2000-03-31 02:32:18 +04:00
|
|
|
|
2011-09-09 06:27:11 +04:00
|
|
|
// XXX If we could reorganize the pref names, we should separate the branch
|
|
|
|
// for each types. Then, we could reduce the unnecessary loop from
|
|
|
|
// nsXPLookAndFeel::OnPrefChanged().
|
2017-03-21 21:59:02 +03:00
|
|
|
Preferences::RegisterPrefixCallback(OnPrefChanged, "ui.");
|
|
|
|
// We really do just want the accessibility.tabfocus pref, not other prefs
|
|
|
|
// that start with that string.
|
2011-09-09 06:27:11 +04:00
|
|
|
Preferences::RegisterCallback(OnPrefChanged, "accessibility.tabfocus");
|
|
|
|
|
2000-03-31 02:32:18 +04:00
|
|
|
unsigned int i;
|
2011-10-11 09:50:08 +04:00
|
|
|
for (i = 0; i < ArrayLength(sIntPrefs); ++i) {
|
2011-05-23 18:54:03 +04:00
|
|
|
InitFromPref(&sIntPrefs[i]);
|
2005-09-12 16:36:11 +04:00
|
|
|
}
|
2000-03-31 02:32:18 +04:00
|
|
|
|
2011-10-11 09:50:08 +04:00
|
|
|
for (i = 0; i < ArrayLength(sFloatPrefs); ++i) {
|
2011-05-23 18:54:03 +04:00
|
|
|
InitFromPref(&sFloatPrefs[i]);
|
2005-09-12 16:36:11 +04:00
|
|
|
}
|
2000-03-31 02:32:18 +04:00
|
|
|
|
2011-10-11 09:50:08 +04:00
|
|
|
for (i = 0; i < ArrayLength(sColorPrefs); ++i) {
|
2011-05-23 18:54:03 +04:00
|
|
|
InitColorFromPref(i);
|
2005-09-12 16:36:11 +04:00
|
|
|
}
|
2009-02-10 22:25:00 +03:00
|
|
|
|
2015-07-04 04:29:00 +03:00
|
|
|
if (XRE_IsContentProcess()) {
|
2015-04-22 17:58:15 +03:00
|
|
|
mozilla::dom::ContentChild* cc = mozilla::dom::ContentChild::GetSingleton();
|
|
|
|
|
2020-07-31 19:21:44 +03:00
|
|
|
LookAndFeel::SetCache(cc->BorrowLookAndFeelCache());
|
2016-11-18 23:36:18 +03:00
|
|
|
// This is only ever used once during initialization, and can be cleared
|
|
|
|
// now.
|
2020-07-31 19:21:44 +03:00
|
|
|
cc->BorrowLookAndFeelCache().Clear();
|
2015-04-22 17:58:15 +03:00
|
|
|
}
|
2000-03-31 02:32:18 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
nsXPLookAndFeel::~nsXPLookAndFeel() {
|
2011-09-09 06:27:11 +04:00
|
|
|
NS_ASSERTION(sInstance == this,
|
|
|
|
"This destroying instance isn't the singleton instance");
|
2012-07-30 18:20:58 +04:00
|
|
|
sInstance = nullptr;
|
2000-03-31 02:32:18 +04:00
|
|
|
}
|
|
|
|
|
2011-09-09 06:27:13 +04:00
|
|
|
bool nsXPLookAndFeel::IsSpecialColor(ColorID aID, nscolor& aColor) {
|
2007-09-04 15:28:12 +04:00
|
|
|
switch (aID) {
|
2019-05-26 16:10:00 +03:00
|
|
|
case ColorID::TextSelectForeground:
|
2007-09-04 15:28:12 +04:00
|
|
|
return (aColor == NS_DONT_CHANGE_COLOR);
|
2019-05-26 16:10:00 +03:00
|
|
|
case ColorID::IMESelectedRawTextBackground:
|
|
|
|
case ColorID::IMESelectedConvertedTextBackground:
|
|
|
|
case ColorID::IMERawInputBackground:
|
|
|
|
case ColorID::IMEConvertedTextBackground:
|
|
|
|
case ColorID::IMESelectedRawTextForeground:
|
|
|
|
case ColorID::IMESelectedConvertedTextForeground:
|
|
|
|
case ColorID::IMERawInputForeground:
|
|
|
|
case ColorID::IMEConvertedTextForeground:
|
|
|
|
case ColorID::IMERawInputUnderline:
|
|
|
|
case ColorID::IMEConvertedTextUnderline:
|
|
|
|
case ColorID::IMESelectedRawTextUnderline:
|
|
|
|
case ColorID::IMESelectedConvertedTextUnderline:
|
|
|
|
case ColorID::SpellCheckerUnderline:
|
2009-04-03 11:26:28 +04:00
|
|
|
return NS_IS_SELECTION_SPECIAL_COLOR(aColor);
|
2008-09-16 15:32:03 +04:00
|
|
|
default:
|
|
|
|
/*
|
|
|
|
* In GetColor(), every color that is not a special color is color
|
2011-10-17 18:59:28 +04:00
|
|
|
* corrected. Use false to make other colors color corrected.
|
2008-09-16 15:32:03 +04:00
|
|
|
*/
|
2011-10-17 18:59:28 +04:00
|
|
|
return false;
|
2007-09-04 15:28:12 +04:00
|
|
|
}
|
2011-10-17 18:59:28 +04:00
|
|
|
return false;
|
2007-09-04 15:28:12 +04:00
|
|
|
}
|
|
|
|
|
2015-09-25 01:59:00 +03:00
|
|
|
bool nsXPLookAndFeel::ColorIsNotCSSAccessible(ColorID aID) {
|
|
|
|
bool result = false;
|
|
|
|
|
|
|
|
switch (aID) {
|
2019-05-26 16:10:00 +03:00
|
|
|
case ColorID::WindowBackground:
|
|
|
|
case ColorID::WindowForeground:
|
|
|
|
case ColorID::WidgetBackground:
|
|
|
|
case ColorID::WidgetForeground:
|
|
|
|
case ColorID::WidgetSelectBackground:
|
|
|
|
case ColorID::WidgetSelectForeground:
|
|
|
|
case ColorID::Widget3DHighlight:
|
|
|
|
case ColorID::Widget3DShadow:
|
|
|
|
case ColorID::TextBackground:
|
|
|
|
case ColorID::TextForeground:
|
|
|
|
case ColorID::TextSelectBackground:
|
|
|
|
case ColorID::TextSelectForeground:
|
|
|
|
case ColorID::TextSelectBackgroundDisabled:
|
|
|
|
case ColorID::TextSelectBackgroundAttention:
|
|
|
|
case ColorID::TextHighlightBackground:
|
|
|
|
case ColorID::TextHighlightForeground:
|
|
|
|
case ColorID::IMERawInputBackground:
|
|
|
|
case ColorID::IMERawInputForeground:
|
|
|
|
case ColorID::IMERawInputUnderline:
|
|
|
|
case ColorID::IMESelectedRawTextBackground:
|
|
|
|
case ColorID::IMESelectedRawTextForeground:
|
|
|
|
case ColorID::IMESelectedRawTextUnderline:
|
|
|
|
case ColorID::IMEConvertedTextBackground:
|
|
|
|
case ColorID::IMEConvertedTextForeground:
|
|
|
|
case ColorID::IMEConvertedTextUnderline:
|
|
|
|
case ColorID::IMESelectedConvertedTextBackground:
|
|
|
|
case ColorID::IMESelectedConvertedTextForeground:
|
|
|
|
case ColorID::IMESelectedConvertedTextUnderline:
|
|
|
|
case ColorID::SpellCheckerUnderline:
|
2015-09-25 01:59:00 +03:00
|
|
|
result = true;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
|
|
|
nscolor nsXPLookAndFeel::GetStandinForNativeColor(ColorID aID) {
|
|
|
|
nscolor result = NS_RGB(0xFF, 0xFF, 0xFF);
|
|
|
|
|
|
|
|
// The stand-in colors are taken from the Windows 7 Aero theme
|
|
|
|
// except Mac-specific colors which are taken from Mac OS 10.7.
|
|
|
|
switch (aID) {
|
|
|
|
// CSS 2 colors:
|
2019-05-26 16:10:00 +03:00
|
|
|
case ColorID::Activeborder:
|
2015-09-25 01:59:00 +03:00
|
|
|
result = NS_RGB(0xB4, 0xB4, 0xB4);
|
|
|
|
break;
|
2019-05-26 16:10:00 +03:00
|
|
|
case ColorID::Activecaption:
|
2015-09-25 01:59:00 +03:00
|
|
|
result = NS_RGB(0x99, 0xB4, 0xD1);
|
|
|
|
break;
|
2019-05-26 16:10:00 +03:00
|
|
|
case ColorID::Appworkspace:
|
2015-09-25 01:59:00 +03:00
|
|
|
result = NS_RGB(0xAB, 0xAB, 0xAB);
|
|
|
|
break;
|
2019-05-26 16:10:00 +03:00
|
|
|
case ColorID::Background:
|
2015-09-25 01:59:00 +03:00
|
|
|
result = NS_RGB(0x00, 0x00, 0x00);
|
|
|
|
break;
|
2019-05-26 16:10:00 +03:00
|
|
|
case ColorID::Buttonface:
|
2015-09-25 01:59:00 +03:00
|
|
|
result = NS_RGB(0xF0, 0xF0, 0xF0);
|
|
|
|
break;
|
2019-05-26 16:10:00 +03:00
|
|
|
case ColorID::Buttonhighlight:
|
2015-09-25 01:59:00 +03:00
|
|
|
result = NS_RGB(0xFF, 0xFF, 0xFF);
|
|
|
|
break;
|
2019-05-26 16:10:00 +03:00
|
|
|
case ColorID::Buttonshadow:
|
2015-09-25 01:59:00 +03:00
|
|
|
result = NS_RGB(0xA0, 0xA0, 0xA0);
|
|
|
|
break;
|
2019-05-26 16:10:00 +03:00
|
|
|
case ColorID::Buttontext:
|
2015-09-25 01:59:00 +03:00
|
|
|
result = NS_RGB(0x00, 0x00, 0x00);
|
|
|
|
break;
|
2019-05-26 16:10:00 +03:00
|
|
|
case ColorID::Captiontext:
|
2015-09-25 01:59:00 +03:00
|
|
|
result = NS_RGB(0x00, 0x00, 0x00);
|
|
|
|
break;
|
2019-05-26 16:10:00 +03:00
|
|
|
case ColorID::Graytext:
|
2015-09-25 01:59:00 +03:00
|
|
|
result = NS_RGB(0x6D, 0x6D, 0x6D);
|
|
|
|
break;
|
2019-05-26 16:10:00 +03:00
|
|
|
case ColorID::Highlight:
|
2015-09-25 01:59:00 +03:00
|
|
|
result = NS_RGB(0x33, 0x99, 0xFF);
|
|
|
|
break;
|
2019-05-26 16:10:00 +03:00
|
|
|
case ColorID::Highlighttext:
|
2015-09-25 01:59:00 +03:00
|
|
|
result = NS_RGB(0xFF, 0xFF, 0xFF);
|
|
|
|
break;
|
2019-05-26 16:10:00 +03:00
|
|
|
case ColorID::Inactiveborder:
|
2015-09-25 01:59:00 +03:00
|
|
|
result = NS_RGB(0xF4, 0xF7, 0xFC);
|
|
|
|
break;
|
2019-05-26 16:10:00 +03:00
|
|
|
case ColorID::Inactivecaption:
|
2015-09-25 01:59:00 +03:00
|
|
|
result = NS_RGB(0xBF, 0xCD, 0xDB);
|
|
|
|
break;
|
2019-05-26 16:10:00 +03:00
|
|
|
case ColorID::Inactivecaptiontext:
|
2015-09-25 01:59:00 +03:00
|
|
|
result = NS_RGB(0x43, 0x4E, 0x54);
|
|
|
|
break;
|
2019-05-26 16:10:00 +03:00
|
|
|
case ColorID::Infobackground:
|
2015-09-25 01:59:00 +03:00
|
|
|
result = NS_RGB(0xFF, 0xFF, 0xE1);
|
|
|
|
break;
|
2019-05-26 16:10:00 +03:00
|
|
|
case ColorID::Infotext:
|
2015-09-25 01:59:00 +03:00
|
|
|
result = NS_RGB(0x00, 0x00, 0x00);
|
|
|
|
break;
|
2019-05-26 16:10:00 +03:00
|
|
|
case ColorID::Menu:
|
2015-09-25 01:59:00 +03:00
|
|
|
result = NS_RGB(0xF0, 0xF0, 0xF0);
|
|
|
|
break;
|
2019-05-26 16:10:00 +03:00
|
|
|
case ColorID::Menutext:
|
2015-09-25 01:59:00 +03:00
|
|
|
result = NS_RGB(0x00, 0x00, 0x00);
|
|
|
|
break;
|
2019-05-26 16:10:00 +03:00
|
|
|
case ColorID::Scrollbar:
|
2015-09-25 01:59:00 +03:00
|
|
|
result = NS_RGB(0xC8, 0xC8, 0xC8);
|
|
|
|
break;
|
2019-05-26 16:10:00 +03:00
|
|
|
case ColorID::Threeddarkshadow:
|
2015-09-25 01:59:00 +03:00
|
|
|
result = NS_RGB(0x69, 0x69, 0x69);
|
|
|
|
break;
|
2019-05-26 16:10:00 +03:00
|
|
|
case ColorID::Threedface:
|
2015-09-25 01:59:00 +03:00
|
|
|
result = NS_RGB(0xF0, 0xF0, 0xF0);
|
|
|
|
break;
|
2019-05-26 16:10:00 +03:00
|
|
|
case ColorID::Threedhighlight:
|
2015-09-25 01:59:00 +03:00
|
|
|
result = NS_RGB(0xFF, 0xFF, 0xFF);
|
|
|
|
break;
|
2019-05-26 16:10:00 +03:00
|
|
|
case ColorID::Threedlightshadow:
|
2015-09-25 01:59:00 +03:00
|
|
|
result = NS_RGB(0xE3, 0xE3, 0xE3);
|
|
|
|
break;
|
2019-05-26 16:10:00 +03:00
|
|
|
case ColorID::Threedshadow:
|
2015-09-25 01:59:00 +03:00
|
|
|
result = NS_RGB(0xA0, 0xA0, 0xA0);
|
|
|
|
break;
|
2019-05-26 16:10:00 +03:00
|
|
|
case ColorID::Window:
|
2015-09-25 01:59:00 +03:00
|
|
|
result = NS_RGB(0xFF, 0xFF, 0xFF);
|
|
|
|
break;
|
2019-05-26 16:10:00 +03:00
|
|
|
case ColorID::Windowframe:
|
2015-09-25 01:59:00 +03:00
|
|
|
result = NS_RGB(0x64, 0x64, 0x64);
|
|
|
|
break;
|
2019-05-26 16:10:00 +03:00
|
|
|
case ColorID::Windowtext:
|
2015-09-25 01:59:00 +03:00
|
|
|
result = NS_RGB(0x00, 0x00, 0x00);
|
|
|
|
break;
|
2019-05-26 16:10:00 +03:00
|
|
|
case ColorID::MozButtondefault:
|
2015-09-25 01:59:00 +03:00
|
|
|
result = NS_RGB(0x69, 0x69, 0x69);
|
|
|
|
break;
|
2019-11-03 00:28:49 +03:00
|
|
|
case ColorID::Field:
|
2015-09-25 01:59:00 +03:00
|
|
|
result = NS_RGB(0xFF, 0xFF, 0xFF);
|
|
|
|
break;
|
2019-11-03 00:28:49 +03:00
|
|
|
case ColorID::Fieldtext:
|
2015-09-25 01:59:00 +03:00
|
|
|
result = NS_RGB(0x00, 0x00, 0x00);
|
|
|
|
break;
|
2019-05-26 16:10:00 +03:00
|
|
|
case ColorID::MozDialog:
|
2015-09-25 01:59:00 +03:00
|
|
|
result = NS_RGB(0xF0, 0xF0, 0xF0);
|
|
|
|
break;
|
2019-05-26 16:10:00 +03:00
|
|
|
case ColorID::MozDialogtext:
|
2020-06-03 23:52:55 +03:00
|
|
|
case ColorID::MozColheadertext:
|
|
|
|
case ColorID::MozColheaderhovertext:
|
2015-09-25 01:59:00 +03:00
|
|
|
result = NS_RGB(0x00, 0x00, 0x00);
|
|
|
|
break;
|
2019-05-26 16:10:00 +03:00
|
|
|
case ColorID::MozDragtargetzone:
|
2015-09-25 01:59:00 +03:00
|
|
|
result = NS_RGB(0xFF, 0xFF, 0xFF);
|
|
|
|
break;
|
2019-05-26 16:10:00 +03:00
|
|
|
case ColorID::MozCellhighlight:
|
2015-09-25 01:59:00 +03:00
|
|
|
result = NS_RGB(0xF0, 0xF0, 0xF0);
|
|
|
|
break;
|
2019-05-26 16:10:00 +03:00
|
|
|
case ColorID::MozCellhighlighttext:
|
2015-09-25 01:59:00 +03:00
|
|
|
result = NS_RGB(0x00, 0x00, 0x00);
|
|
|
|
break;
|
2019-05-26 16:10:00 +03:00
|
|
|
case ColorID::MozHtmlCellhighlight:
|
2015-09-25 01:59:00 +03:00
|
|
|
result = NS_RGB(0x33, 0x99, 0xFF);
|
|
|
|
break;
|
2019-05-26 16:10:00 +03:00
|
|
|
case ColorID::MozHtmlCellhighlighttext:
|
2015-09-25 01:59:00 +03:00
|
|
|
result = NS_RGB(0xFF, 0xFF, 0xFF);
|
|
|
|
break;
|
2019-05-26 16:10:00 +03:00
|
|
|
case ColorID::MozButtonhoverface:
|
2015-09-25 01:59:00 +03:00
|
|
|
result = NS_RGB(0xF0, 0xF0, 0xF0);
|
|
|
|
break;
|
2019-05-26 16:10:00 +03:00
|
|
|
case ColorID::MozButtonhovertext:
|
2015-09-25 01:59:00 +03:00
|
|
|
result = NS_RGB(0x00, 0x00, 0x00);
|
|
|
|
break;
|
2019-05-26 16:10:00 +03:00
|
|
|
case ColorID::MozMenuhover:
|
2015-09-25 01:59:00 +03:00
|
|
|
result = NS_RGB(0x33, 0x99, 0xFF);
|
|
|
|
break;
|
2019-05-26 16:10:00 +03:00
|
|
|
case ColorID::MozMenuhovertext:
|
2015-09-25 01:59:00 +03:00
|
|
|
result = NS_RGB(0x00, 0x00, 0x00);
|
|
|
|
break;
|
2019-05-26 16:10:00 +03:00
|
|
|
case ColorID::MozMenubartext:
|
2015-09-25 01:59:00 +03:00
|
|
|
result = NS_RGB(0x00, 0x00, 0x00);
|
|
|
|
break;
|
2019-05-26 16:10:00 +03:00
|
|
|
case ColorID::MozMenubarhovertext:
|
2015-09-25 01:59:00 +03:00
|
|
|
result = NS_RGB(0x00, 0x00, 0x00);
|
|
|
|
break;
|
2019-05-26 16:10:00 +03:00
|
|
|
case ColorID::MozOddtreerow:
|
|
|
|
case ColorID::MozGtkButtonactivetext:
|
2015-09-25 01:59:00 +03:00
|
|
|
result = NS_RGB(0xFF, 0xFF, 0xFF);
|
|
|
|
break;
|
2019-05-26 16:10:00 +03:00
|
|
|
case ColorID::MozMacChromeActive:
|
2015-09-25 01:59:00 +03:00
|
|
|
result = NS_RGB(0xB2, 0xB2, 0xB2);
|
|
|
|
break;
|
2019-05-26 16:10:00 +03:00
|
|
|
case ColorID::MozMacChromeInactive:
|
2015-09-25 01:59:00 +03:00
|
|
|
result = NS_RGB(0xE1, 0xE1, 0xE1);
|
|
|
|
break;
|
2019-05-26 16:10:00 +03:00
|
|
|
case ColorID::MozMacFocusring:
|
2015-09-25 01:59:00 +03:00
|
|
|
result = NS_RGB(0x60, 0x9D, 0xD7);
|
|
|
|
break;
|
2019-05-26 16:10:00 +03:00
|
|
|
case ColorID::MozMacMenuselect:
|
2015-09-25 01:59:00 +03:00
|
|
|
result = NS_RGB(0x38, 0x75, 0xD7);
|
|
|
|
break;
|
2019-05-26 16:10:00 +03:00
|
|
|
case ColorID::MozMacMenushadow:
|
2015-09-25 01:59:00 +03:00
|
|
|
result = NS_RGB(0xA3, 0xA3, 0xA3);
|
|
|
|
break;
|
2019-05-26 16:10:00 +03:00
|
|
|
case ColorID::MozMacMenutextdisable:
|
2015-09-25 01:59:00 +03:00
|
|
|
result = NS_RGB(0x88, 0x88, 0x88);
|
|
|
|
break;
|
2019-05-26 16:10:00 +03:00
|
|
|
case ColorID::MozMacMenutextselect:
|
2015-09-25 01:59:00 +03:00
|
|
|
result = NS_RGB(0xFF, 0xFF, 0xFF);
|
|
|
|
break;
|
2019-05-26 16:10:00 +03:00
|
|
|
case ColorID::MozMacDisabledtoolbartext:
|
2015-09-25 01:59:00 +03:00
|
|
|
result = NS_RGB(0x3F, 0x3F, 0x3F);
|
|
|
|
break;
|
2019-05-26 16:10:00 +03:00
|
|
|
case ColorID::MozMacSecondaryhighlight:
|
2015-09-25 01:59:00 +03:00
|
|
|
result = NS_RGB(0xD4, 0xD4, 0xD4);
|
|
|
|
break;
|
2019-05-26 16:10:00 +03:00
|
|
|
case ColorID::MozMacVibrancyLight:
|
|
|
|
case ColorID::MozMacVibrantTitlebarLight:
|
2017-09-13 14:48:07 +03:00
|
|
|
result = NS_RGB(0xf7, 0xf7, 0xf7);
|
|
|
|
break;
|
2019-05-26 16:10:00 +03:00
|
|
|
case ColorID::MozMacVibrancyDark:
|
|
|
|
case ColorID::MozMacVibrantTitlebarDark:
|
2017-09-13 14:48:07 +03:00
|
|
|
result = NS_RGB(0x28, 0x28, 0x28);
|
|
|
|
break;
|
2019-05-26 16:10:00 +03:00
|
|
|
case ColorID::MozMacMenupopup:
|
2017-09-13 14:48:07 +03:00
|
|
|
result = NS_RGB(0xe6, 0xe6, 0xe6);
|
|
|
|
break;
|
2019-05-26 16:10:00 +03:00
|
|
|
case ColorID::MozMacMenuitem:
|
2017-09-13 14:48:07 +03:00
|
|
|
result = NS_RGB(0xe6, 0xe6, 0xe6);
|
|
|
|
break;
|
2019-05-26 16:10:00 +03:00
|
|
|
case ColorID::MozMacActiveMenuitem:
|
2017-09-13 14:48:07 +03:00
|
|
|
result = NS_RGB(0x0a, 0x64, 0xdc);
|
|
|
|
break;
|
2019-05-26 16:10:00 +03:00
|
|
|
case ColorID::MozMacSourceList:
|
2017-09-13 14:48:07 +03:00
|
|
|
result = NS_RGB(0xf7, 0xf7, 0xf7);
|
|
|
|
break;
|
2019-05-26 16:10:00 +03:00
|
|
|
case ColorID::MozMacSourceListSelection:
|
2017-09-13 14:48:07 +03:00
|
|
|
result = NS_RGB(0xc8, 0xc8, 0xc8);
|
|
|
|
break;
|
2019-05-26 16:10:00 +03:00
|
|
|
case ColorID::MozMacActiveSourceListSelection:
|
2017-09-13 14:48:07 +03:00
|
|
|
result = NS_RGB(0x0a, 0x64, 0xdc);
|
|
|
|
break;
|
2019-05-26 16:10:00 +03:00
|
|
|
case ColorID::MozMacTooltip:
|
2017-09-13 14:48:07 +03:00
|
|
|
result = NS_RGB(0xf7, 0xf7, 0xf7);
|
|
|
|
break;
|
2019-05-26 16:10:00 +03:00
|
|
|
case ColorID::MozWinAccentcolor:
|
2017-06-30 04:51:56 +03:00
|
|
|
// Seems to be the default color (hardcoded because of bug 1065998)
|
|
|
|
result = NS_RGB(0x9E, 0x9E, 0x9E);
|
|
|
|
break;
|
2019-05-26 16:10:00 +03:00
|
|
|
case ColorID::MozWinAccentcolortext:
|
2017-06-30 04:54:07 +03:00
|
|
|
result = NS_RGB(0x00, 0x00, 0x00);
|
|
|
|
break;
|
2019-05-26 16:10:00 +03:00
|
|
|
case ColorID::MozWinMediatext:
|
2015-09-25 01:59:00 +03:00
|
|
|
result = NS_RGB(0xFF, 0xFF, 0xFF);
|
|
|
|
break;
|
2019-05-26 16:10:00 +03:00
|
|
|
case ColorID::MozWinCommunicationstext:
|
2015-09-25 01:59:00 +03:00
|
|
|
result = NS_RGB(0xFF, 0xFF, 0xFF);
|
|
|
|
break;
|
2019-05-26 16:10:00 +03:00
|
|
|
case ColorID::MozNativehyperlinktext:
|
2015-09-25 01:59:00 +03:00
|
|
|
result = NS_RGB(0x00, 0x66, 0xCC);
|
|
|
|
break;
|
2019-05-26 16:10:00 +03:00
|
|
|
case ColorID::MozComboboxtext:
|
2015-09-25 01:59:00 +03:00
|
|
|
result = NS_RGB(0x00, 0x00, 0x00);
|
|
|
|
break;
|
2019-05-26 16:10:00 +03:00
|
|
|
case ColorID::MozCombobox:
|
2015-09-25 01:59:00 +03:00
|
|
|
result = NS_RGB(0xFF, 0xFF, 0xFF);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
2000-03-31 02:32:18 +04:00
|
|
|
//
|
|
|
|
// All these routines will return NS_OK if they have a value,
|
|
|
|
// in which case the nsLookAndFeel should use that value;
|
|
|
|
// otherwise we'll return NS_ERROR_NOT_AVAILABLE, in which case, the
|
|
|
|
// platform-specific nsLookAndFeel should use its own values instead.
|
|
|
|
//
|
2015-09-25 01:59:00 +03:00
|
|
|
nsresult nsXPLookAndFeel::GetColorImpl(ColorID aID,
|
|
|
|
bool aUseStandinsForNativeColors,
|
|
|
|
nscolor& aResult) {
|
2000-04-12 02:34:55 +04:00
|
|
|
if (!sInitialized) Init();
|
2018-11-30 13:46:48 +03:00
|
|
|
|
2001-04-17 04:46:07 +04:00
|
|
|
// define DEBUG_SYSTEM_COLOR_USE if you want to debug system color
|
|
|
|
// use in a skin that uses them. When set, it will make all system
|
|
|
|
// color pairs that are appropriate for foreground/background
|
|
|
|
// pairing the same. This means if the skin is using system colors
|
|
|
|
// correctly you will not be able to see *any* text.
|
|
|
|
#undef DEBUG_SYSTEM_COLOR_USE
|
|
|
|
|
|
|
|
#ifdef DEBUG_SYSTEM_COLOR_USE
|
|
|
|
{
|
|
|
|
nsresult rv = NS_OK;
|
|
|
|
switch (aID) {
|
|
|
|
// css2 http://www.w3.org/TR/REC-CSS2/ui.html#system-colors
|
2019-05-26 16:10:00 +03:00
|
|
|
case ColorID::Activecaption:
|
2001-04-17 04:46:07 +04:00
|
|
|
// active window caption background
|
2019-05-26 16:10:00 +03:00
|
|
|
case ColorID::Captiontext:
|
2001-04-17 04:46:07 +04:00
|
|
|
// text in active window caption
|
2011-09-09 06:27:13 +04:00
|
|
|
aResult = NS_RGB(0xff, 0x00, 0x00);
|
2001-04-17 04:46:07 +04:00
|
|
|
break;
|
|
|
|
|
2019-05-26 16:10:00 +03:00
|
|
|
case ColorID::Highlight:
|
2001-04-17 04:46:07 +04:00
|
|
|
// background of selected item
|
2019-05-26 16:10:00 +03:00
|
|
|
case ColorID::Highlighttext:
|
2001-04-17 04:46:07 +04:00
|
|
|
// text of selected item
|
2011-09-09 06:27:13 +04:00
|
|
|
aResult = NS_RGB(0xff, 0xff, 0x00);
|
2001-04-17 04:46:07 +04:00
|
|
|
break;
|
|
|
|
|
2019-05-26 16:10:00 +03:00
|
|
|
case ColorID::Inactivecaption:
|
2001-04-17 04:46:07 +04:00
|
|
|
// inactive window caption
|
2019-05-26 16:10:00 +03:00
|
|
|
case ColorID::Inactivecaptiontext:
|
2001-04-17 04:46:07 +04:00
|
|
|
// text in inactive window caption
|
2011-09-09 06:27:13 +04:00
|
|
|
aResult = NS_RGB(0x66, 0x66, 0x00);
|
2001-04-17 04:46:07 +04:00
|
|
|
break;
|
|
|
|
|
2019-05-26 16:10:00 +03:00
|
|
|
case ColorID::Infobackground:
|
2001-04-17 04:46:07 +04:00
|
|
|
// tooltip background color
|
2019-05-26 16:10:00 +03:00
|
|
|
case ColorID::Infotext:
|
2001-04-17 04:46:07 +04:00
|
|
|
// tooltip text color
|
2011-09-09 06:27:13 +04:00
|
|
|
aResult = NS_RGB(0x00, 0xff, 0x00);
|
2001-04-17 04:46:07 +04:00
|
|
|
break;
|
|
|
|
|
2019-05-26 16:10:00 +03:00
|
|
|
case ColorID::Menu:
|
2001-04-17 04:46:07 +04:00
|
|
|
// menu background
|
2019-05-26 16:10:00 +03:00
|
|
|
case ColorID::Menutext:
|
2001-04-17 04:46:07 +04:00
|
|
|
// menu text
|
2011-09-09 06:27:13 +04:00
|
|
|
aResult = NS_RGB(0x00, 0xff, 0xff);
|
2001-04-17 04:46:07 +04:00
|
|
|
break;
|
|
|
|
|
2019-05-26 16:10:00 +03:00
|
|
|
case ColorID::Threedface:
|
|
|
|
case ColorID::Buttonface:
|
2001-04-17 04:46:07 +04:00
|
|
|
// 3-D face color
|
2019-05-26 16:10:00 +03:00
|
|
|
case ColorID::Buttontext:
|
2001-04-17 04:46:07 +04:00
|
|
|
// text on push buttons
|
2011-09-09 06:27:13 +04:00
|
|
|
aResult = NS_RGB(0x00, 0x66, 0x66);
|
2001-04-17 04:46:07 +04:00
|
|
|
break;
|
|
|
|
|
2019-05-26 16:10:00 +03:00
|
|
|
case ColorID::Window:
|
|
|
|
case ColorID::Windowtext:
|
2011-09-09 06:27:13 +04:00
|
|
|
aResult = NS_RGB(0x00, 0x00, 0xff);
|
2001-04-17 04:46:07 +04:00
|
|
|
break;
|
|
|
|
|
|
|
|
// from the CSS3 working draft (not yet finalized)
|
|
|
|
// http://www.w3.org/tr/2000/wd-css3-userint-20000216.html#color
|
|
|
|
|
2019-11-03 00:28:49 +03:00
|
|
|
case ColorID::Field:
|
|
|
|
case ColorID::Fieldtext:
|
2011-09-09 06:27:13 +04:00
|
|
|
aResult = NS_RGB(0xff, 0x00, 0xff);
|
2001-04-17 04:46:07 +04:00
|
|
|
break;
|
|
|
|
|
2019-05-26 16:10:00 +03:00
|
|
|
case ColorID::MozDialog:
|
|
|
|
case ColorID::MozDialogtext:
|
2011-09-09 06:27:13 +04:00
|
|
|
aResult = NS_RGB(0x66, 0x00, 0x66);
|
2001-04-17 04:46:07 +04:00
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
rv = NS_ERROR_NOT_AVAILABLE;
|
|
|
|
}
|
|
|
|
if (NS_SUCCEEDED(rv)) return rv;
|
|
|
|
}
|
|
|
|
#endif // DEBUG_SYSTEM_COLOR_USE
|
|
|
|
|
2015-09-25 01:59:00 +03:00
|
|
|
if (aUseStandinsForNativeColors &&
|
2019-02-06 11:45:44 +03:00
|
|
|
(ColorIsNotCSSAccessible(aID) ||
|
|
|
|
!nsContentUtils::UseStandinsForNativeColors())) {
|
2015-09-25 01:59:00 +03:00
|
|
|
aUseStandinsForNativeColors = false;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!aUseStandinsForNativeColors && IS_COLOR_CACHED(aID)) {
|
2019-05-26 16:10:00 +03:00
|
|
|
aResult = sCachedColors[uint32_t(aID)];
|
2001-11-06 05:41:04 +03:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2002-09-06 11:30:45 +04:00
|
|
|
// There are no system color settings for these, so set them manually
|
2016-11-15 22:38:22 +03:00
|
|
|
#ifndef XP_MACOSX
|
2019-05-26 16:10:00 +03:00
|
|
|
if (aID == ColorID::TextSelectBackgroundDisabled) {
|
2002-09-06 11:30:45 +04:00
|
|
|
// This is used to gray out the selection when it's not focused
|
|
|
|
// Used with nsISelectionController::SELECTION_DISABLED
|
2011-09-09 06:27:13 +04:00
|
|
|
aResult = NS_RGB(0xb0, 0xb0, 0xb0);
|
2002-09-06 11:30:45 +04:00
|
|
|
return NS_OK;
|
|
|
|
}
|
2016-11-15 22:38:22 +03:00
|
|
|
#endif
|
2002-09-06 11:30:45 +04:00
|
|
|
|
2019-05-26 16:10:00 +03:00
|
|
|
if (aID == ColorID::TextSelectBackgroundAttention) {
|
2020-06-09 02:00:21 +03:00
|
|
|
if (StaticPrefs::findbar_modalHighlight() && !mozilla::FissionAutostart()) {
|
2016-06-09 14:30:44 +03:00
|
|
|
aResult = NS_RGBA(0, 0, 0, 0);
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2002-09-06 11:30:45 +04:00
|
|
|
// This makes the selection stand out when typeaheadfind is on
|
|
|
|
// Used with nsISelectionController::SELECTION_ATTENTION
|
2011-09-09 06:27:13 +04:00
|
|
|
aResult = NS_RGB(0x38, 0xd8, 0x78);
|
2002-09-06 11:30:45 +04:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2019-05-26 16:10:00 +03:00
|
|
|
if (aID == ColorID::TextHighlightBackground) {
|
2008-07-31 00:48:56 +04:00
|
|
|
// This makes the matched text stand out when findbar highlighting is on
|
|
|
|
// Used with nsISelectionController::SELECTION_FIND
|
2011-09-09 06:27:13 +04:00
|
|
|
aResult = NS_RGB(0xef, 0x0f, 0xff);
|
2008-07-31 00:48:56 +04:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2019-05-26 16:10:00 +03:00
|
|
|
if (aID == ColorID::TextHighlightForeground) {
|
2008-09-02 10:28:44 +04:00
|
|
|
// The foreground color for the matched text in findbar highlighting
|
|
|
|
// Used with nsISelectionController::SELECTION_FIND
|
2011-09-09 06:27:13 +04:00
|
|
|
aResult = NS_RGB(0xff, 0xff, 0xff);
|
2008-09-02 10:28:44 +04:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2019-08-27 03:07:34 +03:00
|
|
|
if (StaticPrefs::ui_use_native_colors() && aUseStandinsForNativeColors) {
|
2015-09-25 01:59:00 +03:00
|
|
|
aResult = GetStandinForNativeColor(aID);
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2019-08-27 03:07:34 +03:00
|
|
|
if (StaticPrefs::ui_use_native_colors() &&
|
|
|
|
NS_SUCCEEDED(NativeGetColor(aID, aResult))) {
|
2017-03-23 05:52:53 +03:00
|
|
|
if (!mozilla::ServoStyleSet::IsInServoTraversal()) {
|
|
|
|
MOZ_ASSERT(NS_IsMainThread());
|
2017-05-05 09:22:51 +03:00
|
|
|
if ((gfxPlatform::GetCMSMode() == eCMSMode_All) &&
|
|
|
|
!IsSpecialColor(aID, aResult)) {
|
|
|
|
qcms_transform* transform = gfxPlatform::GetCMSInverseRGBTransform();
|
|
|
|
if (transform) {
|
2019-09-01 17:16:07 +03:00
|
|
|
uint8_t color[4];
|
2017-05-05 09:22:51 +03:00
|
|
|
color[0] = NS_GET_R(aResult);
|
|
|
|
color[1] = NS_GET_G(aResult);
|
|
|
|
color[2] = NS_GET_B(aResult);
|
2019-09-01 17:16:07 +03:00
|
|
|
color[3] = NS_GET_A(aResult);
|
2017-05-05 09:22:51 +03:00
|
|
|
qcms_transform_data(transform, color, color, 1);
|
2019-09-01 17:16:07 +03:00
|
|
|
aResult = NS_RGBA(color[0], color[1], color[2], color[3]);
|
2017-05-05 09:22:51 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-03-23 05:52:53 +03:00
|
|
|
CACHE_COLOR(aID, aResult);
|
|
|
|
}
|
2001-11-06 05:41:04 +03:00
|
|
|
return NS_OK;
|
|
|
|
}
|
2000-04-12 02:34:55 +04:00
|
|
|
|
2000-03-31 02:32:18 +04:00
|
|
|
return NS_ERROR_NOT_AVAILABLE;
|
|
|
|
}
|
2016-07-20 18:29:36 +03:00
|
|
|
|
2012-08-22 19:56:38 +04:00
|
|
|
nsresult nsXPLookAndFeel::GetIntImpl(IntID aID, int32_t& aResult) {
|
2000-03-31 02:32:18 +04:00
|
|
|
if (!sInitialized) Init();
|
|
|
|
|
2006-07-20 02:13:18 +04:00
|
|
|
// Set the default values for these prefs. but allow different platforms
|
|
|
|
// to override them in their nsLookAndFeel if desired.
|
|
|
|
switch (aID) {
|
2020-06-11 14:27:43 +03:00
|
|
|
case IntID::ScrollButtonLeftMouseButtonAction:
|
2011-09-09 06:27:13 +04:00
|
|
|
aResult = 0;
|
2006-07-20 02:13:18 +04:00
|
|
|
return NS_OK;
|
2020-06-11 14:27:43 +03:00
|
|
|
case IntID::ScrollButtonMiddleMouseButtonAction:
|
2011-09-09 06:27:13 +04:00
|
|
|
aResult = 3;
|
2006-07-20 02:13:18 +04:00
|
|
|
return NS_OK;
|
2020-06-11 14:27:43 +03:00
|
|
|
case IntID::ScrollButtonRightMouseButtonAction:
|
2011-09-09 06:27:13 +04:00
|
|
|
aResult = 3;
|
2006-07-20 02:13:18 +04:00
|
|
|
return NS_OK;
|
2008-09-16 15:32:03 +04:00
|
|
|
default:
|
|
|
|
/*
|
|
|
|
* The metrics above are hardcoded platform defaults. All the other
|
|
|
|
* metrics are stored in sIntPrefs and can be changed at runtime.
|
|
|
|
*/
|
|
|
|
break;
|
2006-07-20 02:13:18 +04:00
|
|
|
}
|
|
|
|
|
2011-10-11 09:50:08 +04:00
|
|
|
for (unsigned int i = 0; i < ArrayLength(sIntPrefs); ++i) {
|
2011-05-23 18:54:03 +04:00
|
|
|
if (sIntPrefs[i].isSet && (sIntPrefs[i].id == aID)) {
|
2011-09-09 06:27:13 +04:00
|
|
|
aResult = sIntPrefs[i].intVar;
|
2000-03-31 02:32:18 +04:00
|
|
|
return NS_OK;
|
|
|
|
}
|
2011-05-23 18:54:03 +04:00
|
|
|
}
|
2000-03-31 02:32:18 +04:00
|
|
|
|
|
|
|
return NS_ERROR_NOT_AVAILABLE;
|
|
|
|
}
|
|
|
|
|
2011-09-09 06:27:13 +04:00
|
|
|
nsresult nsXPLookAndFeel::GetFloatImpl(FloatID aID, float& aResult) {
|
2000-03-31 02:32:18 +04:00
|
|
|
if (!sInitialized) Init();
|
|
|
|
|
2011-10-11 09:50:08 +04:00
|
|
|
for (unsigned int i = 0; i < ArrayLength(sFloatPrefs); ++i) {
|
2011-05-23 18:54:03 +04:00
|
|
|
if (sFloatPrefs[i].isSet && sFloatPrefs[i].id == aID) {
|
2011-09-09 06:27:13 +04:00
|
|
|
aResult = sFloatPrefs[i].floatVar;
|
2000-03-31 02:32:18 +04:00
|
|
|
return NS_OK;
|
|
|
|
}
|
2011-05-23 18:54:03 +04:00
|
|
|
}
|
2000-03-31 02:32:18 +04:00
|
|
|
|
|
|
|
return NS_ERROR_NOT_AVAILABLE;
|
|
|
|
}
|
|
|
|
|
2011-09-09 06:27:13 +04:00
|
|
|
void nsXPLookAndFeel::RefreshImpl() {
|
2001-12-18 01:51:39 +03:00
|
|
|
// Wipe out our color cache.
|
2012-08-22 19:56:38 +04:00
|
|
|
uint32_t i;
|
2019-09-19 22:05:01 +03:00
|
|
|
for (i = 0; i < uint32_t(ColorID::End); i++) {
|
|
|
|
sCachedColors[i] = 0;
|
|
|
|
}
|
|
|
|
for (i = 0; i < COLOR_CACHE_SIZE; i++) {
|
|
|
|
sCachedColorBits[i] = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Reinit color cache from prefs.
|
|
|
|
for (i = 0; i < uint32_t(ColorID::End); ++i) {
|
|
|
|
InitColorFromPref(i);
|
|
|
|
}
|
2001-12-18 01:51:39 +03:00
|
|
|
}
|
|
|
|
|
2020-07-31 19:21:44 +03:00
|
|
|
LookAndFeelCache nsXPLookAndFeel::GetCacheImpl() { return LookAndFeelCache{}; }
|
2015-04-22 17:58:15 +03:00
|
|
|
|
2019-12-20 22:05:12 +03:00
|
|
|
static bool sRecordedLookAndFeelTelemetry = false;
|
|
|
|
|
|
|
|
void nsXPLookAndFeel::RecordTelemetry() {
|
|
|
|
if (sRecordedLookAndFeelTelemetry) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
sRecordedLookAndFeelTelemetry = true;
|
|
|
|
|
|
|
|
int32_t i;
|
|
|
|
Telemetry::ScalarSet(
|
|
|
|
Telemetry::ScalarID::WIDGET_DARK_MODE,
|
2020-06-11 14:27:43 +03:00
|
|
|
NS_SUCCEEDED(GetIntImpl(IntID::SystemUsesDarkTheme, i)) && i != 0);
|
2019-12-20 22:05:12 +03:00
|
|
|
}
|
|
|
|
|
2011-09-09 06:27:11 +04:00
|
|
|
namespace mozilla {
|
|
|
|
|
2020-05-23 02:03:43 +03:00
|
|
|
// static
|
|
|
|
void LookAndFeel::NotifyChangedAllWindows() {
|
|
|
|
if (nsCOMPtr<nsIObserverService> obs = services::GetObserverService()) {
|
|
|
|
obs->NotifyObservers(nullptr, "look-and-feel-changed", nullptr);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-09-09 06:27:11 +04:00
|
|
|
// static
|
|
|
|
nsresult LookAndFeel::GetColor(ColorID aID, nscolor* aResult) {
|
2015-09-25 01:59:00 +03:00
|
|
|
return nsLookAndFeel::GetInstance()->GetColorImpl(aID, false, *aResult);
|
|
|
|
}
|
|
|
|
|
|
|
|
nsresult LookAndFeel::GetColor(ColorID aID, bool aUseStandinsForNativeColors,
|
|
|
|
nscolor* aResult) {
|
|
|
|
return nsLookAndFeel::GetInstance()->GetColorImpl(
|
|
|
|
aID, aUseStandinsForNativeColors, *aResult);
|
2011-09-09 06:27:11 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
// static
|
2012-08-22 19:56:38 +04:00
|
|
|
nsresult LookAndFeel::GetInt(IntID aID, int32_t* aResult) {
|
2011-09-09 06:27:13 +04:00
|
|
|
return nsLookAndFeel::GetInstance()->GetIntImpl(aID, *aResult);
|
2011-09-09 06:27:11 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
// static
|
|
|
|
nsresult LookAndFeel::GetFloat(FloatID aID, float* aResult) {
|
2011-09-09 06:27:13 +04:00
|
|
|
return nsLookAndFeel::GetInstance()->GetFloatImpl(aID, *aResult);
|
2011-09-09 06:27:11 +04:00
|
|
|
}
|
|
|
|
|
2012-02-21 03:19:48 +04:00
|
|
|
// static
|
2019-02-08 16:22:11 +03:00
|
|
|
bool LookAndFeel::GetFont(FontID aID, nsString& aName, gfxFontStyle& aStyle) {
|
|
|
|
return nsLookAndFeel::GetInstance()->GetFontImpl(aID, aName, aStyle);
|
2012-02-21 03:19:48 +04:00
|
|
|
}
|
|
|
|
|
2011-09-09 06:27:11 +04:00
|
|
|
// static
|
|
|
|
char16_t LookAndFeel::GetPasswordCharacter() {
|
2011-09-09 06:27:13 +04:00
|
|
|
return nsLookAndFeel::GetInstance()->GetPasswordCharacterImpl();
|
2011-09-09 06:27:11 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
// static
|
|
|
|
bool LookAndFeel::GetEchoPassword() {
|
2019-07-22 06:55:13 +03:00
|
|
|
if (StaticPrefs::editor_password_mask_delay() >= 0) {
|
|
|
|
return StaticPrefs::editor_password_mask_delay() > 0;
|
|
|
|
}
|
2011-09-09 06:27:13 +04:00
|
|
|
return nsLookAndFeel::GetInstance()->GetEchoPasswordImpl();
|
2011-09-09 06:27:11 +04:00
|
|
|
}
|
|
|
|
|
2012-07-13 06:26:20 +04:00
|
|
|
// static
|
|
|
|
uint32_t LookAndFeel::GetPasswordMaskDelay() {
|
2019-07-22 06:55:13 +03:00
|
|
|
int32_t delay = StaticPrefs::editor_password_mask_delay();
|
|
|
|
if (delay < 0) {
|
|
|
|
return nsLookAndFeel::GetInstance()->GetPasswordMaskDelayImpl();
|
|
|
|
}
|
|
|
|
return delay;
|
2012-07-13 06:26:20 +04:00
|
|
|
}
|
|
|
|
|
2011-09-09 06:27:11 +04:00
|
|
|
// static
|
2011-09-09 06:27:13 +04:00
|
|
|
void LookAndFeel::Refresh() { nsLookAndFeel::GetInstance()->RefreshImpl(); }
|
2011-09-09 06:27:11 +04:00
|
|
|
|
2017-08-03 23:16:31 +03:00
|
|
|
// static
|
|
|
|
void LookAndFeel::NativeInit() { nsLookAndFeel::GetInstance()->NativeInit(); }
|
|
|
|
|
2015-04-22 17:58:15 +03:00
|
|
|
// static
|
2020-07-31 19:21:44 +03:00
|
|
|
LookAndFeelCache LookAndFeel::GetCache() {
|
|
|
|
return nsLookAndFeel::GetInstance()->GetCacheImpl();
|
2015-04-22 17:58:15 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
// static
|
2020-07-31 19:21:44 +03:00
|
|
|
void LookAndFeel::SetCache(const LookAndFeelCache& aCache) {
|
|
|
|
nsLookAndFeel::GetInstance()->SetCacheImpl(aCache);
|
2015-04-22 17:58:15 +03:00
|
|
|
}
|
|
|
|
|
2020-07-31 19:21:44 +03:00
|
|
|
} // namespace mozilla
|