| 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_fragment.h" | 8 #include "core/layout/ng/ng_fragment.h" |
| 9 #include "core/layout/ng/ng_units.h" | 9 #include "core/layout/ng/ng_units.h" |
| 10 | 10 |
| 11 namespace blink { | 11 namespace blink { |
| 12 | 12 |
| 13 class CORE_EXPORT NGFragmentBuilder final | 13 class CORE_EXPORT NGFragmentBuilder final |
| 14 : public GarbageCollectedFinalized<NGFragmentBuilder> { | 14 : public GarbageCollectedFinalized<NGFragmentBuilder> { |
| 15 public: | 15 public: |
| 16 NGFragmentBuilder(NGPhysicalFragmentBase::NGFragmentType); | 16 NGFragmentBuilder(NGPhysicalFragmentBase::NGFragmentType); |
| 17 | 17 |
| 18 NGFragmentBuilder& SetWritingMode(NGWritingMode); | 18 NGFragmentBuilder& SetWritingMode(NGWritingMode); |
| 19 NGFragmentBuilder& SetDirection(NGDirection); | 19 NGFragmentBuilder& SetDirection(NGDirection); |
| 20 | 20 |
| 21 NGFragmentBuilder& SetInlineSize(LayoutUnit); | 21 NGFragmentBuilder& SetInlineSize(LayoutUnit); |
| 22 NGFragmentBuilder& SetBlockSize(LayoutUnit); | 22 NGFragmentBuilder& SetBlockSize(LayoutUnit); |
| 23 | 23 |
| 24 NGFragmentBuilder& SetInlineOverflow(LayoutUnit); | 24 NGFragmentBuilder& SetInlineOverflow(LayoutUnit); |
| 25 NGFragmentBuilder& SetBlockOverflow(LayoutUnit); | 25 NGFragmentBuilder& SetBlockOverflow(LayoutUnit); |
| 26 | 26 |
| 27 NGFragmentBuilder& AddChild(NGFragment*, NGLogicalOffset); | 27 NGFragmentBuilder& AddChild(NGFragment*, NGLogicalOffset); |
| 28 | 28 |
| 29 // Sets MarginStrut for the resultant fragment. | 29 // Sets MarginStrut for the resultant fragment. |
| 30 // These 2 methods below should be only called once as we update the | |
| 31 // fragment's MarginStrut block start/end from first/last children MarginStrut | |
| 32 NGFragmentBuilder& SetMarginStrutBlockStart(const NGMarginStrut& from); | 30 NGFragmentBuilder& SetMarginStrutBlockStart(const NGMarginStrut& from); |
| 33 NGFragmentBuilder& SetMarginStrutBlockEnd(const NGMarginStrut& from); | 31 NGFragmentBuilder& SetMarginStrutBlockEnd(const NGMarginStrut& from); |
| 34 | 32 |
| 35 // Offsets are not supposed to be set during fragment construction, so we | 33 // Offsets are not supposed to be set during fragment construction, so we |
| 36 // do not provide a setter here. | 34 // do not provide a setter here. |
| 37 | 35 |
| 38 // Creates the fragment. Can only be called once. | 36 // Creates the fragment. Can only be called once. |
| 39 NGPhysicalFragment* ToFragment(); | 37 NGPhysicalFragment* ToFragment(); |
| 40 | 38 |
| 41 DEFINE_INLINE_VIRTUAL_TRACE() { visitor->trace(children_); } | 39 DEFINE_INLINE_VIRTUAL_TRACE() { visitor->trace(children_); } |
| 42 | 40 |
| 43 private: | 41 private: |
| 44 NGPhysicalFragmentBase::NGFragmentType type_; | 42 NGPhysicalFragmentBase::NGFragmentType type_; |
| 45 NGWritingMode writing_mode_; | 43 NGWritingMode writing_mode_; |
| 46 NGDirection direction_; | 44 NGDirection direction_; |
| 47 | 45 |
| 48 NGLogicalSize size_; | 46 NGLogicalSize size_; |
| 49 NGLogicalSize overflow_; | 47 NGLogicalSize overflow_; |
| 50 | 48 |
| 51 NGMarginStrut margin_strut_; | 49 NGMarginStrut margin_strut_; |
| 52 | 50 |
| 53 HeapVector<Member<NGPhysicalFragmentBase>> children_; | 51 HeapVector<Member<NGPhysicalFragmentBase>> children_; |
| 54 Vector<NGLogicalOffset> offsets_; | 52 Vector<NGLogicalOffset> offsets_; |
| 55 | |
| 56 // Whether MarginStrut block start/end was updated. | |
| 57 // It's used for DCHECK safety check. | |
| 58 bool is_margin_strut_block_start_updated_ : 1; | |
| 59 bool is_margin_strut_block_end_updated_ : 1; | |
| 60 }; | 53 }; |
| 61 | 54 |
| 62 } // namespace blink | 55 } // namespace blink |
| 63 | 56 |
| 64 #endif // NGFragmentBuilder | 57 #endif // NGFragmentBuilder |
| OLD | NEW |