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

Issue 2408623002: Views: Extract text selection code from Textfield. (Closed)

Created:
4 years, 2 months ago by karandeepb
Modified:
4 years, 1 month ago
Reviewers:
tapted, sky, msw
CC:
chromium-reviews, tfarina, James Su, shuchen+watch_chromium.org, yusukes+watch_chromium.org, nona+watch_chromium.org, chrome-apps-syd-reviews_chromium.org
Target Ref:
refs/pending/heads/master
Project:
chromium
Visibility:
Public.

Description

Views: Extract text selection code from Textfield. This CL is first in part of CLs to implement text selection for Views::Labels. This CL extracts the text selection functionality from Views::Textfield into a new controller class called SelectionController. This class works in tandem with its delegate. Views::Textfield implements the SelectionController::Delegate interface. This also fixes a couple of bugs related to middle clicks on Linux- 1) Middle clicking inside the selection region of an unfocused textfield should now give it focus. 2) This fixes the appearance of multiple cursors in textfields when middle clicking with an empty selection clipboard. Also, Textfield now handles OnMouseCaptureLost. This ensures that the drag selection timer is stopped and the selection clipboard is updated when mouse capture is released. A subsequent CL will modify views::Label to implement the SelectionController::Delegate interface so that it also supports text selection. Doc= https://docs.google.com/a/google.com/document/d/1JTjY8RLE84hxubCAouHuD6xVtvuMnzbqSDZyf_4N6tY/edit?usp=sharing BUG=630365, 437993, 657691 Committed: https://crrev.com/9bc2b7bbb5062c62fb98fb7d925765f64be80552 Cr-Commit-Position: refs/heads/master@{#427604}

Patch Set 1 #

Patch Set 2 : - #

Patch Set 3 : Reorder funcs. #

Patch Set 4 : Rename [Starting/Ending]MouseAction. #

Total comments: 11

Patch Set 5 : Rebase. #

Patch Set 6 : SelectionControllerDelegate now an inner class. #

Patch Set 7 : Pull more functionality into SelectionController #

Patch Set 8 #

Total comments: 31

Patch Set 9 : Changes for msw@. #

Patch Set 10 : SelectionController::Delegate => SelectionControllerDelegate. #

Patch Set 11 : Rebase. #

Total comments: 19

Patch Set 12 : Removed On[Before|After]SelectionUpdated. #

Total comments: 2

Patch Set 13 : Changes to PasteSelectionClipboard #

Total comments: 9

Patch Set 14 #

Total comments: 12

Patch Set 15 : Rebase. #

Patch Set 16 : Address nits. #

Total comments: 16

Patch Set 17 : Address comments by sky@. #

Total comments: 2

Patch Set 18 : Address nit. #

Patch Set 19 : Check for |handles_selection_clipboard_| #

Total comments: 1
Unified diffs Side-by-side diffs Delta from patch set Stats (+515 lines, -207 lines) Patch
M chrome/browser/ui/views/omnibox/omnibox_view_views.cc View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 1 chunk +1 line, -1 line 0 comments Download
M ui/gfx/render_text.h View 1 2 3 4 5 6 7 8 9 10 11 12 13 1 chunk +6 lines, -0 lines 0 comments Download
M ui/gfx/render_text.cc View 1 2 3 4 5 6 7 1 chunk +7 lines, -0 lines 0 comments Download
M ui/views/BUILD.gn View 1 2 3 4 5 6 7 8 9 10 1 chunk +3 lines, -0 lines 0 comments Download
M ui/views/controls/textfield/textfield.h View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 12 chunks +27 lines, -29 lines 0 comments Download
M ui/views/controls/textfield/textfield.cc View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 14 chunks +108 lines, -172 lines 0 comments Download
M ui/views/controls/textfield/textfield_model.h View 1 2 3 4 5 6 7 1 chunk +2 lines, -1 line 0 comments Download
M ui/views/controls/textfield/textfield_model.cc View 1 2 3 4 5 6 1 chunk +1 line, -4 lines 0 comments Download
A ui/views/selection_controller.h View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 1 chunk +90 lines, -0 lines 0 comments Download
A ui/views/selection_controller.cc View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 1 chunk +203 lines, -0 lines 1 comment Download
A ui/views/selection_controller_delegate.h View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 1 chunk +67 lines, -0 lines 0 comments Download

Dependent Patchsets:

Messages

Total messages: 113 (80 generated)
karandeepb
Trent, can you take a quick look at this and comment about the design. Subsequently ...
4 years, 2 months ago (2016-10-11 03:43:56 UTC) #7
tapted
there does seem to be an opportunity to encapsulate more logic into the SelectionController that ...
4 years, 2 months ago (2016-10-11 04:42:10 UTC) #8
karandeepb
https://codereview.chromium.org/2408623002/diff/60001/ui/views/controls/textfield/textfield.h File ui/views/controls/textfield/textfield.h (right): https://codereview.chromium.org/2408623002/diff/60001/ui/views/controls/textfield/textfield.h#newcode245 ui/views/controls/textfield/textfield.h:245: void SelectAll(bool reversed) override; On 2016/10/11 04:42:09, tapted wrote: ...
4 years, 2 months ago (2016-10-11 05:01:30 UTC) #9
karandeepb
PTAL Trent. Have removed the Select* methods from the SelectionController::Delegate interface and implemented these within ...
4 years, 2 months ago (2016-10-14 09:27:35 UTC) #38
karandeepb
PTAL msw@, sky@. WDYT of the approach?
4 years, 2 months ago (2016-10-14 09:28:53 UTC) #40
msw
I like the general approach, but have some comments. https://codereview.chromium.org/2408623002/diff/340001/ui/views/controls/textfield/textfield.cc File ui/views/controls/textfield/textfield.cc (right): https://codereview.chromium.org/2408623002/diff/340001/ui/views/controls/textfield/textfield.cc#newcode325 ui/views/controls/textfield/textfield.cc:325: ...
4 years, 2 months ago (2016-10-14 18:54:21 UTC) #41
sky
I'm assuming Mike is reviewing this. I'll look at ui/views/selection_controller. https://codereview.chromium.org/2408623002/diff/340001/ui/views/selection_controller.h File ui/views/selection_controller.h (right): https://codereview.chromium.org/2408623002/diff/340001/ui/views/selection_controller.h#newcode86 ...
4 years, 2 months ago (2016-10-14 22:29:48 UTC) #42
karandeepb
PTAL msw@. Thanks. https://codereview.chromium.org/2408623002/diff/340001/ui/views/controls/textfield/textfield.cc File ui/views/controls/textfield/textfield.cc (right): https://codereview.chromium.org/2408623002/diff/340001/ui/views/controls/textfield/textfield.cc#newcode325 ui/views/controls/textfield/textfield.cc:325: // Todo is this redundant? On ...
4 years, 2 months ago (2016-10-17 07:08:15 UTC) #51
karandeepb
ping msw@.
4 years, 2 months ago (2016-10-18 10:13:29 UTC) #52
msw
Sorry for the delay, I was trying to wrap my head around the On[Before|After]* stuff. ...
4 years, 2 months ago (2016-10-18 23:15:05 UTC) #53
tapted
On 2016/10/18 23:15:05, msw wrote: > Sorry for the delay, I was trying to wrap ...
4 years, 2 months ago (2016-10-18 23:34:06 UTC) #54
msw
On 2016/10/18 23:34:06, tapted wrote: > On 2016/10/18 23:15:05, msw wrote: > > Sorry for ...
4 years, 2 months ago (2016-10-19 00:01:49 UTC) #55
karandeepb
>>Sorry for the delay, I was trying to wrap my head around the On[Before|After]* >>stuff. ...
4 years, 2 months ago (2016-10-19 01:15:50 UTC) #56
msw
On 2016/10/19 01:15:50, karandeepb wrote: > On[Before/After]MouseAction are needed since SelectThroughLastDragLocation is > async. With ...
4 years, 2 months ago (2016-10-19 01:38:57 UTC) #57
karandeepb
https://codereview.chromium.org/2408623002/diff/340001/ui/views/controls/textfield/textfield.cc File ui/views/controls/textfield/textfield.cc (right): https://codereview.chromium.org/2408623002/diff/340001/ui/views/controls/textfield/textfield.cc#newcode1784 ui/views/controls/textfield/textfield.cc:1784: UpdateAfterChange(false, true); On 2016/10/18 23:15:05, msw wrote: > On ...
4 years, 2 months ago (2016-10-20 04:12:58 UTC) #73
karandeepb
PTAL msw@. On 2016/10/19 01:38:57, msw wrote: > On 2016/10/19 01:15:50, karandeepb wrote: > > ...
4 years, 2 months ago (2016-10-20 04:15:04 UTC) #74
msw
lgtm with nits. Thanks for all your work here, and suffering my review. https://codereview.chromium.org/2408623002/diff/400001/ui/views/selection_controller.cc File ...
4 years, 2 months ago (2016-10-21 02:14:16 UTC) #77
karandeepb
https://codereview.chromium.org/2408623002/diff/540001/ui/views/controls/textfield/textfield.cc File ui/views/controls/textfield/textfield.cc (left): https://codereview.chromium.org/2408623002/diff/540001/ui/views/controls/textfield/textfield.cc#oldcode2075 ui/views/controls/textfield/textfield.cc:2075: model_->MoveCursorTo(mouse); On 2016/10/21 02:14:15, msw wrote: > On 2016/10/20 ...
4 years, 2 months ago (2016-10-21 05:04:32 UTC) #79
karandeepb
PTAL sky@ for owner's review for ui/views/selection_controller* ui/views/BUILD.gn
4 years, 2 months ago (2016-10-21 05:05:38 UTC) #80
sky
https://codereview.chromium.org/2408623002/diff/620001/ui/views/selection_controller.cc File ui/views/selection_controller.cc (right): https://codereview.chromium.org/2408623002/diff/620001/ui/views/selection_controller.cc#newcode67 ui/views/selection_controller.cc:67: #if defined(OS_LINUX) && !defined(OS_CHROMEOS) I would inject whether this ...
4 years, 2 months ago (2016-10-21 15:03:40 UTC) #81
karandeepb
PTAL sky@. https://codereview.chromium.org/2408623002/diff/620001/ui/views/selection_controller.cc File ui/views/selection_controller.cc (right): https://codereview.chromium.org/2408623002/diff/620001/ui/views/selection_controller.cc#newcode67 ui/views/selection_controller.cc:67: #if defined(OS_LINUX) && !defined(OS_CHROMEOS) On 2016/10/21 15:03:40, ...
4 years, 1 month ago (2016-10-25 05:30:42 UTC) #89
sky
LGTM - thanks https://codereview.chromium.org/2408623002/diff/620001/ui/views/selection_controller.h File ui/views/selection_controller.h (right): https://codereview.chromium.org/2408623002/diff/620001/ui/views/selection_controller.h#newcode37 ui/views/selection_controller.h:37: bool OnMousePressed(const ui::MouseEvent& event, bool handled); ...
4 years, 1 month ago (2016-10-25 16:46:03 UTC) #90
karandeepb
https://codereview.chromium.org/2408623002/diff/660001/ui/views/selection_controller_delegate.h File ui/views/selection_controller_delegate.h (right): https://codereview.chromium.org/2408623002/diff/660001/ui/views/selection_controller_delegate.h#newcode41 ui/views/selection_controller_delegate.h:41: // Called before a mouse action which may change ...
4 years, 1 month ago (2016-10-26 00:46:38 UTC) #91
commit-bot: I haz the power
CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/v2/patch-status/codereview.chromium.org/2408623002/680001
4 years, 1 month ago (2016-10-26 00:59:59 UTC) #94
commit-bot: I haz the power
Try jobs failed on following builders: mac_chromium_rel_ng on master.tryserver.chromium.mac (JOB_FAILED, http://build.chromium.org/p/tryserver.chromium.mac/builders/mac_chromium_rel_ng/builds/322364)
4 years, 1 month ago (2016-10-26 02:13:25 UTC) #96
commit-bot: I haz the power
CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/v2/patch-status/codereview.chromium.org/2408623002/680001
4 years, 1 month ago (2016-10-26 02:17:15 UTC) #98
commit-bot: I haz the power
Try jobs failed on following builders: mac_chromium_rel_ng on master.tryserver.chromium.mac (JOB_FAILED, http://build.chromium.org/p/tryserver.chromium.mac/builders/mac_chromium_rel_ng/builds/322396)
4 years, 1 month ago (2016-10-26 02:22:27 UTC) #100
karandeepb
https://codereview.chromium.org/2408623002/diff/700001/ui/views/selection_controller.cc File ui/views/selection_controller.cc (right): https://codereview.chromium.org/2408623002/diff/700001/ui/views/selection_controller.cc#newcode132 ui/views/selection_controller.cc:132: if (handles_selection_clipboard_ && !render_text->selection().is_empty()) Also added a couple of ...
4 years, 1 month ago (2016-10-26 02:27:39 UTC) #102
commit-bot: I haz the power
CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/v2/patch-status/codereview.chromium.org/2408623002/700001
4 years, 1 month ago (2016-10-26 02:28:04 UTC) #105
commit-bot: I haz the power
Try jobs failed on following builders: linux_chromium_chromeos_rel_ng on master.tryserver.chromium.linux (JOB_FAILED, http://build.chromium.org/p/tryserver.chromium.linux/builders/linux_chromium_chromeos_rel_ng/builds/302837)
4 years, 1 month ago (2016-10-26 05:02:37 UTC) #107
commit-bot: I haz the power
CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/v2/patch-status/codereview.chromium.org/2408623002/700001
4 years, 1 month ago (2016-10-26 05:12:23 UTC) #109
commit-bot: I haz the power
Committed patchset #19 (id:700001)
4 years, 1 month ago (2016-10-26 06:05:01 UTC) #111
commit-bot: I haz the power
4 years, 1 month ago (2016-10-26 06:06:21 UTC) #113
Message was sent while issue was closed.
Patchset 19 (id:??) landed as
https://crrev.com/9bc2b7bbb5062c62fb98fb7d925765f64be80552
Cr-Commit-Position: refs/heads/master@{#427604}

Powered by Google App Engine
This is Rietveld 408576698