| 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 34cc30a526172079f53e9319952ca4127031b08d..6527fae82697ab2cd8742ff1d9cbcffb800eefbb 100644
|
| --- a/ui/touch_selection/touch_selection_controller.cc
|
| +++ b/ui/touch_selection/touch_selection_controller.cc
|
| @@ -66,6 +66,29 @@ TouchSelectionController::TouchSelectionController(
|
| TouchSelectionController::~TouchSelectionController() {
|
| }
|
|
|
| +void TouchSelectionController::OnViewportChanged(
|
| + const gfx::RectF viewport_rect) {
|
| + // Trigger a force update if the viewport is changed, so that
|
| + // it triggers a call to change the mirror values if required.
|
| + if (viewport_rect_ == viewport_rect)
|
| + return;
|
| +
|
| + viewport_rect_ = viewport_rect;
|
| +
|
| + if (active_status_ == INACTIVE)
|
| + return;
|
| +
|
| + if (active_status_ == INSERTION_ACTIVE) {
|
| + DCHECK(insertion_handle_);
|
| + insertion_handle_->SetViewportRect(viewport_rect);
|
| + } else if (active_status_ == SELECTION_ACTIVE) {
|
| + DCHECK(start_selection_handle_);
|
| + DCHECK(end_selection_handle_);
|
| + start_selection_handle_->SetViewportRect(viewport_rect);
|
| + end_selection_handle_->SetViewportRect(viewport_rect);
|
| + }
|
| +}
|
| +
|
| void TouchSelectionController::OnSelectionBoundsChanged(
|
| const SelectionBound& start,
|
| const SelectionBound& end) {
|
| @@ -291,11 +314,11 @@ void TouchSelectionController::OnHandleDragBegin(const TouchHandle& handle) {
|
|
|
| gfx::PointF base, extent;
|
| if (&handle == start_selection_handle_.get()) {
|
| - base = end_selection_handle_->position() + GetEndLineOffset();
|
| - extent = start_selection_handle_->position() + GetStartLineOffset();
|
| + base = end_selection_handle_->focus_bottom() + GetEndLineOffset();
|
| + extent = start_selection_handle_->focus_bottom() + GetStartLineOffset();
|
| } else {
|
| - base = start_selection_handle_->position() + GetStartLineOffset();
|
| - extent = end_selection_handle_->position() + GetEndLineOffset();
|
| + base = start_selection_handle_->focus_bottom() + GetStartLineOffset();
|
| + extent = end_selection_handle_->focus_bottom() + GetEndLineOffset();
|
| }
|
| selection_handle_dragged_ = true;
|
|
|
| @@ -396,9 +419,9 @@ void TouchSelectionController::OnInsertionChanged() {
|
| else
|
| client_->OnSelectionEvent(INSERTION_MOVED);
|
|
|
| + insertion_handle_->SetFocus(start_.edge_top(), start_.edge_bottom());
|
| insertion_handle_->SetVisible(GetStartVisible(),
|
| GetAnimationStyle(was_active));
|
| - insertion_handle_->SetPosition(position);
|
| }
|
|
|
| void TouchSelectionController::OnSelectionChanged() {
|
| @@ -414,11 +437,16 @@ void TouchSelectionController::OnSelectionChanged() {
|
| client_->OnSelectionEvent(SELECTION_MOVED);
|
|
|
| const TouchHandle::AnimationStyle animation = GetAnimationStyle(was_active);
|
| +
|
| + start_selection_handle_->SetFocus(start_.edge_top(), start_.edge_bottom());
|
| + end_selection_handle_->SetFocus(end_.edge_top(), end_.edge_bottom());
|
| +
|
| + start_selection_handle_->SetOrientation(start_orientation_);
|
| + end_selection_handle_->SetOrientation(end_orientation_);
|
| +
|
| start_selection_handle_->SetVisible(GetStartVisible(), animation);
|
| end_selection_handle_->SetVisible(GetEndVisible(), animation);
|
|
|
| - start_selection_handle_->SetPosition(GetStartPosition());
|
| - end_selection_handle_->SetPosition(GetEndPosition());
|
| }
|
|
|
| void TouchSelectionController::ActivateInsertion() {
|
| @@ -426,10 +454,11 @@ void TouchSelectionController::ActivateInsertion() {
|
|
|
| if (!insertion_handle_)
|
| insertion_handle_.reset(
|
| - new TouchHandle(this, TouchHandleOrientation::CENTER));
|
| + new TouchHandle(this, TouchHandleOrientation::CENTER, viewport_rect_));
|
|
|
| if (active_status_ == INACTIVE) {
|
| active_status_ = INSERTION_ACTIVE;
|
| + insertion_handle_->SetViewportRect(viewport_rect_);
|
| insertion_handle_->SetEnabled(true);
|
| client_->OnSelectionEvent(INSERTION_SHOWN);
|
| }
|
| @@ -448,17 +477,19 @@ void TouchSelectionController::ActivateSelection() {
|
| DCHECK_NE(INSERTION_ACTIVE, active_status_);
|
|
|
| if (!start_selection_handle_) {
|
| - start_selection_handle_.reset(new TouchHandle(this, start_orientation_));
|
| + start_selection_handle_.reset(
|
| + new TouchHandle(this, start_orientation_, viewport_rect_));
|
| } else {
|
| + start_selection_handle_->SetViewportRect(viewport_rect_);
|
| start_selection_handle_->SetEnabled(true);
|
| - start_selection_handle_->SetOrientation(start_orientation_);
|
| }
|
|
|
| if (!end_selection_handle_) {
|
| - end_selection_handle_.reset(new TouchHandle(this, end_orientation_));
|
| + end_selection_handle_.reset(
|
| + new TouchHandle(this, end_orientation_, viewport_rect_));
|
| } else {
|
| + end_selection_handle_->SetViewportRect(viewport_rect_);
|
| end_selection_handle_->SetEnabled(true);
|
| - end_selection_handle_->SetOrientation(end_orientation_);
|
| }
|
|
|
| // As a long press received while a selection is already active may trigger
|
|
|