Commit cbe6bd3c authored by Aleks Totic's avatar Aleks Totic Committed by Commit Bot

[TablesNG] Intrinsic logical width cache for table cells

Implementation of the intrinsic logical width cache for TablesNG.

When tables are collapsed, change in border/table structure can
invalidate adjacent cells. Because efficiently computing adjacency
in tables is an open problem, we cannot just
SetIntrinsicLogicalWidthsDirty on all afffected cells.

Instead, cells cache borders used for intrinsic computation,
and use this value to invalidate the cache.

Bug: 958381
Change-Id: I394d6160ee44eb206a7f9b16320ae7ee46d21c88
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2368239
Commit-Queue: Aleks Totic <atotic@chromium.org>
Reviewed-by: default avatarMorten Stenshorne <mstensho@chromium.org>
Reviewed-by: default avatarIan Kilpatrick <ikilpatrick@chromium.org>
Cr-Commit-Position: refs/heads/master@{#801111}
parent 6a73b6e0
......@@ -55,6 +55,7 @@
#include "third_party/blink/renderer/core/layout/ng/ng_simplified_layout_algorithm.h"
#include "third_party/blink/renderer/core/layout/ng/ng_space_utils.h"
#include "third_party/blink/renderer/core/layout/ng/table/layout_ng_table.h"
#include "third_party/blink/renderer/core/layout/ng/table/layout_ng_table_cell.h"
#include "third_party/blink/renderer/core/layout/ng/table/ng_table_borders.h"
#include "third_party/blink/renderer/core/layout/shapes/shape_outside_info.h"
#include "third_party/blink/renderer/core/layout/text_autosizer.h"
......@@ -348,6 +349,7 @@ void SetupBoxLayoutExtraInput(const NGConstraintSpace& space,
}
bool CanUseCachedIntrinsicInlineSizes(const MinMaxSizesInput& input,
const NGConstraintSpace& constraint_space,
const NGBlockNode& node) {
// Obviously can't use the cache if our intrinsic logical widths are dirty.
if (node.GetLayoutBox()->IntrinsicLogicalWidthsDirty())
......@@ -372,6 +374,11 @@ bool CanUseCachedIntrinsicInlineSizes(const MinMaxSizesInput& input,
->IntrinsicLogicalWidthsPercentageResolutionBlockSize())
return false;
if (node.IsNGTableCell() && To<LayoutNGTableCell>(node.GetLayoutBox())
->IntrinsicLogicalWidthsBorderSizes() !=
constraint_space.TableCellBorders())
return false;
return true;
}
......@@ -765,7 +772,7 @@ MinMaxSizesResult NGBlockNode::ComputeMinMaxSizes(
}
bool can_use_cached_intrinsic_inline_sizes =
CanUseCachedIntrinsicInlineSizes(input, *this);
CanUseCachedIntrinsicInlineSizes(input, *constraint_space, *this);
// Use our cached sizes if either:
// - The %-block-sizes match.
......@@ -870,6 +877,11 @@ MinMaxSizesResult NGBlockNode::ComputeMinMaxSizes(
/* child_depends_on_percentage_block_size */
result.depends_on_percentage_block_size, &result.sizes);
if (IsNGTableCell()) {
To<LayoutNGTableCell>(box_)->SetIntrinsicLogicalWidthsBorderSizes(
constraint_space->TableCellBorders());
}
// We report to our parent if we depend on the %-block-size if we used the
// input %-block-size, or one of children said it depended on this.
result.depends_on_percentage_block_size = depends_on_percentage_block_size;
......
......@@ -95,6 +95,10 @@ class CORE_EXPORT NGBlockNode final : public NGLayoutInputNode {
NGBlockNode GetFieldsetContent() const;
bool IsNGTable() const { return IsTable() && box_->IsLayoutNGMixin(); }
bool IsNGTableCell() const {
return box_->IsTableCell() && !box_->IsTableCellLegacy();
}
bool IsFixedTableLayout() const;
const NGBoxStrut& GetTableBorders() const;
......
......@@ -30,6 +30,14 @@ class CORE_EXPORT LayoutNGTableCell
return rowspan;
}
const NGBoxStrut& IntrinsicLogicalWidthsBorderSizes() const {
return intrinsical_logical_widths_border_sizes_;
}
void SetIntrinsicLogicalWidthsBorderSizes(const NGBoxStrut& border_sizes) {
intrinsical_logical_widths_border_sizes_ = border_sizes;
}
LayoutNGTable* Table() const;
// LayoutBlockFlow methods start.
......@@ -111,6 +119,10 @@ class CORE_EXPORT LayoutNGTableCell
return ParseRowSpanFromDOM();
}
// Cached cell border. Used to invalidate calculation of
// intrinsic logical width.
NGBoxStrut intrinsical_logical_widths_border_sizes_;
unsigned has_col_span_ : 1;
unsigned has_rowspan_ : 1;
};
......
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