Commit 53999bf4 authored by Christian Biesinger's avatar Christian Biesinger Committed by Commit Bot

[layoutng] Add move constructors to ng_exclusion_space.h for performance

Cq-Include-Trybots: luci.chromium.try:linux_layout_tests_layout_ng
Change-Id: I2c47b2a941163b30b3a37bd9ef2c08c9b9ccd2ed
Reviewed-on: https://chromium-review.googlesource.com/1212382Reviewed-by: default avatarEmil A Eklund <eae@chromium.org>
Reviewed-by: default avatarIan Kilpatrick <ikilpatrick@chromium.org>
Commit-Queue: Christian Biesinger <cbiesinger@chromium.org>
Cr-Commit-Position: refs/heads/master@{#590472}
parent a73abb20
...@@ -178,6 +178,21 @@ NGExclusionSpace::NGExclusionSpace(const NGExclusionSpace& other) ...@@ -178,6 +178,21 @@ NGExclusionSpace::NGExclusionSpace(const NGExclusionSpace& other)
other.derived_geometry_ = nullptr; other.derived_geometry_ = nullptr;
} }
NGExclusionSpace::NGExclusionSpace(NGExclusionSpace&& other)
: exclusions_(std::move(other.exclusions_)),
num_exclusions_(other.num_exclusions_),
both_clear_offset_(other.both_clear_offset_),
derived_geometry_(std::move(other.derived_geometry_)) {}
NGExclusionSpace& NGExclusionSpace::operator=(const NGExclusionSpace& other) {
exclusions_ = other.exclusions_;
num_exclusions_ = other.num_exclusions_;
both_clear_offset_ = other.both_clear_offset_;
derived_geometry_ = std::move(other.derived_geometry_);
other.derived_geometry_ = nullptr;
return *this;
}
NGExclusionSpace::DerivedGeometry::DerivedGeometry() NGExclusionSpace::DerivedGeometry::DerivedGeometry()
: last_float_block_start_(LayoutUnit::Min()), : last_float_block_start_(LayoutUnit::Min()),
left_float_clear_offset_(LayoutUnit::Min()), left_float_clear_offset_(LayoutUnit::Min()),
......
...@@ -12,6 +12,7 @@ ...@@ -12,6 +12,7 @@
#include "third_party/blink/renderer/core/layout/ng/geometry/ng_bfc_rect.h" #include "third_party/blink/renderer/core/layout/ng/geometry/ng_bfc_rect.h"
#include "third_party/blink/renderer/core/style/computed_style_constants.h" #include "third_party/blink/renderer/core/style/computed_style_constants.h"
#include "third_party/blink/renderer/platform/layout_unit.h" #include "third_party/blink/renderer/platform/layout_unit.h"
#include "third_party/blink/renderer/platform/wtf/allocator.h"
#include "third_party/blink/renderer/platform/wtf/ref_vector.h" #include "third_party/blink/renderer/platform/wtf/ref_vector.h"
#include "third_party/blink/renderer/platform/wtf/vector.h" #include "third_party/blink/renderer/platform/wtf/vector.h"
...@@ -30,6 +31,8 @@ class CORE_EXPORT NGExclusionSpace { ...@@ -30,6 +31,8 @@ class CORE_EXPORT NGExclusionSpace {
public: public:
NGExclusionSpace(); NGExclusionSpace();
NGExclusionSpace(const NGExclusionSpace&); NGExclusionSpace(const NGExclusionSpace&);
NGExclusionSpace(NGExclusionSpace&&) noexcept;
NGExclusionSpace& operator=(const NGExclusionSpace&);
~NGExclusionSpace(){}; ~NGExclusionSpace(){};
void Add(scoped_refptr<const NGExclusion> exclusion); void Add(scoped_refptr<const NGExclusion> exclusion);
...@@ -143,6 +146,26 @@ class CORE_EXPORT NGExclusionSpace { ...@@ -143,6 +146,26 @@ class CORE_EXPORT NGExclusionSpace {
base::AdoptRef(new NGShapeExclusions(*other.shape_exclusions))), base::AdoptRef(new NGShapeExclusions(*other.shape_exclusions))),
has_shape_exclusions(other.has_shape_exclusions) {} has_shape_exclusions(other.has_shape_exclusions) {}
NGShelf(NGShelf&& other) noexcept
: block_offset(other.block_offset),
line_left(other.line_left),
line_right(other.line_right),
line_left_edges(std::move(other.line_left_edges)),
line_right_edges(std::move(other.line_right_edges)),
shape_exclusions(std::move(other.shape_exclusions)),
has_shape_exclusions(other.has_shape_exclusions) {}
NGShelf& operator=(NGShelf&& other) noexcept {
block_offset = other.block_offset;
line_left = other.line_left;
line_right = other.line_right;
line_left_edges = std::move(other.line_left_edges);
line_right_edges = std::move(other.line_right_edges);
shape_exclusions = std::move(other.shape_exclusions);
has_shape_exclusions = other.has_shape_exclusions;
return *this;
}
LayoutUnit block_offset; LayoutUnit block_offset;
LayoutUnit line_left; LayoutUnit line_left;
LayoutUnit line_right; LayoutUnit line_right;
...@@ -192,6 +215,12 @@ class CORE_EXPORT NGExclusionSpace { ...@@ -192,6 +215,12 @@ class CORE_EXPORT NGExclusionSpace {
// derived_geometry_ data-structure. // derived_geometry_ data-structure.
struct DerivedGeometry { struct DerivedGeometry {
DerivedGeometry(); DerivedGeometry();
DerivedGeometry(DerivedGeometry&& o) noexcept
: shelves_(std::move(o.shelves_)),
opportunities_(std::move(o.opportunities_)),
last_float_block_start_(o.last_float_block_start_),
left_float_clear_offset_(o.left_float_clear_offset_),
right_float_clear_offset_(o.right_float_clear_offset_) {}
void Add(const NGExclusion& exclusion); void Add(const NGExclusion& exclusion);
......
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