| 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/geometry/ng_static_position.h" | 8 #include "core/layout/ng/geometry/ng_static_position.h" |
| 9 #include "core/layout/ng/inline/ng_physical_text_fragment.h" | 9 #include "core/layout/ng/inline/ng_physical_text_fragment.h" |
| 10 #include "core/layout/ng/ng_break_token.h" | 10 #include "core/layout/ng/ng_break_token.h" |
| 11 #include "core/layout/ng/ng_constraint_space.h" | 11 #include "core/layout/ng/ng_constraint_space.h" |
| 12 #include "core/layout/ng/ng_layout_result.h" |
| 12 #include "core/layout/ng/ng_out_of_flow_positioned_descendant.h" | 13 #include "core/layout/ng/ng_out_of_flow_positioned_descendant.h" |
| 13 #include "core/layout/ng/ng_physical_fragment.h" | 14 #include "core/layout/ng/ng_physical_fragment.h" |
| 14 #include "core/layout/ng/ng_positioned_float.h" | 15 #include "core/layout/ng/ng_positioned_float.h" |
| 15 #include "core/layout/ng/ng_unpositioned_float.h" | 16 #include "core/layout/ng/ng_unpositioned_float.h" |
| 16 #include "platform/wtf/Allocator.h" | 17 #include "platform/wtf/Allocator.h" |
| 17 | 18 |
| 18 namespace blink { | 19 namespace blink { |
| 19 | 20 |
| 20 class NGLayoutResult; | |
| 21 | |
| 22 class CORE_EXPORT NGFragmentBuilder final { | 21 class CORE_EXPORT NGFragmentBuilder final { |
| 23 DISALLOW_NEW(); | 22 DISALLOW_NEW(); |
| 24 | 23 |
| 25 public: | 24 public: |
| 26 NGFragmentBuilder(NGPhysicalFragment::NGFragmentType, NGLayoutInputNode); | 25 NGFragmentBuilder(NGPhysicalFragment::NGFragmentType, NGLayoutInputNode); |
| 27 | 26 |
| 28 // Build a fragment for LayoutObject without NGLayoutInputNode. LayoutInline | 27 // Build a fragment for LayoutObject without NGLayoutInputNode. LayoutInline |
| 29 // has NGInlineItem but does not have corresponding NGLayoutInputNode. | 28 // has NGInlineItem but does not have corresponding NGLayoutInputNode. |
| 30 NGFragmentBuilder(NGPhysicalFragment::NGFragmentType, LayoutObject*); | 29 NGFragmentBuilder(NGPhysicalFragment::NGFragmentType, LayoutObject*); |
| 31 | 30 |
| (...skipping 10 matching lines...) Expand all Loading... |
| 42 NGFragmentBuilder& SetBlockOverflow(LayoutUnit); | 41 NGFragmentBuilder& SetBlockOverflow(LayoutUnit); |
| 43 | 42 |
| 44 NGFragmentBuilder& AddChild(RefPtr<NGLayoutResult>, const NGLogicalOffset&); | 43 NGFragmentBuilder& AddChild(RefPtr<NGLayoutResult>, const NGLogicalOffset&); |
| 45 NGFragmentBuilder& AddChild(RefPtr<NGPhysicalFragment>, | 44 NGFragmentBuilder& AddChild(RefPtr<NGPhysicalFragment>, |
| 46 const NGLogicalOffset&); | 45 const NGLogicalOffset&); |
| 47 | 46 |
| 48 NGFragmentBuilder& AddPositionedFloat(NGPositionedFloat); | 47 NGFragmentBuilder& AddPositionedFloat(NGPositionedFloat); |
| 49 | 48 |
| 50 NGFragmentBuilder& SetBfcOffset(const NGLogicalOffset& offset); | 49 NGFragmentBuilder& SetBfcOffset(const NGLogicalOffset& offset); |
| 51 | 50 |
| 52 NGFragmentBuilder& AddUnpositionedFloat( | |
| 53 RefPtr<NGUnpositionedFloat> unpositioned_float); | |
| 54 | |
| 55 // Builder has non-trivial out-of-flow descendant methods. | 51 // Builder has non-trivial out-of-flow descendant methods. |
| 56 // These methods are building blocks for implementation of | 52 // These methods are building blocks for implementation of |
| 57 // out-of-flow descendants by layout algorithms. | 53 // out-of-flow descendants by layout algorithms. |
| 58 // | 54 // |
| 59 // They are intended to be used by layout algorithm like this: | 55 // They are intended to be used by layout algorithm like this: |
| 60 // | 56 // |
| 61 // Part 1: layout algorithm positions in-flow children. | 57 // Part 1: layout algorithm positions in-flow children. |
| 62 // out-of-flow children, and out-of-flow descendants of fragments | 58 // out-of-flow children, and out-of-flow descendants of fragments |
| 63 // are stored inside builder. | 59 // are stored inside builder. |
| 64 // | 60 // |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 99 end_margin_strut_ = from; | 95 end_margin_strut_ = from; |
| 100 return *this; | 96 return *this; |
| 101 } | 97 } |
| 102 | 98 |
| 103 // Offsets are not supposed to be set during fragment construction, so we | 99 // Offsets are not supposed to be set during fragment construction, so we |
| 104 // do not provide a setter here. | 100 // do not provide a setter here. |
| 105 | 101 |
| 106 // Creates the fragment. Can only be called once. | 102 // Creates the fragment. Can only be called once. |
| 107 RefPtr<NGLayoutResult> ToBoxFragment(); | 103 RefPtr<NGLayoutResult> ToBoxFragment(); |
| 108 | 104 |
| 109 Vector<RefPtr<NGPhysicalFragment>>& MutableChildren() { return children_; } | 105 RefPtr<NGLayoutResult> Abort(NGLayoutResult::NGLayoutResultStatus); |
| 110 | 106 |
| 111 Vector<NGLogicalOffset>& MutableOffsets() { return offsets_; } | 107 Vector<NGLogicalOffset>& MutableOffsets() { return offsets_; } |
| 112 | 108 |
| 113 // Mutable list of floats that need to be positioned. | 109 void SwapUnpositionedFloats( |
| 114 Vector<RefPtr<NGUnpositionedFloat>>& MutableUnpositionedFloats() { | 110 Vector<RefPtr<NGUnpositionedFloat>>* unpositioned_floats) { |
| 115 return unpositioned_floats_; | 111 unpositioned_floats_.swap(*unpositioned_floats); |
| 116 } | |
| 117 | |
| 118 // List of floats that need to be positioned. | |
| 119 const Vector<RefPtr<NGUnpositionedFloat>>& UnpositionedFloats() const { | |
| 120 return unpositioned_floats_; | |
| 121 } | 112 } |
| 122 | 113 |
| 123 const WTF::Optional<NGLogicalOffset>& BfcOffset() const { | 114 const WTF::Optional<NGLogicalOffset>& BfcOffset() const { |
| 124 return bfc_offset_; | 115 return bfc_offset_; |
| 125 } | 116 } |
| 126 | 117 |
| 127 const Vector<RefPtr<NGPhysicalFragment>>& Children() const { | 118 const Vector<RefPtr<NGPhysicalFragment>>& Children() const { |
| 128 return children_; | 119 return children_; |
| 129 } | 120 } |
| 130 | 121 |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 186 | 177 |
| 187 WTF::Optional<NGLogicalOffset> bfc_offset_; | 178 WTF::Optional<NGLogicalOffset> bfc_offset_; |
| 188 NGMarginStrut end_margin_strut_; | 179 NGMarginStrut end_margin_strut_; |
| 189 | 180 |
| 190 NGBorderEdges border_edges_; | 181 NGBorderEdges border_edges_; |
| 191 }; | 182 }; |
| 192 | 183 |
| 193 } // namespace blink | 184 } // namespace blink |
| 194 | 185 |
| 195 #endif // NGFragmentBuilder | 186 #endif // NGFragmentBuilder |
| OLD | NEW |