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/ng_block_layout_algorithm.h" | 5 #include "core/layout/ng/ng_block_layout_algorithm.h" |
6 | 6 |
7 #include "core/layout/ng/ng_constraint_space.h" | 7 #include "core/layout/ng/ng_constraint_space.h" |
8 #include "core/layout/ng/ng_fragment_builder.h" | 8 #include "core/layout/ng/ng_fragment_builder.h" |
9 #include "core/layout/ng/ng_fragment.h" | 9 #include "core/layout/ng/ng_fragment.h" |
10 #include "core/layout/ng/ng_length_utils.h" | 10 #include "core/layout/ng/ng_length_utils.h" |
(...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
153 // 1) there is no padding or border between parent (current child) and its | 153 // 1) there is no padding or border between parent (current child) and its |
154 // first/last in-flow child | 154 // first/last in-flow child |
155 // 2) parent's logical height is auto. | 155 // 2) parent's logical height is auto. |
156 if (current_child_->Style()->logicalHeight().isAuto() && | 156 if (current_child_->Style()->logicalHeight().isAuto() && |
157 !border_and_padding.block_end) { | 157 !border_and_padding.block_end) { |
158 curr_margin_strut.AppendMarginBlockEnd(margins.block_end); | 158 curr_margin_strut.AppendMarginBlockEnd(margins.block_end); |
159 } else { | 159 } else { |
160 curr_margin_strut.SetMarginBlockEnd(margins.block_end); | 160 curr_margin_strut.SetMarginBlockEnd(margins.block_end); |
161 } | 161 } |
162 | 162 |
163 // Compute the margin block start for | |
164 // 1) adjoining blocks | |
165 // 2) 1st block in LayoutNG root element's constraint space. | |
mstensho (USE GERRIT)
2016/09/28 18:32:33
Oops, some "LayoutNG" here too...
| |
166 LayoutUnit margin_block_start; | |
167 if (is_fragment_margin_strut_block_start_updated_ || space.IsRoot()) { | |
168 margin_block_start = ComputeCollapsedMarginBlockStart( | |
169 prev_child_margin_strut_, curr_margin_strut); | |
170 } | |
171 | |
163 // Update the parent fragment's margin strut | 172 // Update the parent fragment's margin strut |
164 UpdateMarginStrut(curr_margin_strut); | 173 UpdateMarginStrut(curr_margin_strut); |
165 | 174 |
166 // Compute the margin block start for adjoining blocks. | |
167 LayoutUnit margin_block_start; | |
168 if (is_fragment_margin_strut_block_start_updated_) { | |
169 margin_block_start = ComputeCollapsedMarginBlockStart( | |
170 prev_child_margin_strut_, curr_margin_strut); | |
171 } | |
172 prev_child_margin_strut_ = curr_margin_strut; | 175 prev_child_margin_strut_ = curr_margin_strut; |
173 return margin_block_start; | 176 return margin_block_start; |
174 } | 177 } |
175 | 178 |
176 void NGBlockLayoutAlgorithm::UpdateMarginStrut(const NGMarginStrut& from) { | 179 void NGBlockLayoutAlgorithm::UpdateMarginStrut(const NGMarginStrut& from) { |
177 if (!is_fragment_margin_strut_block_start_updated_) { | 180 if (!is_fragment_margin_strut_block_start_updated_) { |
178 builder_->SetMarginStrutBlockStart(from); | 181 builder_->SetMarginStrutBlockStart(from); |
179 is_fragment_margin_strut_block_start_updated_ = true; | 182 is_fragment_margin_strut_block_start_updated_ = true; |
180 } | 183 } |
181 builder_->SetMarginStrutBlockEnd(from); | 184 builder_->SetMarginStrutBlockEnd(from); |
182 } | 185 } |
183 | 186 |
184 } // namespace blink | 187 } // namespace blink |
OLD | NEW |