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

Unified Diff: content/browser/web_contents/touch_editable_impl_aura.h

Issue 12321005: Enable touch based selection and editing for webpages behind a flag. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: patch Created 7 years, 8 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 side-by-side diff with in-line comments
Download patch
Index: content/browser/web_contents/touch_editable_impl_aura.h
diff --git a/content/browser/web_contents/touch_editable_impl_aura.h b/content/browser/web_contents/touch_editable_impl_aura.h
new file mode 100644
index 0000000000000000000000000000000000000000..9b0744170c0cedd1222e2f6f9abceb5b08458b20
--- /dev/null
+++ b/content/browser/web_contents/touch_editable_impl_aura.h
@@ -0,0 +1,101 @@
+// Copyright (c) 2013 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef CONTENT_BROWSER_WEB_CONTENTS_TOUCH_EDITABLE_IMPL_AURA_H_
+#define CONTENT_BROWSER_WEB_CONTENTS_TOUCH_EDITABLE_IMPL_AURA_H_
+
+#include <deque>
+#include <map>
+
+#include "content/browser/renderer_host/render_widget_host_view_aura.h"
+#include "ui/aura/window_observer.h"
+#include "ui/base/touch/touch_editing_controller.h"
+#include "ui/gfx/native_widget_types.h"
+#include "ui/gfx/point.h"
+#include "ui/gfx/rect.h"
+
+namespace ui {
+class Accelerator;
+}
+
+namespace content {
+
+// Aura specific implementation of ui::TouchEditable for a RenderWidgetHostView.
+class TouchEditableImplAura
+ : public ui::TouchEditable,
+ public aura::WindowObserver,
+ public RenderWidgetHostViewAura::TouchEditingClient {
+ public:
+ virtual ~TouchEditableImplAura();
+
+ static TouchEditableImplAura* Create();
+
+ void AttachToView(RenderWidgetHostViewAura* view);
+
+ // Overridden from RenderWidgetHostViewAura::TouchEditingClient.
+ virtual void StartTouchEditing() OVERRIDE;
+ virtual void EndTouchEditing() OVERRIDE;
+ virtual void OnSelectionOrCursorChanged(const gfx::Rect& anchor,
+ const gfx::Rect& focus) OVERRIDE;
+ virtual void OnTextInputTypeChanged(ui::TextInputType type) OVERRIDE;
+ virtual bool HandleInputEvent(const ui::Event* event) OVERRIDE;
+ virtual void GestureEventAck(int gesture_event_type) OVERRIDE;
+ virtual void OnViewDestroyed() OVERRIDE;
+
+ // Overridden from ui::TouchEditable:
+ virtual void SelectRect(const gfx::Point& start,
+ const gfx::Point& end) OVERRIDE;
+ virtual void MoveCaretTo(const gfx::Point& point) OVERRIDE;
+ virtual void GetSelectionEndPoints(gfx::Rect* p1, gfx::Rect* p2) OVERRIDE;
+ virtual gfx::Rect GetBounds() OVERRIDE;
+ virtual gfx::NativeView GetNativeView() OVERRIDE;
+ virtual void ConvertPointToScreen(gfx::Point* point) OVERRIDE;
+ virtual void ConvertPointFromScreen(gfx::Point* point) OVERRIDE;
+ virtual bool DrawsHandles() OVERRIDE;
+ virtual void OpenContextMenu(const gfx::Point anchor) OVERRIDE;
+ virtual bool IsCommandIdChecked(int command_id) const OVERRIDE;
+ virtual bool IsCommandIdEnabled(int command_id) const OVERRIDE;
+ virtual bool GetAcceleratorForCommandId(
+ int command_id,
+ ui::Accelerator* accelerator) OVERRIDE;
+ virtual void ExecuteCommand(int command_id, int event_flags) OVERRIDE;
+
+ // Overridden from aura::WindowObserver.
+ virtual void OnWindowParentChanged(aura::Window* window,
+ aura::Window* parent) OVERRIDE;
+ virtual void OnWindowBoundsChanged(aura::Window* window,
+ const gfx::Rect& old_bounds,
+ const gfx::Rect& new_bounds) OVERRIDE;
+ virtual void OnWindowDestroying(aura::Window* window) OVERRIDE;
+
+ private:
+ TouchEditableImplAura();
+
+ // Convenience method to update the |touch_selection_controller_| or end touch
+ // editing session depending on the current selection and cursor state.
+ void UpdateController();
+
+ void Cleanup();
+
+ // Rectangles for the selection anchor and focus.
+ gfx::Rect selection_anchor_rect_;
+ gfx::Rect selection_focus_rect_;
+
+ // The current text input type.
+ ui::TextInputType text_input_type_;
+
+ RenderWidgetHostViewAura* rwhva_;
+ aura::Window* top_level_window_;
+ scoped_ptr<ui::TouchSelectionController> touch_selection_controller_;
+
+ // True if |rwhva_| is currently handling a gesture that could result in a
+ // change in selection.
+ bool selection_gesture_in_process_;
+
+ DISALLOW_COPY_AND_ASSIGN(TouchEditableImplAura);
+};
+
+} // namespace content
+
+#endif // CONTENT_BROWSER_WEB_CONTENTS_TOUCH_EDITABLE_IMPL_AURA_H_

Powered by Google App Engine
This is Rietveld 408576698