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

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: CR fixes 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 // Because this function only changes "width" when it's not already
201 // set, it is safe to recursively call ourselves here because on the
202 // second call it is guaranteed to be within min..max.
203 ComputeAbsoluteHorizontal(space, style, width, static_position,
204 child_minmax, position);
205 return;
206 }
207
204 // Negative widths are not allowed. 208 // Negative widths are not allowed.
205 width = std::max(*width, border_padding); 209 width = std::max(*width, border_padding);
206 210
207 position->inset.left = *left + *margin_left; 211 position->inset.left = *left + *margin_left;
208 position->inset.right = *right + *margin_right; 212 position->inset.right = *right + *margin_right;
209 position->size.width = *width; 213 position->size.width = *width;
210 } 214 }
211 215
212 // Implements absolute vertical size resolution algorithm. 216 // Implements absolute vertical size resolution algorithm.
213 // https://www.w3.org/TR/css-position-3/#abs-non-replaced-height 217 // https://www.w3.org/TR/css-position-3/#abs-non-replaced-height
214 void ComputeAbsoluteVertical( 218 void ComputeAbsoluteVertical(
215 const NGConstraintSpace& space, 219 const NGConstraintSpace& space,
216 const ComputedStyle& style, 220 const ComputedStyle& style,
221 const Optional<LayoutUnit>& incoming_height,
217 const NGStaticPosition& static_position, 222 const NGStaticPosition& static_position,
218 const Optional<MinAndMaxContentSizes>& child_minmax, 223 const Optional<MinAndMaxContentSizes>& child_minmax,
219 NGAbsolutePhysicalPosition* position) { 224 NGAbsolutePhysicalPosition* position) {
220 NGLogicalSize percentage_logical = space.PercentageResolutionSize(); 225 NGLogicalSize percentage_logical = space.PercentageResolutionSize();
221 NGPhysicalSize percentage_physical = 226 NGPhysicalSize percentage_physical =
222 percentage_logical.ConvertToPhysical(space.WritingMode()); 227 percentage_logical.ConvertToPhysical(space.WritingMode());
223 228
224 LayoutUnit border_top(style.borderTopWidth()); 229 LayoutUnit border_top(style.borderTopWidth());
225 LayoutUnit border_bottom(style.borderBottomWidth()); 230 LayoutUnit border_bottom(style.borderBottomWidth());
226 LayoutUnit padding_top = 231 LayoutUnit padding_top =
227 valueForLength(style.paddingTop(), percentage_logical.inline_size); 232 valueForLength(style.paddingTop(), percentage_logical.inline_size);
228 LayoutUnit padding_bottom = 233 LayoutUnit padding_bottom =
229 valueForLength(style.paddingBottom(), percentage_logical.inline_size); 234 valueForLength(style.paddingBottom(), percentage_logical.inline_size);
230 Optional<LayoutUnit> margin_top; 235 Optional<LayoutUnit> margin_top;
231 if (!style.marginTop().isAuto()) 236 if (!style.marginTop().isAuto())
232 margin_top = 237 margin_top =
233 valueForLength(style.marginTop(), percentage_logical.inline_size); 238 valueForLength(style.marginTop(), percentage_logical.inline_size);
234 Optional<LayoutUnit> margin_bottom; 239 Optional<LayoutUnit> margin_bottom;
235 if (!style.marginBottom().isAuto()) 240 if (!style.marginBottom().isAuto())
236 margin_bottom = 241 margin_bottom =
237 valueForLength(style.marginBottom(), percentage_logical.inline_size); 242 valueForLength(style.marginBottom(), percentage_logical.inline_size);
238 Optional<LayoutUnit> top; 243 Optional<LayoutUnit> top;
239 if (!style.top().isAuto()) 244 if (!style.top().isAuto())
240 top = valueForLength(style.top(), percentage_physical.height); 245 top = valueForLength(style.top(), percentage_physical.height);
241 Optional<LayoutUnit> bottom; 246 Optional<LayoutUnit> bottom;
242 if (!style.bottom().isAuto()) 247 if (!style.bottom().isAuto())
243 bottom = valueForLength(style.bottom(), percentage_physical.height); 248 bottom = valueForLength(style.bottom(), percentage_physical.height);
244 LayoutUnit border_padding = 249 LayoutUnit border_padding =
245 border_top + border_bottom + padding_top + padding_bottom; 250 border_top + border_bottom + padding_top + padding_bottom;
246 251 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 252
262 NGPhysicalSize container_size = 253 NGPhysicalSize container_size =
263 space.AvailableSize().ConvertToPhysical(space.WritingMode()); 254 space.AvailableSize().ConvertToPhysical(space.WritingMode());
264 DCHECK(container_size.height != NGSizeIndefinite); 255 DCHECK(container_size.height != NGSizeIndefinite);
265 256
266 // Solving the equation: 257 // Solving the equation:
267 // top + marginTop + height + marginBottom + bottom 258 // top + marginTop + height + marginBottom + bottom
268 // + border_padding = container height 259 // + border_padding = container height
269 if (!top && !bottom && !height) { 260 if (!top && !bottom && !height) {
270 // Standard: "If all three of top, height, and bottom are auto:" 261 // Standard: "If all three of top, height, and bottom are auto:"
271 if (!margin_top) 262 if (!margin_top)
272 margin_top = LayoutUnit(); 263 margin_top = LayoutUnit();
273 if (!margin_bottom) 264 if (!margin_bottom)
274 margin_bottom = LayoutUnit(); 265 margin_bottom = LayoutUnit();
275 DCHECK(child_minmax.has_value()); 266 DCHECK(child_minmax.has_value());
276 height = child_minmax->ShrinkToFit(container_size.height); 267 height = child_minmax->ShrinkToFit(container_size.height);
277 height = ConstrainByMinMax(*height, min_height, max_height);
278 top = static_position.TopPosition(container_size.height, *height, 268 top = static_position.TopPosition(container_size.height, *height,
279 *margin_top, *margin_bottom); 269 *margin_top, *margin_bottom);
280 } else if (top && bottom && height) { 270 } else if (top && bottom && height) {
281 // Standard: "If top, bottom, and height are not auto:" 271 // Standard: "If top, bottom, and height are not auto:"
282 // Compute margins. 272 // Compute margins.
283 LayoutUnit margin_space = container_size.height - *top - *bottom - *height; 273 LayoutUnit margin_space = container_size.height - *top - *bottom - *height;
284 // When both margins are auto. 274 // When both margins are auto.
285 if (!margin_top && !margin_bottom) { 275 if (!margin_top && !margin_bottom) {
286 if (margin_space > 0) { 276 if (margin_space > 0) {
287 margin_top = margin_space / 2; 277 margin_top = margin_space / 2;
(...skipping 19 matching lines...) Expand all
307 margin_top = LayoutUnit(); 297 margin_top = LayoutUnit();
308 if (!margin_bottom) 298 if (!margin_bottom)
309 margin_bottom = LayoutUnit(); 299 margin_bottom = LayoutUnit();
310 300
311 // Rules 1 through 3, 2 out of 3 are unknown, fix 1. 301 // Rules 1 through 3, 2 out of 3 are unknown, fix 1.
312 if (!top && !height) { 302 if (!top && !height) {
313 // Rule 1. 303 // Rule 1.
314 DCHECK(bottom.has_value()); 304 DCHECK(bottom.has_value());
315 DCHECK(child_minmax.has_value()); 305 DCHECK(child_minmax.has_value());
316 height = child_minmax->ShrinkToFit(container_size.height); 306 height = child_minmax->ShrinkToFit(container_size.height);
317 height = ConstrainByMinMax(*height, min_height, max_height);
318 } else if (!top && !bottom) { 307 } else if (!top && !bottom) {
319 // Rule 2. 308 // Rule 2.
320 DCHECK(height.has_value()); 309 DCHECK(height.has_value());
321 top = static_position.TopPosition(container_size.height, *height, 310 top = static_position.TopPosition(container_size.height, *height,
322 *margin_top, *margin_bottom); 311 *margin_top, *margin_bottom);
323 } else if (!height && !bottom) { 312 } else if (!height && !bottom) {
324 // Rule 3. 313 // Rule 3.
325 DCHECK(child_minmax.has_value()); 314 DCHECK(child_minmax.has_value());
326 height = child_minmax->ShrinkToFit(container_size.height); 315 height = child_minmax->ShrinkToFit(container_size.height);
327 height = ConstrainByMinMax(*height, min_height, max_height);
328 } 316 }
329 317
330 // Rules 4 through 6, 1 out of 3 are unknown. 318 // Rules 4 through 6, 1 out of 3 are unknown.
331 if (!top) { 319 if (!top) {
332 top = container_size.height - *bottom - *height - *margin_top - 320 top = container_size.height - *bottom - *height - *margin_top -
333 *margin_bottom; 321 *margin_bottom;
334 } else if (!bottom) { 322 } else if (!bottom) {
335 bottom = 323 bottom =
336 container_size.height - *top - *height - *margin_top - *margin_bottom; 324 container_size.height - *top - *height - *margin_top - *margin_bottom;
337 } else if (!height) { 325 } else if (!height) {
338 height = 326 height =
339 container_size.height - *top - *bottom - *margin_top - *margin_bottom; 327 container_size.height - *top - *bottom - *margin_top - *margin_bottom;
340 } 328 }
341 DCHECK_EQ(container_size.height, 329 DCHECK_EQ(container_size.height,
342 *top + *bottom + *margin_top + *margin_bottom + *height); 330 *top + *bottom + *margin_top + *margin_bottom + *height);
343 331
344 height = ConstrainByMinMax(*height, min_height, max_height); 332 // If calculated height is outside of min/max constraints,
333 // rerun the algorithm with constrained width.
334 Optional<LayoutUnit> min_height;
335 if (!style.minHeight().isAuto())
336 min_height = ResolveHeight(style.minHeight(), space, style, child_minmax,
337 LengthResolveType::kMinSize);
338 Optional<LayoutUnit> max_height;
339 if (!style.maxHeight().isMaxSizeNone())
340 max_height = ResolveHeight(style.maxHeight(), space, style, child_minmax,
341 LengthResolveType::kMaxSize);
342 if (height != ConstrainByMinMax(*height, min_height, max_height)) {
343 height = ConstrainByMinMax(*height, min_height, max_height);
344 // Because this function only changes "height" when it's not already
345 // set, it is safe to recursively call ourselves here because on the
346 // second call it is guaranteed to be within min..max.
347 ComputeAbsoluteVertical(space, style, height, static_position, child_minmax,
348 position);
349 return;
350 }
345 // Negative heights are not allowed. 351 // Negative heights are not allowed.
346 height = std::max(*height, border_padding); 352 height = std::max(*height, border_padding);
347 353
348 position->inset.top = *top + *margin_top; 354 position->inset.top = *top + *margin_top;
349 position->inset.bottom = *bottom + *margin_bottom; 355 position->inset.bottom = *bottom + *margin_bottom;
350 position->size.height = *height; 356 position->size.height = *height;
351 } 357 }
352 358
353 } // namespace 359 } // namespace
354 360
(...skipping 28 matching lines...) Expand all
383 return (contains_absolute && position == AbsolutePosition) || 389 return (contains_absolute && position == AbsolutePosition) ||
384 (contains_fixed && position == FixedPosition); 390 (contains_fixed && position == FixedPosition);
385 } 391 }
386 392
387 NGAbsolutePhysicalPosition ComputePartialAbsoluteWithChildInlineSize( 393 NGAbsolutePhysicalPosition ComputePartialAbsoluteWithChildInlineSize(
388 const NGConstraintSpace& space, 394 const NGConstraintSpace& space,
389 const ComputedStyle& style, 395 const ComputedStyle& style,
390 const NGStaticPosition& static_position, 396 const NGStaticPosition& static_position,
391 const Optional<MinAndMaxContentSizes>& child_minmax) { 397 const Optional<MinAndMaxContentSizes>& child_minmax) {
392 NGAbsolutePhysicalPosition position; 398 NGAbsolutePhysicalPosition position;
393 if (style.isHorizontalWritingMode()) 399 if (style.isHorizontalWritingMode()) {
394 ComputeAbsoluteHorizontal(space, style, static_position, child_minmax, 400 Optional<LayoutUnit> width;
395 &position); 401 if (!style.width().isAuto()) {
396 else { 402 width = ResolveWidth(style.width(), space, style, child_minmax,
397 ComputeAbsoluteVertical(space, style, static_position, child_minmax, 403 LengthResolveType::kContentSize);
404 }
405 ComputeAbsoluteHorizontal(space, style, width, static_position,
406 child_minmax, &position);
407 } else {
408 Optional<LayoutUnit> height;
409 if (!style.height().isAuto()) {
410 height = ResolveHeight(style.height(), space, style, child_minmax,
411 LengthResolveType::kContentSize);
412 }
413 ComputeAbsoluteVertical(space, style, height, static_position, child_minmax,
398 &position); 414 &position);
399 } 415 }
400 return position; 416 return position;
401 } 417 }
402 418
403 void ComputeFullAbsoluteWithChildBlockSize( 419 void ComputeFullAbsoluteWithChildBlockSize(
404 const NGConstraintSpace& space, 420 const NGConstraintSpace& space,
405 const ComputedStyle& style, 421 const ComputedStyle& style,
406 const NGStaticPosition& static_position, 422 const NGStaticPosition& static_position,
407 const Optional<LayoutUnit>& child_block_size, 423 const Optional<LayoutUnit>& child_block_size,
408 NGAbsolutePhysicalPosition* position) { 424 NGAbsolutePhysicalPosition* position) {
409 // After partial size has been computed, child block size is either 425 // After partial size has been computed, child block size is either
410 // unknown, or fully computed, there is no minmax. 426 // unknown, or fully computed, there is no minmax.
411 // To express this, a 'fixed' minmax is created where 427 // To express this, a 'fixed' minmax is created where
412 // min and max are the same. 428 // min and max are the same.
413 Optional<MinAndMaxContentSizes> child_minmax; 429 Optional<MinAndMaxContentSizes> child_minmax;
414 if (child_block_size.has_value()) { 430 if (child_block_size.has_value()) {
415 child_minmax = MinAndMaxContentSizes{*child_block_size, *child_block_size}; 431 child_minmax = MinAndMaxContentSizes{*child_block_size, *child_block_size};
416 } 432 }
417 if (style.isHorizontalWritingMode()) 433 if (style.isHorizontalWritingMode()) {
418 ComputeAbsoluteVertical(space, style, static_position, child_minmax, 434 Optional<LayoutUnit> height;
435 if (!style.height().isAuto()) {
436 height = ResolveHeight(style.height(), space, style, child_minmax,
437 LengthResolveType::kContentSize);
438 }
439 ComputeAbsoluteVertical(space, style, height, static_position, child_minmax,
419 position); 440 position);
420 else { 441 } else {
421 ComputeAbsoluteHorizontal(space, style, static_position, child_minmax, 442 Optional<LayoutUnit> width;
422 position); 443 if (!style.width().isAuto()) {
444 width = ResolveWidth(style.width(), space, style, child_minmax,
445 LengthResolveType::kContentSize);
446 }
447 ComputeAbsoluteHorizontal(space, style, width, static_position,
448 child_minmax, position);
423 } 449 }
424 } 450 }
425 451
426 } // namespace blink 452 } // 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