Commit e3ef12a3 authored by Ian Kilpatrick's avatar Ian Kilpatrick Committed by Commit Bot

[LayoutNG] Refactor NGConstraintSpace::MaySkipLayout

Previously if a NGConstraintSpace had a rare-data object, and the
comparison NGConstraintSpace did not, we said we couldn't skip layout.

However there are cases where we may allocate a rare-data object and
still be able to skip layout.

I don't believe this case is particularly common, so this is just a
cleanup patch.

Bug: 635619
Change-Id: Iba91c9028b614fcce0c3bf48b14fe38030709ab0
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1546309
Commit-Queue: Ian Kilpatrick <ikilpatrick@chromium.org>
Reviewed-by: default avatarChristian Biesinger <cbiesinger@chromium.org>
Reviewed-by: default avatarMorten Stenshorne <mstensho@chromium.org>
Cr-Commit-Position: refs/heads/master@{#646412}
parent ae8e59d4
......@@ -421,16 +421,21 @@ class CORE_EXPORT NGConstraintSpace final {
// to verify that any constraint space size (available size, percentage size,
// and so on) and BFC offset changes won't require re-layout, before skipping.
bool MaySkipLayout(const NGConstraintSpace& other) const {
if (HasRareData() && other.HasRareData()) {
if (!rare_data_->MaySkipLayout(*other.rare_data_))
return false;
} else if (HasRareData() != other.HasRareData()) {
// We have a bfc_offset_, and a rare_data_ (or vice-versa).
if (!bitfields_.MaySkipLayout(other.bitfields_) ||
exclusion_space_ != other.exclusion_space_)
return false;
}
return exclusion_space_ == other.exclusion_space_ &&
bitfields_.MaySkipLayout(other.bitfields_);
if (!HasRareData() && !other.HasRareData())
return true;
if (HasRareData() && other.HasRareData())
return rare_data_->MaySkipLayout(*other.rare_data_);
if (HasRareData())
return rare_data_->IsInitialForMaySkipLayout();
DCHECK(other.HasRareData());
return other.rare_data_->IsInitialForMaySkipLayout();
}
bool AreSizesEqual(const NGConstraintSpace& other) const {
......@@ -533,6 +538,16 @@ class CORE_EXPORT NGConstraintSpace final {
block_direction_fragmentation_type ==
other.block_direction_fragmentation_type;
}
// Must be kept in sync with members checked within |MaySkipLayout|.
bool IsInitialForMaySkipLayout() const {
return margin_strut == NGMarginStrut() &&
floats_bfc_block_offset == base::nullopt &&
clearance_offset == LayoutUnit::Min() &&
fragmentainer_block_size == NGSizeIndefinite &&
fragmentainer_space_at_bfc_start == NGSizeIndefinite &&
block_direction_fragmentation_type == kFragmentNone;
}
};
// This struct simply allows us easily copy, compare, and initialize all the
......
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