OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "core/layout/ng/geometry/ng_margin_strut.h" | 5 #include "core/layout/ng/geometry/ng_margin_strut.h" |
6 | 6 |
7 #include "wtf/text/WTFString.h" | 7 #include "platform/wtf/text/WTFString.h" |
8 | 8 |
9 namespace blink { | 9 namespace blink { |
10 | 10 |
11 LayoutUnit NGMarginStrut::Sum() const { | 11 LayoutUnit NGMarginStrut::Sum() const { |
12 return margin + negative_margin; | 12 return margin + negative_margin; |
13 } | 13 } |
14 | 14 |
15 bool NGMarginStrut::operator==(const NGMarginStrut& other) const { | 15 bool NGMarginStrut::operator==(const NGMarginStrut& other) const { |
16 return margin == other.margin && negative_margin == other.negative_margin; | 16 return margin == other.margin && negative_margin == other.negative_margin; |
17 } | 17 } |
18 | 18 |
19 void NGMarginStrut::Append(const LayoutUnit& value) { | 19 void NGMarginStrut::Append(const LayoutUnit& value) { |
20 if (value < 0) { | 20 if (value < 0) { |
21 negative_margin = std::min(value, negative_margin); | 21 negative_margin = std::min(value, negative_margin); |
22 } else { | 22 } else { |
23 margin = std::max(value, margin); | 23 margin = std::max(value, margin); |
24 } | 24 } |
25 } | 25 } |
26 | 26 |
27 String NGMarginStrut::ToString() const { | 27 String NGMarginStrut::ToString() const { |
28 return String::Format("%d %d", margin.ToInt(), negative_margin.ToInt()); | 28 return String::Format("%d %d", margin.ToInt(), negative_margin.ToInt()); |
29 } | 29 } |
30 | 30 |
31 std::ostream& operator<<(std::ostream& stream, const NGMarginStrut& value) { | 31 std::ostream& operator<<(std::ostream& stream, const NGMarginStrut& value) { |
32 return stream << value.ToString(); | 32 return stream << value.ToString(); |
33 } | 33 } |
34 | 34 |
35 } // namespace blink | 35 } // namespace blink |
OLD | NEW |