2010-06-03 13:56:36 -07:00
|
|
|
/* -*- Mode: C++; tab-width: 20; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
|
|
|
/* ***** BEGIN LICENSE BLOCK *****
|
|
|
|
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
|
|
|
*
|
|
|
|
* The contents of this file are subject to the Mozilla Public License Version
|
|
|
|
* 1.1 (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.mozilla.org/MPL/
|
|
|
|
*
|
|
|
|
* Software distributed under the License is distributed on an "AS IS" basis,
|
|
|
|
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
|
|
|
* for the specific language governing rights and limitations under the
|
|
|
|
* License.
|
|
|
|
*
|
|
|
|
* The Original Code is mozilla.org code.
|
|
|
|
*
|
|
|
|
* The Initial Developer of the Original Code is
|
|
|
|
* Mozilla Foundation
|
|
|
|
* Portions created by the Initial Developer are Copyright (C) 2010
|
|
|
|
* the Initial Developer. All Rights Reserved.
|
|
|
|
*
|
|
|
|
* Contributor(s):
|
|
|
|
* Vladimir Vukicevic <vladimir@pobox.com>
|
2011-03-30 11:04:41 -07:00
|
|
|
* Alex Pakhotin <alexp@mozilla.com>
|
2010-06-03 13:56:36 -07:00
|
|
|
*
|
|
|
|
* Alternatively, the contents of this file may be used under the terms of
|
|
|
|
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
|
|
|
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
|
|
|
* in which case the provisions of the GPL or the LGPL are applicable instead
|
|
|
|
* of those above. If you wish to allow use of your version of this file only
|
|
|
|
* under the terms of either the GPL or the LGPL, and not to allow others to
|
|
|
|
* use your version of this file under the terms of the MPL, indicate your
|
|
|
|
* decision by deleting the provisions above and replace them with the notice
|
|
|
|
* and other provisions required by the GPL or the LGPL. If you do not delete
|
|
|
|
* the provisions above, a recipient may use your version of this file under
|
|
|
|
* the terms of any one of the MPL, the GPL or the LGPL.
|
|
|
|
*
|
|
|
|
* ***** END LICENSE BLOCK ***** */
|
|
|
|
|
2011-03-30 11:04:41 -07:00
|
|
|
#include "mozilla/dom/ContentChild.h"
|
2011-03-31 05:26:49 -07:00
|
|
|
#include "nsStyleConsts.h"
|
2011-03-30 11:04:41 -07:00
|
|
|
#include "nsXULAppAPI.h"
|
|
|
|
#include "nsLookAndFeel.h"
|
2012-02-20 15:19:48 -08:00
|
|
|
#include "gfxFont.h"
|
2011-03-30 11:04:41 -07:00
|
|
|
|
|
|
|
using namespace mozilla;
|
|
|
|
using mozilla::dom::ContentChild;
|
|
|
|
|
2011-09-28 23:19:26 -07:00
|
|
|
bool nsLookAndFeel::mInitializedSystemColors = false;
|
2011-03-30 11:04:41 -07:00
|
|
|
AndroidSystemColors nsLookAndFeel::mSystemColors;
|
2010-06-03 13:56:36 -07:00
|
|
|
|
2011-09-28 23:19:26 -07:00
|
|
|
bool nsLookAndFeel::mInitializedShowPassword = false;
|
|
|
|
bool nsLookAndFeel::mShowPassword = true;
|
2011-07-26 18:14:52 -07:00
|
|
|
|
2010-06-03 13:56:36 -07:00
|
|
|
nsLookAndFeel::nsLookAndFeel()
|
|
|
|
: nsXPLookAndFeel()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
nsLookAndFeel::~nsLookAndFeel()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2011-03-30 11:04:41 -07:00
|
|
|
#define BG_PRELIGHT_COLOR NS_RGB(0xee,0xee,0xee)
|
|
|
|
#define FG_PRELIGHT_COLOR NS_RGB(0x77,0x77,0x77)
|
|
|
|
#define BLACK_COLOR NS_RGB(0x00,0x00,0x00)
|
|
|
|
#define DARK_GRAY_COLOR NS_RGB(0x40,0x40,0x40)
|
|
|
|
#define GRAY_COLOR NS_RGB(0x80,0x80,0x80)
|
|
|
|
#define LIGHT_GRAY_COLOR NS_RGB(0xa0,0xa0,0xa0)
|
|
|
|
#define RED_COLOR NS_RGB(0xff,0x00,0x00)
|
|
|
|
|
|
|
|
nsresult
|
|
|
|
nsLookAndFeel::GetSystemColors()
|
|
|
|
{
|
2011-07-26 18:14:52 -07:00
|
|
|
if (mInitializedSystemColors)
|
2011-03-30 11:04:41 -07:00
|
|
|
return NS_OK;
|
|
|
|
|
|
|
|
if (!AndroidBridge::Bridge())
|
|
|
|
return NS_ERROR_FAILURE;
|
|
|
|
|
|
|
|
AndroidBridge::Bridge()->GetSystemColors(&mSystemColors);
|
|
|
|
|
2011-10-17 07:59:28 -07:00
|
|
|
mInitializedSystemColors = true;
|
2011-03-30 11:04:41 -07:00
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
nsresult
|
|
|
|
nsLookAndFeel::CallRemoteGetSystemColors()
|
|
|
|
{
|
|
|
|
// An array has to be used to get data from remote process
|
|
|
|
InfallibleTArray<PRUint32> colors;
|
|
|
|
PRUint32 colorsCount = sizeof(AndroidSystemColors) / sizeof(nscolor);
|
|
|
|
|
|
|
|
if (!ContentChild::GetSingleton()->SendGetSystemColors(colorsCount, &colors))
|
|
|
|
return NS_ERROR_FAILURE;
|
|
|
|
|
|
|
|
NS_ASSERTION(colors.Length() == colorsCount, "System colors array is incomplete");
|
|
|
|
if (colors.Length() == 0)
|
|
|
|
return NS_ERROR_FAILURE;
|
|
|
|
|
|
|
|
if (colors.Length() < colorsCount)
|
|
|
|
colorsCount = colors.Length();
|
|
|
|
|
|
|
|
// Array elements correspond to the members of mSystemColors structure,
|
|
|
|
// so just copy the memory block
|
|
|
|
memcpy(&mSystemColors, colors.Elements(), sizeof(nscolor) * colorsCount);
|
|
|
|
|
2011-10-17 07:59:28 -07:00
|
|
|
mInitializedSystemColors = true;
|
2011-03-30 11:04:41 -07:00
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2010-06-03 13:56:36 -07:00
|
|
|
nsresult
|
2011-09-08 19:27:13 -07:00
|
|
|
nsLookAndFeel::NativeGetColor(ColorID aID, nscolor &aColor)
|
2010-06-03 13:56:36 -07:00
|
|
|
{
|
|
|
|
nsresult rv = NS_OK;
|
|
|
|
|
2011-07-26 18:14:52 -07:00
|
|
|
if (!mInitializedSystemColors) {
|
2011-03-30 11:04:41 -07:00
|
|
|
if (XRE_GetProcessType() == GeckoProcessType_Default)
|
|
|
|
rv = GetSystemColors();
|
|
|
|
else
|
|
|
|
rv = CallRemoteGetSystemColors();
|
|
|
|
NS_ENSURE_SUCCESS(rv, rv);
|
|
|
|
}
|
2010-06-03 13:56:36 -07:00
|
|
|
|
|
|
|
// XXX we'll want to use context.obtainStyledAttributes on the java side to
|
|
|
|
// get all of these; see TextView.java for a good exmaple.
|
|
|
|
|
|
|
|
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.
|
2011-09-08 19:27:13 -07:00
|
|
|
case eColorID_WindowBackground:
|
2011-03-30 11:04:41 -07:00
|
|
|
aColor = mSystemColors.colorBackground;
|
2010-06-03 13:56:36 -07:00
|
|
|
break;
|
2011-09-08 19:27:13 -07:00
|
|
|
case eColorID_WindowForeground:
|
2011-03-30 11:04:41 -07:00
|
|
|
aColor = mSystemColors.textColorPrimary;
|
2010-06-03 13:56:36 -07:00
|
|
|
break;
|
2011-09-08 19:27:13 -07:00
|
|
|
case eColorID_WidgetBackground:
|
2011-03-30 11:04:41 -07:00
|
|
|
aColor = mSystemColors.colorBackground;
|
2010-06-03 13:56:36 -07:00
|
|
|
break;
|
2011-09-08 19:27:13 -07:00
|
|
|
case eColorID_WidgetForeground:
|
2011-03-30 11:04:41 -07:00
|
|
|
aColor = mSystemColors.colorForeground;
|
2010-06-03 13:56:36 -07:00
|
|
|
break;
|
2011-09-08 19:27:13 -07:00
|
|
|
case eColorID_WidgetSelectBackground:
|
2011-03-30 11:04:41 -07:00
|
|
|
aColor = mSystemColors.textColorHighlight;
|
2010-06-03 13:56:36 -07:00
|
|
|
break;
|
2011-09-08 19:27:13 -07:00
|
|
|
case eColorID_WidgetSelectForeground:
|
2011-03-30 11:04:41 -07:00
|
|
|
aColor = mSystemColors.textColorPrimaryInverse;
|
2010-06-03 13:56:36 -07:00
|
|
|
break;
|
2011-09-08 19:27:13 -07:00
|
|
|
case eColorID_Widget3DHighlight:
|
2011-03-30 11:04:41 -07:00
|
|
|
aColor = LIGHT_GRAY_COLOR;
|
2010-06-03 13:56:36 -07:00
|
|
|
break;
|
2011-09-08 19:27:13 -07:00
|
|
|
case eColorID_Widget3DShadow:
|
2011-03-30 11:04:41 -07:00
|
|
|
aColor = DARK_GRAY_COLOR;
|
2010-06-03 13:56:36 -07:00
|
|
|
break;
|
2011-09-08 19:27:13 -07:00
|
|
|
case eColorID_TextBackground:
|
2010-06-03 13:56:36 -07:00
|
|
|
// not used?
|
2011-03-30 11:04:41 -07:00
|
|
|
aColor = mSystemColors.colorBackground;
|
2010-06-03 13:56:36 -07:00
|
|
|
break;
|
2011-09-08 19:27:13 -07:00
|
|
|
case eColorID_TextForeground:
|
2010-06-03 13:56:36 -07:00
|
|
|
// not used?
|
2011-03-30 11:04:41 -07:00
|
|
|
aColor = mSystemColors.textColorPrimary;
|
2010-06-03 13:56:36 -07:00
|
|
|
break;
|
2011-09-08 19:27:13 -07:00
|
|
|
case eColorID_TextSelectBackground:
|
|
|
|
case eColorID_IMESelectedRawTextBackground:
|
|
|
|
case eColorID_IMESelectedConvertedTextBackground:
|
2010-06-03 13:56:36 -07:00
|
|
|
// still used
|
2011-03-30 11:04:41 -07:00
|
|
|
aColor = mSystemColors.textColorHighlight;
|
2010-06-03 13:56:36 -07:00
|
|
|
break;
|
2011-09-08 19:27:13 -07:00
|
|
|
case eColorID_TextSelectForeground:
|
|
|
|
case eColorID_IMESelectedRawTextForeground:
|
|
|
|
case eColorID_IMESelectedConvertedTextForeground:
|
2010-06-03 13:56:36 -07:00
|
|
|
// still used
|
2011-03-30 11:04:41 -07:00
|
|
|
aColor = mSystemColors.textColorPrimaryInverse;
|
2010-06-03 13:56:36 -07:00
|
|
|
break;
|
2011-09-08 19:27:13 -07:00
|
|
|
case eColorID_IMERawInputBackground:
|
|
|
|
case eColorID_IMEConvertedTextBackground:
|
2010-06-03 13:56:36 -07:00
|
|
|
aColor = NS_TRANSPARENT;
|
|
|
|
break;
|
2011-09-08 19:27:13 -07:00
|
|
|
case eColorID_IMERawInputForeground:
|
|
|
|
case eColorID_IMEConvertedTextForeground:
|
2010-06-03 13:56:36 -07:00
|
|
|
aColor = NS_SAME_AS_FOREGROUND_COLOR;
|
|
|
|
break;
|
2011-09-08 19:27:13 -07:00
|
|
|
case eColorID_IMERawInputUnderline:
|
|
|
|
case eColorID_IMEConvertedTextUnderline:
|
2010-06-03 13:56:36 -07:00
|
|
|
aColor = NS_SAME_AS_FOREGROUND_COLOR;
|
|
|
|
break;
|
2011-09-08 19:27:13 -07:00
|
|
|
case eColorID_IMESelectedRawTextUnderline:
|
|
|
|
case eColorID_IMESelectedConvertedTextUnderline:
|
2010-06-03 13:56:36 -07:00
|
|
|
aColor = NS_TRANSPARENT;
|
|
|
|
break;
|
2011-09-08 19:27:13 -07:00
|
|
|
case eColorID_SpellCheckerUnderline:
|
2011-03-30 11:04:41 -07:00
|
|
|
aColor = RED_COLOR;
|
2010-06-03 13:56:36 -07:00
|
|
|
break;
|
|
|
|
|
|
|
|
// css2 http://www.w3.org/TR/REC-CSS2/ui.html#system-colors
|
2011-09-08 19:27:13 -07:00
|
|
|
case eColorID_activeborder:
|
2010-06-03 13:56:36 -07:00
|
|
|
// active window border
|
2011-03-30 11:04:41 -07:00
|
|
|
aColor = mSystemColors.colorBackground;
|
2010-06-03 13:56:36 -07:00
|
|
|
break;
|
2011-09-08 19:27:13 -07:00
|
|
|
case eColorID_activecaption:
|
2010-06-03 13:56:36 -07:00
|
|
|
// active window caption background
|
2011-03-30 11:04:41 -07:00
|
|
|
aColor = mSystemColors.colorBackground;
|
2010-06-03 13:56:36 -07:00
|
|
|
break;
|
2011-09-08 19:27:13 -07:00
|
|
|
case eColorID_appworkspace:
|
2010-06-03 13:56:36 -07:00
|
|
|
// MDI background color
|
2011-03-30 11:04:41 -07:00
|
|
|
aColor = mSystemColors.colorBackground;
|
2010-06-03 13:56:36 -07:00
|
|
|
break;
|
2011-09-08 19:27:13 -07:00
|
|
|
case eColorID_background:
|
2010-06-03 13:56:36 -07:00
|
|
|
// desktop background
|
2011-03-30 11:04:41 -07:00
|
|
|
aColor = mSystemColors.colorBackground;
|
2010-06-03 13:56:36 -07:00
|
|
|
break;
|
2011-09-08 19:27:13 -07:00
|
|
|
case eColorID_captiontext:
|
2010-06-03 13:56:36 -07:00
|
|
|
// text in active window caption, size box, and scrollbar arrow box (!)
|
2011-03-30 11:04:41 -07:00
|
|
|
aColor = mSystemColors.colorForeground;
|
2010-06-03 13:56:36 -07:00
|
|
|
break;
|
2011-09-08 19:27:13 -07:00
|
|
|
case eColorID_graytext:
|
2010-06-03 13:56:36 -07:00
|
|
|
// disabled text in windows, menus, etc.
|
2011-03-30 11:04:41 -07:00
|
|
|
aColor = mSystemColors.textColorTertiary;
|
2010-06-03 13:56:36 -07:00
|
|
|
break;
|
2011-09-08 19:27:13 -07:00
|
|
|
case eColorID_highlight:
|
2010-06-03 13:56:36 -07:00
|
|
|
// background of selected item
|
2011-03-30 11:04:41 -07:00
|
|
|
aColor = mSystemColors.textColorHighlight;
|
2010-06-03 13:56:36 -07:00
|
|
|
break;
|
2011-09-08 19:27:13 -07:00
|
|
|
case eColorID_highlighttext:
|
2010-06-03 13:56:36 -07:00
|
|
|
// text of selected item
|
2011-03-30 11:04:41 -07:00
|
|
|
aColor = mSystemColors.textColorPrimaryInverse;
|
2010-06-03 13:56:36 -07:00
|
|
|
break;
|
2011-09-08 19:27:13 -07:00
|
|
|
case eColorID_inactiveborder:
|
2010-06-03 13:56:36 -07:00
|
|
|
// inactive window border
|
2011-03-30 11:04:41 -07:00
|
|
|
aColor = mSystemColors.colorBackground;
|
2010-06-03 13:56:36 -07:00
|
|
|
break;
|
2011-09-08 19:27:13 -07:00
|
|
|
case eColorID_inactivecaption:
|
2010-06-03 13:56:36 -07:00
|
|
|
// inactive window caption
|
2011-03-30 11:04:41 -07:00
|
|
|
aColor = mSystemColors.colorBackground;
|
2010-06-03 13:56:36 -07:00
|
|
|
break;
|
2011-09-08 19:27:13 -07:00
|
|
|
case eColorID_inactivecaptiontext:
|
2010-06-03 13:56:36 -07:00
|
|
|
// text in inactive window caption
|
2011-03-30 11:04:41 -07:00
|
|
|
aColor = mSystemColors.textColorTertiary;
|
2010-06-03 13:56:36 -07:00
|
|
|
break;
|
2011-09-08 19:27:13 -07:00
|
|
|
case eColorID_infobackground:
|
2010-06-03 13:56:36 -07:00
|
|
|
// tooltip background color
|
2011-03-30 11:04:41 -07:00
|
|
|
aColor = mSystemColors.colorBackground;
|
2010-06-03 13:56:36 -07:00
|
|
|
break;
|
2011-09-08 19:27:13 -07:00
|
|
|
case eColorID_infotext:
|
2010-06-03 13:56:36 -07:00
|
|
|
// tooltip text color
|
2011-03-30 11:04:41 -07:00
|
|
|
aColor = mSystemColors.colorForeground;
|
2010-06-03 13:56:36 -07:00
|
|
|
break;
|
2011-09-08 19:27:13 -07:00
|
|
|
case eColorID_menu:
|
2010-06-03 13:56:36 -07:00
|
|
|
// menu background
|
2011-03-30 11:04:41 -07:00
|
|
|
aColor = mSystemColors.colorBackground;
|
2010-06-03 13:56:36 -07:00
|
|
|
break;
|
2011-09-08 19:27:13 -07:00
|
|
|
case eColorID_menutext:
|
2010-06-03 13:56:36 -07:00
|
|
|
// menu text
|
2011-03-30 11:04:41 -07:00
|
|
|
aColor = mSystemColors.colorForeground;
|
2010-06-03 13:56:36 -07:00
|
|
|
break;
|
2011-09-08 19:27:13 -07:00
|
|
|
case eColorID_scrollbar:
|
2010-06-03 13:56:36 -07:00
|
|
|
// scrollbar gray area
|
2011-03-30 11:04:41 -07:00
|
|
|
aColor = mSystemColors.colorBackground;
|
2010-06-03 13:56:36 -07:00
|
|
|
break;
|
|
|
|
|
2011-09-08 19:27:13 -07:00
|
|
|
case eColorID_threedface:
|
|
|
|
case eColorID_buttonface:
|
2010-06-03 13:56:36 -07:00
|
|
|
// 3-D face color
|
2011-03-30 11:04:41 -07:00
|
|
|
aColor = mSystemColors.colorBackground;
|
2010-06-03 13:56:36 -07:00
|
|
|
break;
|
|
|
|
|
2011-09-08 19:27:13 -07:00
|
|
|
case eColorID_buttontext:
|
2010-06-03 13:56:36 -07:00
|
|
|
// text on push buttons
|
2011-03-30 11:04:41 -07:00
|
|
|
aColor = mSystemColors.colorForeground;
|
2010-06-03 13:56:36 -07:00
|
|
|
break;
|
|
|
|
|
2011-09-08 19:27:13 -07:00
|
|
|
case eColorID_buttonhighlight:
|
2010-06-03 13:56:36 -07:00
|
|
|
// 3-D highlighted edge color
|
2011-09-08 19:27:13 -07:00
|
|
|
case eColorID_threedhighlight:
|
2010-06-03 13:56:36 -07:00
|
|
|
// 3-D highlighted outer edge color
|
2011-03-30 11:04:41 -07:00
|
|
|
aColor = LIGHT_GRAY_COLOR;
|
2010-06-03 13:56:36 -07:00
|
|
|
break;
|
|
|
|
|
2011-09-08 19:27:13 -07:00
|
|
|
case eColorID_threedlightshadow:
|
2010-06-03 13:56:36 -07:00
|
|
|
// 3-D highlighted inner edge color
|
2011-03-30 11:04:41 -07:00
|
|
|
aColor = mSystemColors.colorBackground;
|
2010-06-03 13:56:36 -07:00
|
|
|
break;
|
|
|
|
|
2011-09-08 19:27:13 -07:00
|
|
|
case eColorID_buttonshadow:
|
2010-06-03 13:56:36 -07:00
|
|
|
// 3-D shadow edge color
|
2011-09-08 19:27:13 -07:00
|
|
|
case eColorID_threedshadow:
|
2010-06-03 13:56:36 -07:00
|
|
|
// 3-D shadow inner edge color
|
2011-03-30 11:04:41 -07:00
|
|
|
aColor = GRAY_COLOR;
|
2010-06-03 13:56:36 -07:00
|
|
|
break;
|
|
|
|
|
2011-09-08 19:27:13 -07:00
|
|
|
case eColorID_threeddarkshadow:
|
2010-06-03 13:56:36 -07:00
|
|
|
// 3-D shadow outer edge color
|
2011-03-30 11:04:41 -07:00
|
|
|
aColor = BLACK_COLOR;
|
2010-06-03 13:56:36 -07:00
|
|
|
break;
|
|
|
|
|
2011-09-08 19:27:13 -07:00
|
|
|
case eColorID_window:
|
|
|
|
case eColorID_windowframe:
|
2011-03-30 11:04:41 -07:00
|
|
|
aColor = mSystemColors.colorBackground;
|
2010-06-03 13:56:36 -07:00
|
|
|
break;
|
|
|
|
|
2011-09-08 19:27:13 -07:00
|
|
|
case eColorID_windowtext:
|
2011-03-30 11:04:41 -07:00
|
|
|
aColor = mSystemColors.textColorPrimary;
|
2010-06-03 13:56:36 -07:00
|
|
|
break;
|
|
|
|
|
2011-09-08 19:27:13 -07:00
|
|
|
case eColorID__moz_eventreerow:
|
|
|
|
case eColorID__moz_field:
|
2011-03-30 11:04:41 -07:00
|
|
|
aColor = mSystemColors.colorBackground;
|
2010-06-03 13:56:36 -07:00
|
|
|
break;
|
2011-09-08 19:27:13 -07:00
|
|
|
case eColorID__moz_fieldtext:
|
2011-03-30 11:04:41 -07:00
|
|
|
aColor = mSystemColors.textColorPrimary;
|
2010-06-03 13:56:36 -07:00
|
|
|
break;
|
2011-09-08 19:27:13 -07:00
|
|
|
case eColorID__moz_dialog:
|
2011-03-30 11:04:41 -07:00
|
|
|
aColor = mSystemColors.colorBackground;
|
2010-06-03 13:56:36 -07:00
|
|
|
break;
|
2011-09-08 19:27:13 -07:00
|
|
|
case eColorID__moz_dialogtext:
|
2011-03-30 11:04:41 -07:00
|
|
|
aColor = mSystemColors.colorForeground;
|
2010-06-03 13:56:36 -07:00
|
|
|
break;
|
2011-09-08 19:27:13 -07:00
|
|
|
case eColorID__moz_dragtargetzone:
|
2011-03-30 11:04:41 -07:00
|
|
|
aColor = mSystemColors.textColorHighlight;
|
2010-06-03 13:56:36 -07:00
|
|
|
break;
|
2011-09-08 19:27:13 -07:00
|
|
|
case eColorID__moz_buttondefault:
|
2010-06-03 13:56:36 -07:00
|
|
|
// default button border color
|
2011-03-30 11:04:41 -07:00
|
|
|
aColor = BLACK_COLOR;
|
2010-06-03 13:56:36 -07:00
|
|
|
break;
|
2011-09-08 19:27:13 -07:00
|
|
|
case eColorID__moz_buttonhoverface:
|
2010-06-03 13:56:36 -07:00
|
|
|
aColor = BG_PRELIGHT_COLOR;
|
|
|
|
break;
|
2011-09-08 19:27:13 -07:00
|
|
|
case eColorID__moz_buttonhovertext:
|
2010-06-03 13:56:36 -07:00
|
|
|
aColor = FG_PRELIGHT_COLOR;
|
|
|
|
break;
|
2011-09-08 19:27:13 -07:00
|
|
|
case eColorID__moz_cellhighlight:
|
|
|
|
case eColorID__moz_html_cellhighlight:
|
2011-03-30 11:04:41 -07:00
|
|
|
aColor = mSystemColors.textColorHighlight;
|
2010-06-03 13:56:36 -07:00
|
|
|
break;
|
2011-09-08 19:27:13 -07:00
|
|
|
case eColorID__moz_cellhighlighttext:
|
|
|
|
case eColorID__moz_html_cellhighlighttext:
|
2011-03-30 11:04:41 -07:00
|
|
|
aColor = mSystemColors.textColorPrimaryInverse;
|
2010-06-03 13:56:36 -07:00
|
|
|
break;
|
2011-09-08 19:27:13 -07:00
|
|
|
case eColorID__moz_menuhover:
|
2010-06-03 13:56:36 -07:00
|
|
|
aColor = BG_PRELIGHT_COLOR;
|
|
|
|
break;
|
2011-09-08 19:27:13 -07:00
|
|
|
case eColorID__moz_menuhovertext:
|
2010-06-03 13:56:36 -07:00
|
|
|
aColor = FG_PRELIGHT_COLOR;
|
|
|
|
break;
|
2011-09-08 19:27:13 -07:00
|
|
|
case eColorID__moz_oddtreerow:
|
2010-06-03 13:56:36 -07:00
|
|
|
aColor = NS_TRANSPARENT;
|
|
|
|
break;
|
2011-09-08 19:27:13 -07:00
|
|
|
case eColorID__moz_nativehyperlinktext:
|
2010-06-03 13:56:36 -07:00
|
|
|
aColor = NS_SAME_AS_FOREGROUND_COLOR;
|
|
|
|
break;
|
2011-09-08 19:27:13 -07:00
|
|
|
case eColorID__moz_comboboxtext:
|
2011-03-30 11:04:41 -07:00
|
|
|
aColor = mSystemColors.colorForeground;
|
2010-06-03 13:56:36 -07:00
|
|
|
break;
|
2011-09-08 19:27:13 -07:00
|
|
|
case eColorID__moz_combobox:
|
2011-03-30 11:04:41 -07:00
|
|
|
aColor = mSystemColors.colorBackground;
|
2010-06-03 13:56:36 -07:00
|
|
|
break;
|
2011-09-08 19:27:13 -07:00
|
|
|
case eColorID__moz_menubartext:
|
2011-03-30 11:04:41 -07:00
|
|
|
aColor = mSystemColors.colorForeground;
|
2010-06-03 13:56:36 -07:00
|
|
|
break;
|
2011-09-08 19:27:13 -07:00
|
|
|
case eColorID__moz_menubarhovertext:
|
2010-06-03 13:56:36 -07:00
|
|
|
aColor = FG_PRELIGHT_COLOR;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
/* default color is BLACK */
|
|
|
|
aColor = 0;
|
|
|
|
rv = NS_ERROR_FAILURE;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
return rv;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-09-08 19:27:13 -07:00
|
|
|
nsresult
|
|
|
|
nsLookAndFeel::GetIntImpl(IntID aID, PRInt32 &aResult)
|
2010-06-03 13:56:36 -07:00
|
|
|
{
|
2011-09-08 19:27:13 -07:00
|
|
|
nsresult rv = nsXPLookAndFeel::GetIntImpl(aID, aResult);
|
2010-06-03 13:56:36 -07:00
|
|
|
if (NS_SUCCEEDED(rv))
|
|
|
|
return rv;
|
|
|
|
|
|
|
|
rv = NS_OK;
|
|
|
|
|
|
|
|
switch (aID) {
|
2011-09-08 19:27:13 -07:00
|
|
|
case eIntID_CaretBlinkTime:
|
|
|
|
aResult = 500;
|
2010-06-03 13:56:36 -07:00
|
|
|
break;
|
|
|
|
|
2011-09-08 19:27:13 -07:00
|
|
|
case eIntID_CaretWidth:
|
|
|
|
aResult = 1;
|
2010-06-03 13:56:36 -07:00
|
|
|
break;
|
|
|
|
|
2011-09-08 19:27:13 -07:00
|
|
|
case eIntID_ShowCaretDuringSelection:
|
|
|
|
aResult = 0;
|
2010-06-03 13:56:36 -07:00
|
|
|
break;
|
|
|
|
|
2011-09-08 19:27:13 -07:00
|
|
|
case eIntID_SelectTextfieldsOnKeyFocus:
|
2010-06-03 13:56:36 -07:00
|
|
|
// Select textfield content when focused by kbd
|
|
|
|
// used by nsEventStateManager::sTextfieldSelectModel
|
2011-09-08 19:27:13 -07:00
|
|
|
aResult = 1;
|
2010-06-03 13:56:36 -07:00
|
|
|
break;
|
|
|
|
|
2011-09-08 19:27:13 -07:00
|
|
|
case eIntID_SubmenuDelay:
|
|
|
|
aResult = 200;
|
2010-06-03 13:56:36 -07:00
|
|
|
break;
|
|
|
|
|
2011-12-16 01:18:48 -08:00
|
|
|
case eIntID_TooltipDelay:
|
|
|
|
aResult = 500;
|
|
|
|
break;
|
|
|
|
|
2011-09-08 19:27:13 -07:00
|
|
|
case eIntID_MenusCanOverlapOSBar:
|
2010-06-03 13:56:36 -07:00
|
|
|
// we want XUL popups to be able to overlap the task bar.
|
2011-09-08 19:27:13 -07:00
|
|
|
aResult = 1;
|
2010-06-03 13:56:36 -07:00
|
|
|
break;
|
|
|
|
|
2011-09-08 19:27:13 -07:00
|
|
|
case eIntID_ScrollArrowStyle:
|
|
|
|
aResult = eScrollArrowStyle_Single;
|
2010-06-03 13:56:36 -07:00
|
|
|
break;
|
|
|
|
|
2011-09-08 19:27:13 -07:00
|
|
|
case eIntID_ScrollSliderStyle:
|
|
|
|
aResult = eScrollThumbStyle_Proportional;
|
2010-06-03 13:56:36 -07:00
|
|
|
break;
|
|
|
|
|
2011-09-08 19:27:13 -07:00
|
|
|
case eIntID_TouchEnabled:
|
2012-03-20 16:44:43 -07:00
|
|
|
aResult = 1;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case eIntID_WindowsDefaultTheme:
|
2011-09-08 19:27:13 -07:00
|
|
|
case eIntID_MaemoClassic:
|
|
|
|
case eIntID_WindowsThemeIdentifier:
|
|
|
|
aResult = 0;
|
2010-06-03 13:56:36 -07:00
|
|
|
rv = NS_ERROR_NOT_IMPLEMENTED;
|
|
|
|
break;
|
|
|
|
|
2011-09-08 19:27:13 -07:00
|
|
|
case eIntID_SpellCheckerUnderlineStyle:
|
|
|
|
aResult = NS_STYLE_TEXT_DECORATION_STYLE_WAVY;
|
2010-06-03 13:56:36 -07:00
|
|
|
break;
|
|
|
|
|
2011-11-17 15:41:35 -08:00
|
|
|
case eIntID_ScrollbarButtonAutoRepeatBehavior:
|
|
|
|
aResult = 0;
|
|
|
|
break;
|
|
|
|
|
2010-06-03 13:56:36 -07:00
|
|
|
default:
|
2011-09-08 19:27:13 -07:00
|
|
|
aResult = 0;
|
2010-06-03 13:56:36 -07:00
|
|
|
rv = NS_ERROR_FAILURE;
|
|
|
|
}
|
|
|
|
|
|
|
|
return rv;
|
|
|
|
}
|
|
|
|
|
2011-09-08 19:27:13 -07:00
|
|
|
nsresult
|
|
|
|
nsLookAndFeel::GetFloatImpl(FloatID aID, float &aResult)
|
2010-06-03 13:56:36 -07:00
|
|
|
{
|
2011-09-08 19:27:13 -07:00
|
|
|
nsresult rv = nsXPLookAndFeel::GetFloatImpl(aID, aResult);
|
2010-06-03 13:56:36 -07:00
|
|
|
if (NS_SUCCEEDED(rv))
|
|
|
|
return rv;
|
|
|
|
rv = NS_OK;
|
|
|
|
|
|
|
|
switch (aID) {
|
2011-09-08 19:27:13 -07:00
|
|
|
case eFloatID_IMEUnderlineRelativeSize:
|
|
|
|
aResult = 1.0f;
|
2010-06-03 13:56:36 -07:00
|
|
|
break;
|
|
|
|
|
2011-09-08 19:27:13 -07:00
|
|
|
case eFloatID_SpellCheckerUnderlineRelativeSize:
|
|
|
|
aResult = 1.0f;
|
2010-06-03 13:56:36 -07:00
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
2011-09-08 19:27:13 -07:00
|
|
|
aResult = -1.0;
|
2010-06-03 13:56:36 -07:00
|
|
|
rv = NS_ERROR_FAILURE;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
return rv;
|
|
|
|
}
|
2011-07-26 18:14:52 -07:00
|
|
|
|
2012-02-20 15:19:48 -08:00
|
|
|
/*virtual*/
|
|
|
|
bool
|
|
|
|
nsLookAndFeel::GetFontImpl(FontID aID, nsString& aFontName,
|
|
|
|
gfxFontStyle& aFontStyle)
|
|
|
|
{
|
|
|
|
aFontName.AssignLiteral("\"Droid Sans\"");
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
2011-07-26 18:14:52 -07:00
|
|
|
/*virtual*/
|
2011-09-28 23:19:26 -07:00
|
|
|
bool
|
2011-09-08 19:27:13 -07:00
|
|
|
nsLookAndFeel::GetEchoPasswordImpl()
|
2011-07-26 18:14:52 -07:00
|
|
|
{
|
|
|
|
if (!mInitializedShowPassword) {
|
|
|
|
if (XRE_GetProcessType() == GeckoProcessType_Default) {
|
|
|
|
if (AndroidBridge::Bridge())
|
|
|
|
mShowPassword = AndroidBridge::Bridge()->GetShowPasswordSetting();
|
|
|
|
else
|
|
|
|
NS_ASSERTION(AndroidBridge::Bridge() != nsnull, "AndroidBridge is not available!");
|
|
|
|
} else {
|
|
|
|
ContentChild::GetSingleton()->SendGetShowPasswordSetting(&mShowPassword);
|
|
|
|
}
|
2011-10-17 07:59:28 -07:00
|
|
|
mInitializedShowPassword = true;
|
2011-07-26 18:14:52 -07:00
|
|
|
}
|
|
|
|
return mShowPassword;
|
|
|
|
}
|