Commit 2070e480 authored by Koji Ishii's avatar Koji Ishii Committed by Commit Bot

[FragmentItem] Distinguish to include culled inlines or not

Before moving to |NGInlineCursor|:
* |InlineFragmentsFor| returns nothing for culled inlines.
* |SelfFragmentsOf| returns relevant fragments for culled
  inlines.
But both were moved to |NGInlineCursor|.

This patch reviews all changes and re-distinguish them.

Following usages were |SelfFragmentsOf|, changed to use the
new function |MoveToIncludingCulledInline|.

https://chromium-review.googlesource.com/c/chromium/src/+/1862534
|FirstLineBoxTopLeftInternal|
|HitTestCulledInline|
|PhysicalLinesBoundingBox|
* |CollectLineBoxRects| uses different code path by
|LayoutNGFragmentItemEnabled|, so no need to change for now.

https://chromium-review.googlesource.com/c/chromium/src/+/1888623
|LinesVisualOverflowBoundingBox|

Following usages were |InlineFragmentsFor|, keep using
|MoveTo|. It was changed to return empty for culled inlines.

https://chromium-review.googlesource.com/c/chromium/src/+/2022447
LayoutInline::NodeAtPoint

https://chromium-review.googlesource.com/c/chromium/src/+/1888623
LinesVisualOverflowBoundingBox

https://chromium-review.googlesource.com/c/chromium/src/+/1930287
InvalidateDisplayItemClients

Bug: 982194
Change-Id: I4ea181606671a18b6337b7e651916be6ff5d1a82
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2166233Reviewed-by: default avatarYoshifumi Inoue <yosin@chromium.org>
Commit-Queue: Koji Ishii <kojii@chromium.org>
Cr-Commit-Position: refs/heads/master@{#762784}
parent f2fac2fb
......@@ -819,7 +819,7 @@ void LayoutInline::CollectLineBoxRects(
return;
}
NGInlineCursor cursor;
cursor.MoveTo(*this);
cursor.MoveToIncludingCulledInline(*this);
for (; cursor; cursor.MoveToNextForSameLayoutObject())
yield(cursor.Current().RectInContainerBlock());
return;
......@@ -966,7 +966,7 @@ base::Optional<PhysicalOffset> LayoutInline::FirstLineBoxTopLeftInternal()
const {
if (IsInLayoutNGInlineFormattingContext()) {
NGInlineCursor cursor;
cursor.MoveTo(*this);
cursor.MoveToIncludingCulledInline(*this);
if (!cursor)
return base::nullopt;
return cursor.Current().OffsetInContainerBlock();
......@@ -1126,7 +1126,8 @@ bool LayoutInline::HitTestCulledInline(HitTestResult& result,
if (parent_cursor) {
DCHECK(ContainingNGBlockFlow());
NGInlineCursor cursor(*parent_cursor);
for (cursor.MoveTo(*this); cursor; cursor.MoveToNextForSameLayoutObject())
cursor.MoveToIncludingCulledInline(*this);
for (; cursor; cursor.MoveToNextForSameLayoutObject())
yield(cursor.Current().RectInContainerBlock());
} else {
DCHECK(!ContainingNGBlockFlow());
......@@ -1176,7 +1177,7 @@ PositionWithAffinity LayoutInline::PositionForPoint(
PhysicalRect LayoutInline::PhysicalLinesBoundingBox() const {
if (IsInLayoutNGInlineFormattingContext()) {
NGInlineCursor cursor;
cursor.MoveTo(*this);
cursor.MoveToIncludingCulledInline(*this);
PhysicalRect bounding_box;
for (; cursor; cursor.MoveToNextForSameLayoutObject())
bounding_box.UniteIfNonZero(cursor.Current().RectInContainerBlock());
......@@ -1325,7 +1326,7 @@ PhysicalRect LayoutInline::LinesVisualOverflowBoundingBox() const {
if (IsInLayoutNGInlineFormattingContext()) {
PhysicalRect result;
NGInlineCursor cursor;
cursor.MoveTo(*this);
cursor.MoveToIncludingCulledInline(*this);
for (; cursor; cursor.MoveToNextForSameLayoutObject()) {
PhysicalRect child_rect = cursor.Current().InkOverflow();
child_rect.offset += cursor.Current().OffsetInContainerBlock();
......
......@@ -896,7 +896,7 @@ NGInlineCursor::ItemsSpan::iterator NGInlineCursor::SlowFirstItemIteratorFor(
return items_.end();
}
void NGInlineCursor::InternalMoveTo(const LayoutObject& layout_object) {
void NGInlineCursor::MoveTo(const LayoutObject& layout_object) {
DCHECK(layout_object.IsInLayoutNGInlineFormattingContext());
// If this cursor is rootless, find the root of the inline formatting context.
bool had_root = true;
......@@ -941,9 +941,10 @@ void NGInlineCursor::InternalMoveTo(const LayoutObject& layout_object) {
}
}
void NGInlineCursor::MoveTo(const LayoutObject& layout_object) {
void NGInlineCursor::MoveToIncludingCulledInline(
const LayoutObject& layout_object) {
DCHECK(layout_object.IsInLayoutNGInlineFormattingContext()) << layout_object;
InternalMoveTo(layout_object);
MoveTo(layout_object);
if (*this || !HasRoot() ||
RuntimeEnabledFeatures::LayoutNGFragmentItemEnabled()) {
layout_inline_ = nullptr;
......
......@@ -319,6 +319,7 @@ class CORE_EXPORT NGInlineCursor {
// |layout_object|. When |layout_object| has no associated fragments, this
// cursor points nothing.
void MoveTo(const LayoutObject& layout_object);
void MoveToIncludingCulledInline(const LayoutObject& layout_object);
// Move to containing line box. It is error if the current position is line.
void MoveToContainingLine();
......@@ -409,9 +410,6 @@ class CORE_EXPORT NGInlineCursor {
// Move the cursor position to the first fragment in tree.
void MoveToFirst();
// Same as |MoveTo()| but not support culled inline.
void InternalMoveTo(const LayoutObject& layout_object);
void SetRoot(const NGFragmentItems& items);
void SetRoot(const NGFragmentItems& fragment_items, ItemsSpan items);
void SetRoot(const NGPaintFragment& root_paint_fragment);
......
......@@ -214,7 +214,7 @@ TEST_P(NGInlineCursorTest, CulledInlineWithAtomicInline) {
"<b id=culled>abc<div style=display:inline>ABC<br>XYZ</div>xyz</b>"
"</div>");
NGInlineCursor cursor;
cursor.MoveTo(*GetLayoutObjectByElementId("culled"));
cursor.MoveToIncludingCulledInline(*GetLayoutObjectByElementId("culled"));
Vector<String> list;
while (cursor) {
list.push_back(ToDebugString(cursor));
......@@ -235,7 +235,7 @@ TEST_P(NGInlineCursorTest, CulledInlineWithFloat) {
"<b id=culled>abc<div style=float:right></div>xyz</b>"
"</div>");
NGInlineCursor cursor;
cursor.MoveTo(*GetLayoutObjectByElementId("culled"));
cursor.MoveToIncludingCulledInline(*GetLayoutObjectByElementId("culled"));
Vector<String> list;
while (cursor) {
list.push_back(ToDebugString(cursor));
......@@ -252,7 +252,7 @@ TEST_P(NGInlineCursorTest, CulledInlineWithRoot) {
<div id="root"><a id="a"><b>abc</b><br><i>xyz</i></a></div>
)HTML");
const LayoutObject* layout_inline_a = GetLayoutObjectByElementId("a");
cursor.MoveTo(*layout_inline_a);
cursor.MoveToIncludingCulledInline(*layout_inline_a);
Vector<String> list;
while (cursor) {
list.push_back(ToDebugString(cursor));
......@@ -270,7 +270,7 @@ TEST_P(NGInlineCursorTest, CulledInlineWithoutRoot) {
)HTML");
const LayoutObject* layout_inline_a = GetLayoutObjectByElementId("a");
NGInlineCursor cursor;
cursor.MoveTo(*layout_inline_a);
cursor.MoveToIncludingCulledInline(*layout_inline_a);
Vector<String> list;
while (cursor) {
list.push_back(ToDebugString(cursor));
......
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