Index: ui/views/controls/textfield/native_textfield_views.cc |
diff --git a/ui/views/controls/textfield/native_textfield_views.cc b/ui/views/controls/textfield/native_textfield_views.cc |
index c4cae0e228127bcf44b62eaf022a768526217d56..9e978f9c9b83e7e3e05c566b0f0090beb16ed403 100644 |
--- a/ui/views/controls/textfield/native_textfield_views.cc |
+++ b/ui/views/controls/textfield/native_textfield_views.cc |
@@ -206,31 +206,31 @@ void NativeTextfieldViews::OnGestureEvent(ui::GestureEvent* event) { |
if (!GetRenderText()->IsPointInSelection(event->location())) { |
OnBeforeUserAction(); |
model_->SelectWord(); |
- touch_selection_controller_.reset( |
- ui::TouchSelectionController::create(this)); |
OnCaretBoundsChanged(); |
SchedulePaint(); |
OnAfterUserAction(); |
- if (touch_selection_controller_.get()) |
+ if (!touch_selection_controller_) |
+ CreateTouchSelectionControllerAndNotifyIt(); |
+ if (touch_selection_controller_) |
event->SetHandled(); |
} else if (switches::IsTouchDragDropEnabled()) { |
initiating_drag_ = true; |
touch_selection_controller_.reset(); |
} else { |
- if (!touch_selection_controller_.get()) |
+ if (!touch_selection_controller_) |
CreateTouchSelectionControllerAndNotifyIt(); |
- if (touch_selection_controller_.get()) |
+ if (touch_selection_controller_) |
event->SetHandled(); |
} |
return; |
case ui::ET_GESTURE_LONG_TAP: |
- if (!touch_selection_controller_.get()) |
+ if (!touch_selection_controller_) |
CreateTouchSelectionControllerAndNotifyIt(); |
// If touch selection is enabled, the context menu on long tap will be |
// shown by the |touch_selection_controller_|, hence we mark the event |
// handled so views does not try to show context menu on it. |
- if (touch_selection_controller_.get()) |
+ if (touch_selection_controller_) |
event->SetHandled(); |
break; |
default: |
@@ -1393,7 +1393,7 @@ void NativeTextfieldViews::OnCaretBoundsChanged() { |
textfield_->GetInputMethod()->OnCaretBoundsChanged(textfield_); |
// Notify selection controller |
- if (touch_selection_controller_.get()) |
+ if (touch_selection_controller_) |
touch_selection_controller_->SelectionChanged(); |
} |
@@ -1519,6 +1519,9 @@ bool NativeTextfieldViews::ShouldInsertChar(char16 ch, int flags) { |
} |
void NativeTextfieldViews::CreateTouchSelectionControllerAndNotifyIt() { |
+ if (!textfield_->IsFocusable() || !textfield_->HasFocus()) |
sky
2013/12/04 03:56:06
Why do you need to check IsFocusable? Don't you on
mohsen
2013/12/04 05:22:22
The textfield might have focus before getting disa
|
+ return; |
+ |
if (!touch_selection_controller_) { |
touch_selection_controller_.reset( |
ui::TouchSelectionController::create(this)); |