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 NGAbsoluteUtils_h | 5 #ifndef NGAbsoluteUtils_h |
6 #define NGAbsoluteUtils_h | 6 #define NGAbsoluteUtils_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/geometry/ng_physical_size.h" | |
11 #include "core/layout/ng/geometry/ng_static_position.h" | |
12 #include "core/layout/ng/ng_min_max_content_size.h" | |
13 #include "platform/LayoutUnit.h" | 10 #include "platform/LayoutUnit.h" |
14 #include "wtf/Optional.h" | 11 #include "wtf/Optional.h" |
15 | 12 |
16 namespace blink { | 13 namespace blink { |
17 | 14 |
18 class ComputedStyle; | 15 class ComputedStyle; |
19 class NGConstraintSpace; | 16 class NGConstraintSpace; |
20 | 17 |
21 struct CORE_EXPORT NGAbsolutePhysicalPosition { | 18 struct CORE_EXPORT NGAbsolutePhysicalPosition { |
22 NGPhysicalBoxStrut inset; | 19 NGPhysicalBoxStrut inset; |
23 NGPhysicalSize size; | 20 NGPhysicalSize size; |
24 String ToString() const; | 21 String ToString() const; |
25 }; | 22 }; |
26 | 23 |
27 // The following routines implement absolute size resolution algorithm. | 24 // The following routines implement absolute size resolution algorithm. |
28 // https://www.w3.org/TR/css-position-3/#abs-non-replaced-width | 25 // https://www.w3.org/TR/css-position-3/#abs-non-replaced-width |
29 // | 26 // |
30 // The size is computed as NGAbsolutePhysicalPosition. | 27 // The size is computed as NGAbsolutePhysicalPosition. |
31 // It needs to be computed in 4 stages: | 28 // It needs to be computed in 4 stages: |
32 // 1. If AbsoluteNeedsChildInlineSize compute estimated inline_size using | 29 // 1. If AbsoluteNeedsChildInlineSize compute estimated inline_size using |
33 // MinMaxContentSize.ShrinkToFit. | 30 // MinAndMaxContentSizes.ShrinkToFit. |
34 // 2. Compute part of PhysicalPosition that depends upon child inline size | 31 // 2. Compute part of PhysicalPosition that depends upon child inline size |
35 // with ComputePartialAbsoluteWithChildInlineSize. | 32 // with ComputePartialAbsoluteWithChildInlineSize. |
36 // 3. If AbsoluteNeedsChildBlockSize compute estimated block_size by | 33 // 3. If AbsoluteNeedsChildBlockSize compute estimated block_size by |
37 // performing layout with the inline_size calculated from (2). | 34 // performing layout with the inline_size calculated from (2). |
38 // 4. Compute full PhysicalPosition by filling it in with parts that depend | 35 // 4. Compute full PhysicalPosition by filling it in with parts that depend |
39 // upon child's block_size. | 36 // upon child's block_size. |
40 | 37 |
41 // True if ComputePartialAbsoluteWithChildInlineSize will need | 38 // True if ComputePartialAbsoluteWithChildInlineSize will need |
42 // estimated inline size. | 39 // estimated inline size. |
43 CORE_EXPORT bool AbsoluteNeedsChildInlineSize(const ComputedStyle&); | 40 CORE_EXPORT bool AbsoluteNeedsChildInlineSize(const ComputedStyle&); |
44 | 41 |
45 // True if ComputeFullAbsoluteWithChildBlockSize will need | 42 // True if ComputeFullAbsoluteWithChildBlockSize will need |
46 // estimated block size. | 43 // estimated block size. |
47 CORE_EXPORT bool AbsoluteNeedsChildBlockSize(const ComputedStyle&); | 44 CORE_EXPORT bool AbsoluteNeedsChildBlockSize(const ComputedStyle&); |
48 | 45 |
49 // Compute part of position that depends on child's inline_size | 46 // Compute part of position that depends on child's inline_size |
50 // returns partially filled position. | 47 // returns partially filled position. |
51 CORE_EXPORT NGAbsolutePhysicalPosition | 48 CORE_EXPORT NGAbsolutePhysicalPosition |
52 ComputePartialAbsoluteWithChildInlineSize( | 49 ComputePartialAbsoluteWithChildInlineSize( |
53 const NGConstraintSpace& space, | 50 const NGConstraintSpace& space, |
54 const ComputedStyle& style, | 51 const ComputedStyle& style, |
55 const NGStaticPosition&, | 52 const NGStaticPosition&, |
56 const Optional<MinMaxContentSize>& child_minmax); | 53 const Optional<MinAndMaxContentSizes>& child_minmax); |
57 | 54 |
58 // Compute rest of NGPhysicalRect that depends on child's block_size. | 55 // Compute rest of NGPhysicalRect that depends on child's block_size. |
59 CORE_EXPORT void ComputeFullAbsoluteWithChildBlockSize( | 56 CORE_EXPORT void ComputeFullAbsoluteWithChildBlockSize( |
60 const NGConstraintSpace& space, | 57 const NGConstraintSpace& space, |
61 const ComputedStyle& style, | 58 const ComputedStyle& style, |
62 const NGStaticPosition&, | 59 const NGStaticPosition&, |
63 const Optional<LayoutUnit>& child_block_size, | 60 const Optional<LayoutUnit>& child_block_size, |
64 NGAbsolutePhysicalPosition* position); | 61 NGAbsolutePhysicalPosition* position); |
65 | 62 |
66 // TODO(atotic) Absolute coordinates for replaced elements | 63 // TODO(atotic) Absolute coordinates for replaced elements |
67 // ComputeAbsoluteReplaced. | 64 // ComputeAbsoluteReplaced. |
68 // https://www.w3.org/TR/css-position-3/#abs-replaced-width | 65 // https://www.w3.org/TR/css-position-3/#abs-replaced-width |
69 } // namespace blink | 66 } // namespace blink |
70 | 67 |
71 #endif // NGAbsoluteUtils_h | 68 #endif // NGAbsoluteUtils_h |
OLD | NEW |