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

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

Issue 2810833003: Move container_builder to NGLayoutAlgorithm base class. (Closed)
Patch Set: git rebase-update 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
« no previous file with comments | « third_party/WebKit/Source/core/layout/ng/ng_block_layout_algorithm_test.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 NGLayoutAlgorithm_h 5 #ifndef NGLayoutAlgorithm_h
6 #define NGLayoutAlgorithm_h 6 #define NGLayoutAlgorithm_h
7 7
8 #include "core/CoreExport.h" 8 #include "core/CoreExport.h"
9 #include "core/layout/ng/ng_fragment_builder.h"
9 #include "core/layout/ng/ng_min_max_content_size.h" 10 #include "core/layout/ng/ng_min_max_content_size.h"
10 #include "platform/wtf/Allocator.h" 11 #include "platform/wtf/Allocator.h"
11 #include "platform/wtf/Optional.h" 12 #include "platform/wtf/Optional.h"
12 13
13 namespace blink { 14 namespace blink {
14 15
15 class ComputedStyle; 16 class ComputedStyle;
16 class NGConstraintSpace; 17 class NGConstraintSpace;
17 class NGLayoutResult; 18 class NGLayoutResult;
18 19
19 // Base class for all LayoutNG algorithms. 20 // Base class for all LayoutNG algorithms.
20 template <typename NGInputNodeType, typename NGBreakTokenType> 21 template <typename NGInputNodeType, typename NGBreakTokenType>
21 class CORE_EXPORT NGLayoutAlgorithm { 22 class CORE_EXPORT NGLayoutAlgorithm {
22 STACK_ALLOCATED(); 23 STACK_ALLOCATED();
23 public: 24 public:
24 NGLayoutAlgorithm(NGInputNodeType* node, 25 NGLayoutAlgorithm(NGInputNodeType* node,
25 NGConstraintSpace* space, 26 NGConstraintSpace* space,
26 NGBreakTokenType* break_token) 27 NGBreakTokenType* break_token)
27 : node_(node), constraint_space_(space), break_token_(break_token) {} 28 : node_(node),
29 constraint_space_(space),
30 break_token_(break_token),
31 container_builder_(NGPhysicalFragment::kFragmentBox, node) {}
28 32
29 virtual ~NGLayoutAlgorithm() {} 33 virtual ~NGLayoutAlgorithm() {}
30 34
31 // Actual layout function. Lays out the children and descendants within the 35 // Actual layout function. Lays out the children and descendants within the
32 // constraints given by the NGConstraintSpace. Returns a layout result with 36 // constraints given by the NGConstraintSpace. Returns a layout result with
33 // the resulting layout information. 37 // the resulting layout information.
34 // TODO(layout-dev): attempt to make this function const. 38 // TODO(layout-dev): attempt to make this function const.
35 virtual RefPtr<NGLayoutResult> Layout() = 0; 39 virtual RefPtr<NGLayoutResult> Layout() = 0;
36 40
37 // Computes the min-content and max-content intrinsic sizes for the given box. 41 // Computes the min-content and max-content intrinsic sizes for the given box.
(...skipping 10 matching lines...) Expand all
48 DCHECK(constraint_space_); 52 DCHECK(constraint_space_);
49 return *constraint_space_; 53 return *constraint_space_;
50 } 54 }
51 NGConstraintSpace* MutableConstraintSpace() { return constraint_space_; } 55 NGConstraintSpace* MutableConstraintSpace() { return constraint_space_; }
52 56
53 const ComputedStyle& Style() const { 57 const ComputedStyle& Style() const {
54 DCHECK(node_); 58 DCHECK(node_);
55 return node_->Style(); 59 return node_->Style();
56 } 60 }
57 61
62 NGLogicalOffset ContainerBfcOffset() const {
63 DCHECK(container_builder_.BfcOffset().has_value());
64 return container_builder_.BfcOffset().value();
65 }
66
58 virtual NGInputNodeType* Node() const { return node_; } 67 virtual NGInputNodeType* Node() const { return node_; }
59 68
60 NGBreakTokenType* BreakToken() const { return break_token_; } 69 NGBreakTokenType* BreakToken() const { return break_token_; }
61 70
62 Persistent<NGInputNodeType> node_; 71 Persistent<NGInputNodeType> node_;
63 NGConstraintSpace* constraint_space_; 72 NGConstraintSpace* constraint_space_;
64 73
65 // The break token from which we are currently resuming layout. 74 // The break token from which we are currently resuming layout.
66 NGBreakTokenType* break_token_; 75 NGBreakTokenType* break_token_;
76
77 NGFragmentBuilder container_builder_;
67 }; 78 };
68 79
69 } // namespace blink 80 } // namespace blink
70 81
71 #endif // NGLayoutAlgorithm_h 82 #endif // NGLayoutAlgorithm_h
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/layout/ng/ng_block_layout_algorithm_test.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698