| 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 NGBlockLayoutAlgorithm_h | 5 #ifndef NGBlockLayoutAlgorithm_h |
| 6 #define NGBlockLayoutAlgorithm_h | 6 #define NGBlockLayoutAlgorithm_h |
| 7 | 7 |
| 8 #include "core/CoreExport.h" | 8 #include "core/CoreExport.h" |
| 9 #include "core/layout/ng/ng_block_node.h" | 9 #include "core/layout/ng/ng_block_node.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_column_mapper.h" | 11 #include "core/layout/ng/ng_column_mapper.h" |
| 12 #include "core/layout/ng/ng_fragment_builder.h" | 12 #include "core/layout/ng/ng_fragment_builder.h" |
| 13 #include "core/layout/ng/ng_layout_algorithm.h" | 13 #include "core/layout/ng/ng_layout_algorithm.h" |
| 14 #include "core/layout/ng/ng_units.h" | 14 #include "core/layout/ng/ng_units.h" |
| 15 #include "wtf/RefPtr.h" | 15 #include "wtf/RefPtr.h" |
| 16 | 16 |
| 17 namespace blink { | 17 namespace blink { |
| 18 | 18 |
| 19 class ComputedStyle; | 19 class ComputedStyle; |
| 20 class NGBlockBreakToken; | 20 class NGBlockBreakToken; |
| 21 class NGConstraintSpace; | 21 class NGConstraintSpace; |
| 22 class NGConstraintSpaceBuilder; | 22 class NGConstraintSpaceBuilder; |
| 23 class NGInlineNode; | 23 class NGInlineNode; |
| 24 class NGLayoutResult; |
| 24 class NGPhysicalFragment; | 25 class NGPhysicalFragment; |
| 25 | 26 |
| 26 // A class for general block layout (e.g. a <div> with no special style). | 27 // A class for general block layout (e.g. a <div> with no special style). |
| 27 // Lays out the children in sequence. | 28 // Lays out the children in sequence. |
| 28 class CORE_EXPORT NGBlockLayoutAlgorithm : public NGLayoutAlgorithm { | 29 class CORE_EXPORT NGBlockLayoutAlgorithm : public NGLayoutAlgorithm { |
| 29 public: | 30 public: |
| 30 // Default constructor. | 31 // Default constructor. |
| 31 // @param layout_object The layout object associated with this block. | 32 // @param layout_object The layout object associated with this block. |
| 32 // @param style Style reference of the block that is being laid out. | 33 // @param style Style reference of the block that is being laid out. |
| 33 // @param first_child Our first child; the algorithm will use its NextSibling | 34 // @param first_child Our first child; the algorithm will use its NextSibling |
| 34 // method to access all the children. | 35 // method to access all the children. |
| 35 // @param space The constraint space which the algorithm should generate a | 36 // @param space The constraint space which the algorithm should generate a |
| 36 // fragment within. | 37 // fragment within. |
| 37 NGBlockLayoutAlgorithm(LayoutObject* layout_object, | 38 NGBlockLayoutAlgorithm(LayoutObject* layout_object, |
| 38 PassRefPtr<const ComputedStyle> style, | 39 PassRefPtr<const ComputedStyle> style, |
| 39 NGLayoutInputNode* first_child, | 40 NGLayoutInputNode* first_child, |
| 40 NGConstraintSpace* space, | 41 NGConstraintSpace* space, |
| 41 NGBreakToken* break_token = nullptr); | 42 NGBreakToken* break_token = nullptr); |
| 42 | 43 |
| 43 Optional<MinAndMaxContentSizes> ComputeMinAndMaxContentSizes() const override; | 44 Optional<MinAndMaxContentSizes> ComputeMinAndMaxContentSizes() const override; |
| 44 RefPtr<NGPhysicalFragment> Layout() override; | 45 RefPtr<NGLayoutResult> Layout() override; |
| 45 | 46 |
| 46 private: | 47 private: |
| 47 NGBoxStrut CalculateMargins(const NGConstraintSpace& space, | 48 NGBoxStrut CalculateMargins(const NGConstraintSpace& space, |
| 48 const ComputedStyle& style); | 49 const ComputedStyle& style); |
| 49 | 50 |
| 50 // Creates a new constraint space for the current child. | 51 // Creates a new constraint space for the current child. |
| 51 NGConstraintSpace* CreateConstraintSpaceForCurrentChild(); | 52 NGConstraintSpace* CreateConstraintSpaceForCurrentChild(); |
| 52 void FinishCurrentChildLayout(RefPtr<NGPhysicalBoxFragment>); | 53 void FinishCurrentChildLayout(RefPtr<NGLayoutResult>); |
| 53 | 54 |
| 54 // Layout inline children. | 55 // Layout inline children. |
| 55 void LayoutInlineChildren(NGInlineNode*); | 56 void LayoutInlineChildren(NGInlineNode*); |
| 56 | 57 |
| 57 // Proceed to the next sibling that still needs layout. | 58 // Proceed to the next sibling that still needs layout. |
| 58 // | 59 // |
| 59 // @param child_fragment The newly created fragment for the current child. | 60 // @param child_fragment The newly created fragment for the current child. |
| 60 // @return true if we can continue to lay out, or false if we need to abort | 61 // @return true if we can continue to lay out, or false if we need to abort |
| 61 // due to a fragmentainer break. | 62 // due to a fragmentainer break. |
| 62 bool ProceedToNextUnfinishedSibling(NGPhysicalFragment* child_fragment); | 63 bool ProceedToNextUnfinishedSibling(NGPhysicalFragment* child_fragment); |
| (...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 148 // MarginStrut for the previous child. | 149 // MarginStrut for the previous child. |
| 149 NGMarginStrut curr_margin_strut_; | 150 NGMarginStrut curr_margin_strut_; |
| 150 NGLogicalOffset bfc_offset_; | 151 NGLogicalOffset bfc_offset_; |
| 151 NGLogicalOffset curr_bfc_offset_; | 152 NGLogicalOffset curr_bfc_offset_; |
| 152 NGBoxStrut curr_child_margins_; | 153 NGBoxStrut curr_child_margins_; |
| 153 }; | 154 }; |
| 154 | 155 |
| 155 } // namespace blink | 156 } // namespace blink |
| 156 | 157 |
| 157 #endif // NGBlockLayoutAlgorithm_h | 158 #endif // NGBlockLayoutAlgorithm_h |
| OLD | NEW |