OLD | NEW |
(Empty) | |
| 1 // Copyright (c) 2013 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_WEB_CONTENTS_TOUCH_EDITABLE_IMPL_AURA_H_ |
| 6 #define CONTENT_BROWSER_WEB_CONTENTS_TOUCH_EDITABLE_IMPL_AURA_H_ |
| 7 |
| 8 #include <deque> |
| 9 #include <map> |
| 10 #include <queue> |
| 11 |
| 12 #include "content/browser/renderer_host/render_widget_host_view_aura.h" |
| 13 #include "ui/aura/window_observer.h" |
| 14 #include "ui/base/touch/touch_editing_controller.h" |
| 15 #include "ui/gfx/geometry/point.h" |
| 16 #include "ui/gfx/geometry/rect.h" |
| 17 #include "ui/gfx/native_widget_types.h" |
| 18 |
| 19 namespace ui { |
| 20 class Accelerator; |
| 21 } |
| 22 |
| 23 namespace content { |
| 24 class TouchEditableImplAuraTest; |
| 25 |
| 26 // Aura specific implementation of ui::TouchEditable for a RenderWidgetHostView. |
| 27 class CONTENT_EXPORT TouchEditableImplAura |
| 28 : public ui::TouchEditable, |
| 29 public NON_EXPORTED_BASE(RenderWidgetHostViewAura::TouchEditingClient) { |
| 30 public: |
| 31 ~TouchEditableImplAura() override; |
| 32 |
| 33 static TouchEditableImplAura* Create(); |
| 34 |
| 35 void AttachToView(RenderWidgetHostViewAura* view); |
| 36 |
| 37 // Updates the |touch_selection_controller_| or ends touch editing session |
| 38 // depending on the current selection and cursor state. |
| 39 void UpdateEditingController(); |
| 40 |
| 41 virtual void OverscrollStarted(); |
| 42 virtual void OverscrollCompleted(); |
| 43 |
| 44 // Overridden from RenderWidgetHostViewAura::TouchEditingClient. |
| 45 void StartTouchEditing() override; |
| 46 void EndTouchEditing(bool quick) override; |
| 47 void OnSelectionOrCursorChanged(const ui::SelectionBound& anchor, |
| 48 const ui::SelectionBound& focus) override; |
| 49 void OnTextInputTypeChanged(ui::TextInputType type) override; |
| 50 bool HandleInputEvent(const ui::Event* event) override; |
| 51 void GestureEventAck(int gesture_event_type) override; |
| 52 void DidStopFlinging() override; |
| 53 void OnViewDestroyed() override; |
| 54 |
| 55 // Overridden from ui::TouchEditable: |
| 56 void SelectRect(const gfx::Point& start, const gfx::Point& end) override; |
| 57 void MoveCaretTo(const gfx::Point& point) override; |
| 58 void GetSelectionEndPoints(ui::SelectionBound* anchor, |
| 59 ui::SelectionBound* focus) override; |
| 60 gfx::Rect GetBounds() override; |
| 61 gfx::NativeView GetNativeView() const override; |
| 62 void ConvertPointToScreen(gfx::Point* point) override; |
| 63 void ConvertPointFromScreen(gfx::Point* point) override; |
| 64 bool DrawsHandles() override; |
| 65 void OpenContextMenu(const gfx::Point& anchor) override; |
| 66 bool IsCommandIdChecked(int command_id) const override; |
| 67 bool IsCommandIdEnabled(int command_id) const override; |
| 68 bool GetAcceleratorForCommandId(int command_id, |
| 69 ui::Accelerator* accelerator) override; |
| 70 void ExecuteCommand(int command_id, int event_flags) override; |
| 71 void DestroyTouchSelection() override; |
| 72 |
| 73 protected: |
| 74 TouchEditableImplAura(); |
| 75 |
| 76 private: |
| 77 friend class TouchEditableImplAuraTest; |
| 78 |
| 79 // A convenience function that is called after scroll/fling/overscroll ends to |
| 80 // re-activate touch selection if necessary. |
| 81 void StartTouchEditingIfNecessary(); |
| 82 |
| 83 void Cleanup(); |
| 84 |
| 85 // Bounds for the selection. |
| 86 ui::SelectionBound selection_anchor_; |
| 87 ui::SelectionBound selection_focus_; |
| 88 |
| 89 // The current text input type. |
| 90 ui::TextInputType text_input_type_; |
| 91 |
| 92 RenderWidgetHostViewAura* rwhva_; |
| 93 scoped_ptr<ui::TouchEditingControllerDeprecated> touch_selection_controller_; |
| 94 |
| 95 // True if |rwhva_| is currently handling a gesture that could result in a |
| 96 // change in selection (long press, double tap or triple tap). |
| 97 bool selection_gesture_in_process_; |
| 98 |
| 99 // Set to true if handles are hidden when user is scrolling. Used to determine |
| 100 // whether to re-show handles after a scrolling session. |
| 101 bool handles_hidden_due_to_scroll_; |
| 102 |
| 103 // Keep track of scrolls/overscrolls in progress. |
| 104 bool scroll_in_progress_; |
| 105 bool overscroll_in_progress_; |
| 106 |
| 107 // Used to track if a textfield was focused when the current tap gesture |
| 108 // happened. |
| 109 bool textfield_was_focused_on_tap_; |
| 110 |
| 111 DISALLOW_COPY_AND_ASSIGN(TouchEditableImplAura); |
| 112 }; |
| 113 |
| 114 } // namespace content |
| 115 |
| 116 #endif // CONTENT_BROWSER_WEB_CONTENTS_TOUCH_EDITABLE_IMPL_AURA_H_ |
OLD | NEW |