Commit 9d954c0b authored by Yoshifumi Inoue's avatar Yoshifumi Inoue Committed by Commit Bot

Refactor VisibleSelectionTemplate::Validate()

This patch changes VisibleSelectionTemplate::Validate() to use early-return
for improving readability.

Change-Id: If1395322fd0fea262af37c9840c0976439f78cef
Reviewed-on: https://chromium-review.googlesource.com/563220Reviewed-by: default avatarYoichi Osato <yoichio@chromium.org>
Commit-Queue: Yoshifumi Inoue <yosin@chromium.org>
Cr-Commit-Position: refs/heads/master@{#485187}
parent b9961fe3
...@@ -478,19 +478,20 @@ void VisibleSelectionTemplate<Strategy>::Validate(TextGranularity granularity) { ...@@ -478,19 +478,20 @@ void VisibleSelectionTemplate<Strategy>::Validate(TextGranularity granularity) {
AdjustSelectionToAvoidCrossingEditingBoundaries(); AdjustSelectionToAvoidCrossingEditingBoundaries();
UpdateSelectionType(); UpdateSelectionType();
if (GetSelectionType() == kRangeSelection) { if (GetSelectionType() != kRangeSelection)
// "Constrain" the selection to be the smallest equivalent range of return;
// nodes. This is a somewhat arbitrary choice, but experience shows that
// it is useful to make to make the selection "canonical" (if only for // "Constrain" the selection to be the smallest equivalent range of
// purposes of comparing selections). This is an ideal point of the code // nodes. This is a somewhat arbitrary choice, but experience shows that
// to do this operation, since all selection changes that result in a // it is useful to make to make the selection "canonical" (if only for
// RANGE come through here before anyone uses it. // purposes of comparing selections). This is an ideal point of the code
// TODO(yosin) Canonicalizing is good, but haven't we already done it // to do this operation, since all selection changes that result in a
// (when we set these two positions to |VisiblePosition| // RANGE come through here before anyone uses it.
// |deepEquivalent()|s above)? // TODO(yosin) Canonicalizing is good, but haven't we already done it
start_ = MostForwardCaretPosition(start_); // (when we set these two positions to |VisiblePosition|
end_ = MostBackwardCaretPosition(end_); // |deepEquivalent()|s above)?
} start_ = MostForwardCaretPosition(start_);
end_ = MostBackwardCaretPosition(end_);
} }
template <typename Strategy> template <typename Strategy>
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment