Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(220)

Side by Side Diff: third_party/WebKit/Source/core/layout/ng/ng_absolute_utils.cc

Issue 2645863005: Fix how we constrain width/height by min/max (Closed)
Patch Set: Created 3 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « third_party/WebKit/LayoutTests/TestExpectations ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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_absolute_utils.h" 5 #include "core/layout/ng/ng_absolute_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_length_utils.h" 8 #include "core/layout/ng/ng_length_utils.h"
9 #include "core/style/ComputedStyle.h" 9 #include "core/style/ComputedStyle.h"
10 #include "platform/LengthFunctions.h" 10 #include "platform/LengthFunctions.h"
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
50 child_minmax.has_value() ? child_minmax->max_content : LayoutUnit(); 50 child_minmax.has_value() ? child_minmax->max_content : LayoutUnit();
51 return ResolveBlockLength(space, style, height, computed_height, 51 return ResolveBlockLength(space, style, height, computed_height,
52 resolve_type); 52 resolve_type);
53 } 53 }
54 54
55 // Implement absolute horizontal size resolution algorithm. 55 // Implement absolute horizontal size resolution algorithm.
56 // https://www.w3.org/TR/css-position-3/#abs-non-replaced-width 56 // https://www.w3.org/TR/css-position-3/#abs-non-replaced-width
57 void ComputeAbsoluteHorizontal( 57 void ComputeAbsoluteHorizontal(
58 const NGConstraintSpace& space, 58 const NGConstraintSpace& space,
59 const ComputedStyle& style, 59 const ComputedStyle& style,
60 const Optional<LayoutUnit>& incoming_width,
60 const NGStaticPosition& static_position, 61 const NGStaticPosition& static_position,
61 const Optional<MinAndMaxContentSizes>& child_minmax, 62 const Optional<MinAndMaxContentSizes>& child_minmax,
62 NGAbsolutePhysicalPosition* position) { 63 NGAbsolutePhysicalPosition* position) {
63 NGLogicalSize percentage_logical = space.PercentageResolutionSize(); 64 NGLogicalSize percentage_logical = space.PercentageResolutionSize();
64 NGPhysicalSize percentage_physical = 65 NGPhysicalSize percentage_physical =
65 percentage_logical.ConvertToPhysical(space.WritingMode()); 66 percentage_logical.ConvertToPhysical(space.WritingMode());
66 LayoutUnit border_left(style.borderLeftWidth()); 67 LayoutUnit border_left(style.borderLeftWidth());
67 LayoutUnit border_right(style.borderRightWidth()); 68 LayoutUnit border_right(style.borderRightWidth());
68 LayoutUnit padding_left = 69 LayoutUnit padding_left =
69 valueForLength(style.paddingLeft(), percentage_logical.inline_size); 70 valueForLength(style.paddingLeft(), percentage_logical.inline_size);
70 LayoutUnit padding_right = 71 LayoutUnit padding_right =
71 valueForLength(style.paddingRight(), percentage_logical.inline_size); 72 valueForLength(style.paddingRight(), percentage_logical.inline_size);
72 Optional<LayoutUnit> margin_left; 73 Optional<LayoutUnit> margin_left;
73 if (!style.marginLeft().isAuto()) 74 if (!style.marginLeft().isAuto())
74 margin_left = 75 margin_left =
75 valueForLength(style.marginLeft(), percentage_logical.inline_size); 76 valueForLength(style.marginLeft(), percentage_logical.inline_size);
76 Optional<LayoutUnit> margin_right; 77 Optional<LayoutUnit> margin_right;
77 if (!style.marginRight().isAuto()) 78 if (!style.marginRight().isAuto())
78 margin_right = 79 margin_right =
79 valueForLength(style.marginRight(), percentage_logical.inline_size); 80 valueForLength(style.marginRight(), percentage_logical.inline_size);
80 Optional<LayoutUnit> left; 81 Optional<LayoutUnit> left;
81 if (!style.left().isAuto()) 82 if (!style.left().isAuto())
82 left = valueForLength(style.left(), percentage_physical.width); 83 left = valueForLength(style.left(), percentage_physical.width);
83 Optional<LayoutUnit> right; 84 Optional<LayoutUnit> right;
84 if (!style.right().isAuto()) 85 if (!style.right().isAuto())
85 right = valueForLength(style.right(), percentage_physical.width); 86 right = valueForLength(style.right(), percentage_physical.width);
86 LayoutUnit border_padding = 87 LayoutUnit border_padding =
87 border_left + border_right + padding_left + padding_right; 88 border_left + border_right + padding_left + padding_right;
88 Optional<LayoutUnit> min_width; 89 Optional<LayoutUnit> width = incoming_width;
89 if (!style.minWidth().isAuto())
90 min_width = ResolveWidth(style.minWidth(), space, style, child_minmax,
91 LengthResolveType::kMinSize);
92 Optional<LayoutUnit> max_width;
93 if (!style.maxWidth().isMaxSizeNone())
94 max_width = ResolveWidth(style.maxWidth(), space, style, child_minmax,
95 LengthResolveType::kMaxSize);
96 Optional<LayoutUnit> width;
97 if (!style.width().isAuto()) {
98 width = ResolveWidth(style.width(), space, style, child_minmax,
99 LengthResolveType::kContentSize);
100 width = ConstrainByMinMax(*width, min_width, max_width);
101 }
102 NGPhysicalSize container_size = 90 NGPhysicalSize container_size =
103 space.AvailableSize().ConvertToPhysical(space.WritingMode()); 91 space.AvailableSize().ConvertToPhysical(space.WritingMode());
104 DCHECK(container_size.width != NGSizeIndefinite); 92 DCHECK(container_size.width != NGSizeIndefinite);
105 93
106 // Solving the equation: 94 // Solving the equation:
107 // left + marginLeft + width + marginRight + right = container width 95 // left + marginLeft + width + marginRight + right = container width
108 if (!left && !right && !width) { 96 if (!left && !right && !width) {
109 // Standard: "If all three of left, width, and right are auto:" 97 // Standard: "If all three of left, width, and right are auto:"
110 if (!margin_left) 98 if (!margin_left)
111 margin_left = LayoutUnit(); 99 margin_left = LayoutUnit();
112 if (!margin_right) 100 if (!margin_right)
113 margin_right = LayoutUnit(); 101 margin_right = LayoutUnit();
114 DCHECK(child_minmax.has_value()); 102 DCHECK(child_minmax.has_value());
115 width = child_minmax->ShrinkToFit(container_size.width); 103 width = child_minmax->ShrinkToFit(container_size.width);
116 width = ConstrainByMinMax(*width, min_width, max_width);
117 if (space.Direction() == TextDirection::kLtr) { 104 if (space.Direction() == TextDirection::kLtr) {
118 left = static_position.LeftPosition(container_size.width, *width, 105 left = static_position.LeftPosition(container_size.width, *width,
119 *margin_left, *margin_right); 106 *margin_left, *margin_right);
120 } else { 107 } else {
121 right = static_position.RightPosition(container_size.width, *width, 108 right = static_position.RightPosition(container_size.width, *width,
122 *margin_left, *margin_right); 109 *margin_left, *margin_right);
123 } 110 }
124 } else if (left && right && width) { 111 } else if (left && right && width) {
125 // Standard: "If left, right, and width are not auto:" 112 // Standard: "If left, right, and width are not auto:"
126 // Compute margins. 113 // Compute margins.
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
162 margin_left = LayoutUnit(); 149 margin_left = LayoutUnit();
163 if (!margin_right) 150 if (!margin_right)
164 margin_right = LayoutUnit(); 151 margin_right = LayoutUnit();
165 152
166 // Rules 1 through 3, 2 out of 3 are unknown. 153 // Rules 1 through 3, 2 out of 3 are unknown.
167 if (!left && !width) { 154 if (!left && !width) {
168 // Rule 1: left/width are unknown. 155 // Rule 1: left/width are unknown.
169 DCHECK(right.has_value()); 156 DCHECK(right.has_value());
170 DCHECK(child_minmax.has_value()); 157 DCHECK(child_minmax.has_value());
171 width = child_minmax->ShrinkToFit(container_size.width); 158 width = child_minmax->ShrinkToFit(container_size.width);
172 width = ConstrainByMinMax(*width, min_width, max_width);
173 } else if (!left && !right) { 159 } else if (!left && !right) {
174 // Rule 2. 160 // Rule 2.
175 DCHECK(width.has_value()); 161 DCHECK(width.has_value());
176 if (space.Direction() == TextDirection::kLtr) 162 if (space.Direction() == TextDirection::kLtr)
177 left = static_position.LeftPosition(container_size.width, *width, 163 left = static_position.LeftPosition(container_size.width, *width,
178 *margin_left, *margin_right); 164 *margin_left, *margin_right);
179 else 165 else
180 right = static_position.RightPosition(container_size.width, *width, 166 right = static_position.RightPosition(container_size.width, *width,
181 *margin_left, *margin_right); 167 *margin_left, *margin_right);
182 } else if (!width && !right) { 168 } else if (!width && !right) {
183 // Rule 3. 169 // Rule 3.
184 DCHECK(child_minmax.has_value()); 170 DCHECK(child_minmax.has_value());
185 width = child_minmax->ShrinkToFit(container_size.width); 171 width = child_minmax->ShrinkToFit(container_size.width);
186 width = ConstrainByMinMax(*width, min_width, max_width);
187 } 172 }
188 173
189 // Rules 4 through 6, 1 out of 3 are unknown. 174 // Rules 4 through 6, 1 out of 3 are unknown.
190 if (!left) { 175 if (!left) {
191 left = 176 left =
192 container_size.width - *right - *width - *margin_left - *margin_right; 177 container_size.width - *right - *width - *margin_left - *margin_right;
193 } else if (!right) { 178 } else if (!right) {
194 right = 179 right =
195 container_size.width - *left - *width - *margin_left - *margin_right; 180 container_size.width - *left - *width - *margin_left - *margin_right;
196 } else if (!width) { 181 } else if (!width) {
197 width = 182 width =
198 container_size.width - *left - *right - *margin_left - *margin_right; 183 container_size.width - *left - *right - *margin_left - *margin_right;
199 } 184 }
200 DCHECK_EQ(container_size.width, 185 DCHECK_EQ(container_size.width,
201 *left + *right + *margin_left + *margin_right + *width); 186 *left + *right + *margin_left + *margin_right + *width);
202 187
203 width = ConstrainByMinMax(*width, min_width, max_width); 188 // If calculated width is outside of min/max constraints,
189 // rerun the algorithm with constrained width.
190 Optional<LayoutUnit> min_width;
191 if (!style.minWidth().isAuto())
192 min_width = ResolveWidth(style.minWidth(), space, style, child_minmax,
193 LengthResolveType::kMinSize);
194 Optional<LayoutUnit> max_width;
195 if (!style.maxWidth().isMaxSizeNone())
196 max_width = ResolveWidth(style.maxWidth(), space, style, child_minmax,
197 LengthResolveType::kMaxSize);
198 if (width != ConstrainByMinMax(*width, min_width, max_width)) {
199 width = ConstrainByMinMax(*width, min_width, max_width);
200 ComputeAbsoluteHorizontal(space, style, width, static_position,
cbiesinger 2017/01/21 00:03:30 Can you add a comment on why it's safe to call thi
atotic 2017/01/21 00:09:01 done
201 child_minmax, position);
202 return;
203 }
204
204 // Negative widths are not allowed. 205 // Negative widths are not allowed.
205 width = std::max(*width, border_padding); 206 width = std::max(*width, border_padding);
206 207
207 position->inset.left = *left + *margin_left; 208 position->inset.left = *left + *margin_left;
208 position->inset.right = *right + *margin_right; 209 position->inset.right = *right + *margin_right;
209 position->size.width = *width; 210 position->size.width = *width;
210 } 211 }
211 212
212 // Implements absolute vertical size resolution algorithm. 213 // Implements absolute vertical size resolution algorithm.
213 // https://www.w3.org/TR/css-position-3/#abs-non-replaced-height 214 // https://www.w3.org/TR/css-position-3/#abs-non-replaced-height
214 void ComputeAbsoluteVertical( 215 void ComputeAbsoluteVertical(
215 const NGConstraintSpace& space, 216 const NGConstraintSpace& space,
216 const ComputedStyle& style, 217 const ComputedStyle& style,
218 const Optional<LayoutUnit>& incoming_height,
217 const NGStaticPosition& static_position, 219 const NGStaticPosition& static_position,
218 const Optional<MinAndMaxContentSizes>& child_minmax, 220 const Optional<MinAndMaxContentSizes>& child_minmax,
219 NGAbsolutePhysicalPosition* position) { 221 NGAbsolutePhysicalPosition* position) {
220 NGLogicalSize percentage_logical = space.PercentageResolutionSize(); 222 NGLogicalSize percentage_logical = space.PercentageResolutionSize();
221 NGPhysicalSize percentage_physical = 223 NGPhysicalSize percentage_physical =
222 percentage_logical.ConvertToPhysical(space.WritingMode()); 224 percentage_logical.ConvertToPhysical(space.WritingMode());
223 225
224 LayoutUnit border_top(style.borderTopWidth()); 226 LayoutUnit border_top(style.borderTopWidth());
225 LayoutUnit border_bottom(style.borderBottomWidth()); 227 LayoutUnit border_bottom(style.borderBottomWidth());
226 LayoutUnit padding_top = 228 LayoutUnit padding_top =
227 valueForLength(style.paddingTop(), percentage_logical.inline_size); 229 valueForLength(style.paddingTop(), percentage_logical.inline_size);
228 LayoutUnit padding_bottom = 230 LayoutUnit padding_bottom =
229 valueForLength(style.paddingBottom(), percentage_logical.inline_size); 231 valueForLength(style.paddingBottom(), percentage_logical.inline_size);
230 Optional<LayoutUnit> margin_top; 232 Optional<LayoutUnit> margin_top;
231 if (!style.marginTop().isAuto()) 233 if (!style.marginTop().isAuto())
232 margin_top = 234 margin_top =
233 valueForLength(style.marginTop(), percentage_logical.inline_size); 235 valueForLength(style.marginTop(), percentage_logical.inline_size);
234 Optional<LayoutUnit> margin_bottom; 236 Optional<LayoutUnit> margin_bottom;
235 if (!style.marginBottom().isAuto()) 237 if (!style.marginBottom().isAuto())
236 margin_bottom = 238 margin_bottom =
237 valueForLength(style.marginBottom(), percentage_logical.inline_size); 239 valueForLength(style.marginBottom(), percentage_logical.inline_size);
238 Optional<LayoutUnit> top; 240 Optional<LayoutUnit> top;
239 if (!style.top().isAuto()) 241 if (!style.top().isAuto())
240 top = valueForLength(style.top(), percentage_physical.height); 242 top = valueForLength(style.top(), percentage_physical.height);
241 Optional<LayoutUnit> bottom; 243 Optional<LayoutUnit> bottom;
242 if (!style.bottom().isAuto()) 244 if (!style.bottom().isAuto())
243 bottom = valueForLength(style.bottom(), percentage_physical.height); 245 bottom = valueForLength(style.bottom(), percentage_physical.height);
244 LayoutUnit border_padding = 246 LayoutUnit border_padding =
245 border_top + border_bottom + padding_top + padding_bottom; 247 border_top + border_bottom + padding_top + padding_bottom;
246 248 Optional<LayoutUnit> height = incoming_height;
247 Optional<LayoutUnit> min_height;
248 if (!style.minHeight().isAuto())
249 min_height = ResolveHeight(style.minHeight(), space, style, child_minmax,
250 LengthResolveType::kMinSize);
251 Optional<LayoutUnit> max_height;
252 if (!style.maxHeight().isMaxSizeNone())
253 max_height = ResolveHeight(style.maxHeight(), space, style, child_minmax,
254 LengthResolveType::kMaxSize);
255 Optional<LayoutUnit> height;
256 if (!style.height().isAuto()) {
257 height = ResolveHeight(style.height(), space, style, child_minmax,
258 LengthResolveType::kContentSize);
259 height = ConstrainByMinMax(*height, min_height, max_height);
260 }
261 249
262 NGPhysicalSize container_size = 250 NGPhysicalSize container_size =
263 space.AvailableSize().ConvertToPhysical(space.WritingMode()); 251 space.AvailableSize().ConvertToPhysical(space.WritingMode());
264 DCHECK(container_size.height != NGSizeIndefinite); 252 DCHECK(container_size.height != NGSizeIndefinite);
265 253
266 // Solving the equation: 254 // Solving the equation:
267 // top + marginTop + height + marginBottom + bottom 255 // top + marginTop + height + marginBottom + bottom
268 // + border_padding = container height 256 // + border_padding = container height
269 if (!top && !bottom && !height) { 257 if (!top && !bottom && !height) {
270 // Standard: "If all three of top, height, and bottom are auto:" 258 // Standard: "If all three of top, height, and bottom are auto:"
271 if (!margin_top) 259 if (!margin_top)
272 margin_top = LayoutUnit(); 260 margin_top = LayoutUnit();
273 if (!margin_bottom) 261 if (!margin_bottom)
274 margin_bottom = LayoutUnit(); 262 margin_bottom = LayoutUnit();
275 DCHECK(child_minmax.has_value()); 263 DCHECK(child_minmax.has_value());
276 height = child_minmax->ShrinkToFit(container_size.height); 264 height = child_minmax->ShrinkToFit(container_size.height);
277 height = ConstrainByMinMax(*height, min_height, max_height);
278 top = static_position.TopPosition(container_size.height, *height, 265 top = static_position.TopPosition(container_size.height, *height,
279 *margin_top, *margin_bottom); 266 *margin_top, *margin_bottom);
280 } else if (top && bottom && height) { 267 } else if (top && bottom && height) {
281 // Standard: "If top, bottom, and height are not auto:" 268 // Standard: "If top, bottom, and height are not auto:"
282 // Compute margins. 269 // Compute margins.
283 LayoutUnit margin_space = container_size.height - *top - *bottom - *height; 270 LayoutUnit margin_space = container_size.height - *top - *bottom - *height;
284 // When both margins are auto. 271 // When both margins are auto.
285 if (!margin_top && !margin_bottom) { 272 if (!margin_top && !margin_bottom) {
286 if (margin_space > 0) { 273 if (margin_space > 0) {
287 margin_top = margin_space / 2; 274 margin_top = margin_space / 2;
(...skipping 19 matching lines...) Expand all
307 margin_top = LayoutUnit(); 294 margin_top = LayoutUnit();
308 if (!margin_bottom) 295 if (!margin_bottom)
309 margin_bottom = LayoutUnit(); 296 margin_bottom = LayoutUnit();
310 297
311 // Rules 1 through 3, 2 out of 3 are unknown, fix 1. 298 // Rules 1 through 3, 2 out of 3 are unknown, fix 1.
312 if (!top && !height) { 299 if (!top && !height) {
313 // Rule 1. 300 // Rule 1.
314 DCHECK(bottom.has_value()); 301 DCHECK(bottom.has_value());
315 DCHECK(child_minmax.has_value()); 302 DCHECK(child_minmax.has_value());
316 height = child_minmax->ShrinkToFit(container_size.height); 303 height = child_minmax->ShrinkToFit(container_size.height);
317 height = ConstrainByMinMax(*height, min_height, max_height);
318 } else if (!top && !bottom) { 304 } else if (!top && !bottom) {
319 // Rule 2. 305 // Rule 2.
320 DCHECK(height.has_value()); 306 DCHECK(height.has_value());
321 top = static_position.TopPosition(container_size.height, *height, 307 top = static_position.TopPosition(container_size.height, *height,
322 *margin_top, *margin_bottom); 308 *margin_top, *margin_bottom);
323 } else if (!height && !bottom) { 309 } else if (!height && !bottom) {
324 // Rule 3. 310 // Rule 3.
325 DCHECK(child_minmax.has_value()); 311 DCHECK(child_minmax.has_value());
326 height = child_minmax->ShrinkToFit(container_size.height); 312 height = child_minmax->ShrinkToFit(container_size.height);
327 height = ConstrainByMinMax(*height, min_height, max_height);
328 } 313 }
329 314
330 // Rules 4 through 6, 1 out of 3 are unknown. 315 // Rules 4 through 6, 1 out of 3 are unknown.
331 if (!top) { 316 if (!top) {
332 top = container_size.height - *bottom - *height - *margin_top - 317 top = container_size.height - *bottom - *height - *margin_top -
333 *margin_bottom; 318 *margin_bottom;
334 } else if (!bottom) { 319 } else if (!bottom) {
335 bottom = 320 bottom =
336 container_size.height - *top - *height - *margin_top - *margin_bottom; 321 container_size.height - *top - *height - *margin_top - *margin_bottom;
337 } else if (!height) { 322 } else if (!height) {
338 height = 323 height =
339 container_size.height - *top - *bottom - *margin_top - *margin_bottom; 324 container_size.height - *top - *bottom - *margin_top - *margin_bottom;
340 } 325 }
341 DCHECK_EQ(container_size.height, 326 DCHECK_EQ(container_size.height,
342 *top + *bottom + *margin_top + *margin_bottom + *height); 327 *top + *bottom + *margin_top + *margin_bottom + *height);
343 328
344 height = ConstrainByMinMax(*height, min_height, max_height); 329 // If calculated height is outside of min/max constraints,
330 // rerun the algorithm with constrained width.
331 Optional<LayoutUnit> min_height;
332 if (!style.minHeight().isAuto())
333 min_height = ResolveHeight(style.minHeight(), space, style, child_minmax,
334 LengthResolveType::kMinSize);
335 Optional<LayoutUnit> max_height;
336 if (!style.maxHeight().isMaxSizeNone())
337 max_height = ResolveHeight(style.maxHeight(), space, style, child_minmax,
338 LengthResolveType::kMaxSize);
339 if (height != ConstrainByMinMax(*height, min_height, max_height)) {
340 height = ConstrainByMinMax(*height, min_height, max_height);
341 ComputeAbsoluteVertical(space, style, height, static_position, child_minmax,
342 position);
343 return;
344 }
345 // Negative heights are not allowed. 345 // Negative heights are not allowed.
346 height = std::max(*height, border_padding); 346 height = std::max(*height, border_padding);
347 347
348 position->inset.top = *top + *margin_top; 348 position->inset.top = *top + *margin_top;
349 position->inset.bottom = *bottom + *margin_bottom; 349 position->inset.bottom = *bottom + *margin_bottom;
350 position->size.height = *height; 350 position->size.height = *height;
351 } 351 }
352 352
353 } // namespace 353 } // namespace
354 354
(...skipping 28 matching lines...) Expand all
383 return (contains_absolute && position == AbsolutePosition) || 383 return (contains_absolute && position == AbsolutePosition) ||
384 (contains_fixed && position == FixedPosition); 384 (contains_fixed && position == FixedPosition);
385 } 385 }
386 386
387 NGAbsolutePhysicalPosition ComputePartialAbsoluteWithChildInlineSize( 387 NGAbsolutePhysicalPosition ComputePartialAbsoluteWithChildInlineSize(
388 const NGConstraintSpace& space, 388 const NGConstraintSpace& space,
389 const ComputedStyle& style, 389 const ComputedStyle& style,
390 const NGStaticPosition& static_position, 390 const NGStaticPosition& static_position,
391 const Optional<MinAndMaxContentSizes>& child_minmax) { 391 const Optional<MinAndMaxContentSizes>& child_minmax) {
392 NGAbsolutePhysicalPosition position; 392 NGAbsolutePhysicalPosition position;
393 if (style.isHorizontalWritingMode()) 393 if (style.isHorizontalWritingMode()) {
394 ComputeAbsoluteHorizontal(space, style, static_position, child_minmax, 394 Optional<LayoutUnit> width;
395 &position); 395 if (!style.width().isAuto()) {
396 else { 396 width = ResolveWidth(style.width(), space, style, child_minmax,
397 ComputeAbsoluteVertical(space, style, static_position, child_minmax, 397 LengthResolveType::kContentSize);
398 }
399 ComputeAbsoluteHorizontal(space, style, width, static_position,
400 child_minmax, &position);
401 } else {
402 Optional<LayoutUnit> height;
403 if (!style.height().isAuto()) {
404 height = ResolveHeight(style.height(), space, style, child_minmax,
405 LengthResolveType::kContentSize);
406 }
407 ComputeAbsoluteVertical(space, style, height, static_position, child_minmax,
398 &position); 408 &position);
399 } 409 }
400 return position; 410 return position;
401 } 411 }
402 412
403 void ComputeFullAbsoluteWithChildBlockSize( 413 void ComputeFullAbsoluteWithChildBlockSize(
404 const NGConstraintSpace& space, 414 const NGConstraintSpace& space,
405 const ComputedStyle& style, 415 const ComputedStyle& style,
406 const NGStaticPosition& static_position, 416 const NGStaticPosition& static_position,
407 const Optional<LayoutUnit>& child_block_size, 417 const Optional<LayoutUnit>& child_block_size,
408 NGAbsolutePhysicalPosition* position) { 418 NGAbsolutePhysicalPosition* position) {
409 // After partial size has been computed, child block size is either 419 // After partial size has been computed, child block size is either
410 // unknown, or fully computed, there is no minmax. 420 // unknown, or fully computed, there is no minmax.
411 // To express this, a 'fixed' minmax is created where 421 // To express this, a 'fixed' minmax is created where
412 // min and max are the same. 422 // min and max are the same.
413 Optional<MinAndMaxContentSizes> child_minmax; 423 Optional<MinAndMaxContentSizes> child_minmax;
414 if (child_block_size.has_value()) { 424 if (child_block_size.has_value()) {
415 child_minmax = MinAndMaxContentSizes{*child_block_size, *child_block_size}; 425 child_minmax = MinAndMaxContentSizes{*child_block_size, *child_block_size};
416 } 426 }
417 if (style.isHorizontalWritingMode()) 427 if (style.isHorizontalWritingMode()) {
418 ComputeAbsoluteVertical(space, style, static_position, child_minmax, 428 Optional<LayoutUnit> height;
429 if (!style.height().isAuto()) {
430 height = ResolveHeight(style.height(), space, style, child_minmax,
431 LengthResolveType::kContentSize);
432 }
433 ComputeAbsoluteVertical(space, style, height, static_position, child_minmax,
419 position); 434 position);
420 else { 435 } else {
421 ComputeAbsoluteHorizontal(space, style, static_position, child_minmax, 436 Optional<LayoutUnit> width;
422 position); 437 if (!style.width().isAuto()) {
438 width = ResolveWidth(style.width(), space, style, child_minmax,
439 LengthResolveType::kContentSize);
440 }
441 ComputeAbsoluteHorizontal(space, style, width, static_position,
442 child_minmax, position);
423 } 443 }
424 } 444 }
425 445
426 } // namespace blink 446 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/LayoutTests/TestExpectations ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698