summaryrefslogtreecommitdiffstats
path: root/ui/native_theme
diff options
context:
space:
mode:
authorkeishi@chromium.org <keishi@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-05-20 14:35:10 +0000
committerkeishi@chromium.org <keishi@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-05-20 14:35:10 +0000
commit27324cbb71c04c1fa1f7ed4c5cfc6ba10df9bf61 (patch)
tree8a9eca91fb4c83a107c329b2229baf1edaac6e01 /ui/native_theme
parentaabd7f6d180ffb2b3ef590c44628649b94df423e (diff)
downloadchromium_src-27324cbb71c04c1fa1f7ed4c5cfc6ba10df9bf61.zip
chromium_src-27324cbb71c04c1fa1f7ed4c5cfc6ba10df9bf61.tar.gz
chromium_src-27324cbb71c04c1fa1f7ed4c5cfc6ba10df9bf61.tar.bz2
Use the default theme as the fallback UI in Blink
Most native themes don't support zooming or styling required by Blink. This introduces a FallbackTheme that can be used in these situations. Blink side change: https://codereview.chromium.org/14108007/ BUG=84973 Committed: https://src.chromium.org/viewvc/chrome?view=rev&revision=200431 Committed: https://src.chromium.org/viewvc/chrome?view=rev&revision=200785 Review URL: https://chromiumcodereview.appspot.com/14424007 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@201085 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ui/native_theme')
-rw-r--r--ui/native_theme/fallback_theme.cc198
-rw-r--r--ui/native_theme/fallback_theme.h28
-rw-r--r--ui/native_theme/native_theme.gyp2
-rw-r--r--ui/native_theme/native_theme_aura.cc168
-rw-r--r--ui/native_theme/native_theme_aura.h5
5 files changed, 230 insertions, 171 deletions
diff --git a/ui/native_theme/fallback_theme.cc b/ui/native_theme/fallback_theme.cc
new file mode 100644
index 0000000..4bfe8d9
--- /dev/null
+++ b/ui/native_theme/fallback_theme.cc
@@ -0,0 +1,198 @@
+// Copyright (c) 2012 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "ui/native_theme/fallback_theme.h"
+
+#include "base/basictypes.h"
+#include "base/logging.h"
+#include "ui/gfx/color_utils.h"
+#include "ui/gfx/skia_utils_gtk.h"
+#include "ui/native_theme/common_theme.h"
+
+namespace ui {
+
+FallbackTheme::FallbackTheme() {
+}
+
+FallbackTheme::~FallbackTheme() {
+}
+
+SkColor FallbackTheme::GetSystemColor(ColorId color_id) const {
+ // This implementation returns hardcoded colors.
+
+ static const SkColor kInvalidColorIdColor = SkColorSetRGB(255, 0, 128);
+ // Menu:
+ static const SkColor kMenuBackgroundColor = SK_ColorWHITE;
+ // Windows:
+ static const SkColor kWindowBackgroundColor = SK_ColorWHITE;
+ // Dialogs:
+ static const SkColor kDialogBackgroundColor = SkColorSetRGB(251, 251, 251);
+ // FocusableBorder:
+ static const SkColor kFocusedBorderColor = SkColorSetRGB(0x4D, 0x90, 0xFE);
+ static const SkColor kUnfocusedBorderColor = SkColorSetRGB(0xD9, 0xD9, 0xD9);
+ // Button:
+ static const SkColor kButtonBackgroundColor = SkColorSetRGB(0xDE, 0xDE, 0xDE);
+ static const SkColor kButtonEnabledColor = SkColorSetRGB(0x22, 0x22, 0x22);
+ static const SkColor kButtonDisabledColor = SkColorSetRGB(0x99, 0x99, 0x99);
+ static const SkColor kButtonHighlightColor = SkColorSetRGB(0, 0, 0);
+ static const SkColor kButtonHoverColor = kButtonEnabledColor;
+ // MenuItem:
+ static const SkColor kEnabledMenuItemForegroundColor = kButtonEnabledColor;
+ static const SkColor kDisabledMenuItemForegroundColor = kButtonDisabledColor;
+ static const SkColor kFocusedMenuItemBackgroundColor =
+ SkColorSetRGB(0xF1, 0xF1, 0xF1);
+ static const SkColor kHoverMenuItemBackgroundColor =
+ SkColorSetARGB(204, 255, 255, 255);
+ static const SkColor kMenuSeparatorColor = SkColorSetRGB(0xED, 0xED, 0xED);
+ static const SkColor kEnabledMenuButtonBorderColor =
+ SkColorSetARGB(36, 0, 0, 0);
+ static const SkColor kFocusedMenuButtonBorderColor =
+ SkColorSetARGB(72, 0, 0, 0);
+ static const SkColor kHoverMenuButtonBorderColor =
+ SkColorSetARGB(72, 0, 0, 0);
+ // Label:
+ static const SkColor kLabelEnabledColor = kButtonEnabledColor;
+ static const SkColor kLabelDisabledColor = kButtonDisabledColor;
+ static const SkColor kLabelBackgroundColor = SK_ColorWHITE;
+ // Textfield:
+ static const SkColor kTextfieldDefaultColor = SK_ColorBLACK;
+ static const SkColor kTextfieldDefaultBackground = SK_ColorWHITE;
+ static const SkColor kTextfieldReadOnlyColor = SK_ColorDKGRAY;
+ static const SkColor kTextfieldReadOnlyBackground = SK_ColorWHITE;
+ static const SkColor kTextfieldSelectionBackgroundFocused =
+ SkColorSetARGB(0x54, 0x60, 0xA8, 0xEB);
+ static const SkColor kTextfieldSelectionBackgroundUnfocused = SK_ColorLTGRAY;
+ static const SkColor kTextfieldSelectionColor =
+ color_utils::AlphaBlend(SK_ColorBLACK,
+ kTextfieldSelectionBackgroundFocused, 0xdd);
+ // Tree
+ static const SkColor kTreeBackground = SK_ColorWHITE;
+ static const SkColor kTreeTextColor = SK_ColorBLACK;
+ static const SkColor kTreeSelectedTextColor = SK_ColorBLACK;
+ static const SkColor kTreeSelectionBackgroundColor =
+ SkColorSetRGB(0xEE, 0xEE, 0xEE);
+ static const SkColor kTreeArrowColor = SkColorSetRGB(0x7A, 0x7A, 0x7A);
+ // Table
+ static const SkColor kTableBackground = SK_ColorWHITE;
+ static const SkColor kTableTextColor = SK_ColorBLACK;
+ static const SkColor kTableSelectedTextColor = SK_ColorBLACK;
+ static const SkColor kTableSelectionBackgroundColor =
+ SkColorSetRGB(0xEE, 0xEE, 0xEE);
+ static const SkColor kTableGroupingIndicatorColor =
+ SkColorSetRGB(0xCC, 0xCC, 0xCC);
+
+ SkColor color;
+ if (CommonThemeGetSystemColor(color_id, &color))
+ return color;
+
+ switch (color_id) {
+ // Windows
+ case kColorId_WindowBackground:
+ return kWindowBackgroundColor;
+
+ // Dialogs
+ case kColorId_DialogBackground:
+ return kDialogBackgroundColor;
+
+ // FocusableBorder
+ case kColorId_FocusedBorderColor:
+ return kFocusedBorderColor;
+ case kColorId_UnfocusedBorderColor:
+ return kUnfocusedBorderColor;
+
+ // Button
+ case kColorId_ButtonBackgroundColor:
+ return kButtonBackgroundColor;
+ case kColorId_ButtonEnabledColor:
+ return kButtonEnabledColor;
+ case kColorId_ButtonDisabledColor:
+ return kButtonDisabledColor;
+ case kColorId_ButtonHighlightColor:
+ return kButtonHighlightColor;
+ case kColorId_ButtonHoverColor:
+ return kButtonHoverColor;
+
+ // MenuItem
+ case kColorId_EnabledMenuItemForegroundColor:
+ return kEnabledMenuItemForegroundColor;
+ case kColorId_DisabledMenuItemForegroundColor:
+ return kDisabledMenuItemForegroundColor;
+ case kColorId_SelectedMenuItemForegroundColor:
+ return kEnabledMenuItemForegroundColor;
+ case kColorId_FocusedMenuItemBackgroundColor:
+ return kFocusedMenuItemBackgroundColor;
+ case kColorId_HoverMenuItemBackgroundColor:
+ return kHoverMenuItemBackgroundColor;
+ case kColorId_MenuSeparatorColor:
+ return kMenuSeparatorColor;
+ case kColorId_EnabledMenuButtonBorderColor:
+ return kEnabledMenuButtonBorderColor;
+ case kColorId_FocusedMenuButtonBorderColor:
+ return kFocusedMenuButtonBorderColor;
+ case kColorId_HoverMenuButtonBorderColor:
+ return kHoverMenuButtonBorderColor;
+
+ // Label
+ case kColorId_LabelEnabledColor:
+ return kLabelEnabledColor;
+ case kColorId_LabelDisabledColor:
+ return kLabelDisabledColor;
+ case kColorId_LabelBackgroundColor:
+ return kLabelBackgroundColor;
+
+ // Textfield
+ case kColorId_TextfieldDefaultColor:
+ return kTextfieldDefaultColor;
+ case kColorId_TextfieldDefaultBackground:
+ return kTextfieldDefaultBackground;
+ case kColorId_TextfieldReadOnlyColor:
+ return kTextfieldReadOnlyColor;
+ case kColorId_TextfieldReadOnlyBackground:
+ return kTextfieldReadOnlyBackground;
+ case kColorId_TextfieldSelectionColor:
+ return kTextfieldSelectionColor;
+ case kColorId_TextfieldSelectionBackgroundFocused:
+ return kTextfieldSelectionBackgroundFocused;
+ case kColorId_TextfieldSelectionBackgroundUnfocused:
+ return kTextfieldSelectionBackgroundUnfocused;
+
+ // Tree
+ case kColorId_TreeBackground:
+ return kTreeBackground;
+ case kColorId_TreeText:
+ return kTreeTextColor;
+ case kColorId_TreeSelectedText:
+ case kColorId_TreeSelectedTextUnfocused:
+ return kTreeSelectedTextColor;
+ case kColorId_TreeSelectionBackgroundFocused:
+ case kColorId_TreeSelectionBackgroundUnfocused:
+ return kTreeSelectionBackgroundColor;
+ case kColorId_TreeArrow:
+ return kTreeArrowColor;
+
+ // Table
+ case kColorId_TableBackground:
+ return kTableBackground;
+ case kColorId_TableText:
+ return kTableTextColor;
+ case kColorId_TableSelectedText:
+ case kColorId_TableSelectedTextUnfocused:
+ return kTableSelectedTextColor;
+ case kColorId_TableSelectionBackgroundFocused:
+ case kColorId_TableSelectionBackgroundUnfocused:
+ return kTableSelectionBackgroundColor;
+ case kColorId_TableGroupingIndicatorColor:
+ return kTableGroupingIndicatorColor;
+
+ case kColorId_MenuBackgroundColor:
+ return kMenuBackgroundColor;
+ case kColorId_MenuBorderColor:
+ NOTREACHED();
+ break;
+ }
+
+ return kInvalidColorIdColor;
+}
+
+} // namespace ui
diff --git a/ui/native_theme/fallback_theme.h b/ui/native_theme/fallback_theme.h
new file mode 100644
index 0000000..2a69936
--- /dev/null
+++ b/ui/native_theme/fallback_theme.h
@@ -0,0 +1,28 @@
+// Copyright (c) 2012 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef UI_NATIVE_THEME_FALLBACK_THEME_H_
+#define UI_NATIVE_THEME_FALLBACK_THEME_H_
+
+#include "ui/native_theme/native_theme_base.h"
+
+namespace ui {
+
+// This theme can draw UI controls on every platform. This is only used when
+// zooming a web page and the native theme doesn't support scaling.
+class NATIVE_THEME_EXPORT FallbackTheme : public NativeThemeBase {
+ public:
+ FallbackTheme();
+ virtual ~FallbackTheme();
+
+ private:
+ // Overridden from NativeThemeBase:
+ virtual SkColor GetSystemColor(ColorId color_id) const OVERRIDE;
+
+ DISALLOW_COPY_AND_ASSIGN(FallbackTheme);
+};
+
+} // namespace ui
+
+#endif // UI_NATIVE_THEME_FALLBACK_THEME_H_
diff --git a/ui/native_theme/native_theme.gyp b/ui/native_theme/native_theme.gyp
index 70d27a3..671f286 100644
--- a/ui/native_theme/native_theme.gyp
+++ b/ui/native_theme/native_theme.gyp
@@ -23,6 +23,8 @@
'sources': [
'common_theme.cc',
'common_theme.h',
+ 'fallback_theme.cc',
+ 'fallback_theme.h',
'native_theme.cc',
'native_theme.h',
'native_theme_android.cc',
diff --git a/ui/native_theme/native_theme_aura.cc b/ui/native_theme/native_theme_aura.cc
index 8d7ae0b..6cbc255 100644
--- a/ui/native_theme/native_theme_aura.cc
+++ b/ui/native_theme/native_theme_aura.cc
@@ -19,59 +19,6 @@ namespace {
const SkColor kMenuBackgroundColor = SK_ColorWHITE;
-// Theme colors returned by GetSystemColor().
-const SkColor kInvalidColorIdColor = SkColorSetRGB(255, 0, 128);
-// Windows:
-const SkColor kWindowBackgroundColor = SK_ColorWHITE;
-// Dialogs:
-const SkColor kDialogBackgroundColor = SkColorSetRGB(251, 251, 251);
-// FocusableBorder:
-const SkColor kFocusedBorderColor = SkColorSetRGB(0x4D, 0x90, 0xFE);
-const SkColor kUnfocusedBorderColor = SkColorSetRGB(0xD9, 0xD9, 0xD9);
-// Button:
-const SkColor kButtonBackgroundColor = SkColorSetRGB(0xDE, 0xDE, 0xDE);
-const SkColor kButtonEnabledColor = SkColorSetRGB(0x22, 0x22, 0x22);
-const SkColor kButtonDisabledColor = SkColorSetRGB(0x99, 0x99, 0x99);
-const SkColor kButtonHighlightColor = SkColorSetRGB(0, 0, 0);
-const SkColor kButtonHoverColor = kButtonEnabledColor;
-// MenuItem:
-const SkColor kEnabledMenuItemForegroundColor = kButtonEnabledColor;
-const SkColor kDisabledMenuItemForegroundColor = kButtonDisabledColor;
-const SkColor kFocusedMenuItemBackgroundColor = SkColorSetRGB(0xF1, 0xF1, 0xF1);
-const SkColor kHoverMenuItemBackgroundColor =
- SkColorSetARGB(204, 255, 255, 255);
-const SkColor kMenuSeparatorColor = SkColorSetRGB(0xED, 0xED, 0xED);
-const SkColor kEnabledMenuButtonBorderColor = SkColorSetARGB(36, 0, 0, 0);
-const SkColor kFocusedMenuButtonBorderColor = SkColorSetARGB(72, 0, 0, 0);
-const SkColor kHoverMenuButtonBorderColor = SkColorSetARGB(72, 0, 0, 0);
-// Label:
-const SkColor kLabelEnabledColor = kButtonEnabledColor;
-const SkColor kLabelDisabledColor = kButtonDisabledColor;
-const SkColor kLabelBackgroundColor = SK_ColorWHITE;
-// Textfield:
-const SkColor kTextfieldDefaultColor = SK_ColorBLACK;
-const SkColor kTextfieldDefaultBackground = SK_ColorWHITE;
-const SkColor kTextfieldReadOnlyColor = SK_ColorDKGRAY;
-const SkColor kTextfieldReadOnlyBackground = SK_ColorWHITE;
-const SkColor kTextfieldSelectionBackgroundFocused =
- SkColorSetARGB(0x54, 0x60, 0xA8, 0xEB);
-const SkColor kTextfieldSelectionBackgroundUnfocused = SK_ColorLTGRAY;
-const SkColor kTextfieldSelectionColor =
- color_utils::AlphaBlend(SK_ColorBLACK,
- kTextfieldSelectionBackgroundFocused, 0xdd);
-// Tree
-const SkColor kTreeBackground = SK_ColorWHITE;
-const SkColor kTreeTextColor = SK_ColorBLACK;
-const SkColor kTreeSelectedTextColor = SK_ColorBLACK;
-const SkColor kTreeSelectionBackgroundColor = SkColorSetRGB(0xEE, 0xEE, 0xEE);
-const SkColor kTreeArrowColor = SkColorSetRGB(0x7A, 0x7A, 0x7A);
-// Table
-const SkColor kTableBackground = SK_ColorWHITE;
-const SkColor kTableTextColor = SK_ColorBLACK;
-const SkColor kTableSelectedTextColor = SK_ColorBLACK;
-const SkColor kTableSelectionBackgroundColor = SkColorSetRGB(0xEE, 0xEE, 0xEE);
-const SkColor kTableGroupingIndicatorColor = SkColorSetRGB(0xCC, 0xCC, 0xCC);
-
} // namespace
namespace ui {
@@ -95,121 +42,6 @@ NativeThemeAura::NativeThemeAura() {
NativeThemeAura::~NativeThemeAura() {
}
-SkColor NativeThemeAura::GetSystemColor(ColorId color_id) const {
- // This implementation returns hardcoded colors.
- SkColor color;
- if (CommonThemeGetSystemColor(color_id, &color))
- return color;
-
- switch (color_id) {
- // Windows
- case kColorId_WindowBackground:
- return kWindowBackgroundColor;
-
- // Dialogs
- case kColorId_DialogBackground:
- return kDialogBackgroundColor;
-
- // FocusableBorder
- case kColorId_FocusedBorderColor:
- return kFocusedBorderColor;
- case kColorId_UnfocusedBorderColor:
- return kUnfocusedBorderColor;
-
- // Button
- case kColorId_ButtonBackgroundColor:
- return kButtonBackgroundColor;
- case kColorId_ButtonEnabledColor:
- return kButtonEnabledColor;
- case kColorId_ButtonDisabledColor:
- return kButtonDisabledColor;
- case kColorId_ButtonHighlightColor:
- return kButtonHighlightColor;
- case kColorId_ButtonHoverColor:
- return kButtonHoverColor;
-
- // MenuItem
- case kColorId_EnabledMenuItemForegroundColor:
- return kEnabledMenuItemForegroundColor;
- case kColorId_DisabledMenuItemForegroundColor:
- return kDisabledMenuItemForegroundColor;
- case kColorId_SelectedMenuItemForegroundColor:
- return kEnabledMenuItemForegroundColor;
- case kColorId_FocusedMenuItemBackgroundColor:
- return kFocusedMenuItemBackgroundColor;
- case kColorId_HoverMenuItemBackgroundColor:
- return kHoverMenuItemBackgroundColor;
- case kColorId_MenuSeparatorColor:
- return kMenuSeparatorColor;
- case kColorId_EnabledMenuButtonBorderColor:
- return kEnabledMenuButtonBorderColor;
- case kColorId_FocusedMenuButtonBorderColor:
- return kFocusedMenuButtonBorderColor;
- case kColorId_HoverMenuButtonBorderColor:
- return kHoverMenuButtonBorderColor;
-
- // Label
- case kColorId_LabelEnabledColor:
- return kLabelEnabledColor;
- case kColorId_LabelDisabledColor:
- return kLabelDisabledColor;
- case kColorId_LabelBackgroundColor:
- return kLabelBackgroundColor;
-
- // Textfield
- case kColorId_TextfieldDefaultColor:
- return kTextfieldDefaultColor;
- case kColorId_TextfieldDefaultBackground:
- return kTextfieldDefaultBackground;
- case kColorId_TextfieldReadOnlyColor:
- return kTextfieldReadOnlyColor;
- case kColorId_TextfieldReadOnlyBackground:
- return kTextfieldReadOnlyBackground;
- case kColorId_TextfieldSelectionColor:
- return kTextfieldSelectionColor;
- case kColorId_TextfieldSelectionBackgroundFocused:
- return kTextfieldSelectionBackgroundFocused;
- case kColorId_TextfieldSelectionBackgroundUnfocused:
- return kTextfieldSelectionBackgroundUnfocused;
-
- // Tree
- case kColorId_TreeBackground:
- return kTreeBackground;
- case kColorId_TreeText:
- return kTreeTextColor;
- case kColorId_TreeSelectedText:
- case kColorId_TreeSelectedTextUnfocused:
- return kTreeSelectedTextColor;
- case kColorId_TreeSelectionBackgroundFocused:
- case kColorId_TreeSelectionBackgroundUnfocused:
- return kTreeSelectionBackgroundColor;
- case kColorId_TreeArrow:
- return kTreeArrowColor;
-
- // Table
- case kColorId_TableBackground:
- return kTableBackground;
- case kColorId_TableText:
- return kTableTextColor;
- case kColorId_TableSelectedText:
- case kColorId_TableSelectedTextUnfocused:
- return kTableSelectedTextColor;
- case kColorId_TableSelectionBackgroundFocused:
- case kColorId_TableSelectionBackgroundUnfocused:
- return kTableSelectionBackgroundColor;
- case kColorId_TableGroupingIndicatorColor:
- return kTableGroupingIndicatorColor;
-
- case kColorId_MenuBackgroundColor:
- return kMenuBackgroundColor;
- case kColorId_MenuBorderColor:
- NOTREACHED();
- break;
- }
-
- return kInvalidColorIdColor;
-}
-
void NativeThemeAura::PaintMenuPopupBackground(
SkCanvas* canvas,
const gfx::Size& size,
diff --git a/ui/native_theme/native_theme_aura.h b/ui/native_theme/native_theme_aura.h
index 51ebd38..b3417b3 100644
--- a/ui/native_theme/native_theme_aura.h
+++ b/ui/native_theme/native_theme_aura.h
@@ -7,12 +7,12 @@
#include "base/basictypes.h"
#include "base/compiler_specific.h"
-#include "ui/native_theme/native_theme_base.h"
+#include "ui/native_theme/fallback_theme.h"
namespace ui {
// Aura implementation of native theme support.
-class NATIVE_THEME_EXPORT NativeThemeAura : public NativeThemeBase {
+class NATIVE_THEME_EXPORT NativeThemeAura : public FallbackTheme {
public:
static NativeThemeAura* instance();
@@ -21,7 +21,6 @@ class NATIVE_THEME_EXPORT NativeThemeAura : public NativeThemeBase {
virtual ~NativeThemeAura();
// Overridden from NativeThemeBase:
- virtual SkColor GetSystemColor(ColorId color_id) const OVERRIDE;
virtual void PaintMenuPopupBackground(
SkCanvas* canvas,
const gfx::Size& size,