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

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

Issue 138033014: Consistent fading behavior for touch editing handles (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 11 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 93cc7b3c6eb95e988e0791d48682cb3f0df43035..c754fbf3256c5bc9250c7288204c912a6dd44cfd 100644
--- a/ui/views/controls/textfield/textfield.cc
+++ b/ui/views/controls/textfield/textfield.cc
@@ -336,7 +336,7 @@ void Textfield::OnPaint(gfx::Canvas* canvas) {
bool Textfield::OnKeyPressed(const ui::KeyEvent& event) {
bool handled = controller_ && controller_->HandleKeyEvent(this, event);
- touch_selection_controller_.reset();
+ SetTouchSelectionController(NULL);
if (handled)
return true;
@@ -498,7 +498,7 @@ bool Textfield::OnMousePressed(const ui::MouseEvent& event) {
}
OnAfterUserAction();
- touch_selection_controller_.reset();
+ SetTouchSelectionController(NULL);
return true;
}
@@ -568,7 +568,7 @@ void Textfield::OnBlur() {
RepaintCursor();
}
- touch_selection_controller_.reset();
+ SetTouchSelectionController(NULL);
// Border typically draws focus indicator.
SchedulePaint();
@@ -680,8 +680,7 @@ void Textfield::OnGestureEvent(ui::GestureEvent* event) {
if (!GetRenderText()->IsPointInSelection(event->location())) {
OnBeforeUserAction();
model_->SelectWord();
- touch_selection_controller_.reset(
- ui::TouchSelectionController::create(this));
+ SetTouchSelectionController(ui::TouchSelectionController::create(this));
OnCaretBoundsChanged();
SchedulePaint();
OnAfterUserAction();
@@ -689,7 +688,7 @@ void Textfield::OnGestureEvent(ui::GestureEvent* event) {
event->SetHandled();
} else if (switches::IsTouchDragDropEnabled()) {
initiating_drag_ = true;
- touch_selection_controller_.reset();
+ SetTouchSelectionController(NULL);
} else {
if (!touch_selection_controller_)
CreateTouchSelectionControllerAndNotifyIt();
@@ -932,7 +931,7 @@ bool Textfield::DrawsHandles() {
}
void Textfield::OpenContextMenu(const gfx::Point& anchor) {
- touch_selection_controller_.reset();
+ SetTouchSelectionController(NULL);
ShowContextMenu(anchor, ui::MENU_SOURCE_TOUCH_EDIT_MENU);
}
@@ -973,7 +972,7 @@ bool Textfield::GetAcceleratorForCommandId(int command_id,
}
void Textfield::ExecuteCommand(int command_id, int event_flags) {
- touch_selection_controller_.reset();
+ SetTouchSelectionController(NULL);
if (!IsCommandIdEnabled(command_id))
return;
@@ -1462,12 +1461,16 @@ void Textfield::RevealPasswordChar(int index) {
}
void Textfield::CreateTouchSelectionControllerAndNotifyIt() {
- if (!touch_selection_controller_) {
- touch_selection_controller_.reset(
- ui::TouchSelectionController::create(this));
- }
+ if (!touch_selection_controller_)
+ SetTouchSelectionController(ui::TouchSelectionController::create(this));
if (touch_selection_controller_)
touch_selection_controller_->SelectionChanged();
}
+void Textfield::SetTouchSelectionController(ui::TouchSelectionController* tsc) {
+ if (touch_selection_controller_)
+ touch_selection_controller_->HideHandles(false);
+ touch_selection_controller_.reset(tsc);
sky 2014/01/16 23:15:02 Can the destructor imply HideHandles(false) so tha
mohsen 2014/01/17 02:09:41 Yep! Done. Now, handles fade out in their destruct
+}
+
} // namespace views

Powered by Google App Engine
This is Rietveld 408576698