| 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/ng/ng_layout_input_node.h" | 9 #include "core/layout/ng/ng_layout_input_node.h" |
| 10 #include "core/layout/ng/ng_physical_box_fragment.h" | 10 #include "core/layout/ng/ng_physical_box_fragment.h" |
| 11 #include "platform/heap/Handle.h" | 11 #include "platform/heap/Handle.h" |
| 12 | 12 |
| 13 namespace blink { | 13 namespace blink { |
| 14 | 14 |
| 15 class ComputedStyle; | 15 class ComputedStyle; |
| 16 class LayoutBox; | 16 class LayoutBox; |
| 17 class LayoutObject; | 17 class LayoutObject; |
| 18 class NGBreakToken; | 18 class NGBreakToken; |
| 19 class NGConstraintSpace; | 19 class NGConstraintSpace; |
| 20 class NGFragment; | |
| 21 class NGLayoutCoordinator; | |
| 22 struct NGLogicalOffset; | 20 struct NGLogicalOffset; |
| 21 class NGPhysicalFragment; |
| 23 struct MinAndMaxContentSizes; | 22 struct MinAndMaxContentSizes; |
| 24 | 23 |
| 25 // Represents a node to be laid out. | 24 // Represents a node to be laid out. |
| 26 class CORE_EXPORT NGBlockNode final : public NGLayoutInputNode { | 25 class CORE_EXPORT NGBlockNode final : public NGLayoutInputNode { |
| 27 friend NGLayoutInputNode; | 26 friend NGLayoutInputNode; |
| 28 | 27 |
| 29 public: | 28 public: |
| 30 explicit NGBlockNode(LayoutObject*); | 29 explicit NGBlockNode(LayoutObject*); |
| 31 | 30 |
| 32 // TODO(layout-ng): make it private and declare a friend class to use in tests | 31 // TODO(layout-ng): make it private and declare a friend class to use in tests |
| 33 explicit NGBlockNode(ComputedStyle*); | 32 explicit NGBlockNode(ComputedStyle*); |
| 34 | 33 |
| 35 ~NGBlockNode() override; | 34 ~NGBlockNode() override; |
| 36 | 35 |
| 37 bool Layout(NGConstraintSpace*, NGFragment**) override; | 36 NGPhysicalFragment* Layout(NGConstraintSpace* constraint_space) override; |
| 38 void LayoutSync(NGConstraintSpace*, NGFragment**); | |
| 39 | 37 |
| 40 NGBlockNode* NextSibling() override; | 38 NGBlockNode* NextSibling() override; |
| 41 | 39 |
| 42 // Computes the value of min-content and max-content for this box. | 40 // Computes the value of min-content and max-content for this box. |
| 43 // The return value has the same meaning as for Layout. | 41 // The return value has the same meaning as for Layout. |
| 44 // If the underlying layout algorithm returns NotImplemented from | 42 // If the underlying layout algorithm returns NotImplemented from |
| 45 // ComputeMinAndMaxContentSizes, this function will synthesize these sizes | 43 // ComputeMinAndMaxContentSizes, this function will synthesize these sizes |
| 46 // using Layout with special constraint spaces. | 44 // using Layout with special constraint spaces. |
| 47 // It is not legal to interleave a pending Layout() with a pending | 45 // It is not legal to interleave a pending Layout() with a pending |
| 48 // ComputeOrSynthesizeMinAndMaxContentSizes (i.e. you have to call Layout | 46 // ComputeOrSynthesizeMinAndMaxContentSizes (i.e. you have to call Layout |
| (...skipping 22 matching lines...) Expand all Loading... |
| 71 // geometry. | 69 // geometry. |
| 72 NGPhysicalBoxFragment* RunOldLayout(const NGConstraintSpace&); | 70 NGPhysicalBoxFragment* RunOldLayout(const NGConstraintSpace&); |
| 73 | 71 |
| 74 // Called if this is an out-of-flow block which needs to be | 72 // Called if this is an out-of-flow block which needs to be |
| 75 // positioned with legacy layout. | 73 // positioned with legacy layout. |
| 76 void UseOldOutOfFlowPositioning(); | 74 void UseOldOutOfFlowPositioning(); |
| 77 | 75 |
| 78 // Save static position for legacy AbsPos layout. | 76 // Save static position for legacy AbsPos layout. |
| 79 void SaveStaticOffsetForLegacy(const NGLogicalOffset&); | 77 void SaveStaticOffsetForLegacy(const NGLogicalOffset&); |
| 80 | 78 |
| 81 void UpdateLayoutBox(NGPhysicalBoxFragment* fragment, | |
| 82 const NGConstraintSpace* constraint_space); | |
| 83 // This is necessary for interop between old and new trees -- after our parent | 79 // This is necessary for interop between old and new trees -- after our parent |
| 84 // positions us, it calls this function so we can store the position on the | 80 // positions us, it calls this function so we can store the position on the |
| 85 // underlying LayoutBox. | 81 // underlying LayoutBox. |
| 86 void PositionUpdated(); | 82 void PositionUpdated(); |
| 87 | 83 |
| 88 private: | 84 private: |
| 89 bool CanUseNewLayout(); | 85 bool CanUseNewLayout(); |
| 90 bool HasInlineChildren(); | 86 bool HasInlineChildren(); |
| 91 | 87 |
| 92 // After we run the layout algorithm, this function copies back the geometry | 88 // After we run the layout algorithm, this function copies back the geometry |
| 93 // data to the layout box. | 89 // data to the layout box. |
| 94 void CopyFragmentDataToLayoutBox(const NGConstraintSpace&); | 90 void CopyFragmentDataToLayoutBox(const NGConstraintSpace&); |
| 95 | 91 |
| 96 // We can either wrap a layout_box_ or a style_/next_sibling_/first_child_ | 92 // We can either wrap a layout_box_ or a style_/next_sibling_/first_child_ |
| 97 // combination. | 93 // combination. |
| 98 LayoutBox* layout_box_; | 94 LayoutBox* layout_box_; |
| 99 RefPtr<ComputedStyle> style_; | 95 RefPtr<ComputedStyle> style_; |
| 100 Member<NGBlockNode> next_sibling_; | 96 Member<NGBlockNode> next_sibling_; |
| 101 Member<NGLayoutInputNode> first_child_; | 97 Member<NGLayoutInputNode> first_child_; |
| 102 Member<NGLayoutCoordinator> layout_coordinator_; | |
| 103 // TODO(mstensho): An input node may produce multiple fragments, so this | 98 // TODO(mstensho): An input node may produce multiple fragments, so this |
| 104 // should probably be renamed to last_fragment_ or something like that, since | 99 // should probably be renamed to last_fragment_ or something like that, since |
| 105 // the last fragment is all we care about when resuming layout. | 100 // the last fragment is all we care about when resuming layout. |
| 106 Member<NGPhysicalBoxFragment> fragment_; | 101 Member<NGPhysicalBoxFragment> fragment_; |
| 107 }; | 102 }; |
| 108 | 103 |
| 109 DEFINE_TYPE_CASTS(NGBlockNode, | 104 DEFINE_TYPE_CASTS(NGBlockNode, |
| 110 NGLayoutInputNode, | 105 NGLayoutInputNode, |
| 111 node, | 106 node, |
| 112 node->Type() == NGLayoutInputNode::kLegacyBlock, | 107 node->Type() == NGLayoutInputNode::kLegacyBlock, |
| 113 node.Type() == NGLayoutInputNode::kLegacyBlock); | 108 node.Type() == NGLayoutInputNode::kLegacyBlock); |
| 114 | 109 |
| 115 } // namespace blink | 110 } // namespace blink |
| 116 | 111 |
| 117 #endif // NGBlockNode | 112 #endif // NGBlockNode |
| OLD | NEW |