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..feac0e3ccfad26d2fbf2e8ca76eb9a219379a782 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_) { |
@@ -331,7 +341,7 @@ void TouchSelectionController::OnInsertionChanged() { |
insertion_handle_->SetVisible(GetStartVisible(), |
GetAnimationStyle(was_active)); |
- insertion_handle_->SetPosition(position); |
+ insertion_handle_->UpdatePosition(); |
} |
void TouchSelectionController::OnSelectionChanged() { |
@@ -347,8 +357,8 @@ void TouchSelectionController::OnSelectionChanged() { |
start_selection_handle_->SetVisible(GetStartVisible(), animation); |
end_selection_handle_->SetVisible(GetEndVisible(), animation); |
- start_selection_handle_->SetPosition(GetStartPosition()); |
- end_selection_handle_->SetPosition(GetEndPosition()); |
+ start_selection_handle_->UpdatePosition(); |
+ end_selection_handle_->UpdatePosition(); |
} |
void TouchSelectionController::ActivateInsertion() { |
@@ -361,6 +371,8 @@ void TouchSelectionController::ActivateInsertion() { |
if (!is_insertion_active_) { |
is_insertion_active_ = true; |
insertion_handle_->SetEnabled(true); |
+ insertion_handle_->SetFocus(start_.edge_top(), start_.edge_bottom()); |
+ insertion_handle_->SetViewportRect(viewport_rect_); |
client_->OnSelectionEvent(INSERTION_SHOWN, GetStartPosition()); |
} |
} |
@@ -381,6 +393,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 +402,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_); |
} |