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

Unified Diff: ui/touch_selection/touch_selection_controller.cc

Issue 1127383007: Be explicit about forcing TouchSelectionController updates (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Initialize force_next_update_ Created 5 years, 7 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/touch_selection/touch_selection_controller.cc
diff --git a/ui/touch_selection/touch_selection_controller.cc b/ui/touch_selection/touch_selection_controller.cc
index 1c8ceae98b5fe1d7d6508e5a3c254ddf82ba4b9a..6c70d47d0d4b6d70c73145ac9f99939b1aaacfd9 100644
--- a/ui/touch_selection/touch_selection_controller.cc
+++ b/ui/touch_selection/touch_selection_controller.cc
@@ -48,6 +48,7 @@ TouchSelectionController::TouchSelectionController(
: client_(client),
tap_timeout_(tap_timeout),
tap_slop_(tap_slop),
+ force_next_update_(false),
show_on_tap_for_empty_editable_(show_on_tap_for_empty_editable),
response_pending_input_event_(INPUT_EVENT_TYPE_NONE),
start_orientation_(TouchHandleOrientation::UNDEFINED),
@@ -68,13 +69,14 @@ TouchSelectionController::~TouchSelectionController() {
void TouchSelectionController::OnSelectionBoundsChanged(
const SelectionBound& start,
const SelectionBound& end) {
- if (start == start_ && end_ == end)
+ if (!force_next_update_ && start == start_ && end_ == end)
return;
start_ = start;
end_ = end;
start_orientation_ = ToTouchHandleOrientation(start_.type());
end_orientation_ = ToTouchHandleOrientation(end_.type());
+ force_next_update_ = false;
if (!activate_selection_automatically_ &&
!activate_insertion_automatically_) {
@@ -155,7 +157,7 @@ void TouchSelectionController::OnLongPressEvent() {
response_pending_input_event_ = LONG_PRESS;
ShowSelectionHandlesAutomatically();
ShowInsertionHandleAutomatically();
- ResetCachedValuesIfInactive();
+ ForceNextUpdateIfInactive();
}
void TouchSelectionController::AllowShowingFromCurrentSelection() {
@@ -179,7 +181,7 @@ void TouchSelectionController::OnTapEvent() {
ShowInsertionHandleAutomatically();
if (selection_empty_ && !show_on_tap_for_empty_editable_)
DeactivateInsertion();
- ResetCachedValuesIfInactive();
+ ForceNextUpdateIfInactive();
}
void TouchSelectionController::HideAndDisallowShowingAutomatically() {
@@ -208,7 +210,7 @@ void TouchSelectionController::OnSelectionEditable(bool editable) {
if (selection_editable_ == editable)
return;
selection_editable_ = editable;
- ResetCachedValuesIfInactive();
+ ForceNextUpdateIfInactive();
if (!selection_editable_)
DeactivateInsertion();
}
@@ -217,7 +219,7 @@ void TouchSelectionController::OnSelectionEmpty(bool empty) {
if (selection_empty_ == empty)
return;
selection_empty_ = empty;
- ResetCachedValuesIfInactive();
+ ForceNextUpdateIfInactive();
}
bool TouchSelectionController::Animate(base::TimeTicks frame_time) {
@@ -340,14 +342,14 @@ void TouchSelectionController::ShowInsertionHandleAutomatically() {
if (activate_insertion_automatically_)
return;
activate_insertion_automatically_ = true;
- ResetCachedValuesIfInactive();
+ ForceNextUpdateIfInactive();
}
void TouchSelectionController::ShowSelectionHandlesAutomatically() {
if (activate_selection_automatically_)
return;
activate_selection_automatically_ = true;
- ResetCachedValuesIfInactive();
+ ForceNextUpdateIfInactive();
}
void TouchSelectionController::OnInsertionChanged() {
@@ -463,13 +465,9 @@ void TouchSelectionController::DeactivateSelection() {
client_->OnSelectionEvent(SELECTION_CLEARED);
}
-void TouchSelectionController::ResetCachedValuesIfInactive() {
- if (active_status_ != INACTIVE)
- return;
- start_ = SelectionBound();
- end_ = SelectionBound();
- start_orientation_ = TouchHandleOrientation::UNDEFINED;
- end_orientation_ = TouchHandleOrientation::UNDEFINED;
+void TouchSelectionController::ForceNextUpdateIfInactive() {
+ if (active_status_ == INACTIVE)
+ force_next_update_ = true;
}
gfx::Vector2dF TouchSelectionController::GetStartLineOffset() const {
« no previous file with comments | « ui/touch_selection/touch_selection_controller.h ('k') | ui/touch_selection/touch_selection_controller_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698