Chromium Code Reviews| Index: third_party/WebKit/Source/core/layout/ng/ng_units.h |
| diff --git a/third_party/WebKit/Source/core/layout/ng/ng_units.h b/third_party/WebKit/Source/core/layout/ng/ng_units.h |
| index 63bd0b37175a569d88d98a42e5479cdf1c1e5a96..9433440e71811a45a354d6af68d5f3fc16539d5e 100644 |
| --- a/third_party/WebKit/Source/core/layout/ng/ng_units.h |
| +++ b/third_party/WebKit/Source/core/layout/ng/ng_units.h |
| @@ -44,6 +44,12 @@ struct NGLogicalSize { |
| bool IsEmpty() const { |
| return inline_size == LayoutUnit() || block_size == LayoutUnit(); |
| } |
| + |
| + private: |
| + friend class NGBlockLayoutAlgorithmTest; |
|
ikilpatrick
2017/01/24 00:22:13
can you ad a comment here as to why friend class?
Gleb Lanbin
2017/01/24 04:38:02
Done.
|
| + NGLogicalSize(int inline_size, int block_size) |
| + : inline_size(LayoutUnit(inline_size)), |
| + block_size(LayoutUnit(block_size)) {} |
| }; |
| inline std::ostream& operator<<(std::ostream& stream, |
| @@ -77,9 +83,11 @@ struct NGLogicalOffset { |
| bool operator==(const NGLogicalOffset& other) const; |
| NGLogicalOffset operator+(const NGLogicalOffset& other) const; |
| - |
| NGLogicalOffset& operator+=(const NGLogicalOffset& other); |
| + NGLogicalOffset operator-(const NGLogicalOffset& other) const; |
| + NGLogicalOffset& operator-=(const NGLogicalOffset& other); |
| + |
| bool operator>(const NGLogicalOffset& other) const; |
| bool operator>=(const NGLogicalOffset& other) const; |
| @@ -87,6 +95,12 @@ struct NGLogicalOffset { |
| bool operator<=(const NGLogicalOffset& other) const; |
| String ToString() const; |
| + |
| + private: |
| + friend class NGBlockLayoutAlgorithmTest; |
|
ikilpatrick
2017/01/24 00:22:13
as above.
Gleb Lanbin
2017/01/24 04:38:02
Done.
|
| + NGLogicalOffset(int inline_offset, int block_offset) |
| + : inline_offset(LayoutUnit(inline_offset)), |
| + block_offset(LayoutUnit(block_offset)) {} |
| }; |
| CORE_EXPORT inline std::ostream& operator<<(std::ostream& os, |
| @@ -105,8 +119,13 @@ struct NGPhysicalOffset { |
| NGPhysicalOffset operator+(const NGPhysicalOffset& other) const; |
| NGPhysicalOffset& operator+=(const NGPhysicalOffset& other); |
| + |
| NGPhysicalOffset operator-(const NGPhysicalOffset& other) const; |
| NGPhysicalOffset& operator-=(const NGPhysicalOffset& other); |
| + |
| + String ToString() const { |
| + return String::format("%dx%d", left.toInt(), top.toInt()); |
| + } |
| }; |
| struct NGPhysicalSize { |
| @@ -139,6 +158,8 @@ struct NGPhysicalRect { |
| // TODO(glebl): move to a separate file in layout/ng/units. |
| struct CORE_EXPORT NGLogicalRect { |
| NGLogicalRect() {} |
| + NGLogicalRect(const NGLogicalOffset& offset, const NGLogicalSize& size) |
| + : offset(offset), size(size) {} |
| NGLogicalRect(LayoutUnit inline_offset, |
| LayoutUnit block_offset, |
| LayoutUnit inline_size, |
| @@ -197,8 +218,16 @@ struct CORE_EXPORT NGExclusion { |
| // Type of this exclusion. |
| Type type; |
| + |
| + bool operator==(const NGExclusion& other) const; |
| + String ToString() const; |
| }; |
| +inline std::ostream& operator<<(std::ostream& stream, |
| + const NGExclusion& value) { |
| + return stream << value.ToString(); |
| +} |
| + |
| struct CORE_EXPORT NGExclusions { |
| // Default constructor. |
| NGExclusions(); |
| @@ -266,10 +295,21 @@ struct CORE_EXPORT NGBoxStrut { |
| } |
| bool operator==(const NGBoxStrut& other) const; |
| + |
| + String ToString() const { |
| + return String::format("Inline: (%d %d) Block: (%d %d)", |
| + inline_start.toInt(), inline_end.toInt(), |
| + block_start.toInt(), block_end.toInt()); |
| + } |
| }; |
| +inline std::ostream& operator<<(std::ostream& stream, const NGBoxStrut& value) { |
| + return stream << value.ToString(); |
| +} |
| + |
| // This struct is used for the margin collapsing calculation. |
| -struct CORE_EXPORT NGMarginStrut { |
| +// TODO(glebl): Deprecated. It's being replaced by NGMarginStrut |
| +struct CORE_EXPORT NGDeprecatedMarginStrut { |
| LayoutUnit margin_block_start; |
| LayoutUnit margin_block_end; |
| @@ -287,7 +327,23 @@ struct CORE_EXPORT NGMarginStrut { |
| String ToString() const; |
| + bool operator==(const NGDeprecatedMarginStrut& other) const; |
| +}; |
| + |
| +// This struct is used for the margin collapsing calculation. |
| +struct CORE_EXPORT NGMarginStrut { |
| + LayoutUnit margin; |
| + LayoutUnit negative_margin; |
| + |
| bool operator==(const NGMarginStrut& other) const; |
| + |
| + void Append(const LayoutUnit& value); |
| + |
| + LayoutUnit Collapse() const; |
| + |
| + LayoutUnit CollapseWith(const NGMarginStrut& other) const; |
| + |
| + String ToString() const; |
| }; |
| inline std::ostream& operator<<(std::ostream& stream, |