Commit a5bc45b5 authored by Yoshifumi Inoue's avatar Yoshifumi Inoue Committed by Commit Bot

Get rid of unused functions NGPhysicalLineBoxFragment::{First,Last}LogicalLeaf()

This patch gets rid of unused member functions |{First,Last}LogicalLeaf()| from
|NGPhysicalLineBoxFragment| for improving code health.

Note: This patch is follow up of the patch[1] which gets of usages of
|NGPhysicalLineBoxFragment::{First,Last}LogicalLeaf()|.

[1] http://crrev.com/c/1866101 Utilize NGInlineCursor in NGCaretPosition

Change-Id: I64df633e1d43161b623f1ca3d7e9e1772b78577a
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1875017
Commit-Queue: Yoshifumi Inoue <yosin@chromium.org>
Auto-Submit: Yoshifumi Inoue <yosin@chromium.org>
Reviewed-by: default avatarKoji Ishii <kojii@chromium.org>
Cr-Commit-Position: refs/heads/master@{#708540}
parent e8f14977
......@@ -464,7 +464,7 @@ void NGInlineCursor::MoveToFirstLogicalLeaf() {
// TODO(yosin): This isn't correct for mixed Bidi. Fix it. Besides, we
// should compute and store it during layout.
// TODO(yosin): We should check direction of each container instead of line
// box. See also |NGPhysicalLineBoxFragment::LastLogicalLeaf()|.
// box.
if (IsLtr(CurrentStyle().Direction())) {
while (TryToMoveToFirstChild())
continue;
......@@ -485,7 +485,7 @@ void NGInlineCursor::MoveToLastLogicalLeaf() {
// TODO(yosin): This isn't correct for mixed Bidi. Fix it. Besides, we
// should compute and store it during layout.
// TODO(yosin): We should check direction of each container instead of line
// box. See also |NGPhysicalLineBoxFragment::LastLogicalLeaf()|.
// box.
if (IsLtr(CurrentStyle().Direction())) {
while (TryToMoveToLastChild())
continue;
......
......@@ -130,48 +130,6 @@ PhysicalRect NGPhysicalLineBoxFragment::ScrollableOverflow(
return overflow;
}
const NGPhysicalFragment* NGPhysicalLineBoxFragment::FirstLogicalLeaf() const {
if (Children().empty())
return nullptr;
// TODO(xiaochengh): This isn't correct for mixed Bidi. Fix it. Besides, we
// should compute and store it during layout.
const TextDirection direction = Style().Direction();
const NGPhysicalFragment* runner = this;
while (const auto* runner_as_container =
DynamicTo<NGPhysicalContainerFragment>(runner)) {
if (runner->IsBlockFormattingContextRoot())
break;
if (runner_as_container->Children().empty())
break;
runner = direction == TextDirection::kLtr
? runner_as_container->Children().front().get()
: runner_as_container->Children().back().get();
}
DCHECK_NE(runner, this);
return runner;
}
const NGPhysicalFragment* NGPhysicalLineBoxFragment::LastLogicalLeaf() const {
if (Children().empty())
return nullptr;
// TODO(xiaochengh): This isn't correct for mixed Bidi. Fix it. Besides, we
// should compute and store it during layout.
const TextDirection direction = Style().Direction();
const NGPhysicalFragment* runner = this;
while (const auto* runner_as_container =
DynamicTo<NGPhysicalContainerFragment>(runner)) {
if (runner->IsBlockFormattingContextRoot())
break;
if (runner_as_container->Children().empty())
break;
runner = direction == TextDirection::kLtr
? runner_as_container->Children().back().get()
: runner_as_container->Children().front().get();
}
DCHECK_NE(runner, this);
return runner;
}
bool NGPhysicalLineBoxFragment::HasSoftWrapToNextLine() const {
const auto& break_token = To<NGInlineBreakToken>(*BreakToken());
return !break_token.IsFinished() && !break_token.IsForcedBreak();
......
......@@ -64,11 +64,6 @@ class CORE_EXPORT NGPhysicalLineBoxFragment final
const ComputedStyle* container_style,
PhysicalSize container_physical_size) const;
// Returns the first/last leaf fragment in the line in logical order. Returns
// nullptr if the line box is empty.
const NGPhysicalFragment* FirstLogicalLeaf() const;
const NGPhysicalFragment* LastLogicalLeaf() const;
const LayoutObject* ClosestLeafChildForPoint(const PhysicalOffset&,
bool only_editable_leaves) const;
......
......@@ -92,53 +92,4 @@ TEST_F(NGPhysicalLineBoxFragmentTest, HasPropagatedDescendantsOOF) {
EXPECT_TRUE(lines[1]->HasPropagatedDescendants());
}
TEST_F(NGPhysicalLineBoxFragmentTest, FirstLastLogicalLeafInSimpleText) {
SetBodyInnerHTML(
"<div id=root>"
"<span>foo</span>"
"<span>bar</span>"
"</div>");
EXPECT_TEXT_FRAGMENT("foo", GetLineBox()->FirstLogicalLeaf());
EXPECT_TEXT_FRAGMENT("bar", GetLineBox()->LastLogicalLeaf());
}
TEST_F(NGPhysicalLineBoxFragmentTest, FirstLastLogicalLeafInRtlText) {
SetBodyInnerHTML(
"<bdo id=root dir=rtl style='display: block'>"
"<span>foo</span>"
"<span>bar</span>"
"</bdo>");
EXPECT_TEXT_FRAGMENT("foo", GetLineBox()->FirstLogicalLeaf());
EXPECT_TEXT_FRAGMENT("bar", GetLineBox()->LastLogicalLeaf());
}
TEST_F(NGPhysicalLineBoxFragmentTest,
FirstLastLogicalLeafInTextAsDeepDescendants) {
SetBodyInnerHTML(
"<style>span {border: 1px solid black}</style>"
"<div id=root>"
"<span><span>f</span>oo</span>"
"<span>ba<span>r</span></span>"
"</div>");
EXPECT_TEXT_FRAGMENT("f", GetLineBox()->FirstLogicalLeaf());
EXPECT_TEXT_FRAGMENT("r", GetLineBox()->LastLogicalLeaf());
}
TEST_F(NGPhysicalLineBoxFragmentTest, FirstLastLogicalLeafWithInlineBlock) {
SetBodyInnerHTML(
"<div id=root>"
"<span id=foo style='display: inline-block'>foo</span>"
"bar"
"<span id=baz style='display: inline-block'>baz</span>"
"</div>");
EXPECT_BOX_FRAGMENT("foo", GetLineBox()->FirstLogicalLeaf());
EXPECT_BOX_FRAGMENT("baz", GetLineBox()->LastLogicalLeaf());
}
TEST_F(NGPhysicalLineBoxFragmentTest, FirstLastLogicalLeafWithImages) {
SetBodyInnerHTML("<div id=root><img id=img1>foo<img id=img2></div>");
EXPECT_BOX_FRAGMENT("img1", GetLineBox()->FirstLogicalLeaf());
EXPECT_BOX_FRAGMENT("img2", GetLineBox()->LastLogicalLeaf());
}
} // namespace blink
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