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

Unified Diff: ui/touch_selection/touch_selection_controller.cc

Issue 2201853002: Blink handle selection handle visibility (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: default handle visibility should be false Created 4 years, 4 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 ed8c1cca6ff6adb5be2608c9154c65fce5de3752..3e8aaf0490482026ec8d771fc70ab1a7f4db5e37 100644
--- a/ui/touch_selection/touch_selection_controller.cc
+++ b/ui/touch_selection/touch_selection_controller.cc
@@ -62,8 +62,6 @@ TouchSelectionController::TouchSelectionController(
start_orientation_(TouchHandleOrientation::UNDEFINED),
end_orientation_(TouchHandleOrientation::UNDEFINED),
active_status_(INACTIVE),
- activate_insertion_automatically_(false),
- activate_selection_automatically_(false),
selection_empty_(false),
selection_editable_(false),
temporarily_hidden_(false),
@@ -82,13 +80,11 @@ void TouchSelectionController::OnSelectionBoundsChanged(
if (!force_next_update_ && start == start_ && end_ == end)
return;
- // Notify if selection bounds have just been established or dissolved.
- if (start.type() != gfx::SelectionBound::EMPTY &&
- start_.type() == gfx::SelectionBound::EMPTY) {
- client_->OnSelectionEvent(SELECTION_ESTABLISHED);
- } else if (start.type() == gfx::SelectionBound::EMPTY &&
- start_.type() != gfx::SelectionBound::EMPTY) {
- client_->OnSelectionEvent(SELECTION_DISSOLVED);
+ gfx::SelectionBound defaultBound;
+ if (start == defaultBound && end == defaultBound) {
+ DeactivateSelection();
+ DeactivateInsertion();
+ return;
}
// Swap the Handles when the start and end selection points cross each other.
@@ -107,13 +103,6 @@ void TouchSelectionController::OnSelectionBoundsChanged(
end_orientation_ = ToTouchHandleOrientation(end_.type());
force_next_update_ = false;
- if (!activate_selection_automatically_ &&
- !activate_insertion_automatically_) {
- DCHECK_EQ(INACTIVE, active_status_);
- DCHECK_EQ(INPUT_EVENT_TYPE_NONE, response_pending_input_event_);
- return;
- }
-
// Ensure that |response_pending_input_event_| is cleared after the method
// completes, while also making its current value available for the duration
// of the call.
@@ -211,18 +200,11 @@ bool TouchSelectionController::WillHandleTouchEvent(const MotionEvent& event) {
bool TouchSelectionController::WillHandleTapEvent(const gfx::PointF& location,
int tap_count) {
- if (WillHandleTapOrLongPress(location))
- return true;
-
if (tap_count > 1) {
response_pending_input_event_ = REPEATED_TAP;
- ShowSelectionHandlesAutomatically();
} else {
response_pending_input_event_ = TAP;
- if (active_status_ != SELECTION_ACTIVE)
- activate_selection_automatically_ = false;
}
- ShowInsertionHandleAutomatically();
if (selection_empty_ && !config_.show_on_tap_for_empty_editable)
DeactivateInsertion();
ForceNextUpdateIfInactive();
@@ -232,13 +214,8 @@ bool TouchSelectionController::WillHandleTapEvent(const gfx::PointF& location,
bool TouchSelectionController::WillHandleLongPressEvent(
base::TimeTicks event_time,
const gfx::PointF& location) {
- if (WillHandleTapOrLongPress(location))
- return true;
-
longpress_drag_selector_.OnLongPressEvent(event_time, location);
response_pending_input_event_ = LONG_PRESS;
- ShowSelectionHandlesAutomatically();
- ShowInsertionHandleAutomatically();
ForceNextUpdateIfInactive();
return false;
}
@@ -255,32 +232,12 @@ void TouchSelectionController::OnScrollBeginEvent() {
// the cause of a selection change (see https://crbug.com/571897).
longpress_drag_selector_.OnScrollBeginEvent();
response_pending_input_event_ = INPUT_EVENT_TYPE_NONE;
- if (active_status_ == INACTIVE) {
- activate_insertion_automatically_ = false;
- activate_selection_automatically_ = false;
- }
-}
-
-void TouchSelectionController::AllowShowingFromCurrentSelection() {
- if (active_status_ != INACTIVE)
- return;
-
- activate_selection_automatically_ = true;
- activate_insertion_automatically_ = true;
- if (GetStartPosition() != GetEndPosition()) {
- OnSelectionChanged();
- } else if (start_orientation_ == TouchHandleOrientation::CENTER &&
- selection_editable_) {
- OnInsertionChanged();
- }
}
void TouchSelectionController::HideAndDisallowShowingAutomatically() {
response_pending_input_event_ = INPUT_EVENT_TYPE_NONE;
DeactivateInsertion();
DeactivateSelection();
- activate_insertion_automatically_ = false;
- activate_selection_automatically_ = false;
}
void TouchSelectionController::SetTemporarilyHidden(bool hidden) {
@@ -462,36 +419,6 @@ gfx::PointF TouchSelectionController::GetSelectionEnd() const {
return GetEndPosition();
}
-void TouchSelectionController::ShowInsertionHandleAutomatically() {
- if (activate_insertion_automatically_)
- return;
- activate_insertion_automatically_ = true;
- ForceNextUpdateIfInactive();
-}
-
-void TouchSelectionController::ShowSelectionHandlesAutomatically() {
- if (activate_selection_automatically_)
- return;
- activate_selection_automatically_ = true;
- ForceNextUpdateIfInactive();
-}
-
-bool TouchSelectionController::WillHandleTapOrLongPress(
- const gfx::PointF& location) {
- // If there is an active selection that was not triggered by a user gesture,
- // allow showing the handles for that selection if a gesture occurs within
- // the selection rect. Note that this hit test is at best a crude
- // approximation, and may swallow taps that actually fall outside the
- // real selection.
- if (active_status_ == INACTIVE &&
- GetStartPosition() != GetEndPosition() &&
- RectFBetweenSelectionBounds(start_, end_).Contains(location)) {
- AllowShowingFromCurrentSelection();
- return true;
- }
- return false;
-}
-
void TouchSelectionController::OnInsertionChanged() {
DeactivateSelection();
@@ -502,9 +429,6 @@ void TouchSelectionController::OnInsertionChanged() {
return;
}
- if (!activate_insertion_automatically_)
- return;
-
const bool activated = ActivateInsertionIfNecessary();
const TouchHandle::AnimationStyle animation = GetAnimationStyle(!activated);
@@ -520,9 +444,6 @@ void TouchSelectionController::OnInsertionChanged() {
void TouchSelectionController::OnSelectionChanged() {
DeactivateInsertion();
- if (!activate_selection_automatically_)
- return;
-
const bool activated = ActivateSelectionIfNecessary();
const TouchHandle::AnimationStyle animation = GetAnimationStyle(!activated);

Powered by Google App Engine
This is Rietveld 408576698