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 NGBox_h | 5 #ifndef NGBox_h |
6 #define NGBox_h | 6 #define NGBox_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 ComputedStyle; | 13 class ComputedStyle; |
14 class LayoutBox; | 14 class LayoutBox; |
15 class LayoutObject; | 15 class LayoutObject; |
16 class NGBlockLayoutAlgorithm; | 16 class NGBlockLayoutAlgorithm; |
17 class NGConstraintSpace; | 17 class NGConstraintSpace; |
18 class NGFragment; | 18 class NGFragment; |
19 class NGPhysicalFragment; | 19 class NGPhysicalFragment; |
20 | 20 |
21 // Represents a node to be laid out. | 21 // Represents a node to be laid out. |
22 class CORE_EXPORT NGBox final : public GarbageCollectedFinalized<NGBox> { | 22 class CORE_EXPORT NGBox final : public GarbageCollectedFinalized<NGBox> { |
23 public: | 23 public: |
24 explicit NGBox(LayoutObject*); | 24 explicit NGBox(LayoutObject*); |
25 | 25 |
26 // TODO(layout-ng): make it private and declare a friend class to use in tests | 26 // TODO(layout-ng): make it private and declare a friend class to use in tests |
27 explicit NGBox(ComputedStyle*); | 27 explicit NGBox(ComputedStyle*); |
28 | 28 |
29 // Returns true when done; when this function returns false, it has to be | 29 // Returns true when done; when this function returns false, it has to be |
30 // called again. The out parameter will only be set when this function | 30 // called again. The same constraint space has to be passed each time. |
31 // returns true. The same constraint space has to be passed each time. | |
32 // TODO(layout-ng): Should we have a StartLayout function to avoid passing | 31 // TODO(layout-ng): Should we have a StartLayout function to avoid passing |
33 // the same space for each Layout iteration? | 32 // the same space for each Layout iteration? |
34 bool Layout(const NGConstraintSpace*, NGFragment**); | 33 bool Layout(const NGConstraintSpace*); |
35 const ComputedStyle* Style() const; | 34 const ComputedStyle* Style() const; |
36 | 35 |
37 NGBox* NextSibling(); | 36 NGBox* NextSibling(); |
38 | 37 |
39 NGBox* FirstChild(); | 38 NGBox* FirstChild(); |
40 | 39 |
41 void SetNextSibling(NGBox*); | 40 void SetNextSibling(NGBox*); |
42 void SetFirstChild(NGBox*); | 41 void SetFirstChild(NGBox*); |
43 | 42 |
| 43 NGFragment* Fragment() { return fragment_; } |
| 44 |
44 DEFINE_INLINE_VIRTUAL_TRACE() { | 45 DEFINE_INLINE_VIRTUAL_TRACE() { |
45 visitor->trace(algorithm_); | 46 visitor->trace(algorithm_); |
46 visitor->trace(fragment_); | 47 visitor->trace(fragment_); |
47 visitor->trace(next_sibling_); | 48 visitor->trace(next_sibling_); |
48 visitor->trace(first_child_); | 49 visitor->trace(first_child_); |
49 } | 50 } |
50 | 51 |
51 private: | 52 private: |
52 // This is necessary for interop between old and new trees -- after our parent | 53 // This is necessary for interop between old and new trees -- after our parent |
53 // positions us, it calls this function so we can store the position on the | 54 // positions us, it calls this function so we can store the position on the |
54 // underlying LayoutBox. | 55 // underlying LayoutBox. |
55 void PositionUpdated(); | 56 void PositionUpdated(); |
56 | 57 |
57 bool CanUseNewLayout(); | 58 bool CanUseNewLayout(); |
58 | 59 |
59 // We can either wrap a layout_box_ or a style_/next_sibling_/first_child_ | 60 // We can either wrap a layout_box_ or a style_/next_sibling_/first_child_ |
60 // combination. | 61 // combination. |
61 LayoutBox* layout_box_; | 62 LayoutBox* layout_box_; |
62 RefPtr<ComputedStyle> style_; | 63 RefPtr<ComputedStyle> style_; |
63 Member<NGBox> next_sibling_; | 64 Member<NGBox> next_sibling_; |
64 Member<NGBox> first_child_; | 65 Member<NGBox> first_child_; |
65 Member<NGBlockLayoutAlgorithm> algorithm_; | 66 Member<NGBlockLayoutAlgorithm> algorithm_; |
66 Member<NGPhysicalFragment> fragment_; | 67 Member<NGFragment> fragment_; |
67 }; | 68 }; |
68 | 69 |
69 } // namespace blink | 70 } // namespace blink |
70 | 71 |
71 #endif // NGBox_h | 72 #endif // NGBox_h |
OLD | NEW |