Chromium Code Reviews| OLD | NEW |
|---|---|
| (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 ui { | |
| 15 class MotionEvent; | |
| 16 } | |
| 17 | |
| 18 namespace content { | |
| 19 | |
| 20 // Interface through which |TouchSelectionController| issues selection-related | |
| 21 // commands, notifications and requests. | |
| 22 class CONTENT_EXPORT TouchSelectionControllerClient { | |
| 23 public: | |
| 24 virtual ~TouchSelectionControllerClient() {} | |
| 25 | |
| 26 virtual void SetNeedsAnimate() = 0; | |
| 27 virtual void MoveCaret(const gfx::PointF& position) = 0; | |
| 28 virtual void SelectBetweenCoordinates(const gfx::PointF& start, | |
| 29 const gfx::PointF& end) = 0; | |
| 30 virtual void OnSelectionEvent(SelectionEventType event, | |
| 31 const gfx::PointF& anchor_position) = 0; | |
| 32 virtual scoped_ptr<TouchHandleDrawable> CreateDrawable() = 0; | |
| 33 }; | |
| 34 | |
| 35 // Controller for manipulating text selection via touch input. | |
| 36 class CONTENT_EXPORT TouchSelectionController : public TouchHandleClient { | |
| 37 public: | |
| 38 explicit TouchSelectionController(TouchSelectionControllerClient* client); | |
| 39 virtual ~TouchSelectionController(); | |
| 40 | |
| 41 void OnSelectionBoundsChanged(const gfx::RectF& anchor_rect, | |
|
cjhopman
2014/07/07 22:13:41
based on the naming (all the way into WebView::sel
jdduke (slow)
2014/07/08 00:54:45
Sigh, yeah, it took me a while to figure out what
| |
| 42 TouchHandleOrientation anchor_orientation, | |
| 43 bool anchor_visible, | |
| 44 const gfx::RectF& focus_rect, | |
| 45 TouchHandleOrientation focus_orientation, | |
| 46 bool focus_visible); | |
| 47 bool WillHandleTouchEvent(const ui::MotionEvent& event); | |
| 48 void AllowAutomaticInsertionShowing(); | |
| 49 void AllowAutomaticSelectionShowing(); | |
| 50 void HideAndDisallowAutomaticShowing(); | |
| 51 void OnSelectionEditable(bool editable); | |
| 52 bool Animate(base::TimeTicks animate_time); | |
| 53 | |
| 54 private: | |
| 55 // TouchHandleClient implementation. | |
| 56 virtual void OnHandleDragBegin(const TouchHandle& handle) OVERRIDE; | |
| 57 virtual void OnHandleDragUpdate(const TouchHandle& handle, | |
| 58 const gfx::PointF& new_position) OVERRIDE; | |
| 59 virtual void OnHandleDragEnd(const TouchHandle& handle) OVERRIDE; | |
| 60 virtual void OnHandleTapped(const TouchHandle& handle) OVERRIDE; | |
| 61 virtual void SetNeedsAnimate() OVERRIDE; | |
| 62 virtual scoped_ptr<TouchHandleDrawable> CreateDrawable() OVERRIDE; | |
| 63 | |
| 64 void OnInsertionChanged(); | |
| 65 void OnSelectionChanged(); | |
| 66 | |
| 67 void ActivateInsertion(); | |
| 68 void DeactivateInsertion(); | |
| 69 void ActivateSelection(); | |
| 70 void DeactivateSelection(); | |
| 71 void ResetCachedValues(); | |
| 72 | |
| 73 gfx::PointF GetAnchorPosition() const; | |
| 74 gfx::PointF GetFocusPosition() const; | |
| 75 float GetAnchorLineHeight() const; | |
| 76 float GetFocusLineHeight() const; | |
| 77 | |
| 78 TouchSelectionControllerClient* const client_; | |
| 79 | |
| 80 gfx::RectF anchor_rect_; | |
| 81 TouchHandleOrientation anchor_orientation_; | |
| 82 bool anchor_visible_; | |
| 83 gfx::RectF focus_rect_; | |
| 84 TouchHandleOrientation focus_orientation_; | |
| 85 bool focus_visible_; | |
| 86 | |
| 87 scoped_ptr<TouchHandle> insertion_handle_; | |
| 88 bool is_insertion_active_; | |
| 89 bool allow_automatic_insertion_activation_; | |
| 90 | |
| 91 scoped_ptr<TouchHandle> start_selection_handle_; | |
| 92 scoped_ptr<TouchHandle> end_selection_handle_; | |
| 93 gfx::PointF fixed_handle_position_; | |
| 94 bool is_selection_active_; | |
| 95 bool allow_automatic_selection_activation_; | |
| 96 | |
| 97 bool selection_editable_; | |
| 98 bool selection_editable_for_last_update_; | |
| 99 | |
| 100 DISALLOW_COPY_AND_ASSIGN(TouchSelectionController); | |
| 101 }; | |
| 102 | |
| 103 } // namespace content | |
| 104 | |
| 105 #endif // CONTENT_BROWSER_RENDERER_HOST_INPUT_TOUCH_SELECTION_CONTROLLER_H_ | |
| OLD | NEW |