Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(83)

Side by Side Diff: third_party/WebKit/Source/core/layout/ng/ng_block_layout_algorithm.h

Issue 2724133003: [LayoutNG] Switch NGConstraintSpace to being RefCounted. (Closed)
Patch Set: moar. Created 3 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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"
(...skipping 25 matching lines...) Expand all
36 NGBlockBreakToken* break_token = nullptr); 36 NGBlockBreakToken* break_token = nullptr);
37 37
38 Optional<MinAndMaxContentSizes> ComputeMinAndMaxContentSizes() const override; 38 Optional<MinAndMaxContentSizes> ComputeMinAndMaxContentSizes() const override;
39 RefPtr<NGLayoutResult> Layout() override; 39 RefPtr<NGLayoutResult> Layout() override;
40 40
41 private: 41 private:
42 NGBoxStrut CalculateMargins(NGBlockNode* child, 42 NGBoxStrut CalculateMargins(NGBlockNode* child,
43 const NGConstraintSpace& space); 43 const NGConstraintSpace& space);
44 44
45 // Creates a new constraint space for the current child. 45 // Creates a new constraint space for the current child.
46 NGConstraintSpace* CreateConstraintSpaceForChild(NGLayoutInputNode*); 46 RefPtr<NGConstraintSpace> CreateConstraintSpaceForChild(NGLayoutInputNode*);
47 void FinishChildLayout(NGLayoutInputNode*, 47 void FinishChildLayout(NGLayoutInputNode*,
48 NGConstraintSpace*, 48 NGConstraintSpace*,
49 RefPtr<NGLayoutResult>); 49 RefPtr<NGLayoutResult>);
50 50
51 // Layout inline children. 51 // Layout inline children.
52 void LayoutInlineChildren(NGInlineNode*, NGConstraintSpace*); 52 void LayoutInlineChildren(NGInlineNode*, NGConstraintSpace*);
53 53
54 // Final adjustments before fragment creation. We need to prevent the 54 // Final adjustments before fragment creation. We need to prevent the
55 // fragment from crossing fragmentainer boundaries, and rather create a break 55 // fragment from crossing fragmentainer boundaries, and rather create a break
56 // token if we're out of space. 56 // token if we're out of space.
57 void FinalizeForFragmentation(); 57 void FinalizeForFragmentation();
58 58
59 // Calculates logical offset for the current fragment using either 59 // Calculates logical offset for the current fragment using either
60 // {@code content_size_} when the fragment doesn't know it's offset 60 // {@code content_size_} when the fragment doesn't know it's offset
61 // or {@code known_fragment_offset} if the fragment knows it's offset 61 // or {@code known_fragment_offset} if the fragment knows it's offset
62 // @return Fragment's offset relative to the fragment's parent. 62 // @return Fragment's offset relative to the fragment's parent.
63 NGLogicalOffset CalculateLogicalOffset( 63 NGLogicalOffset CalculateLogicalOffset(
64 const WTF::Optional<NGLogicalOffset>& known_fragment_offset); 64 const WTF::Optional<NGLogicalOffset>& known_fragment_offset);
65 65
66 // Updates the fragment's BFC offset if it's not already set. 66 // Updates the fragment's BFC offset if it's not already set.
67 void UpdateFragmentBfcOffset(const NGLogicalOffset& offset); 67 void UpdateFragmentBfcOffset(const NGLogicalOffset& offset);
68 68
69 NGLogicalOffset GetChildSpaceOffset() const { 69 NGLogicalOffset GetChildSpaceOffset() const {
70 return NGLogicalOffset(border_and_padding_.inline_start, content_size_); 70 return NGLogicalOffset(border_and_padding_.inline_start, content_size_);
71 } 71 }
72 72
73 const NGConstraintSpace& ConstraintSpace() const { 73 const NGConstraintSpace& ConstraintSpace() const {
74 DCHECK(constraint_space_);
74 return *constraint_space_; 75 return *constraint_space_;
75 } 76 }
76 77
77 const ComputedStyle& Style() const { return node_->Style(); } 78 const ComputedStyle& Style() const { return node_->Style(); }
78 79
79 Persistent<NGBlockNode> node_; 80 Persistent<NGBlockNode> node_;
80 Persistent<NGConstraintSpace> constraint_space_; 81 NGConstraintSpace* constraint_space_;
ikilpatrick 2017/03/02 17:20:15 Just a pointer as STACK_ALLOCATED(). Going to chan
81 82
82 // The break token from which we are currently resuming layout. 83 // The break token from which we are currently resuming layout.
83 Persistent<NGBlockBreakToken> break_token_; 84 Persistent<NGBlockBreakToken> break_token_;
84 85
85 NGFragmentBuilder builder_; 86 NGFragmentBuilder builder_;
86 NGConstraintSpaceBuilder space_builder_; 87 NGConstraintSpaceBuilder space_builder_;
87 88
88 NGBoxStrut border_and_padding_; 89 NGBoxStrut border_and_padding_;
89 LayoutUnit content_size_; 90 LayoutUnit content_size_;
90 LayoutUnit max_inline_size_; 91 LayoutUnit max_inline_size_;
91 // MarginStrut for the previous child. 92 // MarginStrut for the previous child.
92 NGMarginStrut curr_margin_strut_; 93 NGMarginStrut curr_margin_strut_;
93 NGLogicalOffset curr_bfc_offset_; 94 NGLogicalOffset curr_bfc_offset_;
94 NGBoxStrut curr_child_margins_; 95 NGBoxStrut curr_child_margins_;
95 }; 96 };
96 97
97 } // namespace blink 98 } // namespace blink
98 99
99 #endif // NGBlockLayoutAlgorithm_h 100 #endif // NGBlockLayoutAlgorithm_h
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698