Commit 368bcee3 authored by Aleks Totic's avatar Aleks Totic Committed by Commit Bot

[TablesNG] TableConstraintSpaceData memory optimization

Make all rows share the same TableConstraintSpaceData by
replacing it if we are reusing the fragment.

Bug: 958381
Change-Id: I7647d69d930218f1dfaac2cefdd8a49ba936ceaf
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2511431
Commit-Queue: Aleks Totic <atotic@chromium.org>
Reviewed-by: default avatarIan Kilpatrick <ikilpatrick@chromium.org>
Cr-Commit-Position: refs/heads/master@{#823562}
parent 86d55b4e
......@@ -3498,6 +3498,14 @@ scoped_refptr<const NGLayoutResult> LayoutBox::CachedLayoutResult(
// not clear the child dirty bits.
ClearNeedsLayout();
// Optimization: TableConstraintSpaceData can be large, and it is shared
// between all the rows in a table. Make constraint space table data for
// reused row fragment be identical to the one used by other row fragments.
if (IsTableRow() && IsLayoutNGMixin()) {
const_cast<NGConstraintSpace&>(old_space).ReplaceTableConstraintSpaceData(
*new_space.TableData());
}
// OOF-positioned nodes have to two-tier cache. The additional cache check
// runs before the OOF-positioned sizing, and positioning calculations.
//
......
......@@ -685,6 +685,12 @@ class CORE_EXPORT NGConstraintSpace final {
return true;
}
void ReplaceTableConstraintSpaceData(
const NGTableConstraintSpaceData& table_data) {
DCHECK(HasRareData());
rare_data_->ReplaceTableConstraintSpaceData(table_data);
}
String ToString() const;
private:
......@@ -998,6 +1004,14 @@ class CORE_EXPORT NGConstraintSpace final {
EnsureTableSectionData()->section_index = section_index;
}
void ReplaceTableConstraintSpaceData(
const NGTableConstraintSpaceData& table_data) {
DCHECK_EQ(data_union_type, kTableRowData);
DCHECK(table_data.IsTableSpecificDataEqual(
*(EnsureTableRowData()->table_data)));
EnsureTableRowData()->table_data = &table_data;
}
const NGTableConstraintSpaceData* TableData() {
if (data_union_type == kTableRowData)
return EnsureTableRowData()->table_data.get();
......
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