2001-09-28 20:14:13 +00:00
|
|
|
/* -*- mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
2012-05-21 11:12:37 +00: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-30 22:32:18 +00:00
|
|
|
|
2013-12-09 02:52:54 +00:00
|
|
|
#include "mozilla/ArrayUtils.h"
|
2011-10-11 05:50:08 +00:00
|
|
|
|
2001-11-06 08:23:51 +00:00
|
|
|
#include "nscore.h"
|
|
|
|
|
2000-03-30 22:32:18 +00:00
|
|
|
#include "nsXPLookAndFeel.h"
|
2011-09-09 02:27:11 +00:00
|
|
|
#include "nsLookAndFeel.h"
|
2002-05-15 18:55:21 +00:00
|
|
|
#include "nsCRT.h"
|
2004-10-25 19:34:45 +00:00
|
|
|
#include "nsFont.h"
|
2015-05-07 17:32:01 +00:00
|
|
|
#include "mozilla/dom/ContentChild.h"
|
2011-05-23 14:54:03 +00:00
|
|
|
#include "mozilla/Preferences.h"
|
2013-10-07 23:15:59 +00:00
|
|
|
#include "mozilla/gfx/2D.h"
|
2015-04-22 14:58:15 +00:00
|
|
|
#include "mozilla/widget/WidgetMessageUtils.h"
|
2001-11-06 02:41:04 +00:00
|
|
|
|
2013-09-07 03:08:36 +00:00
|
|
|
#include "gfxPlatform.h"
|
2009-04-07 16:02:11 +00:00
|
|
|
#include "qcms.h"
|
2007-08-30 16:21:16 +00:00
|
|
|
|
2002-01-24 01:18:36 +00:00
|
|
|
#ifdef DEBUG
|
2001-11-06 02:41:04 +00:00
|
|
|
#include "nsSize.h"
|
|
|
|
#endif
|
2009-02-10 19:25:00 +00:00
|
|
|
|
2011-05-23 14:54:03 +00:00
|
|
|
using namespace mozilla;
|
|
|
|
|
2000-03-30 22:32:18 +00:00
|
|
|
nsLookAndFeelIntPref nsXPLookAndFeel::sIntPrefs[] =
|
|
|
|
{
|
2011-09-09 02:27:13 +00:00
|
|
|
{ "ui.caretBlinkTime",
|
|
|
|
eIntID_CaretBlinkTime,
|
2011-10-17 14:59:28 +00:00
|
|
|
false, 0 },
|
2011-09-09 02:27:13 +00:00
|
|
|
{ "ui.caretWidth",
|
|
|
|
eIntID_CaretWidth,
|
2011-10-17 14:59:28 +00:00
|
|
|
false, 0 },
|
2011-09-09 02:27:13 +00:00
|
|
|
{ "ui.caretVisibleWithSelection",
|
|
|
|
eIntID_ShowCaretDuringSelection,
|
2011-10-17 14:59:28 +00:00
|
|
|
false, 0 },
|
2011-09-09 02:27:13 +00:00
|
|
|
{ "ui.submenuDelay",
|
|
|
|
eIntID_SubmenuDelay,
|
2011-10-17 14:59:28 +00:00
|
|
|
false, 0 },
|
2011-09-09 02:27:13 +00:00
|
|
|
{ "ui.dragThresholdX",
|
|
|
|
eIntID_DragThresholdX,
|
2011-10-17 14:59:28 +00:00
|
|
|
false, 0 },
|
2011-09-09 02:27:13 +00:00
|
|
|
{ "ui.dragThresholdY",
|
|
|
|
eIntID_DragThresholdY,
|
2011-10-17 14:59:28 +00:00
|
|
|
false, 0 },
|
2011-09-09 02:27:13 +00:00
|
|
|
{ "ui.useAccessibilityTheme",
|
|
|
|
eIntID_UseAccessibilityTheme,
|
2011-10-17 14:59:28 +00:00
|
|
|
false, 0 },
|
2011-09-09 02:27:13 +00:00
|
|
|
{ "ui.menusCanOverlapOSBar",
|
|
|
|
eIntID_MenusCanOverlapOSBar,
|
2011-10-17 14:59:28 +00:00
|
|
|
false, 0 },
|
2013-05-02 14:58:00 +00:00
|
|
|
{ "ui.useOverlayScrollbars",
|
|
|
|
eIntID_UseOverlayScrollbars,
|
|
|
|
false, 0 },
|
2013-07-02 10:02:21 +00:00
|
|
|
{ "ui.scrollbarDisplayOnMouseMove",
|
|
|
|
eIntID_ScrollbarDisplayOnMouseMove,
|
|
|
|
false, 0 },
|
|
|
|
{ "ui.scrollbarFadeBeginDelay",
|
|
|
|
eIntID_ScrollbarFadeBeginDelay,
|
|
|
|
false, 0 },
|
|
|
|
{ "ui.scrollbarFadeDuration",
|
|
|
|
eIntID_ScrollbarFadeDuration,
|
|
|
|
false, 0 },
|
2012-08-03 10:35:14 +00:00
|
|
|
{ "ui.showHideScrollbars",
|
|
|
|
eIntID_ShowHideScrollbars,
|
|
|
|
false, 0 },
|
2011-09-09 02:27:13 +00:00
|
|
|
{ "ui.skipNavigatingDisabledMenuItem",
|
|
|
|
eIntID_SkipNavigatingDisabledMenuItem,
|
2011-10-17 14:59:28 +00:00
|
|
|
false, 0 },
|
2003-03-16 23:26:31 +00:00
|
|
|
{ "ui.treeOpenDelay",
|
2011-09-09 02:27:13 +00:00
|
|
|
eIntID_TreeOpenDelay,
|
2011-10-17 14:59:28 +00:00
|
|
|
false, 0 },
|
2003-03-16 23:26:31 +00:00
|
|
|
{ "ui.treeCloseDelay",
|
2011-09-09 02:27:13 +00:00
|
|
|
eIntID_TreeCloseDelay,
|
2011-10-17 14:59:28 +00:00
|
|
|
false, 0 },
|
2003-03-16 23:26:31 +00:00
|
|
|
{ "ui.treeLazyScrollDelay",
|
2011-09-09 02:27:13 +00:00
|
|
|
eIntID_TreeLazyScrollDelay,
|
2011-10-17 14:59:28 +00:00
|
|
|
false, 0 },
|
2003-03-16 23:26:31 +00:00
|
|
|
{ "ui.treeScrollDelay",
|
2011-09-09 02:27:13 +00:00
|
|
|
eIntID_TreeScrollDelay,
|
2011-10-17 14:59:28 +00:00
|
|
|
false, 0 },
|
2003-03-16 23:26:31 +00:00
|
|
|
{ "ui.treeScrollLinesMax",
|
2011-09-09 02:27:13 +00:00
|
|
|
eIntID_TreeScrollLinesMax,
|
2011-10-17 14:59:28 +00:00
|
|
|
false, 0 },
|
2005-01-06 23:41:52 +00:00
|
|
|
{ "accessibility.tabfocus",
|
2011-09-09 02:27:13 +00:00
|
|
|
eIntID_TabFocusModel,
|
2011-10-17 14:59:28 +00:00
|
|
|
false, 0 },
|
2006-07-19 19:47:19 +00:00
|
|
|
{ "ui.alertNotificationOrigin",
|
2011-09-09 02:27:13 +00:00
|
|
|
eIntID_AlertNotificationOrigin,
|
2011-10-17 14:59:28 +00:00
|
|
|
false, 0 },
|
2007-04-12 00:36:40 +00:00
|
|
|
{ "ui.scrollToClick",
|
2011-09-09 02:27:13 +00:00
|
|
|
eIntID_ScrollToClick,
|
2011-10-17 14:59:28 +00:00
|
|
|
false, 0 },
|
2007-08-16 20:35:18 +00:00
|
|
|
{ "ui.IMERawInputUnderlineStyle",
|
2011-09-09 02:27:13 +00:00
|
|
|
eIntID_IMERawInputUnderlineStyle,
|
2011-10-17 14:59:28 +00:00
|
|
|
false, 0 },
|
2007-08-16 20:35:18 +00:00
|
|
|
{ "ui.IMESelectedRawTextUnderlineStyle",
|
2011-09-09 02:27:13 +00:00
|
|
|
eIntID_IMESelectedRawTextUnderlineStyle,
|
2011-10-17 14:59:28 +00:00
|
|
|
false, 0 },
|
2007-08-16 20:35:18 +00:00
|
|
|
{ "ui.IMEConvertedTextUnderlineStyle",
|
2011-09-09 02:27:13 +00:00
|
|
|
eIntID_IMEConvertedTextUnderlineStyle,
|
2011-10-17 14:59:28 +00:00
|
|
|
false, 0 },
|
2007-08-16 20:35:18 +00:00
|
|
|
{ "ui.IMESelectedConvertedTextUnderlineStyle",
|
2011-09-09 02:27:13 +00:00
|
|
|
eIntID_IMESelectedConvertedTextUnderline,
|
2011-10-17 14:59:28 +00:00
|
|
|
false, 0 },
|
2009-04-03 07:26:28 +00:00
|
|
|
{ "ui.SpellCheckerUnderlineStyle",
|
2011-09-09 02:27:13 +00:00
|
|
|
eIntID_SpellCheckerUnderlineStyle,
|
2011-10-17 14:59:28 +00:00
|
|
|
false, 0 },
|
2011-11-17 23:41:35 +00:00
|
|
|
{ "ui.scrollbarButtonAutoRepeatBehavior",
|
|
|
|
eIntID_ScrollbarButtonAutoRepeatBehavior,
|
|
|
|
false, 0 },
|
2011-12-16 09:18:48 +00:00
|
|
|
{ "ui.tooltipDelay",
|
|
|
|
eIntID_TooltipDelay,
|
|
|
|
false, 0 },
|
2013-10-23 07:46:00 +00:00
|
|
|
{ "ui.physicalHomeButton",
|
|
|
|
eIntID_PhysicalHomeButton,
|
|
|
|
false, 0 },
|
2015-08-04 20:41:00 +00:00
|
|
|
{ "ui.contextMenuOffsetVertical",
|
|
|
|
eIntID_ContextMenuOffsetVertical,
|
|
|
|
false, 0 },
|
|
|
|
{ "ui.contextMenuOffsetHorizontal",
|
|
|
|
eIntID_ContextMenuOffsetHorizontal,
|
|
|
|
false, 0 }
|
2000-03-30 22:32:18 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
nsLookAndFeelFloatPref nsXPLookAndFeel::sFloatPrefs[] =
|
|
|
|
{
|
2011-09-09 02:27:13 +00:00
|
|
|
{ "ui.IMEUnderlineRelativeSize",
|
|
|
|
eFloatID_IMEUnderlineRelativeSize,
|
2011-10-17 14:59:28 +00:00
|
|
|
false, 0 },
|
2009-04-03 07:26:28 +00:00
|
|
|
{ "ui.SpellCheckerUnderlineRelativeSize",
|
2011-09-09 02:27:13 +00:00
|
|
|
eFloatID_SpellCheckerUnderlineRelativeSize,
|
2011-10-17 14:59:28 +00:00
|
|
|
false, 0 },
|
2011-09-09 02:27:13 +00:00
|
|
|
{ "ui.caretAspectRatio",
|
|
|
|
eFloatID_CaretAspectRatio,
|
2011-10-17 14:59:28 +00:00
|
|
|
false, 0 },
|
2000-04-11 22:34:55 +00:00
|
|
|
};
|
|
|
|
|
2001-11-06 02:41:04 +00:00
|
|
|
|
2011-09-09 02:27:12 +00:00
|
|
|
// This array MUST be kept in the same order as the color list in LookAndFeel.h.
|
2004-03-02 03:44:26 +00:00
|
|
|
/* XXX If you add any strings longer than
|
2008-01-24 09:31:44 +00:00
|
|
|
* "ui.IMESelectedConvertedTextBackground"
|
2004-03-02 03:44:26 +00:00
|
|
|
* to the following array then you MUST update the
|
|
|
|
* sizes of the sColorPrefs array in nsXPLookAndFeel.h
|
|
|
|
*/
|
2005-09-17 11:34:27 +00:00
|
|
|
const char nsXPLookAndFeel::sColorPrefs[][38] =
|
2000-04-11 22:34:55 +00:00
|
|
|
{
|
2001-11-06 02:41:04 +00: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 00:13:00 +00:00
|
|
|
"ui.textSelectForegroundCustom",
|
2002-09-06 07:30:45 +00:00
|
|
|
"ui.textSelectBackgroundDisabled",
|
|
|
|
"ui.textSelectBackgroundAttention",
|
2008-07-30 20:48:56 +00:00
|
|
|
"ui.textHighlightBackground",
|
2008-09-02 06:28:44 +00:00
|
|
|
"ui.textHighlightForeground",
|
2005-09-17 11:34:27 +00: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 07:26:28 +00:00
|
|
|
"ui.SpellCheckerUnderline",
|
2001-11-06 02:41:04 +00:00
|
|
|
"ui.activeborder",
|
|
|
|
"ui.activecaption",
|
|
|
|
"ui.appworkspace",
|
|
|
|
"ui.background",
|
|
|
|
"ui.buttonface",
|
|
|
|
"ui.buttonhighlight",
|
|
|
|
"ui.buttonshadow",
|
|
|
|
"ui.buttontext",
|
|
|
|
"ui.captiontext",
|
|
|
|
"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-18 21:16:29 +00:00
|
|
|
"ui.-moz-buttondefault",
|
2001-11-06 02:41:04 +00:00
|
|
|
"ui.-moz-field",
|
|
|
|
"ui.-moz-fieldtext",
|
|
|
|
"ui.-moz-dialog",
|
|
|
|
"ui.-moz-dialogtext",
|
|
|
|
"ui.-moz-dragtargetzone",
|
2008-04-24 08:08:33 +00:00
|
|
|
"ui.-moz-cellhighlight",
|
|
|
|
"ui.-moz_cellhighlighttext",
|
2008-01-24 09:31:44 +00:00
|
|
|
"ui.-moz-html-cellhighlight",
|
|
|
|
"ui.-moz-html-cellhighlighttext",
|
2008-04-24 08:08:33 +00:00
|
|
|
"ui.-moz-buttonhoverface",
|
|
|
|
"ui.-moz_buttonhovertext",
|
|
|
|
"ui.-moz_menuhover",
|
|
|
|
"ui.-moz_menuhovertext",
|
2009-06-14 21:58:14 +00:00
|
|
|
"ui.-moz_menubartext",
|
2008-04-24 08:08:33 +00:00
|
|
|
"ui.-moz_menubarhovertext",
|
|
|
|
"ui.-moz_eventreerow",
|
|
|
|
"ui.-moz_oddtreerow",
|
2014-09-11 23:31:15 +00:00
|
|
|
"ui.-moz-mac-buttonactivetext",
|
2009-03-31 20:02:55 +00:00
|
|
|
"ui.-moz_mac_chrome_active",
|
|
|
|
"ui.-moz_mac_chrome_inactive",
|
2014-09-11 23:31:15 +00:00
|
|
|
"ui.-moz-mac-defaultbuttontext",
|
2001-11-06 02:41:04 +00:00
|
|
|
"ui.-moz-mac-focusring",
|
|
|
|
"ui.-moz-mac-menuselect",
|
|
|
|
"ui.-moz-mac-menushadow",
|
2006-07-14 19:54:08 +00:00
|
|
|
"ui.-moz-mac-menutextdisable",
|
2001-11-06 02:41:04 +00:00
|
|
|
"ui.-moz-mac-menutextselect",
|
2009-03-31 20:02:55 +00:00
|
|
|
"ui.-moz_mac_disabledtoolbartext",
|
2008-04-29 19:27:23 +00:00
|
|
|
"ui.-moz-mac-secondaryhighlight",
|
|
|
|
"ui.-moz-win-mediatext",
|
2008-07-11 18:34:53 +00:00
|
|
|
"ui.-moz-win-communicationstext",
|
2009-01-16 08:18:49 +00:00
|
|
|
"ui.-moz-nativehyperlinktext",
|
|
|
|
"ui.-moz-comboboxtext",
|
|
|
|
"ui.-moz-combobox"
|
2000-03-30 22:32:18 +00:00
|
|
|
};
|
|
|
|
|
2012-08-22 15:56:38 +00:00
|
|
|
int32_t nsXPLookAndFeel::sCachedColors[LookAndFeel::eColorID_LAST_COLOR] = {0};
|
|
|
|
int32_t nsXPLookAndFeel::sCachedColorBits[COLOR_CACHE_SIZE] = {0};
|
2001-11-06 02:41:04 +00:00
|
|
|
|
2011-09-29 06:19:26 +00:00
|
|
|
bool nsXPLookAndFeel::sInitialized = false;
|
|
|
|
bool nsXPLookAndFeel::sUseNativeColors = true;
|
2015-09-24 22:59:00 +00:00
|
|
|
bool nsXPLookAndFeel::sUseStandinsForNativeColors = false;
|
2016-06-09 11:30:44 +00:00
|
|
|
bool nsXPLookAndFeel::sFindbarModalHighlight = false;
|
2000-03-30 22:32:18 +00:00
|
|
|
|
2012-07-30 14:20:58 +00:00
|
|
|
nsLookAndFeel* nsXPLookAndFeel::sInstance = nullptr;
|
2011-09-29 06:19:26 +00:00
|
|
|
bool nsXPLookAndFeel::sShutdown = false;
|
2011-09-09 02:27:11 +00:00
|
|
|
|
|
|
|
// static
|
|
|
|
nsLookAndFeel*
|
|
|
|
nsXPLookAndFeel::GetInstance()
|
|
|
|
{
|
|
|
|
if (sInstance) {
|
2011-09-09 02:27:13 +00:00
|
|
|
return sInstance;
|
2011-09-09 02:27:11 +00:00
|
|
|
}
|
|
|
|
|
2012-07-30 14:20:58 +00:00
|
|
|
NS_ENSURE_TRUE(!sShutdown, nullptr);
|
2011-09-09 02:27:11 +00:00
|
|
|
|
2011-09-09 02:27:13 +00:00
|
|
|
sInstance = new nsLookAndFeel();
|
|
|
|
return sInstance;
|
2011-09-09 02:27:11 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// static
|
|
|
|
void
|
|
|
|
nsXPLookAndFeel::Shutdown()
|
|
|
|
{
|
|
|
|
if (sShutdown) {
|
|
|
|
return;
|
|
|
|
}
|
2011-10-17 14:59:28 +00:00
|
|
|
sShutdown = true;
|
2011-09-09 02:27:13 +00:00
|
|
|
delete sInstance;
|
2012-07-30 14:20:58 +00:00
|
|
|
sInstance = nullptr;
|
2011-09-09 02:27:11 +00:00
|
|
|
}
|
|
|
|
|
2011-09-09 02:27:13 +00:00
|
|
|
nsXPLookAndFeel::nsXPLookAndFeel() : LookAndFeel()
|
2000-03-30 22:32:18 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2011-09-09 02:27:11 +00:00
|
|
|
// static
|
2005-09-12 12:36:11 +00:00
|
|
|
void
|
2011-09-09 02:27:13 +00:00
|
|
|
nsXPLookAndFeel::IntPrefChanged(nsLookAndFeelIntPref *data)
|
2000-03-30 22:32:18 +00:00
|
|
|
{
|
2011-05-23 14:54:03 +00:00
|
|
|
if (!data) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2012-08-22 15:56:38 +00:00
|
|
|
int32_t intpref;
|
2011-05-23 14:54:03 +00:00
|
|
|
nsresult rv = Preferences::GetInt(data->name, &intpref);
|
|
|
|
if (NS_FAILED(rv)) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
data->intVar = intpref;
|
2011-10-17 14:59:28 +00:00
|
|
|
data->isSet = true;
|
2000-03-30 22:32:18 +00:00
|
|
|
#ifdef DEBUG_akkana
|
2011-05-23 14:54:03 +00:00
|
|
|
printf("====== Changed int pref %s to %d\n", data->name, data->intVar);
|
2000-03-30 22:32:18 +00:00
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
2011-09-09 02:27:11 +00:00
|
|
|
// static
|
2005-09-12 12:36:11 +00:00
|
|
|
void
|
2011-09-09 02:27:13 +00:00
|
|
|
nsXPLookAndFeel::FloatPrefChanged(nsLookAndFeelFloatPref *data)
|
2000-03-30 22:32:18 +00:00
|
|
|
{
|
2011-05-23 14:54:03 +00:00
|
|
|
if (!data) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2012-08-22 15:56:38 +00:00
|
|
|
int32_t intpref;
|
2011-05-23 14:54:03 +00:00
|
|
|
nsresult rv = Preferences::GetInt(data->name, &intpref);
|
|
|
|
if (NS_FAILED(rv)) {
|
|
|
|
return;
|
|
|
|
}
|
2011-09-09 02:27:13 +00:00
|
|
|
data->floatVar = (float)intpref / 100.0f;
|
2011-10-17 14:59:28 +00:00
|
|
|
data->isSet = true;
|
2000-03-30 22:32:18 +00:00
|
|
|
#ifdef DEBUG_akkana
|
2011-05-23 14:54:03 +00:00
|
|
|
printf("====== Changed float pref %s to %f\n", data->name, data->floatVar);
|
2000-03-30 22:32:18 +00:00
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
2011-09-09 02:27:11 +00:00
|
|
|
// static
|
2005-09-12 12:36:11 +00:00
|
|
|
void
|
|
|
|
nsXPLookAndFeel::ColorPrefChanged (unsigned int index, const char *prefName)
|
2000-04-11 22:34:55 +00:00
|
|
|
{
|
2011-05-23 14:54:03 +00:00
|
|
|
nsAutoString colorStr;
|
2011-05-27 04:53:03 +00:00
|
|
|
nsresult rv = Preferences::GetString(prefName, &colorStr);
|
2011-05-23 14:54:03 +00:00
|
|
|
if (NS_FAILED(rv)) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
if (!colorStr.IsEmpty()) {
|
|
|
|
nscolor thecolor;
|
2014-01-04 15:02:17 +00:00
|
|
|
if (colorStr[0] == char16_t('#')) {
|
2016-05-09 05:16:41 +00:00
|
|
|
if (NS_HexToRGBA(nsDependentString(colorStr, 1),
|
|
|
|
nsHexColorType::NoAlpha, &thecolor)) {
|
2012-08-22 15:56:38 +00:00
|
|
|
int32_t id = NS_PTR_TO_INT32(index);
|
2001-11-06 02:41:04 +00:00
|
|
|
CACHE_COLOR(id, thecolor);
|
2000-04-11 22:34:55 +00:00
|
|
|
}
|
2011-05-23 14:54:03 +00:00
|
|
|
} else if (NS_ColorNameToRGB(colorStr, &thecolor)) {
|
2012-08-22 15:56:38 +00:00
|
|
|
int32_t id = NS_PTR_TO_INT32(index);
|
2011-05-23 14:54:03 +00:00
|
|
|
CACHE_COLOR(id, thecolor);
|
|
|
|
#ifdef DEBUG_akkana
|
|
|
|
printf("====== Changed color pref %s to 0x%lx\n",
|
|
|
|
prefName, thecolor);
|
|
|
|
#endif
|
2000-04-11 22:34:55 +00:00
|
|
|
}
|
2011-05-23 14:54:03 +00:00
|
|
|
} else {
|
|
|
|
// Reset to the default color, by clearing the cache
|
|
|
|
// to force lookup when the color is next used
|
2012-08-22 15:56:38 +00:00
|
|
|
int32_t id = NS_PTR_TO_INT32(index);
|
2011-05-23 14:54:03 +00:00
|
|
|
CLEAR_COLOR_CACHE(id);
|
2000-04-11 22:34:55 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2005-09-12 12:36:11 +00:00
|
|
|
void
|
2011-05-23 14:54:03 +00:00
|
|
|
nsXPLookAndFeel::InitFromPref(nsLookAndFeelIntPref* aPref)
|
2000-03-30 22:32:18 +00:00
|
|
|
{
|
2012-08-22 15:56:38 +00:00
|
|
|
int32_t intpref;
|
2011-05-23 14:54:03 +00:00
|
|
|
nsresult rv = Preferences::GetInt(aPref->name, &intpref);
|
|
|
|
if (NS_SUCCEEDED(rv)) {
|
2011-10-17 14:59:28 +00:00
|
|
|
aPref->isSet = true;
|
2000-03-30 22:32:18 +00:00
|
|
|
aPref->intVar = intpref;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2005-09-12 12:36:11 +00:00
|
|
|
void
|
2011-05-23 14:54:03 +00:00
|
|
|
nsXPLookAndFeel::InitFromPref(nsLookAndFeelFloatPref* aPref)
|
2000-03-30 22:32:18 +00:00
|
|
|
{
|
2012-08-22 15:56:38 +00:00
|
|
|
int32_t intpref;
|
2011-05-23 14:54:03 +00:00
|
|
|
nsresult rv = Preferences::GetInt(aPref->name, &intpref);
|
|
|
|
if (NS_SUCCEEDED(rv)) {
|
2011-10-17 14:59:28 +00:00
|
|
|
aPref->isSet = true;
|
2011-09-09 02:27:13 +00:00
|
|
|
aPref->floatVar = (float)intpref / 100.0f;
|
2000-03-30 22:32:18 +00:00
|
|
|
}
|
2000-04-11 22:34:55 +00:00
|
|
|
}
|
|
|
|
|
2005-09-12 12:36:11 +00:00
|
|
|
void
|
2012-08-22 15:56:38 +00:00
|
|
|
nsXPLookAndFeel::InitColorFromPref(int32_t i)
|
2000-04-11 22:34:55 +00:00
|
|
|
{
|
2011-05-23 14:54:03 +00:00
|
|
|
nsAutoString colorStr;
|
2011-05-27 04:53:03 +00:00
|
|
|
nsresult rv = Preferences::GetString(sColorPrefs[i], &colorStr);
|
2011-05-23 14:54:03 +00:00
|
|
|
if (NS_FAILED(rv) || colorStr.IsEmpty()) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
nscolor thecolor;
|
2014-01-04 15:02:17 +00:00
|
|
|
if (colorStr[0] == char16_t('#')) {
|
2011-05-23 14:54:03 +00:00
|
|
|
nsAutoString hexString;
|
|
|
|
colorStr.Right(hexString, colorStr.Length() - 1);
|
2016-05-09 05:16:41 +00:00
|
|
|
if (NS_HexToRGBA(hexString, nsHexColorType::NoAlpha, &thecolor)) {
|
2001-11-06 02:41:04 +00:00
|
|
|
CACHE_COLOR(i, thecolor);
|
2005-09-12 12:36:11 +00:00
|
|
|
}
|
2011-05-23 14:54:03 +00:00
|
|
|
} else if (NS_ColorNameToRGB(colorStr, &thecolor)) {
|
|
|
|
CACHE_COLOR(i, thecolor);
|
2005-09-12 12:36:11 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-09-09 02:27:11 +00:00
|
|
|
// static
|
2013-12-10 23:10:01 +00:00
|
|
|
void
|
2011-09-09 02:27:11 +00:00
|
|
|
nsXPLookAndFeel::OnPrefChanged(const char* aPref, void* aClosure)
|
2005-09-12 12:36:11 +00:00
|
|
|
{
|
|
|
|
|
|
|
|
// looping in the same order as in ::Init
|
|
|
|
|
2011-09-09 02:27:11 +00:00
|
|
|
nsDependentCString prefName(aPref);
|
2005-09-12 12:36:11 +00:00
|
|
|
unsigned int i;
|
2011-10-11 05:50:08 +00:00
|
|
|
for (i = 0; i < ArrayLength(sIntPrefs); ++i) {
|
2011-09-09 02:27:11 +00:00
|
|
|
if (prefName.Equals(sIntPrefs[i].name)) {
|
2005-09-12 12:36:11 +00:00
|
|
|
IntPrefChanged(&sIntPrefs[i]);
|
2013-12-10 23:10:01 +00:00
|
|
|
return;
|
2005-09-12 12:36:11 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-10-11 05:50:08 +00:00
|
|
|
for (i = 0; i < ArrayLength(sFloatPrefs); ++i) {
|
2011-09-09 02:27:11 +00:00
|
|
|
if (prefName.Equals(sFloatPrefs[i].name)) {
|
2005-09-12 12:36:11 +00:00
|
|
|
FloatPrefChanged(&sFloatPrefs[i]);
|
2013-12-10 23:10:01 +00:00
|
|
|
return;
|
2005-09-12 12:36:11 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-10-11 05:50:08 +00:00
|
|
|
for (i = 0; i < ArrayLength(sColorPrefs); ++i) {
|
2011-09-09 02:27:11 +00:00
|
|
|
if (prefName.Equals(sColorPrefs[i])) {
|
2005-09-12 12:36:11 +00:00
|
|
|
ColorPrefChanged(i, sColorPrefs[i]);
|
2013-12-10 23:10:01 +00:00
|
|
|
return;
|
2000-04-11 22:34:55 +00:00
|
|
|
}
|
|
|
|
}
|
2000-03-30 22:32:18 +00: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()
|
|
|
|
{
|
|
|
|
// 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 14:59:28 +00:00
|
|
|
sInitialized = true;
|
2000-03-30 22:32:18 +00:00
|
|
|
|
2011-09-09 02:27:11 +00: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().
|
|
|
|
Preferences::RegisterCallback(OnPrefChanged, "ui.");
|
|
|
|
Preferences::RegisterCallback(OnPrefChanged, "accessibility.tabfocus");
|
|
|
|
|
2000-03-30 22:32:18 +00:00
|
|
|
unsigned int i;
|
2011-10-11 05:50:08 +00:00
|
|
|
for (i = 0; i < ArrayLength(sIntPrefs); ++i) {
|
2011-05-23 14:54:03 +00:00
|
|
|
InitFromPref(&sIntPrefs[i]);
|
2005-09-12 12:36:11 +00:00
|
|
|
}
|
2000-03-30 22:32:18 +00:00
|
|
|
|
2011-10-11 05:50:08 +00:00
|
|
|
for (i = 0; i < ArrayLength(sFloatPrefs); ++i) {
|
2011-05-23 14:54:03 +00:00
|
|
|
InitFromPref(&sFloatPrefs[i]);
|
2005-09-12 12:36:11 +00:00
|
|
|
}
|
2000-03-30 22:32:18 +00:00
|
|
|
|
2011-10-11 05:50:08 +00:00
|
|
|
for (i = 0; i < ArrayLength(sColorPrefs); ++i) {
|
2011-05-23 14:54:03 +00:00
|
|
|
InitColorFromPref(i);
|
2005-09-12 12:36:11 +00:00
|
|
|
}
|
2009-02-10 19:25:00 +00:00
|
|
|
|
2015-09-24 22:59:00 +00:00
|
|
|
Preferences::AddBoolVarCache(&sUseNativeColors,
|
|
|
|
"ui.use_native_colors",
|
|
|
|
sUseNativeColors);
|
|
|
|
Preferences::AddBoolVarCache(&sUseStandinsForNativeColors,
|
|
|
|
"ui.use_standins_for_native_colors",
|
|
|
|
sUseStandinsForNativeColors);
|
2016-06-09 11:30:44 +00:00
|
|
|
Preferences::AddBoolVarCache(&sFindbarModalHighlight,
|
|
|
|
"findbar.modalHighlight",
|
|
|
|
sFindbarModalHighlight);
|
2015-04-22 14:58:15 +00:00
|
|
|
|
2015-07-04 01:29:00 +00:00
|
|
|
if (XRE_IsContentProcess()) {
|
2015-04-22 14:58:15 +00:00
|
|
|
mozilla::dom::ContentChild* cc =
|
|
|
|
mozilla::dom::ContentChild::GetSingleton();
|
|
|
|
|
2016-11-18 20:36:18 +00:00
|
|
|
LookAndFeel::SetIntCache(cc->LookAndFeelCache());
|
|
|
|
// This is only ever used once during initialization, and can be cleared now.
|
|
|
|
cc->LookAndFeelCache().Clear();
|
2015-04-22 14:58:15 +00:00
|
|
|
}
|
2000-03-30 22:32:18 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
nsXPLookAndFeel::~nsXPLookAndFeel()
|
|
|
|
{
|
2011-09-09 02:27:11 +00:00
|
|
|
NS_ASSERTION(sInstance == this,
|
|
|
|
"This destroying instance isn't the singleton instance");
|
2012-07-30 14:20:58 +00:00
|
|
|
sInstance = nullptr;
|
2000-03-30 22:32:18 +00:00
|
|
|
}
|
|
|
|
|
2011-09-29 06:19:26 +00:00
|
|
|
bool
|
2011-09-09 02:27:13 +00:00
|
|
|
nsXPLookAndFeel::IsSpecialColor(ColorID aID, nscolor &aColor)
|
2007-09-04 11:28:12 +00:00
|
|
|
{
|
|
|
|
switch (aID) {
|
2011-09-09 02:27:13 +00:00
|
|
|
case eColorID_TextSelectForeground:
|
2007-09-04 11:28:12 +00:00
|
|
|
return (aColor == NS_DONT_CHANGE_COLOR);
|
2011-09-09 02:27:13 +00:00
|
|
|
case eColorID_IMESelectedRawTextBackground:
|
|
|
|
case eColorID_IMESelectedConvertedTextBackground:
|
|
|
|
case eColorID_IMERawInputBackground:
|
|
|
|
case eColorID_IMEConvertedTextBackground:
|
|
|
|
case eColorID_IMESelectedRawTextForeground:
|
|
|
|
case eColorID_IMESelectedConvertedTextForeground:
|
|
|
|
case eColorID_IMERawInputForeground:
|
|
|
|
case eColorID_IMEConvertedTextForeground:
|
|
|
|
case eColorID_IMERawInputUnderline:
|
|
|
|
case eColorID_IMEConvertedTextUnderline:
|
|
|
|
case eColorID_IMESelectedRawTextUnderline:
|
|
|
|
case eColorID_IMESelectedConvertedTextUnderline:
|
|
|
|
case eColorID_SpellCheckerUnderline:
|
2009-04-03 07:26:28 +00:00
|
|
|
return NS_IS_SELECTION_SPECIAL_COLOR(aColor);
|
2008-09-16 11:32:03 +00:00
|
|
|
default:
|
|
|
|
/*
|
|
|
|
* In GetColor(), every color that is not a special color is color
|
2011-10-17 14:59:28 +00:00
|
|
|
* corrected. Use false to make other colors color corrected.
|
2008-09-16 11:32:03 +00:00
|
|
|
*/
|
2011-10-17 14:59:28 +00:00
|
|
|
return false;
|
2007-09-04 11:28:12 +00:00
|
|
|
}
|
2011-10-17 14:59:28 +00:00
|
|
|
return false;
|
2007-09-04 11:28:12 +00:00
|
|
|
}
|
|
|
|
|
2015-09-24 22:59:00 +00:00
|
|
|
bool
|
|
|
|
nsXPLookAndFeel::ColorIsNotCSSAccessible(ColorID aID)
|
|
|
|
{
|
|
|
|
bool result = false;
|
|
|
|
|
|
|
|
switch (aID) {
|
|
|
|
case eColorID_WindowBackground:
|
|
|
|
case eColorID_WindowForeground:
|
|
|
|
case eColorID_WidgetBackground:
|
|
|
|
case eColorID_WidgetForeground:
|
|
|
|
case eColorID_WidgetSelectBackground:
|
|
|
|
case eColorID_WidgetSelectForeground:
|
|
|
|
case eColorID_Widget3DHighlight:
|
|
|
|
case eColorID_Widget3DShadow:
|
|
|
|
case eColorID_TextBackground:
|
|
|
|
case eColorID_TextForeground:
|
|
|
|
case eColorID_TextSelectBackground:
|
|
|
|
case eColorID_TextSelectForeground:
|
|
|
|
case eColorID_TextSelectBackgroundDisabled:
|
|
|
|
case eColorID_TextSelectBackgroundAttention:
|
|
|
|
case eColorID_TextHighlightBackground:
|
|
|
|
case eColorID_TextHighlightForeground:
|
|
|
|
case eColorID_IMERawInputBackground:
|
|
|
|
case eColorID_IMERawInputForeground:
|
|
|
|
case eColorID_IMERawInputUnderline:
|
|
|
|
case eColorID_IMESelectedRawTextBackground:
|
|
|
|
case eColorID_IMESelectedRawTextForeground:
|
|
|
|
case eColorID_IMESelectedRawTextUnderline:
|
|
|
|
case eColorID_IMEConvertedTextBackground:
|
|
|
|
case eColorID_IMEConvertedTextForeground:
|
|
|
|
case eColorID_IMEConvertedTextUnderline:
|
|
|
|
case eColorID_IMESelectedConvertedTextBackground:
|
|
|
|
case eColorID_IMESelectedConvertedTextForeground:
|
|
|
|
case eColorID_IMESelectedConvertedTextUnderline:
|
|
|
|
case eColorID_SpellCheckerUnderline:
|
|
|
|
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:
|
|
|
|
case eColorID_activeborder: result = NS_RGB(0xB4, 0xB4, 0xB4); break;
|
|
|
|
case eColorID_activecaption: result = NS_RGB(0x99, 0xB4, 0xD1); break;
|
|
|
|
case eColorID_appworkspace: result = NS_RGB(0xAB, 0xAB, 0xAB); break;
|
|
|
|
case eColorID_background: result = NS_RGB(0x00, 0x00, 0x00); break;
|
|
|
|
case eColorID_buttonface: result = NS_RGB(0xF0, 0xF0, 0xF0); break;
|
|
|
|
case eColorID_buttonhighlight: result = NS_RGB(0xFF, 0xFF, 0xFF); break;
|
|
|
|
case eColorID_buttonshadow: result = NS_RGB(0xA0, 0xA0, 0xA0); break;
|
|
|
|
case eColorID_buttontext: result = NS_RGB(0x00, 0x00, 0x00); break;
|
|
|
|
case eColorID_captiontext: result = NS_RGB(0x00, 0x00, 0x00); break;
|
|
|
|
case eColorID_graytext: result = NS_RGB(0x6D, 0x6D, 0x6D); break;
|
|
|
|
case eColorID_highlight: result = NS_RGB(0x33, 0x99, 0xFF); break;
|
|
|
|
case eColorID_highlighttext: result = NS_RGB(0xFF, 0xFF, 0xFF); break;
|
|
|
|
case eColorID_inactiveborder: result = NS_RGB(0xF4, 0xF7, 0xFC); break;
|
|
|
|
case eColorID_inactivecaption: result = NS_RGB(0xBF, 0xCD, 0xDB); break;
|
|
|
|
case eColorID_inactivecaptiontext:
|
|
|
|
result = NS_RGB(0x43, 0x4E, 0x54); break;
|
|
|
|
case eColorID_infobackground: result = NS_RGB(0xFF, 0xFF, 0xE1); break;
|
|
|
|
case eColorID_infotext: result = NS_RGB(0x00, 0x00, 0x00); break;
|
|
|
|
case eColorID_menu: result = NS_RGB(0xF0, 0xF0, 0xF0); break;
|
|
|
|
case eColorID_menutext: result = NS_RGB(0x00, 0x00, 0x00); break;
|
|
|
|
case eColorID_scrollbar: result = NS_RGB(0xC8, 0xC8, 0xC8); break;
|
|
|
|
case eColorID_threeddarkshadow: result = NS_RGB(0x69, 0x69, 0x69); break;
|
|
|
|
case eColorID_threedface: result = NS_RGB(0xF0, 0xF0, 0xF0); break;
|
|
|
|
case eColorID_threedhighlight: result = NS_RGB(0xFF, 0xFF, 0xFF); break;
|
|
|
|
case eColorID_threedlightshadow: result = NS_RGB(0xE3, 0xE3, 0xE3); break;
|
|
|
|
case eColorID_threedshadow: result = NS_RGB(0xA0, 0xA0, 0xA0); break;
|
|
|
|
case eColorID_window: result = NS_RGB(0xFF, 0xFF, 0xFF); break;
|
|
|
|
case eColorID_windowframe: result = NS_RGB(0x64, 0x64, 0x64); break;
|
|
|
|
case eColorID_windowtext: result = NS_RGB(0x00, 0x00, 0x00); break;
|
|
|
|
case eColorID__moz_buttondefault:
|
|
|
|
result = NS_RGB(0x69, 0x69, 0x69); break;
|
|
|
|
case eColorID__moz_field: result = NS_RGB(0xFF, 0xFF, 0xFF); break;
|
|
|
|
case eColorID__moz_fieldtext: result = NS_RGB(0x00, 0x00, 0x00); break;
|
|
|
|
case eColorID__moz_dialog: result = NS_RGB(0xF0, 0xF0, 0xF0); break;
|
|
|
|
case eColorID__moz_dialogtext: result = NS_RGB(0x00, 0x00, 0x00); break;
|
|
|
|
case eColorID__moz_dragtargetzone:
|
|
|
|
result = NS_RGB(0xFF, 0xFF, 0xFF); break;
|
|
|
|
case eColorID__moz_cellhighlight:
|
|
|
|
result = NS_RGB(0xF0, 0xF0, 0xF0); break;
|
|
|
|
case eColorID__moz_cellhighlighttext:
|
|
|
|
result = NS_RGB(0x00, 0x00, 0x00); break;
|
|
|
|
case eColorID__moz_html_cellhighlight:
|
|
|
|
result = NS_RGB(0x33, 0x99, 0xFF); break;
|
|
|
|
case eColorID__moz_html_cellhighlighttext:
|
|
|
|
result = NS_RGB(0xFF, 0xFF, 0xFF); break;
|
|
|
|
case eColorID__moz_buttonhoverface:
|
|
|
|
result = NS_RGB(0xF0, 0xF0, 0xF0); break;
|
|
|
|
case eColorID__moz_buttonhovertext:
|
|
|
|
result = NS_RGB(0x00, 0x00, 0x00); break;
|
|
|
|
case eColorID__moz_menuhover:
|
|
|
|
result = NS_RGB(0x33, 0x99, 0xFF); break;
|
|
|
|
case eColorID__moz_menuhovertext:
|
|
|
|
result = NS_RGB(0x00, 0x00, 0x00); break;
|
|
|
|
case eColorID__moz_menubartext:
|
|
|
|
result = NS_RGB(0x00, 0x00, 0x00); break;
|
|
|
|
case eColorID__moz_menubarhovertext:
|
|
|
|
result = NS_RGB(0x00, 0x00, 0x00); break;
|
|
|
|
case eColorID__moz_oddtreerow:
|
|
|
|
result = NS_RGB(0xFF, 0xFF, 0xFF); break;
|
|
|
|
case eColorID__moz_mac_chrome_active:
|
|
|
|
result = NS_RGB(0xB2, 0xB2, 0xB2); break;
|
|
|
|
case eColorID__moz_mac_chrome_inactive:
|
|
|
|
result = NS_RGB(0xE1, 0xE1, 0xE1); break;
|
|
|
|
case eColorID__moz_mac_focusring:
|
|
|
|
result = NS_RGB(0x60, 0x9D, 0xD7); break;
|
|
|
|
case eColorID__moz_mac_menuselect:
|
|
|
|
result = NS_RGB(0x38, 0x75, 0xD7); break;
|
|
|
|
case eColorID__moz_mac_menushadow:
|
|
|
|
result = NS_RGB(0xA3, 0xA3, 0xA3); break;
|
|
|
|
case eColorID__moz_mac_menutextdisable:
|
|
|
|
result = NS_RGB(0x88, 0x88, 0x88); break;
|
|
|
|
case eColorID__moz_mac_menutextselect:
|
|
|
|
result = NS_RGB(0xFF, 0xFF, 0xFF); break;
|
|
|
|
case eColorID__moz_mac_disabledtoolbartext:
|
|
|
|
result = NS_RGB(0x3F, 0x3F, 0x3F); break;
|
|
|
|
case eColorID__moz_mac_secondaryhighlight:
|
|
|
|
result = NS_RGB(0xD4, 0xD4, 0xD4); break;
|
|
|
|
case eColorID__moz_win_mediatext:
|
|
|
|
result = NS_RGB(0xFF, 0xFF, 0xFF); break;
|
|
|
|
case eColorID__moz_win_communicationstext:
|
|
|
|
result = NS_RGB(0xFF, 0xFF, 0xFF); break;
|
|
|
|
case eColorID__moz_nativehyperlinktext:
|
|
|
|
result = NS_RGB(0x00, 0x66, 0xCC); break;
|
|
|
|
case eColorID__moz_comboboxtext:
|
|
|
|
result = NS_RGB(0x00, 0x00, 0x00); break;
|
|
|
|
case eColorID__moz_combobox:
|
|
|
|
result = NS_RGB(0xFF, 0xFF, 0xFF); break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
2000-03-30 22:32:18 +00: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.
|
|
|
|
//
|
2011-09-09 02:27:13 +00:00
|
|
|
nsresult
|
2015-09-24 22:59:00 +00:00
|
|
|
nsXPLookAndFeel::GetColorImpl(ColorID aID, bool aUseStandinsForNativeColors,
|
|
|
|
nscolor &aResult)
|
2000-03-30 22:32:18 +00:00
|
|
|
{
|
2000-04-11 22:34:55 +00:00
|
|
|
if (!sInitialized)
|
|
|
|
Init();
|
|
|
|
|
2001-04-17 00:46:07 +00: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
|
2011-09-09 02:27:13 +00:00
|
|
|
case eColorID_activecaption:
|
2001-04-17 00:46:07 +00:00
|
|
|
// active window caption background
|
2011-09-09 02:27:13 +00:00
|
|
|
case eColorID_captiontext:
|
2001-04-17 00:46:07 +00:00
|
|
|
// text in active window caption
|
2011-09-09 02:27:13 +00:00
|
|
|
aResult = NS_RGB(0xff, 0x00, 0x00);
|
2001-04-17 00:46:07 +00:00
|
|
|
break;
|
|
|
|
|
2011-09-09 02:27:13 +00:00
|
|
|
case eColorID_highlight:
|
2001-04-17 00:46:07 +00:00
|
|
|
// background of selected item
|
2011-09-09 02:27:13 +00:00
|
|
|
case eColorID_highlighttext:
|
2001-04-17 00:46:07 +00:00
|
|
|
// text of selected item
|
2011-09-09 02:27:13 +00:00
|
|
|
aResult = NS_RGB(0xff, 0xff, 0x00);
|
2001-04-17 00:46:07 +00:00
|
|
|
break;
|
|
|
|
|
2011-09-09 02:27:13 +00:00
|
|
|
case eColorID_inactivecaption:
|
2001-04-17 00:46:07 +00:00
|
|
|
// inactive window caption
|
2011-09-09 02:27:13 +00:00
|
|
|
case eColorID_inactivecaptiontext:
|
2001-04-17 00:46:07 +00:00
|
|
|
// text in inactive window caption
|
2011-09-09 02:27:13 +00:00
|
|
|
aResult = NS_RGB(0x66, 0x66, 0x00);
|
2001-04-17 00:46:07 +00:00
|
|
|
break;
|
|
|
|
|
2011-09-09 02:27:13 +00:00
|
|
|
case eColorID_infobackground:
|
2001-04-17 00:46:07 +00:00
|
|
|
// tooltip background color
|
2011-09-09 02:27:13 +00:00
|
|
|
case eColorID_infotext:
|
2001-04-17 00:46:07 +00:00
|
|
|
// tooltip text color
|
2011-09-09 02:27:13 +00:00
|
|
|
aResult = NS_RGB(0x00, 0xff, 0x00);
|
2001-04-17 00:46:07 +00:00
|
|
|
break;
|
|
|
|
|
2011-09-09 02:27:13 +00:00
|
|
|
case eColorID_menu:
|
2001-04-17 00:46:07 +00:00
|
|
|
// menu background
|
2011-09-09 02:27:13 +00:00
|
|
|
case eColorID_menutext:
|
2001-04-17 00:46:07 +00:00
|
|
|
// menu text
|
2011-09-09 02:27:13 +00:00
|
|
|
aResult = NS_RGB(0x00, 0xff, 0xff);
|
2001-04-17 00:46:07 +00:00
|
|
|
break;
|
|
|
|
|
2011-09-09 02:27:13 +00:00
|
|
|
case eColorID_threedface:
|
|
|
|
case eColorID_buttonface:
|
2001-04-17 00:46:07 +00:00
|
|
|
// 3-D face color
|
2011-09-09 02:27:13 +00:00
|
|
|
case eColorID_buttontext:
|
2001-04-17 00:46:07 +00:00
|
|
|
// text on push buttons
|
2011-09-09 02:27:13 +00:00
|
|
|
aResult = NS_RGB(0x00, 0x66, 0x66);
|
2001-04-17 00:46:07 +00:00
|
|
|
break;
|
|
|
|
|
2011-09-09 02:27:13 +00:00
|
|
|
case eColorID_window:
|
|
|
|
case eColorID_windowtext:
|
|
|
|
aResult = NS_RGB(0x00, 0x00, 0xff);
|
2001-04-17 00:46:07 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
// from the CSS3 working draft (not yet finalized)
|
|
|
|
// http://www.w3.org/tr/2000/wd-css3-userint-20000216.html#color
|
|
|
|
|
2011-09-09 02:27:13 +00:00
|
|
|
case eColorID__moz_field:
|
|
|
|
case eColorID__moz_fieldtext:
|
|
|
|
aResult = NS_RGB(0xff, 0x00, 0xff);
|
2001-04-17 00:46:07 +00:00
|
|
|
break;
|
|
|
|
|
2011-09-09 02:27:13 +00:00
|
|
|
case eColorID__moz_dialog:
|
|
|
|
case eColorID__moz_dialogtext:
|
|
|
|
aResult = NS_RGB(0x66, 0x00, 0x66);
|
2001-04-17 00:46:07 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
rv = NS_ERROR_NOT_AVAILABLE;
|
|
|
|
}
|
|
|
|
if (NS_SUCCEEDED(rv))
|
|
|
|
return rv;
|
|
|
|
}
|
|
|
|
#endif // DEBUG_SYSTEM_COLOR_USE
|
|
|
|
|
2015-09-24 22:59:00 +00:00
|
|
|
if (aUseStandinsForNativeColors &&
|
|
|
|
(ColorIsNotCSSAccessible(aID) || !sUseStandinsForNativeColors)) {
|
|
|
|
aUseStandinsForNativeColors = false;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!aUseStandinsForNativeColors && IS_COLOR_CACHED(aID)) {
|
2011-09-09 02:27:13 +00:00
|
|
|
aResult = sCachedColors[aID];
|
2001-11-06 02:41:04 +00:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2002-09-06 07:30:45 +00:00
|
|
|
// There are no system color settings for these, so set them manually
|
2016-11-15 19:38:22 +00:00
|
|
|
#ifndef XP_MACOSX
|
2011-09-09 02:27:13 +00:00
|
|
|
if (aID == eColorID_TextSelectBackgroundDisabled) {
|
2002-09-06 07:30:45 +00:00
|
|
|
// This is used to gray out the selection when it's not focused
|
|
|
|
// Used with nsISelectionController::SELECTION_DISABLED
|
2011-09-09 02:27:13 +00:00
|
|
|
aResult = NS_RGB(0xb0, 0xb0, 0xb0);
|
2002-09-06 07:30:45 +00:00
|
|
|
return NS_OK;
|
|
|
|
}
|
2016-11-15 19:38:22 +00:00
|
|
|
#endif
|
2002-09-06 07:30:45 +00:00
|
|
|
|
2011-09-09 02:27:13 +00:00
|
|
|
if (aID == eColorID_TextSelectBackgroundAttention) {
|
2016-06-09 11:30:44 +00:00
|
|
|
if (sFindbarModalHighlight) {
|
|
|
|
aResult = NS_RGBA(0, 0, 0, 0);
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2002-09-06 07:30:45 +00:00
|
|
|
// This makes the selection stand out when typeaheadfind is on
|
|
|
|
// Used with nsISelectionController::SELECTION_ATTENTION
|
2011-09-09 02:27:13 +00:00
|
|
|
aResult = NS_RGB(0x38, 0xd8, 0x78);
|
2002-09-06 07:30:45 +00:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2011-09-09 02:27:13 +00:00
|
|
|
if (aID == eColorID_TextHighlightBackground) {
|
2008-07-30 20:48:56 +00:00
|
|
|
// This makes the matched text stand out when findbar highlighting is on
|
|
|
|
// Used with nsISelectionController::SELECTION_FIND
|
2011-09-09 02:27:13 +00:00
|
|
|
aResult = NS_RGB(0xef, 0x0f, 0xff);
|
2008-07-30 20:48:56 +00:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2011-09-09 02:27:13 +00:00
|
|
|
if (aID == eColorID_TextHighlightForeground) {
|
2008-09-02 06:28:44 +00:00
|
|
|
// The foreground color for the matched text in findbar highlighting
|
|
|
|
// Used with nsISelectionController::SELECTION_FIND
|
2011-09-09 02:27:13 +00:00
|
|
|
aResult = NS_RGB(0xff, 0xff, 0xff);
|
2008-09-02 06:28:44 +00:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2015-09-24 22:59:00 +00:00
|
|
|
if (sUseNativeColors && aUseStandinsForNativeColors) {
|
|
|
|
aResult = GetStandinForNativeColor(aID);
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2011-09-09 02:27:13 +00:00
|
|
|
if (sUseNativeColors && NS_SUCCEEDED(NativeGetColor(aID, aResult))) {
|
2013-09-07 03:08:36 +00:00
|
|
|
if ((gfxPlatform::GetCMSMode() == eCMSMode_All) &&
|
2011-09-09 02:27:13 +00:00
|
|
|
!IsSpecialColor(aID, aResult)) {
|
2013-09-07 03:08:36 +00:00
|
|
|
qcms_transform *transform = gfxPlatform::GetCMSInverseRGBTransform();
|
2007-08-30 16:21:16 +00:00
|
|
|
if (transform) {
|
2012-08-22 15:56:38 +00:00
|
|
|
uint8_t color[3];
|
2011-09-09 02:27:13 +00:00
|
|
|
color[0] = NS_GET_R(aResult);
|
|
|
|
color[1] = NS_GET_G(aResult);
|
|
|
|
color[2] = NS_GET_B(aResult);
|
2009-04-07 16:02:11 +00:00
|
|
|
qcms_transform_data(transform, color, color, 1);
|
2011-09-09 02:27:13 +00:00
|
|
|
aResult = NS_RGB(color[0], color[1], color[2]);
|
2007-08-30 16:21:16 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-09-09 02:27:13 +00:00
|
|
|
CACHE_COLOR(aID, aResult);
|
2001-11-06 02:41:04 +00:00
|
|
|
return NS_OK;
|
|
|
|
}
|
2000-04-11 22:34:55 +00:00
|
|
|
|
2000-03-30 22:32:18 +00:00
|
|
|
return NS_ERROR_NOT_AVAILABLE;
|
|
|
|
}
|
2016-07-20 15:29:36 +00:00
|
|
|
|
2011-09-09 02:27:13 +00:00
|
|
|
nsresult
|
2012-08-22 15:56:38 +00:00
|
|
|
nsXPLookAndFeel::GetIntImpl(IntID aID, int32_t &aResult)
|
2000-03-30 22:32:18 +00:00
|
|
|
{
|
|
|
|
if (!sInitialized)
|
|
|
|
Init();
|
|
|
|
|
2006-07-19 22:13:18 +00:00
|
|
|
// Set the default values for these prefs. but allow different platforms
|
|
|
|
// to override them in their nsLookAndFeel if desired.
|
|
|
|
switch (aID) {
|
2011-09-09 02:27:13 +00:00
|
|
|
case eIntID_ScrollButtonLeftMouseButtonAction:
|
|
|
|
aResult = 0;
|
2006-07-19 22:13:18 +00:00
|
|
|
return NS_OK;
|
2011-09-09 02:27:13 +00:00
|
|
|
case eIntID_ScrollButtonMiddleMouseButtonAction:
|
|
|
|
aResult = 3;
|
2006-07-19 22:13:18 +00:00
|
|
|
return NS_OK;
|
2011-09-09 02:27:13 +00:00
|
|
|
case eIntID_ScrollButtonRightMouseButtonAction:
|
|
|
|
aResult = 3;
|
2006-07-19 22:13:18 +00:00
|
|
|
return NS_OK;
|
2008-09-16 11:32:03 +00: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-19 22:13:18 +00:00
|
|
|
}
|
|
|
|
|
2011-10-11 05:50:08 +00:00
|
|
|
for (unsigned int i = 0; i < ArrayLength(sIntPrefs); ++i) {
|
2011-05-23 14:54:03 +00:00
|
|
|
if (sIntPrefs[i].isSet && (sIntPrefs[i].id == aID)) {
|
2011-09-09 02:27:13 +00:00
|
|
|
aResult = sIntPrefs[i].intVar;
|
2000-03-30 22:32:18 +00:00
|
|
|
return NS_OK;
|
|
|
|
}
|
2011-05-23 14:54:03 +00:00
|
|
|
}
|
2000-03-30 22:32:18 +00:00
|
|
|
|
|
|
|
return NS_ERROR_NOT_AVAILABLE;
|
|
|
|
}
|
|
|
|
|
2011-09-09 02:27:13 +00:00
|
|
|
nsresult
|
|
|
|
nsXPLookAndFeel::GetFloatImpl(FloatID aID, float &aResult)
|
2000-03-30 22:32:18 +00:00
|
|
|
{
|
|
|
|
if (!sInitialized)
|
|
|
|
Init();
|
|
|
|
|
2011-10-11 05:50:08 +00:00
|
|
|
for (unsigned int i = 0; i < ArrayLength(sFloatPrefs); ++i) {
|
2011-05-23 14:54:03 +00:00
|
|
|
if (sFloatPrefs[i].isSet && sFloatPrefs[i].id == aID) {
|
2011-09-09 02:27:13 +00:00
|
|
|
aResult = sFloatPrefs[i].floatVar;
|
2000-03-30 22:32:18 +00:00
|
|
|
return NS_OK;
|
|
|
|
}
|
2011-05-23 14:54:03 +00:00
|
|
|
}
|
2000-03-30 22:32:18 +00:00
|
|
|
|
|
|
|
return NS_ERROR_NOT_AVAILABLE;
|
|
|
|
}
|
|
|
|
|
2011-09-09 02:27:13 +00:00
|
|
|
void
|
|
|
|
nsXPLookAndFeel::RefreshImpl()
|
2001-12-17 22:51:39 +00:00
|
|
|
{
|
|
|
|
// Wipe out our color cache.
|
2012-08-22 15:56:38 +00:00
|
|
|
uint32_t i;
|
2011-09-09 02:27:13 +00:00
|
|
|
for (i = 0; i < eColorID_LAST_COLOR; i++)
|
2001-12-17 22:51:39 +00:00
|
|
|
sCachedColors[i] = 0;
|
|
|
|
for (i = 0; i < COLOR_CACHE_SIZE; i++)
|
|
|
|
sCachedColorBits[i] = 0;
|
|
|
|
}
|
|
|
|
|
2015-04-22 14:58:15 +00:00
|
|
|
nsTArray<LookAndFeelInt>
|
|
|
|
nsXPLookAndFeel::GetIntCacheImpl()
|
|
|
|
{
|
|
|
|
return nsTArray<LookAndFeelInt>();
|
|
|
|
}
|
|
|
|
|
2011-09-09 02:27:11 +00:00
|
|
|
namespace mozilla {
|
|
|
|
|
|
|
|
// static
|
|
|
|
nsresult
|
|
|
|
LookAndFeel::GetColor(ColorID aID, nscolor* aResult)
|
|
|
|
{
|
2015-09-24 22:59:00 +00: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 02:27:11 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// static
|
|
|
|
nsresult
|
2012-08-22 15:56:38 +00:00
|
|
|
LookAndFeel::GetInt(IntID aID, int32_t* aResult)
|
2011-09-09 02:27:11 +00:00
|
|
|
{
|
2011-09-09 02:27:13 +00:00
|
|
|
return nsLookAndFeel::GetInstance()->GetIntImpl(aID, *aResult);
|
2011-09-09 02:27:11 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// static
|
|
|
|
nsresult
|
|
|
|
LookAndFeel::GetFloat(FloatID aID, float* aResult)
|
|
|
|
{
|
2011-09-09 02:27:13 +00:00
|
|
|
return nsLookAndFeel::GetInstance()->GetFloatImpl(aID, *aResult);
|
2011-09-09 02:27:11 +00:00
|
|
|
}
|
|
|
|
|
2012-02-20 23:19:48 +00:00
|
|
|
// static
|
|
|
|
bool
|
2012-09-29 11:35:08 +00:00
|
|
|
LookAndFeel::GetFont(FontID aID, nsString& aName, gfxFontStyle& aStyle,
|
|
|
|
float aDevPixPerCSSPixel)
|
2012-02-20 23:19:48 +00:00
|
|
|
{
|
2012-09-29 11:35:08 +00:00
|
|
|
return nsLookAndFeel::GetInstance()->GetFontImpl(aID, aName, aStyle,
|
|
|
|
aDevPixPerCSSPixel);
|
2012-02-20 23:19:48 +00:00
|
|
|
}
|
|
|
|
|
2011-09-09 02:27:11 +00:00
|
|
|
// static
|
2014-01-04 15:02:17 +00:00
|
|
|
char16_t
|
2011-09-09 02:27:11 +00:00
|
|
|
LookAndFeel::GetPasswordCharacter()
|
|
|
|
{
|
2011-09-09 02:27:13 +00:00
|
|
|
return nsLookAndFeel::GetInstance()->GetPasswordCharacterImpl();
|
2011-09-09 02:27:11 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// static
|
2011-09-29 06:19:26 +00:00
|
|
|
bool
|
2011-09-09 02:27:11 +00:00
|
|
|
LookAndFeel::GetEchoPassword()
|
|
|
|
{
|
2011-09-09 02:27:13 +00:00
|
|
|
return nsLookAndFeel::GetInstance()->GetEchoPasswordImpl();
|
2011-09-09 02:27:11 +00:00
|
|
|
}
|
|
|
|
|
2012-07-13 02:26:20 +00:00
|
|
|
// static
|
2012-08-22 15:56:38 +00:00
|
|
|
uint32_t
|
2012-07-13 02:26:20 +00:00
|
|
|
LookAndFeel::GetPasswordMaskDelay()
|
|
|
|
{
|
|
|
|
return nsLookAndFeel::GetInstance()->GetPasswordMaskDelayImpl();
|
|
|
|
}
|
|
|
|
|
2011-09-09 02:27:11 +00:00
|
|
|
// static
|
|
|
|
void
|
|
|
|
LookAndFeel::Refresh()
|
|
|
|
{
|
2011-09-09 02:27:13 +00:00
|
|
|
nsLookAndFeel::GetInstance()->RefreshImpl();
|
2011-09-09 02:27:11 +00:00
|
|
|
}
|
|
|
|
|
2015-04-22 14:58:15 +00:00
|
|
|
// static
|
|
|
|
nsTArray<LookAndFeelInt>
|
|
|
|
LookAndFeel::GetIntCache()
|
|
|
|
{
|
|
|
|
return nsLookAndFeel::GetInstance()->GetIntCacheImpl();
|
|
|
|
}
|
|
|
|
|
|
|
|
// static
|
|
|
|
void
|
|
|
|
LookAndFeel::SetIntCache(const nsTArray<LookAndFeelInt>& aLookAndFeelIntCache)
|
|
|
|
{
|
|
|
|
return nsLookAndFeel::GetInstance()->SetIntCacheImpl(aLookAndFeelIntCache);
|
|
|
|
}
|
|
|
|
|
2011-09-09 02:27:11 +00:00
|
|
|
} // namespace mozilla
|