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

Unified Diff: ui/views/selection_controller_host.h

Issue 2408623002: Views: Extract text selection code from Textfield. (Closed)
Patch Set: Rename [Starting/Ending]MouseAction. Created 4 years, 2 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
« ui/views/selection_controller.h ('K') | « ui/views/selection_controller.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/views/selection_controller_host.h
diff --git a/ui/views/selection_controller_host.h b/ui/views/selection_controller_host.h
new file mode 100644
index 0000000000000000000000000000000000000000..6071440e5304be0155f2306c733e48eb0dd7b3a8
--- /dev/null
+++ b/ui/views/selection_controller_host.h
@@ -0,0 +1,103 @@
+// Copyright 2016 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 UI_VIEWS_SELECTION_CONTROLLER_HOST_H_
+#define UI_VIEWS_SELECTION_CONTROLLER_HOST_H_
+
+#include "ui/gfx/selection_model.h"
+namespace gfx {
+class RenderText;
+class Point;
+class Range;
+}
+
+namespace views {
+
+class SelectionController;
+
+// An interface implemented/managed by a view which uses a SelectionController.
+class SelectionControllerHost {
tapted 2016/10/11 04:42:09 in views parlance, this would probably be a Select
karandeepb 2016/10/14 09:27:34 Done. Also made it an inner class of SelectionCont
+ public:
+ // Returns the associated RenderText instance to be used for selection.
+ // Todo(karandeepb): Modify RenderText so that this can return a pointer to a
+ // const RenderText.
+ virtual gfx::RenderText* GetRenderTextForSelection() = 0;
+
+ // Methods related to properties of the associated view
+
+ // Returns true if the associated text view is read only.
+ virtual bool IsReadOnly() const = 0;
+ // Returns whether there is a drag operation originating from the associated
+ // view.
+ virtual bool HasTextBeingDragged() const = 0;
+ // Sets whether text is being dragged from the associated view.
+ virtual void SetTextBeingDragged(bool value) = 0;
+ // Returns the height of the associated view.
+ virtual int GetViewHeight() const = 0;
+ // Returns the width of the associated view.
+ virtual int GetViewWidth() const = 0;
+ // Returns the drag selection timer delay. This is the duration after which a
+ // drag selection is updated when the event location is outside the text
+ // bounds.
+ virtual int GetDragSelectionDelay() const = 0;
+
+ // Methods called to notify a mouse action which may change the associated
+ // view's text and/or selection.
+
+ // Called before performing a mouse action which may change the associated
+ // text or selection. Should not be called in succession and must always be
+ // followed by an OnAfterMouseAction call.
+ virtual void OnBeforeMouseAction() = 0;
+ // Called after the mouse action is performed. |text_changed| and
+ // |selection_changed| can be used by subclasses to make any necessary updates
+ // like redraw the text. Must always be preceeded by a OnBeforeMouseAction
+ // call.
+ virtual void OnAfterMouseAction(bool text_changed,
+ bool selection_changed) = 0;
+
+ // Selection related methods. Called only when a mouse action is in progress.
+ // Subclasses can defer making updates till the OnAfterMouseAction call.
+
+ // Select the entire text range. If |reversed| is true, the range will end at
+ // the logical beginning of the text; this generally shows the leading portion
+ // of text that overflows its display area.
+ virtual void SelectAll(bool reversed) = 0;
+ // Selects the word closest to |point|.
+ virtual void SelectWordAt(const gfx::Point& point) = 0;
+ // Selects the word at the current cursor position. If there is a non-empty
+ // selection, the selection bounds are extended to their nearest word
+ // boundaries.
+ virtual void SelectWord() = 0;
+ // Selects the specified logical text range. The range is truncated to lie
+ // within the text range. If the |range| start or end is not a cursorable
+ // position (not on grapheme boundary), it is a NO-OP.
+ virtual void SelectRange(const gfx::Range& range) = 0;
+ // Moves the cursor to the text index corresponding to |point|. |point| is in
+ // the coordinates of the associated view. If |select| is true, a selection is
+ // made with the current selection start index.
+ virtual void MoveCursorTo(const gfx::Point& point, bool select) = 0;
+ // Clears the existing selection keeping the current cursor position and caret
+ // affinity.
+ virtual void ClearSelection() = 0;
+ // Select till the beginning/end of line keeping the current selection start.
+ // Todo should this say something about only supporting single line.
+ virtual void SelectTillEdge(gfx::VisualCursorDirection direction) = 0;
+
+ // Selection clipboard related methods. Called only when a mouse action is in
+ // progress.
+
+ // Pastes the text in the selection clipboard at the current cursor position.
+ // NO-OP if the associated text view is read-only.
+ virtual void PasteSelectionClipboard() = 0;
+ // Updates the selection clipboard with the currently selected text. Should
+ // empty the selection clipboard if no text is currently selected.
+ virtual void UpdateSelectionClipboard() = 0;
+
+ protected:
+ virtual ~SelectionControllerHost() {}
+};
+
+} // namespace views
+
+#endif // UI_VIEWS_SELECTION_CONTROLLER_HOST_H_
« ui/views/selection_controller.h ('K') | « ui/views/selection_controller.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698