OLD | NEW |
1 // Copyright 2017 The Chromium Authors. All rights reserved. | 1 // Copyright 2017 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 NGLayoutResult_h | 5 #ifndef NGLayoutResult_h |
6 #define NGLayoutResult_h | 6 #define NGLayoutResult_h |
7 | 7 |
8 #include "core/CoreExport.h" | 8 #include "core/CoreExport.h" |
9 #include "core/layout/ng/geometry/ng_static_position.h" | 9 #include "core/layout/ng/geometry/ng_static_position.h" |
10 #include "core/layout/ng/ng_block_node.h" | 10 #include "core/layout/ng/ng_block_node.h" |
11 #include "core/layout/ng/ng_out_of_flow_positioned_descendant.h" | 11 #include "core/layout/ng/ng_out_of_flow_positioned_descendant.h" |
12 #include "core/layout/ng/ng_physical_fragment.h" | 12 #include "core/layout/ng/ng_physical_fragment.h" |
13 #include "core/layout/ng/ng_unpositioned_float.h" | 13 #include "core/layout/ng/ng_unpositioned_float.h" |
14 #include "platform/LayoutUnit.h" | 14 #include "platform/LayoutUnit.h" |
15 #include "platform/heap/Handle.h" | 15 #include "platform/heap/Handle.h" |
16 #include "platform/wtf/RefPtr.h" | 16 #include "platform/wtf/RefPtr.h" |
17 #include "platform/wtf/Vector.h" | 17 #include "platform/wtf/Vector.h" |
18 | 18 |
19 namespace blink { | 19 namespace blink { |
20 | 20 |
21 // The NGLayoutResult stores the resulting data from layout. This includes | 21 // The NGLayoutResult stores the resulting data from layout. This includes |
22 // geometry information in form of a NGPhysicalFragment, which is kept around | 22 // geometry information in form of a NGPhysicalFragment, which is kept around |
23 // for painting, hit testing, etc., as well as additional data which is only | 23 // for painting, hit testing, etc., as well as additional data which is only |
24 // necessary during layout and stored on this object. | 24 // necessary during layout and stored on this object. |
25 // Layout code should access the NGPhysicalFragment through the wrappers in | 25 // Layout code should access the NGPhysicalFragment through the wrappers in |
26 // NGFragment et al. | 26 // NGFragment et al. |
27 class CORE_EXPORT NGLayoutResult : public RefCounted<NGLayoutResult> { | 27 class CORE_EXPORT NGLayoutResult : public RefCounted<NGLayoutResult> { |
28 public: | 28 public: |
| 29 enum NGLayoutResultStatus { |
| 30 kSuccess = 0, |
| 31 kBfcOffsetResolved = 1, |
| 32 // When adding new values, make sure the bit size of |status_| is large |
| 33 // enough to store. |
| 34 }; |
| 35 |
29 RefPtr<NGPhysicalFragment> PhysicalFragment() const { | 36 RefPtr<NGPhysicalFragment> PhysicalFragment() const { |
30 return physical_fragment_; | 37 return physical_fragment_; |
31 } | 38 } |
| 39 |
32 RefPtr<NGPhysicalFragment>& MutablePhysicalFragment() { | 40 RefPtr<NGPhysicalFragment>& MutablePhysicalFragment() { |
33 return physical_fragment_; | 41 return physical_fragment_; |
34 } | 42 } |
35 | 43 |
36 const Vector<NGOutOfFlowPositionedDescendant> OutOfFlowPositionedDescendants() | 44 const Vector<NGOutOfFlowPositionedDescendant> OutOfFlowPositionedDescendants() |
37 const { | 45 const { |
38 return oof_positioned_descendants_; | 46 return oof_positioned_descendants_; |
39 } | 47 } |
40 | 48 |
41 // List of floats that need to be positioned by the next in-flow child that | 49 // List of floats that need to be positioned by the next in-flow child that |
42 // can determine its position in space. | 50 // can determine its position in space. |
43 // Use case example where it may be needed: | 51 // Use case example where it may be needed: |
44 // <div><float></div> | 52 // <div><float></div> |
45 // <div style="margin-top: 10px; height: 20px"></div> | 53 // <div style="margin-top: 10px; height: 20px"></div> |
46 // The float cannot be positioned right away inside of the 1st div because | 54 // The float cannot be positioned right away inside of the 1st div because |
47 // the vertical position is not known at that moment. It will be known only | 55 // the vertical position is not known at that moment. It will be known only |
48 // after the 2nd div collapses its margin with its parent. | 56 // after the 2nd div collapses its margin with its parent. |
49 const Vector<RefPtr<NGUnpositionedFloat>>& UnpositionedFloats() const { | 57 const Vector<RefPtr<NGUnpositionedFloat>>& UnpositionedFloats() const { |
50 return unpositioned_floats_; | 58 return unpositioned_floats_; |
51 } | 59 } |
52 | 60 |
| 61 NGLayoutResultStatus Status() const { |
| 62 return static_cast<NGLayoutResultStatus>(status_); |
| 63 } |
| 64 |
53 const WTF::Optional<NGLogicalOffset>& BfcOffset() const { | 65 const WTF::Optional<NGLogicalOffset>& BfcOffset() const { |
54 return bfc_offset_; | 66 return bfc_offset_; |
55 } | 67 } |
56 | 68 |
57 const NGMarginStrut EndMarginStrut() const { return end_margin_strut_; } | 69 const NGMarginStrut EndMarginStrut() const { return end_margin_strut_; } |
58 | 70 |
59 private: | 71 private: |
60 friend class NGFragmentBuilder; | 72 friend class NGFragmentBuilder; |
61 | 73 |
62 NGLayoutResult(PassRefPtr<NGPhysicalFragment> physical_fragment, | 74 NGLayoutResult(PassRefPtr<NGPhysicalFragment> physical_fragment, |
63 Vector<NGOutOfFlowPositionedDescendant> | 75 Vector<NGOutOfFlowPositionedDescendant> |
64 out_of_flow_positioned_descendants, | 76 out_of_flow_positioned_descendants, |
65 Vector<RefPtr<NGUnpositionedFloat>>& unpositioned_floats, | 77 Vector<RefPtr<NGUnpositionedFloat>>& unpositioned_floats, |
66 const WTF::Optional<NGLogicalOffset> bfc_offset, | 78 const WTF::Optional<NGLogicalOffset> bfc_offset, |
67 const NGMarginStrut end_margin_strut); | 79 const NGMarginStrut end_margin_strut, |
| 80 NGLayoutResultStatus status); |
68 | 81 |
69 RefPtr<NGPhysicalFragment> physical_fragment_; | 82 RefPtr<NGPhysicalFragment> physical_fragment_; |
70 Vector<RefPtr<NGUnpositionedFloat>> unpositioned_floats_; | 83 Vector<RefPtr<NGUnpositionedFloat>> unpositioned_floats_; |
71 | 84 |
72 Vector<NGOutOfFlowPositionedDescendant> oof_positioned_descendants_; | 85 Vector<NGOutOfFlowPositionedDescendant> oof_positioned_descendants_; |
73 const WTF::Optional<NGLogicalOffset> bfc_offset_; | 86 const WTF::Optional<NGLogicalOffset> bfc_offset_; |
74 const NGMarginStrut end_margin_strut_; | 87 const NGMarginStrut end_margin_strut_; |
| 88 |
| 89 unsigned status_ : 1; |
75 }; | 90 }; |
76 | 91 |
77 } // namespace blink | 92 } // namespace blink |
78 | 93 |
79 #endif // NGLayoutResult_h | 94 #endif // NGLayoutResult_h |
OLD | NEW |