OLD | NEW |
| (Empty) |
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 | |
3 // found in the LICENSE file. | |
4 | |
5 #ifndef NGLogicalRect_h | |
6 #define NGLogicalRect_h | |
7 | |
8 #include "core/CoreExport.h" | |
9 #include "core/layout/ng/geometry/ng_logical_offset.h" | |
10 #include "core/layout/ng/geometry/ng_logical_size.h" | |
11 #include "platform/LayoutUnit.h" | |
12 | |
13 namespace blink { | |
14 | |
15 // NGLogicalRect is the position and size of a rect (typically a fragment) | |
16 // relative to its parent rect in the logical coordinate system. | |
17 struct CORE_EXPORT NGLogicalRect { | |
18 NGLogicalRect() {} | |
19 NGLogicalRect(const NGLogicalOffset& offset, const NGLogicalSize& size) | |
20 : offset(offset), size(size) {} | |
21 NGLogicalRect(LayoutUnit inline_offset, | |
22 LayoutUnit block_offset, | |
23 LayoutUnit inline_size, | |
24 LayoutUnit block_size) | |
25 : offset(inline_offset, block_offset), size(inline_size, block_size) {} | |
26 | |
27 bool IsEmpty() const; | |
28 | |
29 // Whether this rectangle is contained by the provided rectangle. | |
30 bool IsContained(const NGLogicalRect& other) const; | |
31 | |
32 LayoutUnit InlineStartOffset() const { return offset.inline_offset; } | |
33 LayoutUnit InlineEndOffset() const { | |
34 return offset.inline_offset + size.inline_size; | |
35 } | |
36 LayoutUnit BlockStartOffset() const { return offset.block_offset; } | |
37 LayoutUnit BlockEndOffset() const { | |
38 return offset.block_offset + size.block_size; | |
39 } | |
40 | |
41 LayoutUnit BlockSize() const { return size.block_size; } | |
42 LayoutUnit InlineSize() const { return size.inline_size; } | |
43 | |
44 String ToString() const; | |
45 bool operator==(const NGLogicalRect& other) const; | |
46 | |
47 NGLogicalOffset offset; | |
48 NGLogicalSize size; | |
49 }; | |
50 | |
51 CORE_EXPORT std::ostream& operator<<(std::ostream&, const NGLogicalRect&); | |
52 | |
53 } // namespace blink | |
54 | |
55 #endif // NGLogicalRect_h | |
OLD | NEW |