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

[TablesNG] Add collapsed flag for column visibility

Prerequisite for landing algorithms: column visibility flag.
Also, minor fix for computing orthogonal cell sizes
in CreateCellInlineConstraint.

Bug: 958381
Change-Id: I27de68a819ba5664e568cee58597d6edf6baa203
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2368105Reviewed-by: default avatarMorten Stenshorne <mstensho@chromium.org>
Reviewed-by: default avatarIan Kilpatrick <ikilpatrick@chromium.org>
Commit-Queue: Aleks Totic <atotic@chromium.org>
Cr-Commit-Position: refs/heads/master@{#801087}
parent 6dcaaf62
......@@ -80,15 +80,20 @@ NGTableTypes::Column NGTableTypes::CreateColumn(
bool is_constrained = inline_size.has_value();
if (percentage_inline_size && *percentage_inline_size == 0.0f)
percentage_inline_size.reset();
return Column{min_inline_size.value_or(LayoutUnit()), inline_size,
percentage_inline_size, is_constrained, kIndefiniteSize};
bool is_collapsed = style.Visibility() == EVisibility::kCollapse;
return Column{min_inline_size.value_or(LayoutUnit()),
inline_size,
percentage_inline_size,
is_constrained,
is_collapsed,
kIndefiniteSize};
}
// Implements https://www.w3.org/TR/css-tables-3/#computing-cell-measures
// "outer min-content and outer max-content widths for table cells"
// Note: this method calls NGBlockNode::ComputeMinMaxSizes.
NGTableTypes::CellInlineConstraint NGTableTypes::CreateCellInlineConstraint(
const NGLayoutInputNode& node,
const NGBlockNode& node,
WritingMode table_writing_mode,
bool is_fixed_layout,
const NGBoxStrut& cell_border,
......@@ -108,17 +113,29 @@ NGTableTypes::CellInlineConstraint NGTableTypes::CreateCellInlineConstraint(
MinMaxSizesInput input(kIndefiniteSize, MinMaxSizesType::kIntrinsic);
MinMaxSizesResult min_max_size;
if (is_collapsed) {
bool is_parallel =
IsParallelWritingMode(table_writing_mode, node.Style().GetWritingMode());
bool need_constraint_space = is_collapsed || !is_parallel;
if (need_constraint_space) {
NGConstraintSpaceBuilder builder(table_writing_mode,
node.Style().GetWritingMode(),
/* is_new_fc */ false);
/* is_new_fc */ true);
builder.SetTableCellBorders(cell_border);
builder.SetIsTableCell(true, /* is_legacy_table_cell */ false);
builder.SetCacheSlot(NGCacheSlot::kMeasure);
if (!is_parallel) {
PhysicalSize icb_size = node.InitialContainingBlockSize();
builder.SetOrthogonalFallbackInlineSize(
IsHorizontalWritingMode(table_writing_mode) ? icb_size.height
: icb_size.width);
builder.SetIsShrinkToFit(node.Style().LogicalWidth().IsAuto());
builder.SetTextDirection(node.Style().Direction());
}
NGConstraintSpace space = builder.ToConstraintSpace();
// It'd be nice to avoid computing minmax if not needed, but the criteria
// is not clear.
min_max_size = To<NGBlockNode>(node).ComputeMinMaxSizes(table_writing_mode,
input, &space);
min_max_size = node.ComputeMinMaxSizes(table_writing_mode, input, &space);
} else {
min_max_size = node.ComputeMinMaxSizes(table_writing_mode, input);
}
......
......@@ -67,7 +67,7 @@ class CORE_EXPORT NGTableTypes {
base::Optional<float> percent; // 100% is stored as 100.0f
// True if any cell for this column is constrained.
bool is_constrained = false;
bool is_collapsed = false;
// The final inline-size of the column after all constraints have been
// applied.
LayoutUnit computed_inline_size;
......@@ -169,6 +169,7 @@ class CORE_EXPORT NGTableTypes {
struct ColumnLocation {
LayoutUnit offset; // inline offset from table edge.
LayoutUnit size;
bool is_collapsed;
};
struct Section {
......@@ -185,7 +186,7 @@ class CORE_EXPORT NGTableTypes {
base::Optional<LayoutUnit> default_inline_size);
static CellInlineConstraint CreateCellInlineConstraint(
const NGLayoutInputNode&,
const NGBlockNode&,
WritingMode table_writing_mode,
bool is_fixed_layout,
const NGBoxStrut& cell_border,
......
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