diff --git a/ui/touch_selection/touch_selection_controller.cc b/ui/touch_selection/touch_selection_controller.cc index 29068794dbb3af..540dfee5237bc1 100644 --- a/ui/touch_selection/touch_selection_controller.cc +++ b/ui/touch_selection/touch_selection_controller.cc @@ -79,6 +79,8 @@ void TouchSelectionController::OnSelectionBoundsChanged( if (!activate_selection_automatically_ && !activate_insertion_automatically_) { + DCHECK(!is_insertion_active_); + DCHECK(!is_selection_active_); DCHECK_EQ(INPUT_EVENT_TYPE_NONE, response_pending_input_event_); return; } @@ -173,7 +175,8 @@ void TouchSelectionController::AllowShowingFromCurrentSelection() { void TouchSelectionController::OnTapEvent() { response_pending_input_event_ = TAP; - activate_selection_automatically_ = false; + if (!is_selection_active_) + activate_selection_automatically_ = false; ShowInsertionHandleAutomatically(); if (selection_empty_ && !show_on_tap_for_empty_editable_) DeactivateInsertion(); diff --git a/ui/touch_selection/touch_selection_controller_unittest.cc b/ui/touch_selection/touch_selection_controller_unittest.cc index 22059588abd45c..247ed97a45ae75 100644 --- a/ui/touch_selection/touch_selection_controller_unittest.cc +++ b/ui/touch_selection/touch_selection_controller_unittest.cc @@ -924,6 +924,14 @@ TEST_F(TouchSelectionControllerTest, NoSelectionAfterLongpressThenTap) { controller().OnLongPressEvent(); ChangeSelection(start_rect, visible, end_rect, visible); EXPECT_THAT(GetAndResetEvents(), ElementsAre(SELECTION_SHOWN)); + + // Tapping again shouldn't have any effect on subsequent selection events. + controller().OnTapEvent(); + end_rect.Offset(10, 10); + ChangeSelection(start_rect, visible, end_rect, visible); + EXPECT_THAT(GetAndResetEvents(), ElementsAre(SELECTION_MOVED)); + ClearSelection(); + EXPECT_THAT(GetAndResetEvents(), ElementsAre(SELECTION_CLEARED)); } TEST_F(TouchSelectionControllerTest, AllowShowingFromCurrentSelection) {