Commit 86141fb5 authored by Koji Ishii's avatar Koji Ishii Committed by Commit Bot

Refactor RecalcInkOverflow to take |const NGInlineCursor&|

This patch refactors |NGFragmentItem::RecalcInkOverflow| to
take |const NGInlineCursor&| instead of |NGInlineCursor*|.
With this refactoring, it is callers' responsibility to
advance the cursor.

This is to prepare using this function for self-painting
|LayoutInline|.

This patch has no behavior changes.

Bug: 1128199
Change-Id: Iee1964255f5d1c31b4d3cf4e1bb73b6c4b50f327
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2426213Reviewed-by: default avatarKent Tamura <tkent@chromium.org>
Commit-Queue: Koji Ishii <kojii@chromium.org>
Cr-Commit-Position: refs/heads/master@{#810173}
parent 77cc304d
......@@ -507,19 +507,18 @@ PhysicalRect NGFragmentItem::RecalcInkOverflowForCursor(
DCHECK(cursor);
DCHECK(!cursor->Current() || cursor->IsAtFirst());
PhysicalRect contents_ink_overflow;
while (*cursor) {
for (; *cursor; cursor->MoveToNextSkippingChildren()) {
const NGFragmentItem* item = cursor->CurrentItem();
DCHECK(item);
if (UNLIKELY(item->IsLayoutObjectDestroyedOrMoved())) {
// TODO(crbug.com/1099613): This should not happen, as long as it is
// layout-clean. It looks like there are cases where the layout is dirty.
NOTREACHED();
cursor->MoveToNextSkippingChildren();
continue;
}
PhysicalRect child_rect;
item->GetMutableForPainting().RecalcInkOverflow(cursor, &child_rect);
item->GetMutableForPainting().RecalcInkOverflow(*cursor, &child_rect);
if (item->HasSelfPaintingLayer())
continue;
if (!child_rect.IsEmpty()) {
......@@ -531,21 +530,18 @@ PhysicalRect NGFragmentItem::RecalcInkOverflowForCursor(
}
void NGFragmentItem::RecalcInkOverflow(
NGInlineCursor* cursor,
const NGInlineCursor& cursor,
PhysicalRect* self_and_contents_rect_out) {
DCHECK_EQ(this, cursor->CurrentItem());
DCHECK_EQ(this, cursor.CurrentItem());
if (UNLIKELY(IsLayoutObjectDestroyedOrMoved())) {
// TODO(crbug.com/1099613): This should not happen, as long as it is really
// layout-clean. It looks like there are cases where the layout is dirty.
NOTREACHED();
cursor->MoveToNextSkippingChildren();
return;
}
if (IsText()) {
cursor->MoveToNext();
// Re-computing text item is not necessary, because all changes that needs
// to re-compute ink overflow invalidate layout.
if (IsInkOverflowComputed()) {
......@@ -553,7 +549,7 @@ void NGFragmentItem::RecalcInkOverflow(
return;
}
NGTextFragmentPaintInfo paint_info = TextPaintInfo(cursor->Items());
NGTextFragmentPaintInfo paint_info = TextPaintInfo(cursor.Items());
if (paint_info.shape_result) {
ink_overflow_type_ = ink_overflow_.SetTextInkOverflow(
InkOverflowType(), paint_info, Style(), Size(),
......@@ -571,15 +567,13 @@ void NGFragmentItem::RecalcInkOverflow(
// overflow to be stored in |LayoutBox|.
if (LayoutBox* owner_box = MutableInkOverflowOwnerBox()) {
DCHECK(!HasChildren());
cursor->MoveToNextSkippingChildren();
owner_box->RecalcNormalFlowChildVisualOverflowIfNeeded();
*self_and_contents_rect_out = owner_box->PhysicalVisualOverflowRect();
return;
}
// Re-compute descendants, then compute the contents ink overflow from them.
NGInlineCursor descendants_cursor = cursor->CursorForDescendants();
cursor->MoveToNextSkippingChildren();
NGInlineCursor descendants_cursor = cursor.CursorForDescendants();
PhysicalRect contents_rect = RecalcInkOverflowForCursor(&descendants_cursor);
// |contents_rect| is relative to the inline formatting context. Make it
......
......@@ -247,7 +247,7 @@ class CORE_EXPORT NGFragmentItem {
STACK_ALLOCATED();
public:
void RecalcInkOverflow(NGInlineCursor* cursor,
void RecalcInkOverflow(const NGInlineCursor& cursor,
PhysicalRect* self_and_contents_rect_out) {
return item_.RecalcInkOverflow(cursor, self_and_contents_rect_out);
}
......@@ -409,9 +409,8 @@ class CORE_EXPORT NGFragmentItem {
const LayoutBox* InkOverflowOwnerBox() const;
LayoutBox* MutableInkOverflowOwnerBox();
// Re-compute the ink overflow for this item. |cursor| should be at |this|,
// and is advanced to the next item on return.
void RecalcInkOverflow(NGInlineCursor* cursor,
// Re-compute the ink overflow for this item. |cursor| should be at |this|.
void RecalcInkOverflow(const NGInlineCursor& cursor,
PhysicalRect* self_and_contents_rect_out);
const LayoutObject* layout_object_;
......
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