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_layout_result.h" | |
11 #include "core/layout/ng/ng_physical_box_fragment.h" | 12 #include "core/layout/ng/ng_physical_box_fragment.h" |
12 #include "platform/heap/Handle.h" | 13 #include "platform/heap/Handle.h" |
13 | 14 |
14 namespace blink { | 15 namespace blink { |
15 | 16 |
16 class ComputedStyle; | 17 class ComputedStyle; |
17 class LayoutObject; | 18 class LayoutObject; |
18 class NGBreakToken; | 19 class NGBreakToken; |
19 class NGConstraintSpace; | 20 class NGConstraintSpace; |
21 class NGLayoutResult; | |
20 struct NGLogicalOffset; | 22 struct NGLogicalOffset; |
21 class NGPhysicalFragment; | |
22 struct MinAndMaxContentSizes; | 23 struct MinAndMaxContentSizes; |
23 | 24 |
24 // Represents a node to be laid out. | 25 // Represents a node to be laid out. |
25 class CORE_EXPORT NGBlockNode final : public NGLayoutInputNode { | 26 class CORE_EXPORT NGBlockNode final : public NGLayoutInputNode { |
26 friend NGLayoutInputNode; | 27 friend NGLayoutInputNode; |
27 | 28 |
28 public: | 29 public: |
29 explicit NGBlockNode(LayoutObject*); | 30 explicit NGBlockNode(LayoutObject*); |
30 | 31 |
31 // TODO(layout-ng): make it private and declare a friend class to use in tests | 32 // TODO(layout-ng): make it private and declare a friend class to use in tests |
32 explicit NGBlockNode(ComputedStyle*); | 33 explicit NGBlockNode(ComputedStyle*); |
33 | 34 |
34 ~NGBlockNode() override; | 35 ~NGBlockNode() override; |
35 | 36 |
36 RefPtr<NGPhysicalFragment> Layout( | 37 RefPtr<NGLayoutResult> Layout(NGConstraintSpace* constraint_space) override; |
37 NGConstraintSpace* constraint_space) override; | |
38 NGBlockNode* NextSibling() override; | 38 NGBlockNode* NextSibling() override; |
39 LayoutObject* GetLayoutObject() override; | 39 LayoutObject* GetLayoutObject() override; |
40 | 40 |
41 // Computes the value of min-content and max-content for this box. | 41 // Computes the value of min-content and max-content for this box. |
42 // If the underlying layout algorithm's ComputeMinAndMaxContentSizes returns | 42 // If the underlying layout algorithm's ComputeMinAndMaxContentSizes returns |
43 // no value, this function will synthesize these sizes using Layout with | 43 // no value, this function will synthesize these sizes using Layout with |
44 // special constraint spaces -- infinite available size for max content, zero | 44 // special constraint spaces -- infinite available size for max content, zero |
45 // available size for min content, and percentage resolution size zero for | 45 // available size for min content, and percentage resolution size zero for |
46 // both. | 46 // both. |
47 MinAndMaxContentSizes ComputeMinAndMaxContentSizes(); | 47 MinAndMaxContentSizes ComputeMinAndMaxContentSizes(); |
48 | 48 |
49 const ComputedStyle& Style() const; | 49 const ComputedStyle& Style() const; |
50 | 50 |
51 NGLayoutInputNode* FirstChild(); | 51 NGLayoutInputNode* FirstChild(); |
52 | 52 |
53 void SetNextSibling(NGBlockNode*); | 53 void SetNextSibling(NGBlockNode*); |
54 void SetFirstChild(NGLayoutInputNode*); | 54 void SetFirstChild(NGLayoutInputNode*); |
55 | 55 |
56 void SetFragment(NGPhysicalBoxFragment* fragment) { fragment_ = fragment; } | 56 /// void SetFragment(NGPhysicalBoxFragment* fragment) { fragment_ = fragment; |
ikilpatrick
2017/02/21 22:26:02
remove or fix, or something :)
cbiesinger
2017/02/22 18:09:00
Ah, you were too fast, I uploaded a second patchse
| |
57 /// } | |
57 NGBreakToken* CurrentBreakToken() const; | 58 NGBreakToken* CurrentBreakToken() const; |
58 bool IsLayoutFinished() const { | 59 bool IsLayoutFinished() const { |
59 return fragment_ && !fragment_->BreakToken(); | 60 return layout_result_ && !layout_result_->PhysicalFragment()->BreakToken(); |
60 } | 61 } |
61 | 62 |
62 DECLARE_VIRTUAL_TRACE(); | 63 DECLARE_VIRTUAL_TRACE(); |
63 | 64 |
64 // Runs layout on layout_box_ and creates a fragment for the resulting | 65 // Runs layout on layout_box_ and creates a fragment for the resulting |
65 // geometry. | 66 // geometry. |
66 RefPtr<NGPhysicalBoxFragment> RunOldLayout(const NGConstraintSpace&); | 67 RefPtr<NGLayoutResult> RunOldLayout(const NGConstraintSpace&); |
67 | 68 |
68 // Called if this is an out-of-flow block which needs to be | 69 // Called if this is an out-of-flow block which needs to be |
69 // positioned with legacy layout. | 70 // positioned with legacy layout. |
70 void UseOldOutOfFlowPositioning(); | 71 void UseOldOutOfFlowPositioning(); |
71 | 72 |
72 // Save static position for legacy AbsPos layout. | 73 // Save static position for legacy AbsPos layout. |
73 void SaveStaticOffsetForLegacy(const NGLogicalOffset&); | 74 void SaveStaticOffsetForLegacy(const NGLogicalOffset&); |
74 private: | 75 private: |
75 | 76 |
76 bool CanUseNewLayout(); | 77 bool CanUseNewLayout(); |
77 bool HasInlineChildren(); | 78 bool HasInlineChildren(); |
78 | 79 |
79 // After we run the layout algorithm, this function copies back the geometry | 80 // After we run the layout algorithm, this function copies back the geometry |
80 // data to the layout box. | 81 // data to the layout box. |
81 void CopyFragmentDataToLayoutBox(const NGConstraintSpace&); | 82 void CopyFragmentDataToLayoutBox(const NGConstraintSpace&); |
82 | 83 |
83 // We can either wrap a layout_box_ or a style_/next_sibling_/first_child_ | 84 // We can either wrap a layout_box_ or a style_/next_sibling_/first_child_ |
84 // combination. | 85 // combination. |
85 LayoutBox* layout_box_; | 86 LayoutBox* layout_box_; |
86 RefPtr<ComputedStyle> style_; | 87 RefPtr<ComputedStyle> style_; |
87 Member<NGBlockNode> next_sibling_; | 88 Member<NGBlockNode> next_sibling_; |
88 Member<NGLayoutInputNode> first_child_; | 89 Member<NGLayoutInputNode> first_child_; |
89 // TODO(mstensho): An input node may produce multiple fragments, so this | 90 // TODO(mstensho): An input node may produce multiple fragments, so this |
90 // should probably be renamed to last_fragment_ or something like that, since | 91 // should probably be renamed to last_result_ or something like that, since |
91 // the last fragment is all we care about when resuming layout. | 92 // the last fragment is all we care about when resuming layout. |
92 RefPtr<NGPhysicalBoxFragment> fragment_; | 93 RefPtr<NGLayoutResult> layout_result_; |
93 }; | 94 }; |
94 | 95 |
95 DEFINE_TYPE_CASTS(NGBlockNode, | 96 DEFINE_TYPE_CASTS(NGBlockNode, |
96 NGLayoutInputNode, | 97 NGLayoutInputNode, |
97 node, | 98 node, |
98 node->Type() == NGLayoutInputNode::kLegacyBlock, | 99 node->Type() == NGLayoutInputNode::kLegacyBlock, |
99 node.Type() == NGLayoutInputNode::kLegacyBlock); | 100 node.Type() == NGLayoutInputNode::kLegacyBlock); |
100 | 101 |
101 } // namespace blink | 102 } // namespace blink |
102 | 103 |
103 #endif // NGBlockNode | 104 #endif // NGBlockNode |
OLD | NEW |