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 #include "base/metrics/histogram_macros.h" | 9 #include "base/metrics/histogram_macros.h" |
10 | 10 |
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
82 | 82 |
83 // Notify if selection bounds have just been established or dissolved. | 83 // Notify if selection bounds have just been established or dissolved. |
84 if (start.type() != SelectionBound::EMPTY && | 84 if (start.type() != SelectionBound::EMPTY && |
85 start_.type() == SelectionBound::EMPTY) { | 85 start_.type() == SelectionBound::EMPTY) { |
86 client_->OnSelectionEvent(SELECTION_ESTABLISHED); | 86 client_->OnSelectionEvent(SELECTION_ESTABLISHED); |
87 } else if (start.type() == SelectionBound::EMPTY && | 87 } else if (start.type() == SelectionBound::EMPTY && |
88 start_.type() != SelectionBound::EMPTY) { | 88 start_.type() != SelectionBound::EMPTY) { |
89 client_->OnSelectionEvent(SELECTION_DISSOLVED); | 89 client_->OnSelectionEvent(SELECTION_DISSOLVED); |
90 } | 90 } |
91 | 91 |
92 // Swap the Handles when the start and end selection points cross each other. | |
93 if (active_status_ == SELECTION_ACTIVE) { | |
94 if ((start_selection_handle_->IsActive() && | |
95 end_.edge_bottom() == start.edge_bottom()) || | |
96 (end_selection_handle_->IsActive() && | |
97 end.edge_bottom() == start_.edge_bottom())) { | |
98 start_selection_handle_.swap(end_selection_handle_); | |
99 } | |
100 } | |
101 | |
92 start_ = start; | 102 start_ = start; |
93 end_ = end; | 103 end_ = end; |
94 start_orientation_ = ToTouchHandleOrientation(start_.type()); | 104 start_orientation_ = ToTouchHandleOrientation(start_.type()); |
95 end_orientation_ = ToTouchHandleOrientation(end_.type()); | 105 end_orientation_ = ToTouchHandleOrientation(end_.type()); |
96 force_next_update_ = false; | 106 force_next_update_ = false; |
97 | 107 |
98 if (!activate_selection_automatically_ && | 108 if (!activate_selection_automatically_ && |
99 !activate_insertion_automatically_) { | 109 !activate_insertion_automatically_) { |
100 DCHECK_EQ(INACTIVE, active_status_); | 110 DCHECK_EQ(INACTIVE, active_status_); |
101 DCHECK_EQ(INPUT_EVENT_TYPE_NONE, response_pending_input_event_); | 111 DCHECK_EQ(INPUT_EVENT_TYPE_NONE, response_pending_input_event_); |
(...skipping 540 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
642 return !temporarily_hidden_ && !longpress_drag_selector_.IsActive(); | 652 return !temporarily_hidden_ && !longpress_drag_selector_.IsActive(); |
643 } | 653 } |
644 | 654 |
645 bool TouchSelectionController::GetEndVisible() const { | 655 bool TouchSelectionController::GetEndVisible() const { |
646 if (!end_.visible()) | 656 if (!end_.visible()) |
647 return false; | 657 return false; |
648 | 658 |
649 return !temporarily_hidden_ && !longpress_drag_selector_.IsActive(); | 659 return !temporarily_hidden_ && !longpress_drag_selector_.IsActive(); |
650 } | 660 } |
651 | 661 |
662 TouchHandleOrientation TouchSelectionController::GetStartHandleOrientation() | |
663 const { | |
mohsen
2015/11/19 21:35:36
Can you add this logic directly in |TouchSelection
AviD
2015/12/11 11:25:53
Done.
| |
664 if (active_status_ != SELECTION_ACTIVE) | |
665 return TouchHandleOrientation::UNDEFINED; | |
666 return start_selection_handle_->orientation(); | |
667 } | |
668 | |
669 TouchHandleOrientation TouchSelectionController::GetEndHandleOrientation() | |
670 const { | |
671 if (active_status_ != SELECTION_ACTIVE) | |
672 return TouchHandleOrientation::UNDEFINED; | |
673 return end_selection_handle_->orientation(); | |
674 } | |
675 | |
652 TouchHandle::AnimationStyle TouchSelectionController::GetAnimationStyle( | 676 TouchHandle::AnimationStyle TouchSelectionController::GetAnimationStyle( |
653 bool was_active) const { | 677 bool was_active) const { |
654 return was_active && client_->SupportsAnimation() | 678 return was_active && client_->SupportsAnimation() |
655 ? TouchHandle::ANIMATION_SMOOTH | 679 ? TouchHandle::ANIMATION_SMOOTH |
656 : TouchHandle::ANIMATION_NONE; | 680 : TouchHandle::ANIMATION_NONE; |
657 } | 681 } |
658 | 682 |
659 void TouchSelectionController::LogSelectionEnd() { | 683 void TouchSelectionController::LogSelectionEnd() { |
660 // TODO(mfomitchev): Once we are able to tell the difference between | 684 // TODO(mfomitchev): Once we are able to tell the difference between |
661 // 'successful' and 'unsuccessful' selections - log | 685 // 'successful' and 'unsuccessful' selections - log |
662 // Event.TouchSelection.Duration instead and get rid of | 686 // Event.TouchSelection.Duration instead and get rid of |
663 // Event.TouchSelectionD.WasDraggeduration. | 687 // Event.TouchSelectionD.WasDraggeduration. |
664 if (selection_handle_dragged_) { | 688 if (selection_handle_dragged_) { |
665 base::TimeDelta duration = base::TimeTicks::Now() - selection_start_time_; | 689 base::TimeDelta duration = base::TimeTicks::Now() - selection_start_time_; |
666 UMA_HISTOGRAM_CUSTOM_TIMES("Event.TouchSelection.WasDraggedDuration", | 690 UMA_HISTOGRAM_CUSTOM_TIMES("Event.TouchSelection.WasDraggedDuration", |
667 duration, | 691 duration, |
668 base::TimeDelta::FromMilliseconds(500), | 692 base::TimeDelta::FromMilliseconds(500), |
669 base::TimeDelta::FromSeconds(60), | 693 base::TimeDelta::FromSeconds(60), |
670 60); | 694 60); |
671 } | 695 } |
672 } | 696 } |
673 | 697 |
674 } // namespace ui | 698 } // namespace ui |
OLD | NEW |