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) {
AdjustSelectionToAvoidCrossingEditingBoundaries();
UpdateSelectionType();
if (GetSelectionType() == kRangeSelection) {
// "Constrain" the selection to be the smallest equivalent range of
// nodes. This is a somewhat arbitrary choice, but experience shows that
// it is useful to make to make the selection "canonical" (if only for
// purposes of comparing selections). This is an ideal point of the code
// to do this operation, since all selection changes that result in a
// RANGE come through here before anyone uses it.
// TODO(yosin) Canonicalizing is good, but haven't we already done it
// (when we set these two positions to |VisiblePosition|
// |deepEquivalent()|s above)?
start_ = MostForwardCaretPosition(start_);
end_ = MostBackwardCaretPosition(end_);
}
if (GetSelectionType() != kRangeSelection)
return;
// "Constrain" the selection to be the smallest equivalent range of
// nodes. This is a somewhat arbitrary choice, but experience shows that
// it is useful to make to make the selection "canonical" (if only for
// purposes of comparing selections). This is an ideal point of the code
// to do this operation, since all selection changes that result in a
// RANGE come through here before anyone uses it.
// TODO(yosin) Canonicalizing is good, but haven't we already done it
// (when we set these two positions to |VisiblePosition|
// |deepEquivalent()|s above)?
start_ = MostForwardCaretPosition(start_);
end_ = MostBackwardCaretPosition(end_);
}
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