Skip to content

Commit

Permalink
[flex] Remove intrinsic sizing algorithms that aren't web compatible.
Browse files Browse the repository at this point in the history
These algorithms caused too many regressions - remove :(

See:
w3c/csswg-drafts#8884 (comment)

Bug: 240765
Change-Id: Id5c5d0817d778ff8094e606d5d111c808c6c6c5f
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4799320
Reviewed-by: Morten Stenshorne <mstensho@chromium.org>
Commit-Queue: Ian Kilpatrick <ikilpatrick@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1186508}
  • Loading branch information
bfgeek authored and Chromium LUCI CQ committed Aug 22, 2023
1 parent 874ea6d commit 6ed2b77
Show file tree
Hide file tree
Showing 9 changed files with 11 additions and 436 deletions.
7 changes: 2 additions & 5 deletions third_party/blink/renderer/core/layout/layout_box.h
Original file line number Diff line number Diff line change
Expand Up @@ -1366,18 +1366,15 @@ class CORE_EXPORT LayoutBox : public LayoutBoxModelObject {
LayoutUnit intrinsic_logical_widths_initial_block_size,
bool depends_on_block_constraints,
bool child_depends_on_block_constraints,
bool flex_intrinsic_sizing,
const MinMaxSizes* sizes) {
const MinMaxSizes& sizes) {
NOT_DESTROYED();
intrinsic_logical_widths_initial_block_size_ =
intrinsic_logical_widths_initial_block_size;
SetIntrinsicLogicalWidthsDependsOnBlockConstraints(
depends_on_block_constraints);
SetIntrinsicLogicalWidthsInFlexIntrinsicSizing(flex_intrinsic_sizing);
SetIntrinsicLogicalWidthsChildDependsOnBlockConstraints(
child_depends_on_block_constraints);
if (sizes)
intrinsic_logical_widths_ = *sizes;
intrinsic_logical_widths_ = sizes;
ClearIntrinsicLogicalWidthsDirty();
}

Expand Down
12 changes: 0 additions & 12 deletions third_party/blink/renderer/core/layout/layout_object.h
Original file line number Diff line number Diff line change
Expand Up @@ -1590,15 +1590,6 @@ class CORE_EXPORT LayoutObject : public GarbageCollected<LayoutObject>,
bitfields_.SetIntrinsicLogicalWidthsChildDependsOnBlockConstraints(b);
}

void SetIntrinsicLogicalWidthsInFlexIntrinsicSizing(bool b) {
NOT_DESTROYED();
bitfields_.SetIntrinsicLogicalWidthsInFlexIntrinsicSizing(b);
}
bool IntrinsicLogicalWidthsInFlexIntrinsicSizing() const {
NOT_DESTROYED();
return bitfields_.IntrinsicLogicalWidthsInFlexIntrinsicSizing();
}

bool NeedsLayoutOverflowRecalc() const {
NOT_DESTROYED();
return bitfields_.SelfNeedsLayoutOverflowRecalc() ||
Expand Down Expand Up @@ -3997,9 +3988,6 @@ class CORE_EXPORT LayoutObject : public GarbageCollected<LayoutObject>,
intrinsic_logical_widths_child_depends_on_block_constraints_,
IntrinsicLogicalWidthsChildDependsOnBlockConstraints);

ADD_BOOLEAN_BITFIELD(intrinsic_logical_widths_in_flex_intrinsic_sizing_,
IntrinsicLogicalWidthsInFlexIntrinsicSizing);

// This flag is set on inline container boxes that need to run the
// Pre-layout phase in LayoutNG. See NGInlineNode::CollectInlines().
// Also maybe set to inline boxes to optimize the propagation.
Expand Down

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,7 @@ class CORE_EXPORT NGFlexLayoutAlgorithm
NGConstraintSpace BuildSpaceForFlexBasis(const NGBlockNode& flex_item) const;
NGConstraintSpace BuildSpaceForIntrinsicBlockSize(
const NGBlockNode& flex_item,
absl::optional<LayoutUnit> override_inline_size,
Phase phase) const;
absl::optional<LayoutUnit> override_inline_size) const;
// |line_cross_size_for_stretch| should only be set when running the final
// layout pass for stretch, when the line cross size is definite.
// |block_offset_for_fragmentation| should only be set when running the final
Expand Down Expand Up @@ -115,13 +114,8 @@ class CORE_EXPORT NGFlexLayoutAlgorithm

void AdjustButtonBaseline(LayoutUnit final_content_cross_size);

MinMaxSizesResult ComputeMinMaxSizeOfRowContainer();
MinMaxSizesResult ComputeMinMaxSizeOfRowContainerV3();
MinMaxSizesResult ComputeMinMaxSizeOfMultilineColumnContainer();
// This implements 9.9.3. Flex Item Intrinsic Size Contributions, from
// https://drafts.csswg.org/css-flexbox/#intrinsic-item-contributions.
MinMaxSizesResult ComputeItemContributions(const NGConstraintSpace& space,
const FlexItem& item) const;

// Return the amount of block space available in the current fragmentainer
// for the node being laid out by this algorithm.
Expand Down
10 changes: 1 addition & 9 deletions third_party/blink/renderer/core/layout/ng/ng_block_node.cc
Original file line number Diff line number Diff line change
Expand Up @@ -260,13 +260,6 @@ bool CanUseCachedIntrinsicInlineSizes(const NGConstraintSpace& constraint_space,
return false;
}

if (constraint_space.IsInFlexIntrinsicSizing() !=
node.GetLayoutBox()->IntrinsicLogicalWidthsInFlexIntrinsicSizing()) {
UseCounter::Count(node.GetDocument(),
WebFeature::kFlexIntrinsicSizesCacheMiss);
return false;
}

return true;
}

Expand Down Expand Up @@ -1026,8 +1019,7 @@ MinMaxSizesResult NGBlockNode::ComputeMinMaxSizes(
box_->SetIntrinsicLogicalWidthsFromNG(
initial_block_size, depends_on_block_constraints,
/* child_depends_on_block_constraints */
result.depends_on_block_constraints,
constraint_space.IsInFlexIntrinsicSizing(), &result.sizes);
result.depends_on_block_constraints, result.sizes);

if (IsNGTableCell()) {
To<LayoutNGTableCell>(box_.Get())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -523,10 +523,6 @@ class CORE_EXPORT NGConstraintSpace final {
return bitfields_.is_restricted_block_size_table_cell_child;
}

bool IsInFlexIntrinsicSizing() const {
return bitfields_.is_in_flex_intrinsic_sizing;
}

bool IsPaintedAtomically() const { return bitfields_.is_painted_atomically; }

// If specified a layout should produce a Fragment which fragments at the
Expand Down Expand Up @@ -1560,7 +1556,6 @@ class CORE_EXPORT NGConstraintSpace final {
is_initial_block_size_indefinite(false),
is_table_cell_child(false),
is_restricted_block_size_table_cell_child(false),
is_in_flex_intrinsic_sizing(false),
percentage_inline_storage(kSameAsAvailable),
percentage_block_storage(kSameAsAvailable),
replaced_percentage_block_storage(kSameAsAvailable) {}
Expand Down Expand Up @@ -1619,7 +1614,6 @@ class CORE_EXPORT NGConstraintSpace final {
unsigned is_initial_block_size_indefinite : 1;
unsigned is_table_cell_child : 1;
unsigned is_restricted_block_size_table_cell_child : 1;
unsigned is_in_flex_intrinsic_sizing : 1;

unsigned percentage_inline_storage : 2; // NGPercentageStorage
unsigned percentage_block_storage : 2; // NGPercentageStorage
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@ class CORE_EXPORT NGConstraintSpaceBuilder final {
if (parent_space.ShouldRepeat())
SetShouldRepeat(true);
SetIsInsideRepeatableContent(parent_space.IsInsideRepeatableContent());
SetIsInFlexIntrinsicSizing(parent_space.IsInFlexIntrinsicSizing());
}

// The setters on this builder are in the writing mode of parent_writing_mode.
Expand Down Expand Up @@ -179,10 +178,6 @@ class CORE_EXPORT NGConstraintSpaceBuilder final {

void DisableFurtherFragmentation() { space_.DisableFurtherFragmentation(); }

void SetIsInFlexIntrinsicSizing(bool b) {
space_.bitfields_.is_in_flex_intrinsic_sizing = b;
}

void SetIsFixedInlineSize(bool b) {
if (LIKELY(is_in_parallel_flow_))
space_.bitfields_.is_fixed_inline_size = b;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -738,8 +738,7 @@ MinMaxSizesResult NGTableLayoutAlgorithm::ComputeMinMaxSizes(
std::max(grid_min_max.min_size, caption_constraint.min_size),
std::max(grid_min_max.max_size, caption_constraint.min_size)};

if (is_fixed_layout && Style().LogicalWidth().IsPercentOrCalc() &&
!ConstraintSpace().IsInFlexIntrinsicSizing()) {
if (is_fixed_layout && Style().LogicalWidth().IsPercentOrCalc()) {
min_max.max_size = NGTableTypes::kTableMaxInlineSize;
}
DCHECK_LE(min_max.min_size, min_max.max_size);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2099,13 +2099,6 @@
name: "LayoutFlexNewColumnAlgorithm",
status: "stable",
},
{
name: "LayoutFlexNewRowAlgorithm",
implied_by: ["LayoutFlexNewRowAlgorithmV2"],
},
{
name: "LayoutFlexNewRowAlgorithmV2",
},
{
name: "LayoutFlexNewRowAlgorithmV3",
status: "test",
Expand Down

0 comments on commit 6ed2b77

Please sign in to comment.