Index: ui/touch_selection/touch_selection_controller_aura.h |
diff --git a/ui/touch_selection/touch_selection_controller_aura.h b/ui/touch_selection/touch_selection_controller_aura.h |
new file mode 100644 |
index 0000000000000000000000000000000000000000..7e91b4c566043e080cbf5a9998b8bcd221aa53e0 |
--- /dev/null |
+++ b/ui/touch_selection/touch_selection_controller_aura.h |
@@ -0,0 +1,120 @@ |
+// Copyright 2015 The Chromium Authors. All rights reserved. |
+// Use of this source code is governed by a BSD-style license that can be |
+// found in the LICENSE file. |
+ |
+#ifndef UI_TOUCH_SELECTION_TOUCH_SELECTION_CONTROLLER_AURA_H_ |
+#define UI_TOUCH_SELECTION_TOUCH_SELECTION_CONTROLLER_AURA_H_ |
+ |
+#include "base/timer/timer.h" |
+#include "ui/events/event_handler.h" |
+#include "ui/touch_selection/touch_selection_controller.h" |
+#include "ui/touch_selection/touch_selection_menu_runner.h" |
+ |
+namespace aura { |
+class Window; |
+} |
+ |
+namespace ui { |
+class MotionEventAura; |
+class TouchEvent; |
+ |
+// The interface used by TouchSelectionControllerAura to communicate with its |
+// client. |
+class UI_TOUCH_SELECTION_EXPORT TouchSelectionControllerAuraClient { |
+ public: |
+ virtual ~TouchSelectionControllerAuraClient() {}; |
+ |
+ virtual void MoveCaret(const gfx::PointF& position) = 0; |
+ virtual void MoveRangeSelectionExtent(const gfx::PointF& extent) = 0; |
+ virtual void SelectBetweenCoordinates(const gfx::PointF& base, |
+ const gfx::PointF& extent) = 0; |
+ virtual aura::Window* GetParentWindow() const = 0; |
+ virtual gfx::Rect GetClientBounds() const = 0; |
+ virtual bool IsCommandIdEnabled(int command_id) const = 0; |
+ virtual void ExecuteCommand(int command_id, int event_flags) = 0; |
+ virtual void OpenContextMenu(const gfx::PointF& point) = 0; |
+}; |
+ |
+// Aura specific implementaion of a touch selection controller. Wraps an |
+// instance of TouchSelectionController and augments it with additional behavior |
+// needed in Aura. |
+class UI_TOUCH_SELECTION_EXPORT TouchSelectionControllerAura |
sadrul
2015/03/05 12:37:03
Calling this TouchSelectionControllerAura when it
mohsen
2015/03/06 23:10:08
Yeah. Any suggestions? AuraTouchSelectionControlle
|
+ : public TouchSelectionControllerClient, |
+ public TouchSelectionMenuClient, |
+ public EventHandler { |
+ public: |
+ explicit TouchSelectionControllerAura( |
+ TouchSelectionControllerAuraClient* client); |
+ ~TouchSelectionControllerAura() override; |
+ |
+ void OnSelectionEditable(bool editable); |
+ void OnSelectionEmpty(bool empty); |
+ void OnSelectionBoundsUpdated(const SelectionBound& start, |
+ const SelectionBound& end); |
+ void HandleGestureEvent(GestureEvent* event); |
+ void HandleTouchEvent(TouchEvent* event); |
sadrul
2015/03/05 12:37:03
Why have these two separate, instead of overriding
mohsen
2015/03/06 23:10:08
EventHandler equivalents were for pre-target handl
|
+ void HideAndDisallowShowingAutomatically(); |
+ void OnWindowMoved(); |
+ void OnOverscrollStarted(); |
+ void OnOverscrollCompleted(); |
+ void OnFlingCompleted(); |
+ |
+ protected: |
+ // TouchSelectionControllerClient: |
+ bool SupportsAnimation() const override; |
+ void SetNeedsAnimate() override; |
+ void MoveCaret(const gfx::PointF& position) override; |
+ void MoveRangeSelectionExtent(const gfx::PointF& extent) override; |
+ void SelectBetweenCoordinates(const gfx::PointF& base, |
+ const gfx::PointF& extent) override; |
+ void OnSelectionEvent(SelectionEventType event, |
+ const gfx::PointF& position) override; |
+ scoped_ptr<TouchHandleDrawable> CreateDrawable() override; |
+ |
+ private: |
+ friend class TestTouchSelectionControllerAura; |
+ |
+ gfx::Rect GetMenuAnchorRect() const; |
+ void ShowQuickMenu(); |
+ void UpdateQuickMenu(); |
+ bool IsQuickMenuAllowed() const; |
+ |
+ // TouchSelectionMenuClient: |
+ bool IsCommandIdEnabled(int command_id) const override; |
+ void ExecuteCommand(int command_id, int event_flags) override; |
+ void OpenContextMenu() override; |
+ |
+ // EventHandler: |
+ void OnKeyEvent(KeyEvent* event) override; |
+ void OnMouseEvent(MouseEvent* event) override; |
+ void OnScrollEvent(ScrollEvent* event) override; |
+ |
+ void set_immediate_quick_menu_for_testing(bool immediate) { |
+ immediate_quick_menu_for_testing_ = immediate; |
+ } |
+ |
+ bool is_insertion_active_for_testing() const { |
+ return controller_->is_insertion_active(); |
+ } |
+ |
+ bool is_selection_active_for_testing() const { |
+ return controller_->is_selection_active(); |
+ } |
sadrul
2015/03/05 12:37:03
Can you move these to TestApi pattern?
mohsen
2015/03/06 23:10:08
Done.
|
+ |
+ TouchSelectionControllerAuraClient* client_; |
+ scoped_ptr<MotionEventAura> motion_event_; |
+ scoped_ptr<TouchSelectionController> controller_; |
+ base::OneShotTimer<TouchSelectionControllerAura> quick_menu_timer_; |
+ bool scroll_in_progress_; |
+ bool overscroll_in_progress_; |
+ bool handle_drag_in_progress_; |
+ bool selection_editable_; |
+ |
+ bool immediate_quick_menu_for_testing_; |
sadrul
2015/03/05 12:37:03
Doesn't look like this is ever initialized?
Also,
mohsen
2015/03/06 23:10:08
Initialization fixed.
Also, moved this to test api
|
+ |
+ DISALLOW_COPY_AND_ASSIGN(TouchSelectionControllerAura); |
+}; |
+ |
+} // namespace ui |
+ |
+#endif // UI_TOUCH_SELECTION_TOUCH_SELECTION_CONTROLLER_AURA_H_ |