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_length_utils.h" | 5 #include "core/layout/ng/ng_length_utils.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_margin_strut.h" | |
9 #include "core/style/ComputedStyle.h" | 8 #include "core/style/ComputedStyle.h" |
10 #include "platform/LayoutUnit.h" | 9 #include "platform/LayoutUnit.h" |
11 #include "platform/Length.h" | 10 #include "platform/Length.h" |
12 | 11 |
13 namespace blink { | 12 namespace blink { |
14 // TODO(layout-ng): | 13 // TODO(layout-ng): |
15 // - Handle border-box correctly | 14 // - Handle border-box correctly |
16 // - positioned and/or replaced calculations | 15 // - positioned and/or replaced calculations |
17 // - Handle margins for fill-available and width: auto | 16 // - Handle margins for fill-available and width: auto |
18 | 17 |
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
109 contentSize, LengthResolveType::MinSize); | 108 contentSize, LengthResolveType::MinSize); |
110 extent = std::max(extent, min); | 109 extent = std::max(extent, min); |
111 | 110 |
112 if (style.boxSizing() == BoxSizingContentBox) { | 111 if (style.boxSizing() == BoxSizingContentBox) { |
113 // TODO(layout-ng): Compute border/padding size and add it | 112 // TODO(layout-ng): Compute border/padding size and add it |
114 } | 113 } |
115 | 114 |
116 return extent; | 115 return extent; |
117 } | 116 } |
118 | 117 |
119 NGBoxMargins computeMargins(const NGConstraintSpace& constraintSpace, | 118 NGBoxStrut computeMargins(const NGConstraintSpace& constraintSpace, |
120 const ComputedStyle& style) { | 119 const ComputedStyle& style) { |
121 // Margins always get computed relative to the inline size: | 120 // Margins always get computed relative to the inline size: |
122 // https://www.w3.org/TR/CSS2/box.html#value-def-margin-width | 121 // https://www.w3.org/TR/CSS2/box.html#value-def-margin-width |
123 NGBoxMargins margins; | 122 NGBoxStrut margins; |
124 margins.inline_start = resolveInlineLength( | 123 margins.inline_start = resolveInlineLength( |
125 constraintSpace, style.marginStart(), LengthResolveType::MarginSize); | 124 constraintSpace, style.marginStart(), LengthResolveType::MarginSize); |
126 margins.inline_end = resolveInlineLength(constraintSpace, style.marginEnd(), | 125 margins.inline_end = resolveInlineLength(constraintSpace, style.marginEnd(), |
127 LengthResolveType::MarginSize); | 126 LengthResolveType::MarginSize); |
128 margins.block_start = resolveInlineLength( | 127 margins.block_start = resolveInlineLength( |
129 constraintSpace, style.marginBefore(), LengthResolveType::MarginSize); | 128 constraintSpace, style.marginBefore(), LengthResolveType::MarginSize); |
130 margins.block_end = resolveInlineLength(constraintSpace, style.marginAfter(), | 129 margins.block_end = resolveInlineLength(constraintSpace, style.marginAfter(), |
131 LengthResolveType::MarginSize); | 130 LengthResolveType::MarginSize); |
132 return margins; | 131 return margins; |
133 } | 132 } |
134 | 133 |
135 } // namespace blink | 134 } // namespace blink |
OLD | NEW |