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

[layoutng] Minor code cleanup

Use =default in some places where we can, to avoid hand-writing
move constructors and move assignment operators.

Also adds a move constructor to NG{Unp,P}ositionedFloat and adds a
missed std::move call.

R=eae@chromium.org,ikilpatrick@chromium.org

Cq-Include-Trybots: luci.chromium.try:linux_layout_tests_layout_ng
Change-Id: I8c3c850d495b455a9a6dddff0b62f3dcf1927c64
Reviewed-on: https://chromium-review.googlesource.com/1226008Reviewed-by: default avatarIan Kilpatrick <ikilpatrick@chromium.org>
Commit-Queue: Christian Biesinger <cbiesinger@chromium.org>
Cr-Commit-Position: refs/heads/master@{#591476}
parent 4653c999
...@@ -179,12 +179,8 @@ NGExclusionSpaceInternal::NGExclusionSpaceInternal( ...@@ -179,12 +179,8 @@ NGExclusionSpaceInternal::NGExclusionSpaceInternal(
other.derived_geometry_ = nullptr; other.derived_geometry_ = nullptr;
} }
NGExclusionSpaceInternal::NGExclusionSpaceInternal( NGExclusionSpaceInternal::NGExclusionSpaceInternal(NGExclusionSpaceInternal&&) =
NGExclusionSpaceInternal&& other) default;
: exclusions_(std::move(other.exclusions_)),
num_exclusions_(other.num_exclusions_),
both_clear_offset_(other.both_clear_offset_),
derived_geometry_(std::move(other.derived_geometry_)) {}
NGExclusionSpaceInternal& NGExclusionSpaceInternal::operator=( NGExclusionSpaceInternal& NGExclusionSpaceInternal::operator=(
const NGExclusionSpaceInternal& other) { const NGExclusionSpaceInternal& other) {
...@@ -196,6 +192,9 @@ NGExclusionSpaceInternal& NGExclusionSpaceInternal::operator=( ...@@ -196,6 +192,9 @@ NGExclusionSpaceInternal& NGExclusionSpaceInternal::operator=(
return *this; return *this;
} }
NGExclusionSpaceInternal& NGExclusionSpaceInternal::operator=(
NGExclusionSpaceInternal&&) = default;
NGExclusionSpaceInternal::DerivedGeometry::DerivedGeometry() NGExclusionSpaceInternal::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()),
......
...@@ -31,7 +31,8 @@ class CORE_EXPORT NGExclusionSpaceInternal { ...@@ -31,7 +31,8 @@ class CORE_EXPORT NGExclusionSpaceInternal {
NGExclusionSpaceInternal(const NGExclusionSpaceInternal&); NGExclusionSpaceInternal(const NGExclusionSpaceInternal&);
NGExclusionSpaceInternal(NGExclusionSpaceInternal&&) noexcept; NGExclusionSpaceInternal(NGExclusionSpaceInternal&&) noexcept;
NGExclusionSpaceInternal& operator=(const NGExclusionSpaceInternal&); NGExclusionSpaceInternal& operator=(const NGExclusionSpaceInternal&);
~NGExclusionSpaceInternal(){}; NGExclusionSpaceInternal& operator=(NGExclusionSpaceInternal&&);
~NGExclusionSpaceInternal() {}
void Add(scoped_refptr<const NGExclusion> exclusion); void Add(scoped_refptr<const NGExclusion> exclusion);
...@@ -138,25 +139,8 @@ class CORE_EXPORT NGExclusionSpaceInternal { ...@@ -138,25 +139,8 @@ class CORE_EXPORT NGExclusionSpaceInternal {
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 NGShelf(NGShelf&& other) noexcept = default;
: block_offset(other.block_offset), NGShelf& operator=(NGShelf&& other) noexcept = default;
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;
...@@ -207,12 +191,7 @@ class CORE_EXPORT NGExclusionSpaceInternal { ...@@ -207,12 +191,7 @@ class CORE_EXPORT NGExclusionSpaceInternal {
// derived_geometry_ data-structure. // derived_geometry_ data-structure.
struct DerivedGeometry { struct DerivedGeometry {
DerivedGeometry(); DerivedGeometry();
DerivedGeometry(DerivedGeometry&& o) noexcept DerivedGeometry(DerivedGeometry&& o) noexcept = default;
: 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);
...@@ -296,8 +275,7 @@ class CORE_EXPORT NGExclusionSpace { ...@@ -296,8 +275,7 @@ class CORE_EXPORT NGExclusionSpace {
: exclusion_space_(other.exclusion_space_ ? new NGExclusionSpaceInternal( : exclusion_space_(other.exclusion_space_ ? new NGExclusionSpaceInternal(
*other.exclusion_space_) *other.exclusion_space_)
: nullptr) {} : nullptr) {}
NGExclusionSpace(NGExclusionSpace&& other) noexcept NGExclusionSpace(NGExclusionSpace&& other) noexcept = default;
: exclusion_space_(std::move(other.exclusion_space_)) {}
NGExclusionSpace& operator=(const NGExclusionSpace& other) { NGExclusionSpace& operator=(const NGExclusionSpace& other) {
exclusion_space_ = other.exclusion_space_ exclusion_space_ = other.exclusion_space_
...@@ -306,11 +284,12 @@ class CORE_EXPORT NGExclusionSpace { ...@@ -306,11 +284,12 @@ class CORE_EXPORT NGExclusionSpace {
: nullptr; : nullptr;
return *this; return *this;
} }
NGExclusionSpace& operator=(NGExclusionSpace&& other) = default;
void Add(scoped_refptr<const NGExclusion> exclusion) { void Add(scoped_refptr<const NGExclusion> exclusion) {
if (!exclusion_space_) if (!exclusion_space_)
exclusion_space_ = std::make_unique<NGExclusionSpaceInternal>(); exclusion_space_ = std::make_unique<NGExclusionSpaceInternal>();
exclusion_space_->Add(exclusion); exclusion_space_->Add(std::move(exclusion));
} }
// Returns a layout opportunity, within the BFC. // Returns a layout opportunity, within the BFC.
......
...@@ -18,6 +18,10 @@ struct CORE_EXPORT NGPositionedFloat { ...@@ -18,6 +18,10 @@ struct CORE_EXPORT NGPositionedFloat {
NGPositionedFloat(scoped_refptr<NGLayoutResult> layout_result, NGPositionedFloat(scoped_refptr<NGLayoutResult> layout_result,
const NGBfcOffset& bfc_offset); const NGBfcOffset& bfc_offset);
~NGPositionedFloat(); ~NGPositionedFloat();
NGPositionedFloat(NGPositionedFloat&&) noexcept = default;
NGPositionedFloat(const NGPositionedFloat&) = default;
NGPositionedFloat& operator=(NGPositionedFloat&&) = default;
NGPositionedFloat& operator=(const NGPositionedFloat&) = default;
scoped_refptr<NGLayoutResult> layout_result; scoped_refptr<NGLayoutResult> layout_result;
NGBfcOffset bfc_offset; NGBfcOffset bfc_offset;
......
...@@ -22,6 +22,11 @@ struct CORE_EXPORT NGUnpositionedFloat final { ...@@ -22,6 +22,11 @@ struct CORE_EXPORT NGUnpositionedFloat final {
NGUnpositionedFloat(NGBlockNode node, NGBlockBreakToken* token); NGUnpositionedFloat(NGBlockNode node, NGBlockBreakToken* token);
~NGUnpositionedFloat(); ~NGUnpositionedFloat();
NGUnpositionedFloat(NGUnpositionedFloat&&) noexcept = default;
NGUnpositionedFloat(const NGUnpositionedFloat&) noexcept = default;
NGUnpositionedFloat& operator=(NGUnpositionedFloat&&) = default;
NGUnpositionedFloat& operator=(const NGUnpositionedFloat&) = default;
NGBlockNode node; NGBlockNode node;
scoped_refptr<NGBlockBreakToken> token; scoped_refptr<NGBlockBreakToken> 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