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 #ifndef NGLayoutAlgorithm_h | 5 #ifndef NGLayoutAlgorithm_h |
6 #define NGLayoutAlgorithm_h | 6 #define NGLayoutAlgorithm_h |
7 | 7 |
8 #include "core/CoreExport.h" | 8 #include "core/CoreExport.h" |
| 9 #include "core/layout/ng/ng_constraint_space.h" |
| 10 #include "core/layout/ng/ng_layout_input_node.h" |
9 #include "core/layout/ng/ng_min_max_content_size.h" | 11 #include "core/layout/ng/ng_min_max_content_size.h" |
10 #include "wtf/Allocator.h" | 12 #include "wtf/Allocator.h" |
11 #include "wtf/Optional.h" | 13 #include "wtf/Optional.h" |
12 | 14 |
13 namespace blink { | 15 namespace blink { |
14 | 16 |
15 class ComputedStyle; | 17 class ComputedStyle; |
16 class NGConstraintSpace; | 18 struct NGBoxStrut; |
17 class NGLayoutResult; | 19 class NGLayoutResult; |
18 | 20 |
19 // Base class for all LayoutNG algorithms. | 21 // Base class for all LayoutNG algorithms. |
20 template <typename NGInputNodeType, typename NGBreakTokenType> | 22 template <typename NGInputNodeType, typename NGBreakTokenType> |
21 class CORE_EXPORT NGLayoutAlgorithm { | 23 class CORE_EXPORT NGLayoutAlgorithm { |
22 STACK_ALLOCATED(); | 24 STACK_ALLOCATED(); |
23 public: | 25 public: |
24 NGLayoutAlgorithm(NGInputNodeType* node, | 26 NGLayoutAlgorithm(NGInputNodeType* node, |
25 NGConstraintSpace* space, | 27 NGConstraintSpace* space, |
26 NGBreakTokenType* break_token) | 28 NGBreakTokenType* break_token) |
(...skipping 10 matching lines...) Expand all Loading... |
37 // Computes the min-content and max-content intrinsic sizes for the given box. | 39 // Computes the min-content and max-content intrinsic sizes for the given box. |
38 // The result will not take any min-width, max-width or width properties into | 40 // The result will not take any min-width, max-width or width properties into |
39 // account. If the return value is empty, the caller is expected to synthesize | 41 // account. If the return value is empty, the caller is expected to synthesize |
40 // this value from the overflow rect returned from Layout called with an | 42 // this value from the overflow rect returned from Layout called with an |
41 // available width of 0 and LayoutUnit::max(), respectively. | 43 // available width of 0 and LayoutUnit::max(), respectively. |
42 virtual Optional<MinMaxContentSize> ComputeMinMaxContentSize() const { | 44 virtual Optional<MinMaxContentSize> ComputeMinMaxContentSize() const { |
43 return WTF::nullopt; | 45 return WTF::nullopt; |
44 } | 46 } |
45 | 47 |
46 protected: | 48 protected: |
| 49 static NGBoxStrut ComputeMarginsForChild(const NGConstraintSpace& space, |
| 50 NGLayoutInputNode* child); |
| 51 |
47 const NGConstraintSpace& ConstraintSpace() const { | 52 const NGConstraintSpace& ConstraintSpace() const { |
48 DCHECK(constraint_space_); | 53 DCHECK(constraint_space_); |
49 return *constraint_space_; | 54 return *constraint_space_; |
50 } | 55 } |
51 NGConstraintSpace* MutableConstraintSpace() { return constraint_space_; } | 56 NGConstraintSpace* MutableConstraintSpace() { return constraint_space_; } |
52 | 57 |
53 const ComputedStyle& Style() const { | 58 const ComputedStyle& Style() const { |
54 DCHECK(node_); | 59 DCHECK(node_); |
55 return node_->Style(); | 60 return node_->Style(); |
56 } | 61 } |
57 | 62 |
58 virtual NGInputNodeType* Node() const { return node_; } | 63 virtual NGInputNodeType* Node() const { return node_; } |
59 | 64 |
60 NGBreakTokenType* BreakToken() const { return break_token_; } | 65 NGBreakTokenType* BreakToken() const { return break_token_; } |
61 | 66 |
62 Persistent<NGInputNodeType> node_; | 67 Persistent<NGInputNodeType> node_; |
63 NGConstraintSpace* constraint_space_; | 68 NGConstraintSpace* constraint_space_; |
64 | 69 |
65 // The break token from which we are currently resuming layout. | 70 // The break token from which we are currently resuming layout. |
66 NGBreakTokenType* break_token_; | 71 NGBreakTokenType* break_token_; |
67 }; | 72 }; |
68 | 73 |
69 } // namespace blink | 74 } // namespace blink |
70 | 75 |
71 #endif // NGLayoutAlgorithm_h | 76 #endif // NGLayoutAlgorithm_h |
OLD | NEW |