| 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 // Sets how much of the block size we've used so far for this box. |
| 79 DCHECK(!break_token_); | 80 // |
| 80 break_token_ = token; | 81 // This will result in a fragment which has an unfinished break token, which |
| 82 // contains this information. |
| 83 NGFragmentBuilder& SetUsedBlockSize(LayoutUnit used_block_size) { |
| 84 used_block_size_ = used_block_size; |
| 85 did_break_ = true; |
| 86 return *this; |
| 81 } | 87 } |
| 82 bool HasBreakToken() const { return break_token_; } | |
| 83 | 88 |
| 84 NGFragmentBuilder& SetEndMarginStrut(const NGMarginStrut& from) { | 89 NGFragmentBuilder& SetEndMarginStrut(const NGMarginStrut& from) { |
| 85 end_margin_strut_ = from; | 90 end_margin_strut_ = from; |
| 86 return *this; | 91 return *this; |
| 87 } | 92 } |
| 88 | 93 |
| 89 // Offsets are not supposed to be set during fragment construction, so we | 94 // Offsets are not supposed to be set during fragment construction, so we |
| 90 // do not provide a setter here. | 95 // do not provide a setter here. |
| 91 | 96 |
| 92 // Creates the fragment. Can only be called once. | 97 // Creates the fragment. Can only be called once. |
| 93 RefPtr<NGLayoutResult> ToBoxFragment(); | 98 RefPtr<NGLayoutResult> ToBoxFragment(); |
| 94 RefPtr<NGPhysicalTextFragment> ToTextFragment(unsigned index, | 99 RefPtr<NGPhysicalTextFragment> ToTextFragment(unsigned index, |
| 95 unsigned start_offset, | 100 unsigned start_offset, |
| 96 unsigned end_offset); | 101 unsigned end_offset); |
| 97 | 102 |
| 98 // Mutable list of floats that need to be positioned. | 103 // Mutable list of floats that need to be positioned. |
| 99 Vector<Persistent<NGFloatingObject>>& MutableUnpositionedFloats() { | 104 Vector<Persistent<NGFloatingObject>>& MutableUnpositionedFloats() { |
| 100 return unpositioned_floats_; | 105 return unpositioned_floats_; |
| 101 } | 106 } |
| 102 | 107 |
| 103 // List of floats that need to be positioned. | 108 // List of floats that need to be positioned. |
| 104 const Vector<Persistent<NGFloatingObject>>& UnpositionedFloats() const { | 109 const Vector<Persistent<NGFloatingObject>>& UnpositionedFloats() const { |
| 105 return unpositioned_floats_; | 110 return unpositioned_floats_; |
| 106 } | 111 } |
| 107 | 112 |
| 108 const WTF::Optional<NGLogicalOffset>& BfcOffset() const { | 113 const WTF::Optional<NGLogicalOffset>& BfcOffset() const { |
| 109 return bfc_offset_; | 114 return bfc_offset_; |
| 110 } | 115 } |
| 111 | 116 |
| 117 bool DidBreak() const { return did_break_; } |
| 118 |
| 112 private: | 119 private: |
| 113 // Out-of-flow descendant placement information. | 120 // Out-of-flow descendant placement information. |
| 114 // The generated fragment must compute NGStaticPosition for all | 121 // The generated fragment must compute NGStaticPosition for all |
| 115 // out-of-flow descendants. | 122 // out-of-flow descendants. |
| 116 // The resulting NGStaticPosition gets derived from: | 123 // The resulting NGStaticPosition gets derived from: |
| 117 // 1. The offset of fragment's child. | 124 // 1. The offset of fragment's child. |
| 118 // 2. The static position of descendant wrt child. | 125 // 2. The static position of descendant wrt child. |
| 119 // | 126 // |
| 120 // A child can be: | 127 // A child can be: |
| 121 // 1. A descendant itself. In this case, descendant position is (0,0). | 128 // 1. A descendant itself. In this case, descendant position is (0,0). |
| (...skipping 11 matching lines...) Expand all Loading... |
| 133 TextDirection direction_; | 140 TextDirection direction_; |
| 134 | 141 |
| 135 Persistent<NGLayoutInputNode> node_; | 142 Persistent<NGLayoutInputNode> node_; |
| 136 | 143 |
| 137 NGLogicalSize size_; | 144 NGLogicalSize size_; |
| 138 NGLogicalSize overflow_; | 145 NGLogicalSize overflow_; |
| 139 | 146 |
| 140 Vector<RefPtr<NGPhysicalFragment>> children_; | 147 Vector<RefPtr<NGPhysicalFragment>> children_; |
| 141 Vector<NGLogicalOffset> offsets_; | 148 Vector<NGLogicalOffset> offsets_; |
| 142 | 149 |
| 150 bool did_break_; |
| 151 LayoutUnit used_block_size_; |
| 152 |
| 153 Persistent<HeapVector<Member<NGBreakToken>>> child_break_tokens_; |
| 154 |
| 143 WeakBoxList out_of_flow_descendant_candidates_; | 155 WeakBoxList out_of_flow_descendant_candidates_; |
| 144 Vector<OutOfFlowPlacement> out_of_flow_candidate_placements_; | 156 Vector<OutOfFlowPlacement> out_of_flow_candidate_placements_; |
| 145 | 157 |
| 146 WeakBoxList out_of_flow_descendants_; | 158 WeakBoxList out_of_flow_descendants_; |
| 147 Vector<NGStaticPosition> out_of_flow_positions_; | 159 Vector<NGStaticPosition> out_of_flow_positions_; |
| 148 | 160 |
| 149 // Floats that need to be positioned by the next in-flow fragment that can | 161 // Floats that need to be positioned by the next in-flow fragment that can |
| 150 // determine its block position in space. | 162 // determine its block position in space. |
| 151 Vector<Persistent<NGFloatingObject>> unpositioned_floats_; | 163 Vector<Persistent<NGFloatingObject>> unpositioned_floats_; |
| 152 | 164 |
| 153 Vector<NGLogicalOffset> floating_object_offsets_; | 165 Vector<NGLogicalOffset> floating_object_offsets_; |
| 154 Vector<Persistent<NGFloatingObject>> positioned_floats_; | 166 Vector<Persistent<NGFloatingObject>> positioned_floats_; |
| 155 | 167 |
| 156 Persistent<NGBreakToken> break_token_; | |
| 157 | |
| 158 WTF::Optional<NGLogicalOffset> bfc_offset_; | 168 WTF::Optional<NGLogicalOffset> bfc_offset_; |
| 159 NGMarginStrut end_margin_strut_; | 169 NGMarginStrut end_margin_strut_; |
| 160 }; | 170 }; |
| 161 | 171 |
| 162 } // namespace blink | 172 } // namespace blink |
| 163 | 173 |
| 164 #endif // NGFragmentBuilder | 174 #endif // NGFragmentBuilder |
| OLD | NEW |