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/chromeos/touch_exploration_controller.h" | 5 #include "ui/chromeos/touch_exploration_controller.h" |
6 | 6 |
7 #include <utility> | 7 #include <utility> |
8 | 8 |
9 #include "base/logging.h" | 9 #include "base/logging.h" |
10 #include "base/strings/string_number_conversions.h" | 10 #include "base/strings/string_number_conversions.h" |
11 #include "base/time/default_tick_clock.h" | |
12 #include "ui/accessibility/ax_enums.h" | 11 #include "ui/accessibility/ax_enums.h" |
13 #include "ui/aura/client/cursor_client.h" | 12 #include "ui/aura/client/cursor_client.h" |
14 #include "ui/aura/window.h" | 13 #include "ui/aura/window.h" |
15 #include "ui/aura/window_event_dispatcher.h" | 14 #include "ui/aura/window_event_dispatcher.h" |
16 #include "ui/aura/window_tree_host.h" | 15 #include "ui/aura/window_tree_host.h" |
17 #include "ui/events/event.h" | 16 #include "ui/events/event.h" |
18 #include "ui/events/event_processor.h" | 17 #include "ui/events/event_processor.h" |
19 #include "ui/events/event_utils.h" | 18 #include "ui/events/event_utils.h" |
20 #include "ui/gfx/geometry/rect.h" | 19 #include "ui/gfx/geometry/rect.h" |
21 | 20 |
(...skipping 11 matching lines...) Expand all Loading... |
33 | 32 |
34 TouchExplorationController::TouchExplorationController( | 33 TouchExplorationController::TouchExplorationController( |
35 aura::Window* root_window, | 34 aura::Window* root_window, |
36 TouchExplorationControllerDelegate* delegate) | 35 TouchExplorationControllerDelegate* delegate) |
37 : root_window_(root_window), | 36 : root_window_(root_window), |
38 delegate_(delegate), | 37 delegate_(delegate), |
39 state_(NO_FINGERS_DOWN), | 38 state_(NO_FINGERS_DOWN), |
40 anchor_point_state_(ANCHOR_POINT_NONE), | 39 anchor_point_state_(ANCHOR_POINT_NONE), |
41 gesture_provider_(new GestureProviderAura(this, this)), | 40 gesture_provider_(new GestureProviderAura(this, this)), |
42 prev_state_(NO_FINGERS_DOWN), | 41 prev_state_(NO_FINGERS_DOWN), |
43 VLOG_on_(true), | 42 VLOG_on_(true) { |
44 tick_clock_(NULL) { | |
45 DCHECK(root_window); | 43 DCHECK(root_window); |
46 root_window->GetHost()->GetEventSource()->AddEventRewriter(this); | 44 root_window->GetHost()->GetEventSource()->AddEventRewriter(this); |
47 } | 45 } |
48 | 46 |
49 TouchExplorationController::~TouchExplorationController() { | 47 TouchExplorationController::~TouchExplorationController() { |
50 root_window_->GetHost()->GetEventSource()->RemoveEventRewriter(this); | 48 root_window_->GetHost()->GetEventSource()->RemoveEventRewriter(this); |
51 } | 49 } |
52 | 50 |
53 void TouchExplorationController::SetTouchAccessibilityAnchorPoint( | 51 void TouchExplorationController::SetTouchAccessibilityAnchorPoint( |
54 const gfx::Point& anchor_point) { | 52 const gfx::Point& anchor_point) { |
(...skipping 631 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
686 | 684 |
687 DispatchEvent(&control_down); | 685 DispatchEvent(&control_down); |
688 DispatchEvent(&control_up); | 686 DispatchEvent(&control_up); |
689 SET_STATE(NO_FINGERS_DOWN); | 687 SET_STATE(NO_FINGERS_DOWN); |
690 return ui::EVENT_REWRITE_DISCARD; | 688 return ui::EVENT_REWRITE_DISCARD; |
691 } | 689 } |
692 return ui::EVENT_REWRITE_DISCARD; | 690 return ui::EVENT_REWRITE_DISCARD; |
693 } | 691 } |
694 | 692 |
695 base::TimeTicks TouchExplorationController::Now() { | 693 base::TimeTicks TouchExplorationController::Now() { |
696 if (tick_clock_) { | |
697 // This is the same as what EventTimeForNow() does, but here we do it | |
698 // with a clock that can be replaced with a simulated clock for tests. | |
699 return tick_clock_->NowTicks(); | |
700 } | |
701 return ui::EventTimeForNow(); | 694 return ui::EventTimeForNow(); |
702 } | 695 } |
703 | 696 |
704 void TouchExplorationController::StartTapTimer() { | 697 void TouchExplorationController::StartTapTimer() { |
705 tap_timer_.Start(FROM_HERE, | 698 tap_timer_.Start(FROM_HERE, |
706 gesture_detector_config_.double_tap_timeout, | 699 gesture_detector_config_.double_tap_timeout, |
707 this, | 700 this, |
708 &TouchExplorationController::OnTapTimerFired); | 701 &TouchExplorationController::OnTapTimerFired); |
709 } | 702 } |
710 | 703 |
(...skipping 436 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1147 return "TWO_FINGER_TAP"; | 1140 return "TWO_FINGER_TAP"; |
1148 } | 1141 } |
1149 return "Not a state"; | 1142 return "Not a state"; |
1150 } | 1143 } |
1151 | 1144 |
1152 float TouchExplorationController::GetSplitTapTouchSlop() { | 1145 float TouchExplorationController::GetSplitTapTouchSlop() { |
1153 return gesture_detector_config_.touch_slop * 3; | 1146 return gesture_detector_config_.touch_slop * 3; |
1154 } | 1147 } |
1155 | 1148 |
1156 } // namespace ui | 1149 } // namespace ui |
OLD | NEW |