| 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_box.h" | 9 #include "core/layout/ng/ng_box.h" |
| 10 #include "core/layout/ng/ng_fragment_builder.h" | 10 #include "core/layout/ng/ng_fragment_builder.h" |
| (...skipping 19 matching lines...) Expand all Loading... |
| 30 // Actual layout implementation. Lays out the children in sequence within the | 30 // Actual layout implementation. Lays out the children in sequence within the |
| 31 // constraints given by the NGConstraintSpace. Returns a fragment with the | 31 // constraints given by the NGConstraintSpace. Returns a fragment with the |
| 32 // resulting layout information. | 32 // resulting layout information. |
| 33 // This function can not be const because for interruptible layout, we have | 33 // This function can not be const because for interruptible layout, we have |
| 34 // to be able to store state information. | 34 // to be able to store state information. |
| 35 // Returns true when done; when this function returns false, it has to be | 35 // Returns true when done; when this function returns false, it has to be |
| 36 // called again. The out parameter will only be set when this function | 36 // called again. The out parameter will only be set when this function |
| 37 // returns true. The same constraint space has to be passed each time. | 37 // returns true. The same constraint space has to be passed each time. |
| 38 bool Layout(const NGConstraintSpace*, NGPhysicalFragment**) override; | 38 bool Layout(const NGConstraintSpace*, NGPhysicalFragment**) override; |
| 39 | 39 |
| 40 DEFINE_INLINE_VIRTUAL_TRACE() { | 40 DECLARE_VIRTUAL_TRACE(); |
| 41 NGLayoutAlgorithm::trace(visitor); | |
| 42 visitor->trace(first_child_); | |
| 43 visitor->trace(builder_); | |
| 44 visitor->trace(constraint_space_for_children_); | |
| 45 visitor->trace(current_child_); | |
| 46 } | |
| 47 | 41 |
| 48 private: | 42 private: |
| 49 // Computes collapsed margins for 2 adjoining blocks and updates the resultant | 43 // Computes collapsed margins for 2 adjoining blocks and updates the resultant |
| 50 // fragment's MarginStrut if needed. | 44 // fragment's MarginStrut if needed. |
| 51 // See https://www.w3.org/TR/CSS2/box.html#collapsing-margins | 45 // See https://www.w3.org/TR/CSS2/box.html#collapsing-margins |
| 52 // | 46 // |
| 53 // @param space Constraint space for the block. | 47 // @param space Constraint space for the block. |
| 54 // @param child_margins Margins information for the current child. | 48 // @param child_margins Margins information for the current child. |
| 55 // @param fragment Current child's fragment. | 49 // @param fragment Current child's fragment. |
| 56 // @return NGBoxStrut with margins block start/end. | 50 // @return NGBoxStrut with margins block start/end. |
| (...skipping 21 matching lines...) Expand all Loading... |
| 78 NGLogicalOffset PositionFloatFragment(const NGFragment& fragment, | 72 NGLogicalOffset PositionFloatFragment(const NGFragment& fragment, |
| 79 const NGBoxStrut& margins); | 73 const NGBoxStrut& margins); |
| 80 | 74 |
| 81 // Updates block-{start|end} of the currently constructed fragment. | 75 // Updates block-{start|end} of the currently constructed fragment. |
| 82 // | 76 // |
| 83 // This method is supposed to be called on every child but it only updates | 77 // This method is supposed to be called on every child but it only updates |
| 84 // the block-start once (on the first non-zero height child fragment) and | 78 // the block-start once (on the first non-zero height child fragment) and |
| 85 // keeps updating block-end (on every non-zero height child). | 79 // keeps updating block-end (on every non-zero height child). |
| 86 void UpdateMarginStrut(const NGMarginStrut& from); | 80 void UpdateMarginStrut(const NGMarginStrut& from); |
| 87 | 81 |
| 82 bool LayoutCurrentChild(const NGConstraintSpace*); |
| 83 |
| 88 // Read-only Getters. | 84 // Read-only Getters. |
| 89 const ComputedStyle& Style() const { return *style_; } | 85 const ComputedStyle& Style() const { return *style_; } |
| 90 | 86 |
| 91 RefPtr<const ComputedStyle> style_; | 87 RefPtr<const ComputedStyle> style_; |
| 92 Member<NGBox> first_child_; | 88 Member<NGBox> first_child_; |
| 93 | 89 |
| 94 enum State { kStateInit, kStateChildLayout, kStateFinalize }; | 90 enum State { kStateInit, kStateChildLayout, kStateFinalize }; |
| 95 State state_; | 91 State state_; |
| 96 Member<NGFragmentBuilder> builder_; | 92 Member<NGFragmentBuilder> builder_; |
| 97 Member<NGConstraintSpace> constraint_space_for_children_; | 93 Member<NGConstraintSpace> constraint_space_for_children_; |
| 98 Member<NGBox> current_child_; | 94 Member<NGBox> current_child_; |
| 99 NGBoxStrut border_and_padding_; | 95 NGBoxStrut border_and_padding_; |
| 100 LayoutUnit content_size_; | 96 LayoutUnit content_size_; |
| 101 LayoutUnit max_inline_size_; | 97 LayoutUnit max_inline_size_; |
| 102 // MarginStrut for the previous child. | 98 // MarginStrut for the previous child. |
| 103 NGMarginStrut prev_child_margin_strut_; | 99 NGMarginStrut prev_child_margin_strut_; |
| 104 // Whether the block-start was set for the currently built | 100 // Whether the block-start was set for the currently built |
| 105 // fragment's margin strut. | 101 // fragment's margin strut. |
| 106 bool is_fragment_margin_strut_block_start_updated_ : 1; | 102 bool is_fragment_margin_strut_block_start_updated_ : 1; |
| 107 }; | 103 }; |
| 108 | 104 |
| 109 } // namespace blink | 105 } // namespace blink |
| 110 | 106 |
| 111 #endif // NGBlockLayoutAlgorithm_h | 107 #endif // NGBlockLayoutAlgorithm_h |
| OLD | NEW |