OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 LayoutSubtreeRootList_h | 5 #ifndef LayoutSubtreeRootList_h |
6 #define LayoutSubtreeRootList_h | 6 #define LayoutSubtreeRootList_h |
7 | 7 |
| 8 #include "wtf/Allocator.h" |
8 #include "wtf/HashSet.h" | 9 #include "wtf/HashSet.h" |
9 #include "wtf/Vector.h" | 10 #include "wtf/Vector.h" |
10 | 11 |
11 namespace blink { | 12 namespace blink { |
12 | 13 |
13 class LayoutObject; | 14 class LayoutObject; |
14 | 15 |
15 // This class keeps track of layout objects that have identified to be | 16 // This class keeps track of layout objects that have identified to be |
16 // independent layout roots meaning they won't affect other parts of the tree | 17 // independent layout roots meaning they won't affect other parts of the tree |
17 // by their layout. This is an optimization to avoid doing extra work and tree | 18 // by their layout. This is an optimization to avoid doing extra work and tree |
18 // walking during layout. See objectIsRelayoutBoundary for the criteria for | 19 // walking during layout. See objectIsRelayoutBoundary for the criteria for |
19 // being a root. | 20 // being a root. |
20 // These roots are sorted into a vector ordered by their depth in the tree, | 21 // These roots are sorted into a vector ordered by their depth in the tree, |
21 // and returned one by one deepest first for layout. This is necessary in the | 22 // and returned one by one deepest first for layout. This is necessary in the |
22 // case of nested subtree roots where a positioned object is added to the | 23 // case of nested subtree roots where a positioned object is added to the |
23 // contained root but its containing block is above that root. | 24 // contained root but its containing block is above that root. |
24 // It ensures we add positioned objects to their containing block's positioned | 25 // It ensures we add positioned objects to their containing block's positioned |
25 // descendant lists before laying out those objects if they're contained in | 26 // descendant lists before laying out those objects if they're contained in |
26 // a higher root. | 27 // a higher root. |
27 // TODO(leviw): This should really be something akin to a LayoutController | 28 // TODO(leviw): This should really be something akin to a LayoutController |
28 // that FrameView delegates layout work to. | 29 // that FrameView delegates layout work to. |
29 class LayoutSubtreeRootList { | 30 class LayoutSubtreeRootList { |
| 31 DISALLOW_ALLOCATION(); |
30 public: | 32 public: |
31 LayoutSubtreeRootList() | 33 LayoutSubtreeRootList() |
32 { } | 34 { } |
33 | 35 |
34 void addRoot(LayoutObject& object) | 36 void addRoot(LayoutObject& object) |
35 { | 37 { |
36 ASSERT(m_orderedRoots.isEmpty()); | 38 ASSERT(m_orderedRoots.isEmpty()); |
37 m_roots.add(&object); | 39 m_roots.add(&object); |
38 } | 40 } |
39 void removeRoot(LayoutObject&); | 41 void removeRoot(LayoutObject&); |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
83 | 85 |
84 // Outside of layout, roots can be added when marked as needing layout and | 86 // Outside of layout, roots can be added when marked as needing layout and |
85 // removed when removed when destroyed. They're kept in this hashset to | 87 // removed when removed when destroyed. They're kept in this hashset to |
86 // keep those operations fast. | 88 // keep those operations fast. |
87 HashSet<LayoutObject*> m_roots; | 89 HashSet<LayoutObject*> m_roots; |
88 }; | 90 }; |
89 | 91 |
90 } // namespace blink | 92 } // namespace blink |
91 | 93 |
92 #endif // LayoutSubtreeRootList_h | 94 #endif // LayoutSubtreeRootList_h |
OLD | NEW |