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 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
45 visitor->trace(current_child_); | 45 visitor->trace(current_child_); |
46 } | 46 } |
47 | 47 |
48 private: | 48 private: |
49 // Computes collapsed margins for 2 adjoining blocks and updates the resultant | 49 // Computes collapsed margins for 2 adjoining blocks and updates the resultant |
50 // fragment's MarginStrut if needed. | 50 // fragment's MarginStrut if needed. |
51 // See https://www.w3.org/TR/CSS2/box.html#collapsing-margins | 51 // See https://www.w3.org/TR/CSS2/box.html#collapsing-margins |
52 // | 52 // |
53 // @param space Constraint space for the block. | 53 // @param space Constraint space for the block. |
54 // @param child_margins Margins information for the current child. | 54 // @param child_margins Margins information for the current child. |
55 // @param children_margin_strut MarginStrut for children of the current child. | 55 // @param fragment Current child's fragment. |
56 // @return Margin block start based on collapsed margins result. | 56 // @return Margin block start based on collapsed margins result. |
57 LayoutUnit CollapseMargins(const NGConstraintSpace& space, | 57 LayoutUnit CollapseMargins(const NGConstraintSpace& space, |
58 const NGBoxStrut& child_margins, | 58 const NGBoxStrut& child_margins, |
59 const NGMarginStrut& children_margin_strut); | 59 const NGFragment& fragment); |
| 60 |
| 61 // Updates block-{start|end} of the currently constructed fragment. |
| 62 // |
| 63 // This method is supposed to be called on every child but it only updates |
| 64 // the block-start once (on the first non-zero height child fragment) and |
| 65 // keeps updating block-end (on every non-zero height child). |
| 66 void UpdateMarginStrut(const NGMarginStrut& from); |
60 | 67 |
61 RefPtr<const ComputedStyle> style_; | 68 RefPtr<const ComputedStyle> style_; |
62 Member<NGBox> first_child_; | 69 Member<NGBox> first_child_; |
63 | 70 |
64 enum State { kStateInit, kStateChildLayout, kStateFinalize }; | 71 enum State { kStateInit, kStateChildLayout, kStateFinalize }; |
65 State state_; | 72 State state_; |
66 Member<NGFragmentBuilder> builder_; | 73 Member<NGFragmentBuilder> builder_; |
67 Member<NGConstraintSpace> constraint_space_for_children_; | 74 Member<NGConstraintSpace> constraint_space_for_children_; |
68 Member<NGBox> current_child_; | 75 Member<NGBox> current_child_; |
69 NGBoxStrut border_and_padding_; | 76 NGBoxStrut border_and_padding_; |
70 LayoutUnit content_size_; | 77 LayoutUnit content_size_; |
71 LayoutUnit max_inline_size_; | 78 LayoutUnit max_inline_size_; |
72 // MarginStrut for the previous child. | 79 // MarginStrut for the previous child. |
73 NGMarginStrut prev_child_margin_strut_; | 80 NGMarginStrut prev_child_margin_strut_; |
| 81 // Whether the block-start was set for the currently built |
| 82 // fragment's margin strut. |
| 83 bool is_fragment_margin_strut_block_start_updated_ : 1; |
74 }; | 84 }; |
75 | 85 |
76 } // namespace blink | 86 } // namespace blink |
77 | 87 |
78 #endif // NGBlockLayoutAlgorithm_h | 88 #endif // NGBlockLayoutAlgorithm_h |
OLD | NEW |