Commit 19c1d403 authored by Yoshifumi Inoue's avatar Yoshifumi Inoue Committed by Commit Bot

Get rid of unused function NGPhysicalLineBoxFragment::ClosestLeafChildForPoint()

This patch gets rid of unused function |ClosestLeafChildForPoint()| in
|NGPhysicalLineBoxFragment| for improving code health.

This patch is follow-up of the patch[1] which gets rid of clients of
|ClosestLeafChildForPoint()|.

[1] http://crrev.com/c/1875856 Introduce NGInlineCursor version of
ClosestLeafChildForPoint() for AbstractLineBox

Change-Id: Ia626b7e77ac415c6d2164072b50f3b34fcbe6b4f
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1877874
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@{#709825}
parent 0e412286
...@@ -24,18 +24,6 @@ static_assert(sizeof(NGPhysicalLineBoxFragment) == ...@@ -24,18 +24,6 @@ static_assert(sizeof(NGPhysicalLineBoxFragment) ==
sizeof(SameSizeAsNGPhysicalLineBoxFragment), sizeof(SameSizeAsNGPhysicalLineBoxFragment),
"NGPhysicalLineBoxFragment should stay small"); "NGPhysicalLineBoxFragment should stay small");
bool IsInlineLeaf(const NGPhysicalFragment& fragment) {
if (fragment.IsText())
return true;
return fragment.IsBox() && fragment.IsAtomicInline();
}
bool IsEditableFragment(const NGPhysicalFragment& fragment) {
if (!fragment.GetNode())
return false;
return HasEditableStyle(*fragment.GetNode());
}
} // namespace } // namespace
scoped_refptr<const NGPhysicalLineBoxFragment> scoped_refptr<const NGPhysicalLineBoxFragment>
...@@ -151,47 +139,4 @@ PhysicalOffset NGPhysicalLineBoxFragment::LineEndPoint() const { ...@@ -151,47 +139,4 @@ PhysicalOffset NGPhysicalLineBoxFragment::LineEndPoint() const {
BaseDirection(), Size(), pixel_size); BaseDirection(), Size(), pixel_size);
} }
const LayoutObject* NGPhysicalLineBoxFragment::ClosestLeafChildForPoint(
const PhysicalOffset& point,
bool only_editable_leaves) const {
const PhysicalSize unit_square(LayoutUnit(1), LayoutUnit(1));
const LogicalOffset logical_point = point.ConvertToLogical(
Style().GetWritingMode(), BaseDirection(), Size(), unit_square);
const LayoutUnit inline_offset = logical_point.inline_offset;
const NGPhysicalFragment* closest_leaf_child = nullptr;
LayoutUnit closest_leaf_distance;
for (const auto& descendant :
NGInlineFragmentTraversal::DescendantsOf(*this)) {
const NGPhysicalFragment& fragment = *descendant.fragment;
if (!fragment.GetLayoutObject())
continue;
if (!IsInlineLeaf(fragment) || fragment.IsListMarker())
continue;
if (only_editable_leaves && !IsEditableFragment(fragment))
continue;
const LogicalSize fragment_logical_size =
fragment.Size().ConvertToLogical(Style().GetWritingMode());
const LogicalOffset fragment_logical_offset =
descendant.offset_to_container_box.ConvertToLogical(
Style().GetWritingMode(), BaseDirection(), Size(), fragment.Size());
const LayoutUnit inline_min = fragment_logical_offset.inline_offset;
const LayoutUnit inline_max = fragment_logical_offset.inline_offset +
fragment_logical_size.inline_size;
if (inline_offset >= inline_min && inline_offset < inline_max)
return fragment.GetLayoutObject();
const LayoutUnit distance =
inline_offset < inline_min ? inline_min - inline_offset
: inline_offset - inline_max + LayoutUnit(1);
if (!closest_leaf_child || distance < closest_leaf_distance) {
closest_leaf_child = &fragment;
closest_leaf_distance = distance;
}
}
if (!closest_leaf_child)
return nullptr;
return closest_leaf_child->GetLayoutObject();
}
} // namespace blink } // namespace blink
...@@ -64,9 +64,6 @@ class CORE_EXPORT NGPhysicalLineBoxFragment final ...@@ -64,9 +64,6 @@ class CORE_EXPORT NGPhysicalLineBoxFragment final
const ComputedStyle* container_style, const ComputedStyle* container_style,
PhysicalSize container_physical_size) const; PhysicalSize container_physical_size) const;
const LayoutObject* ClosestLeafChildForPoint(const PhysicalOffset&,
bool only_editable_leaves) const;
// Returns a point at the visual start/end of the line. // Returns a point at the visual start/end of the line.
// Encapsulates the handling of text direction and writing mode. // Encapsulates the handling of text direction and writing mode.
PhysicalOffset LineStartPoint() const; PhysicalOffset LineStartPoint() const;
......
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