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

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

Issue 2345183002: Views: Draw Textfield selected text in gray when top-level Widget loses focus.
Patch Set: Fix DCHECKs. Created 4 years, 1 month 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.h
diff --git a/ui/views/controls/textfield/textfield.h b/ui/views/controls/textfield/textfield.h
index 44b37d2c19e070e2892219a432fe0fe45205e17c..ceba307835fe7d819012df1b0245a1f231443480 100644
--- a/ui/views/controls/textfield/textfield.h
+++ b/ui/views/controls/textfield/textfield.h
@@ -29,6 +29,7 @@
#include "ui/views/context_menu_controller.h"
#include "ui/views/controls/textfield/textfield_model.h"
#include "ui/views/drag_controller.h"
+#include "ui/views/focus/focus_manager.h"
#include "ui/views/selection_controller.h"
#include "ui/views/selection_controller_delegate.h"
#include "ui/views/view.h"
@@ -45,6 +46,7 @@ class VIEWS_EXPORT Textfield : public View,
public TextfieldModel::Delegate,
public ContextMenuController,
public DragController,
+ public FocusChangeListener,
public WordLookupClient,
public SelectionControllerDelegate,
public ui::TouchEditable,
@@ -140,6 +142,10 @@ class VIEWS_EXPORT Textfield : public View,
void SetSelectionBackgroundColor(SkColor color);
void UseDefaultSelectionBackgroundColor();
+ // Gets the selection background color for use when the Textfield was the last
+ // to be focused in a widget.
+ SkColor GetUnfocusedSelectionBackgroundColor() const;
+
// Set drop shadows underneath the text.
void SetShadows(const gfx::ShadowValues& shadows);
@@ -243,6 +249,9 @@ class VIEWS_EXPORT Textfield : public View,
bool GetNeedsNotificationWhenVisibleBoundsChange() const override;
void OnVisibleBoundsChanged() override;
void OnEnabledChanged() override;
+ void ViewHierarchyChanged(
+ const ViewHierarchyChangedDetails& details) override;
+ void NativeViewHierarchyChanged() override;
void OnPaint(gfx::Canvas* canvas) override;
void OnFocus() override;
void OnBlur() override;
@@ -266,6 +275,10 @@ class VIEWS_EXPORT Textfield : public View,
const gfx::Point& press_pt,
const gfx::Point& p) override;
+ // FocusChangeListener overrides:
+ void OnWillChangeFocus(View* focused_before, View* focused_now) override;
+ void OnDidChangeFocus(View* focused_before, View* focused_now) override;
+
// WordLookupClient overrides:
bool GetDecoratedWordAtPoint(const gfx::Point& point,
gfx::DecoratedText* decorated_word,
@@ -363,6 +376,10 @@ class VIEWS_EXPORT Textfield : public View,
bool PasteSelectionClipboard() override;
void UpdateSelectionClipboard() override;
+ // Adds or removes this Textfield as a FocusChangeListener based on
+ // |add_as_listener|.
+ void AddOrRemoveAsFocusChangeListener(bool add_as_listener);
tapted 2016/11/02 03:45:06 It's generally nice to have a `bool` argument read
Patti Lor 2016/11/07 05:34:27 Done.
+
// Handles a request to change the value of this text field from software
// using an accessibility API (typically automation software, screen readers
// don't normally use this). If |clear_first| is true, this replaces all text
@@ -472,6 +489,12 @@ class VIEWS_EXPORT Textfield : public View,
SkColor selection_text_color_;
SkColor selection_background_color_;
+ // In cases where the Widget is deleted before the Textfield, there is no
+ // longer a way to retrieve the FocusManager. It's still needed to remove this
+ // Textfield as an observer, so keep a reference to the FocusManager this
+ // Textfield is listening to, if any.
+ FocusManager* focus_manager_;
+
// Text to display when empty.
base::string16 placeholder_text_;

Powered by Google App Engine
This is Rietveld 408576698