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

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

Issue 2723023003: Revert of [LayoutNG] Move remaining ng_units structs to their own files (Closed)
Patch Set: Created 3 years, 9 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
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 10 matching lines...) Expand all
21 21
22 bool AbsoluteVerticalNeedsEstimate(const ComputedStyle& style) { 22 bool AbsoluteVerticalNeedsEstimate(const ComputedStyle& style) {
23 Length height = style.height(); 23 Length height = style.height();
24 return height.isIntrinsic() || 24 return height.isIntrinsic() ||
25 (height.isAuto() && (style.top().isAuto() || style.bottom().isAuto())); 25 (height.isAuto() && (style.top().isAuto() || style.bottom().isAuto()));
26 } 26 }
27 27
28 LayoutUnit ResolveWidth(const Length& width, 28 LayoutUnit ResolveWidth(const Length& width,
29 const NGConstraintSpace& space, 29 const NGConstraintSpace& space,
30 const ComputedStyle& style, 30 const ComputedStyle& style,
31 const Optional<MinMaxContentSize>& child_minmax, 31 const Optional<MinAndMaxContentSizes>& child_minmax,
32 LengthResolveType resolve_type) { 32 LengthResolveType resolve_type) {
33 if (space.WritingMode() == kHorizontalTopBottom) 33 if (space.WritingMode() == kHorizontalTopBottom)
34 return ResolveInlineLength(space, style, child_minmax, width, resolve_type); 34 return ResolveInlineLength(space, style, child_minmax, width, resolve_type);
35 LayoutUnit computed_width = 35 LayoutUnit computed_width =
36 child_minmax.has_value() ? child_minmax->max_content : LayoutUnit(); 36 child_minmax.has_value() ? child_minmax->max_content : LayoutUnit();
37 return ResolveBlockLength(space, style, style.width(), computed_width, 37 return ResolveBlockLength(space, style, style.width(), computed_width,
38 resolve_type); 38 resolve_type);
39 } 39 }
40 40
41 LayoutUnit ResolveHeight(const Length& height, 41 LayoutUnit ResolveHeight(const Length& height,
42 const NGConstraintSpace& space, 42 const NGConstraintSpace& space,
43 const ComputedStyle& style, 43 const ComputedStyle& style,
44 const Optional<MinMaxContentSize>& child_minmax, 44 const Optional<MinAndMaxContentSizes>& child_minmax,
45 LengthResolveType resolve_type) { 45 LengthResolveType resolve_type) {
46 if (space.WritingMode() != kHorizontalTopBottom) 46 if (space.WritingMode() != kHorizontalTopBottom)
47 return ResolveInlineLength(space, style, child_minmax, height, 47 return ResolveInlineLength(space, style, child_minmax, height,
48 resolve_type); 48 resolve_type);
49 LayoutUnit computed_height = 49 LayoutUnit computed_height =
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(const NGConstraintSpace& space, 57 void ComputeAbsoluteHorizontal(
58 const ComputedStyle& style, 58 const NGConstraintSpace& space,
59 const Optional<LayoutUnit>& incoming_width, 59 const ComputedStyle& style,
60 const NGStaticPosition& static_position, 60 const Optional<LayoutUnit>& incoming_width,
61 const Optional<MinMaxContentSize>& child_minmax, 61 const NGStaticPosition& static_position,
62 NGAbsolutePhysicalPosition* position) { 62 const Optional<MinAndMaxContentSizes>& child_minmax,
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;
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after
207 // Negative widths are not allowed. 208 // Negative widths are not allowed.
208 width = std::max(*width, border_padding); 209 width = std::max(*width, border_padding);
209 210
210 position->inset.left = *left + *margin_left; 211 position->inset.left = *left + *margin_left;
211 position->inset.right = *right + *margin_right; 212 position->inset.right = *right + *margin_right;
212 position->size.width = *width; 213 position->size.width = *width;
213 } 214 }
214 215
215 // Implements absolute vertical size resolution algorithm. 216 // Implements absolute vertical size resolution algorithm.
216 // 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
217 void ComputeAbsoluteVertical(const NGConstraintSpace& space, 218 void ComputeAbsoluteVertical(
218 const ComputedStyle& style, 219 const NGConstraintSpace& space,
219 const Optional<LayoutUnit>& incoming_height, 220 const ComputedStyle& style,
220 const NGStaticPosition& static_position, 221 const Optional<LayoutUnit>& incoming_height,
221 const Optional<MinMaxContentSize>& child_minmax, 222 const NGStaticPosition& static_position,
222 NGAbsolutePhysicalPosition* position) { 223 const Optional<MinAndMaxContentSizes>& child_minmax,
224 NGAbsolutePhysicalPosition* position) {
223 NGLogicalSize percentage_logical = space.PercentageResolutionSize(); 225 NGLogicalSize percentage_logical = space.PercentageResolutionSize();
224 NGPhysicalSize percentage_physical = 226 NGPhysicalSize percentage_physical =
225 percentage_logical.ConvertToPhysical(space.WritingMode()); 227 percentage_logical.ConvertToPhysical(space.WritingMode());
226 228
227 LayoutUnit border_top(style.borderTopWidth()); 229 LayoutUnit border_top(style.borderTopWidth());
228 LayoutUnit border_bottom(style.borderBottomWidth()); 230 LayoutUnit border_bottom(style.borderBottomWidth());
229 LayoutUnit padding_top = 231 LayoutUnit padding_top =
230 valueForLength(style.paddingTop(), percentage_logical.inline_size); 232 valueForLength(style.paddingTop(), percentage_logical.inline_size);
231 LayoutUnit padding_bottom = 233 LayoutUnit padding_bottom =
232 valueForLength(style.paddingBottom(), percentage_logical.inline_size); 234 valueForLength(style.paddingBottom(), percentage_logical.inline_size);
(...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after
374 if (style.isHorizontalWritingMode()) 376 if (style.isHorizontalWritingMode())
375 return AbsoluteHorizontalNeedsEstimate(style); 377 return AbsoluteHorizontalNeedsEstimate(style);
376 else 378 else
377 return AbsoluteVerticalNeedsEstimate(style); 379 return AbsoluteVerticalNeedsEstimate(style);
378 } 380 }
379 381
380 NGAbsolutePhysicalPosition ComputePartialAbsoluteWithChildInlineSize( 382 NGAbsolutePhysicalPosition ComputePartialAbsoluteWithChildInlineSize(
381 const NGConstraintSpace& space, 383 const NGConstraintSpace& space,
382 const ComputedStyle& style, 384 const ComputedStyle& style,
383 const NGStaticPosition& static_position, 385 const NGStaticPosition& static_position,
384 const Optional<MinMaxContentSize>& child_minmax) { 386 const Optional<MinAndMaxContentSizes>& child_minmax) {
385 NGAbsolutePhysicalPosition position; 387 NGAbsolutePhysicalPosition position;
386 if (style.isHorizontalWritingMode()) { 388 if (style.isHorizontalWritingMode()) {
387 Optional<LayoutUnit> width; 389 Optional<LayoutUnit> width;
388 if (!style.width().isAuto()) { 390 if (!style.width().isAuto()) {
389 width = ResolveWidth(style.width(), space, style, child_minmax, 391 width = ResolveWidth(style.width(), space, style, child_minmax,
390 LengthResolveType::kContentSize); 392 LengthResolveType::kContentSize);
391 } 393 }
392 ComputeAbsoluteHorizontal(space, style, width, static_position, 394 ComputeAbsoluteHorizontal(space, style, width, static_position,
393 child_minmax, &position); 395 child_minmax, &position);
394 } else { 396 } else {
(...skipping 11 matching lines...) Expand all
406 void ComputeFullAbsoluteWithChildBlockSize( 408 void ComputeFullAbsoluteWithChildBlockSize(
407 const NGConstraintSpace& space, 409 const NGConstraintSpace& space,
408 const ComputedStyle& style, 410 const ComputedStyle& style,
409 const NGStaticPosition& static_position, 411 const NGStaticPosition& static_position,
410 const Optional<LayoutUnit>& child_block_size, 412 const Optional<LayoutUnit>& child_block_size,
411 NGAbsolutePhysicalPosition* position) { 413 NGAbsolutePhysicalPosition* position) {
412 // After partial size has been computed, child block size is either 414 // After partial size has been computed, child block size is either
413 // unknown, or fully computed, there is no minmax. 415 // unknown, or fully computed, there is no minmax.
414 // To express this, a 'fixed' minmax is created where 416 // To express this, a 'fixed' minmax is created where
415 // min and max are the same. 417 // min and max are the same.
416 Optional<MinMaxContentSize> child_minmax; 418 Optional<MinAndMaxContentSizes> child_minmax;
417 if (child_block_size.has_value()) { 419 if (child_block_size.has_value()) {
418 child_minmax = MinMaxContentSize{*child_block_size, *child_block_size}; 420 child_minmax = MinAndMaxContentSizes{*child_block_size, *child_block_size};
419 } 421 }
420 if (style.isHorizontalWritingMode()) { 422 if (style.isHorizontalWritingMode()) {
421 Optional<LayoutUnit> height; 423 Optional<LayoutUnit> height;
422 if (!style.height().isAuto()) { 424 if (!style.height().isAuto()) {
423 height = ResolveHeight(style.height(), space, style, child_minmax, 425 height = ResolveHeight(style.height(), space, style, child_minmax,
424 LengthResolveType::kContentSize); 426 LengthResolveType::kContentSize);
425 } 427 }
426 ComputeAbsoluteVertical(space, style, height, static_position, child_minmax, 428 ComputeAbsoluteVertical(space, style, height, static_position, child_minmax,
427 position); 429 position);
428 } else { 430 } else {
429 Optional<LayoutUnit> width; 431 Optional<LayoutUnit> width;
430 if (!style.width().isAuto()) { 432 if (!style.width().isAuto()) {
431 width = ResolveWidth(style.width(), space, style, child_minmax, 433 width = ResolveWidth(style.width(), space, style, child_minmax,
432 LengthResolveType::kContentSize); 434 LengthResolveType::kContentSize);
433 } 435 }
434 ComputeAbsoluteHorizontal(space, style, width, static_position, 436 ComputeAbsoluteHorizontal(space, style, width, static_position,
435 child_minmax, position); 437 child_minmax, position);
436 } 438 }
437 } 439 }
438 440
439 } // namespace blink 441 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698