Commit 4e3f9a32 authored by Xiaocheng Hu's avatar Xiaocheng Hu Committed by Commit Bot

Break calls of ComputeInlineBoxPosition in VisibleUnits.cpp

This patch breaks the two calls of ComputeInlineBoxPosition() in
VisibleUnits.cpp into ComputeInlineAdjustedPosition() +
ComputeInlineBoxPositionForInlineAdjustedPosition().

This is a preparation patch for plugging in NG-alternative
implementation between the two functions.

Bug: 771398
Change-Id: I662067dbfc26fb5c7443d712928aef59a6b0e29b
Reviewed-on: https://chromium-review.googlesource.com/812144Reviewed-by: default avatarYoshifumi Inoue <yosin@chromium.org>
Commit-Queue: Xiaocheng Hu <xiaochengh@chromium.org>
Cr-Commit-Position: refs/heads/master@{#522719}
parent b9354abb
...@@ -695,14 +695,31 @@ LocalCaretRect LocalCaretRectOfPositionTemplate( ...@@ -695,14 +695,31 @@ LocalCaretRect LocalCaretRectOfPositionTemplate(
if (!layout_object) if (!layout_object)
return LocalCaretRect(); return LocalCaretRect();
const InlineBoxPosition& box_position = ComputeInlineBoxPosition(position); const PositionWithAffinityTemplate<Strategy>& adjusted =
ComputeInlineAdjustedPosition(position);
if (box_position.inline_box) {
return ComputeLocalCaretRect( if (adjusted.IsNotNull()) {
LineLayoutAPIShim::LayoutObjectFrom( // TODO(xiaochengh): Plug in NG implementation here.
box_position.inline_box->GetLineLayoutItem()),
box_position); // TODO(editing-dev): This DCHECK is for ensuring the correctness of
// breaking |ComputeInlineBoxPosition| into |ComputeInlineAdjustedPosition|
// and |ComputeInlineBoxPositionForInlineAdjustedPosition|. If there is any
// DCHECK hit, we should pass primary direction to the latter function.
// TODO(crbug.com/793098): Fix it so that we don't need to bother about
// primary direction.
DCHECK_EQ(PrimaryDirectionOf(*position.AnchorNode()),
PrimaryDirectionOf(*adjusted.AnchorNode()));
const InlineBoxPosition& box_position =
ComputeInlineBoxPositionForInlineAdjustedPosition(adjusted);
if (box_position.inline_box) {
return ComputeLocalCaretRect(
LineLayoutAPIShim::LayoutObjectFrom(
box_position.inline_box->GetLineLayoutItem()),
box_position);
}
} }
// DeleteSelectionCommandTest.deleteListFromTable goes here. // DeleteSelectionCommandTest.deleteListFromTable goes here.
return LocalCaretRect( return LocalCaretRect(
layout_object, layout_object,
...@@ -721,7 +738,23 @@ LocalCaretRect LocalSelectionRectOfPositionTemplate( ...@@ -721,7 +738,23 @@ LocalCaretRect LocalSelectionRectOfPositionTemplate(
if (!node->GetLayoutObject()) if (!node->GetLayoutObject())
return LocalCaretRect(); return LocalCaretRect();
const InlineBoxPosition& box_position = ComputeInlineBoxPosition(position); const PositionWithAffinityTemplate<Strategy>& adjusted =
ComputeInlineAdjustedPosition(position);
if (adjusted.IsNull())
return LocalCaretRect();
// TODO(xiaochengh): Plug in NG implementation here.
// TODO(editing-dev): This DCHECK is for ensuring the correctness of
// breaking |ComputeInlineBoxPosition| into |ComputeInlineAdjustedPosition|
// and |ComputeInlineBoxPositionForInlineAdjustedPosition|. If there is any
// DCHECK hit, we should pass primary direction to the latter function.
// TODO(crbug.com/793098): Fix it so that we don't need to bother about
// primary direction.
DCHECK_EQ(PrimaryDirectionOf(*position.AnchorNode()),
PrimaryDirectionOf(*adjusted.AnchorNode()));
const InlineBoxPosition& box_position =
ComputeInlineBoxPositionForInlineAdjustedPosition(adjusted);
if (!box_position.inline_box) if (!box_position.inline_box)
return LocalCaretRect(); return LocalCaretRect();
......
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