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_logical_rect.h" | 5 #include "core/layout/ng/geometry/ng_logical_rect.h" |
6 | 6 |
7 #include "wtf/text/WTFString.h" | 7 #include "wtf/text/WTFString.h" |
8 | 8 |
9 namespace blink { | 9 namespace blink { |
10 | 10 |
11 bool NGLogicalRect::IsEmpty() const { | 11 bool NGLogicalRect::IsEmpty() const { |
12 return size.IsEmpty() && offset.inline_offset == LayoutUnit() && | 12 return size.IsEmpty() && offset.inline_offset == LayoutUnit() && |
13 offset.block_offset == LayoutUnit(); | 13 offset.block_offset == LayoutUnit(); |
14 } | 14 } |
15 | 15 |
16 bool NGLogicalRect::IsContained(const NGLogicalRect& other) const { | 16 bool NGLogicalRect::IsContained(const NGLogicalRect& other) const { |
17 return !(InlineEndOffset() <= other.InlineStartOffset() || | 17 return !(InlineEndOffset() <= other.InlineStartOffset() || |
18 BlockEndOffset() <= other.BlockStartOffset() || | 18 BlockEndOffset() <= other.BlockStartOffset() || |
19 InlineStartOffset() >= other.InlineEndOffset() || | 19 InlineStartOffset() >= other.InlineEndOffset() || |
20 BlockStartOffset() >= other.BlockEndOffset()); | 20 BlockStartOffset() >= other.BlockEndOffset()); |
21 } | 21 } |
22 | 22 |
23 bool NGLogicalRect::operator==(const NGLogicalRect& other) const { | 23 bool NGLogicalRect::operator==(const NGLogicalRect& other) const { |
24 return std::tie(other.offset, other.size) == std::tie(offset, size); | 24 return std::tie(other.offset, other.size) == std::tie(offset, size); |
25 } | 25 } |
26 | 26 |
27 String NGLogicalRect::ToString() const { | 27 String NGLogicalRect::ToString() const { |
28 return String::format("%s,%s %sx%s", | 28 return IsEmpty() |
29 offset.inline_offset.toString().ascii().data(), | 29 ? "(empty)" |
30 offset.block_offset.toString().ascii().data(), | 30 : String::format("%sx%s at (%s,%s)", |
31 size.inline_size.toString().ascii().data(), | 31 size.inline_size.toString().ascii().data(), |
32 size.block_size.toString().ascii().data()); | 32 size.block_size.toString().ascii().data(), |
| 33 offset.inline_offset.toString().ascii().data(), |
| 34 offset.block_offset.toString().ascii().data()); |
33 } | 35 } |
34 | 36 |
35 std::ostream& operator<<(std::ostream& os, const NGLogicalRect& value) { | 37 std::ostream& operator<<(std::ostream& os, const NGLogicalRect& value) { |
36 return os << value.ToString(); | 38 return os << value.ToString(); |
37 } | 39 } |
38 | 40 |
39 } // namespace blink | 41 } // namespace blink |
OLD | NEW |