Commit 708062c2 authored by Xiaocheng Hu's avatar Xiaocheng Hu Committed by Commit Bot

Use general variable names and comments in SelectionModifierCharacter

We previously deduplicated left and right traversal algorithm in
SelectionModifierCharacter, but haven't changed the variable names and
comment yet, which is finished by this patch.

Change-Id: Ie4a801b8b203433c189c70d8cb3824bd06931037
Reviewed-on: https://chromium-review.googlesource.com/1026835Reviewed-by: default avatarYoshifumi Inoue <yosin@chromium.org>
Commit-Queue: Xiaocheng Hu <xiaochengh@chromium.org>
Cr-Commit-Position: refs/heads/master@{#553450}
parent 956820a1
...@@ -243,9 +243,6 @@ bool IsAfterAtomicInlineOrLineBreak(const InlineBox& box, int offset) { ...@@ -243,9 +243,6 @@ bool IsAfterAtomicInlineOrLineBreak(const InlineBox& box, int offset) {
return box.GetLineLayoutItem().IsAtomicInlineLevel(); return box.GetLineLayoutItem().IsAtomicInlineLevel();
} }
// TODO(yosin): We should rename local variables and comments in
// |TraverseInternalAlgorithm()| to generic name based on |Traversal| instead of
// assuming right-to-left traversal.
template <typename Strategy, typename Traversal> template <typename Strategy, typename Traversal>
static PositionTemplate<Strategy> TraverseInternalAlgorithm( static PositionTemplate<Strategy> TraverseInternalAlgorithm(
const VisiblePositionTemplate<Strategy>& visible_position) { const VisiblePositionTemplate<Strategy>& visible_position) {
...@@ -300,39 +297,40 @@ static PositionTemplate<Strategy> TraverseInternalAlgorithm( ...@@ -300,39 +297,40 @@ static PositionTemplate<Strategy> TraverseInternalAlgorithm(
break; break;
if (Traversal::IsOvershot(offset, *box)) { if (Traversal::IsOvershot(offset, *box)) {
// Overshot to the left. // Overshot forwardly.
InlineBox* const prev_box = InlineBox* const forward_box =
Traversal::ForwardLeafChildIgnoringLineBreakOf(*box); Traversal::ForwardLeafChildIgnoringLineBreakOf(*box);
if (!prev_box) { if (!forward_box) {
const PositionTemplate<Strategy>& position_on_left = const PositionTemplate<Strategy>& forward_position =
Traversal::ForwardVisuallyDistinctCandidateOf( Traversal::ForwardVisuallyDistinctCandidateOf(
primary_direction, visible_position.DeepEquivalent()); primary_direction, visible_position.DeepEquivalent());
if (position_on_left.IsNull()) if (forward_position.IsNull())
return PositionTemplate<Strategy>(); return PositionTemplate<Strategy>();
const InlineBox* box_on_left = const InlineBox* forward_position_box =
ComputeInlineBoxPosition(PositionWithAffinityTemplate<Strategy>( ComputeInlineBoxPosition(PositionWithAffinityTemplate<Strategy>(
position_on_left, affinity)) forward_position, affinity))
.inline_box; .inline_box;
if (box_on_left && box_on_left->Root() == box->Root()) if (forward_position_box &&
forward_position_box->Root() == box->Root())
return PositionTemplate<Strategy>(); return PositionTemplate<Strategy>();
return position_on_left; return forward_position;
} }
// Reposition at the other logical position corresponding to our // Reposition at the other logical position corresponding to our
// edge's visual position and go for another round. // edge's visual position and go for another round.
box = prev_box; box = forward_box;
offset = Traversal::CaretEndOffsetOf(*prev_box); offset = Traversal::CaretEndOffsetOf(*forward_box);
continue; continue;
} }
DCHECK_EQ(offset, Traversal::CaretStartOffsetOf(*box)); DCHECK_EQ(offset, Traversal::CaretStartOffsetOf(*box));
unsigned char level = box->BidiLevel(); unsigned char level = box->BidiLevel();
InlineBox* prev_box = Traversal::ForwardLeafChildOf(*box); InlineBox* forward_box = Traversal::ForwardLeafChildOf(*box);
if (box->Direction() == primary_direction) { if (box->Direction() == primary_direction) {
if (!prev_box) { if (!forward_box) {
InlineBox* logical_start = nullptr; InlineBox* logical_start = nullptr;
if (Traversal::LogicalStartBoxOf(primary_direction, *box, if (Traversal::LogicalStartBoxOf(primary_direction, *box,
logical_start)) { logical_start)) {
...@@ -341,31 +339,32 @@ static PositionTemplate<Strategy> TraverseInternalAlgorithm( ...@@ -341,31 +339,32 @@ static PositionTemplate<Strategy> TraverseInternalAlgorithm(
} }
break; break;
} }
if (prev_box->BidiLevel() >= level) if (forward_box->BidiLevel() >= level)
break; break;
level = prev_box->BidiLevel(); level = forward_box->BidiLevel();
InlineBox* const next_box = Traversal::FindBackwardBidiRun(*box, level); InlineBox* const backward_box =
if (next_box && next_box->BidiLevel() == level) Traversal::FindBackwardBidiRun(*box, level);
if (backward_box && backward_box->BidiLevel() == level)
break; break;
box = prev_box; box = forward_box;
offset = Traversal::CaretEndOffsetOf(*box); offset = Traversal::CaretEndOffsetOf(*box);
if (box->Direction() == primary_direction) if (box->Direction() == primary_direction)
break; break;
continue; continue;
} }
while (prev_box && !prev_box->GetLineLayoutItem().GetNode()) while (forward_box && !forward_box->GetLineLayoutItem().GetNode())
prev_box = Traversal::ForwardLeafChildOf(*prev_box); forward_box = Traversal::ForwardLeafChildOf(*forward_box);
if (prev_box) { if (forward_box) {
box = prev_box; box = forward_box;
offset = Traversal::CaretEndOffsetOf(*box); offset = Traversal::CaretEndOffsetOf(*box);
if (box->BidiLevel() > level) { if (box->BidiLevel() > level) {
prev_box = Traversal::FindForwardBidiRun(*prev_box, level); forward_box = Traversal::FindForwardBidiRun(*forward_box, level);
if (!prev_box || prev_box->BidiLevel() < level) if (!forward_box || forward_box->BidiLevel() < level)
continue; continue;
} }
break; break;
......
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