| Index: third_party/WebKit/Source/core/editing/VisibleUnits.cpp
|
| diff --git a/third_party/WebKit/Source/core/editing/VisibleUnits.cpp b/third_party/WebKit/Source/core/editing/VisibleUnits.cpp
|
| index d4355c86858b648cfbc2d8743d4387c817b425bb..1cb2230373de5150956fa9bf386e7360ae30f8af 100644
|
| --- a/third_party/WebKit/Source/core/editing/VisibleUnits.cpp
|
| +++ b/third_party/WebKit/Source/core/editing/VisibleUnits.cpp
|
| @@ -839,41 +839,37 @@ static InlineBoxPosition ComputeInlineBoxPositionForTextNode(
|
| int caret_offset,
|
| TextAffinity affinity,
|
| TextDirection primary_direction) {
|
| - // TODO(yosin): We should move this code fragment to another function to
|
| - // remove the scope.
|
| InlineBox* inline_box = nullptr;
|
| - {
|
| - LayoutText* text_layout_object = ToLayoutText(layout_object);
|
| -
|
| - InlineTextBox* candidate = nullptr;
|
| + LayoutText* text_layout_object = ToLayoutText(layout_object);
|
|
|
| - for (InlineTextBox* box : InlineTextBoxesOf(*text_layout_object)) {
|
| - int caret_min_offset = box->CaretMinOffset();
|
| - int caret_max_offset = box->CaretMaxOffset();
|
| + InlineTextBox* candidate = nullptr;
|
|
|
| - if (caret_offset < caret_min_offset || caret_offset > caret_max_offset ||
|
| - (caret_offset == caret_max_offset && box->IsLineBreak()))
|
| - continue;
|
| + for (InlineTextBox* box : InlineTextBoxesOf(*text_layout_object)) {
|
| + int caret_min_offset = box->CaretMinOffset();
|
| + int caret_max_offset = box->CaretMaxOffset();
|
|
|
| - if (caret_offset > caret_min_offset && caret_offset < caret_max_offset)
|
| - return InlineBoxPosition(box, caret_offset);
|
| + if (caret_offset < caret_min_offset || caret_offset > caret_max_offset ||
|
| + (caret_offset == caret_max_offset && box->IsLineBreak()))
|
| + continue;
|
|
|
| - if (IsCaretAtEdgeOfInlineTextBox(caret_offset, *box, affinity)) {
|
| - inline_box = box;
|
| - break;
|
| - }
|
| + if (caret_offset > caret_min_offset && caret_offset < caret_max_offset)
|
| + return InlineBoxPosition(box, caret_offset);
|
|
|
| - candidate = box;
|
| - }
|
| - if (candidate && candidate == text_layout_object->LastTextBox() &&
|
| - affinity == TextAffinity::kDownstream) {
|
| - inline_box = SearchAheadForBetterMatch(text_layout_object);
|
| - if (inline_box)
|
| - caret_offset = inline_box->CaretMinOffset();
|
| + if (IsCaretAtEdgeOfInlineTextBox(caret_offset, *box, affinity)) {
|
| + inline_box = box;
|
| + break;
|
| }
|
| - if (!inline_box)
|
| - inline_box = candidate;
|
| +
|
| + candidate = box;
|
| + }
|
| + if (candidate && candidate == text_layout_object->LastTextBox() &&
|
| + affinity == TextAffinity::kDownstream) {
|
| + inline_box = SearchAheadForBetterMatch(text_layout_object);
|
| + if (inline_box)
|
| + caret_offset = inline_box->CaretMinOffset();
|
| }
|
| + if (!inline_box)
|
| + inline_box = candidate;
|
|
|
| if (!inline_box)
|
| return InlineBoxPosition();
|
|
|