diff options
author | sadrul@chromium.org <sadrul@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-01-23 21:13:33 +0000 |
---|---|---|
committer | sadrul@chromium.org <sadrul@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-01-23 21:13:33 +0000 |
commit | 721ea92d1b137200ec44c034bc3aabd5dd8ea689 (patch) | |
tree | 99f64b29f6419423936a46d81f674e1854437505 /ui | |
parent | d8aac29988bd0fca34d47f55f733f6c07fa79de9 (diff) | |
download | chromium_src-721ea92d1b137200ec44c034bc3aabd5dd8ea689.zip chromium_src-721ea92d1b137200ec44c034bc3aabd5dd8ea689.tar.gz chromium_src-721ea92d1b137200ec44c034bc3aabd5dd8ea689.tar.bz2 |
aura/views: Use colors from NativeTheme in the omnibox popup.
BUG=105901
TEST=manually
Review URL: https://chromiumcodereview.appspot.com/9280011
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@118736 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ui')
-rw-r--r-- | ui/gfx/native_theme.h | 8 | ||||
-rw-r--r-- | ui/gfx/native_theme_aura.cc | 19 | ||||
-rw-r--r-- | ui/gfx/native_theme_chromeos.cc | 19 | ||||
-rw-r--r-- | ui/gfx/native_theme_win.cc | 20 | ||||
-rw-r--r-- | ui/gfx/render_text.cc | 15 |
5 files changed, 74 insertions, 7 deletions
diff --git a/ui/gfx/native_theme.h b/ui/gfx/native_theme.h index 900eb2f0..fb41177 100644 --- a/ui/gfx/native_theme.h +++ b/ui/gfx/native_theme.h @@ -230,7 +230,13 @@ class UI_EXPORT NativeTheme { // MenuItem kColorId_EnabledMenuItemForegroundColor, kColorId_DisabledMenuItemForegroundColor, - kColorId_FocusedMenuItemBackgroundColor + kColorId_FocusedMenuItemBackgroundColor, + // Textfield + kColorId_TextfieldDefaultColor, + kColorId_TextfieldDefaultBackground, + kColorId_TextfieldSelectionColor, + kColorId_TextfieldSelectionBackgroundFocused, + kColorId_TextfieldSelectionBackgroundUnfocused, // TODO(benrg): move other hardcoded colors here. }; diff --git a/ui/gfx/native_theme_aura.cc b/ui/gfx/native_theme_aura.cc index 9690def..04a3ff5 100644 --- a/ui/gfx/native_theme_aura.cc +++ b/ui/gfx/native_theme_aura.cc @@ -33,6 +33,13 @@ const SkColor kEnabledMenuItemForegroundColor = SK_ColorBLACK; const SkColor kDisabledMenuItemForegroundColor = SkColorSetRGB(0x80, 0x80, 0x80); const SkColor kFocusedMenuItemBackgroundColor = SkColorSetRGB(0xDC, 0xE4, 0xFA); +// Textfield: +const SkColor kTextfieldDefaultColor = SK_ColorBLACK; +const SkColor kTextfieldDefaultBackground = SK_ColorWHITE; +const SkColor kTextfieldSelectionColor = SK_ColorWHITE; +const SkColor kTextfieldSelectionBackgroundFocused = + SkColorSetRGB(0x1D, 0x90, 0xFF); +const SkColor kTextfieldSelectionBackgroundUnfocused = SK_ColorLTGRAY; } // namespace @@ -89,6 +96,18 @@ SkColor NativeThemeAura::GetSystemColor(ColorId color_id) const { case kColorId_FocusedMenuItemBackgroundColor: return kFocusedMenuItemBackgroundColor; + // Textfield + case kColorId_TextfieldDefaultColor: + return kTextfieldDefaultColor; + case kColorId_TextfieldDefaultBackground: + return kTextfieldDefaultBackground; + case kColorId_TextfieldSelectionColor: + return kTextfieldSelectionColor; + case kColorId_TextfieldSelectionBackgroundFocused: + return kTextfieldSelectionBackgroundFocused; + case kColorId_TextfieldSelectionBackgroundUnfocused: + return kTextfieldSelectionBackgroundUnfocused; + default: NOTREACHED() << "Invalid color_id: " << color_id; break; diff --git a/ui/gfx/native_theme_chromeos.cc b/ui/gfx/native_theme_chromeos.cc index 1f4c87f..38ab1e5 100644 --- a/ui/gfx/native_theme_chromeos.cc +++ b/ui/gfx/native_theme_chromeos.cc @@ -89,6 +89,13 @@ const SkColor kEnabledMenuItemForegroundColor = SK_ColorBLACK; const SkColor kDisabledMenuItemForegroundColor = SkColorSetRGB(0x80, 0x80, 0x80); const SkColor kFocusedMenuItemBackgroundColor = SkColorSetRGB(0xDC, 0xE4, 0xFA); +// Textfield: +const SkColor kTextfieldDefaultColor = SK_ColorBLACK; +const SkColor kTextfieldDefaultBackground = SK_ColorWHITE; +const SkColor kTextfieldSelectionColor = SK_ColorWHITE; +const SkColor kTextfieldSelectionBackgroundFocused = + SkColorSetRGB(0x1D, 0x90, 0xFF); +const SkColor kTextfieldSelectionBackgroundUnfocused = SK_ColorLTGRAY; // Geometry constants @@ -358,6 +365,18 @@ SkColor NativeThemeChromeos::GetSystemColor(ColorId color_id) const { case kColorId_FocusedMenuItemBackgroundColor: return kFocusedMenuItemBackgroundColor; + // Textfield + case kColorId_TextfieldDefaultColor: + return kTextfieldDefaultColor; + case kColorId_TextfieldDefaultBackground: + return kTextfieldDefaultBackground; + case kColorId_TextfieldSelectionColor: + return kTextfieldSelectionColor; + case kColorId_TextfieldSelectionBackgroundFocused: + return kTextfieldSelectionBackgroundFocused; + case kColorId_TextfieldSelectionBackgroundUnfocused: + return kTextfieldSelectionBackgroundUnfocused; + default: NOTREACHED() << "Invalid color_id: " << color_id; break; diff --git a/ui/gfx/native_theme_win.cc b/ui/gfx/native_theme_win.cc index 2f76c77..66a9130 100644 --- a/ui/gfx/native_theme_win.cc +++ b/ui/gfx/native_theme_win.cc @@ -27,6 +27,7 @@ namespace { +// TODO: Obtain the correct colors using GetSysColor. // Theme colors returned by GetSystemColor(). const SkColor kInvalidColorIdColor = SkColorSetRGB(255, 0, 128); // Dialogs: @@ -44,6 +45,13 @@ const SkColor kTextButtonHoverColor = kTextButtonEnabledColor; const SkColor kEnabledMenuItemForegroundColor = kTextButtonEnabledColor; const SkColor kDisabledMenuItemForegroundColor = kTextButtonDisabledColor; const SkColor kFocusedMenuItemBackgroundColor = SkColorSetRGB(246, 249, 253); +// Textfield: +const SkColor kTextfieldDefaultColor = SK_ColorBLACK; +const SkColor kTextfieldDefaultBackground = SK_ColorWHITE; +const SkColor kTextfieldSelectionColor = SK_ColorWHITE; +const SkColor kTextfieldSelectionBackgroundFocused = + SkColorSetRGB(0x1D, 0x90, 0xFF); +const SkColor kTextfieldSelectionBackgroundUnfocused = SK_ColorLTGRAY; SkColor WinColorToSkColor(COLORREF color) { return SkColorSetRGB(GetRValue(color), GetGValue(color), GetBValue(color)); @@ -391,6 +399,18 @@ SkColor NativeThemeWin::GetSystemColor(ColorId color_id) const { case kColorId_FocusedMenuItemBackgroundColor: return kFocusedMenuItemBackgroundColor; + // Textfield + case kColorId_TextfieldDefaultColor: + return kTextfieldDefaultColor; + case kColorId_TextfieldDefaultBackground: + return kTextfieldDefaultBackground; + case kColorId_TextfieldSelectionColor: + return kTextfieldSelectionColor; + case kColorId_TextfieldSelectionBackgroundFocused: + return kTextfieldSelectionBackgroundFocused; + case kColorId_TextfieldSelectionBackgroundUnfocused: + return kTextfieldSelectionBackgroundUnfocused; + default: NOTREACHED() << "Invalid color_id: " << color_id; break; diff --git a/ui/gfx/render_text.cc b/ui/gfx/render_text.cc index bc62a66..ef7ed00 100644 --- a/ui/gfx/render_text.cc +++ b/ui/gfx/render_text.cc @@ -14,6 +14,7 @@ #include "third_party/skia/include/effects/SkGradientShader.h" #include "ui/gfx/canvas.h" #include "ui/gfx/canvas_skia.h" +#include "ui/gfx/native_theme.h" #include "unicode/uchar.h" namespace { @@ -23,9 +24,6 @@ namespace { // settings and current settings. // TODO(oshima): Change this to match the standard chrome // before dogfooding textfield views. -const SkColor kSelectedTextColor = SK_ColorWHITE; -const SkColor kFocusedSelectionColor = SkColorSetRGB(30, 144, 255); -const SkColor kUnfocusedSelectionColor = SK_ColorLTGRAY; const SkColor kCursorColor = SK_ColorBLACK; #ifndef NDEBUG @@ -626,7 +624,8 @@ void RenderText::ApplyCompositionAndSelectionStyles( // Apply a selection style override to a copy of the style ranges. if (!EmptySelection()) { StyleRange selection_style(default_style_); - selection_style.foreground = kSelectedTextColor; + selection_style.foreground = NativeTheme::instance()->GetSystemColor( + NativeTheme::kColorId_TextfieldSelectionColor); selection_style.range.set_start(MinOfSelection()); selection_style.range.set_end(MaxOfSelection()); ApplyStyleRangeImpl(style_ranges, selection_style); @@ -641,7 +640,8 @@ void RenderText::ApplyCompositionAndSelectionStyles( // http://crbug.com/110109 if (!insert_mode_ && cursor_visible() && focused()) { StyleRange replacement_mode_style(default_style_); - replacement_mode_style.foreground = kSelectedTextColor; + replacement_mode_style.foreground = NativeTheme::instance()->GetSystemColor( + NativeTheme::kColorId_TextfieldSelectionColor); size_t cursor = GetCursorPosition(); replacement_mode_style.range.set_start(cursor); replacement_mode_style.range.set_end( @@ -787,7 +787,10 @@ void RenderText::UpdateCachedBoundsAndOffset() { void RenderText::DrawSelection(Canvas* canvas) { std::vector<Rect> sel = GetSubstringBounds( GetSelectionStart(), GetCursorPosition()); - SkColor color = focused() ? kFocusedSelectionColor : kUnfocusedSelectionColor; + NativeTheme::ColorId color_id = focused() ? + NativeTheme::kColorId_TextfieldSelectionBackgroundFocused : + NativeTheme::kColorId_TextfieldSelectionBackgroundUnfocused; + SkColor color = NativeTheme::instance()->GetSystemColor(color_id); for (std::vector<Rect>::const_iterator i = sel.begin(); i < sel.end(); ++i) canvas->FillRect(color, *i); } |