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/stylus_text_selector.h" | 5 #include "content/browser/renderer_host/input/stylus_text_selector.h" |
6 | 6 |
7 #include "ui/events/event_constants.h" | 7 #include "ui/events/event_constants.h" |
8 #include "ui/events/gesture_detection/gesture_detector.h" | 8 #include "ui/events/gesture_detection/gesture_detector.h" |
9 #include "ui/events/gesture_detection/gesture_provider_config_helper.h" | 9 #include "ui/events/gesture_detection/gesture_provider_config_helper.h" |
10 #include "ui/events/gesture_detection/motion_event.h" | 10 #include "ui/events/gesture_detection/motion_event.h" |
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
103 return true; | 103 return true; |
104 } | 104 } |
105 | 105 |
106 bool StylusTextSelector::OnSingleTapUp(const MotionEvent& e, int tap_count) { | 106 bool StylusTextSelector::OnSingleTapUp(const MotionEvent& e, int tap_count) { |
107 DCHECK(text_selection_triggered_); | 107 DCHECK(text_selection_triggered_); |
108 DCHECK(!dragging_); | 108 DCHECK(!dragging_); |
109 client_->OnStylusSelectTap(e.GetEventTime(), e.GetX(), e.GetY()); | 109 client_->OnStylusSelectTap(e.GetEventTime(), e.GetX(), e.GetY()); |
110 return true; | 110 return true; |
111 } | 111 } |
112 | 112 |
113 bool StylusTextSelector::OnScroll(const MotionEvent& e1, | 113 bool StylusTextSelector::OnScroll(const MotionEvent& e1, const MotionEvent& e2, |
114 const MotionEvent& e2, | 114 const MotionEvent& secondary_pointer_down_event, float distance_x, |
tdresser
2016/06/28 15:24:18
Remove _event.
sahel
2016/06/29 16:26:18
Done.
| |
115 float distance_x, | 115 float distance_y) { |
116 float distance_y) { | |
117 DCHECK(text_selection_triggered_); | 116 DCHECK(text_selection_triggered_); |
118 | 117 |
119 // Return if Stylus button is not pressed. | 118 // Return if Stylus button is not pressed. |
120 if (!secondary_button_pressed_) | 119 if (!secondary_button_pressed_) |
121 return true; | 120 return true; |
122 | 121 |
123 if (!dragging_) { | 122 if (!dragging_) { |
124 dragging_ = true; | 123 dragging_ = true; |
125 dragged_ = true; | 124 dragged_ = true; |
126 client_->OnStylusSelectBegin(anchor_x_, anchor_y_, e2.GetX(), e2.GetY()); | 125 client_->OnStylusSelectBegin(anchor_x_, anchor_y_, e2.GetX(), e2.GetY()); |
127 } else { | 126 } else { |
128 client_->OnStylusSelectUpdate(e2.GetX(), e2.GetY()); | 127 client_->OnStylusSelectUpdate(e2.GetX(), e2.GetY()); |
129 } | 128 } |
130 | 129 |
131 return true; | 130 return true; |
132 } | 131 } |
133 | 132 |
134 // static | 133 // static |
135 bool StylusTextSelector::ShouldStartTextSelection(const MotionEvent& event) { | 134 bool StylusTextSelector::ShouldStartTextSelection(const MotionEvent& event) { |
136 DCHECK_GT(event.GetPointerCount(), 0u); | 135 DCHECK_GT(event.GetPointerCount(), 0u); |
137 // Currently we are supporting stylus-only cases. | 136 // Currently we are supporting stylus-only cases. |
138 const bool is_stylus = event.GetToolType(0) == MotionEvent::TOOL_TYPE_STYLUS; | 137 const bool is_stylus = event.GetToolType(0) == MotionEvent::TOOL_TYPE_STYLUS; |
139 const bool is_only_secondary_button_pressed = | 138 const bool is_only_secondary_button_pressed = |
140 event.GetButtonState() == MotionEvent::BUTTON_SECONDARY; | 139 event.GetButtonState() == MotionEvent::BUTTON_SECONDARY; |
141 return is_stylus && is_only_secondary_button_pressed; | 140 return is_stylus && is_only_secondary_button_pressed; |
142 } | 141 } |
143 | 142 |
144 } // namespace content | 143 } // namespace content |
OLD | NEW |