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 NGLayoutInputNode_h | 5 #ifndef NGLayoutInputNode_h |
6 #define NGLayoutInputNode_h | 6 #define NGLayoutInputNode_h |
7 | 7 |
8 #include "core/CoreExport.h" | 8 #include "core/CoreExport.h" |
9 #include "platform/heap/Handle.h" | 9 #include "platform/heap/Handle.h" |
10 | 10 |
11 namespace blink { | 11 namespace blink { |
12 | 12 |
13 class NGConstraintSpace; | 13 class NGConstraintSpace; |
14 class NGFragment; | 14 class NGPhysicalFragment; |
15 class NGLayoutAlgorithm; | 15 class NGLayoutAlgorithm; |
16 | 16 |
17 // Represents the input to a layout algorithm for a given node. The layout | 17 // Represents the input to a layout algorithm for a given node. The layout |
18 // engine should use the style, node type to determine which type of layout | 18 // engine should use the style, node type to determine which type of layout |
19 // algorithm to use to produce fragments for this node. | 19 // algorithm to use to produce fragments for this node. |
20 class CORE_EXPORT NGLayoutInputNode | 20 class CORE_EXPORT NGLayoutInputNode |
21 : public GarbageCollectedFinalized<NGLayoutInputNode> { | 21 : public GarbageCollectedFinalized<NGLayoutInputNode> { |
22 public: | 22 public: |
23 enum NGLayoutInputNodeType { kLegacyBlock = 0, kLegacyInline = 1 }; | 23 enum NGLayoutInputNodeType { kLegacyBlock = 0, kLegacyInline = 1 }; |
24 | 24 |
25 virtual ~NGLayoutInputNode(){}; | 25 virtual ~NGLayoutInputNode(){}; |
26 | 26 |
27 // Returns true when done; when this function returns false, it has to be | 27 // Performs layout on this input node, will return a new fragment. |
28 // called again. The out parameter will only be set when this function | 28 virtual NGPhysicalFragment* Layout(NGConstraintSpace*) = 0; |
29 // returns true. The same constraint space has to be passed each time. | |
30 virtual bool Layout(NGConstraintSpace*, NGFragment**) = 0; | |
31 | 29 |
32 // Returns the next sibling. | 30 // Returns the next sibling. |
33 virtual NGLayoutInputNode* NextSibling() = 0; | 31 virtual NGLayoutInputNode* NextSibling() = 0; |
34 | 32 |
35 NGLayoutInputNodeType Type() const { | 33 NGLayoutInputNodeType Type() const { |
36 return static_cast<NGLayoutInputNodeType>(type_); | 34 return static_cast<NGLayoutInputNodeType>(type_); |
37 } | 35 } |
38 | 36 |
39 static NGLayoutAlgorithm* AlgorithmForInputNode(NGLayoutInputNode*, | 37 static NGLayoutAlgorithm* AlgorithmForInputNode(NGLayoutInputNode*, |
40 NGConstraintSpace*); | 38 NGConstraintSpace*); |
41 | 39 |
42 DEFINE_INLINE_VIRTUAL_TRACE() {} | 40 DEFINE_INLINE_VIRTUAL_TRACE() {} |
43 | 41 |
44 protected: | 42 protected: |
45 explicit NGLayoutInputNode(NGLayoutInputNodeType type) : type_(type) {} | 43 explicit NGLayoutInputNode(NGLayoutInputNodeType type) : type_(type) {} |
46 | 44 |
47 private: | 45 private: |
48 unsigned type_ : 1; | 46 unsigned type_ : 1; |
49 }; | 47 }; |
50 | 48 |
51 } // namespace blink | 49 } // namespace blink |
52 | 50 |
53 #endif // NGLayoutInputNode_h | 51 #endif // NGLayoutInputNode_h |
OLD | NEW |