Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(68)

Unified Diff: trunk/src/ui/views/controls/textfield/textfield.cc

Issue 256683003: Revert 266042 "Automatically call OnNativeThemeChanged when a wi..." (Closed) Base URL: svn://svn.chromium.org/chrome/
Patch Set: Created 6 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « trunk/src/ui/views/controls/textfield/textfield.h ('k') | trunk/src/ui/views/view.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: trunk/src/ui/views/controls/textfield/textfield.cc
===================================================================
--- trunk/src/ui/views/controls/textfield/textfield.cc (revision 266071)
+++ trunk/src/ui/views/controls/textfield/textfield.cc (working copy)
@@ -846,6 +846,12 @@
SchedulePaint();
}
+void Textfield::ViewHierarchyChanged(
+ const ViewHierarchyChangedDetails& details) {
+ if (details.is_add && details.child == this)
+ UpdateColorsFromTheme(GetNativeTheme());
+}
+
void Textfield::OnPaint(gfx::Canvas* canvas) {
OnPaintBackground(canvas);
PaintTextAndCursor(canvas);
@@ -890,15 +896,7 @@
}
void Textfield::OnNativeThemeChanged(const ui::NativeTheme* theme) {
- gfx::RenderText* render_text = GetRenderText();
- render_text->SetColor(GetTextColor());
- UpdateBackgroundColor();
- render_text->set_cursor_color(GetTextColor());
- render_text->set_selection_color(theme->GetSystemColor(
- ui::NativeTheme::kColorId_TextfieldSelectionColor));
- render_text->set_selection_background_focused_color(theme->GetSystemColor(
- ui::NativeTheme::kColorId_TextfieldSelectionBackgroundFocused));
-
+ UpdateColorsFromTheme(theme);
}
////////////////////////////////////////////////////////////////////////////////
@@ -1464,6 +1462,17 @@
SchedulePaint();
}
+void Textfield::UpdateColorsFromTheme(const ui::NativeTheme* theme) {
+ gfx::RenderText* render_text = GetRenderText();
+ render_text->SetColor(GetTextColor());
+ UpdateBackgroundColor();
+ render_text->set_cursor_color(GetTextColor());
+ render_text->set_selection_color(theme->GetSystemColor(
+ ui::NativeTheme::kColorId_TextfieldSelectionColor));
+ render_text->set_selection_background_focused_color(theme->GetSystemColor(
+ ui::NativeTheme::kColorId_TextfieldSelectionBackgroundFocused));
+}
+
void Textfield::UpdateAfterChange(bool text_changed, bool cursor_changed) {
if (text_changed) {
if (controller_)
« no previous file with comments | « trunk/src/ui/views/controls/textfield/textfield.h ('k') | trunk/src/ui/views/view.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698