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

Unified 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: Test and comments Created 6 years, 6 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/renderer_host/input/touch_selection_controller.h
diff --git a/content/browser/renderer_host/input/touch_selection_controller.h b/content/browser/renderer_host/input/touch_selection_controller.h
new file mode 100644
index 0000000000000000000000000000000000000000..f1b2632d1adf9c5563aff00afb181cef29cf9e6f
--- /dev/null
+++ b/content/browser/renderer_host/input/touch_selection_controller.h
@@ -0,0 +1,105 @@
+// Copyright 2014 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_RENDERER_HOST_INPUT_TOUCH_SELECTION_CONTROLLER_H_
+#define CONTENT_BROWSER_RENDERER_HOST_INPUT_TOUCH_SELECTION_CONTROLLER_H_
+
+#include "content/browser/renderer_host/input/selection_event_type.h"
+#include "content/browser/renderer_host/input/touch_handle.h"
+#include "content/common/content_export.h"
+#include "ui/gfx/geometry/point_f.h"
+#include "ui/gfx/geometry/rect_f.h"
+
+namespace ui {
+class MotionEvent;
+}
+
+namespace content {
+
+// Interface through which |TouchSelectionController| issues selection-related
+// commands, notifications and requests.
+class CONTENT_EXPORT TouchSelectionControllerClient {
+ public:
+ virtual ~TouchSelectionControllerClient() {}
+
+ virtual void SetNeedsAnimate() = 0;
+ virtual void MoveCaret(const gfx::PointF& position) = 0;
+ virtual void SelectBetweenCoordinates(const gfx::PointF& start,
+ const gfx::PointF& end) = 0;
+ virtual void OnSelectionEvent(SelectionEventType event,
+ const gfx::PointF& anchor_position) = 0;
+ virtual scoped_ptr<TouchHandleDrawable> CreateDrawable() = 0;
+};
+
+// Controller for manipulating text selection via touch input.
+class CONTENT_EXPORT TouchSelectionController : public TouchHandleClient {
+ public:
+ explicit TouchSelectionController(TouchSelectionControllerClient* client);
+ virtual ~TouchSelectionController();
+
+ 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
+ TouchHandleOrientation anchor_orientation,
+ bool anchor_visible,
+ const gfx::RectF& focus_rect,
+ TouchHandleOrientation focus_orientation,
+ bool focus_visible);
+ bool WillHandleTouchEvent(const ui::MotionEvent& event);
+ void AllowAutomaticInsertionShowing();
+ void AllowAutomaticSelectionShowing();
+ void HideAndDisallowAutomaticShowing();
+ void OnSelectionEditable(bool editable);
+ bool Animate(base::TimeTicks animate_time);
+
+ private:
+ // TouchHandleClient implementation.
+ virtual void OnHandleDragBegin(const TouchHandle& handle) OVERRIDE;
+ virtual void OnHandleDragUpdate(const TouchHandle& handle,
+ const gfx::PointF& new_position) OVERRIDE;
+ virtual void OnHandleDragEnd(const TouchHandle& handle) OVERRIDE;
+ virtual void OnHandleTapped(const TouchHandle& handle) OVERRIDE;
+ virtual void SetNeedsAnimate() OVERRIDE;
+ virtual scoped_ptr<TouchHandleDrawable> CreateDrawable() OVERRIDE;
+
+ void OnInsertionChanged();
+ void OnSelectionChanged();
+
+ void ActivateInsertion();
+ void DeactivateInsertion();
+ void ActivateSelection();
+ void DeactivateSelection();
+ void ResetCachedValues();
+
+ gfx::PointF GetAnchorPosition() const;
+ gfx::PointF GetFocusPosition() const;
+ float GetAnchorLineHeight() const;
+ float GetFocusLineHeight() const;
+
+ TouchSelectionControllerClient* const client_;
+
+ gfx::RectF anchor_rect_;
+ TouchHandleOrientation anchor_orientation_;
+ bool anchor_visible_;
+ gfx::RectF focus_rect_;
+ TouchHandleOrientation focus_orientation_;
+ bool focus_visible_;
+
+ scoped_ptr<TouchHandle> insertion_handle_;
+ bool is_insertion_active_;
+ bool allow_automatic_insertion_activation_;
+
+ scoped_ptr<TouchHandle> start_selection_handle_;
+ scoped_ptr<TouchHandle> end_selection_handle_;
+ gfx::PointF fixed_handle_position_;
+ bool is_selection_active_;
+ bool allow_automatic_selection_activation_;
+
+ bool selection_editable_;
+ bool selection_editable_for_last_update_;
+
+ DISALLOW_COPY_AND_ASSIGN(TouchSelectionController);
+};
+
+} // namespace content
+
+#endif // CONTENT_BROWSER_RENDERER_HOST_INPUT_TOUCH_SELECTION_CONTROLLER_H_

Powered by Google App Engine
This is Rietveld 408576698