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 NGBlockLayoutAlgorithm_h | 5 #ifndef NGBlockLayoutAlgorithm_h |
6 #define NGBlockLayoutAlgorithm_h | 6 #define NGBlockLayoutAlgorithm_h |
7 | 7 |
8 #include "core/CoreExport.h" | 8 #include "core/CoreExport.h" |
9 #include "core/layout/ng/ng_block_break_token.h" | |
9 #include "core/layout/ng/ng_block_node.h" | 10 #include "core/layout/ng/ng_block_node.h" |
10 #include "core/layout/ng/ng_break_token.h" | 11 #include "core/layout/ng/ng_break_token.h" |
11 #include "core/layout/ng/ng_fragment_builder.h" | 12 #include "core/layout/ng/ng_fragment_builder.h" |
12 #include "core/layout/ng/ng_layout_algorithm.h" | 13 #include "core/layout/ng/ng_layout_algorithm.h" |
13 #include "core/layout/ng/ng_units.h" | 14 #include "core/layout/ng/ng_units.h" |
14 #include "wtf/RefPtr.h" | 15 #include "wtf/RefPtr.h" |
15 | 16 |
16 namespace blink { | 17 namespace blink { |
17 | 18 |
18 class ComputedStyle; | 19 class ComputedStyle; |
19 class NGBlockBreakToken; | 20 class NGBlockBreakToken; |
20 class NGConstraintSpace; | 21 class NGConstraintSpace; |
21 class NGConstraintSpaceBuilder; | 22 class NGConstraintSpaceBuilder; |
22 class NGInlineNode; | 23 class NGInlineNode; |
23 class NGLayoutResult; | 24 class NGLayoutResult; |
24 | 25 |
25 // A class for general block layout (e.g. a <div> with no special style). | 26 // A class for general block layout (e.g. a <div> with no special style). |
26 // Lays out the children in sequence. | 27 // Lays out the children in sequence. |
27 class CORE_EXPORT NGBlockLayoutAlgorithm : public NGLayoutAlgorithm { | 28 class CORE_EXPORT NGBlockLayoutAlgorithm : public NGLayoutAlgorithm { |
28 public: | 29 public: |
29 // Default constructor. | 30 // Default constructor. |
30 // @param node The input node to perform layout upon. | 31 // @param node The input node to perform layout upon. |
31 // @param space The constraint space which the algorithm should generate a | 32 // @param space The constraint space which the algorithm should generate a |
32 // fragment within. | 33 // fragment within. |
33 // @param break_token The break token from which the layout should start. | 34 // @param break_token The break token from which the layout should start. |
34 NGBlockLayoutAlgorithm(NGBlockNode* node, | 35 NGBlockLayoutAlgorithm(NGBlockNode* node, |
35 NGConstraintSpace* space, | 36 NGConstraintSpace* space, |
36 NGBlockBreakToken* break_token = nullptr); | 37 RefPtr<NGBlockBreakToken> break_token = nullptr); |
37 | 38 |
38 Optional<MinAndMaxContentSizes> ComputeMinAndMaxContentSizes() const override; | 39 Optional<MinAndMaxContentSizes> ComputeMinAndMaxContentSizes() const override; |
39 RefPtr<NGLayoutResult> Layout() override; | 40 RefPtr<NGLayoutResult> Layout() override; |
40 | 41 |
41 private: | 42 private: |
42 NGBoxStrut CalculateMargins(const NGConstraintSpace& space, | 43 NGBoxStrut CalculateMargins(const NGConstraintSpace& space, |
43 const ComputedStyle& style); | 44 const ComputedStyle& style); |
44 | 45 |
45 // Creates a new constraint space for the current child. | 46 // Creates a new constraint space for the current child. |
46 NGConstraintSpace* CreateConstraintSpaceForCurrentChild(); | 47 NGConstraintSpace* CreateConstraintSpaceForCurrentChild(); |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
81 const NGConstraintSpace& CurrentChildConstraintSpace() const { | 82 const NGConstraintSpace& CurrentChildConstraintSpace() const { |
82 return *space_for_current_child_.get(); | 83 return *space_for_current_child_.get(); |
83 } | 84 } |
84 | 85 |
85 const ComputedStyle& Style() const { return node_->Style(); } | 86 const ComputedStyle& Style() const { return node_->Style(); } |
86 | 87 |
87 Persistent<NGBlockNode> node_; | 88 Persistent<NGBlockNode> node_; |
88 Persistent<NGConstraintSpace> constraint_space_; | 89 Persistent<NGConstraintSpace> constraint_space_; |
89 | 90 |
90 // The break token from which we are currently resuming layout. | 91 // The break token from which we are currently resuming layout. |
91 Persistent<NGBlockBreakToken> break_token_; | 92 RefPtr<NGBlockBreakToken> break_token_; |
ikilpatrick
2017/02/28 17:13:13
I could also make this a raw ptr? (and other alg.
| |
92 | 93 |
93 std::unique_ptr<NGFragmentBuilder> builder_; | 94 std::unique_ptr<NGFragmentBuilder> builder_; |
94 Persistent<NGConstraintSpaceBuilder> space_builder_; | 95 Persistent<NGConstraintSpaceBuilder> space_builder_; |
95 Persistent<NGConstraintSpace> space_for_current_child_; | 96 Persistent<NGConstraintSpace> space_for_current_child_; |
96 Persistent<NGLayoutInputNode> current_child_; | 97 Persistent<NGLayoutInputNode> current_child_; |
97 | 98 |
98 NGBoxStrut border_and_padding_; | 99 NGBoxStrut border_and_padding_; |
99 LayoutUnit content_size_; | 100 LayoutUnit content_size_; |
100 LayoutUnit max_inline_size_; | 101 LayoutUnit max_inline_size_; |
101 // MarginStrut for the previous child. | 102 // MarginStrut for the previous child. |
102 NGMarginStrut curr_margin_strut_; | 103 NGMarginStrut curr_margin_strut_; |
103 NGLogicalOffset bfc_offset_; | 104 NGLogicalOffset bfc_offset_; |
104 NGLogicalOffset curr_bfc_offset_; | 105 NGLogicalOffset curr_bfc_offset_; |
105 NGBoxStrut curr_child_margins_; | 106 NGBoxStrut curr_child_margins_; |
106 }; | 107 }; |
107 | 108 |
108 } // namespace blink | 109 } // namespace blink |
109 | 110 |
110 #endif // NGBlockLayoutAlgorithm_h | 111 #endif // NGBlockLayoutAlgorithm_h |
OLD | NEW |