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

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

Issue 2540653003: Implement collection of out-of-flow descendants (Closed)
Patch Set: Collection of out-of-flow descendants 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 side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/Source/core/layout/ng/ng_fragment_builder.h
diff --git a/third_party/WebKit/Source/core/layout/ng/ng_fragment_builder.h b/third_party/WebKit/Source/core/layout/ng/ng_fragment_builder.h
index 5b1a1f14a45407523f45b47e291a92e618ff25d8..89a2eb8174dbea11d8a88519776e178c313b433e 100644
--- a/third_party/WebKit/Source/core/layout/ng/ng_fragment_builder.h
+++ b/third_party/WebKit/Source/core/layout/ng/ng_fragment_builder.h
@@ -28,8 +28,44 @@ class CORE_EXPORT NGFragmentBuilder final
NGFragmentBuilder& AddChild(NGFragmentBase*, NGLogicalOffset);
- NGFragmentBuilder& SetOutOfFlowDescendants(WeakBoxList&,
- Vector<NGLogicalOffset>&);
+ // Builder has non-trivial out-of-flow descendant methods.
+ // These methods are building blocks for implementation of
+ // out-of-flow descendants by layout algorithms.
+ //
+ // They are intended to be used by layout algorithm like this:
+ //
+ // 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
+ // 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
+ // are stored inside builder.
+ //
+ // for (child : children)
+ // if (child->position == (Absolute or Fixed))
+ // builder->AddOutOfFlowChildCandidate(child);
+ // else
+ // fragment = child->Layout()
+ // builder->AddChild(fragment)
+ // end
+ //
+ // Part 2: layout algorithm positions out-of-flow descendants.
+ //
+ // builder->SetInlineSize/SetBlockSize
+ // builder->GetOutOfFlowDescendantCandidates(oof_candidates)
+ // while (oof_candidates.size() > 0)
+ // {
+ // canditate = oof_candidates.shift
ikilpatrick 2016/12/02 21:06:13 .nit s/shift/shift()/
atotic 2016/12/02 22:19:37 done
+ // if (CanPosition(candidate))
+ // fragment = candidate->Layout();
+ // builder->AddChild(fragment);
+ // builder->GetOutOfFlowDescendantCandidates(child_oof_candidates)
+ // oof_candidates.prepend(child_oof_candidates)
+ // else
+ // builder->AddOutOfFlowDescendant();
+ // }
+ NGFragmentBuilder& AddOutOfFlowChildCandidate(NGBlockNode*, NGLogicalOffset);
+
+ void GetOutOfFlowDescendantCandidates(WeakBoxList*, Vector<NGCorner>*);
+
+ NGFragmentBuilder& AddOutOfFlowDescendant(NGBlockNode*, const NGCorner&);
// Sets MarginStrut for the resultant fragment.
NGFragmentBuilder& SetMarginStrutBlockStart(const NGMarginStrut& from);
@@ -44,6 +80,18 @@ class CORE_EXPORT NGFragmentBuilder final
DECLARE_VIRTUAL_TRACE();
private:
+ // Out-of-flow descendant placement information.
+ // 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
+ // NGCorner gets derived from:
ikilpatrick 2016/12/02 21:06:13 The resulting NGCorner? maybe?
atotic 2016/12/02 22:19:37 done
+ // 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
+ // 2. Corner of descendant wrt child.
+ // child_offset is stored as NGLogicalOffset because physical offset cannot
+ // be computed until we know fragment's size.
+ struct OutOfFlowPlacement {
+ NGLogicalOffset child_offset;
+ NGCorner descendant_corner;
+ };
+
NGPhysicalFragmentBase::NGFragmentType type_;
NGWritingMode writing_mode_;
TextDirection direction_;
@@ -55,8 +103,12 @@ class CORE_EXPORT NGFragmentBuilder final
HeapVector<Member<NGPhysicalFragmentBase>> children_;
Vector<NGLogicalOffset> offsets_;
+
+ WeakBoxList out_of_flow_descendant_candidates_;
+ Vector<OutOfFlowPlacement> out_of_flow_candidate_placements_;
+
WeakBoxList out_of_flow_descendants_;
- Vector<NGLogicalOffset> out_of_flow_offsets_;
+ Vector<NGCorner> out_of_flow_corners_;
};
} // namespace blink

Powered by Google App Engine
This is Rietveld 408576698