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 IsEmpty() | 28 return String::format("%s,%s %sx%s", |
29 ? "(empty)" | 29 offset.inline_offset.toString().ascii().data(), |
30 : String::format("%sx%s at (%s,%s)", | 30 offset.block_offset.toString().ascii().data(), |
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()); | |
35 } | 33 } |
36 | 34 |
37 std::ostream& operator<<(std::ostream& os, const NGLogicalRect& value) { | 35 std::ostream& operator<<(std::ostream& os, const NGLogicalRect& value) { |
38 return os << value.ToString(); | 36 return os << value.ToString(); |
39 } | 37 } |
40 | 38 |
41 } // namespace blink | 39 } // namespace blink |
OLD | NEW |