|
|
Created:
5 years, 8 months ago by mfomitchev Modified:
5 years, 8 months ago CC:
blink-reviews Base URL:
https://chromium.googlesource.com/chromium/blink.git@master Target Ref:
refs/heads/master Project:
blink Visibility:
Public. |
DescriptionMaking VisibleSelection operator== take base and extent into account.
If the user long presses on a word to select, a selection is created with base and extent at the long press point (and start/end at the start/end of the word). If the user then starts dragging the handle, in the beginning of the drag the selection is updated to have base/extent at start/end positions. However unless == takes base and extent into account, the update doesn't take place, which causes problems down the line.
BUG=NONE
Committed: https://src.chromium.org/viewvc/blink?view=rev&revision=193950
Patch Set 1 #
Total comments: 3
Patch Set 2 : Removed unneeded check. #Patch Set 3 : Adding None check. #
Total comments: 1
Patch Set 4 : Need to check affinity() and isDirectional() even if selection is none. #Messages
Total messages: 19 (7 generated)
mfomitchev@chromium.org changed reviewers: + rbyers@chromium.org, yoichio@chromium.org, yosin@chromium.org
LGTM I feel this is natural for operator==(). If we really need to compare start/end, we should have specific function for it.
On 2015/04/16 03:34:08, Yosi_UTC9 wrote: > LGTM > > I feel this is natural for operator==(). If we really need to compare start/end, > we should have specific function for it. Background, in ideal situation, since start and end are calculated from base/extent, comparing one set is enough, either start/end or base/extent, but as description said this isn't true.
https://codereview.chromium.org/1089283002/diff/1/Source/core/editing/Visible... File Source/core/editing/VisibleSelection.h (right): https://codereview.chromium.org/1089283002/diff/1/Source/core/editing/Visible... Source/core/editing/VisibleSelection.h:185: return a.start() == b.start() && a.end() == b.end() && a.affinity() == b.affinity() && a.isBaseFirst() == b.isBaseFirst() Since we compare base/extent equality, we don't need to check equality of |isBaseFirst()|. https://codereview.chromium.org/1089283002/diff/1/Source/core/editing/Visible... Source/core/editing/VisibleSelection.h:185: return a.start() == b.start() && a.end() == b.end() && a.affinity() == b.affinity() && a.isBaseFirst() == b.isBaseFirst() if one of selections is null, we don't need to check start/end and base/extent. So, we could write: if (a.affinity() != b.affinity() || a.isDirectional() != b.isDirectional()) return false; if (a.isNull()) return b.isNull(); return a.start() == b.start() && a.end() == b.end() && a.base() == b.base() && a.extent() == b.extent();
rbyers: can you PTAL:? https://codereview.chromium.org/1089283002/diff/1/Source/core/editing/Visible... File Source/core/editing/VisibleSelection.h (right): https://codereview.chromium.org/1089283002/diff/1/Source/core/editing/Visible... Source/core/editing/VisibleSelection.h:185: return a.start() == b.start() && a.end() == b.end() && a.affinity() == b.affinity() && a.isBaseFirst() == b.isBaseFirst() On 2015/04/16 04:59:04, Yosi_UTC9 wrote: > if one of selections is null, we don't need to check start/end and base/extent. > So, we could write: > > if (a.affinity() != b.affinity() || a.isDirectional() != b.isDirectional()) > return false; > > if (a.isNull()) > return b.isNull(); > > return a.start() == b.start() && a.end() == b.end() && a.base() == b.base() && > a.extent() == b.extent(); > Added the None check and removed isBaseFirst() check. Other than that, I am not sure we need to explicitly short-circuit: if any of the == evaluate to false, it won't evaluate any other == anyway. And it seems that checking start/end positions first is pretty effective in eliminating unequal results right away. Even if this makes sense, I don't think it needs to be a part of this CL.
Rubber-stamp LGTM (Yosi is the expert).
The CQ bit was checked by mfomitchev@google.com
The patchset sent to the CQ was uploaded after l-g-t-m from yosin@chromium.org Link to the patchset: https://codereview.chromium.org/1089283002/#ps40001 (title: "Adding None check.")
CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/patch-status/1089283002/40001
mfomitchev@chromium.org changed reviewers: + sgurun@chromium.org - mfomitchev@google.com
The CQ bit was unchecked by commit-bot@chromium.org
Try jobs failed on following builders: mac_blink_rel on tryserver.blink (JOB_FAILED, http://build.chromium.org/p/tryserver.blink/builders/mac_blink_rel/builds/52167)
https://codereview.chromium.org/1089283002/diff/40001/Source/core/editing/Vis... File Source/core/editing/VisibleSelection.h (right): https://codereview.chromium.org/1089283002/diff/40001/Source/core/editing/Vis... Source/core/editing/VisibleSelection.h:186: return b.isNone(); We need to check affinity() and isDirectional() even if selection is none. This is the reason why editing/deleting/delete-cell-contents-win.html failed on Mac. The root cause is found in FrameSelection::setSelection() void FrameSelection::setSelection() { ... VisibleSelection s = validateSelection(newSelection); if (shouldAlwaysUseDirectionalSelection(m_frame)) s.setIsDirectional(true); /// Set isDirectional regardless selection type, e.g. including selection is empty ... if (m_selection == s) { // Check new selection is different from current selection ... return; } ... // Log selection change event in test_runner. m_frame->editor().respondToChangedSelection(oldSelection, options); ...
On 2015/04/17 04:15:59, Yosi_UTC9 wrote: > https://codereview.chromium.org/1089283002/diff/40001/Source/core/editing/Vis... > File Source/core/editing/VisibleSelection.h (right): > > https://codereview.chromium.org/1089283002/diff/40001/Source/core/editing/Vis... > Source/core/editing/VisibleSelection.h:186: return b.isNone(); > We need to check affinity() and isDirectional() even if selection is none. > This is the reason why editing/deleting/delete-cell-contents-win.html failed on > Mac. > > The root cause is found in FrameSelection::setSelection() > > void FrameSelection::setSelection() { > ... > VisibleSelection s = validateSelection(newSelection); > if (shouldAlwaysUseDirectionalSelection(m_frame)) > s.setIsDirectional(true); /// Set isDirectional regardless selection > type, e.g. including selection is empty > ... > if (m_selection == s) { // Check new selection is different from current > selection > ... > return; > } > ... > // Log selection change event in test_runner. > m_frame->editor().respondToChangedSelection(oldSelection, options); > ... Ah, I see. Updated, thanks!
The CQ bit was checked by mfomitchev@chromium.org
The patchset sent to the CQ was uploaded after l-g-t-m from yosin@chromium.org, rbyers@chromium.org Link to the patchset: https://codereview.chromium.org/1089283002/#ps60001 (title: "Need to check affinity() and isDirectional() even if selection is none.")
CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/patch-status/1089283002/60001
Message was sent while issue was closed.
Committed patchset #4 (id:60001) as https://src.chromium.org/viewvc/blink?view=rev&revision=193950 |