| 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 0fe37bfec988ce5ee355ab3af0f81238c6e28496..6eb6d29cea23161f0d14d6e838e7bc460d9500a7 100644
|
| --- a/third_party/WebKit/Source/core/editing/VisibleUnits.cpp
|
| +++ b/third_party/WebKit/Source/core/editing/VisibleUnits.cpp
|
| @@ -770,12 +770,49 @@ static bool IsCaretAtEdgeOfInlineTextBox(int caret_offset,
|
| return box.NextLeafChild() && box.NextLeafChild()->IsLineBreak();
|
| }
|
|
|
| -// TODO(yosin): We have a forward declaration here to reduce patch size. We'll
|
| -// replace this with an implementation once review finished.
|
| -static InlineBoxPosition ComputeInlineBoxPositionForTextNode(LayoutObject*,
|
| - int caret_offset,
|
| - TextAffinity,
|
| - TextDirection);
|
| +static InlineBoxPosition ComputeInlineBoxPositionForTextNode(
|
| + LayoutObject* layout_object,
|
| + int caret_offset,
|
| + TextAffinity affinity,
|
| + TextDirection primary_direction) {
|
| + InlineBox* inline_box = nullptr;
|
| + LayoutText* text_layout_object = ToLayoutText(layout_object);
|
| +
|
| + InlineTextBox* candidate = nullptr;
|
| +
|
| + 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 ||
|
| + (caret_offset == caret_max_offset && box->IsLineBreak()))
|
| + continue;
|
| +
|
| + if (caret_offset > caret_min_offset && caret_offset < caret_max_offset)
|
| + return InlineBoxPosition(box, caret_offset);
|
| +
|
| + if (IsCaretAtEdgeOfInlineTextBox(caret_offset, *box, affinity)) {
|
| + inline_box = box;
|
| + break;
|
| + }
|
| +
|
| + 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();
|
| + return AdjustInlineBoxPositionForTextDirection(
|
| + inline_box, caret_offset, layout_object->Style()->GetUnicodeBidi(),
|
| + primary_direction);
|
| +}
|
|
|
| template <typename Strategy>
|
| static InlineBoxPosition ComputeInlineBoxPositionTemplate(
|
| @@ -833,52 +870,6 @@ static InlineBoxPosition ComputeInlineBoxPositionTemplate(
|
| affinity, primary_direction);
|
| }
|
|
|
| -// TODO(yosin): We should make |ComputeInlineBoxPositionForTextNode()| to take
|
| -// |const LayoutText&|.
|
| -static InlineBoxPosition ComputeInlineBoxPositionForTextNode(
|
| - LayoutObject* layout_object,
|
| - int caret_offset,
|
| - TextAffinity affinity,
|
| - TextDirection primary_direction) {
|
| - InlineBox* inline_box = nullptr;
|
| - LayoutText* text_layout_object = ToLayoutText(layout_object);
|
| -
|
| - InlineTextBox* candidate = nullptr;
|
| -
|
| - 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 ||
|
| - (caret_offset == caret_max_offset && box->IsLineBreak()))
|
| - continue;
|
| -
|
| - if (caret_offset > caret_min_offset && caret_offset < caret_max_offset)
|
| - return InlineBoxPosition(box, caret_offset);
|
| -
|
| - if (IsCaretAtEdgeOfInlineTextBox(caret_offset, *box, affinity)) {
|
| - inline_box = box;
|
| - break;
|
| - }
|
| -
|
| - 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();
|
| - return AdjustInlineBoxPositionForTextDirection(
|
| - inline_box, caret_offset, layout_object->Style()->GetUnicodeBidi(),
|
| - primary_direction);
|
| -}
|
| -
|
| static InlineBoxPosition AdjustInlineBoxPositionForTextDirection(
|
| InlineBox* inline_box,
|
| int caret_offset,
|
|
|