Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(161)

Side by Side Diff: Source/core/dom/TreeScope.h

Issue 235113002: Oilpan: Remove guardRef and guardDeref from TreeScope. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Rebase again. Created 6 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2011 Google Inc. All Rights Reserved. 2 * Copyright (C) 2011 Google Inc. All Rights Reserved.
3 * Copyright (C) 2012 Apple Inc. All Rights Reserved. 3 * Copyright (C) 2012 Apple Inc. All Rights Reserved.
4 * 4 *
5 * Redistribution and use in source and binary forms, with or without 5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions 6 * modification, are permitted provided that the following conditions
7 * are met: 7 * are met:
8 * 1. Redistributions of source code must retain the above copyright 8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright 10 * 2. Redistributions in binary form must reproduce the above copyright
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
95 95
96 bool applyAuthorStyles() const; 96 bool applyAuthorStyles() const;
97 97
98 // Used by the basic DOM mutation methods (e.g., appendChild()). 98 // Used by the basic DOM mutation methods (e.g., appendChild()).
99 void adoptIfNeeded(Node&); 99 void adoptIfNeeded(Node&);
100 100
101 Node& rootNode() const { return m_rootNode; } 101 Node& rootNode() const { return m_rootNode; }
102 102
103 IdTargetObserverRegistry& idTargetObserverRegistry() const { return *m_idTar getObserverRegistry.get(); } 103 IdTargetObserverRegistry& idTargetObserverRegistry() const { return *m_idTar getObserverRegistry.get(); }
104 104
105
106 #if !ENABLE(OILPAN)
105 // Nodes belonging to this scope hold guard references - 107 // Nodes belonging to this scope hold guard references -
106 // these are enough to keep the scope from being destroyed, but 108 // these are enough to keep the scope from being destroyed, but
107 // not enough to keep it from removing its children. This allows a 109 // not enough to keep it from removing its children. This allows a
108 // node that outlives its scope to still have a valid document 110 // node that outlives its scope to still have a valid document
109 // pointer without introducing reference cycles. 111 // pointer without introducing reference cycles.
110 void guardRef() 112 void guardRef()
111 { 113 {
112 #if ENABLE(OILPAN) 114 #if ENABLE(OILPAN)
tkent 2014/04/24 01:20:24 Here is in !ENABLE(OILPAN)
Mads Ager (chromium) 2014/04/24 10:57:36 Yeah, sorry, I thought I cleaned that up but most
113 if (!m_guardRefCount) { 115 if (!m_guardRefCount) {
114 ASSERT(!m_keepAlive); 116 ASSERT(!m_keepAlive);
115 m_keepAlive = adoptPtr(new Persistent<TreeScope>(this)); 117 m_keepAlive = adoptPtr(new Persistent<TreeScope>(this));
116 } 118 }
117 #else 119 #else
118 ASSERT(!deletionHasBegun()); 120 ASSERT(!deletionHasBegun());
119 #endif 121 #endif
120 ++m_guardRefCount; 122 ++m_guardRefCount;
121 } 123 }
122 124
123 void guardDeref() 125 void guardDeref()
124 { 126 {
125 ASSERT(m_guardRefCount > 0); 127 ASSERT(m_guardRefCount > 0);
126 #if !ENABLE(OILPAN) 128 #if !ENABLE(OILPAN)
tkent 2014/04/24 01:20:24 This is redundant because here is in !ENABLE(OILPA
Mads Ager (chromium) 2014/04/24 10:57:36 Done.
127 ASSERT(!deletionHasBegun()); 129 ASSERT(!deletionHasBegun());
128 #endif 130 #endif
129 --m_guardRefCount; 131 --m_guardRefCount;
130 #if ENABLE(OILPAN) 132 #if ENABLE(OILPAN)
tkent 2014/04/24 01:20:24 Here is in !ENABLE(OILPAN).
Mads Ager (chromium) 2014/04/24 10:57:36 Done.
131 if (!m_guardRefCount) 133 if (!m_guardRefCount)
132 clearKeepAlive(); 134 clearKeepAlive();
133 #else 135 #else
134 if (!m_guardRefCount && !refCount() && !rootNodeHasTreeSharedParent()) { 136 if (!m_guardRefCount && !refCount() && !rootNodeHasTreeSharedParent()) {
135 beginDeletion(); 137 beginDeletion();
136 delete this; 138 delete this;
137 } 139 }
138 #endif 140 #endif
139 } 141 }
142 #endif
140 143
141 void removedLastRefToScope(); 144 void removedLastRefToScope();
142 145
143 #if ENABLE(OILPAN) 146 #if ENABLE(OILPAN)
144 void clearKeepAlive() 147 void clearKeepAlive()
145 { 148 {
146 ASSERT(m_keepAlive); 149 ASSERT(m_keepAlive);
147 m_keepAlive = nullptr; 150 m_keepAlive = nullptr;
148 } 151 }
149 #endif 152 #endif
150 153
151 bool isInclusiveAncestorOf(const TreeScope&) const; 154 bool isInclusiveAncestorOf(const TreeScope&) const;
152 unsigned short comparePosition(const TreeScope&) const; 155 unsigned short comparePosition(const TreeScope&) const;
153 156
154 const TreeScope* commonAncestorTreeScope(const TreeScope& other) const; 157 const TreeScope* commonAncestorTreeScope(const TreeScope& other) const;
155 TreeScope* commonAncestorTreeScope(TreeScope& other); 158 TreeScope* commonAncestorTreeScope(TreeScope& other);
156 159
157 Element* getElementByAccessKey(const String& key) const; 160 Element* getElementByAccessKey(const String& key) const;
158 161
162 virtual void trace(Visitor*);
163
159 protected: 164 protected:
160 TreeScope(ContainerNode&, Document&); 165 TreeScope(ContainerNode&, Document&);
161 TreeScope(Document&); 166 TreeScope(Document&);
162 virtual ~TreeScope(); 167 virtual ~TreeScope();
163 168
164 void destroyTreeScopeData(); 169 void destroyTreeScopeData();
165 void setDocument(Document& document) { m_document = &document; } 170 void setDocument(Document& document) { m_document = &document; }
166 void setParentTreeScope(TreeScope&); 171 void setParentTreeScope(TreeScope&);
167 172
168 bool hasGuardRefCount() const { return m_guardRefCount; } 173 bool hasGuardRefCount() const { return m_guardRefCount; }
169 174
170 void setNeedsStyleRecalcForViewportUnits(); 175 void setNeedsStyleRecalcForViewportUnits();
171 176
172 private: 177 private:
173 virtual void dispose() { } 178 virtual void dispose() { }
174 179
175 int refCount() const; 180 int refCount() const;
176 #if SECURITY_ASSERT_ENABLED 181 #if SECURITY_ASSERT_ENABLED
177 bool deletionHasBegun(); 182 bool deletionHasBegun();
178 void beginDeletion(); 183 void beginDeletion();
179 #else 184 #else
180 bool deletionHasBegun() { return false; } 185 bool deletionHasBegun() { return false; }
181 void beginDeletion() { } 186 void beginDeletion() { }
182 #endif 187 #endif
183 188
184 bool rootNodeHasTreeSharedParent() const; 189 bool rootNodeHasTreeSharedParent() const;
185 190
186 Node& m_rootNode; 191 Node& m_rootNode;
187 Document* m_document; 192 Document* m_document;
188 TreeScope* m_parentTreeScope; 193 RawPtrWillBeMember<TreeScope> m_parentTreeScope;
189 int m_guardRefCount; 194 int m_guardRefCount;
190 195
191 OwnPtr<DocumentOrderedMap> m_elementsById; 196 OwnPtr<DocumentOrderedMap> m_elementsById;
192 OwnPtr<DocumentOrderedMap> m_imageMapsByName; 197 OwnPtr<DocumentOrderedMap> m_imageMapsByName;
193 OwnPtr<DocumentOrderedMap> m_labelsByForAttribute; 198 OwnPtr<DocumentOrderedMap> m_labelsByForAttribute;
194 199
195 OwnPtr<IdTargetObserverRegistry> m_idTargetObserverRegistry; 200 OwnPtr<IdTargetObserverRegistry> m_idTargetObserverRegistry;
196 201
197 #if ENABLE(OILPAN) 202 #if ENABLE(OILPAN)
Mads Ager (chromium) 2014/04/24 10:57:36 All of this code has been removed. There are no mo
198 // With Oilpan, a non-zero reference count will keep the TreeScope alive 203 // With Oilpan, a non-zero reference count will keep the TreeScope alive
199 // with a self-persistent handle. Whenever the ref count goes above zero 204 // with a self-persistent handle. Whenever the ref count goes above zero
200 // we register the TreeScope as a root for garbage collection by allocating a 205 // we register the TreeScope as a root for garbage collection by allocating a
201 // persistent handle to the object itself. When the ref count goes to zero 206 // persistent handle to the object itself. When the ref count goes to zero
202 // we deallocate the persistent handle again so the object can die if there 207 // we deallocate the persistent handle again so the object can die if there
203 // are no other things keeping it alive. 208 // are no other things keeping it alive.
204 // 209 //
205 // FIXME: Oilpan: Remove m_keepAlive and ref counting and use tracing instea d. 210 // FIXME: Oilpan: Remove m_keepAlive and ref counting and use tracing instea d.
206 GC_PLUGIN_IGNORE("359444") 211 GC_PLUGIN_IGNORE("359444")
207 OwnPtr<Persistent<TreeScope> > m_keepAlive; 212 OwnPtr<Persistent<TreeScope> > m_keepAlive;
208 #endif 213 #endif
209 214
210 GC_PLUGIN_IGNORE("359444") 215 GC_PLUGIN_IGNORE("359444")
211 mutable RefPtrWillBePersistent<DOMSelection> m_selection; 216 mutable RefPtrWillBePersistent<DOMSelection> m_selection;
Mads Ager (chromium) 2014/04/24 10:57:36 This persistent has been removed as well.
212 }; 217 };
213 218
214 inline bool TreeScope::hasElementWithId(StringImpl* id) const 219 inline bool TreeScope::hasElementWithId(StringImpl* id) const
215 { 220 {
216 ASSERT(id); 221 ASSERT(id);
217 return m_elementsById && m_elementsById->contains(id); 222 return m_elementsById && m_elementsById->contains(id);
218 } 223 }
219 224
220 inline bool TreeScope::containsMultipleElementsWithId(const AtomicString& id) co nst 225 inline bool TreeScope::containsMultipleElementsWithId(const AtomicString& id) co nst
221 { 226 {
222 return m_elementsById && m_elementsById->containsMultiple(id.impl()); 227 return m_elementsById && m_elementsById->containsMultiple(id.impl());
223 } 228 }
224 229
225 inline bool operator==(const TreeScope& a, const TreeScope& b) { return &a == &b ; } 230 inline bool operator==(const TreeScope& a, const TreeScope& b) { return &a == &b ; }
226 inline bool operator==(const TreeScope& a, const TreeScope* b) { return &a == b; } 231 inline bool operator==(const TreeScope& a, const TreeScope* b) { return &a == b; }
227 inline bool operator==(const TreeScope* a, const TreeScope& b) { return a == &b; } 232 inline bool operator==(const TreeScope* a, const TreeScope& b) { return a == &b; }
228 inline bool operator!=(const TreeScope& a, const TreeScope& b) { return !(a == b ); } 233 inline bool operator!=(const TreeScope& a, const TreeScope& b) { return !(a == b ); }
229 inline bool operator!=(const TreeScope& a, const TreeScope* b) { return !(a == b ); } 234 inline bool operator!=(const TreeScope& a, const TreeScope* b) { return !(a == b ); }
230 inline bool operator!=(const TreeScope* a, const TreeScope& b) { return !(a == b ); } 235 inline bool operator!=(const TreeScope* a, const TreeScope& b) { return !(a == b ); }
231 236
232 HitTestResult hitTestInDocument(const Document*, int x, int y); 237 HitTestResult hitTestInDocument(const Document*, int x, int y);
233 TreeScope* commonTreeScope(Node*, Node*); 238 TreeScope* commonTreeScope(Node*, Node*);
234 239
235 } // namespace WebCore 240 } // namespace WebCore
236 241
237 #endif // TreeScope_h 242 #endif // TreeScope_h
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698