Skip to content

Commit

Permalink
Prevent taps from suppressing selection handle updates
Browse files Browse the repository at this point in the history
A recent change made selection handle activation more strict, preventing
tap gestures from showing the handles. This inadvertently caused an
issue where tapping during a selection would prevent subsequent
selection handle updates. Fix this by only suppressing selection handle
activation after a tap if there's no active selection.

BUG=486045

Review URL: https://codereview.chromium.org/1135813002

Cr-Commit-Position: refs/heads/master@{#328995}
  • Loading branch information
jdduke authored and Commit bot committed May 8, 2015
1 parent b3dadfc commit 11d7eac
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
5 changes: 4 additions & 1 deletion ui/touch_selection/touch_selection_controller.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down Expand Up @@ -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();
Expand Down
8 changes: 8 additions & 0 deletions ui/touch_selection/touch_selection_controller_unittest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down

0 comments on commit 11d7eac

Please sign in to comment.