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

[layoutng] Use Shrink(0) rather than resize(0)

This allows me to remove the otherwise-unnecessary constructors
I added in https://chromium-review.googlesource.com/c/chromium/src/+/1286884

R=eae@chromium.org

Cq-Include-Trybots: luci.chromium.try:linux_layout_tests_layout_ng
Change-Id: I720e6a128b6aa16db734bbc4bad94c0af827782d
Reviewed-on: https://chromium-review.googlesource.com/c/1289304Reviewed-by: default avatarAleks Totic <atotic@chromium.org>
Reviewed-by: default avatarEmil A Eklund <eae@chromium.org>
Commit-Queue: Christian Biesinger <cbiesinger@chromium.org>
Commit-Queue: Emil A Eklund <eae@chromium.org>
Cr-Commit-Position: refs/heads/master@{#600894}
parent fa9af6af
...@@ -725,8 +725,8 @@ scoped_refptr<NGLayoutResult> NGInlineLayoutAlgorithm::Layout() { ...@@ -725,8 +725,8 @@ scoped_refptr<NGLayoutResult> NGInlineLayoutAlgorithm::Layout() {
#endif #endif
// Reset any state that may have been modified in a previous pass. // Reset any state that may have been modified in a previous pass.
positioned_floats.resize(0); positioned_floats.Shrink(0);
unpositioned_floats_.resize(0); unpositioned_floats_.Shrink(0);
container_builder_.Reset(); container_builder_.Reset();
exclusion_space = initial_exclusion_space; exclusion_space = initial_exclusion_space;
...@@ -876,7 +876,7 @@ void NGInlineLayoutAlgorithm::PositionPendingFloats( ...@@ -876,7 +876,7 @@ void NGInlineLayoutAlgorithm::PositionPendingFloats(
<< "The floats BFC block offset should be known here"; << "The floats BFC block offset should be known here";
if (BreakToken() && BreakToken()->IgnoreFloats()) { if (BreakToken() && BreakToken()->IgnoreFloats()) {
unpositioned_floats_.resize(0); unpositioned_floats_.Shrink(0);
return; return;
} }
...@@ -896,7 +896,7 @@ void NGInlineLayoutAlgorithm::PositionPendingFloats( ...@@ -896,7 +896,7 @@ void NGInlineLayoutAlgorithm::PositionPendingFloats(
ConstraintSpace(), exclusion_space, &positioned_floats); ConstraintSpace(), exclusion_space, &positioned_floats);
positioned_floats_.AppendVector(positioned_floats); positioned_floats_.AppendVector(positioned_floats);
unpositioned_floats_.resize(0); unpositioned_floats_.Shrink(0);
} }
void NGInlineLayoutAlgorithm::BidiReorder() { void NGInlineLayoutAlgorithm::BidiReorder() {
......
...@@ -733,7 +733,7 @@ static LayoutUnit ComputeContentSize( ...@@ -733,7 +733,7 @@ static LayoutUnit ComputeContentSize(
nullptr /* container_builder */, &empty_exclusion_space, 0u, nullptr /* container_builder */, &empty_exclusion_space, 0u,
line_opportunity, nullptr /* break_token */); line_opportunity, nullptr /* break_token */);
do { do {
unpositioned_floats.resize(0); unpositioned_floats.Shrink(0);
NGLineInfo line_info; NGLineInfo line_info;
line_breaker.NextLine(&line_info); line_breaker.NextLine(&line_info);
......
...@@ -2089,7 +2089,7 @@ void NGBlockLayoutAlgorithm::PositionPendingFloats( ...@@ -2089,7 +2089,7 @@ void NGBlockLayoutAlgorithm::PositionPendingFloats(
AddPositionedFloats(positioned_floats); AddPositionedFloats(positioned_floats);
unpositioned_floats_.resize(0); unpositioned_floats_.Shrink(0);
} }
template <class Vec> template <class Vec>
......
...@@ -171,7 +171,7 @@ void NGContainerFragmentBuilder::GetAndClearOutOfFlowDescendantCandidates( ...@@ -171,7 +171,7 @@ void NGContainerFragmentBuilder::GetAndClearOutOfFlowDescendantCandidates(
// The descendant may be a "position: absolute" which contains a "position: // The descendant may be a "position: absolute" which contains a "position:
// fixed" for example. (This fragment isn't the containing block for the // fixed" for example. (This fragment isn't the containing block for the
// fixed descendant). // fixed descendant).
oof_positioned_candidates_.resize(0); oof_positioned_candidates_.Shrink(0);
} }
void NGContainerFragmentBuilder::MoveOutOfFlowDescendantCandidatesToDescendants( void NGContainerFragmentBuilder::MoveOutOfFlowDescendantCandidatesToDescendants(
......
...@@ -206,10 +206,6 @@ class CORE_EXPORT NGContainerFragmentBuilder : public NGBaseFragmentBuilder { ...@@ -206,10 +206,6 @@ class CORE_EXPORT NGContainerFragmentBuilder : public NGBaseFragmentBuilder {
child_offset(child_offset_arg), child_offset(child_offset_arg),
is_line_relative(true), is_line_relative(true),
line_direction(line_direction_arg) {} line_direction(line_direction_arg) {}
// This constructor is not meant to be called, but required so we can use
// Vector::resize(0).
NGOutOfFlowPositionedCandidate() {}
}; };
NGContainerFragmentBuilder(scoped_refptr<const ComputedStyle>, NGContainerFragmentBuilder(scoped_refptr<const ComputedStyle>,
......
...@@ -74,7 +74,7 @@ void NGOutOfFlowLayoutPart::Run(LayoutBox* only_layout) { ...@@ -74,7 +74,7 @@ void NGOutOfFlowLayoutPart::Run(LayoutBox* only_layout) {
} }
// Sweep any descendants that might have been added. // Sweep any descendants that might have been added.
// This happens when an absolute container has a fixed child. // This happens when an absolute container has a fixed child.
descendant_candidates.resize(0); descendant_candidates.Shrink(0);
container_builder_->GetAndClearOutOfFlowDescendantCandidates( container_builder_->GetAndClearOutOfFlowDescendantCandidates(
&descendant_candidates, container_builder_->GetLayoutObject()); &descendant_candidates, container_builder_->GetLayoutObject());
} }
......
...@@ -33,10 +33,6 @@ struct CORE_EXPORT NGOutOfFlowPositionedDescendant { ...@@ -33,10 +33,6 @@ struct CORE_EXPORT NGOutOfFlowPositionedDescendant {
: node(node_param), : node(node_param),
static_position(static_position_param), static_position(static_position_param),
inline_container(inline_container_param) {} inline_container(inline_container_param) {}
// This constructor is not meant to be called, but required so we can use
// Vector::resize(0).
NGOutOfFlowPositionedDescendant() : node(nullptr) {}
}; };
} // namespace blink } // namespace blink
......
...@@ -15,10 +15,6 @@ class NGLayoutResult; ...@@ -15,10 +15,6 @@ class NGLayoutResult;
// Contains the information necessary for copying back data to a FloatingObject. // Contains the information necessary for copying back data to a FloatingObject.
struct CORE_EXPORT NGPositionedFloat { struct CORE_EXPORT NGPositionedFloat {
// This constructor is not meant to be called, but required so we can use
// Vector::resize(0).
NGPositionedFloat() {}
NGPositionedFloat(scoped_refptr<NGLayoutResult> layout_result, NGPositionedFloat(scoped_refptr<NGLayoutResult> layout_result,
const NGBfcOffset& bfc_offset); const NGBfcOffset& bfc_offset);
~NGPositionedFloat(); ~NGPositionedFloat();
......
...@@ -20,10 +20,6 @@ struct CORE_EXPORT NGUnpositionedFloat final { ...@@ -20,10 +20,6 @@ struct CORE_EXPORT NGUnpositionedFloat final {
DISALLOW_NEW(); DISALLOW_NEW();
public: public:
// This constructor is not meant to be called, but required so we can use
// Vector::resize(0).
NGUnpositionedFloat() : node(nullptr) {}
NGUnpositionedFloat(NGBlockNode node, const NGBlockBreakToken* token) NGUnpositionedFloat(NGBlockNode node, const NGBlockBreakToken* token)
: node(node), token(token) {} : node(node), token(token) {}
......
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