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

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: Fixed overrides in TouchHandleDrawableAura Created 5 years, 11 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 2014 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 //...
22 class UI_TOUCH_SELECTION_EXPORT TouchSelectionControllerAuraClient {
23 public:
24 virtual ~TouchSelectionControllerAuraClient() {};
25
26 virtual void MoveCaret(const gfx::PointF& position) = 0;
27 virtual void MoveRangeSelectionExtent(const gfx::PointF& extent) = 0;
28 virtual void SelectBetweenCoordinates(const gfx::PointF& base,
29 const gfx::PointF& extent) = 0;
30 virtual aura::Window* GetParentWindow() const = 0;
31 virtual bool IsCommandIdEnabled(int command_id) const = 0;
32 virtual void ExecuteCommand(int command_id, int event_flags) = 0;
33 virtual void OpenContextMenu(const gfx::PointF& point) = 0;
34 virtual gfx::Rect ConvertRectToScreen(const gfx::Rect& rect) const = 0;
35 };
36
37 class UI_TOUCH_SELECTION_EXPORT TouchSelectionControllerAura
38 : public TouchSelectionControllerClient,
39 public TouchSelectionMenuClient,
40 public EventHandler {
41 public:
42 explicit TouchSelectionControllerAura(
43 TouchSelectionControllerAuraClient* client);
44 ~TouchSelectionControllerAura() override;
45
46 void OnSelectionEditable(bool editable);
47 void OnSelectionEmpty(bool empty);
48 void OnSelectionBoundsUpdated(const SelectionBound& start,
49 const SelectionBound& end);
50 void HandleGestureEvent(GestureEvent* event);
51 void HandleTouchEvent(TouchEvent* event);
52 void HideAndDisallowShowingAutomatically();
53 void OnWindowMoved();
54 void OnOverscrollStarted();
55 void OnOverscrollCompleted();
56 void OnFlingCompleted();
57
58 const SelectionBound& start() const { return controller_->start(); }
59 const SelectionBound& end() const { return controller_->end(); }
60
61 private:
62 friend class TouchSelectionControllerAuraTest;
63
64 gfx::Rect GetAnchorRect() const;
65 void ShowQuickMenu();
66 void UpdateQuickMenu();
67 bool IsQuickMenuAllowed() const;
68
69 // Overriden from TouchSelectionControllerClient.
70 bool SupportsAnimation() const override;
71 void SetNeedsAnimate() override;
72 void MoveCaret(const gfx::PointF& position) override;
73 void MoveRangeSelectionExtent(const gfx::PointF& extent) override;
74 void SelectBetweenCoordinates(const gfx::PointF& base,
75 const gfx::PointF& extent) override;
76 void OnSelectionEvent(SelectionEventType event,
77 const gfx::PointF& position) override;
78 scoped_ptr<TouchHandleDrawable> CreateDrawable() override;
79
80 // Overriden from TouchSelectionMenuClient.
81 bool IsCommandIdEnabled(int command_id) const override;
82 void ExecuteCommand(int command_id, int event_flags) override;
83 void OpenContextMenu() override;
84
85 // Overriden from EventHandler.
86 void OnKeyEvent(KeyEvent* event) override;
87 void OnMouseEvent(MouseEvent* event) override;
88 void OnScrollEvent(ScrollEvent* event) override;
89
90 TouchSelectionController* controller_for_testing() const {
91 return controller_.get();
92 }
93
94 void set_immediate_quick_menu_for_testing(bool immediate) {
95 immediate_quick_menu_for_testing_ = immediate;
96 }
97
98 TouchSelectionControllerAuraClient* client_;
99 scoped_ptr<MotionEventAura> motion_event_;
100 scoped_ptr<TouchSelectionController> controller_;
101 base::OneShotTimer<TouchSelectionControllerAura> quick_menu_timer_;
102 bool scroll_in_progress_;
103 bool overscroll_in_progress_;
104 bool handle_drag_in_progress_;
105
106 bool immediate_quick_menu_for_testing_;
107
108 DISALLOW_COPY_AND_ASSIGN(TouchSelectionControllerAura);
109 };
110
111 } // namespace ui
112
113 #endif // UI_TOUCH_SELECTION_TOUCH_SELECTION_CONTROLLER_AURA_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698