Commit 1bb9e566 authored by Koji Ishii's avatar Koji Ishii Committed by Commit Bot

Add integrity checks of flags for NGPhysicalBoxFragment

This patch adds integrity checks for the flags of
|NGPhysicalBoxFragment| and its actual children.

Bug: 982194
Change-Id: Ic18f088c1263d4f76f03dc1f22a88d3700254b68
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2050151Reviewed-by: default avatarIan Kilpatrick <ikilpatrick@chromium.org>
Reviewed-by: default avatarMorten Stenshorne <mstensho@chromium.org>
Commit-Queue: Koji Ishii <kojii@chromium.org>
Cr-Commit-Position: refs/heads/master@{#741743}
parent 14a6c6c5
...@@ -112,6 +112,10 @@ NGPhysicalBoxFragment::NGPhysicalBoxFragment( ...@@ -112,6 +112,10 @@ NGPhysicalBoxFragment::NGPhysicalBoxFragment(
has_baseline_ = false; has_baseline_ = false;
baseline_ = LayoutUnit::Min(); baseline_ = LayoutUnit::Min();
} }
#if DCHECK_IS_ON()
CheckIntegrity();
#endif
} }
scoped_refptr<const NGLayoutResult> scoped_refptr<const NGLayoutResult>
...@@ -490,6 +494,58 @@ void NGPhysicalBoxFragment::CheckSameForSimplifiedLayout( ...@@ -490,6 +494,58 @@ void NGPhysicalBoxFragment::CheckSameForSimplifiedLayout(
DCHECK(Borders() == other.Borders()); DCHECK(Borders() == other.Borders());
DCHECK(Padding() == other.Padding()); DCHECK(Padding() == other.Padding());
} }
// Check our flags represent the actual children correctly.
void NGPhysicalBoxFragment::CheckIntegrity() const {
bool has_inflow_blocks = false;
bool has_inlines = false;
bool has_line_boxes = false;
bool has_floats = false;
bool has_list_markers = false;
for (const NGLink& child : Children()) {
if (child->IsFloating())
has_floats = true;
else if (child->IsOutOfFlowPositioned())
; // OOF can be in the fragment tree regardless of |HasItems|.
else if (child->IsLineBox())
has_line_boxes = true;
else if (child->IsListMarker())
has_list_markers = true;
else if (child->IsInline())
has_inlines = true;
else
has_inflow_blocks = true;
}
// If we have line boxes, |IsInlineFormattingContext()| is true, but the
// reverse is not always true.
if (has_line_boxes || has_inlines)
DCHECK(IsInlineFormattingContext());
// If display-locked, we may not have any children.
DCHECK(layout_object_);
if (layout_object_ && layout_object_->PaintBlockedByDisplayLock(
DisplayLockLifecycleTarget::kChildren))
return;
if (RuntimeEnabledFeatures::LayoutNGFragmentItemEnabled()) {
if (RuntimeEnabledFeatures::LayoutNGBlockFragmentationEnabled()) {
if (has_line_boxes)
DCHECK(HasItems());
} else {
DCHECK_EQ(HasItems(), has_line_boxes);
}
if (has_line_boxes) {
DCHECK(!has_inlines);
DCHECK(!has_inflow_blocks);
// Following objects should be in the items, not in the tree.
DCHECK(!has_floats);
DCHECK(!has_list_markers);
}
}
}
#endif #endif
} // namespace blink } // namespace blink
...@@ -159,6 +159,10 @@ class CORE_EXPORT NGPhysicalBoxFragment final ...@@ -159,6 +159,10 @@ class CORE_EXPORT NGPhysicalBoxFragment final
return has_borders_ ? address + 1 : address; return has_borders_ ? address + 1 : address;
} }
#if DCHECK_IS_ON()
void CheckIntegrity() const;
#endif
LayoutUnit baseline_; LayoutUnit baseline_;
NGLink children_[]; NGLink children_[];
// borders and padding come from after |children_| if they are not zero. // borders and padding come from after |children_| if they are not zero.
......
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