Chromium Code Reviews| Index: third_party/WebKit/Source/core/layout/ng/ng_units.cc |
| diff --git a/third_party/WebKit/Source/core/layout/ng/ng_units.cc b/third_party/WebKit/Source/core/layout/ng/ng_units.cc |
| index 5ca4d0d24455acb8e2b47757ddf99b0e523bbeb0..36a778031fa14cf55982a35dd7fd166498d8752d 100644 |
| --- a/third_party/WebKit/Source/core/layout/ng/ng_units.cc |
| +++ b/third_party/WebKit/Source/core/layout/ng/ng_units.cc |
| @@ -133,6 +133,16 @@ bool NGLogicalOffset::operator<=(const NGLogicalOffset& other) const { |
| block_offset <= other.block_offset; |
| } |
| +NGLogicalOffset NGLogicalOffset::operator-(const NGLogicalOffset& other) const { |
| + return NGLogicalOffset{this->inline_offset - other.inline_offset, |
| + this->block_offset - other.block_offset}; |
| +} |
| + |
| +NGLogicalOffset& NGLogicalOffset::operator-=(const NGLogicalOffset& other) { |
| + *this = *this - other; |
| + return *this; |
| +} |
| + |
| String NGLogicalOffset::ToString() const { |
| return String::format("%dx%d", inline_offset.toInt(), block_offset.toInt()); |
| } |
| @@ -192,11 +202,11 @@ NGBoxStrut NGPhysicalBoxStrut::ConvertToLogical(NGWritingMode writing_mode, |
| return strut; |
| } |
| -LayoutUnit NGMarginStrut::BlockEndSum() const { |
| +LayoutUnit NGDeprecatedMarginStrut::BlockEndSum() const { |
| return margin_block_end + negative_margin_block_end; |
| } |
| -void NGMarginStrut::AppendMarginBlockStart(const LayoutUnit& value) { |
| +void NGDeprecatedMarginStrut::AppendMarginBlockStart(const LayoutUnit& value) { |
| if (value < 0) { |
| negative_margin_block_start = |
| -std::max(value.abs(), negative_margin_block_start.abs()); |
| @@ -205,7 +215,7 @@ void NGMarginStrut::AppendMarginBlockStart(const LayoutUnit& value) { |
| } |
| } |
| -void NGMarginStrut::AppendMarginBlockEnd(const LayoutUnit& value) { |
| +void NGDeprecatedMarginStrut::AppendMarginBlockEnd(const LayoutUnit& value) { |
| if (value < 0) { |
| negative_margin_block_end = |
| -std::max(value.abs(), negative_margin_block_end.abs()); |
| @@ -214,7 +224,7 @@ void NGMarginStrut::AppendMarginBlockEnd(const LayoutUnit& value) { |
| } |
| } |
| -void NGMarginStrut::SetMarginBlockStart(const LayoutUnit& value) { |
| +void NGDeprecatedMarginStrut::SetMarginBlockStart(const LayoutUnit& value) { |
| if (value < 0) { |
| negative_margin_block_start = value; |
| } else { |
| @@ -222,7 +232,7 @@ void NGMarginStrut::SetMarginBlockStart(const LayoutUnit& value) { |
| } |
| } |
| -void NGMarginStrut::SetMarginBlockEnd(const LayoutUnit& value) { |
| +void NGDeprecatedMarginStrut::SetMarginBlockEnd(const LayoutUnit& value) { |
| if (value < 0) { |
| negative_margin_block_end = value; |
| } else { |
| @@ -230,18 +240,19 @@ void NGMarginStrut::SetMarginBlockEnd(const LayoutUnit& value) { |
| } |
| } |
| -String NGMarginStrut::ToString() const { |
| +String NGDeprecatedMarginStrut::ToString() const { |
| return String::format("Start: (%d %d) End: (%d %d)", |
| margin_block_start.toInt(), margin_block_end.toInt(), |
| negative_margin_block_start.toInt(), |
| negative_margin_block_end.toInt()); |
| } |
| -bool NGMarginStrut::IsEmpty() const { |
| - return *this == NGMarginStrut(); |
| +bool NGDeprecatedMarginStrut::IsEmpty() const { |
| + return *this == NGDeprecatedMarginStrut(); |
| } |
| -bool NGMarginStrut::operator==(const NGMarginStrut& other) const { |
| +bool NGDeprecatedMarginStrut::operator==( |
| + const NGDeprecatedMarginStrut& other) const { |
| return std::tie(other.margin_block_start, other.margin_block_end, |
| other.negative_margin_block_start, |
| other.negative_margin_block_end) == |
| @@ -249,6 +260,41 @@ bool NGMarginStrut::operator==(const NGMarginStrut& other) const { |
| negative_margin_block_start, negative_margin_block_end); |
| } |
| +void NGMarginStrut::Append(const LayoutUnit& value) { |
| + if (value < 0) { |
| + negative_margin = std::min(value, negative_margin); |
| + } else { |
| + margin = std::max(value, margin); |
| + } |
| +} |
| + |
| +LayoutUnit NGMarginStrut::Collapse() const { |
| + return margin + negative_margin; |
| +} |
| + |
| +LayoutUnit NGMarginStrut::CollapseWith(const NGMarginStrut& other) const { |
|
ikilpatrick
2017/01/24 00:22:13
I don't think you'll need this, re: 0 block size c
Gleb Lanbin
2017/01/24 04:38:02
deleted for now.
|
| + return std::max(margin, other.margin) + |
| + std::min(negative_margin, other.negative_margin); |
| +} |
| + |
| +String NGMarginStrut::ToString() const { |
| + return String::format("%d %d", margin.toInt(), negative_margin.toInt()); |
| +} |
| + |
| +bool NGMarginStrut::operator==(const NGMarginStrut& other) const { |
| + return std::tie(other.margin, other.negative_margin) == |
| + std::tie(margin, negative_margin); |
| +} |
| + |
| +bool NGExclusion::operator==(const NGExclusion& other) const { |
| + return std::tie(other.rect, other.type) == std::tie(rect, type); |
| +} |
| + |
| +String NGExclusion::ToString() const { |
| + return String::format("Rect: %s Type: %d", rect.ToString().ascii().data(), |
| + type); |
| +} |
| + |
| NGExclusions::NGExclusions() |
| : last_left_float(nullptr), last_right_float(nullptr) {} |