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_physical_fragment_base.h" | 8 #include "core/layout/ng/ng_physical_fragment_base.h" |
9 #include "core/layout/ng/ng_units.h" | 9 #include "core/layout/ng/ng_units.h" |
10 | 10 |
11 namespace blink { | 11 namespace blink { |
12 | 12 |
13 class NGFragmentBase; | 13 class NGFragmentBase; |
14 class NGInlineNode; | 14 class NGInlineNode; |
15 class NGPhysicalFragment; | 15 class NGPhysicalFragment; |
16 class NGPhysicalTextFragment; | 16 class NGPhysicalTextFragment; |
17 | 17 |
18 class CORE_EXPORT NGFragmentBuilder final | 18 class CORE_EXPORT NGFragmentBuilder final |
19 : public GarbageCollectedFinalized<NGFragmentBuilder> { | 19 : public GarbageCollectedFinalized<NGFragmentBuilder> { |
20 public: | 20 public: |
21 NGFragmentBuilder(NGPhysicalFragmentBase::NGFragmentType); | 21 NGFragmentBuilder(NGPhysicalFragmentBase::NGFragmentType); |
22 | 22 |
23 using WeakBoxList = HeapLinkedHashSet<WeakMember<NGBlockNode>>; | 23 using WeakBoxList = HeapLinkedHashSet<WeakMember<NGBlockNode>>; |
24 | 24 |
25 NGFragmentBuilder& SetWritingMode(NGWritingMode); | 25 NGFragmentBuilder& SetWritingMode(NGWritingMode); |
26 NGFragmentBuilder& SetDirection(TextDirection); | 26 NGFragmentBuilder& SetDirection(TextDirection); |
27 | 27 |
28 NGFragmentBuilder& SetInlineSize(LayoutUnit); | 28 NGFragmentBuilder& SetInlineSize(LayoutUnit); |
29 NGFragmentBuilder& SetBlockSize(LayoutUnit); | 29 NGFragmentBuilder& SetBlockSize(LayoutUnit); |
| 30 NGLogicalSize Size() const { return size_; } |
30 | 31 |
31 NGFragmentBuilder& SetInlineOverflow(LayoutUnit); | 32 NGFragmentBuilder& SetInlineOverflow(LayoutUnit); |
32 NGFragmentBuilder& SetBlockOverflow(LayoutUnit); | 33 NGFragmentBuilder& SetBlockOverflow(LayoutUnit); |
33 | 34 |
34 NGFragmentBuilder& AddChild(NGFragmentBase*, NGLogicalOffset); | 35 NGFragmentBuilder& AddChild(NGFragmentBase*, const NGLogicalOffset&); |
35 | 36 |
36 // Builder has non-trivial out-of-flow descendant methods. | 37 // Builder has non-trivial out-of-flow descendant methods. |
37 // These methods are building blocks for implementation of | 38 // These methods are building blocks for implementation of |
38 // out-of-flow descendants by layout algorithms. | 39 // out-of-flow descendants by layout algorithms. |
39 // | 40 // |
40 // They are intended to be used by layout algorithm like this: | 41 // They are intended to be used by layout algorithm like this: |
41 // | 42 // |
42 // Part 1: layout algorithm positions in-flow children. | 43 // Part 1: layout algorithm positions in-flow children. |
43 // out-of-flow children, and out-of-flow descendants of fragments | 44 // out-of-flow children, and out-of-flow descendants of fragments |
44 // are stored inside builder. | 45 // are stored inside builder. |
45 // | 46 // |
46 // for (child : children) | 47 // for (child : children) |
47 // if (child->position == (Absolute or Fixed)) | 48 // if (child->position == (Absolute or Fixed)) |
48 // builder->AddOutOfFlowChildCandidate(child); | 49 // builder->AddOutOfFlowChildCandidate(child); |
49 // else | 50 // else |
50 // fragment = child->Layout() | 51 // fragment = child->Layout() |
51 // builder->AddChild(fragment) | 52 // builder->AddChild(fragment) |
52 // end | 53 // end |
53 // | 54 // |
54 // Part 2: layout algorithm positions out-of-flow descendants. | 55 // Part 2: layout algorithm positions out-of-flow descendants. |
55 // | 56 // |
56 // builder->SetInlineSize/SetBlockSize | 57 // builder->SetInlineSize/SetBlockSize |
57 // builder->GetAndClearOutOfFlowDescendantCandidates(oof_candidates) | 58 // builder->GetAndClearOutOfFlowDescendantCandidates(oof_candidates) |
| 59 // NGOutOfFlowLayoutPart out_of_flow_layout(container_style, |
| 60 // builder->Size()); |
58 // while (oof_candidates.size() > 0) | 61 // while (oof_candidates.size() > 0) |
59 // { | 62 // { |
60 // candidate = oof_candidates.shift() | 63 // candidate = oof_candidates.shift() |
61 // if (CanPosition(candidate)) | 64 // if (out_of_flow_layout.StartLayout(candidate)) |
62 // fragment = candidate->Layout(); | 65 // NGFragmentBase* fragment; |
| 66 // NGLogicalOffset* fragment_offset; |
| 67 // while (out_of_flow_layout.Layout(&fragment, &fragment_offset) == |
| 68 // kNotFinished) |
| 69 // ; |
63 // builder->AddChild(fragment); | 70 // builder->AddChild(fragment); |
64 // builder->GetAndClearOutOfFlowDescendantCandidates(child_oof_candidates) | 71 // builder->GetAndClearOutOfFlowDescendantCandidates(child_oof_candidates) |
65 // oof_candidates.prepend(child_oof_candidates) | 72 // oof_candidates.prepend(child_oof_candidates) |
66 // else | 73 // else |
67 // builder->AddOutOfFlowDescendant(); | 74 // builder->AddOutOfFlowDescendant(); |
68 // } | 75 // } |
69 NGFragmentBuilder& AddOutOfFlowChildCandidate(NGBlockNode*, NGLogicalOffset); | 76 NGFragmentBuilder& AddOutOfFlowChildCandidate(NGBlockNode*, NGLogicalOffset); |
70 | 77 |
71 void GetAndClearOutOfFlowDescendantCandidates(WeakBoxList*, | 78 void GetAndClearOutOfFlowDescendantCandidates(WeakBoxList*, |
72 Vector<NGStaticPosition>*); | 79 Vector<NGStaticPosition>*); |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
123 WeakBoxList out_of_flow_descendant_candidates_; | 130 WeakBoxList out_of_flow_descendant_candidates_; |
124 Vector<OutOfFlowPlacement> out_of_flow_candidate_placements_; | 131 Vector<OutOfFlowPlacement> out_of_flow_candidate_placements_; |
125 | 132 |
126 WeakBoxList out_of_flow_descendants_; | 133 WeakBoxList out_of_flow_descendants_; |
127 Vector<NGStaticPosition> out_of_flow_positions_; | 134 Vector<NGStaticPosition> out_of_flow_positions_; |
128 }; | 135 }; |
129 | 136 |
130 } // namespace blink | 137 } // namespace blink |
131 | 138 |
132 #endif // NGFragmentBuilder | 139 #endif // NGFragmentBuilder |
OLD | NEW |