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

Issue 8044004: Clean up of SelectionModel (Closed)

Created:
9 years, 3 months ago by xji
Modified:
9 years, 2 months ago
Reviewers:
msw, oshima, varunjain, behdad
CC:
chromium-reviews, dhollowa
Visibility:
Public.

Description

1. change the setters of gfx::SelectionModel to be private. Set one alone might make SelectionModel into un-stable state, which should not be allowed. 2. Removing SelectionModel(size_t, size_t) constructor. Introduce RenderText::SelectRange(const ui::Range&) to handle range. 3. revert removal of SelectRange/GetSelectedRange in r103188. BUG=90426 TEST=view_unittests. Committed: http://src.chromium.org/viewvc/chrome?view=rev&revision=105138

Patch Set 1 #

Patch Set 2 : '' #

Patch Set 3 : '' #

Total comments: 21

Patch Set 4 : '' #

Total comments: 22

Patch Set 5 : address comment #

Patch Set 6 : sync and fix SelectionModel ctor usage #

Patch Set 7 : fix SelectionModel ctor usage in TextfieldViewsModel::MoveCursorTo #

Total comments: 9

Patch Set 8 : add comment about 'next' in ReplaceTextInternal #

Unified diffs Side-by-side diffs Delta from patch set Stats (+467 lines, -161 lines) Patch
M chrome/browser/ui/views/omnibox/omnibox_view_views.cc View 1 2 3 4 5 8 chunks +20 lines, -39 lines 0 comments Download
M ui/gfx/render_text.h View 1 2 3 4 5 2 chunks +7 lines, -4 lines 0 comments Download
M ui/gfx/render_text.cc View 1 2 3 4 5 3 chunks +26 lines, -3 lines 0 comments Download
M ui/gfx/selection_model.h View 1 2 3 4 5 1 chunk +9 lines, -10 lines 0 comments Download
M ui/gfx/selection_model.cc View 1 2 3 4 5 1 chunk +0 lines, -4 lines 0 comments Download
M views/controls/textfield/native_textfield_gtk.h View 1 2 3 4 5 1 chunk +2 lines, -0 lines 0 comments Download
M views/controls/textfield/native_textfield_gtk.cc View 1 2 3 4 5 1 chunk +10 lines, -2 lines 0 comments Download
M views/controls/textfield/native_textfield_views.h View 1 2 3 4 5 1 chunk +2 lines, -0 lines 0 comments Download
M views/controls/textfield/native_textfield_views.cc View 1 2 3 4 5 5 chunks +23 lines, -14 lines 0 comments Download
M views/controls/textfield/native_textfield_views_unittest.cc View 1 2 3 4 5 5 chunks +6 lines, -5 lines 0 comments Download
M views/controls/textfield/native_textfield_win.h View 1 2 3 4 5 1 chunk +2 lines, -0 lines 0 comments Download
M views/controls/textfield/native_textfield_win.cc View 1 2 3 4 5 1 chunk +8 lines, -0 lines 0 comments Download
M views/controls/textfield/native_textfield_wrapper.h View 1 2 3 4 5 1 chunk +6 lines, -0 lines 0 comments Download
M views/controls/textfield/textfield.h View 1 2 3 4 5 1 chunk +8 lines, -0 lines 0 comments Download
M views/controls/textfield/textfield.cc View 1 2 3 4 5 3 chunks +17 lines, -7 lines 0 comments Download
M views/controls/textfield/textfield_views_model.h View 1 2 3 4 5 1 chunk +8 lines, -0 lines 0 comments Download
M views/controls/textfield/textfield_views_model.cc View 1 2 3 4 5 6 7 5 chunks +28 lines, -12 lines 0 comments Download
M views/controls/textfield/textfield_views_model_unittest.cc View 1 2 3 4 5 10 chunks +155 lines, -38 lines 0 comments Download
M views/touchui/touch_selection_controller_impl_unittest.cc View 1 2 3 4 5 4 chunks +130 lines, -23 lines 0 comments Download

Messages

Total messages: 21 (0 generated)
xji
9 years, 2 months ago (2011-09-28 23:02:38 UTC) #1
msw
The changes here generally seem correct, yet they might be insufficient to ensure correct usage. ...
9 years, 2 months ago (2011-09-29 02:20:21 UTC) #2
xji
Ah, I got a "Invalid XSRF token." when I submit last time, and I have ...
9 years, 2 months ago (2011-09-29 21:11:10 UTC) #3
xji
> > What about all the places that use > > the caret positions, which ...
9 years, 2 months ago (2011-09-29 23:59:47 UTC) #4
xji
> I'm concerned by the presence of this new caret position enum value that's > ...
9 years, 2 months ago (2011-09-30 00:53:43 UTC) #5
xji
Looks like the 2 ways to completely get rid of TRAILING_OF_PREVIOUS_GRAPHEME are: remove SelectionModel(size_t start, ...
9 years, 2 months ago (2011-09-30 01:39:35 UTC) #6
msw
On 2011/09/30 01:39:35, xji wrote: > Looks like the 2 ways to completely get rid ...
9 years, 2 months ago (2011-09-30 19:09:16 UTC) #7
xji
http://codereview.chromium.org/8044004/diff/6001/ui/gfx/render_text.cc File ui/gfx/render_text.cc (right): http://codereview.chromium.org/8044004/diff/6001/ui/gfx/render_text.cc#newcode421 ui/gfx/render_text.cc:421: return SelectionModel(selection_start, On 2011/09/29 02:20:21, msw wrote: > You ...
9 years, 2 months ago (2011-10-03 23:18:57 UTC) #8
msw
Mostly nits, I like this approach much better. http://codereview.chromium.org/8044004/diff/15001/chrome/browser/ui/views/omnibox/omnibox_view_views.cc File chrome/browser/ui/views/omnibox/omnibox_view_views.cc (right): http://codereview.chromium.org/8044004/diff/15001/chrome/browser/ui/views/omnibox/omnibox_view_views.cc#newcode407 chrome/browser/ui/views/omnibox/omnibox_view_views.cc:407: if ...
9 years, 2 months ago (2011-10-04 07:25:41 UTC) #9
xji
I am not able to remove SelectionModel ctor in TextfieldViewModel::MoveCursorTo(), I need either the ctor ...
9 years, 2 months ago (2011-10-05 01:23:42 UTC) #10
xji
On 2011/10/05 01:23:42, xji wrote: > I am not able to remove SelectionModel ctor in ...
9 years, 2 months ago (2011-10-05 01:38:05 UTC) #11
xji
On 2011/10/05 01:23:42, xji wrote: > > Also, I added test for NativeTextfieldViews::SelectRect() which reveals ...
9 years, 2 months ago (2011-10-05 23:38:37 UTC) #12
msw
http://codereview.chromium.org/8044004/diff/37003/views/controls/textfield/native_textfield_views.cc File views/controls/textfield/native_textfield_views.cc (right): http://codereview.chromium.org/8044004/diff/37003/views/controls/textfield/native_textfield_views.cc#newcode279 views/controls/textfield/native_textfield_views.cc:279: if (start_pos.selection_start() == end_pos.selection_end()) Is it always safe to ...
9 years, 2 months ago (2011-10-07 20:54:20 UTC) #13
xji
http://codereview.chromium.org/8044004/diff/37003/views/controls/textfield/native_textfield_views.cc File views/controls/textfield/native_textfield_views.cc (right): http://codereview.chromium.org/8044004/diff/37003/views/controls/textfield/native_textfield_views.cc#newcode279 views/controls/textfield/native_textfield_views.cc:279: if (start_pos.selection_start() == end_pos.selection_end()) On 2011/10/07 20:54:20, msw wrote: ...
9 years, 2 months ago (2011-10-07 21:42:04 UTC) #14
msw
Each place I asked about the use of SelectRange, I was wondering if you change ...
9 years, 2 months ago (2011-10-07 23:59:11 UTC) #15
xji
On 2011/10/07 23:59:11, msw wrote: > Each place I asked about the use of SelectRange, ...
9 years, 2 months ago (2011-10-08 00:15:34 UTC) #16
msw
On 2011/10/08 00:15:34, xji wrote: > On 2011/10/07 23:59:11, msw wrote: > > Each place ...
9 years, 2 months ago (2011-10-08 01:15:06 UTC) #17
oshima
http://codereview.chromium.org/8044004/diff/37003/views/controls/textfield/textfield_views_model.cc File views/controls/textfield/textfield_views_model.cc (right): http://codereview.chromium.org/8044004/diff/37003/views/controls/textfield/textfield_views_model.cc#newcode676 views/controls/textfield/textfield_views_model.cc:676: InsertTextInternal(text, mergeable); On 2011/10/07 21:42:04, xji wrote: > On ...
9 years, 2 months ago (2011-10-08 01:40:47 UTC) #18
xji
On 2011/10/08 01:15:06, msw wrote: > On 2011/10/08 00:15:34, xji wrote: > > On 2011/10/07 ...
9 years, 2 months ago (2011-10-10 17:42:44 UTC) #19
xji
On 2011/10/08 01:40:47, oshima wrote: > http://codereview.chromium.org/8044004/diff/37003/views/controls/textfield/textfield_views_model.cc > File views/controls/textfield/textfield_views_model.cc (right): > > http://codereview.chromium.org/8044004/diff/37003/views/controls/textfield/textfield_views_model.cc#newcode676 > ...
9 years, 2 months ago (2011-10-10 17:45:39 UTC) #20
oshima
9 years, 2 months ago (2011-10-10 18:37:35 UTC) #21
On 2011/10/10 17:45:39, xji wrote:
> On 2011/10/08 01:40:47, oshima wrote:
> >
>
http://codereview.chromium.org/8044004/diff/37003/views/controls/textfield/te...
> > File views/controls/textfield/textfield_views_model.cc (right):
> > 
> >
>
http://codereview.chromium.org/8044004/diff/37003/views/controls/textfield/te...
> > views/controls/textfield/textfield_views_model.cc:676:
> InsertTextInternal(text,
> > mergeable);
> > On 2011/10/07 21:42:04, xji wrote:
> > > On 2011/10/07 20:54:20, msw wrote:
> > > > Are we doing the right thing here by setting the selection model before
> the
> > > text
> > > > is replaced? Could that set invalid non-grapheme-boundary positions? You
> can
> > > ask
> > > > Oshima if needed; he wrote the editing model.
> > > 
> > > Before the text is replaced and when there is no selection, we need to set
> the
> > > selection range as the range of next character (as in replace mode, which
by
> > > default is replacing next character with |text|).
> > > Since we are using 'next=IndexOfNextGrapheme', we wont set it on
> > > non-grapheme-boundary. There is test to test ReplaceChar() and
ReplaceText()
> > in
> > > TextfieldViewModelTest.
> > 
> > Setting selection is necessary for "NO INSERT" mode editing.
> > When text is more than 1 char, we replace the same number (or max) of
> characters
> > that can be
> > replaced. 
> 
> hmm..? I am confused.
> If there is no existing selection, we always replace the next character (more
> accurately, next grapheme), which is only 1 character, with text even there
are
> more than 1 characters in the text. Is it?

I think there is no such use case to replace with text longer than 1 character
wihtout selection.
We can either refractor method to deal with specific case, or add DCHECK to make
sure
we only replacing 1 character (when there is no selection) with proper
documentation.

> 
> 
> >This definition just happened to be this way and could be different
> > but i don't think
> > there is such real use case, so i just left that way.
> > 
> > So, I think just selecting one character (current to next) should be
> sufficient.

Powered by Google App Engine
This is Rietveld 408576698