Commit 775938b6 authored by Xiaocheng Hu's avatar Xiaocheng Hu Committed by Commit Bot

Change Range::expand() to VisiblePosition-free functions for word and sentence

This patch changes Range::expand() to call VP-free version of word and
sentence start/end functions, by hoisting the creation of VP from
the functions into itself. In this way we reduce the usage of functions
relying on VP.

Bug: 657237
Change-Id: I56ea3cb88972144887eba7701cfdc3628bdbf67b
Reviewed-on: https://chromium-review.googlesource.com/c/1338719
Commit-Queue: Xiaocheng Hu <xiaochengh@chromium.org>
Reviewed-by: default avatarKent Tamura <tkent@chromium.org>
Reviewed-by: default avatarYoichi Osato <yoichio@chromium.org>
Reviewed-by: default avatarYoshifumi Inoue <yosin@chromium.org>
Cr-Commit-Position: refs/heads/master@{#608855}
parent d1a83017
......@@ -1618,11 +1618,12 @@ void Range::expand(const String& unit, ExceptionState& exception_state) {
VisiblePosition start = CreateVisiblePosition(StartPosition());
VisiblePosition end = CreateVisiblePosition(EndPosition());
if (unit == "word") {
start = StartOfWord(start);
end = EndOfWord(end);
start = CreateVisiblePosition(StartOfWordPosition(start.DeepEquivalent()));
end = CreateVisiblePosition(EndOfWordPosition(end.DeepEquivalent()));
} else if (unit == "sentence") {
start = StartOfSentence(start);
end = EndOfSentence(end);
start =
CreateVisiblePosition(StartOfSentencePosition(start.DeepEquivalent()));
end = CreateVisiblePosition(EndOfSentence(end.DeepEquivalent()));
} else if (unit == "block") {
start = StartOfParagraph(start);
end = EndOfParagraph(end);
......
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