Commit 965bbf35 authored by Xiaocheng Hu's avatar Xiaocheng Hu Committed by Commit Bot

Further reorganize code flow in ComputeInlineBoxPosition

This patch moves the atomic inline handling code before the block flow
handling code, so that there is no longer fall through from block flow
to atomic inline.

Bug: 771398
Change-Id: Idb4013e5616a2e81a13f4c6829c3afb2b86faa68
Reviewed-on: https://chromium-review.googlesource.com/775550
Commit-Queue: Yoshifumi Inoue <yosin@chromium.org>
Reviewed-by: default avatarYoshifumi Inoue <yosin@chromium.org>
Cr-Commit-Position: refs/heads/master@{#517766}
parent 69ebaf4f
...@@ -283,50 +283,47 @@ InlineBoxPosition ComputeInlineBoxPositionTemplate( ...@@ -283,50 +283,47 @@ InlineBoxPosition ComputeInlineBoxPositionTemplate(
affinity, primary_direction); affinity, primary_direction);
} }
if (layout_object->IsLayoutBlockFlow()) { if (layout_object->IsAtomicInlineLevel()) {
if (CanHaveChildrenForEditing(anchor_node) && // TODO(xiaochengh): Wrap the following into a function.
HasRenderedNonAnonymousDescendantsWithHeight(layout_object)) { if (!layout_object->IsBox())
// Try a visually equivalent position with possibly opposite return InlineBoxPosition();
// editability. This helps in case |this| is in an editable block InlineBox* const inline_box =
// but surrounded by non-editable positions. It acts to negate the ToLayoutBox(layout_object)->InlineBoxWrapper();
// logic at the beginning of if (!inline_box)
// |LayoutObject::createPositionWithAffinity()|. return InlineBoxPosition();
const PositionTemplate<Strategy>& downstream_equivalent = if ((caret_offset > inline_box->CaretMinOffset() &&
DownstreamIgnoringEditingBoundaries(position); caret_offset < inline_box->CaretMaxOffset()))
if (downstream_equivalent != position) { return InlineBoxPosition(inline_box, caret_offset);
return ComputeInlineBoxPosition( return AdjustInlineBoxPositionForTextDirection(
downstream_equivalent, TextAffinity::kUpstream, primary_direction); inline_box, caret_offset, layout_object->Style()->GetUnicodeBidi(),
} primary_direction);
const PositionTemplate<Strategy>& upstream_equivalent =
UpstreamIgnoringEditingBoundaries(position);
if (upstream_equivalent == position ||
DownstreamIgnoringEditingBoundaries(upstream_equivalent) == position)
return InlineBoxPosition();
return ComputeInlineBoxPosition(
upstream_equivalent, TextAffinity::kUpstream, primary_direction);
}
// We can't return null here because atomic inlines can also be block flows,
// e.g., LayoutTextControl.
// TODO(xiaochengh): Move atomic inline handling before block flow handling
// so that we can directly return null here.
} }
if (!layout_object->IsAtomicInlineLevel()) if (!layout_object->IsLayoutBlockFlow())
return InlineBoxPosition(); return InlineBoxPosition();
// TODO(xiaochengh): Wrap the following into a function.
if (!layout_object->IsBox()) if (!CanHaveChildrenForEditing(anchor_node) ||
!HasRenderedNonAnonymousDescendantsWithHeight(layout_object))
return InlineBoxPosition(); return InlineBoxPosition();
InlineBox* const inline_box = ToLayoutBox(layout_object)->InlineBoxWrapper(); // Try a visually equivalent position with possibly opposite
if (!inline_box) // 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(); return InlineBoxPosition();
if ((caret_offset > inline_box->CaretMinOffset() &&
caret_offset < inline_box->CaretMaxOffset())) return ComputeInlineBoxPosition(upstream_equivalent, TextAffinity::kUpstream,
return InlineBoxPosition(inline_box, caret_offset); primary_direction);
return AdjustInlineBoxPositionForTextDirection(
inline_box, caret_offset, layout_object->Style()->GetUnicodeBidi(),
primary_direction);
} }
template <typename Strategy> template <typename Strategy>
......
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