| 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 "core/style/ComputedStyle.h" | 9 #include "core/style/ComputedStyle.h" |
| 10 #include "platform/heap/Handle.h" | 10 #include "platform/heap/Handle.h" |
| 11 | 11 |
| 12 namespace blink { | 12 namespace blink { |
| 13 | 13 |
| 14 class LayoutObject; | 14 class LayoutObject; |
| 15 class NGBreakToken; | 15 class NGBreakToken; |
| 16 class NGConstraintSpace; | 16 class NGConstraintSpace; |
| 17 class NGLayoutResult; | 17 class NGLayoutResult; |
| 18 struct MinMaxContentSize; | 18 struct MinMaxContentSize; |
| 19 | 19 |
| 20 // Represents the input to a layout algorithm for a given node. The layout | 20 // Represents the input to a layout algorithm for a given node. The layout |
| 21 // engine should use the style, node type to determine which type of layout | 21 // engine should use the style, node type to determine which type of layout |
| 22 // algorithm to use to produce fragments for this node. | 22 // algorithm to use to produce fragments for this node. |
| 23 class CORE_EXPORT NGLayoutInputNode | 23 class CORE_EXPORT NGLayoutInputNode { |
| 24 : public GarbageCollectedFinalized<NGLayoutInputNode> { | 24 DISALLOW_NEW_EXCEPT_PLACEMENT_NEW(); |
| 25 |
| 25 public: | 26 public: |
| 26 enum NGLayoutInputNodeType { kLegacyBlock = 0, kLegacyInline = 1 }; | 27 NGLayoutInputNode(std::nullptr_t) : box_(nullptr) {} |
| 27 | 28 |
| 28 bool IsInline() const { return type_ == kLegacyInline; } | 29 bool IsInline() const; |
| 30 bool IsBlock() const; |
| 31 bool IsFloating() const; |
| 32 bool IsOutOfFlowPositioned() const; |
| 29 | 33 |
| 30 bool IsBlock() const { return type_ == kLegacyBlock; } | 34 // Performs layout on this input node, will return the layout result. |
| 35 RefPtr<NGLayoutResult> Layout(NGConstraintSpace*, NGBreakToken*); |
| 31 | 36 |
| 32 bool IsFloating() const { return IsBlock() && Style().IsFloating(); } | 37 MinMaxContentSize ComputeMinMaxContentSize(); |
| 33 | 38 |
| 34 bool IsOutOfFlowPositioned() const { | 39 // Returns the next sibling. |
| 35 return IsBlock() && Style().HasOutOfFlowPosition(); | 40 NGLayoutInputNode NextSibling(); |
| 41 |
| 42 // Returns the LayoutObject which is associated with this node. |
| 43 LayoutObject* GetLayoutObject() const; |
| 44 |
| 45 const ComputedStyle& Style() const; |
| 46 |
| 47 String ToString() const; |
| 48 |
| 49 explicit operator bool() { return box_ != nullptr; } |
| 50 |
| 51 bool operator==(const NGLayoutInputNode& other) const { |
| 52 return box_ == other.box_; |
| 36 } | 53 } |
| 37 | 54 |
| 38 virtual ~NGLayoutInputNode(){}; | 55 bool operator!=(const NGLayoutInputNode& other) const { |
| 39 | 56 return !(*this == other); |
| 40 // Performs layout on this input node, will return the layout result. | |
| 41 virtual RefPtr<NGLayoutResult> Layout(NGConstraintSpace*, NGBreakToken*) = 0; | |
| 42 | |
| 43 // Returns the next sibling. | |
| 44 virtual NGLayoutInputNode* NextSibling() = 0; | |
| 45 | |
| 46 // Returns the LayoutObject which is associated with this node. | |
| 47 virtual LayoutObject* GetLayoutObject() const = 0; | |
| 48 | |
| 49 virtual MinMaxContentSize ComputeMinMaxContentSize() = 0; | |
| 50 | |
| 51 virtual const ComputedStyle& Style() const = 0; | |
| 52 | |
| 53 virtual String ToString() const = 0; | |
| 54 | |
| 55 NGLayoutInputNodeType Type() const { | |
| 56 return static_cast<NGLayoutInputNodeType>(type_); | |
| 57 } | 57 } |
| 58 | 58 |
| 59 #ifndef NDEBUG | 59 #ifndef NDEBUG |
| 60 void ShowNodeTree() const; | 60 void ShowNodeTree() const; |
| 61 #endif | 61 #endif |
| 62 | 62 |
| 63 DEFINE_INLINE_VIRTUAL_TRACE() {} | 63 protected: |
| 64 explicit NGLayoutInputNode(LayoutBox* box) : box_(box) {} |
| 64 | 65 |
| 65 protected: | 66 LayoutBox* box_; |
| 66 explicit NGLayoutInputNode(NGLayoutInputNodeType type) : type_(type) {} | |
| 67 | |
| 68 private: | |
| 69 unsigned type_ : 1; | |
| 70 }; | 67 }; |
| 71 | 68 |
| 72 } // namespace blink | 69 } // namespace blink |
| 73 | 70 |
| 74 #endif // NGLayoutInputNode_h | 71 #endif // NGLayoutInputNode_h |
| OLD | NEW |