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

Side by Side Diff: third_party/WebKit/Source/core/layout/ng/ng_length_utils.h

Issue 2721613003: [LayoutNG] Move remaining ng_units structs to their own files (Closed)
Patch Set: Don't export NGBoxStrut for now 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 #ifndef NGLengthUtils_h 5 #ifndef NGLengthUtils_h
6 #define NGLengthUtils_h 6 #define NGLengthUtils_h
7 7
8 #include "core/CoreExport.h" 8 #include "core/CoreExport.h"
9 #include "core/layout/ng/ng_units.h" 9 #include "core/layout/ng/geometry/ng_box_strut.h"
10 #include "core/layout/ng/ng_min_max_content_size.h"
10 #include "core/layout/ng/ng_writing_mode.h" 11 #include "core/layout/ng/ng_writing_mode.h"
11 #include "platform/text/TextDirection.h" 12 #include "platform/text/TextDirection.h"
12 #include "wtf/Optional.h" 13 #include "wtf/Optional.h"
13 14
14 namespace blink { 15 namespace blink {
15 class ComputedStyle; 16 class ComputedStyle;
16 class LayoutUnit; 17 class LayoutUnit;
17 class Length; 18 class Length;
18 struct MinAndMaxContentSizes; 19 struct MinMaxContentSize;
19 class NGConstraintSpace; 20 class NGConstraintSpace;
20 struct NGBoxStrut; 21 struct NGBoxStrut;
21 22
22 enum class LengthResolveType { 23 enum class LengthResolveType {
23 kMinSize, 24 kMinSize,
24 kMaxSize, 25 kMaxSize,
25 kContentSize, 26 kContentSize,
26 kMarginBorderPaddingSize 27 kMarginBorderPaddingSize
27 }; 28 };
28 29
29 // Whether the caller needs to compute min-content and max-content sizes to 30 // Whether the caller needs to compute min-content and max-content sizes to
30 // pass them to ResolveInlineLength / ComputeInlineSizeForFragment. 31 // pass them to ResolveInlineLength / ComputeInlineSizeForFragment.
31 // If this function returns false, it is safe to pass an empty 32 // If this function returns false, it is safe to pass an empty
32 // MinAndMaxContentSizes struct to those functions. 33 // MinMaxContentSize struct to those functions.
33 CORE_EXPORT bool NeedMinAndMaxContentSizes(const NGConstraintSpace&, 34 CORE_EXPORT bool NeedMinMaxContentSize(const NGConstraintSpace&,
34 const ComputedStyle&); 35 const ComputedStyle&);
35 36
36 // Like NeedMinAndMaxContentSizes, but for use when calling 37 // Like NeedMinMaxContentSize, but for use when calling
37 // ComputeMinAndMaxContentContribution. 38 // ComputeMinAndMaxContentContribution.
38 CORE_EXPORT bool NeedMinAndMaxContentSizesForContentContribution( 39 CORE_EXPORT bool NeedMinMaxContentSizeForContentContribution(
39 const ComputedStyle&); 40 const ComputedStyle&);
40 41
41 // Convert an inline-axis length to a layout unit using the given constraint 42 // Convert an inline-axis length to a layout unit using the given constraint
42 // space. 43 // space.
43 CORE_EXPORT LayoutUnit 44 CORE_EXPORT LayoutUnit
44 ResolveInlineLength(const NGConstraintSpace&, 45 ResolveInlineLength(const NGConstraintSpace&,
45 const ComputedStyle&, 46 const ComputedStyle&,
46 const WTF::Optional<MinAndMaxContentSizes>&, 47 const WTF::Optional<MinMaxContentSize>&,
47 const Length&, 48 const Length&,
48 LengthResolveType); 49 LengthResolveType);
49 50
50 // Convert a block-axis length to a layout unit using the given constraint 51 // Convert a block-axis length to a layout unit using the given constraint
51 // space and content size. 52 // space and content size.
52 CORE_EXPORT LayoutUnit ResolveBlockLength(const NGConstraintSpace&, 53 CORE_EXPORT LayoutUnit ResolveBlockLength(const NGConstraintSpace&,
53 const ComputedStyle&, 54 const ComputedStyle&,
54 const Length&, 55 const Length&,
55 LayoutUnit content_size, 56 LayoutUnit content_size,
56 LengthResolveType); 57 LengthResolveType);
57 58
58 // For the given style and min/max content sizes, computes the min and max 59 // For the given style and min/max content sizes, computes the min and max
59 // content contribution (https://drafts.csswg.org/css-sizing/#contributions). 60 // content contribution (https://drafts.csswg.org/css-sizing/#contributions).
60 // This is similar to ComputeInlineSizeForFragment except that it does not 61 // This is similar to ComputeInlineSizeForFragment except that it does not
61 // require a constraint space (percentage sizes as well as auto margins compute 62 // require a constraint space (percentage sizes as well as auto margins compute
62 // to zero) and that an auto inline size resolves to the respective min/max 63 // to zero) and that an auto inline size resolves to the respective min/max
63 // content size. 64 // content size.
64 // Also, the min/max contribution does include the inline margins as well. 65 // Also, the min/max contribution does include the inline margins as well.
65 CORE_EXPORT MinAndMaxContentSizes ComputeMinAndMaxContentContribution( 66 CORE_EXPORT MinMaxContentSize
66 const ComputedStyle&, 67 ComputeMinAndMaxContentContribution(const ComputedStyle&,
67 const WTF::Optional<MinAndMaxContentSizes>&); 68 const WTF::Optional<MinMaxContentSize>&);
68 69
69 // Resolves the given length to a layout unit, constraining it by the min 70 // Resolves the given length to a layout unit, constraining it by the min
70 // logical width and max logical width properties from the ComputedStyle 71 // logical width and max logical width properties from the ComputedStyle
71 // object. 72 // object.
72 CORE_EXPORT LayoutUnit 73 CORE_EXPORT LayoutUnit
73 ComputeInlineSizeForFragment(const NGConstraintSpace&, 74 ComputeInlineSizeForFragment(const NGConstraintSpace&,
74 const ComputedStyle&, 75 const ComputedStyle&,
75 const WTF::Optional<MinAndMaxContentSizes>&); 76 const WTF::Optional<MinMaxContentSize>&);
76 77
77 // Resolves the given length to a layout unit, constraining it by the min 78 // Resolves the given length to a layout unit, constraining it by the min
78 // logical height and max logical height properties from the ComputedStyle 79 // logical height and max logical height properties from the ComputedStyle
79 // object. 80 // object.
80 CORE_EXPORT LayoutUnit ComputeBlockSizeForFragment(const NGConstraintSpace&, 81 CORE_EXPORT LayoutUnit ComputeBlockSizeForFragment(const NGConstraintSpace&,
81 const ComputedStyle&, 82 const ComputedStyle&,
82 LayoutUnit content_size); 83 LayoutUnit content_size);
83 84
84 // Based on available inline size, CSS computed column-width, CSS computed 85 // Based on available inline size, CSS computed column-width, CSS computed
85 // column-count and CSS used column-gap, return CSS used column-count. 86 // column-count and CSS used column-gap, return CSS used column-count.
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
119 const LayoutUnit& inline_size, 120 const LayoutUnit& inline_size,
120 NGBoxStrut* margins); 121 NGBoxStrut* margins);
121 122
122 CORE_EXPORT LayoutUnit ConstrainByMinMax(LayoutUnit length, 123 CORE_EXPORT LayoutUnit ConstrainByMinMax(LayoutUnit length,
123 Optional<LayoutUnit> min, 124 Optional<LayoutUnit> min,
124 Optional<LayoutUnit> max); 125 Optional<LayoutUnit> max);
125 126
126 } // namespace blink 127 } // namespace blink
127 128
128 #endif // NGLengthUtils_h 129 #endif // NGLengthUtils_h
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698