Commit 31da4fe3 authored by Ian Kilpatrick's avatar Ian Kilpatrick Committed by Commit Bot

[LayoutNG] Remove NGConstraintSpace allocation when computing float inline-size.

This shouldn't have any behaviour change. Instead of using the
ComputeInlineSizeForFragment call directly, we optimistically perform layout
on the float to determine this size.

This saves an allocation of an NGConstraintSpace (and simplifies the code
dramatically), which results in a 25% perf increase in some float
benchmarks (see previous pinpoint result).

Cq-Include-Trybots: luci.chromium.try:linux_layout_tests_layout_ng
Change-Id: I111e62a4c16c206473085ebd309719f017196959
Bug: 635619
Reviewed-on: https://chromium-review.googlesource.com/1143882
Commit-Queue: Ian Kilpatrick <ikilpatrick@chromium.org>
Reviewed-by: default avatarKoji Ishii <kojii@chromium.org>
Cr-Commit-Position: refs/heads/master@{#576778}
parent 98d34d3f
......@@ -843,6 +843,14 @@ void NGLineBreaker::HandleFloat(const NGInlineItem& item) {
margins, node,
/* break_token */ nullptr);
// If we are currently computing our min/max-content size simply append
// to the unpositioned floats list and abort.
if (mode_ != NGLineBreakerMode::kContent) {
AddUnpositionedFloat(unpositioned_floats_, container_builder_,
std::move(unpositioned_float));
return;
}
LayoutUnit inline_margin_size =
(ComputeInlineSizeForUnpositionedFloat(constraint_space_,
unpositioned_float.get()) +
......@@ -870,15 +878,10 @@ void NGLineBreaker::HandleFloat(const NGInlineItem& item) {
// also is strictly within the non-shape area).
// - It will be moved down due to block-start edge alignment.
// - It will be moved down due to clearance.
// - We are currently computing our min/max-content size. (We use the
// unpositioned_floats to manually adjust the min/max-content size after
// the line breaker has run).
bool float_after_line =
!can_fit_float ||
exclusion_space_->LastFloatBlockStart() > bfc_block_offset ||
exclusion_space_->ClearanceOffset(float_style.Clear()) >
bfc_block_offset ||
mode_ != NGLineBreakerMode::kContent;
exclusion_space_->ClearanceOffset(float_style.Clear()) > bfc_block_offset;
// Check if we already have a pending float. That's because a float cannot be
// higher than any block or floated box generated before.
......
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