2011-11-10 16:17:46 -08:00
|
|
|
/* -*- Mode: C++; tab-width: 20; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
2012-07-20 02:10:44 -07:00
|
|
|
/* Copyright 2012 Mozilla Foundation and Mozilla contributors
|
|
|
|
*
|
|
|
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
* you may not use this file except in compliance with the License.
|
|
|
|
* You may obtain a copy of the License at
|
|
|
|
*
|
|
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
*
|
|
|
|
* Unless required by applicable law or agreed to in writing, software
|
|
|
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
* See the License for the specific language governing permissions and
|
|
|
|
* limitations under the License.
|
|
|
|
*/
|
2011-11-10 16:17:46 -08:00
|
|
|
|
|
|
|
#include "nsLookAndFeel.h"
|
2012-03-01 23:03:19 -08:00
|
|
|
#include "nsStyleConsts.h"
|
2012-02-20 15:19:48 -08:00
|
|
|
#include "gfxFont.h"
|
2013-10-07 16:15:59 -07:00
|
|
|
#include "gfxFontConstants.h"
|
|
|
|
#include "mozilla/gfx/2D.h"
|
2013-06-05 19:42:02 -07:00
|
|
|
#include "cutils/properties.h"
|
2011-11-10 16:17:46 -08:00
|
|
|
|
2012-12-03 19:24:51 -08:00
|
|
|
static const PRUnichar UNICODE_BULLET = 0x2022;
|
|
|
|
|
2011-11-10 16:17:46 -08:00
|
|
|
nsLookAndFeel::nsLookAndFeel()
|
|
|
|
: nsXPLookAndFeel()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
nsLookAndFeel::~nsLookAndFeel()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
nsresult
|
|
|
|
nsLookAndFeel::NativeGetColor(ColorID aID, nscolor &aColor)
|
|
|
|
{
|
|
|
|
nsresult rv = NS_OK;
|
|
|
|
|
|
|
|
#define BASE_ACTIVE_COLOR NS_RGB(0xaa,0xaa,0xaa)
|
|
|
|
#define BASE_NORMAL_COLOR NS_RGB(0xff,0xff,0xff)
|
|
|
|
#define BASE_SELECTED_COLOR NS_RGB(0xaa,0xaa,0xaa)
|
|
|
|
#define BG_ACTIVE_COLOR NS_RGB(0xff,0xff,0xff)
|
|
|
|
#define BG_INSENSITIVE_COLOR NS_RGB(0xaa,0xaa,0xaa)
|
|
|
|
#define BG_NORMAL_COLOR NS_RGB(0xff,0xff,0xff)
|
|
|
|
#define BG_PRELIGHT_COLOR NS_RGB(0xee,0xee,0xee)
|
|
|
|
#define BG_SELECTED_COLOR NS_RGB(0x99,0x99,0x99)
|
|
|
|
#define DARK_NORMAL_COLOR NS_RGB(0x88,0x88,0x88)
|
|
|
|
#define FG_INSENSITIVE_COLOR NS_RGB(0x44,0x44,0x44)
|
|
|
|
#define FG_NORMAL_COLOR NS_RGB(0x00,0x00,0x00)
|
|
|
|
#define FG_PRELIGHT_COLOR NS_RGB(0x77,0x77,0x77)
|
|
|
|
#define FG_SELECTED_COLOR NS_RGB(0xaa,0xaa,0xaa)
|
|
|
|
#define LIGHT_NORMAL_COLOR NS_RGB(0xaa,0xaa,0xaa)
|
|
|
|
#define TEXT_ACTIVE_COLOR NS_RGB(0x99,0x99,0x99)
|
|
|
|
#define TEXT_NORMAL_COLOR NS_RGB(0x00,0x00,0x00)
|
|
|
|
#define TEXT_SELECTED_COLOR NS_RGB(0x00,0x00,0x00)
|
|
|
|
|
|
|
|
switch (aID) {
|
|
|
|
// These colors don't seem to be used for anything anymore in Mozilla
|
|
|
|
// (except here at least TextSelectBackground and TextSelectForeground)
|
|
|
|
// The CSS2 colors below are used.
|
|
|
|
case eColorID_WindowBackground:
|
|
|
|
aColor = BASE_NORMAL_COLOR;
|
|
|
|
break;
|
|
|
|
case eColorID_WindowForeground:
|
|
|
|
aColor = TEXT_NORMAL_COLOR;
|
|
|
|
break;
|
|
|
|
case eColorID_WidgetBackground:
|
|
|
|
aColor = BG_NORMAL_COLOR;
|
|
|
|
break;
|
|
|
|
case eColorID_WidgetForeground:
|
|
|
|
aColor = FG_NORMAL_COLOR;
|
|
|
|
break;
|
|
|
|
case eColorID_WidgetSelectBackground:
|
|
|
|
aColor = BG_SELECTED_COLOR;
|
|
|
|
break;
|
|
|
|
case eColorID_WidgetSelectForeground:
|
|
|
|
aColor = FG_SELECTED_COLOR;
|
|
|
|
break;
|
|
|
|
case eColorID_Widget3DHighlight:
|
|
|
|
aColor = NS_RGB(0xa0,0xa0,0xa0);
|
|
|
|
break;
|
|
|
|
case eColorID_Widget3DShadow:
|
|
|
|
aColor = NS_RGB(0x40,0x40,0x40);
|
|
|
|
break;
|
|
|
|
case eColorID_TextBackground:
|
|
|
|
// not used?
|
|
|
|
aColor = BASE_NORMAL_COLOR;
|
|
|
|
break;
|
2013-09-22 02:44:26 -07:00
|
|
|
case eColorID_TextForeground:
|
2011-11-10 16:17:46 -08:00
|
|
|
// not used?
|
|
|
|
aColor = TEXT_NORMAL_COLOR;
|
|
|
|
break;
|
|
|
|
case eColorID_TextSelectBackground:
|
|
|
|
case eColorID_IMESelectedRawTextBackground:
|
|
|
|
case eColorID_IMESelectedConvertedTextBackground:
|
|
|
|
// still used
|
|
|
|
aColor = BASE_SELECTED_COLOR;
|
|
|
|
break;
|
|
|
|
case eColorID_TextSelectForeground:
|
|
|
|
case eColorID_IMESelectedRawTextForeground:
|
|
|
|
case eColorID_IMESelectedConvertedTextForeground:
|
|
|
|
// still used
|
|
|
|
aColor = TEXT_SELECTED_COLOR;
|
|
|
|
break;
|
|
|
|
case eColorID_IMERawInputBackground:
|
|
|
|
case eColorID_IMEConvertedTextBackground:
|
|
|
|
aColor = NS_TRANSPARENT;
|
|
|
|
break;
|
|
|
|
case eColorID_IMERawInputForeground:
|
|
|
|
case eColorID_IMEConvertedTextForeground:
|
|
|
|
aColor = NS_SAME_AS_FOREGROUND_COLOR;
|
|
|
|
break;
|
|
|
|
case eColorID_IMERawInputUnderline:
|
|
|
|
case eColorID_IMEConvertedTextUnderline:
|
|
|
|
aColor = NS_SAME_AS_FOREGROUND_COLOR;
|
|
|
|
break;
|
|
|
|
case eColorID_IMESelectedRawTextUnderline:
|
|
|
|
case eColorID_IMESelectedConvertedTextUnderline:
|
|
|
|
aColor = NS_TRANSPARENT;
|
|
|
|
break;
|
|
|
|
case eColorID_SpellCheckerUnderline:
|
|
|
|
aColor = NS_RGB(0xff, 0, 0);
|
|
|
|
break;
|
|
|
|
|
|
|
|
// css2 http://www.w3.org/TR/REC-CSS2/ui.html#system-colors
|
|
|
|
case eColorID_activeborder:
|
|
|
|
// active window border
|
|
|
|
aColor = BG_NORMAL_COLOR;
|
|
|
|
break;
|
|
|
|
case eColorID_activecaption:
|
|
|
|
// active window caption background
|
|
|
|
aColor = BG_NORMAL_COLOR;
|
|
|
|
break;
|
|
|
|
case eColorID_appworkspace:
|
|
|
|
// MDI background color
|
|
|
|
aColor = BG_NORMAL_COLOR;
|
|
|
|
break;
|
|
|
|
case eColorID_background:
|
|
|
|
// desktop background
|
|
|
|
aColor = BG_NORMAL_COLOR;
|
|
|
|
break;
|
|
|
|
case eColorID_captiontext:
|
|
|
|
// text in active window caption, size box, and scrollbar arrow box (!)
|
|
|
|
aColor = FG_NORMAL_COLOR;
|
|
|
|
break;
|
|
|
|
case eColorID_graytext:
|
|
|
|
// disabled text in windows, menus, etc.
|
|
|
|
aColor = FG_INSENSITIVE_COLOR;
|
|
|
|
break;
|
|
|
|
case eColorID_highlight:
|
|
|
|
// background of selected item
|
|
|
|
aColor = BASE_SELECTED_COLOR;
|
|
|
|
break;
|
|
|
|
case eColorID_highlighttext:
|
|
|
|
// text of selected item
|
|
|
|
aColor = TEXT_SELECTED_COLOR;
|
|
|
|
break;
|
|
|
|
case eColorID_inactiveborder:
|
|
|
|
// inactive window border
|
|
|
|
aColor = BG_NORMAL_COLOR;
|
|
|
|
break;
|
|
|
|
case eColorID_inactivecaption:
|
|
|
|
// inactive window caption
|
|
|
|
aColor = BG_INSENSITIVE_COLOR;
|
|
|
|
break;
|
|
|
|
case eColorID_inactivecaptiontext:
|
|
|
|
// text in inactive window caption
|
|
|
|
aColor = FG_INSENSITIVE_COLOR;
|
|
|
|
break;
|
|
|
|
case eColorID_infobackground:
|
|
|
|
// tooltip background color
|
|
|
|
aColor = BG_NORMAL_COLOR;
|
|
|
|
break;
|
|
|
|
case eColorID_infotext:
|
|
|
|
// tooltip text color
|
|
|
|
aColor = TEXT_NORMAL_COLOR;
|
|
|
|
break;
|
|
|
|
case eColorID_menu:
|
|
|
|
// menu background
|
|
|
|
aColor = BG_NORMAL_COLOR;
|
|
|
|
break;
|
|
|
|
case eColorID_menutext:
|
|
|
|
// menu text
|
|
|
|
aColor = TEXT_NORMAL_COLOR;
|
|
|
|
break;
|
|
|
|
case eColorID_scrollbar:
|
|
|
|
// scrollbar gray area
|
|
|
|
aColor = BG_ACTIVE_COLOR;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case eColorID_threedface:
|
|
|
|
case eColorID_buttonface:
|
|
|
|
// 3-D face color
|
|
|
|
aColor = BG_NORMAL_COLOR;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case eColorID_buttontext:
|
|
|
|
// text on push buttons
|
|
|
|
aColor = TEXT_NORMAL_COLOR;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case eColorID_buttonhighlight:
|
|
|
|
// 3-D highlighted edge color
|
|
|
|
case eColorID_threedhighlight:
|
|
|
|
// 3-D highlighted outer edge color
|
|
|
|
aColor = LIGHT_NORMAL_COLOR;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case eColorID_threedlightshadow:
|
|
|
|
// 3-D highlighted inner edge color
|
|
|
|
aColor = BG_NORMAL_COLOR;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case eColorID_buttonshadow:
|
|
|
|
// 3-D shadow edge color
|
|
|
|
case eColorID_threedshadow:
|
|
|
|
// 3-D shadow inner edge color
|
|
|
|
aColor = DARK_NORMAL_COLOR;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case eColorID_threeddarkshadow:
|
|
|
|
// 3-D shadow outer edge color
|
|
|
|
aColor = NS_RGB(0,0,0);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case eColorID_window:
|
|
|
|
case eColorID_windowframe:
|
|
|
|
aColor = BG_NORMAL_COLOR;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case eColorID_windowtext:
|
|
|
|
aColor = FG_NORMAL_COLOR;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case eColorID__moz_eventreerow:
|
|
|
|
case eColorID__moz_field:
|
|
|
|
aColor = BASE_NORMAL_COLOR;
|
|
|
|
break;
|
|
|
|
case eColorID__moz_fieldtext:
|
|
|
|
aColor = TEXT_NORMAL_COLOR;
|
|
|
|
break;
|
|
|
|
case eColorID__moz_dialog:
|
|
|
|
aColor = BG_NORMAL_COLOR;
|
|
|
|
break;
|
|
|
|
case eColorID__moz_dialogtext:
|
|
|
|
aColor = FG_NORMAL_COLOR;
|
|
|
|
break;
|
|
|
|
case eColorID__moz_dragtargetzone:
|
|
|
|
aColor = BG_SELECTED_COLOR;
|
2013-09-22 02:44:26 -07:00
|
|
|
break;
|
2011-11-10 16:17:46 -08:00
|
|
|
case eColorID__moz_buttondefault:
|
|
|
|
// default button border color
|
|
|
|
aColor = NS_RGB(0,0,0);
|
|
|
|
break;
|
|
|
|
case eColorID__moz_buttonhoverface:
|
|
|
|
aColor = BG_PRELIGHT_COLOR;
|
|
|
|
break;
|
|
|
|
case eColorID__moz_buttonhovertext:
|
|
|
|
aColor = FG_PRELIGHT_COLOR;
|
|
|
|
break;
|
|
|
|
case eColorID__moz_cellhighlight:
|
|
|
|
case eColorID__moz_html_cellhighlight:
|
|
|
|
aColor = BASE_ACTIVE_COLOR;
|
|
|
|
break;
|
|
|
|
case eColorID__moz_cellhighlighttext:
|
|
|
|
case eColorID__moz_html_cellhighlighttext:
|
|
|
|
aColor = TEXT_ACTIVE_COLOR;
|
|
|
|
break;
|
|
|
|
case eColorID__moz_menuhover:
|
|
|
|
aColor = BG_PRELIGHT_COLOR;
|
|
|
|
break;
|
|
|
|
case eColorID__moz_menuhovertext:
|
|
|
|
aColor = FG_PRELIGHT_COLOR;
|
|
|
|
break;
|
|
|
|
case eColorID__moz_oddtreerow:
|
|
|
|
aColor = NS_TRANSPARENT;
|
|
|
|
break;
|
|
|
|
case eColorID__moz_nativehyperlinktext:
|
|
|
|
aColor = NS_SAME_AS_FOREGROUND_COLOR;
|
|
|
|
break;
|
|
|
|
case eColorID__moz_comboboxtext:
|
|
|
|
aColor = TEXT_NORMAL_COLOR;
|
|
|
|
break;
|
|
|
|
case eColorID__moz_combobox:
|
|
|
|
aColor = BG_NORMAL_COLOR;
|
|
|
|
break;
|
|
|
|
case eColorID__moz_menubartext:
|
|
|
|
aColor = TEXT_NORMAL_COLOR;
|
|
|
|
break;
|
|
|
|
case eColorID__moz_menubarhovertext:
|
|
|
|
aColor = FG_PRELIGHT_COLOR;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
/* default color is BLACK */
|
|
|
|
aColor = 0;
|
|
|
|
rv = NS_ERROR_FAILURE;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
return rv;
|
|
|
|
}
|
|
|
|
|
2012-03-01 23:03:19 -08:00
|
|
|
nsresult
|
2012-08-22 08:56:38 -07:00
|
|
|
nsLookAndFeel::GetIntImpl(IntID aID, int32_t &aResult)
|
2012-03-01 23:03:19 -08:00
|
|
|
{
|
|
|
|
nsresult rv = nsXPLookAndFeel::GetIntImpl(aID, aResult);
|
|
|
|
if (NS_SUCCEEDED(rv))
|
|
|
|
return rv;
|
|
|
|
|
|
|
|
rv = NS_OK;
|
|
|
|
|
|
|
|
switch (aID) {
|
|
|
|
case eIntID_CaretBlinkTime:
|
|
|
|
aResult = 500;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case eIntID_CaretWidth:
|
|
|
|
aResult = 1;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case eIntID_ShowCaretDuringSelection:
|
|
|
|
aResult = 0;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case eIntID_SelectTextfieldsOnKeyFocus:
|
|
|
|
// Select textfield content when focused by kbd
|
|
|
|
// used by nsEventStateManager::sTextfieldSelectModel
|
|
|
|
aResult = 1;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case eIntID_SubmenuDelay:
|
|
|
|
aResult = 200;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case eIntID_TooltipDelay:
|
|
|
|
aResult = 500;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case eIntID_MenusCanOverlapOSBar:
|
|
|
|
// we want XUL popups to be able to overlap the task bar.
|
|
|
|
aResult = 1;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case eIntID_ScrollArrowStyle:
|
|
|
|
aResult = eScrollArrowStyle_Single;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case eIntID_ScrollSliderStyle:
|
|
|
|
aResult = eScrollThumbStyle_Proportional;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case eIntID_TouchEnabled:
|
2012-03-20 16:44:43 -07:00
|
|
|
aResult = 1;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case eIntID_WindowsDefaultTheme:
|
2012-03-01 23:03:19 -08:00
|
|
|
case eIntID_WindowsThemeIdentifier:
|
2013-07-01 09:02:29 -07:00
|
|
|
case eIntID_OperatingSystemVersionIdentifier:
|
2012-03-01 23:03:19 -08:00
|
|
|
aResult = 0;
|
|
|
|
rv = NS_ERROR_NOT_IMPLEMENTED;
|
|
|
|
break;
|
|
|
|
|
2013-09-22 02:44:26 -07:00
|
|
|
case eIntID_IMERawInputUnderlineStyle:
|
|
|
|
case eIntID_IMEConvertedTextUnderlineStyle:
|
|
|
|
aResult = NS_STYLE_TEXT_DECORATION_STYLE_SOLID;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case eIntID_IMESelectedRawTextUnderlineStyle:
|
|
|
|
case eIntID_IMESelectedConvertedTextUnderline:
|
|
|
|
aResult = NS_STYLE_TEXT_DECORATION_STYLE_NONE;
|
|
|
|
break;
|
|
|
|
|
2012-03-01 23:03:19 -08:00
|
|
|
case eIntID_SpellCheckerUnderlineStyle:
|
|
|
|
aResult = NS_STYLE_TEXT_DECORATION_STYLE_WAVY;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case eIntID_ScrollbarButtonAutoRepeatBehavior:
|
|
|
|
aResult = 0;
|
|
|
|
break;
|
|
|
|
|
2013-06-05 19:42:02 -07:00
|
|
|
case eIntID_PhysicalHomeButton: {
|
|
|
|
char propValue[PROPERTY_VALUE_MAX];
|
|
|
|
property_get("ro.moz.has_home_button", propValue, "1");
|
|
|
|
aResult = atoi(propValue);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2012-03-01 23:03:19 -08:00
|
|
|
default:
|
|
|
|
aResult = 0;
|
|
|
|
rv = NS_ERROR_FAILURE;
|
|
|
|
}
|
|
|
|
|
|
|
|
return rv;
|
|
|
|
}
|
|
|
|
|
2013-09-22 02:44:26 -07:00
|
|
|
nsresult
|
|
|
|
nsLookAndFeel::GetFloatImpl(FloatID aID, float &aResult)
|
|
|
|
{
|
|
|
|
nsresult res = nsXPLookAndFeel::GetFloatImpl(aID, aResult);
|
|
|
|
if (NS_SUCCEEDED(res))
|
|
|
|
return res;
|
|
|
|
res = NS_OK;
|
|
|
|
|
|
|
|
switch (aID) {
|
|
|
|
case eFloatID_IMEUnderlineRelativeSize:
|
|
|
|
aResult = 1.0f;
|
|
|
|
break;
|
|
|
|
case eFloatID_SpellCheckerUnderlineRelativeSize:
|
|
|
|
aResult = 1.0f;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
aResult = -1.0;
|
|
|
|
res = NS_ERROR_FAILURE;
|
|
|
|
}
|
|
|
|
return res;
|
|
|
|
}
|
|
|
|
|
2012-02-20 15:19:48 -08:00
|
|
|
/*virtual*/
|
|
|
|
bool
|
|
|
|
nsLookAndFeel::GetFontImpl(FontID aID, nsString& aFontName,
|
2012-09-29 04:35:08 -07:00
|
|
|
gfxFontStyle& aFontStyle,
|
|
|
|
float aDevPixPerCSSPixel)
|
2012-02-20 15:19:48 -08:00
|
|
|
{
|
2013-09-24 10:57:25 -07:00
|
|
|
aFontName.AssignLiteral("\"Fira Sans OT\"");
|
2012-02-20 15:19:48 -08:00
|
|
|
aFontStyle.style = NS_FONT_STYLE_NORMAL;
|
|
|
|
aFontStyle.weight = NS_FONT_WEIGHT_NORMAL;
|
|
|
|
aFontStyle.stretch = NS_FONT_STRETCH_NORMAL;
|
|
|
|
aFontStyle.size = 9.0 * 96.0f / 72.0f;
|
|
|
|
aFontStyle.systemFont = true;
|
|
|
|
return true;
|
|
|
|
}
|
2012-07-14 16:05:54 -07:00
|
|
|
|
|
|
|
/*virtual*/
|
|
|
|
bool
|
|
|
|
nsLookAndFeel::GetEchoPasswordImpl() {
|
|
|
|
return true;
|
|
|
|
}
|
2012-11-28 22:13:35 -08:00
|
|
|
|
|
|
|
/*virtual*/
|
|
|
|
uint32_t
|
|
|
|
nsLookAndFeel::GetPasswordMaskDelayImpl()
|
|
|
|
{
|
|
|
|
// Same value on Android framework
|
|
|
|
return 1500;
|
|
|
|
}
|
2012-12-03 19:24:51 -08:00
|
|
|
|
|
|
|
/* virtual */
|
|
|
|
PRUnichar
|
|
|
|
nsLookAndFeel::GetPasswordCharacterImpl()
|
|
|
|
{
|
|
|
|
return UNICODE_BULLET;
|
|
|
|
}
|