Commit d47ace06 authored by Christian Biesinger's avatar Christian Biesinger Committed by Commit Bot

[layoutng] Give the positioned floats vector an inline capacity

For the cases where we store that vector on the stack, we can
easily give it an inline capacity and gain some performance.

There is one function that can take either a stack-based or
LayoutResult-based positioned floats vector; I made that a template
so it can accept either one.

Cq-Include-Trybots: luci.chromium.try:linux_layout_tests_layout_ng
Change-Id: I2afb67e03862f062864dd4d36c740b5c578041aa
Reviewed-on: https://chromium-review.googlesource.com/1226159Reviewed-by: default avatarIan Kilpatrick <ikilpatrick@chromium.org>
Commit-Queue: Christian Biesinger <cbiesinger@chromium.org>
Cr-Commit-Position: refs/heads/master@{#593686}
parent 47bf6523
...@@ -853,7 +853,7 @@ void NGInlineLayoutAlgorithm::PositionPendingFloats( ...@@ -853,7 +853,7 @@ 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 Vector<NGPositionedFloat> positioned_floats = const NGPositionedFloatVector positioned_floats =
PositionFloats(ConstraintSpace().AvailableSize(), PositionFloats(ConstraintSpace().AvailableSize(),
ConstraintSpace().PercentageResolutionSize(), ConstraintSpace().PercentageResolutionSize(),
ConstraintSpace().ReplacedPercentageResolutionSize(), ConstraintSpace().ReplacedPercentageResolutionSize(),
......
...@@ -2074,8 +2074,8 @@ void NGBlockLayoutAlgorithm::PositionPendingFloats( ...@@ -2074,8 +2074,8 @@ void NGBlockLayoutAlgorithm::PositionPendingFloats(
unpositioned_floats_.clear(); unpositioned_floats_.clear();
} }
void NGBlockLayoutAlgorithm::AddPositionedFloats( template <class Vec>
const Vector<NGPositionedFloat>& positioned_floats) { void NGBlockLayoutAlgorithm::AddPositionedFloats(const Vec& positioned_floats) {
DCHECK(container_builder_.BfcBlockOffset() || DCHECK(container_builder_.BfcBlockOffset() ||
ConstraintSpace().FloatsBfcBlockOffset()) ConstraintSpace().FloatsBfcBlockOffset())
<< "The parent BFC block offset should be known here"; << "The parent BFC block offset should be known here";
......
...@@ -11,6 +11,7 @@ ...@@ -11,6 +11,7 @@
#include "third_party/blink/renderer/core/layout/ng/geometry/ng_margin_strut.h" #include "third_party/blink/renderer/core/layout/ng/geometry/ng_margin_strut.h"
#include "third_party/blink/renderer/core/layout/ng/ng_block_break_token.h" #include "third_party/blink/renderer/core/layout/ng/ng_block_break_token.h"
#include "third_party/blink/renderer/core/layout/ng/ng_block_node.h" #include "third_party/blink/renderer/core/layout/ng/ng_block_node.h"
#include "third_party/blink/renderer/core/layout/ng/ng_floats_utils.h"
#include "third_party/blink/renderer/core/layout/ng/ng_fragment_builder.h" #include "third_party/blink/renderer/core/layout/ng/ng_fragment_builder.h"
#include "third_party/blink/renderer/core/layout/ng/ng_layout_algorithm.h" #include "third_party/blink/renderer/core/layout/ng/ng_layout_algorithm.h"
#include "third_party/blink/renderer/core/layout/ng/ng_unpositioned_float.h" #include "third_party/blink/renderer/core/layout/ng/ng_unpositioned_float.h"
...@@ -244,7 +245,8 @@ class CORE_EXPORT NGBlockLayoutAlgorithm ...@@ -244,7 +245,8 @@ class CORE_EXPORT NGBlockLayoutAlgorithm
void PositionPendingFloats(LayoutUnit origin_block_offset); void PositionPendingFloats(LayoutUnit origin_block_offset);
// Adds a set of positioned floats as children to the current fragment. // Adds a set of positioned floats as children to the current fragment.
void AddPositionedFloats(const Vector<NGPositionedFloat>& positioned_floats); template <class Vec>
void AddPositionedFloats(const Vec& positioned_floats);
// Positions a list marker for the specified block content. // Positions a list marker for the specified block content.
void PositionOrPropagateListMarker(const NGLayoutResult&, NGLogicalOffset*); void PositionOrPropagateListMarker(const NGLayoutResult&, NGLogicalOffset*);
......
...@@ -306,7 +306,7 @@ NGPositionedFloat PositionFloat( ...@@ -306,7 +306,7 @@ NGPositionedFloat PositionFloat(
return NGPositionedFloat(std::move(layout_result), float_bfc_offset); return NGPositionedFloat(std::move(layout_result), float_bfc_offset);
} }
const Vector<NGPositionedFloat> PositionFloats( const NGPositionedFloatVector 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,
...@@ -315,7 +315,7 @@ const Vector<NGPositionedFloat> PositionFloats( ...@@ -315,7 +315,7 @@ const Vector<NGPositionedFloat> PositionFloats(
NGUnpositionedFloatVector& unpositioned_floats, NGUnpositionedFloatVector& unpositioned_floats,
const NGConstraintSpace& space, const NGConstraintSpace& space,
NGExclusionSpace* exclusion_space) { NGExclusionSpace* exclusion_space) {
Vector<NGPositionedFloat> positioned_floats; NGPositionedFloatVector positioned_floats;
positioned_floats.ReserveCapacity(unpositioned_floats.size()); positioned_floats.ReserveCapacity(unpositioned_floats.size());
for (NGUnpositionedFloat& unpositioned_float : unpositioned_floats) { for (NGUnpositionedFloat& unpositioned_float : unpositioned_floats) {
......
...@@ -23,6 +23,8 @@ struct NGLogicalSize; ...@@ -23,6 +23,8 @@ struct NGLogicalSize;
struct NGPositionedFloat; struct NGPositionedFloat;
struct NGUnpositionedFloat; struct NGUnpositionedFloat;
typedef Vector<NGPositionedFloat, 8> NGPositionedFloatVector;
enum NGFloatTypeValue { enum NGFloatTypeValue {
kFloatTypeNone = 0b00, kFloatTypeNone = 0b00,
kFloatTypeLeft = 0b01, kFloatTypeLeft = 0b01,
...@@ -51,15 +53,15 @@ PositionFloat(const NGLogicalSize& float_available_size, ...@@ -51,15 +53,15 @@ 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 Vector<NGPositionedFloat> PositionFloats( CORE_EXPORT const NGPositionedFloatVector
const NGLogicalSize& float_available_size, PositionFloats(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);
// 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