Commit 923f4e28 authored by Xiaocheng Hu's avatar Xiaocheng Hu Committed by Commit Bot

Slight reorganization of ComputeInlineBoxPosition

This patch slightly reorganizes the above mentioned function to make the
logic clearer that, the function has three major branches dependig on
the type of |layout_object|: text, block flow with children, or atomic
inline.

Detail: Adding |IsAtomicInlineLevel()| check to the last part of the
function doesn't introduce any behavior change. This is because that
|LayoutBox::InlineBoxWrapper()| returns non-null result only when the
layout object is an atomic inline.

Bug: 771398
Change-Id: Id61830a9ad11de40c5ae7456e3e13b6a4094b1a9
Reviewed-on: https://chromium-review.googlesource.com/775659Reviewed-by: default avatarYoshifumi Inoue <yosin@chromium.org>
Commit-Queue: Xiaocheng Hu <xiaochengh@chromium.org>
Cr-Commit-Position: refs/heads/master@{#517410}
parent 3cd9e411
......@@ -282,29 +282,40 @@ InlineBoxPosition ComputeInlineBoxPositionTemplate(
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) {
if (layout_object->IsLayoutBlockFlow()) {
if (CanHaveChildrenForEditing(anchor_node) &&
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();
return ComputeInlineBoxPosition(
downstream_equivalent, TextAffinity::kUpstream, primary_direction);
upstream_equivalent, TextAffinity::kUpstream, 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())
return InlineBoxPosition();
if (!layout_object->IsBox())
return InlineBoxPosition();
InlineBox* const inline_box = ToLayoutBox(layout_object)->InlineBoxWrapper();
......
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