Commit 248a5a86 authored by Koji Ishii's avatar Koji Ishii Committed by Commit Bot

[LayoutNG] Change PositionFloats signature

This patch changes PositionFloats to have
NGPositionedFloatVector* to return the positioned floats,
instead of it to return the vector.

NGPositionedFloatVector has inline buffer that returning
it involves a bit of memory copy overhead.

Pinpoint shows slight improvement. We could see them within
errors, but mostly positive, and running twice shows similar
trends.
https://pinpoint-dot-chromeperf.appspot.com/job/11f3134ce40000

Bug: 635619
Cq-Include-Trybots: luci.chromium.try:linux_layout_tests_layout_ng
Change-Id: I29c23e370b398f54a9acc1745f37ea9ffcb1b2fc
Reviewed-on: https://chromium-review.googlesource.com/c/1282689Reviewed-by: default avatarIan Kilpatrick <ikilpatrick@chromium.org>
Reviewed-by: default avatarChristian Biesinger <cbiesinger@chromium.org>
Commit-Queue: Koji Ishii <kojii@chromium.org>
Cr-Commit-Position: refs/heads/master@{#600101}
parent 0171953a
...@@ -888,12 +888,12 @@ void NGInlineLayoutAlgorithm::PositionPendingFloats( ...@@ -888,12 +888,12 @@ void NGInlineLayoutAlgorithm::PositionPendingFloats(
NGBfcOffset origin_bfc_offset = {ConstraintSpace().BfcOffset().line_offset, NGBfcOffset origin_bfc_offset = {ConstraintSpace().BfcOffset().line_offset,
bfc_block_offset + content_size}; bfc_block_offset + content_size};
const NGPositionedFloatVector positioned_floats = NGPositionedFloatVector positioned_floats;
PositionFloats(ConstraintSpace().AvailableSize(), PositionFloats(ConstraintSpace().AvailableSize(),
ConstraintSpace().PercentageResolutionSize(), ConstraintSpace().PercentageResolutionSize(),
ConstraintSpace().ReplacedPercentageResolutionSize(), ConstraintSpace().ReplacedPercentageResolutionSize(),
origin_bfc_offset, bfc_block_offset, unpositioned_floats_, origin_bfc_offset, bfc_block_offset, unpositioned_floats_,
ConstraintSpace(), exclusion_space); ConstraintSpace(), exclusion_space, &positioned_floats);
positioned_floats_.AppendVector(positioned_floats); positioned_floats_.AppendVector(positioned_floats);
unpositioned_floats_.clear(); unpositioned_floats_.clear();
......
...@@ -2081,10 +2081,11 @@ void NGBlockLayoutAlgorithm::PositionPendingFloats( ...@@ -2081,10 +2081,11 @@ void NGBlockLayoutAlgorithm::PositionPendingFloats(
? container_builder_.BfcBlockOffset().value() ? container_builder_.BfcBlockOffset().value()
: ConstraintSpace().FloatsBfcBlockOffset().value(); : ConstraintSpace().FloatsBfcBlockOffset().value();
const auto positioned_floats = PositionFloats( NGPositionedFloatVector positioned_floats;
child_available_size_, child_percentage_size_, PositionFloats(child_available_size_, child_percentage_size_,
replaced_child_percentage_size_, origin_bfc_offset, bfc_block_offset, replaced_child_percentage_size_, origin_bfc_offset,
unpositioned_floats_, ConstraintSpace(), &exclusion_space_); bfc_block_offset, unpositioned_floats_, ConstraintSpace(),
&exclusion_space_, &positioned_floats);
AddPositionedFloats(positioned_floats); AddPositionedFloats(positioned_floats);
......
...@@ -306,26 +306,24 @@ NGPositionedFloat PositionFloat( ...@@ -306,26 +306,24 @@ NGPositionedFloat PositionFloat(
return NGPositionedFloat(std::move(layout_result), float_bfc_offset); return NGPositionedFloat(std::move(layout_result), float_bfc_offset);
} }
const NGPositionedFloatVector PositionFloats( void PositionFloats(const NGLogicalSize& float_available_size,
const NGLogicalSize& float_available_size, const NGLogicalSize& float_percentage_size,
const NGLogicalSize& float_percentage_size, const NGLogicalSize& float_replaced_percentage_size,
const NGLogicalSize& float_replaced_percentage_size, const NGBfcOffset& origin_bfc_offset,
const NGBfcOffset& origin_bfc_offset, LayoutUnit parent_bfc_block_offset,
LayoutUnit parent_bfc_block_offset, NGUnpositionedFloatVector& unpositioned_floats,
NGUnpositionedFloatVector& unpositioned_floats, const NGConstraintSpace& space,
const NGConstraintSpace& space, NGExclusionSpace* exclusion_space,
NGExclusionSpace* exclusion_space) { NGPositionedFloatVector* positioned_floats) {
NGPositionedFloatVector positioned_floats; positioned_floats->ReserveCapacity(positioned_floats->size() +
positioned_floats.ReserveCapacity(unpositioned_floats.size()); unpositioned_floats.size());
for (NGUnpositionedFloat& unpositioned_float : unpositioned_floats) { for (NGUnpositionedFloat& unpositioned_float : unpositioned_floats) {
positioned_floats.push_back(PositionFloat( positioned_floats->push_back(PositionFloat(
float_available_size, float_percentage_size, float_available_size, float_percentage_size,
float_replaced_percentage_size, origin_bfc_offset, float_replaced_percentage_size, origin_bfc_offset,
parent_bfc_block_offset, &unpositioned_float, space, exclusion_space)); parent_bfc_block_offset, &unpositioned_float, space, exclusion_space));
} }
return positioned_floats;
} }
void AddUnpositionedFloat(NGUnpositionedFloatVector* unpositioned_floats, void AddUnpositionedFloat(NGUnpositionedFloatVector* unpositioned_floats,
......
...@@ -53,15 +53,16 @@ PositionFloat(const NGLogicalSize& float_available_size, ...@@ -53,15 +53,16 @@ PositionFloat(const NGLogicalSize& float_available_size,
// Positions the list of {@code unpositioned_floats}. Adds them as exclusions to // Positions the list of {@code unpositioned_floats}. Adds them as exclusions to
// {@code space}. // {@code space}.
CORE_EXPORT const NGPositionedFloatVector CORE_EXPORT void PositionFloats(
PositionFloats(const NGLogicalSize& float_available_size, const NGLogicalSize& float_available_size,
const NGLogicalSize& float_percentage_size, const NGLogicalSize& float_percentage_size,
const NGLogicalSize& float_replaced_percentage_size, const NGLogicalSize& float_replaced_percentage_size,
const NGBfcOffset& origin_bfc_offset, const NGBfcOffset& origin_bfc_offset,
LayoutUnit container_block_offset, LayoutUnit container_block_offset,
NGUnpositionedFloatVector& unpositioned_floats, NGUnpositionedFloatVector& unpositioned_floats,
const NGConstraintSpace& space, const NGConstraintSpace& space,
NGExclusionSpace* exclusion_space); NGExclusionSpace* exclusion_space,
NGPositionedFloatVector* positioned_floats);
// Add a pending float to the list. It will be committed (positioned) once we // Add a pending float to the list. It will be committed (positioned) once we
// have resolved the BFC block offset. // have resolved the BFC block offset.
......
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