summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorjdduke <jdduke@chromium.org>2015-05-15 13:56:06 -0700
committerCommit bot <commit-bot@chromium.org>2015-05-15 20:56:19 +0000
commit9a0d887094a3b66880edf8f48d0065b9ddf4c75e (patch)
tree2b5fc59637548499ae8efc7c88b73df32d1e2bb3
parent4313b5b899dc48e3a89735deb82596d6983c21ba (diff)
downloadchromium_src-9a0d887094a3b66880edf8f48d0065b9ddf4c75e.zip
chromium_src-9a0d887094a3b66880edf8f48d0065b9ddf4c75e.tar.gz
chromium_src-9a0d887094a3b66880edf8f48d0065b9ddf4c75e.tar.bz2
Ensure async selections after longpress activate the handles
Fix an issue where the selection handles remain hidden if "empty" selection updates occur after a longpress but before the nonempty selection update. BUG=393025 NOTRY=true Review URL: https://codereview.chromium.org/1139123009 Cr-Commit-Position: refs/heads/master@{#330190}
-rw-r--r--ui/touch_selection/touch_selection_controller.cc8
-rw-r--r--ui/touch_selection/touch_selection_controller_unittest.cc21
2 files changed, 28 insertions, 1 deletions
diff --git a/ui/touch_selection/touch_selection_controller.cc b/ui/touch_selection/touch_selection_controller.cc
index ad010c3..34cc30a 100644
--- a/ui/touch_selection/touch_selection_controller.cc
+++ b/ui/touch_selection/touch_selection_controller.cc
@@ -491,8 +491,14 @@ void TouchSelectionController::DeactivateSelection() {
}
void TouchSelectionController::ForceNextUpdateIfInactive() {
- if (active_status_ == INACTIVE)
+ // Only force the update if the reported selection is non-empty but still
+ // considered "inactive", i.e., it wasn't preceded by a user gesture or
+ // the handles have since been explicitly hidden.
+ if (active_status_ == INACTIVE &&
+ start_.type() != SelectionBound::EMPTY &&
+ end_.type() != SelectionBound::EMPTY) {
force_next_update_ = true;
+ }
}
gfx::Vector2dF TouchSelectionController::GetStartLineOffset() const {
diff --git a/ui/touch_selection/touch_selection_controller_unittest.cc b/ui/touch_selection/touch_selection_controller_unittest.cc
index c78a5d5..8125c50 100644
--- a/ui/touch_selection/touch_selection_controller_unittest.cc
+++ b/ui/touch_selection/touch_selection_controller_unittest.cc
@@ -575,6 +575,27 @@ TEST_F(TouchSelectionControllerTest, SelectionBasic) {
EXPECT_EQ(gfx::PointF(), GetLastEventStart());
}
+TEST_F(TouchSelectionControllerTest, SelectionAllowsEmptyUpdateAfterLongPress) {
+ gfx::RectF start_rect(5, 5, 0, 10);
+ gfx::RectF end_rect(50, 5, 0, 10);
+ bool visible = true;
+
+ OnLongPressEvent();
+ EXPECT_THAT(GetAndResetEvents(), IsEmpty());
+
+ // There may be several empty updates after a longpress due to the
+ // asynchronous response. These empty updates should not prevent the selection
+ // handles from (eventually) activating.
+ ClearSelection();
+ EXPECT_THAT(GetAndResetEvents(), IsEmpty());
+
+ ClearSelection();
+ EXPECT_THAT(GetAndResetEvents(), IsEmpty());
+
+ ChangeSelection(start_rect, visible, end_rect, visible);
+ EXPECT_THAT(GetAndResetEvents(), ElementsAre(SELECTION_SHOWN));
+}
+
TEST_F(TouchSelectionControllerTest, SelectionRepeatedLongPress) {
gfx::RectF start_rect(5, 5, 0, 10);
gfx::RectF end_rect(50, 5, 0, 10);