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

Unified Diff: ui/touch_selection/touch_selection_controller.cc

Issue 481683003: Support for Adaptive Handle Orientation (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: cleanup Created 5 years, 8 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 2e18037c658c9b0f7fc02d66e5a8471e8589d0a2..84cf8d83fa7f6c7072819d8a0433028d232cb3d2 100644
--- a/ui/touch_selection/touch_selection_controller.cc
+++ b/ui/touch_selection/touch_selection_controller.cc
@@ -59,6 +59,7 @@ TouchSelectionController::TouchSelectionController(
selection_empty_(false),
selection_editable_(false),
temporarily_hidden_(false),
+ viewport_size_changed_(false),
selection_handle_dragged_(false) {
DCHECK(client_);
}
@@ -66,16 +67,25 @@ TouchSelectionController::TouchSelectionController(
TouchSelectionController::~TouchSelectionController() {
}
+void TouchSelectionController::OnViewportChanged(
+ const gfx::RectF viewport_rect) {
+ if (viewport_rect_ == viewport_rect)
+ return;
+ viewport_size_changed_ = true;
+ viewport_rect_ = viewport_rect;
+}
+
void TouchSelectionController::OnSelectionBoundsChanged(
const SelectionBound& start,
const SelectionBound& end) {
- if (start == start_ && end_ == end)
+ if (start == start_ && end_ == end && !viewport_size_changed_)
return;
start_ = start;
end_ = end;
start_orientation_ = ToTouchHandleOrientation(start_.type());
end_orientation_ = ToTouchHandleOrientation(end_.type());
+ viewport_size_changed_ = false;
if (!activate_selection_automatically_ &&
!activate_insertion_automatically_) {
@@ -329,9 +339,10 @@ void TouchSelectionController::OnInsertionChanged() {
else
client_->OnSelectionEvent(INSERTION_MOVED, position);
+ insertion_handle_->SetViewportRect(viewport_rect_);
+ insertion_handle_->SetFocus(start_.edge_top(), start_.edge_bottom());
jdduke (slow) 2015/05/11 15:40:16 Hmm, shouldn't the visibility update come first?
AviD 2015/05/19 16:26:28 It wouldn't matter much here, as we call updateLay
insertion_handle_->SetVisible(GetStartVisible(),
GetAnimationStyle(was_active));
- insertion_handle_->SetPosition(position);
}
void TouchSelectionController::OnSelectionChanged() {
@@ -346,9 +357,6 @@ void TouchSelectionController::OnSelectionChanged() {
const TouchHandle::AnimationStyle animation = GetAnimationStyle(was_active);
start_selection_handle_->SetVisible(GetStartVisible(), animation);
end_selection_handle_->SetVisible(GetEndVisible(), animation);
-
- start_selection_handle_->SetPosition(GetStartPosition());
jdduke (slow) 2015/05/11 15:40:16 Hmm, I think you need to rebase. We now only condi
AviD 2015/05/19 16:26:28 I will rebase in the next patch.
AviD 2015/05/21 09:23:15 Now that we have conditional calling of ActivateSe
- end_selection_handle_->SetPosition(GetEndPosition());
}
void TouchSelectionController::ActivateInsertion() {
@@ -381,6 +389,8 @@ void TouchSelectionController::ActivateSelection() {
start_selection_handle_.reset(new TouchHandle(this, start_orientation_));
} else {
start_selection_handle_->SetEnabled(true);
+ start_selection_handle_->SetFocus(start_.edge_top(), start_.edge_bottom());
+ start_selection_handle_->SetViewportRect(viewport_rect_);
start_selection_handle_->SetOrientation(start_orientation_);
}
@@ -388,6 +398,8 @@ void TouchSelectionController::ActivateSelection() {
end_selection_handle_.reset(new TouchHandle(this, end_orientation_));
} else {
end_selection_handle_->SetEnabled(true);
+ end_selection_handle_->SetFocus(end_.edge_top(), end_.edge_bottom());
+ end_selection_handle_->SetViewportRect(viewport_rect_);
end_selection_handle_->SetOrientation(end_orientation_);
}

Powered by Google App Engine
This is Rietveld 408576698