Commit 4536c5cc authored by Yoshifumi Inoue's avatar Yoshifumi Inoue Committed by Commit Bot

Utilize EmitsSmallXForTextSecurity TextIteratorBehavior in NextBoundary()

This patch changes |NextBoundary()| to utilize |EmitsSmallXForTextSecurity|
|TextIteratorBehavior| to handle -webkit-text-security CSS property in
|TextIterator| to reduce source code for improving code health.

This patch is similar to the patch[1].

http://crrev.com/c/760218: Utilize EmitsSmallXForTextSecurity
TextIteratorBehavior in PreviousBoundary()

Bug: 778507
Change-Id: Ia62bcec825be863ff15a9075eeb22f2a6a9ee981
Reviewed-on: https://chromium-review.googlesource.com/760063
Commit-Queue: Yoshifumi Inoue <yosin@chromium.org>
Reviewed-by: default avatarXiaocheng Hu <xiaochengh@chromium.org>
Cr-Commit-Position: refs/heads/master@{#515489}
parent e5466217
......@@ -447,10 +447,13 @@ static PositionTemplate<Strategy> NextBoundaryAlgorithm(
start.AnchorNode(), start.OffsetInContainerNode());
const PositionTemplate<Strategy> search_end =
PositionTemplate<Strategy>::LastPositionInNode(*boundary);
// Treat bullets used in the text security mode as regular characters when
// looking for boundaries
TextIteratorAlgorithm<Strategy> it(
search_start, search_end,
TextIteratorBehavior::Builder()
.SetEmitsCharactersBetweenAllVisiblePositions(true)
.SetEmitsSmallXForTextSecurity(true)
.Build());
const unsigned kInvalidOffset = static_cast<unsigned>(-1);
unsigned next = kInvalidOffset;
......@@ -460,8 +463,8 @@ static PositionTemplate<Strategy> NextBoundaryAlgorithm(
// Keep asking the iterator for chunks until the search function
// returns an end value not equal to the length of the string passed to
// it.
bool in_text_security_mode = it.IsInTextSecurityMode();
if (!in_text_security_mode) {
// TDOO(editing-dev): We should get rid of redundant scope.
{
int run_offset = 0;
do {
run_offset += it.CopyTextTo(&string, run_offset, string.Capacity());
......@@ -476,11 +479,6 @@ static PositionTemplate<Strategy> NextBoundaryAlgorithm(
} while (next == string.Size() && run_offset < it.length());
if (next != string.Size())
break;
} else {
// Treat bullets used in the text security mode as regular
// characters when looking for boundaries
string.PushCharacters('x', it.length());
next = string.Size();
}
it.Advance();
}
......
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