summaryrefslogtreecommitdiffstats
path: root/ui
diff options
context:
space:
mode:
authorpkasting@chromium.org <pkasting@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-06-02 19:28:06 +0000
committerpkasting@chromium.org <pkasting@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-06-02 19:28:06 +0000
commit820b9db6d0a40faee9ec6dbf0c00336c6fd639a8 (patch)
treed582939f06f326d0a0c48fcdda5aaa44f678ba3c /ui
parentfdc433c0ae0c609ffb3d1bf8fb0f41496b4e3b77 (diff)
downloadchromium_src-820b9db6d0a40faee9ec6dbf0c00336c6fd639a8.zip
chromium_src-820b9db6d0a40faee9ec6dbf0c00336c6fd639a8.tar.gz
chromium_src-820b9db6d0a40faee9ec6dbf0c00336c6fd639a8.tar.bz2
New animation for the origin chip URL showing/hiding.
When the chip is hidden, we instantly show the entire omnibox text, aligned so that the hostname is in the same place it was in the chip, and clipped to just have the hostname visible. Then we animate moving the alignment over to the normal omnibox text position (i.e. just after the location icon) while expanding the clip to gradually reveal the whole text. We also crossfade the selection colors from the chip colors to the standard omnibox ones. This also: * Animates correctly when the hostname is not at the beginning of the origin chip (i.e. for EV certs) * Properly reverses the animation if the user changes state in the middle (hard to see with quick animations, but looks nicer if we slow them down or with very large animation distances) * Fixes dropping characters during animation (because the real omnibox is visible and focused, and can respond correctly to keypresses) * Fixes animations improperly running across tab switches * Cleans up some unused origin chip code Also tested in RTL mode. BUG=363681,365818,374251 TEST=With the origin chip on, showing and hiding the URL should animate much more quickly and cleanly Review URL: https://codereview.chromium.org/302453002 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@274305 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ui')
-rw-r--r--ui/views/controls/textfield/textfield.cc58
-rw-r--r--ui/views/controls/textfield/textfield.h33
2 files changed, 76 insertions, 15 deletions
diff --git a/ui/views/controls/textfield/textfield.cc b/ui/views/controls/textfield/textfield.cc
index 09f261f..b4d48da 100644
--- a/ui/views/controls/textfield/textfield.cc
+++ b/ui/views/controls/textfield/textfield.cc
@@ -255,10 +255,14 @@ Textfield::Textfield()
controller_(NULL),
read_only_(false),
default_width_in_chars_(0),
- text_color_(SK_ColorBLACK),
use_default_text_color_(true),
- background_color_(SK_ColorWHITE),
use_default_background_color_(true),
+ use_default_selection_text_color_(true),
+ use_default_selection_background_color_(true),
+ text_color_(SK_ColorBLACK),
+ background_color_(SK_ColorWHITE),
+ selection_text_color_(SK_ColorWHITE),
+ selection_background_color_(SK_ColorBLUE),
placeholder_text_color_(kDefaultPlaceholderTextColor),
text_input_type_(ui::TEXT_INPUT_TYPE_TEXT),
performing_user_action_(false),
@@ -385,6 +389,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();
}
@@ -908,11 +954,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());
}
////////////////////////////////////////////////////////////////////////////////
diff --git a/ui/views/controls/textfield/textfield.h b/ui/views/controls/textfield/textfield.h
index 8c81c6f..f01a5e4 100644
--- a/ui/views/controls/textfield/textfield.h
+++ b/ui/views/controls/textfield/textfield.h
@@ -95,18 +95,31 @@ class VIEWS_EXPORT Textfield : public View,
// Checks if there is any selected text.
bool HasSelection() const;
- // Gets/Sets the text color to be used when painting the Textfield.
- // Call |UseDefaultTextColor| to restore the default system color.
+ // Gets/sets the text color to be used when painting the Textfield.
+ // Call UseDefaultTextColor() to restore the default system color.
SkColor GetTextColor() const;
void SetTextColor(SkColor color);
void UseDefaultTextColor();
- // Gets/Sets the background color to be used when painting the Textfield.
- // Call |UseDefaultBackgroundColor| to restore the default system color.
+ // Gets/sets the background color to be used when painting the Textfield.
+ // Call UseDefaultBackgroundColor() to restore the default system color.
SkColor GetBackgroundColor() const;
void SetBackgroundColor(SkColor color);
void UseDefaultBackgroundColor();
+ // Gets/sets the selection text color to be used when painting the Textfield.
+ // Call UseDefaultSelectionTextColor() to restore the default system color.
+ SkColor GetSelectionTextColor() const;
+ void SetSelectionTextColor(SkColor color);
+ void UseDefaultSelectionTextColor();
+
+ // Gets/sets the selection background color to be used when painting the
+ // Textfield. Call UseDefaultSelectionBackgroundColor() to restore the default
+ // system color.
+ SkColor GetSelectionBackgroundColor() const;
+ void SetSelectionBackgroundColor(SkColor color);
+ void UseDefaultSelectionBackgroundColor();
+
// Gets/Sets whether or not the cursor is enabled.
bool GetCursorEnabled() const;
void SetCursorEnabled(bool enabled);
@@ -375,12 +388,16 @@ class VIEWS_EXPORT Textfield : public View,
scoped_ptr<Painter> focus_painter_;
- // Flags indicating whether text and background system colors should be used,
- // and the actual color values used if the corresponding flags are set false.
- SkColor text_color_;
+ // Flags indicating whether various system colors should be used, and if not,
+ // what overriding color values should be used instead.
bool use_default_text_color_;
- SkColor background_color_;
bool use_default_background_color_;
+ bool use_default_selection_text_color_;
+ bool use_default_selection_background_color_;
+ SkColor text_color_;
+ SkColor background_color_;
+ SkColor selection_text_color_;
+ SkColor selection_background_color_;
// Text to display when empty.
base::string16 placeholder_text_;