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 "content/browser/renderer_host/input/touch_selection_controller.h" | 5 #include "content/browser/renderer_host/input/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 #include "third_party/WebKit/public/web/WebInputEvent.h" | 9 #include "third_party/WebKit/public/web/WebInputEvent.h" |
10 | 10 |
(...skipping 28 matching lines...) Expand all Loading... | |
39 start_orientation_(TOUCH_HANDLE_ORIENTATION_UNDEFINED), | 39 start_orientation_(TOUCH_HANDLE_ORIENTATION_UNDEFINED), |
40 end_orientation_(TOUCH_HANDLE_ORIENTATION_UNDEFINED), | 40 end_orientation_(TOUCH_HANDLE_ORIENTATION_UNDEFINED), |
41 is_insertion_active_(false), | 41 is_insertion_active_(false), |
42 activate_insertion_automatically_(false), | 42 activate_insertion_automatically_(false), |
43 is_selection_active_(false), | 43 is_selection_active_(false), |
44 activate_selection_automatically_(false), | 44 activate_selection_automatically_(false), |
45 selection_empty_(false), | 45 selection_empty_(false), |
46 selection_editable_(false), | 46 selection_editable_(false), |
47 temporarily_hidden_(false) { | 47 temporarily_hidden_(false) { |
48 DCHECK(client_); | 48 DCHECK(client_); |
49 HideAndDisallowShowingAutomatically(); | 49 HideAndDisallowShowingAutomatically(); // XXX: needed? |
jdduke (slow)
2014/11/13 15:18:55
Probably not =/
mohsen
2015/02/22 23:23:09
Removed.
| |
50 } | 50 } |
51 | 51 |
52 TouchSelectionController::~TouchSelectionController() { | 52 TouchSelectionController::~TouchSelectionController() { |
53 } | 53 } |
54 | 54 |
55 void TouchSelectionController::OnSelectionBoundsChanged( | 55 void TouchSelectionController::OnSelectionBoundsChanged( |
56 const cc::ViewportSelectionBound& start, | 56 const cc::ViewportSelectionBound& start, |
57 const cc::ViewportSelectionBound& end) { | 57 const cc::ViewportSelectionBound& end) { |
58 if (!activate_selection_automatically_ && | 58 if (!activate_selection_automatically_ && |
59 !activate_insertion_automatically_) { | 59 !activate_insertion_automatically_) { |
(...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
196 | 196 |
197 if (is_selection_active_) { | 197 if (is_selection_active_) { |
198 bool needs_animate = start_selection_handle_->Animate(frame_time); | 198 bool needs_animate = start_selection_handle_->Animate(frame_time); |
199 needs_animate |= end_selection_handle_->Animate(frame_time); | 199 needs_animate |= end_selection_handle_->Animate(frame_time); |
200 return needs_animate; | 200 return needs_animate; |
201 } | 201 } |
202 | 202 |
203 return false; | 203 return false; |
204 } | 204 } |
205 | 205 |
206 void TouchSelectionController::ActivateSelection( | |
207 const cc::ViewportSelectionBound& start, | |
208 const cc::ViewportSelectionBound& end) { | |
209 if (start.edge_bottom != end.edge_bottom) { | |
210 ShowSelectionHandlesAutomatically(); | |
211 OnSelectionBoundsChanged(start, end); | |
212 } | |
213 } | |
214 | |
206 void TouchSelectionController::OnHandleDragBegin(const TouchHandle& handle) { | 215 void TouchSelectionController::OnHandleDragBegin(const TouchHandle& handle) { |
207 if (&handle == insertion_handle_.get()) { | 216 if (&handle == insertion_handle_.get()) { |
208 client_->OnSelectionEvent(INSERTION_DRAG_STARTED, handle.position()); | 217 client_->OnSelectionEvent(INSERTION_DRAG_STARTED, handle.position()); |
209 return; | 218 return; |
210 } | 219 } |
211 | 220 |
212 gfx::PointF base, extent; | 221 gfx::PointF base, extent; |
213 if (&handle == start_selection_handle_.get()) { | 222 if (&handle == start_selection_handle_.get()) { |
214 base = end_selection_handle_->position() + GetEndLineOffset(); | 223 base = end_selection_handle_->position() + GetEndLineOffset(); |
215 extent = start_selection_handle_->position() + GetStartLineOffset(); | 224 extent = start_selection_handle_->position() + GetStartLineOffset(); |
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
299 client_->OnSelectionEvent(INSERTION_MOVED, position); | 308 client_->OnSelectionEvent(INSERTION_MOVED, position); |
300 | 309 |
301 insertion_handle_->SetVisible(GetStartVisible(), | 310 insertion_handle_->SetVisible(GetStartVisible(), |
302 GetAnimationStyle(was_active)); | 311 GetAnimationStyle(was_active)); |
303 insertion_handle_->SetPosition(position); | 312 insertion_handle_->SetPosition(position); |
304 } | 313 } |
305 | 314 |
306 void TouchSelectionController::OnSelectionChanged() { | 315 void TouchSelectionController::OnSelectionChanged() { |
307 DeactivateInsertion(); | 316 DeactivateInsertion(); |
308 | 317 |
309 if (!activate_selection_automatically_) | 318 if (!activate_selection_automatically_) // XXX: needed? |
jdduke (slow)
2014/11/13 15:18:55
Yes, else the handles would be shown for programma
| |
310 return; | 319 return; |
311 | 320 |
312 const bool was_active = is_selection_active_; | 321 const bool was_active = is_selection_active_; |
313 ActivateSelection(); | 322 ActivateSelection(); |
314 | 323 |
315 const TouchHandle::AnimationStyle animation = GetAnimationStyle(was_active); | 324 const TouchHandle::AnimationStyle animation = GetAnimationStyle(was_active); |
316 start_selection_handle_->SetVisible(GetStartVisible(), animation); | 325 start_selection_handle_->SetVisible(GetStartVisible(), animation); |
317 end_selection_handle_->SetVisible(GetEndVisible(), animation); | 326 end_selection_handle_->SetVisible(GetEndVisible(), animation); |
318 | 327 |
319 start_selection_handle_->SetPosition(GetStartPosition()); | 328 start_selection_handle_->SetPosition(GetStartPosition()); |
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
414 } | 423 } |
415 | 424 |
416 TouchHandle::AnimationStyle TouchSelectionController::GetAnimationStyle( | 425 TouchHandle::AnimationStyle TouchSelectionController::GetAnimationStyle( |
417 bool was_active) const { | 426 bool was_active) const { |
418 return was_active && client_->SupportsAnimation() | 427 return was_active && client_->SupportsAnimation() |
419 ? TouchHandle::ANIMATION_SMOOTH | 428 ? TouchHandle::ANIMATION_SMOOTH |
420 : TouchHandle::ANIMATION_NONE; | 429 : TouchHandle::ANIMATION_NONE; |
421 } | 430 } |
422 | 431 |
423 } // namespace content | 432 } // namespace content |
OLD | NEW |