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

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 focus changing to other Views. 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 1a28b12433f14585c7479c71f13c942e3e8595f9..d23612fdacad084c7b3d70a149dae073dfbdd323 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/view.h"
#include "ui/views/word_lookup_client.h"
@@ -43,6 +44,7 @@ class VIEWS_EXPORT Textfield : public View,
public TextfieldModel::Delegate,
public ContextMenuController,
public DragController,
+ public FocusChangeListener,
public WordLookupClient,
public ui::TouchEditable,
public ui::TextInputClient {
@@ -137,6 +139,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);
@@ -209,7 +215,7 @@ class VIEWS_EXPORT Textfield : public View,
// Returns whether there is a drag operation originating from the textfield.
bool HasTextBeingDragged();
- // View overrides:
+ // View:
tapted 2016/10/13 06:21:35 there's a lot of this style still around - usually
Patti Lor 2016/10/24 02:43:17 Reverted in both the .h and .cc :)
gfx::Insets GetInsets() const override;
int GetBaseline() const override;
gfx::Size GetPreferredSize() const override;
@@ -238,21 +244,23 @@ 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;
gfx::Point GetKeyboardContextMenuLocation() override;
void OnNativeThemeChanged(const ui::NativeTheme* theme) override;
- // TextfieldModel::Delegate overrides:
+ // TextfieldModel::Delegate:
void OnCompositionTextConfirmedOrCleared() override;
- // ContextMenuController overrides:
+ // ContextMenuController:
void ShowContextMenuForView(View* source,
const gfx::Point& point,
ui::MenuSourceType source_type) override;
- // DragController overrides:
+ // DragController:
void WriteDragDataForView(View* sender,
const gfx::Point& press_pt,
ui::OSExchangeData* data) override;
@@ -261,12 +269,16 @@ class VIEWS_EXPORT Textfield : public View,
const gfx::Point& press_pt,
const gfx::Point& p) override;
- // WordLookupClient overrides:
+ // FocusChangeListener:
+ void OnWillChangeFocus(View* focused_before, View* focused_now) override;
+ void OnDidChangeFocus(View* focused_before, View* focused_now) override;
+
+ // WordLookupClient:
bool GetDecoratedWordAtPoint(const gfx::Point& point,
gfx::DecoratedText* decorated_word,
gfx::Point* baseline_point) override;
- // ui::TouchEditable overrides:
+ // ui::TouchEditable:
void SelectRect(const gfx::Point& start, const gfx::Point& end) override;
void MoveCaretTo(const gfx::Point& point) override;
void GetSelectionEndPoints(gfx::SelectionBound* anchor,
@@ -279,14 +291,14 @@ class VIEWS_EXPORT Textfield : public View,
void OpenContextMenu(const gfx::Point& anchor) override;
void DestroyTouchSelection() override;
- // ui::SimpleMenuModel::Delegate overrides:
+ // ui::SimpleMenuModel::Delegate:
bool IsCommandIdChecked(int command_id) const override;
bool IsCommandIdEnabled(int command_id) const override;
bool GetAcceleratorForCommandId(int command_id,
ui::Accelerator* accelerator) const override;
void ExecuteCommand(int command_id, int event_flags) override;
- // ui::TextInputClient overrides:
+ // ui::TextInputClient:
void SetCompositionText(const ui::CompositionText& composition) override;
void ConfirmCompositionText() override;
void ClearCompositionText() override;
@@ -334,7 +346,7 @@ class VIEWS_EXPORT Textfield : public View,
private:
friend class TextfieldTestApi;
- // View overrides:
+ // View:
// Declared final since overriding by subclasses would interfere with the
// accounting related to the scheduled text edit command. Subclasses should
// use TextfieldController::HandleKeyEvent, to intercept the key event.
@@ -457,6 +469,10 @@ class VIEWS_EXPORT Textfield : public View,
SkColor selection_text_color_;
SkColor selection_background_color_;
+ // Whether to start drawing the text selection in gray due to the Widget
+ // losing focus.
+ bool change_selection_background_color_on_next_blur_;
+
// Text to display when empty.
base::string16 placeholder_text_;

Powered by Google App Engine
This is Rietveld 408576698