Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(141)

Side by Side Diff: third_party/WebKit/Source/core/layout/ng/ng_fragment_builder.h

Issue 2540653003: Implement collection of out-of-flow descendants (Closed)
Patch Set: CR fixes: rename Corner to StaticPosition Created 4 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
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 in-flow children.
38 // out-of-flow children, and out-of-flow descendants of fragments
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()
cbiesinger 2016/12/02 22:37:03 typo: candidate
atotic 2016/12/02 23:08:44 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*,
cbiesinger 2016/12/02 22:37:03 Maybe better to return a vector of pairs (or, a st
atotic 2016/12/02 23:08:44 I also dislike objects being split between two col
67 Vector<NGStaticPosition>*);
68
69 NGFragmentBuilder& AddOutOfFlowDescendant(NGBlockNode*,
70 const NGStaticPosition&);
33 71
34 // Sets MarginStrut for the resultant fragment. 72 // Sets MarginStrut for the resultant fragment.
35 NGFragmentBuilder& SetMarginStrutBlockStart(const NGMarginStrut& from); 73 NGFragmentBuilder& SetMarginStrutBlockStart(const NGMarginStrut& from);
36 NGFragmentBuilder& SetMarginStrutBlockEnd(const NGMarginStrut& from); 74 NGFragmentBuilder& SetMarginStrutBlockEnd(const NGMarginStrut& from);
37 75
38 // Offsets are not supposed to be set during fragment construction, so we 76 // Offsets are not supposed to be set during fragment construction, so we
39 // do not provide a setter here. 77 // do not provide a setter here.
40 78
41 // Creates the fragment. Can only be called once. 79 // Creates the fragment. Can only be called once.
42 NGPhysicalFragment* ToFragment(); 80 NGPhysicalFragment* ToFragment();
43 81
44 DECLARE_VIRTUAL_TRACE(); 82 DECLARE_VIRTUAL_TRACE();
45 83
46 private: 84 private:
85 // Out-of-flow descendant placement information.
86 // The generated fragment must compute NGStaticPosition for all
87 // out-of-flow descendants.
88 // The resulting NGStaticPosition gets derived from:
89 // 1. The offset of fragment's child.
90 // 2. The static position of descendant wrt child.
91 //
92 // A child can be:
93 // 1. A descendant itself. In this case, descendant position is (0,0).
cbiesinger 2016/12/02 22:37:03 descendant -> direct child, I think?
atotic 2016/12/02 23:08:44 It does. The comment repeats this information beca
94 // 2. A fragment containing a descendant.
95 //
96 // child_offset is stored as NGLogicalOffset because physical offset cannot
97 // be computed until we know fragment's size.
98 struct OutOfFlowPlacement {
99 NGLogicalOffset child_offset;
100 NGStaticPosition descendant_position;
101 };
102
47 NGPhysicalFragmentBase::NGFragmentType type_; 103 NGPhysicalFragmentBase::NGFragmentType type_;
48 NGWritingMode writing_mode_; 104 NGWritingMode writing_mode_;
49 TextDirection direction_; 105 TextDirection direction_;
50 106
51 NGLogicalSize size_; 107 NGLogicalSize size_;
52 NGLogicalSize overflow_; 108 NGLogicalSize overflow_;
53 109
54 NGMarginStrut margin_strut_; 110 NGMarginStrut margin_strut_;
55 111
56 HeapVector<Member<NGPhysicalFragmentBase>> children_; 112 HeapVector<Member<NGPhysicalFragmentBase>> children_;
57 Vector<NGLogicalOffset> offsets_; 113 Vector<NGLogicalOffset> offsets_;
114
115 WeakBoxList out_of_flow_descendant_candidates_;
116 Vector<OutOfFlowPlacement> out_of_flow_candidate_placements_;
117
58 WeakBoxList out_of_flow_descendants_; 118 WeakBoxList out_of_flow_descendants_;
59 Vector<NGLogicalOffset> out_of_flow_offsets_; 119 Vector<NGStaticPosition> out_of_flow_positions_;
60 }; 120 };
61 121
62 } // namespace blink 122 } // namespace blink
63 123
64 #endif // NGFragmentBuilder 124 #endif // NGFragmentBuilder
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698