| 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_break_token.h" | 8 #include "core/layout/ng/ng_break_token.h" |
| 9 #include "core/layout/ng/ng_constraint_space.h" | 9 #include "core/layout/ng/ng_constraint_space.h" |
| 10 #include "core/layout/ng/ng_floating_object.h" | 10 #include "core/layout/ng/ng_floating_object.h" |
| (...skipping 17 matching lines...) Expand all Loading... |
| 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(RefPtr<NGLayoutResult>, const NGLogicalOffset&); | 35 NGFragmentBuilder& AddChild(RefPtr<NGLayoutResult>, const NGLogicalOffset&); |
| 36 NGFragmentBuilder& AddChild(RefPtr<NGPhysicalFragment>, | 36 NGFragmentBuilder& AddChild(RefPtr<NGPhysicalFragment>, |
| 37 const NGLogicalOffset&); | 37 const NGLogicalOffset&); |
| 38 |
| 38 NGFragmentBuilder& AddFloatingObject(NGFloatingObject*, | 39 NGFragmentBuilder& AddFloatingObject(NGFloatingObject*, |
| 39 const NGLogicalOffset&); | 40 const NGLogicalOffset&); |
| 40 | 41 |
| 41 NGFragmentBuilder& SetBfcOffset(const NGLogicalOffset& offset); | 42 NGFragmentBuilder& SetBfcOffset(const NGLogicalOffset& offset); |
| 42 | 43 |
| 43 NGFragmentBuilder& AddUnpositionedFloat(NGFloatingObject* floating_object); | 44 NGFragmentBuilder& AddUnpositionedFloat(NGFloatingObject* floating_object); |
| 44 | 45 |
| 45 // Builder has non-trivial out-of-flow descendant methods. | 46 // Builder has non-trivial out-of-flow descendant methods. |
| 46 // These methods are building blocks for implementation of | 47 // These methods are building blocks for implementation of |
| 47 // out-of-flow descendants by layout algorithms. | 48 // out-of-flow descendants by layout algorithms. |
| (...skipping 20 matching lines...) Expand all Loading... |
| 68 // | 69 // |
| 69 // See layout part for builder interaction. | 70 // See layout part for builder interaction. |
| 70 NGFragmentBuilder& AddOutOfFlowChildCandidate(NGBlockNode*, NGLogicalOffset); | 71 NGFragmentBuilder& AddOutOfFlowChildCandidate(NGBlockNode*, NGLogicalOffset); |
| 71 | 72 |
| 72 void GetAndClearOutOfFlowDescendantCandidates(WeakBoxList*, | 73 void GetAndClearOutOfFlowDescendantCandidates(WeakBoxList*, |
| 73 Vector<NGStaticPosition>*); | 74 Vector<NGStaticPosition>*); |
| 74 | 75 |
| 75 NGFragmentBuilder& AddOutOfFlowDescendant(NGBlockNode*, | 76 NGFragmentBuilder& AddOutOfFlowDescendant(NGBlockNode*, |
| 76 const NGStaticPosition&); | 77 const NGStaticPosition&); |
| 77 | 78 |
| 78 void SetBreakToken(NGBreakToken* token) { | 79 NGFragmentBuilder& SetUsedBlockSize(LayoutUnit used_block_size) { |
| 79 DCHECK(!break_token_); | 80 used_block_size_ = used_block_size; |
| 80 break_token_ = token; | 81 did_break_ = true; |
| 82 return *this; |
| 81 } | 83 } |
| 82 bool HasBreakToken() const { return break_token_; } | |
| 83 | 84 |
| 84 NGFragmentBuilder& SetEndMarginStrut(const NGMarginStrut& from) { | 85 NGFragmentBuilder& SetEndMarginStrut(const NGMarginStrut& from) { |
| 85 end_margin_strut_ = from; | 86 end_margin_strut_ = from; |
| 86 return *this; | 87 return *this; |
| 87 } | 88 } |
| 88 | 89 |
| 89 // Offsets are not supposed to be set during fragment construction, so we | 90 // Offsets are not supposed to be set during fragment construction, so we |
| 90 // do not provide a setter here. | 91 // do not provide a setter here. |
| 91 | 92 |
| 92 // Creates the fragment. Can only be called once. | 93 // Creates the fragment. Can only be called once. |
| 93 RefPtr<NGLayoutResult> ToBoxFragment(); | 94 RefPtr<NGLayoutResult> ToBoxFragment(); |
| 94 RefPtr<NGPhysicalTextFragment> ToTextFragment(unsigned index, | 95 RefPtr<NGPhysicalTextFragment> ToTextFragment(unsigned index, |
| 95 unsigned start_offset, | 96 unsigned start_offset, |
| 96 unsigned end_offset); | 97 unsigned end_offset); |
| 97 | 98 |
| 98 // Mutable list of floats that need to be positioned. | 99 // Mutable list of floats that need to be positioned. |
| 99 Vector<Persistent<NGFloatingObject>>& MutableUnpositionedFloats() { | 100 Vector<Persistent<NGFloatingObject>>& MutableUnpositionedFloats() { |
| 100 return unpositioned_floats_; | 101 return unpositioned_floats_; |
| 101 } | 102 } |
| 102 | 103 |
| 103 // List of floats that need to be positioned. | 104 // List of floats that need to be positioned. |
| 104 const Vector<Persistent<NGFloatingObject>>& UnpositionedFloats() const { | 105 const Vector<Persistent<NGFloatingObject>>& UnpositionedFloats() const { |
| 105 return unpositioned_floats_; | 106 return unpositioned_floats_; |
| 106 } | 107 } |
| 107 | 108 |
| 108 const WTF::Optional<NGLogicalOffset>& BfcOffset() const { | 109 const WTF::Optional<NGLogicalOffset>& BfcOffset() const { |
| 109 return bfc_offset_; | 110 return bfc_offset_; |
| 110 } | 111 } |
| 111 | 112 |
| 113 bool DidBreak() const { return did_break_; } |
| 114 |
| 112 private: | 115 private: |
| 113 // Out-of-flow descendant placement information. | 116 // Out-of-flow descendant placement information. |
| 114 // The generated fragment must compute NGStaticPosition for all | 117 // The generated fragment must compute NGStaticPosition for all |
| 115 // out-of-flow descendants. | 118 // out-of-flow descendants. |
| 116 // The resulting NGStaticPosition gets derived from: | 119 // The resulting NGStaticPosition gets derived from: |
| 117 // 1. The offset of fragment's child. | 120 // 1. The offset of fragment's child. |
| 118 // 2. The static position of descendant wrt child. | 121 // 2. The static position of descendant wrt child. |
| 119 // | 122 // |
| 120 // A child can be: | 123 // A child can be: |
| 121 // 1. A descendant itself. In this case, descendant position is (0,0). | 124 // 1. A descendant itself. In this case, descendant position is (0,0). |
| (...skipping 11 matching lines...) Expand all Loading... |
| 133 TextDirection direction_; | 136 TextDirection direction_; |
| 134 | 137 |
| 135 Persistent<NGLayoutInputNode> node_; | 138 Persistent<NGLayoutInputNode> node_; |
| 136 | 139 |
| 137 NGLogicalSize size_; | 140 NGLogicalSize size_; |
| 138 NGLogicalSize overflow_; | 141 NGLogicalSize overflow_; |
| 139 | 142 |
| 140 Vector<RefPtr<NGPhysicalFragment>> children_; | 143 Vector<RefPtr<NGPhysicalFragment>> children_; |
| 141 Vector<NGLogicalOffset> offsets_; | 144 Vector<NGLogicalOffset> offsets_; |
| 142 | 145 |
| 146 bool did_break_; |
| 147 LayoutUnit used_block_size_; |
| 148 |
| 149 Persistent<HeapVector<Member<NGBreakToken>>> child_break_tokens_; |
| 150 |
| 143 WeakBoxList out_of_flow_descendant_candidates_; | 151 WeakBoxList out_of_flow_descendant_candidates_; |
| 144 Vector<OutOfFlowPlacement> out_of_flow_candidate_placements_; | 152 Vector<OutOfFlowPlacement> out_of_flow_candidate_placements_; |
| 145 | 153 |
| 146 WeakBoxList out_of_flow_descendants_; | 154 WeakBoxList out_of_flow_descendants_; |
| 147 Vector<NGStaticPosition> out_of_flow_positions_; | 155 Vector<NGStaticPosition> out_of_flow_positions_; |
| 148 | 156 |
| 149 // Floats that need to be positioned by the next in-flow fragment that can | 157 // Floats that need to be positioned by the next in-flow fragment that can |
| 150 // determine its block position in space. | 158 // determine its block position in space. |
| 151 Vector<Persistent<NGFloatingObject>> unpositioned_floats_; | 159 Vector<Persistent<NGFloatingObject>> unpositioned_floats_; |
| 152 | 160 |
| 153 Vector<NGLogicalOffset> floating_object_offsets_; | 161 Vector<NGLogicalOffset> floating_object_offsets_; |
| 154 Vector<Persistent<NGFloatingObject>> positioned_floats_; | 162 Vector<Persistent<NGFloatingObject>> positioned_floats_; |
| 155 | 163 |
| 156 Persistent<NGBreakToken> break_token_; | |
| 157 | |
| 158 WTF::Optional<NGLogicalOffset> bfc_offset_; | 164 WTF::Optional<NGLogicalOffset> bfc_offset_; |
| 159 NGMarginStrut end_margin_strut_; | 165 NGMarginStrut end_margin_strut_; |
| 160 }; | 166 }; |
| 161 | 167 |
| 162 } // namespace blink | 168 } // namespace blink |
| 163 | 169 |
| 164 #endif // NGFragmentBuilder | 170 #endif // NGFragmentBuilder |
| OLD | NEW |