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

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

Issue 302453002: New animation for the origin chip URL showing/hiding. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Bugfixes and more animations Created 6 years, 7 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
Index: ui/views/controls/textfield/textfield.cc
diff --git a/ui/views/controls/textfield/textfield.cc b/ui/views/controls/textfield/textfield.cc
index 68aa01ec3bd832958bcc74db80c22734a5f3398c..669adbcf2027047044bec12165ef24bbbb43d446 100644
--- a/ui/views/controls/textfield/textfield.cc
+++ b/ui/views/controls/textfield/textfield.cc
@@ -245,6 +245,10 @@ Textfield::Textfield()
use_default_text_color_(true),
background_color_(SK_ColorWHITE),
use_default_background_color_(true),
+ selection_text_color_(SK_ColorWHITE),
+ use_default_selection_text_color_(true),
+ selection_background_color_(SK_ColorBLUE),
+ use_default_selection_background_color_(true),
placeholder_text_color_(kDefaultPlaceholderTextColor),
text_input_type_(ui::TEXT_INPUT_TYPE_TEXT),
performing_user_action_(false),
@@ -371,6 +375,48 @@ void Textfield::UseDefaultBackgroundColor() {
UpdateBackgroundColor();
}
+SkColor Textfield::GetSelectionTextColor() const {
+ return use_default_selection_text_color_ ?
+ GetNativeTheme()->GetSystemColor(
+ ui::NativeTheme::kColorId_TextfieldSelectionColor) :
+ selection_text_color_;
+}
+
+void Textfield::SetSelectionTextColor(SkColor color) {
+ selection_text_color_ = color;
+ use_default_selection_text_color_ = false;
+ GetRenderText()->set_selection_color(GetSelectionTextColor());
+ SchedulePaint();
+}
+
+void Textfield::UseDefaultSelectionTextColor() {
+ use_default_selection_text_color_ = true;
+ GetRenderText()->set_selection_color(GetSelectionTextColor());
+ SchedulePaint();
+}
+
+SkColor Textfield::GetSelectionBackgroundColor() const {
+ return use_default_selection_background_color_ ?
+ GetNativeTheme()->GetSystemColor(
+ ui::NativeTheme::kColorId_TextfieldSelectionBackgroundFocused) :
+ selection_background_color_;
+}
+
+void Textfield::SetSelectionBackgroundColor(SkColor color) {
+ selection_background_color_ = color;
+ use_default_selection_background_color_ = false;
+ GetRenderText()->set_selection_background_focused_color(
+ GetSelectionBackgroundColor());
+ SchedulePaint();
+}
+
+void Textfield::UseDefaultSelectionBackgroundColor() {
+ use_default_selection_background_color_ = true;
+ GetRenderText()->set_selection_background_focused_color(
+ GetSelectionBackgroundColor());
+ SchedulePaint();
+}
+
bool Textfield::GetCursorEnabled() const {
return GetRenderText()->cursor_enabled();
}
@@ -901,11 +947,9 @@ void Textfield::OnNativeThemeChanged(const ui::NativeTheme* theme) {
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));
-
+ render_text->set_selection_color(GetSelectionTextColor());
+ render_text->set_selection_background_focused_color(
+ GetSelectionBackgroundColor());
}
////////////////////////////////////////////////////////////////////////////////

Powered by Google App Engine
This is Rietveld 408576698