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_node.h" | 9 #include "core/layout/ng/ng_block_node.h" |
10 #include "core/layout/ng/ng_break_token.h" | 10 #include "core/layout/ng/ng_break_token.h" |
11 #include "core/layout/ng/ng_column_mapper.h" | 11 #include "core/layout/ng/ng_column_mapper.h" |
12 #include "core/layout/ng/ng_fragment_builder.h" | 12 #include "core/layout/ng/ng_fragment_builder.h" |
13 #include "core/layout/ng/ng_layout_algorithm.h" | 13 #include "core/layout/ng/ng_layout_algorithm.h" |
14 #include "core/layout/ng/ng_units.h" | 14 #include "core/layout/ng/ng_units.h" |
15 #include "wtf/RefPtr.h" | 15 #include "wtf/RefPtr.h" |
16 | 16 |
17 namespace blink { | 17 namespace blink { |
18 | 18 |
19 class ComputedStyle; | 19 class ComputedStyle; |
20 class NGBlockBreakToken; | 20 class NGBlockBreakToken; |
21 class NGBoxFragment; | |
22 class NGConstraintSpace; | 21 class NGConstraintSpace; |
23 class NGConstraintSpaceBuilder; | 22 class NGConstraintSpaceBuilder; |
24 class NGInlineNode; | 23 class NGInlineNode; |
25 class NGPhysicalFragment; | 24 class NGPhysicalFragment; |
26 | 25 |
27 // 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). |
28 // Lays out the children in sequence. | 27 // Lays out the children in sequence. |
29 class CORE_EXPORT NGBlockLayoutAlgorithm : public NGLayoutAlgorithm { | 28 class CORE_EXPORT NGBlockLayoutAlgorithm : public NGLayoutAlgorithm { |
30 public: | 29 public: |
31 // Default constructor. | 30 // Default constructor. |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
91 // Get the amount of block space left in the current fragmentainer for the | 90 // Get the amount of block space left in the current fragmentainer for the |
92 // child that is about to be laid out. | 91 // child that is about to be laid out. |
93 LayoutUnit SpaceAvailableForCurrentChild() const; | 92 LayoutUnit SpaceAvailableForCurrentChild() const; |
94 | 93 |
95 LayoutUnit BorderEdgeForCurrentChild() const { | 94 LayoutUnit BorderEdgeForCurrentChild() const { |
96 // TODO(mstensho): Need to take care of margin collapsing somehow. We | 95 // TODO(mstensho): Need to take care of margin collapsing somehow. We |
97 // should at least attempt to estimate what the top margin is going to be. | 96 // should at least attempt to estimate what the top margin is going to be. |
98 return content_size_; | 97 return content_size_; |
99 } | 98 } |
100 | 99 |
101 // Calculates offset for the provided fragment which is relative to the | 100 // Calculates logical offset for the current fragment using either |
102 // fragment's parent. | 101 // {@code content_size_} when the fragment doesn't know it's offset |
103 NGLogicalOffset CalculateRelativeOffset(const NGBoxFragment& fragment); | 102 // or {@code known_fragment_offset} if the fragment knows it's offset |
| 103 // @return Fragment's offset relative to the fragment's parent. |
| 104 NGLogicalOffset CalculateLogicalOffset( |
| 105 const WTF::Optional<NGLogicalOffset>& known_fragment_offset); |
| 106 |
104 NGLogicalOffset GetChildSpaceOffset() const { | 107 NGLogicalOffset GetChildSpaceOffset() const { |
105 return NGLogicalOffset(border_and_padding_.inline_start, content_size_); | 108 return NGLogicalOffset(border_and_padding_.inline_start, content_size_); |
106 } | 109 } |
107 | 110 |
108 // Read-only Getters. | 111 // Read-only Getters. |
109 const ComputedStyle& CurrentChildStyle() const { | 112 const ComputedStyle& CurrentChildStyle() const { |
110 DCHECK(current_child_); | 113 DCHECK(current_child_); |
111 return toNGBlockNode(current_child_)->Style(); | 114 return toNGBlockNode(current_child_)->Style(); |
112 } | 115 } |
113 | 116 |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
145 // MarginStrut for the previous child. | 148 // MarginStrut for the previous child. |
146 NGMarginStrut curr_margin_strut_; | 149 NGMarginStrut curr_margin_strut_; |
147 NGLogicalOffset bfc_offset_; | 150 NGLogicalOffset bfc_offset_; |
148 NGLogicalOffset curr_bfc_offset_; | 151 NGLogicalOffset curr_bfc_offset_; |
149 NGBoxStrut curr_child_margins_; | 152 NGBoxStrut curr_child_margins_; |
150 }; | 153 }; |
151 | 154 |
152 } // namespace blink | 155 } // namespace blink |
153 | 156 |
154 #endif // NGBlockLayoutAlgorithm_h | 157 #endif // NGBlockLayoutAlgorithm_h |
OLD | NEW |