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

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

Issue 2782603003: Add NGColumnLayoutAlgorithm skeleton implementation. (Closed)
Patch Set: update TestExpectations Created 3 years, 8 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/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_node.h" 11 #include "core/layout/ng/ng_block_node.h"
11 #include "core/layout/ng/ng_constraint_space_builder.h" 12 #include "core/layout/ng/ng_constraint_space_builder.h"
12 #include "core/layout/ng/ng_fragment_builder.h" 13 #include "core/layout/ng/ng_fragment_builder.h"
13 #include "core/layout/ng/ng_layout_algorithm.h" 14 #include "core/layout/ng/ng_layout_algorithm.h"
14 #include "wtf/RefPtr.h" 15 #include "wtf/RefPtr.h"
15 16
16 namespace blink { 17 namespace blink {
17 18
18 class ComputedStyle;
19 class NGBlockBreakToken;
20 class NGConstraintSpace; 19 class NGConstraintSpace;
21 class NGLayoutResult; 20 class NGLayoutResult;
22 21
23 // A class for general block layout (e.g. a <div> with no special style). 22 // A class for general block layout (e.g. a <div> with no special style).
24 // Lays out the children in sequence. 23 // Lays out the children in sequence.
25 class CORE_EXPORT NGBlockLayoutAlgorithm : public NGLayoutAlgorithm { 24 class CORE_EXPORT NGBlockLayoutAlgorithm
25 : public NGLayoutAlgorithm<NGBlockNode, NGBlockBreakToken> {
26 public: 26 public:
27 // Default constructor. 27 // Default constructor.
28 // @param node The input node to perform layout upon. 28 // @param node The input node to perform layout upon.
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 RefPtr<NGLayoutResult> Layout() override; 37 virtual RefPtr<NGLayoutResult> Layout() override;
38 38
39 private: 39 private:
40 NGBoxStrut CalculateMargins(NGLayoutInputNode* child, 40 NGBoxStrut CalculateMargins(NGLayoutInputNode* child,
41 const NGConstraintSpace& space); 41 const NGConstraintSpace& space);
42 42
43 // Creates a new constraint space for the current child. 43 // Creates a new constraint space for the current child.
44 RefPtr<NGConstraintSpace> CreateConstraintSpaceForChild(NGLayoutInputNode*); 44 RefPtr<NGConstraintSpace> CreateConstraintSpaceForChild(NGLayoutInputNode*);
45 void PrepareChildLayout(NGLayoutInputNode*); 45 void PrepareChildLayout(NGLayoutInputNode*);
46 void FinishChildLayout(NGLayoutInputNode*, 46 void FinishChildLayout(NGLayoutInputNode*,
47 NGConstraintSpace*, 47 NGConstraintSpace*,
48 RefPtr<NGLayoutResult>); 48 RefPtr<NGLayoutResult>);
49 49
50 // Final adjustments before fragment creation. We need to prevent the 50 // Final adjustments before fragment creation. We need to prevent the
51 // fragment from crossing fragmentainer boundaries, and rather create a break 51 // fragment from crossing fragmentainer boundaries, and rather create a break
52 // token if we're out of space. 52 // token if we're out of space.
53 void FinalizeForFragmentation(); 53 void FinalizeForFragmentation();
54 54
55 // Calculates logical offset for the current fragment using either 55 // Calculates logical offset for the current fragment using either
56 // {@code content_size_} when the fragment doesn't know it's offset 56 // {@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 57 // or {@code known_fragment_offset} if the fragment knows it's offset
58 // @return Fragment's offset relative to the fragment's parent. 58 // @return Fragment's offset relative to the fragment's parent.
59 NGLogicalOffset CalculateLogicalOffset( 59 NGLogicalOffset CalculateLogicalOffset(
60 const WTF::Optional<NGLogicalOffset>& known_fragment_offset); 60 const WTF::Optional<NGLogicalOffset>& known_fragment_offset);
61 61
62 // Updates the fragment's BFC offset if it's not already set. 62 // Updates the fragment's BFC offset if it's not already set.
63 void UpdateFragmentBfcOffset(const NGLogicalOffset& offset); 63 void UpdateFragmentBfcOffset(const NGLogicalOffset& offset);
64 64
65 const NGConstraintSpace& ConstraintSpace() const {
66 DCHECK(constraint_space_);
67 return *constraint_space_;
68 }
69
70 const ComputedStyle& Style() const { return node_->Style(); }
71
72 // Mutable Getters.
73 NGConstraintSpace* MutableConstraintSpace() { return constraint_space_; }
74
75 Persistent<NGBlockNode> node_;
76 NGConstraintSpace* constraint_space_;
77
78 // The break token from which we are currently resuming layout.
79 NGBlockBreakToken* break_token_;
80
81 NGFragmentBuilder builder_; 65 NGFragmentBuilder builder_;
82 NGConstraintSpaceBuilder space_builder_; 66 NGConstraintSpaceBuilder space_builder_;
83 67
84 NGBoxStrut border_and_padding_; 68 NGBoxStrut border_and_padding_;
85 LayoutUnit content_size_; 69 LayoutUnit content_size_;
86 LayoutUnit max_inline_size_; 70 LayoutUnit max_inline_size_;
87 // MarginStrut for the previous child. 71 // MarginStrut for the previous child.
88 NGMarginStrut curr_margin_strut_; 72 NGMarginStrut curr_margin_strut_;
89 NGLogicalOffset curr_bfc_offset_; 73 NGLogicalOffset curr_bfc_offset_;
90 NGBoxStrut curr_child_margins_; 74 NGBoxStrut curr_child_margins_;
91 }; 75 };
92 76
93 } // namespace blink 77 } // namespace blink
94 78
95 #endif // NGBlockLayoutAlgorithm_h 79 #endif // NGBlockLayoutAlgorithm_h
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/layout/BUILD.gn ('k') | third_party/WebKit/Source/core/layout/ng/ng_block_layout_algorithm.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698