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 NGFragmentBuilder_h | 5 #ifndef NGFragmentBuilder_h |
6 #define NGFragmentBuilder_h | 6 #define NGFragmentBuilder_h |
7 | 7 |
8 #include "core/layout/ng/ng_fragment.h" | 8 #include "core/layout/ng/ng_fragment.h" |
9 #include "core/layout/ng/ng_units.h" | 9 #include "core/layout/ng/ng_units.h" |
10 | 10 |
(...skipping 10 matching lines...) Expand all Loading... | |
21 NGFragmentBuilder& SetDirection(TextDirection); | 21 NGFragmentBuilder& SetDirection(TextDirection); |
22 | 22 |
23 NGFragmentBuilder& SetInlineSize(LayoutUnit); | 23 NGFragmentBuilder& SetInlineSize(LayoutUnit); |
24 NGFragmentBuilder& SetBlockSize(LayoutUnit); | 24 NGFragmentBuilder& SetBlockSize(LayoutUnit); |
25 | 25 |
26 NGFragmentBuilder& SetInlineOverflow(LayoutUnit); | 26 NGFragmentBuilder& SetInlineOverflow(LayoutUnit); |
27 NGFragmentBuilder& SetBlockOverflow(LayoutUnit); | 27 NGFragmentBuilder& SetBlockOverflow(LayoutUnit); |
28 | 28 |
29 NGFragmentBuilder& AddChild(NGFragmentBase*, NGLogicalOffset); | 29 NGFragmentBuilder& AddChild(NGFragmentBase*, NGLogicalOffset); |
30 | 30 |
31 NGFragmentBuilder& SetOutOfFlowDescendants(WeakBoxList&, | 31 // Builder has non-trivial out-of-flow descendant methods. |
32 Vector<NGLogicalOffset>&); | 32 // These methods are building blocks for implementation of |
33 // out-of-flow descendants by layout algorithms. | |
34 // | |
35 // They are intended to be used by layout algorithm like this: | |
36 // | |
37 // Part 1: layout algorithm positions positioned children. | |
ikilpatrick
2016/12/02 21:06:13
s/positioned/in-flow ?
atotic
2016/12/02 22:19:37
done
| |
38 // out-of-flow children, and out-of-flow descendants of positioned childen | |
ikilpatrick
2016/12/02 21:06:13
.... and out-of-flow descendants of fragments
atotic
2016/12/02 22:19:37
done
| |
39 // are stored inside builder. | |
40 // | |
41 // for (child : children) | |
42 // if (child->position == (Absolute or Fixed)) | |
43 // builder->AddOutOfFlowChildCandidate(child); | |
44 // else | |
45 // fragment = child->Layout() | |
46 // builder->AddChild(fragment) | |
47 // end | |
48 // | |
49 // Part 2: layout algorithm positions out-of-flow descendants. | |
50 // | |
51 // builder->SetInlineSize/SetBlockSize | |
52 // builder->GetOutOfFlowDescendantCandidates(oof_candidates) | |
53 // while (oof_candidates.size() > 0) | |
54 // { | |
55 // canditate = oof_candidates.shift | |
ikilpatrick
2016/12/02 21:06:13
.nit s/shift/shift()/
atotic
2016/12/02 22:19:37
done
| |
56 // if (CanPosition(candidate)) | |
57 // fragment = candidate->Layout(); | |
58 // builder->AddChild(fragment); | |
59 // builder->GetOutOfFlowDescendantCandidates(child_oof_candidates) | |
60 // oof_candidates.prepend(child_oof_candidates) | |
61 // else | |
62 // builder->AddOutOfFlowDescendant(); | |
63 // } | |
64 NGFragmentBuilder& AddOutOfFlowChildCandidate(NGBlockNode*, NGLogicalOffset); | |
65 | |
66 void GetOutOfFlowDescendantCandidates(WeakBoxList*, Vector<NGCorner>*); | |
67 | |
68 NGFragmentBuilder& AddOutOfFlowDescendant(NGBlockNode*, const NGCorner&); | |
33 | 69 |
34 // Sets MarginStrut for the resultant fragment. | 70 // Sets MarginStrut for the resultant fragment. |
35 NGFragmentBuilder& SetMarginStrutBlockStart(const NGMarginStrut& from); | 71 NGFragmentBuilder& SetMarginStrutBlockStart(const NGMarginStrut& from); |
36 NGFragmentBuilder& SetMarginStrutBlockEnd(const NGMarginStrut& from); | 72 NGFragmentBuilder& SetMarginStrutBlockEnd(const NGMarginStrut& from); |
37 | 73 |
38 // Offsets are not supposed to be set during fragment construction, so we | 74 // Offsets are not supposed to be set during fragment construction, so we |
39 // do not provide a setter here. | 75 // do not provide a setter here. |
40 | 76 |
41 // Creates the fragment. Can only be called once. | 77 // Creates the fragment. Can only be called once. |
42 NGPhysicalFragment* ToFragment(); | 78 NGPhysicalFragment* ToFragment(); |
43 | 79 |
44 DECLARE_VIRTUAL_TRACE(); | 80 DECLARE_VIRTUAL_TRACE(); |
45 | 81 |
46 private: | 82 private: |
83 // Out-of-flow descendant placement information. | |
84 // Generated fragment must compute NGCorner for all out-of-flow descendants. | |
ikilpatrick
2016/12/02 21:06:13
The generated fragment ...
atotic
2016/12/02 22:19:37
done
| |
85 // NGCorner gets derived from: | |
ikilpatrick
2016/12/02 21:06:13
The resulting NGCorner? maybe?
atotic
2016/12/02 22:19:37
done
| |
86 // 1. Offset of fragment's child wrt fragment. | |
ikilpatrick
2016/12/02 21:06:13
The logical offset of the child within this fragme
atotic
2016/12/02 22:19:37
fixed
| |
87 // 2. Corner of descendant wrt child. | |
88 // child_offset is stored as NGLogicalOffset because physical offset cannot | |
89 // be computed until we know fragment's size. | |
90 struct OutOfFlowPlacement { | |
91 NGLogicalOffset child_offset; | |
92 NGCorner descendant_corner; | |
93 }; | |
94 | |
47 NGPhysicalFragmentBase::NGFragmentType type_; | 95 NGPhysicalFragmentBase::NGFragmentType type_; |
48 NGWritingMode writing_mode_; | 96 NGWritingMode writing_mode_; |
49 TextDirection direction_; | 97 TextDirection direction_; |
50 | 98 |
51 NGLogicalSize size_; | 99 NGLogicalSize size_; |
52 NGLogicalSize overflow_; | 100 NGLogicalSize overflow_; |
53 | 101 |
54 NGMarginStrut margin_strut_; | 102 NGMarginStrut margin_strut_; |
55 | 103 |
56 HeapVector<Member<NGPhysicalFragmentBase>> children_; | 104 HeapVector<Member<NGPhysicalFragmentBase>> children_; |
57 Vector<NGLogicalOffset> offsets_; | 105 Vector<NGLogicalOffset> offsets_; |
106 | |
107 WeakBoxList out_of_flow_descendant_candidates_; | |
108 Vector<OutOfFlowPlacement> out_of_flow_candidate_placements_; | |
109 | |
58 WeakBoxList out_of_flow_descendants_; | 110 WeakBoxList out_of_flow_descendants_; |
59 Vector<NGLogicalOffset> out_of_flow_offsets_; | 111 Vector<NGCorner> out_of_flow_corners_; |
60 }; | 112 }; |
61 | 113 |
62 } // namespace blink | 114 } // namespace blink |
63 | 115 |
64 #endif // NGFragmentBuilder | 116 #endif // NGFragmentBuilder |
OLD | NEW |