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

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 rebase. Created 4 years, 2 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.h
diff --git a/ui/views/controls/textfield/textfield.h b/ui/views/controls/textfield/textfield.h
index 5eb167deedcdbd5ddb0bbcf9fbbe939a8f3d65cb..47ecc483b1bdbce7a649e5b0d384f185c9bcf9c1 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,8 @@ class VIEWS_EXPORT Textfield : public View,
bool GetNeedsNotificationWhenVisibleBoundsChange() const override;
void OnVisibleBoundsChanged() override;
void OnEnabledChanged() override;
+ void ViewHierarchyChanged(
+ const ViewHierarchyChangedDetails& details) override;
void OnPaint(gfx::Canvas* canvas) override;
void OnFocus() override;
void OnBlur() override;
@@ -266,6 +274,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,
@@ -469,6 +481,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