| 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 <vector> | 7 #include <vector> |
| 8 | 8 |
| 9 #include "testing/gmock/include/gmock/gmock.h" | 9 #include "testing/gmock/include/gmock/gmock.h" |
| 10 #include "testing/gtest/include/gtest/gtest.h" | 10 #include "testing/gtest/include/gtest/gtest.h" |
| (...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 111 this, | 111 this, |
| 112 base::TimeDelta::FromMilliseconds(kDefaultTapTimeoutMs), | 112 base::TimeDelta::FromMilliseconds(kDefaultTapTimeoutMs), |
| 113 kDefaulTapSlop, | 113 kDefaulTapSlop, |
| 114 show_on_tap_for_empty_editable)); | 114 show_on_tap_for_empty_editable)); |
| 115 } | 115 } |
| 116 | 116 |
| 117 void SetAnimationEnabled(bool enabled) { animation_enabled_ = enabled; } | 117 void SetAnimationEnabled(bool enabled) { animation_enabled_ = enabled; } |
| 118 void SetDraggingEnabled(bool enabled) { dragging_enabled_ = enabled; } | 118 void SetDraggingEnabled(bool enabled) { dragging_enabled_ = enabled; } |
| 119 | 119 |
| 120 void ClearSelection() { | 120 void ClearSelection() { |
| 121 controller_->OnSelectionBoundsChanged(SelectionBound(), | 121 controller_->OnSelectionBoundsUpdated(SelectionBound(), |
| 122 SelectionBound()); | 122 SelectionBound()); |
| 123 } | 123 } |
| 124 | 124 |
| 125 void ClearInsertion() { ClearSelection(); } | 125 void ClearInsertion() { ClearSelection(); } |
| 126 | 126 |
| 127 void ChangeInsertion(const gfx::RectF& rect, bool visible) { | 127 void ChangeInsertion(const gfx::RectF& rect, bool visible) { |
| 128 SelectionBound bound; | 128 SelectionBound bound; |
| 129 bound.set_type(SelectionBound::CENTER); | 129 bound.set_type(SelectionBound::CENTER); |
| 130 bound.SetEdge(rect.origin(), rect.bottom_left()); | 130 bound.SetEdge(rect.origin(), rect.bottom_left()); |
| 131 bound.set_visible(visible); | 131 bound.set_visible(visible); |
| 132 controller_->OnSelectionBoundsChanged(bound, bound); | 132 controller_->OnSelectionBoundsUpdated(bound, bound); |
| 133 } | 133 } |
| 134 | 134 |
| 135 void ChangeSelection(const gfx::RectF& start_rect, | 135 void ChangeSelection(const gfx::RectF& start_rect, |
| 136 bool start_visible, | 136 bool start_visible, |
| 137 const gfx::RectF& end_rect, | 137 const gfx::RectF& end_rect, |
| 138 bool end_visible) { | 138 bool end_visible) { |
| 139 SelectionBound start_bound, end_bound; | 139 SelectionBound start_bound, end_bound; |
| 140 start_bound.set_type(SelectionBound::LEFT); | 140 start_bound.set_type(SelectionBound::LEFT); |
| 141 end_bound.set_type(SelectionBound::RIGHT); | 141 end_bound.set_type(SelectionBound::RIGHT); |
| 142 start_bound.SetEdge(start_rect.origin(), start_rect.bottom_left()); | 142 start_bound.SetEdge(start_rect.origin(), start_rect.bottom_left()); |
| 143 end_bound.SetEdge(end_rect.origin(), end_rect.bottom_left()); | 143 end_bound.SetEdge(end_rect.origin(), end_rect.bottom_left()); |
| 144 start_bound.set_visible(start_visible); | 144 start_bound.set_visible(start_visible); |
| 145 end_bound.set_visible(end_visible); | 145 end_bound.set_visible(end_visible); |
| 146 controller_->OnSelectionBoundsChanged(start_bound, end_bound); | 146 controller_->OnSelectionBoundsUpdated(start_bound, end_bound); |
| 147 } | 147 } |
| 148 | 148 |
| 149 void Animate() { | 149 void Animate() { |
| 150 base::TimeTicks now = base::TimeTicks::Now(); | 150 base::TimeTicks now = base::TimeTicks::Now(); |
| 151 while (needs_animate_) { | 151 while (needs_animate_) { |
| 152 needs_animate_ = controller_->Animate(now); | 152 needs_animate_ = controller_->Animate(now); |
| 153 now += base::TimeDelta::FromMilliseconds(16); | 153 now += base::TimeDelta::FromMilliseconds(16); |
| 154 } | 154 } |
| 155 } | 155 } |
| 156 | 156 |
| (...skipping 769 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 926 controller().OnSelectionEmpty(false); | 926 controller().OnSelectionEmpty(false); |
| 927 controller().HideAndDisallowShowingAutomatically(); | 927 controller().HideAndDisallowShowingAutomatically(); |
| 928 gfx::RectF insertion_rect(5, 5, 0, 10); | 928 gfx::RectF insertion_rect(5, 5, 0, 10); |
| 929 ChangeInsertion(insertion_rect, visible); | 929 ChangeInsertion(insertion_rect, visible); |
| 930 controller().AllowShowingFromCurrentSelection(); | 930 controller().AllowShowingFromCurrentSelection(); |
| 931 EXPECT_THAT(GetAndResetEvents(), ElementsAre(INSERTION_SHOWN)); | 931 EXPECT_THAT(GetAndResetEvents(), ElementsAre(INSERTION_SHOWN)); |
| 932 EXPECT_EQ(insertion_rect.bottom_left(), GetLastEventAnchor()); | 932 EXPECT_EQ(insertion_rect.bottom_left(), GetLastEventAnchor()); |
| 933 } | 933 } |
| 934 | 934 |
| 935 } // namespace ui | 935 } // namespace ui |
| OLD | NEW |