| 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" | |
| 9 #include "core/layout/ng/ng_units.h" | 8 #include "core/layout/ng/ng_units.h" |
| 9 #include "core/layout/ng/ng_physical_fragment.h" |
| 10 | 10 |
| 11 namespace blink { | 11 namespace blink { |
| 12 | 12 |
| 13 class NGFragmentBase; | 13 class NGFragment; |
| 14 class NGInlineNode; | 14 class NGInlineNode; |
| 15 class NGPhysicalFragment; | 15 class NGPhysicalBoxFragment; |
| 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(NGPhysicalFragment::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 NGLogicalSize Size() const { return size_; } |
| 31 | 31 |
| 32 NGFragmentBuilder& SetInlineOverflow(LayoutUnit); | 32 NGFragmentBuilder& SetInlineOverflow(LayoutUnit); |
| 33 NGFragmentBuilder& SetBlockOverflow(LayoutUnit); | 33 NGFragmentBuilder& SetBlockOverflow(LayoutUnit); |
| 34 | 34 |
| 35 NGFragmentBuilder& AddChild(NGFragmentBase*, const NGLogicalOffset&); | 35 NGFragmentBuilder& AddChild(NGFragment*, const NGLogicalOffset&); |
| 36 | 36 |
| 37 // Builder has non-trivial out-of-flow descendant methods. | 37 // Builder has non-trivial out-of-flow descendant methods. |
| 38 // These methods are building blocks for implementation of | 38 // These methods are building blocks for implementation of |
| 39 // out-of-flow descendants by layout algorithms. | 39 // out-of-flow descendants by layout algorithms. |
| 40 // | 40 // |
| 41 // They are intended to be used by layout algorithm like this: | 41 // They are intended to be used by layout algorithm like this: |
| 42 // | 42 // |
| 43 // Part 1: layout algorithm positions in-flow children. | 43 // Part 1: layout algorithm positions in-flow children. |
| 44 // out-of-flow children, and out-of-flow descendants of fragments | 44 // out-of-flow children, and out-of-flow descendants of fragments |
| 45 // are stored inside builder. | 45 // are stored inside builder. |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 82 const NGStaticPosition&); | 82 const NGStaticPosition&); |
| 83 | 83 |
| 84 // Sets MarginStrut for the resultant fragment. | 84 // Sets MarginStrut for the resultant fragment. |
| 85 NGFragmentBuilder& SetMarginStrutBlockStart(const NGMarginStrut& from); | 85 NGFragmentBuilder& SetMarginStrutBlockStart(const NGMarginStrut& from); |
| 86 NGFragmentBuilder& SetMarginStrutBlockEnd(const NGMarginStrut& from); | 86 NGFragmentBuilder& SetMarginStrutBlockEnd(const NGMarginStrut& from); |
| 87 | 87 |
| 88 // Offsets are not supposed to be set during fragment construction, so we | 88 // Offsets are not supposed to be set during fragment construction, so we |
| 89 // do not provide a setter here. | 89 // do not provide a setter here. |
| 90 | 90 |
| 91 // Creates the fragment. Can only be called once. | 91 // Creates the fragment. Can only be called once. |
| 92 NGPhysicalFragment* ToFragment(); | 92 NGPhysicalBoxFragment* ToBoxFragment(); |
| 93 NGPhysicalTextFragment* ToTextFragment(NGInlineNode*, | 93 NGPhysicalTextFragment* ToTextFragment(NGInlineNode*, |
| 94 unsigned start_index, | 94 unsigned start_index, |
| 95 unsigned end_index); | 95 unsigned end_index); |
| 96 | 96 |
| 97 DECLARE_VIRTUAL_TRACE(); | 97 DECLARE_VIRTUAL_TRACE(); |
| 98 | 98 |
| 99 private: | 99 private: |
| 100 // Out-of-flow descendant placement information. | 100 // Out-of-flow descendant placement information. |
| 101 // The generated fragment must compute NGStaticPosition for all | 101 // The generated fragment must compute NGStaticPosition for all |
| 102 // out-of-flow descendants. | 102 // out-of-flow descendants. |
| 103 // The resulting NGStaticPosition gets derived from: | 103 // The resulting NGStaticPosition gets derived from: |
| 104 // 1. The offset of fragment's child. | 104 // 1. The offset of fragment's child. |
| 105 // 2. The static position of descendant wrt child. | 105 // 2. The static position of descendant wrt child. |
| 106 // | 106 // |
| 107 // A child can be: | 107 // A child can be: |
| 108 // 1. A descendant itself. In this case, descendant position is (0,0). | 108 // 1. A descendant itself. In this case, descendant position is (0,0). |
| 109 // 2. A fragment containing a descendant. | 109 // 2. A fragment containing a descendant. |
| 110 // | 110 // |
| 111 // child_offset is stored as NGLogicalOffset because physical offset cannot | 111 // child_offset is stored as NGLogicalOffset because physical offset cannot |
| 112 // be computed until we know fragment's size. | 112 // be computed until we know fragment's size. |
| 113 struct OutOfFlowPlacement { | 113 struct OutOfFlowPlacement { |
| 114 NGLogicalOffset child_offset; | 114 NGLogicalOffset child_offset; |
| 115 NGStaticPosition descendant_position; | 115 NGStaticPosition descendant_position; |
| 116 }; | 116 }; |
| 117 | 117 |
| 118 NGPhysicalFragmentBase::NGFragmentType type_; | 118 NGPhysicalFragment::NGFragmentType type_; |
| 119 NGWritingMode writing_mode_; | 119 NGWritingMode writing_mode_; |
| 120 TextDirection direction_; | 120 TextDirection direction_; |
| 121 | 121 |
| 122 NGLogicalSize size_; | 122 NGLogicalSize size_; |
| 123 NGLogicalSize overflow_; | 123 NGLogicalSize overflow_; |
| 124 | 124 |
| 125 NGMarginStrut margin_strut_; | 125 NGMarginStrut margin_strut_; |
| 126 | 126 |
| 127 HeapVector<Member<NGPhysicalFragmentBase>> children_; | 127 HeapVector<Member<NGPhysicalFragment>> children_; |
| 128 Vector<NGLogicalOffset> offsets_; | 128 Vector<NGLogicalOffset> offsets_; |
| 129 | 129 |
| 130 WeakBoxList out_of_flow_descendant_candidates_; | 130 WeakBoxList out_of_flow_descendant_candidates_; |
| 131 Vector<OutOfFlowPlacement> out_of_flow_candidate_placements_; | 131 Vector<OutOfFlowPlacement> out_of_flow_candidate_placements_; |
| 132 | 132 |
| 133 WeakBoxList out_of_flow_descendants_; | 133 WeakBoxList out_of_flow_descendants_; |
| 134 Vector<NGStaticPosition> out_of_flow_positions_; | 134 Vector<NGStaticPosition> out_of_flow_positions_; |
| 135 }; | 135 }; |
| 136 | 136 |
| 137 } // namespace blink | 137 } // namespace blink |
| 138 | 138 |
| 139 #endif // NGFragmentBuilder | 139 #endif // NGFragmentBuilder |
| OLD | NEW |