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,7 +478,9 @@ void VisibleSelectionTemplate<Strategy>::Validate(TextGranularity granularity) { ...@@ -478,7 +478,9 @@ void VisibleSelectionTemplate<Strategy>::Validate(TextGranularity granularity) {
AdjustSelectionToAvoidCrossingEditingBoundaries(); AdjustSelectionToAvoidCrossingEditingBoundaries();
UpdateSelectionType(); UpdateSelectionType();
if (GetSelectionType() == kRangeSelection) { if (GetSelectionType() != kRangeSelection)
return;
// "Constrain" the selection to be the smallest equivalent range of // "Constrain" the selection to be the smallest equivalent range of
// nodes. This is a somewhat arbitrary choice, but experience shows that // nodes. This is a somewhat arbitrary choice, but experience shows that
// it is useful to make to make the selection "canonical" (if only for // it is useful to make to make the selection "canonical" (if only for
...@@ -490,7 +492,6 @@ void VisibleSelectionTemplate<Strategy>::Validate(TextGranularity granularity) { ...@@ -490,7 +492,6 @@ void VisibleSelectionTemplate<Strategy>::Validate(TextGranularity granularity) {
// |deepEquivalent()|s above)? // |deepEquivalent()|s above)?
start_ = MostForwardCaretPosition(start_); start_ = MostForwardCaretPosition(start_);
end_ = MostBackwardCaretPosition(end_); 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