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

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: 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 SelectBetweenCoordinates(const gfx::PointF& start,
31 const gfx::PointF& end) = 0;
32 virtual aura::Window* GetParentWindow() = 0;
33 virtual bool IsCommandIdEnabled(int command_id) = 0;
34 virtual void ExecuteCommand(int command_id, int event_flags) = 0;
35 virtual void OpenContextMenu(const gfx::PointF& point) = 0;
36 virtual gfx::Rect ConvertRectToScreen(const gfx::RectF& rect) const = 0;
37 };
38
39 class TouchSelectionControllerAura : public TouchSelectionControllerClient,
40 public views::TouchEditingMenuController,
41 public ui::EventHandler {
42 public:
43 explicit TouchSelectionControllerAura(
44 TouchSelectionControllerAuraClient* client);
45 virtual ~TouchSelectionControllerAura();
46
47 //void SetTemporarilyHidden(bool hidden);
48 void OnSelectionEditable(bool editable);
49 void OnSelectionEmpty(bool empty);
50 void OnSelectionBoundsChanged(const cc::ViewportSelectionBound& start,
51 const cc::ViewportSelectionBound& end);
52 void HandleGestureEvent(ui::GestureEvent* event);
53 void HideAndDisallowShowingAutomatically();
54 void HandleTouchEvent(ui::TouchEvent* event);
55 void OnWindowMoved();
56 void OnOverscrollStarted();
57 void OnOverscrollCompleted();
58 void OnFlingCompleted();
59
60 gfx::RectF GetCaretBounds() const;
61
62 const cc::ViewportSelectionBound& start() const { return start_; }
63 const cc::ViewportSelectionBound& end() const { return end_; }
64
65 private:
66 gfx::RectF GetStartRect() const;
67 gfx::RectF GetEndRect() const;
68 gfx::RectF GetBoundingRect() const;
69 gfx::RectF GetAnchorRect() const;
70 void QuickMenuTimerFired();
71 void UpdateQuickMenu();
72 bool IsQuickMenuAllowed() const;
73
74 // Overriden from TouchSelectionControllerClient.
75 virtual bool SupportsAnimation() const override;
76 virtual void SetNeedsAnimate() override;
77 virtual void MoveCaret(const gfx::PointF& position) override;
78 virtual void SelectBetweenCoordinates(const gfx::PointF& start,
79 const gfx::PointF& end) override;
80 virtual void OnSelectionEvent(SelectionEventType event,
81 const gfx::PointF& position) override;
82 virtual scoped_ptr<TouchHandleDrawable> CreateDrawable() override;
83
84 // Overriden from views::TouchEditingMenuController.
85 virtual bool IsCommandIdEnabled(int command_id) const override;
86 virtual void ExecuteCommand(int command_id, int event_flags) override;
87 virtual void OpenContextMenu() override;
88 virtual void OnMenuClosed(views::TouchEditingMenuView* menu) override;
89
90 // Overriden from ui::EventHandler.
91 virtual void OnKeyEvent(ui::KeyEvent* event) override;
92 virtual void OnMouseEvent(ui::MouseEvent* event) override;
93 virtual void OnScrollEvent(ui::ScrollEvent* event) override;
94
95 TouchSelectionControllerAuraClient* client_;
96 scoped_ptr<ui::MotionEventAura> motion_event_;
97 scoped_ptr<TouchSelectionController> controller_;
98 base::OneShotTimer<TouchSelectionControllerAura> quick_menu_timer_;
99 views::TouchEditingMenuView* quick_menu_;
100 bool scroll_in_progress_;
101 bool overscroll_in_progress_;
102 bool handle_drag_in_progress_;
103 cc::ViewportSelectionBound start_;
104 cc::ViewportSelectionBound end_;
105
106 DISALLOW_COPY_AND_ASSIGN(TouchSelectionControllerAura);
107 };
108
109 }
110
111 #endif // CONTENT_BROWSER_RENDERER_HOST_TOUCH_SELECTION_CONTROLLER_AURA_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698