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

Unified Diff: ui/views/controls/textfield/textfield.h

Issue 2408623002: Views: Extract text selection code from Textfield. (Closed)
Patch Set: Removed On[Before|After]SelectionUpdated. 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
« no previous file with comments | « ui/views/BUILD.gn ('k') | ui/views/controls/textfield/textfield.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/views/controls/textfield/textfield.h
diff --git a/ui/views/controls/textfield/textfield.h b/ui/views/controls/textfield/textfield.h
index 55353ee8a4874498dbeff19c73dd9df4b11a7c6d..31784b610b11ed442053a6c27e3e5c4ae8b38968 100644
--- a/ui/views/controls/textfield/textfield.h
+++ b/ui/views/controls/textfield/textfield.h
@@ -29,6 +29,7 @@
#include "ui/views/context_menu_controller.h"
#include "ui/views/controls/textfield/textfield_model.h"
#include "ui/views/drag_controller.h"
+#include "ui/views/selection_controller_delegate.h"
#include "ui/views/view.h"
#include "ui/views/word_lookup_client.h"
@@ -36,6 +37,7 @@ namespace views {
class MenuRunner;
class Painter;
+class SelectionController;
class TextfieldController;
// A views/skia textfield implementation. No platform-specific code is used.
@@ -44,6 +46,7 @@ class VIEWS_EXPORT Textfield : public View,
public ContextMenuController,
public DragController,
public WordLookupClient,
+ public SelectionControllerDelegate,
public ui::TouchEditable,
public ui::TextInputClient {
public:
@@ -210,9 +213,6 @@ class VIEWS_EXPORT Textfield : public View,
// Set the accessible name of the text field.
void SetAccessibleName(const base::string16& name);
- // Returns whether there is a drag operation originating from the textfield.
- bool HasTextBeingDragged();
-
// View overrides:
gfx::Insets GetInsets() const override;
int GetBaseline() const override;
@@ -270,6 +270,9 @@ class VIEWS_EXPORT Textfield : public View,
gfx::DecoratedText* decorated_word,
gfx::Point* baseline_point) override;
+ // SelectionControllerDelegate overrides:
+ bool HasTextBeingDragged() const override;
+
// ui::TouchEditable overrides:
void SelectRect(const gfx::Point& start, const gfx::Point& end) override;
void MoveCaretTo(const gfx::Point& point) override;
@@ -327,7 +330,7 @@ class VIEWS_EXPORT Textfield : public View,
// Returns the TextfieldModel's text/cursor/selection rendering model.
gfx::RenderText* GetRenderText() const;
- gfx::Point last_click_location() const { return last_click_location_; }
+ gfx::Point GetLastClickLocation() const;
// Get the text from the selection clipboard.
virtual base::string16 GetSelectionClipboardText() const;
@@ -345,6 +348,18 @@ class VIEWS_EXPORT Textfield : public View,
bool OnKeyPressed(const ui::KeyEvent& event) final;
bool OnKeyReleased(const ui::KeyEvent& event) final;
+ // SelectionControllerDelegate overrides:
+ gfx::RenderText* GetRenderTextForSelectionController() override;
+ bool IsReadOnly() const override;
+ void SetTextBeingDragged(bool value) override;
+ int GetViewHeight() const override;
+ int GetViewWidth() const override;
+ int GetDragSelectionDelay() const override;
+ void OnBeforeMouseAction() override;
+ void OnAfterMouseAction(bool text_changed, bool selection_changed) override;
+ void PasteSelectionClipboard(const ui::MouseEvent& event) override;
+ void UpdateSelectionClipboard() override;
+
// Handles a request to change the value of this text field from software
// using an accessibility API (typically automation software, screen readers
// don't normally use this). Sets the value and clears the selection.
@@ -370,9 +385,6 @@ class VIEWS_EXPORT Textfield : public View,
// Helper function to call MoveCursorTo on the TextfieldModel.
void MoveCursorTo(const gfx::Point& point, bool select);
- // Helper function to update the selection on a mouse drag.
- void SelectThroughLastDragLocation();
-
// Convenience method to notify the InputMethod and TouchSelectionController.
void OnCaretBoundsChanged();
@@ -395,9 +407,6 @@ class VIEWS_EXPORT Textfield : public View,
// Utility function to prepare the context menu.
void UpdateContextMenu();
- // Tracks the mouse clicks for single/double/triple clicks.
- void TrackMouseClicks(const ui::MouseEvent& event);
-
// Returns true if the current text input type allows access by the IME.
bool ImeEditingAllowed() const;
@@ -407,13 +416,6 @@ class VIEWS_EXPORT Textfield : public View,
void CreateTouchSelectionControllerAndNotifyIt();
- // Updates the selection clipboard to any non-empty text selection for a non-
- // password textfield.
- void UpdateSelectionClipboard() const;
-
- // Pastes the selection clipboard for the specified mouse event.
- void PasteSelectionClipboard(const ui::MouseEvent& event);
-
// Called when editing a textfield fails because the textfield is readonly.
void OnEditFailed();
@@ -487,8 +489,9 @@ class VIEWS_EXPORT Textfield : public View,
// The timer to reveal the last typed password character.
base::OneShotTimer password_reveal_timer_;
- // Tracks whether a user action is being performed; i.e. OnBeforeUserAction()
- // has been called, but OnAfterUserAction() has not yet been called.
+ // Tracks whether a user action is being performed which may change the
+ // textfield; i.e. OnBeforeUserAction() has been called, but
karandeepb 2016/10/20 04:12:57 This is in line with the comments regarding On[Bef
msw 2016/10/21 02:14:15 Acknowledged.
+ // OnAfterUserAction() has not yet been called.
bool performing_user_action_;
// True if InputMethod::CancelComposition() should not be called.
@@ -504,19 +507,11 @@ class VIEWS_EXPORT Textfield : public View,
// Is the user potentially dragging and dropping from this view?
bool initiating_drag_;
- // A timer and point used to modify the selection when dragging.
- base::RepeatingTimer drag_selection_timer_;
- gfx::Point last_drag_location_;
-
- // State variables used to track double and triple clicks.
- size_t aggregated_clicks_;
- base::TimeTicks last_click_time_;
- gfx::Point last_click_location_;
- gfx::Range double_click_word_;
-
std::unique_ptr<ui::TouchEditingControllerDeprecated>
touch_selection_controller_;
+ std::unique_ptr<SelectionController> selection_controller_;
+
// Used to track touch drag starting location and offset to enable touch
// scrolling.
gfx::Point drag_start_location_;
« no previous file with comments | « ui/views/BUILD.gn ('k') | ui/views/controls/textfield/textfield.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698