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 is not dumb when handling out of flow descendants. |
ikilpatrick
2016/12/02 17:47:06
Maybe:
The builder isn't "simple" when handling o
atotic
2016/12/02 19:55:15
entire comment revised for clarity
| |
32 Vector<NGLogicalOffset>&); | 32 // Out of flow descendants API should be used like this: |
33 // for (child : children) | |
34 // if (child->position == (Absolute or Fixed) | |
ikilpatrick
2016/12/02 17:47:06
missing closing ')'
atotic
2016/12/02 19:55:15
entire comment revised for clarity
| |
35 // builder->AddOutOfFlowCandidateChild(child); | |
36 // else | |
37 // child->Layout() | |
ikilpatrick
2016/12/02 17:47:06
i'd write:
fragment = child->Layout()
instead. (m
atotic
2016/12/02 19:55:16
done
| |
38 // builder_->AddChild(child) | |
39 // end | |
40 // builder->SetInlineSize/SetBlockSize | |
41 // while (builder->GetOutOfFlowDescendantCandidates(oof_candidates) | |
ikilpatrick
2016/12/02 17:47:06
while loop bad?
atotic
2016/12/02 19:55:16
entire comment revised for clarity
| |
42 // && oof_candidates.size() > 0) | |
43 // { | |
44 // for (candidate : oof_candidates) | |
45 // if (CanPosition(candidate) | |
46 // candidate->Layout(); | |
47 // builder_->AddChild(); | |
48 // else | |
49 // builder_->AddOutOfFlowDescendant(); | |
50 // } | |
ikilpatrick
2016/12/02 17:47:06
There are two cases:
- The descendant came from a
atotic
2016/12/02 19:55:15
entire comment revised for clarity
| |
51 NGFragmentBuilder& AddOutOfFlowCandidateChild(NGBlockNode*, NGLogicalOffset); | |
ikilpatrick
2016/12/02 17:47:06
AddOutOfFlowDescendantCandidate for consistency.
atotic
2016/12/02 19:55:15
It can only be a child, so will not rename to Desc
| |
52 | |
53 void GetOutOfFlowDescendantCandidates(WeakBoxList&, Vector<NGCorner>&); | |
54 | |
55 NGFragmentBuilder& AddOutOfFlowDescendant(NGBlockNode*, const NGCorner&); | |
33 | 56 |
34 // Sets MarginStrut for the resultant fragment. | 57 // Sets MarginStrut for the resultant fragment. |
35 NGFragmentBuilder& SetMarginStrutBlockStart(const NGMarginStrut& from); | 58 NGFragmentBuilder& SetMarginStrutBlockStart(const NGMarginStrut& from); |
36 NGFragmentBuilder& SetMarginStrutBlockEnd(const NGMarginStrut& from); | 59 NGFragmentBuilder& SetMarginStrutBlockEnd(const NGMarginStrut& from); |
37 | 60 |
38 // Offsets are not supposed to be set during fragment construction, so we | 61 // Offsets are not supposed to be set during fragment construction, so we |
39 // do not provide a setter here. | 62 // do not provide a setter here. |
40 | 63 |
41 // Creates the fragment. Can only be called once. | 64 // Creates the fragment. Can only be called once. |
42 NGPhysicalFragment* ToFragment(); | 65 NGPhysicalFragment* ToFragment(); |
43 | 66 |
44 DECLARE_VIRTUAL_TRACE(); | 67 DECLARE_VIRTUAL_TRACE(); |
45 | 68 |
46 private: | 69 private: |
70 // Descendant offset information | |
ikilpatrick
2016/12/02 17:47:06
Maybe:
Descendant offset information. We need inf
atotic
2016/12/02 19:55:16
Renamed OutOfFlowOffset to OutOfFlowPlacement for
| |
71 struct OutOfFlowOffset { | |
72 NGLogicalOffset child_offset; | |
73 NGCorner descendant_corner; | |
74 }; | |
75 | |
47 NGPhysicalFragmentBase::NGFragmentType type_; | 76 NGPhysicalFragmentBase::NGFragmentType type_; |
48 NGWritingMode writing_mode_; | 77 NGWritingMode writing_mode_; |
49 TextDirection direction_; | 78 TextDirection direction_; |
50 | 79 |
51 NGLogicalSize size_; | 80 NGLogicalSize size_; |
52 NGLogicalSize overflow_; | 81 NGLogicalSize overflow_; |
53 | 82 |
54 NGMarginStrut margin_strut_; | 83 NGMarginStrut margin_strut_; |
55 | 84 |
56 HeapVector<Member<NGPhysicalFragmentBase>> children_; | 85 HeapVector<Member<NGPhysicalFragmentBase>> children_; |
57 Vector<NGLogicalOffset> offsets_; | 86 Vector<NGLogicalOffset> offsets_; |
87 | |
88 WeakBoxList out_of_flow_descendant_candidates_; | |
89 Vector<OutOfFlowOffset> oof_candidate_offsets_; | |
ikilpatrick
2016/12/02 17:47:06
s/oof/out_of_flow/
to be consistent with rest of
atotic
2016/12/02 19:55:15
Will do.
Note: this is an example where "explicit
| |
90 | |
58 WeakBoxList out_of_flow_descendants_; | 91 WeakBoxList out_of_flow_descendants_; |
59 Vector<NGLogicalOffset> out_of_flow_offsets_; | 92 Vector<NGCorner> out_of_flow_corners_; |
60 }; | 93 }; |
61 | 94 |
62 } // namespace blink | 95 } // namespace blink |
63 | 96 |
64 #endif // NGFragmentBuilder | 97 #endif // NGFragmentBuilder |
OLD | NEW |