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