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 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
105 *out = nullptr; | 105 *out = nullptr; |
106 return true; | 106 return true; |
107 } | 107 } |
108 | 108 |
109 LayoutUnit NGBlockLayoutAlgorithm::CollapseMargins( | 109 LayoutUnit NGBlockLayoutAlgorithm::CollapseMargins( |
110 const NGBoxStrut& margins, | 110 const NGBoxStrut& margins, |
111 const NGMarginStrut& children_margin_strut) { | 111 const NGMarginStrut& children_margin_strut) { |
112 // Calculate margin strut for the current child. | 112 // Calculate margin strut for the current child. |
113 NGMarginStrut curr_margin_strut = children_margin_strut; | 113 NGMarginStrut curr_margin_strut = children_margin_strut; |
114 curr_margin_strut.AppendMarginBlockStart(margins.block_start); | 114 curr_margin_strut.AppendMarginBlockStart(margins.block_start); |
115 curr_margin_strut.AppendMarginBlockEnd(margins.block_end); | 115 if (current_child_->Style()->height().isAuto()) { |
ikilpatrick
2016/09/13 19:08:39
not logicalHeight here?
Gleb Lanbin
2016/09/13 19:33:44
Done.
| |
116 // bottom margin of a last in-flow child is only collapsed if | |
117 // the parent has 'auto' computed height | |
118 curr_margin_strut.AppendMarginBlockEnd(margins.block_end); | |
119 } else { | |
120 curr_margin_strut.SetMarginBlockEnd(margins.block_end); | |
121 } | |
116 | 122 |
117 // Set the margin strut for the resultant fragment if this is the first or | 123 // Set the margin strut for the resultant fragment if this is the first or |
118 // last child fragment. | 124 // last child fragment. |
119 if (current_child_ == first_child_) | 125 if (current_child_ == first_child_) |
120 builder_->SetMarginStrutBlockStart(curr_margin_strut); | 126 builder_->SetMarginStrutBlockStart(curr_margin_strut); |
121 if (!current_child_->NextSibling()) | 127 if (!current_child_->NextSibling()) |
122 builder_->SetMarginStrutBlockEnd(curr_margin_strut); | 128 builder_->SetMarginStrutBlockEnd(curr_margin_strut); |
123 | 129 |
124 // Compute the margin block start for adjoining blocks. | 130 // Compute the margin block start for adjoining blocks. |
125 LayoutUnit margin_block_start; | 131 LayoutUnit margin_block_start; |
126 if (current_child_ != first_child_) | 132 if (current_child_ != first_child_) |
127 margin_block_start = ComputeCollapsedMarginBlockStart( | 133 margin_block_start = ComputeCollapsedMarginBlockStart( |
128 prev_child_margin_strut_, curr_margin_strut); | 134 prev_child_margin_strut_, curr_margin_strut); |
129 | 135 |
130 prev_child_margin_strut_ = curr_margin_strut; | 136 prev_child_margin_strut_ = curr_margin_strut; |
131 // TODO(layout-ng): support other Margin Collapsing use cases, | 137 // TODO(layout-ng): support other Margin Collapsing use cases, |
132 // i.e. support 0 height elements etc. | 138 // i.e. support 0 height elements etc. |
133 return margin_block_start; | 139 return margin_block_start; |
134 } | 140 } |
135 | 141 |
136 } // namespace blink | 142 } // namespace blink |
OLD | NEW |