Commit 864dabc9 authored by James Cook's avatar James Cook Committed by Commit Bot

cros: Move some touch a11y code out of ui/chromeos into ash

Now that we have //ash/components we're trying to clean up //ui to get
it back to its original state of being low-level UI libraries.

This code was written during the Athena days (when we were trying to
avoid using ash). It is only used inside //ash, so move it there.

Bug: none
Test: ash_unittests, ui_chromeos_unittests
Change-Id: I2484d2d54a8ad99b855719c968708c3008ba52a0
Reviewed-on: https://chromium-review.googlesource.com/917439Reviewed-by: default avatarDominic Mazzoni <dmazzoni@chromium.org>
Commit-Queue: James Cook <jamescook@chromium.org>
Cr-Commit-Position: refs/heads/master@{#536754}
parent b36af4e1
...@@ -66,6 +66,10 @@ component("ash") { ...@@ -66,6 +66,10 @@ component("ash") {
"accessibility/focus_ring_controller.h", "accessibility/focus_ring_controller.h",
"accessibility/focus_ring_layer.cc", "accessibility/focus_ring_layer.cc",
"accessibility/focus_ring_layer.h", "accessibility/focus_ring_layer.h",
"accessibility/touch_accessibility_enabler.cc",
"accessibility/touch_accessibility_enabler.h",
"accessibility/touch_exploration_controller.cc",
"accessibility/touch_exploration_controller.h",
"animation/animation_change_type.h", "animation/animation_change_type.h",
"app_list/app_list_delegate_impl.cc", "app_list/app_list_delegate_impl.cc",
"app_list/app_list_delegate_impl.h", "app_list/app_list_delegate_impl.h",
...@@ -1350,6 +1354,8 @@ test("ash_unittests") { ...@@ -1350,6 +1354,8 @@ test("ash_unittests") {
"accelerators/spoken_feedback_toggler_unittest.cc", "accelerators/spoken_feedback_toggler_unittest.cc",
"accessibility/accessibility_controller_unittest.cc", "accessibility/accessibility_controller_unittest.cc",
"accessibility/accessibility_focus_ring_controller_unittest.cc", "accessibility/accessibility_focus_ring_controller_unittest.cc",
"accessibility/touch_accessibility_enabler_unittest.cc",
"accessibility/touch_exploration_controller_unittest.cc",
"app_list/app_list_presenter_delegate_unittest.cc", "app_list/app_list_presenter_delegate_unittest.cc",
"ash_touch_exploration_manager_chromeos_unittest.cc", "ash_touch_exploration_manager_chromeos_unittest.cc",
"autoclick/autoclick_unittest.cc", "autoclick/autoclick_unittest.cc",
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
#include "ui/chromeos/touch_accessibility_enabler.h" #include "ash/accessibility/touch_accessibility_enabler.h"
#include <math.h> #include <math.h>
...@@ -18,7 +18,7 @@ ...@@ -18,7 +18,7 @@
#include "ui/events/event_processor.h" #include "ui/events/event_processor.h"
#include "ui/events/event_utils.h" #include "ui/events/event_utils.h"
namespace ui { namespace ash {
namespace { namespace {
...@@ -147,7 +147,7 @@ void TouchAccessibilityEnabler::StartTimer() { ...@@ -147,7 +147,7 @@ void TouchAccessibilityEnabler::StartTimer() {
return; return;
timer_.Start(FROM_HERE, base::TimeDelta::FromMilliseconds(kTimerDelayInMS), timer_.Start(FROM_HERE, base::TimeDelta::FromMilliseconds(kTimerDelayInMS),
this, &ui::TouchAccessibilityEnabler::OnTimer); this, &TouchAccessibilityEnabler::OnTimer);
} }
void TouchAccessibilityEnabler::CancelTimer() { void TouchAccessibilityEnabler::CancelTimer() {
...@@ -184,4 +184,4 @@ void TouchAccessibilityEnabler::ResetToNoFingersDown() { ...@@ -184,4 +184,4 @@ void TouchAccessibilityEnabler::ResetToNoFingersDown() {
CancelTimer(); CancelTimer();
} }
} // namespace ui } // namespace ash
...@@ -2,15 +2,15 @@ ...@@ -2,15 +2,15 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
#ifndef UI_CHROMEOS_TOUCH_ACCESSIBILITY_ENABLER_H_ #ifndef ASH_ACCESSIBILITY_TOUCH_ACCESSIBILITY_ENABLER_H_
#define UI_CHROMEOS_TOUCH_ACCESSIBILITY_ENABLER_H_ #define ASH_ACCESSIBILITY_TOUCH_ACCESSIBILITY_ENABLER_H_
#include "ash/ash_export.h"
#include "base/macros.h" #include "base/macros.h"
#include "base/memory/weak_ptr.h" #include "base/memory/weak_ptr.h"
#include "base/time/tick_clock.h" #include "base/time/tick_clock.h"
#include "base/timer/timer.h" #include "base/timer/timer.h"
#include "base/values.h" #include "base/values.h"
#include "ui/chromeos/ui_chromeos_export.h"
#include "ui/events/event.h" #include "ui/events/event.h"
#include "ui/events/event_handler.h" #include "ui/events/event_handler.h"
#include "ui/events/gesture_detection/gesture_detector.h" #include "ui/events/gesture_detection/gesture_detector.h"
...@@ -19,11 +19,7 @@ namespace aura { ...@@ -19,11 +19,7 @@ namespace aura {
class Window; class Window;
} }
namespace ui { namespace ash {
class Event;
class EventHandler;
class TouchEvent;
// A delegate to handle commands in response to detected accessibility gesture // A delegate to handle commands in response to detected accessibility gesture
// events. // events.
...@@ -50,10 +46,10 @@ class TouchAccessibilityEnablerDelegate { ...@@ -50,10 +46,10 @@ class TouchAccessibilityEnablerDelegate {
// TouchAccessibilityEnabler triggers turning spoken feedback on or off // TouchAccessibilityEnabler triggers turning spoken feedback on or off
// by holding down two fingers on the touch screen for several seconds. // by holding down two fingers on the touch screen for several seconds.
class UI_CHROMEOS_EXPORT TouchAccessibilityEnabler : public ui::EventHandler { class ASH_EXPORT TouchAccessibilityEnabler : public ui::EventHandler {
public: public:
TouchAccessibilityEnabler(aura::Window* root_window, TouchAccessibilityEnabler(aura::Window* root_window,
ui::TouchAccessibilityEnablerDelegate* delegate); TouchAccessibilityEnablerDelegate* delegate);
~TouchAccessibilityEnabler() override; ~TouchAccessibilityEnabler() override;
bool IsInNoFingersDownForTesting() { return state_ == NO_FINGERS_DOWN; } bool IsInNoFingersDownForTesting() { return state_ == NO_FINGERS_DOWN; }
...@@ -109,7 +105,7 @@ class UI_CHROMEOS_EXPORT TouchAccessibilityEnabler : public ui::EventHandler { ...@@ -109,7 +105,7 @@ class UI_CHROMEOS_EXPORT TouchAccessibilityEnabler : public ui::EventHandler {
aura::Window* root_window_; aura::Window* root_window_;
// Called when we detect a long-press of two fingers. Not owned. // Called when we detect a long-press of two fingers. Not owned.
ui::TouchAccessibilityEnablerDelegate* delegate_; TouchAccessibilityEnablerDelegate* delegate_;
// The current state. // The current state.
State state_; State state_;
...@@ -140,6 +136,6 @@ class UI_CHROMEOS_EXPORT TouchAccessibilityEnabler : public ui::EventHandler { ...@@ -140,6 +136,6 @@ class UI_CHROMEOS_EXPORT TouchAccessibilityEnabler : public ui::EventHandler {
DISALLOW_COPY_AND_ASSIGN(TouchAccessibilityEnabler); DISALLOW_COPY_AND_ASSIGN(TouchAccessibilityEnabler);
}; };
} // namespace ui } // namespace ash
#endif // UI_CHROMEOS_TOUCH_ACCESSIBILITY_ENABLER_H_ #endif // ASH_ACCESSIBILITY_TOUCH_ACCESSIBILITY_ENABLER_H_
...@@ -2,14 +2,14 @@ ...@@ -2,14 +2,14 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
#include "ui/chromeos/touch_accessibility_enabler.h" #include "ash/accessibility/touch_accessibility_enabler.h"
#include "ash/accessibility/touch_exploration_controller.h"
#include "base/macros.h" #include "base/macros.h"
#include "base/test/simple_test_tick_clock.h" #include "base/test/simple_test_tick_clock.h"
#include "base/time/time.h" #include "base/time/time.h"
#include "ui/aura/test/aura_test_base.h" #include "ui/aura/test/aura_test_base.h"
#include "ui/aura/window.h" #include "ui/aura/window.h"
#include "ui/chromeos/touch_exploration_controller.h"
#include "ui/events/event.h" #include "ui/events/event.h"
#include "ui/events/event_utils.h" #include "ui/events/event_utils.h"
#include "ui/events/gestures/gesture_provider_aura.h" #include "ui/events/gestures/gesture_provider_aura.h"
...@@ -17,12 +17,12 @@ ...@@ -17,12 +17,12 @@
#include "ui/events/test/events_test_utils.h" #include "ui/events/test/events_test_utils.h"
#include "ui/gfx/geometry/point.h" #include "ui/gfx/geometry/point.h"
namespace ui { namespace ash {
namespace { namespace {
class MockTouchAccessibilityEnablerDelegate class MockTouchAccessibilityEnablerDelegate
: public ui::TouchAccessibilityEnablerDelegate { : public TouchAccessibilityEnablerDelegate {
public: public:
MockTouchAccessibilityEnablerDelegate() {} MockTouchAccessibilityEnablerDelegate() {}
~MockTouchAccessibilityEnablerDelegate() override {} ~MockTouchAccessibilityEnablerDelegate() override {}
...@@ -60,7 +60,7 @@ class TouchAccessibilityEnablerTest : public aura::test::AuraTestBase { ...@@ -60,7 +60,7 @@ class TouchAccessibilityEnablerTest : public aura::test::AuraTestBase {
void SetUp() override { void SetUp() override {
aura::test::AuraTestBase::SetUp(); aura::test::AuraTestBase::SetUp();
generator_.reset(new test::EventGenerator(root_window())); generator_.reset(new ui::test::EventGenerator(root_window()));
simulated_clock_ = new base::SimpleTestTickClock(); simulated_clock_ = new base::SimpleTestTickClock();
// Tests fail if time is ever 0. // Tests fail if time is ever 0.
...@@ -85,7 +85,7 @@ class TouchAccessibilityEnablerTest : public aura::test::AuraTestBase { ...@@ -85,7 +85,7 @@ class TouchAccessibilityEnablerTest : public aura::test::AuraTestBase {
return simulated_clock_->NowTicks(); return simulated_clock_->NowTicks();
} }
std::unique_ptr<test::EventGenerator> generator_; std::unique_ptr<ui::test::EventGenerator> generator_;
// Owned by |ui|. // Owned by |ui|.
base::SimpleTestTickClock* simulated_clock_ = nullptr; base::SimpleTestTickClock* simulated_clock_ = nullptr;
MockTouchAccessibilityEnablerDelegate delegate_; MockTouchAccessibilityEnablerDelegate delegate_;
...@@ -223,4 +223,4 @@ TEST_F(TouchAccessibilityEnablerTest, MovingFingerPastSlopCancelsDetection) { ...@@ -223,4 +223,4 @@ TEST_F(TouchAccessibilityEnablerTest, MovingFingerPastSlopCancelsDetection) {
EXPECT_TRUE(enabler_->IsInWaitForNoFingersForTesting()); EXPECT_TRUE(enabler_->IsInWaitForNoFingersForTesting());
} }
} // namespace ui } // namespace ash
...@@ -2,10 +2,11 @@ ...@@ -2,10 +2,11 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
#include "ui/chromeos/touch_exploration_controller.h" #include "ash/accessibility/touch_exploration_controller.h"
#include <utility> #include <utility>
#include "ash/accessibility/touch_accessibility_enabler.h"
#include "base/logging.h" #include "base/logging.h"
#include "base/strings/string_number_conversions.h" #include "base/strings/string_number_conversions.h"
#include "ui/accessibility/ax_enums.mojom.h" #include "ui/accessibility/ax_enums.mojom.h"
...@@ -13,7 +14,6 @@ ...@@ -13,7 +14,6 @@
#include "ui/aura/window.h" #include "ui/aura/window.h"
#include "ui/aura/window_event_dispatcher.h" #include "ui/aura/window_event_dispatcher.h"
#include "ui/aura/window_tree_host.h" #include "ui/aura/window_tree_host.h"
#include "ui/chromeos/touch_accessibility_enabler.h"
#include "ui/events/event.h" #include "ui/events/event.h"
#include "ui/events/event_processor.h" #include "ui/events/event_processor.h"
#include "ui/events/event_utils.h" #include "ui/events/event_utils.h"
...@@ -24,7 +24,7 @@ ...@@ -24,7 +24,7 @@
if (VLOG_IS_ON(1)) \ if (VLOG_IS_ON(1)) \
VlogEvent(event, __func__) VlogEvent(event, __func__)
namespace ui { namespace ash {
namespace { namespace {
...@@ -47,7 +47,7 @@ TouchExplorationController::TouchExplorationController( ...@@ -47,7 +47,7 @@ TouchExplorationController::TouchExplorationController(
delegate_(delegate), delegate_(delegate),
state_(NO_FINGERS_DOWN), state_(NO_FINGERS_DOWN),
anchor_point_state_(ANCHOR_POINT_NONE), anchor_point_state_(ANCHOR_POINT_NONE),
gesture_provider_(new GestureProviderAura(this, this)), gesture_provider_(new ui::GestureProviderAura(this, this)),
prev_state_(NO_FINGERS_DOWN), prev_state_(NO_FINGERS_DOWN),
VLOG_on_(true), VLOG_on_(true),
touch_accessibility_enabler_(touch_accessibility_enabler) { touch_accessibility_enabler_(touch_accessibility_enabler) {
...@@ -307,15 +307,13 @@ ui::EventRewriteStatus TouchExplorationController::InNoFingersDown( ...@@ -307,15 +307,13 @@ ui::EventRewriteStatus TouchExplorationController::InNoFingersDown(
(BOTTOM_LEFT_CORNER == location) || (BOTTOM_RIGHT_CORNER == location); (BOTTOM_LEFT_CORNER == location) || (BOTTOM_RIGHT_CORNER == location);
if (in_a_bottom_corner) { if (in_a_bottom_corner) {
passthrough_timer_.Start( passthrough_timer_.Start(
FROM_HERE, FROM_HERE, gesture_detector_config_.longpress_timeout, this,
gesture_detector_config_.longpress_timeout,
this,
&TouchExplorationController::OnPassthroughTimerFired); &TouchExplorationController::OnPassthroughTimerFired);
} }
initial_press_.reset(new TouchEvent(event)); initial_press_ = std::make_unique<ui::TouchEvent>(event);
most_recent_press_timestamp_ = initial_press_->time_stamp(); most_recent_press_timestamp_ = initial_press_->time_stamp();
initial_presses_[event.pointer_details().id] = event.location(); initial_presses_[event.pointer_details().id] = event.location();
last_unused_finger_event_.reset(new TouchEvent(event)); last_unused_finger_event_ = std::make_unique<ui::TouchEvent>(event);
StartTapTimer(); StartTapTimer();
SET_STATE(SINGLE_TAP_PRESSED); SET_STATE(SINGLE_TAP_PRESSED);
return ui::EVENT_REWRITE_DISCARD; return ui::EVENT_REWRITE_DISCARD;
...@@ -348,7 +346,7 @@ ui::EventRewriteStatus TouchExplorationController::InSingleTapPressed( ...@@ -348,7 +346,7 @@ ui::EventRewriteStatus TouchExplorationController::InSingleTapPressed(
if (type == ui::ET_TOUCH_PRESSED) { if (type == ui::ET_TOUCH_PRESSED) {
initial_presses_[event.pointer_details().id] = event.location(); initial_presses_[event.pointer_details().id] = event.location();
SET_STATE(TWO_FINGER_TAP); SET_STATE(TWO_FINGER_TAP);
return EVENT_REWRITE_DISCARD; return ui::EVENT_REWRITE_DISCARD;
} else if (type == ui::ET_TOUCH_RELEASED || type == ui::ET_TOUCH_CANCELLED) { } else if (type == ui::ET_TOUCH_RELEASED || type == ui::ET_TOUCH_CANCELLED) {
if (passthrough_timer_.IsRunning()) if (passthrough_timer_.IsRunning())
passthrough_timer_.Stop(); passthrough_timer_.Stop();
...@@ -359,14 +357,14 @@ ui::EventRewriteStatus TouchExplorationController::InSingleTapPressed( ...@@ -359,14 +357,14 @@ ui::EventRewriteStatus TouchExplorationController::InSingleTapPressed(
} else if (current_touch_ids_.size() == 0) { } else if (current_touch_ids_.size() == 0) {
SET_STATE(NO_FINGERS_DOWN); SET_STATE(NO_FINGERS_DOWN);
} }
return EVENT_REWRITE_DISCARD; return ui::EVENT_REWRITE_DISCARD;
} else if (type == ui::ET_TOUCH_MOVED) { } else if (type == ui::ET_TOUCH_MOVED) {
float distance = (event.location() - initial_press_->location()).Length(); float distance = (event.location() - initial_press_->location()).Length();
// If the user does not move far enough from the original position, then the // If the user does not move far enough from the original position, then the
// resulting movement should not be considered to be a deliberate gesture or // resulting movement should not be considered to be a deliberate gesture or
// touch exploration. // touch exploration.
if (distance <= gesture_detector_config_.touch_slop) if (distance <= gesture_detector_config_.touch_slop)
return EVENT_REWRITE_DISCARD; return ui::EVENT_REWRITE_DISCARD;
float delta_time = float delta_time =
(event.time_stamp() - most_recent_press_timestamp_).InSecondsF(); (event.time_stamp() - most_recent_press_timestamp_).InSecondsF();
...@@ -461,10 +459,10 @@ ui::EventRewriteStatus TouchExplorationController::InDoubleTapPending( ...@@ -461,10 +459,10 @@ ui::EventRewriteStatus TouchExplorationController::InDoubleTapPending(
tap_timer_.Stop(); tap_timer_.Stop();
OnTapTimerFired(); OnTapTimerFired();
} }
return EVENT_REWRITE_DISCARD; return ui::EVENT_REWRITE_DISCARD;
} else if (type == ui::ET_TOUCH_RELEASED || type == ui::ET_TOUCH_CANCELLED) { } else if (type == ui::ET_TOUCH_RELEASED || type == ui::ET_TOUCH_CANCELLED) {
if (current_touch_ids_.size() != 0) if (current_touch_ids_.size() != 0)
return EVENT_REWRITE_DISCARD; return ui::EVENT_REWRITE_DISCARD;
SendSimulatedClickOrTap(); SendSimulatedClickOrTap();
...@@ -483,7 +481,7 @@ ui::EventRewriteStatus TouchExplorationController::InTouchReleasePending( ...@@ -483,7 +481,7 @@ ui::EventRewriteStatus TouchExplorationController::InTouchReleasePending(
return ui::EVENT_REWRITE_DISCARD; return ui::EVENT_REWRITE_DISCARD;
} else if (type == ui::ET_TOUCH_RELEASED || type == ui::ET_TOUCH_CANCELLED) { } else if (type == ui::ET_TOUCH_RELEASED || type == ui::ET_TOUCH_CANCELLED) {
if (current_touch_ids_.size() != 0) if (current_touch_ids_.size() != 0)
return EVENT_REWRITE_DISCARD; return ui::EVENT_REWRITE_DISCARD;
SendSimulatedClickOrTap(); SendSimulatedClickOrTap();
SET_STATE(NO_FINGERS_DOWN); SET_STATE(NO_FINGERS_DOWN);
...@@ -499,12 +497,12 @@ ui::EventRewriteStatus TouchExplorationController::InTouchExploration( ...@@ -499,12 +497,12 @@ ui::EventRewriteStatus TouchExplorationController::InTouchExploration(
const ui::EventType type = event.type(); const ui::EventType type = event.type();
if (type == ui::ET_TOUCH_PRESSED) { if (type == ui::ET_TOUCH_PRESSED) {
// Enter split-tap mode. // Enter split-tap mode.
initial_press_.reset(new TouchEvent(event)); initial_press_ = std::make_unique<ui::TouchEvent>(event);
tap_timer_.Stop(); tap_timer_.Stop();
SET_STATE(TOUCH_EXPLORE_SECOND_PRESS); SET_STATE(TOUCH_EXPLORE_SECOND_PRESS);
return ui::EVENT_REWRITE_DISCARD; return ui::EVENT_REWRITE_DISCARD;
} else if (type == ui::ET_TOUCH_RELEASED || type == ui::ET_TOUCH_CANCELLED) { } else if (type == ui::ET_TOUCH_RELEASED || type == ui::ET_TOUCH_CANCELLED) {
initial_press_.reset(new TouchEvent(event)); initial_press_ = std::make_unique<ui::TouchEvent>(event);
StartTapTimer(); StartTapTimer();
most_recent_press_timestamp_ = event.time_stamp(); most_recent_press_timestamp_ = event.time_stamp();
MaybeSendSimulatedTapInLiftActivationBounds(event); MaybeSendSimulatedTapInLiftActivationBounds(event);
...@@ -516,7 +514,7 @@ ui::EventRewriteStatus TouchExplorationController::InTouchExploration( ...@@ -516,7 +514,7 @@ ui::EventRewriteStatus TouchExplorationController::InTouchExploration(
// Rewrite as a mouse-move event. // Rewrite as a mouse-move event.
*rewritten_event = CreateMouseMoveEvent(event.location_f(), event.flags()); *rewritten_event = CreateMouseMoveEvent(event.location_f(), event.flags());
last_touch_exploration_.reset(new TouchEvent(event)); last_touch_exploration_ = std::make_unique<ui::TouchEvent>(event);
if (anchor_point_state_ != ANCHOR_POINT_EXPLICITLY_SET) if (anchor_point_state_ != ANCHOR_POINT_EXPLICITLY_SET)
anchor_point_ = last_touch_exploration_->location_f(); anchor_point_ = last_touch_exploration_->location_f();
...@@ -544,8 +542,8 @@ ui::EventRewriteStatus TouchExplorationController::InCornerPassthrough( ...@@ -544,8 +542,8 @@ ui::EventRewriteStatus TouchExplorationController::InCornerPassthrough(
// If the first finger has left the corner, then exit passthrough. // If the first finger has left the corner, then exit passthrough.
if (event.pointer_details().id == initial_press_->pointer_details().id) { if (event.pointer_details().id == initial_press_->pointer_details().id) {
int edges = FindEdgesWithinInset(event.location(), kSlopDistanceFromEdge); int edges = FindEdgesWithinInset(event.location(), kSlopDistanceFromEdge);
bool in_a_bottom_corner = (edges == BOTTOM_LEFT_CORNER) || bool in_a_bottom_corner =
(edges == BOTTOM_RIGHT_CORNER); (edges == BOTTOM_LEFT_CORNER) || (edges == BOTTOM_RIGHT_CORNER);
if (type == ui::ET_TOUCH_MOVED && in_a_bottom_corner) if (type == ui::ET_TOUCH_MOVED && in_a_bottom_corner)
return ui::EVENT_REWRITE_DISCARD; return ui::EVENT_REWRITE_DISCARD;
...@@ -641,13 +639,13 @@ ui::EventRewriteStatus TouchExplorationController::InTouchExploreSecondPress( ...@@ -641,13 +639,13 @@ ui::EventRewriteStatus TouchExplorationController::InTouchExploreSecondPress(
if (event.pointer_details().id == if (event.pointer_details().id ==
last_touch_exploration_->pointer_details().id) { last_touch_exploration_->pointer_details().id) {
SET_STATE(TOUCH_RELEASE_PENDING); SET_STATE(TOUCH_RELEASE_PENDING);
return EVENT_REWRITE_DISCARD; return ui::EVENT_REWRITE_DISCARD;
} }
// Continue to release the touch only if the touch explore finger is the // Continue to release the touch only if the touch explore finger is the
// only finger remaining. // only finger remaining.
if (current_touch_ids_.size() != 1) if (current_touch_ids_.size() != 1)
return EVENT_REWRITE_DISCARD; return ui::EVENT_REWRITE_DISCARD;
SendSimulatedClickOrTap(); SendSimulatedClickOrTap();
...@@ -664,7 +662,7 @@ ui::EventRewriteStatus TouchExplorationController::InWaitForNoFingers( ...@@ -664,7 +662,7 @@ ui::EventRewriteStatus TouchExplorationController::InWaitForNoFingers(
std::unique_ptr<ui::Event>* rewritten_event) { std::unique_ptr<ui::Event>* rewritten_event) {
if (current_touch_ids_.size() == 0) if (current_touch_ids_.size() == 0)
SET_STATE(NO_FINGERS_DOWN); SET_STATE(NO_FINGERS_DOWN);
return EVENT_REWRITE_DISCARD; return ui::EVENT_REWRITE_DISCARD;
} }
void TouchExplorationController::PlaySoundForTimer() { void TouchExplorationController::PlaySoundForTimer() {
...@@ -727,7 +725,7 @@ ui::EventRewriteStatus TouchExplorationController::InSlideGesture( ...@@ -727,7 +725,7 @@ ui::EventRewriteStatus TouchExplorationController::InSlideGesture(
if (sound_timer_.IsRunning()) if (sound_timer_.IsRunning())
sound_timer_.Stop(); sound_timer_.Stop();
SET_STATE(WAIT_FOR_NO_FINGERS); SET_STATE(WAIT_FOR_NO_FINGERS);
return EVENT_REWRITE_DISCARD; return ui::EVENT_REWRITE_DISCARD;
} }
// There should not be more than one finger down. // There should not be more than one finger down.
...@@ -740,7 +738,7 @@ ui::EventRewriteStatus TouchExplorationController::InSlideGesture( ...@@ -740,7 +738,7 @@ ui::EventRewriteStatus TouchExplorationController::InSlideGesture(
if (sound_timer_.IsRunning()) { if (sound_timer_.IsRunning()) {
sound_timer_.Stop(); sound_timer_.Stop();
} }
return EVENT_REWRITE_DISCARD; return ui::EVENT_REWRITE_DISCARD;
} }
// This can occur if the user leaves the screen edge and then returns to it to // This can occur if the user leaves the screen edge and then returns to it to
...@@ -748,7 +746,7 @@ ui::EventRewriteStatus TouchExplorationController::InSlideGesture( ...@@ -748,7 +746,7 @@ ui::EventRewriteStatus TouchExplorationController::InSlideGesture(
if (!sound_timer_.IsRunning()) { if (!sound_timer_.IsRunning()) {
sound_timer_.Start(FROM_HERE, sound_timer_.Start(FROM_HERE,
base::TimeDelta::FromMilliseconds(kSoundDelayInMS), this, base::TimeDelta::FromMilliseconds(kSoundDelayInMS), this,
&ui::TouchExplorationController::PlaySoundForTimer); &TouchExplorationController::PlaySoundForTimer);
delegate_->PlayVolumeAdjustEarcon(); delegate_->PlayVolumeAdjustEarcon();
} }
...@@ -796,9 +794,7 @@ base::TimeTicks TouchExplorationController::Now() { ...@@ -796,9 +794,7 @@ base::TimeTicks TouchExplorationController::Now() {
} }
void TouchExplorationController::StartTapTimer() { void TouchExplorationController::StartTapTimer() {
tap_timer_.Start(FROM_HERE, tap_timer_.Start(FROM_HERE, gesture_detector_config_.double_tap_timeout, this,
gesture_detector_config_.double_tap_timeout,
this,
&TouchExplorationController::OnTapTimerFired); &TouchExplorationController::OnTapTimerFired);
} }
...@@ -809,7 +805,8 @@ void TouchExplorationController::OnTapTimerFired() { ...@@ -809,7 +805,8 @@ void TouchExplorationController::OnTapTimerFired() {
break; break;
case TOUCH_EXPLORE_RELEASED: case TOUCH_EXPLORE_RELEASED:
SET_STATE(NO_FINGERS_DOWN); SET_STATE(NO_FINGERS_DOWN);
last_touch_exploration_.reset(new TouchEvent(*initial_press_)); last_touch_exploration_ =
std::make_unique<ui::TouchEvent>(*initial_press_);
anchor_point_ = last_touch_exploration_->location_f(); anchor_point_ = last_touch_exploration_->location_f();
anchor_point_state_ = ANCHOR_POINT_FROM_TOUCH_EXPLORATION; anchor_point_state_ = ANCHOR_POINT_FROM_TOUCH_EXPLORATION;
return; return;
...@@ -850,7 +847,7 @@ void TouchExplorationController::OnTapTimerFired() { ...@@ -850,7 +847,7 @@ void TouchExplorationController::OnTapTimerFired() {
std::unique_ptr<ui::Event> mouse_move = CreateMouseMoveEvent( std::unique_ptr<ui::Event> mouse_move = CreateMouseMoveEvent(
initial_press_->location_f(), initial_press_->flags()); initial_press_->location_f(), initial_press_->flags());
DispatchEvent(mouse_move.get()); DispatchEvent(mouse_move.get());
last_touch_exploration_.reset(new TouchEvent(*initial_press_)); last_touch_exploration_ = std::make_unique<ui::TouchEvent>(*initial_press_);
anchor_point_ = last_touch_exploration_->location_f(); anchor_point_ = last_touch_exploration_->location_f();
anchor_point_state_ = ANCHOR_POINT_FROM_TOUCH_EXPLORATION; anchor_point_state_ = ANCHOR_POINT_FROM_TOUCH_EXPLORATION;
} }
...@@ -894,7 +891,7 @@ void TouchExplorationController::OnGestureEvent(ui::GestureConsumer* consumer, ...@@ -894,7 +891,7 @@ void TouchExplorationController::OnGestureEvent(ui::GestureConsumer* consumer,
ui::GestureEvent* gesture) {} ui::GestureEvent* gesture) {}
void TouchExplorationController::ProcessGestureEvents() { void TouchExplorationController::ProcessGestureEvents() {
std::vector<std::unique_ptr<GestureEvent>> gestures = std::vector<std::unique_ptr<ui::GestureEvent>> gestures =
gesture_provider_->GetAndResetPendingGestures(); gesture_provider_->GetAndResetPendingGestures();
for (const auto& gesture : gestures) { for (const auto& gesture : gestures) {
if (gesture->type() == ui::ET_GESTURE_SWIPE && if (gesture->type() == ui::ET_GESTURE_SWIPE &&
...@@ -915,11 +912,11 @@ void TouchExplorationController::ProcessGestureEvents() { ...@@ -915,11 +912,11 @@ void TouchExplorationController::ProcessGestureEvents() {
void TouchExplorationController::SideSlideControl(ui::GestureEvent* gesture) { void TouchExplorationController::SideSlideControl(ui::GestureEvent* gesture) {
ui::EventType type = gesture->type(); ui::EventType type = gesture->type();
if (type == ET_GESTURE_SCROLL_BEGIN) { if (type == ui::ET_GESTURE_SCROLL_BEGIN) {
delegate_->PlayVolumeAdjustEarcon(); delegate_->PlayVolumeAdjustEarcon();
} }
if (type == ET_GESTURE_SCROLL_END) { if (type == ui::ET_GESTURE_SCROLL_END) {
if (sound_timer_.IsRunning()) if (sound_timer_.IsRunning())
sound_timer_.Stop(); sound_timer_.Stop();
delegate_->PlayVolumeAdjustEarcon(); delegate_->PlayVolumeAdjustEarcon();
...@@ -962,7 +959,7 @@ void TouchExplorationController::OnSwipeEvent(ui::GestureEvent* swipe_gesture) { ...@@ -962,7 +959,7 @@ void TouchExplorationController::OnSwipeEvent(ui::GestureEvent* swipe_gesture) {
// occurred. TODO(evy) : Research which swipe results users most want and // occurred. TODO(evy) : Research which swipe results users most want and
// remap these swipes to the best events. Hopefully in the near future // remap these swipes to the best events. Hopefully in the near future
// there will also be a menu for users to pick custom mappings. // there will also be a menu for users to pick custom mappings.
GestureEventDetails event_details = swipe_gesture->details(); ui::GestureEventDetails event_details = swipe_gesture->details();
int num_fingers = event_details.touch_points(); int num_fingers = event_details.touch_points();
if (VLOG_on_) if (VLOG_on_)
VLOG(1) << "\nSwipe with " << num_fingers << " fingers."; VLOG(1) << "\nSwipe with " << num_fingers << " fingers.";
...@@ -1089,9 +1086,7 @@ base::Closure TouchExplorationController::BindKeyEventWithFlags( ...@@ -1089,9 +1086,7 @@ base::Closure TouchExplorationController::BindKeyEventWithFlags(
const ui::KeyboardCode key, const ui::KeyboardCode key,
int flags) { int flags) {
return base::Bind(&TouchExplorationController::DispatchKeyWithFlags, return base::Bind(&TouchExplorationController::DispatchKeyWithFlags,
base::Unretained(this), base::Unretained(this), key, flags);
key,
flags);
} }
std::unique_ptr<ui::MouseEvent> std::unique_ptr<ui::MouseEvent>
...@@ -1150,7 +1145,7 @@ void TouchExplorationController::SetState(State new_state, ...@@ -1150,7 +1145,7 @@ void TouchExplorationController::SetState(State new_state,
gesture_provider_.reset(NULL); gesture_provider_.reset(NULL);
break; break;
case NO_FINGERS_DOWN: case NO_FINGERS_DOWN:
gesture_provider_.reset(new GestureProviderAura(this, this)); gesture_provider_ = std::make_unique<ui::GestureProviderAura>(this, this);
if (sound_timer_.IsRunning()) if (sound_timer_.IsRunning())
sound_timer_.Stop(); sound_timer_.Stop();
tap_timer_.Stop(); tap_timer_.Stop();
...@@ -1186,8 +1181,8 @@ void TouchExplorationController::VlogEvent(const ui::TouchEvent& touch_event, ...@@ -1186,8 +1181,8 @@ void TouchExplorationController::VlogEvent(const ui::TouchEvent& touch_event,
// The above statement prevents events of the same type and id from being // The above statement prevents events of the same type and id from being
// printed in a row. However, if two fingers are down, they would both be // printed in a row. However, if two fingers are down, they would both be
// moving and alternating printing move events unless we check for this. // moving and alternating printing move events unless we check for this.
if (prev_event_ && prev_event_->type() == ET_TOUCH_MOVED && if (prev_event_ && prev_event_->type() == ui::ET_TOUCH_MOVED &&
touch_event.type() == ET_TOUCH_MOVED) { touch_event.type() == ui::ET_TOUCH_MOVED) {
return; return;
} }
...@@ -1198,7 +1193,7 @@ void TouchExplorationController::VlogEvent(const ui::TouchEvent& touch_event, ...@@ -1198,7 +1193,7 @@ void TouchExplorationController::VlogEvent(const ui::TouchEvent& touch_event,
VLOG(1) << "\n Function name: " << function_name << "\n Event Type: " << type VLOG(1) << "\n Function name: " << function_name << "\n Event Type: " << type
<< "\n Location: " << location.ToString() << "\n Location: " << location.ToString()
<< "\n Touch ID: " << touch_id; << "\n Touch ID: " << touch_id;
prev_event_.reset(new TouchEvent(touch_event)); prev_event_ = std::make_unique<ui::TouchEvent>(touch_event);
} }
const char* TouchExplorationController::EnumStateToString(State state) { const char* TouchExplorationController::EnumStateToString(State state) {
...@@ -1239,4 +1234,4 @@ float TouchExplorationController::GetSplitTapTouchSlop() { ...@@ -1239,4 +1234,4 @@ float TouchExplorationController::GetSplitTapTouchSlop() {
return gesture_detector_config_.touch_slop * 3; return gesture_detector_config_.touch_slop * 3;
} }
} // namespace ui } // namespace ash
...@@ -2,15 +2,15 @@ ...@@ -2,15 +2,15 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
#ifndef UI_CHROMEOS_TOUCH_EXPLORATION_CONTROLLER_H_ #ifndef ASH_ACCESSIBILITY_TOUCH_EXPLORATION_CONTROLLER_H_
#define UI_CHROMEOS_TOUCH_EXPLORATION_CONTROLLER_H_ #define ASH_ACCESSIBILITY_TOUCH_EXPLORATION_CONTROLLER_H_
#include "ash/ash_export.h"
#include "base/macros.h" #include "base/macros.h"
#include "base/memory/weak_ptr.h" #include "base/memory/weak_ptr.h"
#include "base/timer/timer.h" #include "base/timer/timer.h"
#include "base/values.h" #include "base/values.h"
#include "ui/accessibility/ax_enums.mojom.h" #include "ui/accessibility/ax_enums.mojom.h"
#include "ui/chromeos/ui_chromeos_export.h"
#include "ui/events/event.h" #include "ui/events/event.h"
#include "ui/events/event_rewriter.h" #include "ui/events/event_rewriter.h"
#include "ui/events/gesture_detection/gesture_detector.h" #include "ui/events/gesture_detection/gesture_detector.h"
...@@ -22,12 +22,15 @@ class Window; ...@@ -22,12 +22,15 @@ class Window;
} }
namespace ui { namespace ui {
class Event; class Event;
class GestureEvent; class GestureEvent;
class GestureProviderAura; class GestureProviderAura;
class TouchAccessibilityEnabler;
class TouchEvent; class TouchEvent;
} // namespace ui
namespace ash {
class TouchAccessibilityEnabler;
// A delegate to handle commands in response to detected accessibility gesture // A delegate to handle commands in response to detected accessibility gesture
// events. // events.
...@@ -179,14 +182,14 @@ class TouchExplorationControllerDelegate { ...@@ -179,14 +182,14 @@ class TouchExplorationControllerDelegate {
// //
// The caller is expected to retain ownership of instances of this class and // The caller is expected to retain ownership of instances of this class and
// destroy them before |root_window| is destroyed. // destroy them before |root_window| is destroyed.
class UI_CHROMEOS_EXPORT TouchExplorationController class ASH_EXPORT TouchExplorationController
: public ui::EventRewriter, : public ui::EventRewriter,
public ui::GestureProviderAuraClient, public ui::GestureProviderAuraClient,
public ui::GestureConsumer { public ui::GestureConsumer {
public: public:
explicit TouchExplorationController( explicit TouchExplorationController(
aura::Window* root_window, aura::Window* root_window,
ui::TouchExplorationControllerDelegate* delegate, TouchExplorationControllerDelegate* delegate,
base::WeakPtr<TouchAccessibilityEnabler> touch_accessibility_enabler); base::WeakPtr<TouchAccessibilityEnabler> touch_accessibility_enabler);
~TouchExplorationController() override; ~TouchExplorationController() override;
...@@ -462,7 +465,7 @@ class UI_CHROMEOS_EXPORT TouchExplorationController ...@@ -462,7 +465,7 @@ class UI_CHROMEOS_EXPORT TouchExplorationController
aura::Window* root_window_; aura::Window* root_window_;
// Handles volume control. Not owned. // Handles volume control. Not owned.
ui::TouchExplorationControllerDelegate* delegate_; TouchExplorationControllerDelegate* delegate_;
// A set of touch ids for fingers currently touching the screen. // A set of touch ids for fingers currently touching the screen.
std::vector<int> current_touch_ids_; std::vector<int> current_touch_ids_;
...@@ -553,6 +556,6 @@ class UI_CHROMEOS_EXPORT TouchExplorationController ...@@ -553,6 +556,6 @@ class UI_CHROMEOS_EXPORT TouchExplorationController
DISALLOW_COPY_AND_ASSIGN(TouchExplorationController); DISALLOW_COPY_AND_ASSIGN(TouchExplorationController);
}; };
} // namespace ui } // namespace ash
#endif // UI_CHROMEOS_TOUCH_EXPLORATION_CONTROLLER_H_ #endif // ASH_ACCESSIBILITY_TOUCH_EXPLORATION_CONTROLLER_H_
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
#include "ui/chromeos/touch_exploration_controller.h" #include "ash/accessibility/touch_exploration_controller.h"
#include <math.h> #include <math.h>
#include <stddef.h> #include <stddef.h>
...@@ -29,7 +29,7 @@ ...@@ -29,7 +29,7 @@
using EventList = std::vector<std::unique_ptr<ui::Event>>; using EventList = std::vector<std::unique_ptr<ui::Event>>;
namespace ui { namespace ash {
namespace { namespace {
...@@ -39,9 +39,7 @@ class EventCapturer : public ui::EventHandler { ...@@ -39,9 +39,7 @@ class EventCapturer : public ui::EventHandler {
EventCapturer() {} EventCapturer() {}
~EventCapturer() override {} ~EventCapturer() override {}
void Reset() { void Reset() { events_.clear(); }
events_.clear();
}
void OnEvent(ui::Event* event) override { void OnEvent(ui::Event* event) override {
if (event->IsMouseEvent() || event->IsTouchEvent() || if (event->IsMouseEvent() || event->IsTouchEvent() ||
...@@ -75,7 +73,7 @@ int Factorial(int n) { ...@@ -75,7 +73,7 @@ int Factorial(int n) {
} }
class MockTouchExplorationControllerDelegate class MockTouchExplorationControllerDelegate
: public ui::TouchExplorationControllerDelegate { : public TouchExplorationControllerDelegate {
public: public:
void SetOutputLevel(int volume) override { void SetOutputLevel(int volume) override {
volume_changes_.push_back(volume); volume_changes_.push_back(volume);
...@@ -217,7 +215,7 @@ class TouchExplorationTest : public aura::test::AuraTestBase { ...@@ -217,7 +215,7 @@ class TouchExplorationTest : public aura::test::AuraTestBase {
aura::test::AuraTestBase::SetUp(); aura::test::AuraTestBase::SetUp();
cursor_client_.reset(new aura::test::TestCursorClient(root_window())); cursor_client_.reset(new aura::test::TestCursorClient(root_window()));
root_window()->AddPreTargetHandler(&event_capturer_); root_window()->AddPreTargetHandler(&event_capturer_);
generator_.reset(new test::EventGenerator(root_window())); generator_.reset(new ui::test::EventGenerator(root_window()));
simulated_clock_ = new base::SimpleTestTickClock(); simulated_clock_ = new base::SimpleTestTickClock();
// Tests fail if time is ever 0. // Tests fail if time is ever 0.
...@@ -249,8 +247,7 @@ class TouchExplorationTest : public aura::test::AuraTestBase { ...@@ -249,8 +247,7 @@ class TouchExplorationTest : public aura::test::AuraTestBase {
const EventList& all_events = GetCapturedEvents(); const EventList& all_events = GetCapturedEvents();
std::vector<ui::LocatedEvent*> located_events; std::vector<ui::LocatedEvent*> located_events;
for (size_t i = 0; i < all_events.size(); ++i) { for (size_t i = 0; i < all_events.size(); ++i) {
if (all_events[i]->IsMouseEvent() || if (all_events[i]->IsMouseEvent() || all_events[i]->IsTouchEvent() ||
all_events[i]->IsTouchEvent() ||
all_events[i]->IsGestureEvent()) { all_events[i]->IsGestureEvent()) {
located_events.push_back( located_events.push_back(
static_cast<ui::LocatedEvent*>(all_events[i].get())); static_cast<ui::LocatedEvent*>(all_events[i].get()));
...@@ -279,9 +276,7 @@ class TouchExplorationTest : public aura::test::AuraTestBase { ...@@ -279,9 +276,7 @@ class TouchExplorationTest : public aura::test::AuraTestBase {
return events; return events;
} }
void ClearCapturedEvents() { void ClearCapturedEvents() { event_capturer_.Reset(); }
event_capturer_.Reset();
}
void AdvanceSimulatedTimePastTapDelay() { void AdvanceSimulatedTimePastTapDelay() {
simulated_clock_->Advance(gesture_detector_config_.double_tap_timeout); simulated_clock_->Advance(gesture_detector_config_.double_tap_timeout);
...@@ -307,10 +302,8 @@ class TouchExplorationTest : public aura::test::AuraTestBase { ...@@ -307,10 +302,8 @@ class TouchExplorationTest : public aura::test::AuraTestBase {
if (!on && touch_exploration_controller_.get()) { if (!on && touch_exploration_controller_.get()) {
touch_exploration_controller_.reset(); touch_exploration_controller_.reset();
} else if (on && !touch_exploration_controller_.get()) { } else if (on && !touch_exploration_controller_.get()) {
touch_exploration_controller_.reset( touch_exploration_controller_.reset(new TouchExplorationControllerTestApi(
new ui::TouchExplorationControllerTestApi( new TouchExplorationController(root_window(), &delegate_, nullptr)));
new TouchExplorationController(root_window(), &delegate_,
nullptr)));
cursor_client()->ShowCursor(); cursor_client()->ShowCursor();
cursor_client()->DisableMouseEvents(); cursor_client()->DisableMouseEvents();
} }
...@@ -374,8 +367,7 @@ class TouchExplorationTest : public aura::test::AuraTestBase { ...@@ -374,8 +367,7 @@ class TouchExplorationTest : public aura::test::AuraTestBase {
bool IsInTouchToMouseMode() { bool IsInTouchToMouseMode() {
aura::client::CursorClient* cursor_client = aura::client::CursorClient* cursor_client =
aura::client::GetCursorClient(root_window()); aura::client::GetCursorClient(root_window());
return cursor_client && return cursor_client && cursor_client->IsMouseEventsEnabled() &&
cursor_client->IsMouseEventsEnabled() &&
!cursor_client->IsCursorVisible(); !cursor_client->IsCursorVisible();
} }
...@@ -427,7 +419,7 @@ class TouchExplorationTest : public aura::test::AuraTestBase { ...@@ -427,7 +419,7 @@ class TouchExplorationTest : public aura::test::AuraTestBase {
touch_exploration_controller_->SetLiftActivationBounds(bounds); touch_exploration_controller_->SetLiftActivationBounds(bounds);
} }
std::unique_ptr<test::EventGenerator> generator_; std::unique_ptr<ui::test::EventGenerator> generator_;
ui::GestureDetector::Config gesture_detector_config_; ui::GestureDetector::Config gesture_detector_config_;
// Owned by |ui|. // Owned by |ui|.
base::SimpleTestTickClock* simulated_clock_; base::SimpleTestTickClock* simulated_clock_;
...@@ -1380,20 +1372,20 @@ TEST_F(TouchExplorationTest, DISABLED_AllFingerPermutations) { ...@@ -1380,20 +1372,20 @@ TEST_F(TouchExplorationTest, DISABLED_AllFingerPermutations) {
// A copy of all events list which can be modified without destrying events. // A copy of all events list which can be modified without destrying events.
std::vector<ui::TouchEvent*> queued_events; std::vector<ui::TouchEvent*> queued_events;
for (int touch_id = 0; touch_id < 3; touch_id++){ for (int touch_id = 0; touch_id < 3; touch_id++) {
int x = 10*touch_id + 1; int x = 10 * touch_id + 1;
int y = 10*touch_id + 2; int y = 10 * touch_id + 2;
all_events.push_back(std::make_unique<TouchEvent>( all_events.push_back(std::make_unique<ui::TouchEvent>(
ui::ET_TOUCH_PRESSED, gfx::Point(x++, y++), Now(), ui::ET_TOUCH_PRESSED, gfx::Point(x++, y++), Now(),
ui::PointerDetails(ui::EventPointerType::POINTER_TYPE_TOUCH, ui::PointerDetails(ui::EventPointerType::POINTER_TYPE_TOUCH,
touch_id))); touch_id)));
queued_events.push_back(all_events.back().get()); queued_events.push_back(all_events.back().get());
all_events.push_back(std::make_unique<TouchEvent>( all_events.push_back(std::make_unique<ui::TouchEvent>(
ui::ET_TOUCH_MOVED, gfx::Point(x++, y++), Now(), ui::ET_TOUCH_MOVED, gfx::Point(x++, y++), Now(),
ui::PointerDetails(ui::EventPointerType::POINTER_TYPE_TOUCH, ui::PointerDetails(ui::EventPointerType::POINTER_TYPE_TOUCH,
touch_id))); touch_id)));
queued_events.push_back(all_events.back().get()); queued_events.push_back(all_events.back().get());
all_events.push_back(std::make_unique<TouchEvent>( all_events.push_back(std::make_unique<ui::TouchEvent>(
ui::ET_TOUCH_RELEASED, gfx::Point(x, y), Now(), ui::ET_TOUCH_RELEASED, gfx::Point(x, y), Now(),
ui::PointerDetails(ui::EventPointerType::POINTER_TYPE_TOUCH, ui::PointerDetails(ui::EventPointerType::POINTER_TYPE_TOUCH,
touch_id))); touch_id)));
...@@ -1461,7 +1453,7 @@ TEST_F(TouchExplorationTest, DISABLED_AllFingerPermutations) { ...@@ -1461,7 +1453,7 @@ TEST_F(TouchExplorationTest, DISABLED_AllFingerPermutations) {
// |next_dispatch| has to be put in this container so that its time // |next_dispatch| has to be put in this container so that its time
// stamp can be changed to this point in the test, when it is being // stamp can be changed to this point in the test, when it is being
// dispatched.. // dispatched..
EventTestApi test_dispatch(next_dispatch); ui::EventTestApi test_dispatch(next_dispatch);
test_dispatch.set_time_stamp(Now()); test_dispatch.set_time_stamp(Now());
generator_->Dispatch(next_dispatch); generator_->Dispatch(next_dispatch);
queued_events.erase(queued_events.begin() + index); queued_events.erase(queued_events.begin() + index);
...@@ -1469,16 +1461,16 @@ TEST_F(TouchExplorationTest, DISABLED_AllFingerPermutations) { ...@@ -1469,16 +1461,16 @@ TEST_F(TouchExplorationTest, DISABLED_AllFingerPermutations) {
// Keep track of what fingers have been pressed, to release // Keep track of what fingers have been pressed, to release
// only those fingers at the end, so the check for being in // only those fingers at the end, so the check for being in
// no fingers down can be accurate. // no fingers down can be accurate.
if (next_dispatch->type() == ET_TOUCH_PRESSED) { if (next_dispatch->type() == ui::ET_TOUCH_PRESSED) {
fingers_pressed[next_dispatch->pointer_details().id] = true; fingers_pressed[next_dispatch->pointer_details().id] = true;
} else if (next_dispatch->type() == ET_TOUCH_RELEASED) { } else if (next_dispatch->type() == ui::ET_TOUCH_RELEASED) {
fingers_pressed[next_dispatch->pointer_details().id] = false; fingers_pressed[next_dispatch->pointer_details().id] = false;
} }
} }
ASSERT_EQ(queued_events.size(), 0u); ASSERT_EQ(queued_events.size(), 0u);
// Release fingers recorded as pressed. // Release fingers recorded as pressed.
for(int j = 0; j < int(fingers_pressed.size()); j++){ for (int j = 0; j < int(fingers_pressed.size()); j++) {
if (fingers_pressed[j] == true) { if (fingers_pressed[j] == true) {
generator_->ReleaseTouchId(j); generator_->ReleaseTouchId(j);
fingers_pressed[j] = false; fingers_pressed[j] = false;
...@@ -1894,8 +1886,7 @@ TEST_F(TouchExplorationTest, EnterEarconPlays) { ...@@ -1894,8 +1886,7 @@ TEST_F(TouchExplorationTest, EnterEarconPlays) {
locations.push_back(bottom_edge); locations.push_back(bottom_edge);
for (std::vector<gfx::Point>::const_iterator point = locations.begin(); for (std::vector<gfx::Point>::const_iterator point = locations.begin();
point != locations.end(); point != locations.end(); ++point) {
++point) {
ui::TouchEvent touch_event( ui::TouchEvent touch_event(
ui::ET_TOUCH_PRESSED, *point, Now(), ui::ET_TOUCH_PRESSED, *point, Now(),
ui::PointerDetails(ui::EventPointerType::POINTER_TYPE_TOUCH, 1)); ui::PointerDetails(ui::EventPointerType::POINTER_TYPE_TOUCH, 1));
...@@ -1938,8 +1929,7 @@ TEST_F(TouchExplorationTest, ExitEarconPlays) { ...@@ -1938,8 +1929,7 @@ TEST_F(TouchExplorationTest, ExitEarconPlays) {
locations.push_back(bottom_edge); locations.push_back(bottom_edge);
for (std::vector<gfx::Point>::const_iterator point = locations.begin(); for (std::vector<gfx::Point>::const_iterator point = locations.begin();
point != locations.end(); point != locations.end(); ++point) {
++point) {
generator_->PressTouch(); generator_->PressTouch();
generator_->MoveTouch(initial_press); generator_->MoveTouch(initial_press);
generator_->MoveTouch(*point); generator_->MoveTouch(*point);
...@@ -2124,4 +2114,4 @@ TEST_F(TouchExplorationTest, AlreadyHeldFingersGetCanceled) { ...@@ -2124,4 +2114,4 @@ TEST_F(TouchExplorationTest, AlreadyHeldFingersGetCanceled) {
ASSERT_EQ(1U, events.size()); ASSERT_EQ(1U, events.size());
} }
} // namespace ui } // namespace ash
...@@ -10,6 +10,7 @@ ...@@ -10,6 +10,7 @@
#include "ash/accessibility/accessibility_controller.h" #include "ash/accessibility/accessibility_controller.h"
#include "ash/accessibility/accessibility_delegate.h" #include "ash/accessibility/accessibility_delegate.h"
#include "ash/accessibility/accessibility_focus_ring_controller.h" #include "ash/accessibility/accessibility_focus_ring_controller.h"
#include "ash/accessibility/touch_exploration_controller.h"
#include "ash/keyboard/keyboard_observer_register.h" #include "ash/keyboard/keyboard_observer_register.h"
#include "ash/public/cpp/app_types.h" #include "ash/public/cpp/app_types.h"
#include "ash/root_window_controller.h" #include "ash/root_window_controller.h"
...@@ -21,7 +22,6 @@ ...@@ -21,7 +22,6 @@
#include "chromeos/audio/cras_audio_handler.h" #include "chromeos/audio/cras_audio_handler.h"
#include "chromeos/chromeos_switches.h" #include "chromeos/chromeos_switches.h"
#include "ui/aura/client/aura_constants.h" #include "ui/aura/client/aura_constants.h"
#include "ui/chromeos/touch_exploration_controller.h"
#include "ui/gfx/geometry/rect.h" #include "ui/gfx/geometry/rect.h"
#include "ui/keyboard/keyboard_controller.h" #include "ui/keyboard/keyboard_controller.h"
#include "ui/wm/public/activation_client.h" #include "ui/wm/public/activation_client.h"
...@@ -197,14 +197,14 @@ void AshTouchExplorationManager::UpdateTouchExplorationState() { ...@@ -197,14 +197,14 @@ void AshTouchExplorationManager::UpdateTouchExplorationState() {
if (!touch_accessibility_enabler_) { if (!touch_accessibility_enabler_) {
// Always enable gesture to toggle spoken feedback. // Always enable gesture to toggle spoken feedback.
touch_accessibility_enabler_.reset(new ui::TouchAccessibilityEnabler( touch_accessibility_enabler_.reset(new TouchAccessibilityEnabler(
root_window_controller_->GetRootWindow(), this)); root_window_controller_->GetRootWindow(), this));
} }
if (spoken_feedback_enabled) { if (spoken_feedback_enabled) {
if (!touch_exploration_controller_.get()) { if (!touch_exploration_controller_.get()) {
touch_exploration_controller_ = touch_exploration_controller_ =
std::make_unique<ui::TouchExplorationController>( std::make_unique<TouchExplorationController>(
root_window_controller_->GetRootWindow(), this, root_window_controller_->GetRootWindow(), this,
touch_accessibility_enabler_->GetWeakPtr()); touch_accessibility_enabler_->GetWeakPtr());
} }
......
...@@ -7,13 +7,13 @@ ...@@ -7,13 +7,13 @@
#include <memory> #include <memory>
#include "ash/accessibility/touch_accessibility_enabler.h"
#include "ash/accessibility/touch_exploration_controller.h"
#include "ash/ash_export.h" #include "ash/ash_export.h"
#include "ash/shell_observer.h" #include "ash/shell_observer.h"
#include "ash/system/accessibility_observer.h" #include "ash/system/accessibility_observer.h"
#include "base/macros.h" #include "base/macros.h"
#include "base/scoped_observer.h" #include "base/scoped_observer.h"
#include "ui/chromeos/touch_accessibility_enabler.h"
#include "ui/chromeos/touch_exploration_controller.h"
#include "ui/display/display_observer.h" #include "ui/display/display_observer.h"
#include "ui/keyboard/keyboard_controller_observer.h" #include "ui/keyboard/keyboard_controller_observer.h"
#include "ui/wm/public/activation_change_observer.h" #include "ui/wm/public/activation_change_observer.h"
...@@ -35,8 +35,8 @@ class RootWindowController; ...@@ -35,8 +35,8 @@ class RootWindowController;
// the system. // the system.
class ASH_EXPORT AshTouchExplorationManager class ASH_EXPORT AshTouchExplorationManager
: public AccessibilityObserver, : public AccessibilityObserver,
public ui::TouchExplorationControllerDelegate, public TouchExplorationControllerDelegate,
public ui::TouchAccessibilityEnablerDelegate, public TouchAccessibilityEnablerDelegate,
public display::DisplayObserver, public display::DisplayObserver,
public ::wm::ActivationChangeObserver, public ::wm::ActivationChangeObserver,
public keyboard::KeyboardControllerObserver, public keyboard::KeyboardControllerObserver,
...@@ -92,8 +92,8 @@ class ASH_EXPORT AshTouchExplorationManager ...@@ -92,8 +92,8 @@ class ASH_EXPORT AshTouchExplorationManager
void UpdateTouchExplorationState(); void UpdateTouchExplorationState();
bool VolumeAdjustSoundEnabled(); bool VolumeAdjustSoundEnabled();
std::unique_ptr<ui::TouchExplorationController> touch_exploration_controller_; std::unique_ptr<TouchExplorationController> touch_exploration_controller_;
std::unique_ptr<ui::TouchAccessibilityEnabler> touch_accessibility_enabler_; std::unique_ptr<TouchAccessibilityEnabler> touch_accessibility_enabler_;
RootWindowController* root_window_controller_; RootWindowController* root_window_controller_;
chromeos::CrasAudioHandler* audio_handler_; chromeos::CrasAudioHandler* audio_handler_;
ScopedObserver<keyboard::KeyboardController, ScopedObserver<keyboard::KeyboardController,
......
...@@ -9,6 +9,7 @@ ...@@ -9,6 +9,7 @@
#include <queue> #include <queue>
#include <vector> #include <vector>
#include "ash/accessibility/touch_exploration_controller.h"
#include "ash/ash_constants.h" #include "ash/ash_constants.h"
#include "ash/ash_touch_exploration_manager_chromeos.h" #include "ash/ash_touch_exploration_manager_chromeos.h"
#include "ash/focus_cycler.h" #include "ash/focus_cycler.h"
...@@ -72,7 +73,6 @@ ...@@ -72,7 +73,6 @@
#include "ui/aura/window_observer.h" #include "ui/aura/window_observer.h"
#include "ui/aura/window_tracker.h" #include "ui/aura/window_tracker.h"
#include "ui/base/models/menu_model.h" #include "ui/base/models/menu_model.h"
#include "ui/chromeos/touch_exploration_controller.h"
#include "ui/compositor/layer.h" #include "ui/compositor/layer.h"
#include "ui/display/types/display_constants.h" #include "ui/display/types/display_constants.h"
#include "ui/events/event_utils.h" #include "ui/events/event_utils.h"
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
#include "ui/chromeos/touch_exploration_controller.h" #include "ash/accessibility/touch_exploration_controller.h"
#include "ash/accessibility/accessibility_delegate.h" #include "ash/accessibility/accessibility_delegate.h"
#include "ash/public/cpp/accessibility_types.h" #include "ash/public/cpp/accessibility_types.h"
......
...@@ -26,10 +26,6 @@ component("chromeos") { ...@@ -26,10 +26,6 @@ component("chromeos") {
"ime/input_method_menu_manager.h", "ime/input_method_menu_manager.h",
"ime/mode_indicator_view.cc", "ime/mode_indicator_view.cc",
"ime/mode_indicator_view.h", "ime/mode_indicator_view.h",
"touch_accessibility_enabler.cc",
"touch_accessibility_enabler.h",
"touch_exploration_controller.cc",
"touch_exploration_controller.h",
"user_activity_power_manager_notifier.cc", "user_activity_power_manager_notifier.cc",
"user_activity_power_manager_notifier.h", "user_activity_power_manager_notifier.h",
] ]
...@@ -70,8 +66,6 @@ test("ui_chromeos_unittests") { ...@@ -70,8 +66,6 @@ test("ui_chromeos_unittests") {
"ime/input_method_menu_item_unittest.cc", "ime/input_method_menu_item_unittest.cc",
"ime/input_method_menu_manager_unittest.cc", "ime/input_method_menu_manager_unittest.cc",
"run_all_unittests.cc", "run_all_unittests.cc",
"touch_accessibility_enabler_unittest.cc",
"touch_exploration_controller_unittest.cc",
] ]
deps = [ deps = [
":chromeos", ":chromeos",
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment