Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(555)

Side by Side Diff: ui/touch_selection/touch_selection_controller_aura.h

Issue 698253004: Reland: Implement Aura side of unified touch text selection for contents (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebased after addition of touch_handle_orientation file Created 5 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #ifndef UI_TOUCH_SELECTION_TOUCH_SELECTION_CONTROLLER_AURA_H_
6 #define UI_TOUCH_SELECTION_TOUCH_SELECTION_CONTROLLER_AURA_H_
7
8 #include "base/timer/timer.h"
9 #include "ui/events/event_handler.h"
10 #include "ui/touch_selection/touch_selection_controller.h"
11 #include "ui/touch_selection/touch_selection_menu_runner.h"
12
13 namespace aura {
14 class Window;
15 }
16
17 namespace ui {
18 class MotionEventAura;
19 class TouchEvent;
20
21 // The interface used by TouchSelectionControllerAura to communicate with its
22 // client.
23 class UI_TOUCH_SELECTION_EXPORT TouchSelectionControllerAuraClient {
24 public:
25 virtual ~TouchSelectionControllerAuraClient() {};
26
27 virtual void MoveCaret(const gfx::PointF& position) = 0;
28 virtual void MoveRangeSelectionExtent(const gfx::PointF& extent) = 0;
29 virtual void SelectBetweenCoordinates(const gfx::PointF& base,
30 const gfx::PointF& extent) = 0;
31 virtual aura::Window* GetParentWindow() const = 0;
32 virtual gfx::Rect GetClientBounds() const = 0;
33 virtual bool IsCommandIdEnabled(int command_id) const = 0;
34 virtual void ExecuteCommand(int command_id, int event_flags) = 0;
35 virtual void OpenContextMenu(const gfx::PointF& point) = 0;
36 };
37
38 // Aura specific implementaion of a touch selection controller. Wraps an
39 // instance of TouchSelectionController and augments it with additional behavior
40 // needed in Aura.
41 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
42 : public TouchSelectionControllerClient,
43 public TouchSelectionMenuClient,
44 public EventHandler {
45 public:
46 explicit TouchSelectionControllerAura(
47 TouchSelectionControllerAuraClient* client);
48 ~TouchSelectionControllerAura() override;
49
50 void OnSelectionEditable(bool editable);
51 void OnSelectionEmpty(bool empty);
52 void OnSelectionBoundsUpdated(const SelectionBound& start,
53 const SelectionBound& end);
54 void HandleGestureEvent(GestureEvent* event);
55 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
56 void HideAndDisallowShowingAutomatically();
57 void OnWindowMoved();
58 void OnOverscrollStarted();
59 void OnOverscrollCompleted();
60 void OnFlingCompleted();
61
62 protected:
63 // TouchSelectionControllerClient:
64 bool SupportsAnimation() const override;
65 void SetNeedsAnimate() override;
66 void MoveCaret(const gfx::PointF& position) override;
67 void MoveRangeSelectionExtent(const gfx::PointF& extent) override;
68 void SelectBetweenCoordinates(const gfx::PointF& base,
69 const gfx::PointF& extent) override;
70 void OnSelectionEvent(SelectionEventType event,
71 const gfx::PointF& position) override;
72 scoped_ptr<TouchHandleDrawable> CreateDrawable() override;
73
74 private:
75 friend class TestTouchSelectionControllerAura;
76
77 gfx::Rect GetMenuAnchorRect() const;
78 void ShowQuickMenu();
79 void UpdateQuickMenu();
80 bool IsQuickMenuAllowed() const;
81
82 // TouchSelectionMenuClient:
83 bool IsCommandIdEnabled(int command_id) const override;
84 void ExecuteCommand(int command_id, int event_flags) override;
85 void OpenContextMenu() override;
86
87 // EventHandler:
88 void OnKeyEvent(KeyEvent* event) override;
89 void OnMouseEvent(MouseEvent* event) override;
90 void OnScrollEvent(ScrollEvent* event) override;
91
92 void set_immediate_quick_menu_for_testing(bool immediate) {
93 immediate_quick_menu_for_testing_ = immediate;
94 }
95
96 bool is_insertion_active_for_testing() const {
97 return controller_->is_insertion_active();
98 }
99
100 bool is_selection_active_for_testing() const {
101 return controller_->is_selection_active();
102 }
sadrul 2015/03/05 12:37:03 Can you move these to TestApi pattern?
mohsen 2015/03/06 23:10:08 Done.
103
104 TouchSelectionControllerAuraClient* client_;
105 scoped_ptr<MotionEventAura> motion_event_;
106 scoped_ptr<TouchSelectionController> controller_;
107 base::OneShotTimer<TouchSelectionControllerAura> quick_menu_timer_;
108 bool scroll_in_progress_;
109 bool overscroll_in_progress_;
110 bool handle_drag_in_progress_;
111 bool selection_editable_;
112
113 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
114
115 DISALLOW_COPY_AND_ASSIGN(TouchSelectionControllerAura);
116 };
117
118 } // namespace ui
119
120 #endif // UI_TOUCH_SELECTION_TOUCH_SELECTION_CONTROLLER_AURA_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698