Commit 53c5cda5 authored by Xiaocheng Hu's avatar Xiaocheng Hu Committed by Commit Bot

Introduce ComputeInlineBoxPositionForAtomicInline

This patch wraps code in ComputeInlineBoxPosition into a new
function, so that the code flow becomes clearer.

Bug: 771398
Change-Id: I6b702f736fe7e21b454aa207180aebadeba63699
Reviewed-on: https://chromium-review.googlesource.com/777702Reviewed-by: default avatarYoichi Osato <yoichio@chromium.org>
Reviewed-by: default avatarYoshifumi Inoue <yosin@chromium.org>
Commit-Queue: Xiaocheng Hu <xiaochengh@chromium.org>
Cr-Commit-Position: refs/heads/master@{#517895}
parent b2ce04b8
......@@ -264,6 +264,23 @@ InlineBoxPosition ComputeInlineBoxPositionForTextNode(
primary_direction);
}
InlineBoxPosition ComputeInlineBoxPositionForAtomicInline(
const LayoutObject* layout_object,
int caret_offset,
TextDirection 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);
}
template <typename Strategy>
InlineBoxPosition ComputeInlineBoxPositionTemplate(
const PositionTemplate<Strategy>& position,
......@@ -284,18 +301,7 @@ InlineBoxPosition ComputeInlineBoxPositionTemplate(
}
if (layout_object->IsAtomicInlineLevel()) {
// TODO(xiaochengh): Wrap the following into a function.
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(),
return ComputeInlineBoxPositionForAtomicInline(layout_object, caret_offset,
primary_direction);
}
......
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