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

Side by Side Diff: content/browser/renderer_host/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 SetVisible removal and Mikhail's directional handles patch Created 6 years, 1 month 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 CONTENT_BROWSER_RENDERER_HOST_TOUCH_SELECTION_CONTROLLER_AURA_H_
6 #define CONTENT_BROWSER_RENDERER_HOST_TOUCH_SELECTION_CONTROLLER_AURA_H_
7
8 #include <set>
9
10 #include "base/timer/timer.h"
11 #include "cc/output/viewport_selection_bound.h"
12 #include "content/browser/renderer_host/input/touch_selection_controller.h"
13 #include "ui/views/touchui/touch_editing_menu.h"
14
15 namespace aura {
16 class Window;
17 }
18
19 namespace ui {
20 class MotionEventAura;
21 class TouchEvent;
22 }
23
24 namespace content {
25
26 class TouchSelectionControllerAuraClient {
27 public:
28 virtual float GetDeviceScaleFactor() = 0;
29 virtual void MoveCaret(const gfx::PointF& position) = 0;
30 virtual void MoveRangeSelectionExtent(const gfx::PointF& extent) = 0;
31 virtual void SelectBetweenCoordinates(const gfx::PointF& base,
32 const gfx::PointF& extent) = 0;
33 virtual aura::Window* GetParentWindow() = 0;
34 virtual bool IsCommandIdEnabled(int command_id) = 0;
35 virtual void ExecuteCommand(int command_id, int event_flags) = 0;
36 virtual void OpenContextMenu(const gfx::PointF& point) = 0;
37 virtual gfx::Rect ConvertRectToScreen(const gfx::RectF& rect) const = 0;
38 };
39
40 class TouchSelectionControllerAura : public TouchSelectionControllerClient,
41 public views::TouchEditingMenuController,
42 public ui::EventHandler {
43 public:
44 explicit TouchSelectionControllerAura(
45 TouchSelectionControllerAuraClient* client);
46 virtual ~TouchSelectionControllerAura();
47
48 //void SetTemporarilyHidden(bool hidden);
49 void OnSelectionEditable(bool editable);
50 void OnSelectionEmpty(bool empty);
51 void OnSelectionBoundsChanged(const cc::ViewportSelectionBound& start,
52 const cc::ViewportSelectionBound& end);
53 void HandleGestureEvent(ui::GestureEvent* event);
54 void HideAndDisallowShowingAutomatically();
55 void HandleTouchEvent(ui::TouchEvent* event);
56 void OnWindowMoved();
57 void OnOverscrollStarted();
58 void OnOverscrollCompleted();
59 void OnFlingCompleted();
60
61 gfx::RectF GetCaretBounds() const;
62
63 const cc::ViewportSelectionBound& start() const { return start_; }
64 const cc::ViewportSelectionBound& end() const { return end_; }
65
66 private:
67 gfx::RectF GetStartRect() const;
68 gfx::RectF GetEndRect() const;
69 gfx::RectF GetBoundingRect() const;
70 gfx::RectF GetAnchorRect() const;
71 void QuickMenuTimerFired();
72 void UpdateQuickMenu();
73 bool IsQuickMenuAllowed() const;
74
75 // Overriden from TouchSelectionControllerClient.
76 virtual bool SupportsAnimation() const override;
77 virtual void SetNeedsAnimate() override;
78 virtual void MoveCaret(const gfx::PointF& position) override;
79 virtual void MoveRangeSelectionExtent(const gfx::PointF& extent) override;
80 virtual void SelectBetweenCoordinates(const gfx::PointF& base,
81 const gfx::PointF& extent) override;
82 virtual void OnSelectionEvent(SelectionEventType event,
83 const gfx::PointF& position) override;
84 virtual scoped_ptr<TouchHandleDrawable> CreateDrawable() override;
85
86 // Overriden from views::TouchEditingMenuController.
87 virtual bool IsCommandIdEnabled(int command_id) const override;
88 virtual void ExecuteCommand(int command_id, int event_flags) override;
89 virtual void OpenContextMenu() override;
90 virtual void OnMenuClosed(views::TouchEditingMenuView* menu) override;
91
92 // Overriden from ui::EventHandler.
93 virtual void OnKeyEvent(ui::KeyEvent* event) override;
94 virtual void OnMouseEvent(ui::MouseEvent* event) override;
95 virtual void OnScrollEvent(ui::ScrollEvent* event) override;
96
97 TouchSelectionControllerAuraClient* client_;
98 scoped_ptr<ui::MotionEventAura> motion_event_;
99 scoped_ptr<TouchSelectionController> controller_;
100 base::OneShotTimer<TouchSelectionControllerAura> quick_menu_timer_;
101 views::TouchEditingMenuView* quick_menu_;
102 bool scroll_in_progress_;
103 bool overscroll_in_progress_;
104 bool handle_drag_in_progress_;
105 cc::ViewportSelectionBound start_;
106 cc::ViewportSelectionBound end_;
107
108 DISALLOW_COPY_AND_ASSIGN(TouchSelectionControllerAura);
109 };
110
111 }
112
113 #endif // CONTENT_BROWSER_RENDERER_HOST_TOUCH_SELECTION_CONTROLLER_AURA_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698