| 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..5b77ae5f7b1e8d04c6ebaab66a6f535b9583ab43 100644
|
| --- a/third_party/WebKit/Source/core/editing/VisibleUnits.cpp
|
| +++ b/third_party/WebKit/Source/core/editing/VisibleUnits.cpp
|
| @@ -791,46 +791,44 @@ static InlineBoxPosition ComputeInlineBoxPositionTemplate(
|
|
|
| DCHECK(layout_object) << position;
|
|
|
| - if (!layout_object->IsText()) {
|
| - if (CanHaveChildrenForEditing(anchor_node) &&
|
| - layout_object->IsLayoutBlockFlow() &&
|
| - HasRenderedNonAnonymousDescendantsWithHeight(layout_object)) {
|
| - // Try a visually equivalent position with possibly opposite
|
| - // editability. This helps in case |this| is in an editable block
|
| - // but surrounded by non-editable positions. It acts to negate the
|
| - // logic at the beginning of
|
| - // |LayoutObject::createPositionWithAffinity()|.
|
| - const PositionTemplate<Strategy>& downstream_equivalent =
|
| - DownstreamIgnoringEditingBoundaries(position);
|
| - if (downstream_equivalent != position) {
|
| - return ComputeInlineBoxPosition(
|
| - downstream_equivalent, TextAffinity::kUpstream, primary_direction);
|
| - }
|
| - const PositionTemplate<Strategy>& upstream_equivalent =
|
| - UpstreamIgnoringEditingBoundaries(position);
|
| - if (upstream_equivalent == position ||
|
| - DownstreamIgnoringEditingBoundaries(upstream_equivalent) == position)
|
| - return InlineBoxPosition();
|
| -
|
| + if (layout_object->IsText()) {
|
| + return ComputeInlineBoxPositionForTextNode(layout_object, caret_offset,
|
| + affinity, primary_direction);
|
| + }
|
| + if (CanHaveChildrenForEditing(anchor_node) &&
|
| + layout_object->IsLayoutBlockFlow() &&
|
| + HasRenderedNonAnonymousDescendantsWithHeight(layout_object)) {
|
| + // Try a visually equivalent position with possibly opposite
|
| + // editability. This helps in case |this| is in an editable block
|
| + // but surrounded by non-editable positions. It acts to negate the
|
| + // logic at the beginning of
|
| + // |LayoutObject::createPositionWithAffinity()|.
|
| + const PositionTemplate<Strategy>& downstream_equivalent =
|
| + DownstreamIgnoringEditingBoundaries(position);
|
| + if (downstream_equivalent != position) {
|
| return ComputeInlineBoxPosition(
|
| - upstream_equivalent, TextAffinity::kUpstream, primary_direction);
|
| + downstream_equivalent, TextAffinity::kUpstream, primary_direction);
|
| }
|
| - if (!layout_object->IsBox())
|
| - return InlineBoxPosition();
|
| - InlineBox* const inline_box =
|
| - ToLayoutBox(layout_object)->InlineBoxWrapper();
|
| - if (!inline_box)
|
| + const PositionTemplate<Strategy>& upstream_equivalent =
|
| + UpstreamIgnoringEditingBoundaries(position);
|
| + if (upstream_equivalent == position ||
|
| + DownstreamIgnoringEditingBoundaries(upstream_equivalent) == position)
|
| return InlineBoxPosition();
|
| - if ((caret_offset > inline_box->CaretMinOffset() &&
|
| - caret_offset < inline_box->CaretMaxOffset()))
|
| - return InlineBoxPosition(inline_box, caret_offset);
|
| - return AdjustInlineBoxPositionForTextDirection(
|
| - inline_box, caret_offset, layout_object->Style()->GetUnicodeBidi(),
|
| - primary_direction);
|
| - }
|
|
|
| - return ComputeInlineBoxPositionForTextNode(layout_object, caret_offset,
|
| - affinity, primary_direction);
|
| + return ComputeInlineBoxPosition(upstream_equivalent,
|
| + TextAffinity::kUpstream, primary_direction);
|
| + }
|
| + if (!layout_object->IsBox())
|
| + return InlineBoxPosition();
|
| + InlineBox* const inline_box = ToLayoutBox(layout_object)->InlineBoxWrapper();
|
| + if (!inline_box)
|
| + return InlineBoxPosition();
|
| + if ((caret_offset > inline_box->CaretMinOffset() &&
|
| + caret_offset < inline_box->CaretMaxOffset()))
|
| + return InlineBoxPosition(inline_box, caret_offset);
|
| + return AdjustInlineBoxPositionForTextDirection(
|
| + inline_box, caret_offset, layout_object->Style()->GetUnicodeBidi(),
|
| + primary_direction);
|
| }
|
|
|
| // TODO(yosin): We should make |ComputeInlineBoxPositionForTextNode()| to take
|
|
|