| 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 NGBlockNode_h | 5 #ifndef NGBlockNode_h |
| 6 #define NGBlockNode_h | 6 #define NGBlockNode_h |
| 7 | 7 |
| 8 #include "core/CoreExport.h" | 8 #include "core/CoreExport.h" |
| 9 #include "core/layout/LayoutBox.h" | 9 #include "core/layout/LayoutBox.h" |
| 10 #include "core/layout/ng/ng_layout_input_node.h" | 10 #include "core/layout/ng/ng_layout_input_node.h" |
| 11 #include "core/layout/ng/ng_physical_box_fragment.h" | 11 #include "core/layout/ng/ng_physical_box_fragment.h" |
| 12 #include "platform/heap/Handle.h" | 12 #include "platform/heap/Handle.h" |
| 13 | 13 |
| 14 namespace blink { | 14 namespace blink { |
| 15 | 15 |
| 16 class ComputedStyle; | |
| 17 class LayoutObject; | 16 class LayoutObject; |
| 18 class NGBreakToken; | 17 class NGBreakToken; |
| 19 class NGConstraintSpace; | 18 class NGConstraintSpace; |
| 20 class NGLayoutResult; | 19 class NGLayoutResult; |
| 21 struct NGLogicalOffset; | 20 struct NGLogicalOffset; |
| 22 struct MinMaxContentSize; | 21 struct MinMaxContentSize; |
| 23 | 22 |
| 24 // Represents a node to be laid out. | 23 // Represents a node to be laid out. |
| 25 class CORE_EXPORT NGBlockNode final : public NGLayoutInputNode { | 24 class CORE_EXPORT NGBlockNode final : public NGLayoutInputNode { |
| 26 friend NGLayoutInputNode; | 25 friend NGLayoutInputNode; |
| 27 | |
| 28 public: | 26 public: |
| 29 explicit NGBlockNode(LayoutObject*); | 27 explicit NGBlockNode(LayoutBox*); |
| 30 | |
| 31 ~NGBlockNode() override; | |
| 32 | 28 |
| 33 RefPtr<NGLayoutResult> Layout(NGConstraintSpace* constraint_space, | 29 RefPtr<NGLayoutResult> Layout(NGConstraintSpace* constraint_space, |
| 34 NGBreakToken* break_token = nullptr) override; | 30 NGBreakToken* break_token = nullptr); |
| 35 NGLayoutInputNode* NextSibling() override; | 31 NGLayoutInputNode NextSibling() const; |
| 36 LayoutObject* GetLayoutObject() const override; | |
| 37 | 32 |
| 38 // Computes the value of min-content and max-content for this box. | 33 // Computes the value of min-content and max-content for this box. |
| 39 // If the underlying layout algorithm's ComputeMinMaxContentSize returns | 34 // If the underlying layout algorithm's ComputeMinMaxContentSize returns |
| 40 // no value, this function will synthesize these sizes using Layout with | 35 // no value, this function will synthesize these sizes using Layout with |
| 41 // special constraint spaces -- infinite available size for max content, zero | 36 // special constraint spaces -- infinite available size for max content, zero |
| 42 // available size for min content, and percentage resolution size zero for | 37 // available size for min content, and percentage resolution size zero for |
| 43 // both. | 38 // both. |
| 44 MinMaxContentSize ComputeMinMaxContentSize() override; | 39 MinMaxContentSize ComputeMinMaxContentSize(); |
| 45 | 40 |
| 46 const ComputedStyle& Style() const override; | 41 NGLayoutInputNode FirstChild(); |
| 47 | 42 |
| 48 NGLayoutInputNode* FirstChild(); | 43 // Runs layout on the underlying LayoutObject and creates a fragment for the |
| 49 | 44 // resulting geometry. |
| 50 DECLARE_VIRTUAL_TRACE(); | |
| 51 | |
| 52 // Runs layout on layout_box_ and creates a fragment for the resulting | |
| 53 // geometry. | |
| 54 RefPtr<NGLayoutResult> RunOldLayout(const NGConstraintSpace&); | 45 RefPtr<NGLayoutResult> RunOldLayout(const NGConstraintSpace&); |
| 55 | 46 |
| 56 // Called if this is an out-of-flow block which needs to be | 47 // Called if this is an out-of-flow block which needs to be |
| 57 // positioned with legacy layout. | 48 // positioned with legacy layout. |
| 58 void UseOldOutOfFlowPositioning(); | 49 void UseOldOutOfFlowPositioning(); |
| 59 | 50 |
| 60 // Save static position for legacy AbsPos layout. | 51 // Save static position for legacy AbsPos layout. |
| 61 void SaveStaticOffsetForLegacy(const NGLogicalOffset&); | 52 void SaveStaticOffsetForLegacy(const NGLogicalOffset&); |
| 62 | 53 |
| 63 bool CanUseNewLayout() const; | 54 bool CanUseNewLayout() const; |
| 64 | 55 |
| 65 String ToString() const override; | 56 String ToString() const; |
| 66 | 57 |
| 67 private: | 58 private: |
| 68 // After we run the layout algorithm, this function copies back the geometry | 59 // After we run the layout algorithm, this function copies back the geometry |
| 69 // data to the layout box. | 60 // data to the layout box. |
| 70 void CopyFragmentDataToLayoutBox(const NGConstraintSpace&, NGLayoutResult*); | 61 void CopyFragmentDataToLayoutBox(const NGConstraintSpace&, NGLayoutResult*); |
| 71 | |
| 72 // We can either wrap a layout_box_ or a next_sibling_/first_child_ | |
| 73 // combination. | |
| 74 LayoutBox* layout_box_; | |
| 75 Member<NGLayoutInputNode> next_sibling_; | |
| 76 Member<NGLayoutInputNode> first_child_; | |
| 77 }; | 62 }; |
| 78 | 63 |
| 79 DEFINE_TYPE_CASTS(NGBlockNode, | 64 DEFINE_TYPE_CASTS(NGBlockNode, |
| 80 NGLayoutInputNode, | 65 NGLayoutInputNode, |
| 81 node, | 66 node, |
| 82 node->IsBlock(), | 67 node->IsBlock(), |
| 83 node.IsBlock()); | 68 node.IsBlock()); |
| 84 | 69 |
| 85 } // namespace blink | 70 } // namespace blink |
| 86 | 71 |
| 87 #endif // NGBlockNode | 72 #endif // NGBlockNode |
| OLD | NEW |