| 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/geometry/ng_margin_strut.h" | 9 #include "core/layout/ng/geometry/ng_margin_strut.h" |
| 10 #include "core/layout/ng/ng_block_break_token.h" | 10 #include "core/layout/ng/ng_block_break_token.h" |
| (...skipping 18 matching lines...) Expand all Loading... |
| 29 // @param space The constraint space which the algorithm should generate a | 29 // @param space The constraint space which the algorithm should generate a |
| 30 // fragment within. | 30 // fragment within. |
| 31 // @param break_token The break token from which the layout should start. | 31 // @param break_token The break token from which the layout should start. |
| 32 NGBlockLayoutAlgorithm(NGBlockNode* node, | 32 NGBlockLayoutAlgorithm(NGBlockNode* node, |
| 33 NGConstraintSpace* space, | 33 NGConstraintSpace* space, |
| 34 NGBlockBreakToken* break_token = nullptr); | 34 NGBlockBreakToken* break_token = nullptr); |
| 35 | 35 |
| 36 Optional<MinMaxContentSize> ComputeMinMaxContentSize() const override; | 36 Optional<MinMaxContentSize> ComputeMinMaxContentSize() const override; |
| 37 virtual RefPtr<NGLayoutResult> Layout() override; | 37 virtual RefPtr<NGLayoutResult> Layout() override; |
| 38 | 38 |
| 39 protected: |
| 40 NGFragmentBuilder builder_; |
| 41 NGConstraintSpaceBuilder space_builder_; |
| 42 |
| 43 NGBoxStrut border_and_padding_; |
| 44 LayoutUnit content_size_; |
| 45 LayoutUnit max_inline_size_; |
| 46 |
| 39 private: | 47 private: |
| 40 NGBoxStrut CalculateMargins(NGLayoutInputNode* child, | 48 NGBoxStrut CalculateMargins(NGLayoutInputNode* child, |
| 41 const NGConstraintSpace& space); | 49 const NGConstraintSpace& space); |
| 42 | 50 |
| 43 // Creates a new constraint space for the current child. | 51 // Creates a new constraint space for the current child. |
| 44 RefPtr<NGConstraintSpace> CreateConstraintSpaceForChild(NGLayoutInputNode*); | 52 RefPtr<NGConstraintSpace> CreateConstraintSpaceForChild(NGLayoutInputNode*); |
| 45 void PrepareChildLayout(NGLayoutInputNode*); | 53 void PrepareChildLayout(NGLayoutInputNode*); |
| 46 void FinishChildLayout(NGLayoutInputNode*, | 54 void FinishChildLayout(NGLayoutInputNode*, |
| 47 NGConstraintSpace*, | 55 NGConstraintSpace*, |
| 48 RefPtr<NGLayoutResult>); | 56 RefPtr<NGLayoutResult>); |
| 49 | 57 |
| 50 // Final adjustments before fragment creation. We need to prevent the | 58 // Final adjustments before fragment creation. We need to prevent the |
| 51 // fragment from crossing fragmentainer boundaries, and rather create a break | 59 // fragment from crossing fragmentainer boundaries, and rather create a break |
| 52 // token if we're out of space. | 60 // token if we're out of space. |
| 53 void FinalizeForFragmentation(); | 61 void FinalizeForFragmentation(); |
| 54 | 62 |
| 55 // Calculates logical offset for the current fragment using either | 63 // Calculates logical offset for the current fragment using either |
| 56 // {@code content_size_} when the fragment doesn't know it's offset | 64 // {@code content_size_} when the fragment doesn't know it's offset |
| 57 // or {@code known_fragment_offset} if the fragment knows it's offset | 65 // or {@code known_fragment_offset} if the fragment knows it's offset |
| 58 // @return Fragment's offset relative to the fragment's parent. | 66 // @return Fragment's offset relative to the fragment's parent. |
| 59 NGLogicalOffset CalculateLogicalOffset( | 67 NGLogicalOffset CalculateLogicalOffset( |
| 60 const WTF::Optional<NGLogicalOffset>& known_fragment_offset); | 68 const WTF::Optional<NGLogicalOffset>& known_fragment_offset); |
| 61 | 69 |
| 62 // Updates the fragment's BFC offset if it's not already set. | 70 // Updates the fragment's BFC offset if it's not already set. |
| 63 void UpdateFragmentBfcOffset(const NGLogicalOffset& offset); | 71 void UpdateFragmentBfcOffset(const NGLogicalOffset& offset); |
| 64 | 72 |
| 65 NGFragmentBuilder builder_; | |
| 66 NGConstraintSpaceBuilder space_builder_; | |
| 67 | |
| 68 NGBoxStrut border_and_padding_; | |
| 69 LayoutUnit content_size_; | |
| 70 LayoutUnit max_inline_size_; | |
| 71 // MarginStrut for the previous child. | 73 // MarginStrut for the previous child. |
| 72 NGMarginStrut curr_margin_strut_; | 74 NGMarginStrut curr_margin_strut_; |
| 73 NGLogicalOffset curr_bfc_offset_; | 75 NGLogicalOffset curr_bfc_offset_; |
| 74 NGBoxStrut curr_child_margins_; | 76 NGBoxStrut curr_child_margins_; |
| 75 }; | 77 }; |
| 76 | 78 |
| 77 } // namespace blink | 79 } // namespace blink |
| 78 | 80 |
| 79 #endif // NGBlockLayoutAlgorithm_h | 81 #endif // NGBlockLayoutAlgorithm_h |
| OLD | NEW |