| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "ui/touch_selection/touch_selection_controller.h" | 5 #include "ui/touch_selection/touch_selection_controller.h" |
| 6 | 6 |
| 7 #include "base/auto_reset.h" | 7 #include "base/auto_reset.h" |
| 8 #include "base/logging.h" | 8 #include "base/logging.h" |
| 9 | 9 |
| 10 namespace ui { | 10 namespace ui { |
| (...skipping 237 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 248 const gfx::PointF& position) { | 248 const gfx::PointF& position) { |
| 249 // As the position corresponds to the bottom left point of the selection | 249 // As the position corresponds to the bottom left point of the selection |
| 250 // bound, offset it by half the corresponding line height. | 250 // bound, offset it by half the corresponding line height. |
| 251 gfx::Vector2dF line_offset = &handle == end_selection_handle_.get() | 251 gfx::Vector2dF line_offset = &handle == end_selection_handle_.get() |
| 252 ? GetStartLineOffset() | 252 ? GetStartLineOffset() |
| 253 : GetEndLineOffset(); | 253 : GetEndLineOffset(); |
| 254 gfx::PointF line_position = position + line_offset; | 254 gfx::PointF line_position = position + line_offset; |
| 255 if (&handle == insertion_handle_.get()) { | 255 if (&handle == insertion_handle_.get()) { |
| 256 client_->MoveCaret(line_position); | 256 client_->MoveCaret(line_position); |
| 257 } else { | 257 } else { |
| 258 client_->MoveRangeSelectionExtent(line_position); | 258 client_->MoveRangeSelectionExtent(line_position, ui::CHARACTER_GRANULARITY); |
| 259 } | 259 } |
| 260 } | 260 } |
| 261 | 261 |
| 262 void TouchSelectionController::OnHandleDragEnd(const TouchHandle& handle) { | 262 void TouchSelectionController::OnHandleDragEnd(const TouchHandle& handle) { |
| 263 if (&handle != insertion_handle_.get()) | 263 if (&handle != insertion_handle_.get()) |
| 264 client_->OnSelectionEvent(SELECTION_DRAG_STOPPED, handle.position()); | 264 client_->OnSelectionEvent(SELECTION_DRAG_STOPPED, handle.position()); |
| 265 } | 265 } |
| 266 | 266 |
| 267 void TouchSelectionController::OnHandleTapped(const TouchHandle& handle) { | 267 void TouchSelectionController::OnHandleTapped(const TouchHandle& handle) { |
| 268 if (insertion_handle_ && &handle == insertion_handle_.get()) | 268 if (insertion_handle_ && &handle == insertion_handle_.get()) |
| (...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 434 } | 434 } |
| 435 | 435 |
| 436 TouchHandle::AnimationStyle TouchSelectionController::GetAnimationStyle( | 436 TouchHandle::AnimationStyle TouchSelectionController::GetAnimationStyle( |
| 437 bool was_active) const { | 437 bool was_active) const { |
| 438 return was_active && client_->SupportsAnimation() | 438 return was_active && client_->SupportsAnimation() |
| 439 ? TouchHandle::ANIMATION_SMOOTH | 439 ? TouchHandle::ANIMATION_SMOOTH |
| 440 : TouchHandle::ANIMATION_NONE; | 440 : TouchHandle::ANIMATION_NONE; |
| 441 } | 441 } |
| 442 | 442 |
| 443 } // namespace ui | 443 } // namespace ui |
| OLD | NEW |