Commit bca48f5e authored by Yoshifumi Inoue's avatar Yoshifumi Inoue Committed by Commit Bot

Utilize EmitsSmallXForTextSecurity TextIteratorBehavior in PreviousBoundary()

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

This patch is similar to the patch[1].

[1] http://crrev.com/c/760063: Utilize EmitsSmallXForTextSecurity
TextIteratorBehavior in NextBoundary()

Bug: 778507
Change-Id: I4612c7916498ee2604062ac50eb79803f93172e9
Reviewed-on: https://chromium-review.googlesource.com/760218
Commit-Queue: Yoshifumi Inoue <yosin@chromium.org>
Reviewed-by: default avatarXiaocheng Hu <xiaochengh@chromium.org>
Cr-Commit-Position: refs/heads/master@{#515483}
parent 500f6da3
...@@ -360,15 +360,20 @@ static PositionTemplate<Strategy> PreviousBoundaryAlgorithm( ...@@ -360,15 +360,20 @@ static PositionTemplate<Strategy> PreviousBoundaryAlgorithm(
BackwardsTextBuffer string; BackwardsTextBuffer string;
string.PushRange(suffix_string.Data(), suffix_string.Size()); string.PushRange(suffix_string.Data(), suffix_string.Size());
// Treat bullets used in the text security mode as regular characters when
// looking for boundaries.
SimplifiedBackwardsTextIteratorAlgorithm<Strategy> it( SimplifiedBackwardsTextIteratorAlgorithm<Strategy> it(
EphemeralRangeTemplate<Strategy>(start, end)); EphemeralRangeTemplate<Strategy>(start, end),
TextIteratorBehavior::Builder()
.SetEmitsSmallXForTextSecurity(true)
.Build());
unsigned next = 0; unsigned next = 0;
bool need_more_context = false; bool need_more_context = false;
while (!it.AtEnd()) { while (!it.AtEnd()) {
bool in_text_security_mode = it.IsInTextSecurityMode();
// iterate to get chunks until the searchFunction returns a non-zero // iterate to get chunks until the searchFunction returns a non-zero
// value. // value.
if (!in_text_security_mode) { // TODO(editing-dev): We should get rid of redundant scope.
{
int run_offset = 0; int run_offset = 0;
do { do {
run_offset += it.CopyTextTo(&string, run_offset, string.Capacity()); run_offset += it.CopyTextTo(&string, run_offset, string.Capacity());
...@@ -378,11 +383,6 @@ static PositionTemplate<Strategy> PreviousBoundaryAlgorithm( ...@@ -378,11 +383,6 @@ static PositionTemplate<Strategy> PreviousBoundaryAlgorithm(
} while (!next && run_offset < it.length()); } while (!next && run_offset < it.length());
if (next) if (next)
break; break;
} else {
// Treat bullets used in the text security mode as regular
// characters when looking for boundaries
string.PushCharacters('x', it.length());
next = 0;
} }
it.Advance(); 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