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

Side by Side Diff: content/browser/renderer_host/input/touch_selection_controller.h

Issue 335943002: [Android] Composited selection handle rendering (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@input_native_handles_final
Patch Set: Rebase Created 6 years, 5 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 CONTENT_BROWSER_RENDERER_HOST_INPUT_TOUCH_SELECTION_CONTROLLER_H_
6 #define CONTENT_BROWSER_RENDERER_HOST_INPUT_TOUCH_SELECTION_CONTROLLER_H_
7
8 #include "content/browser/renderer_host/input/selection_event_type.h"
9 #include "content/browser/renderer_host/input/touch_handle.h"
10 #include "content/common/content_export.h"
11 #include "ui/gfx/geometry/point_f.h"
12 #include "ui/gfx/geometry/rect_f.h"
13
14 namespace blink {
15 class WebInputEvent;
16 }
17
18 namespace ui {
19 class MotionEvent;
20 }
21
22 namespace content {
23
24 // Interface through which |TouchSelectionController| issues selection-related
25 // commands, notifications and requests.
26 class CONTENT_EXPORT TouchSelectionControllerClient {
27 public:
28 virtual ~TouchSelectionControllerClient() {}
29
30 virtual bool SupportsAnimation() const = 0;
31 virtual void SetNeedsAnimate() = 0;
32 virtual void MoveCaret(const gfx::PointF& position) = 0;
33 virtual void SelectBetweenCoordinates(const gfx::PointF& start,
34 const gfx::PointF& end) = 0;
35 virtual void OnSelectionEvent(SelectionEventType event,
36 const gfx::PointF& position) = 0;
37 virtual scoped_ptr<TouchHandleDrawable> CreateDrawable() = 0;
38 };
39
40 // Controller for manipulating text selection via touch input.
41 class CONTENT_EXPORT TouchSelectionController : public TouchHandleClient {
42 public:
43 explicit TouchSelectionController(TouchSelectionControllerClient* client);
44 virtual ~TouchSelectionController();
45
46 // To be called when the selection bounds have changed.
47 // Note that such updates will trigger handle updates only if preceded
48 // by an appropriate call to allow automatic showing.
49 void OnSelectionBoundsChanged(const gfx::RectF& start_rect,
50 TouchHandleOrientation start_orientation,
51 bool start_visible,
52 const gfx::RectF& end_rect,
53 TouchHandleOrientation end_orientation,
54 bool end_visible);
55
56 // Allows touch-dragging of the handle.
57 // Returns true iff the event was consumed, in which case the caller should
58 // cease further handling of the event.
59 bool WillHandleTouchEvent(const ui::MotionEvent& event);
60
61 // Allow the insertion or selection handles to be shown from the data
62 // in |OnSelectionBoundsChanged()|.
63 void AllowAutomaticInsertionShowing();
64 void AllowAutomaticSelectionShowing();
65
66 // Hide the handles and suppress bounds updates until the next explicit
67 // showing allowance.
68 void HideAndDisallowAutomaticShowing();
69
70 // To be called when the editability of the focused region changes.
71 void OnSelectionEditable(bool editable);
72
73 // Ticks an active animation, as requested to the client by |SetNeedsAnimate|.
74 // Returns true if an animation is active and requires further ticking.
75 bool Animate(base::TimeTicks animate_time);
76
77 private:
78 // TouchHandleClient implementation.
79 virtual void OnHandleDragBegin(const TouchHandle& handle) OVERRIDE;
80 virtual void OnHandleDragUpdate(const TouchHandle& handle,
81 const gfx::PointF& new_position) OVERRIDE;
82 virtual void OnHandleDragEnd(const TouchHandle& handle) OVERRIDE;
83 virtual void OnHandleTapped(const TouchHandle& handle) OVERRIDE;
84 virtual void SetNeedsAnimate() OVERRIDE;
85 virtual scoped_ptr<TouchHandleDrawable> CreateDrawable() OVERRIDE;
86
87 void OnInsertionChanged();
88 void OnSelectionChanged();
89
90 void ActivateInsertion();
91 void DeactivateInsertion();
92 void ActivateSelection();
93 void DeactivateSelection();
94 void ResetCachedValues();
95
96 gfx::PointF GetStartPosition() const;
97 gfx::PointF GetEndPosition() const;
98 float GetStartLineHeight() const;
99 float GetEndLineHeight() const;
100 TouchHandle::AnimationStyle GetAnimationStyle() const;
101
102 TouchSelectionControllerClient* const client_;
103
104 gfx::RectF start_rect_;
105 TouchHandleOrientation start_orientation_;
106 bool start_visible_;
107 gfx::RectF end_rect_;
108 TouchHandleOrientation end_orientation_;
109 bool end_visible_;
110
111 scoped_ptr<TouchHandle> insertion_handle_;
112 bool is_insertion_active_;
113 bool allow_automatic_insertion_activation_;
114
115 scoped_ptr<TouchHandle> start_selection_handle_;
116 scoped_ptr<TouchHandle> end_selection_handle_;
117 gfx::PointF fixed_handle_position_;
118 bool is_selection_active_;
119 bool allow_automatic_selection_activation_;
120
121 bool selection_editable_;
122 bool selection_editable_for_last_update_;
123
124 DISALLOW_COPY_AND_ASSIGN(TouchSelectionController);
125 };
126
127 } // namespace content
128
129 #endif // CONTENT_BROWSER_RENDERER_HOST_INPUT_TOUCH_SELECTION_CONTROLLER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698