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

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

Issue 236653002: Oilpan: move mutation observers to the Oilpan heap. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Rebased + explicitly dispose() mutation observer registrations always (non-Oilpan also.) 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
« no previous file with comments | « Source/core/dom/Node.cpp ('k') | Source/core/dom/NodeRareData.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2008, 2010 Apple Inc. All rights reserved. 2 * Copyright (C) 2008, 2010 Apple Inc. All rights reserved.
3 * Copyright (C) 2008 David Smith <catfish.man@gmail.com> 3 * Copyright (C) 2008 David Smith <catfish.man@gmail.com>
4 * 4 *
5 * This library is free software; you can redistribute it and/or 5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Library General Public 6 * modify it under the terms of the GNU Library General Public
7 * License as published by the Free Software Foundation; either 7 * License as published by the Free Software Foundation; either
8 * version 2 of the License, or (at your option) any later version. 8 * version 2 of the License, or (at your option) any later version.
9 * 9 *
10 * This library is distributed in the hope that it will be useful, 10 * This library is distributed in the hope that it will be useful,
(...skipping 11 matching lines...) Expand all
22 #ifndef NodeRareData_h 22 #ifndef NodeRareData_h
23 #define NodeRareData_h 23 #define NodeRareData_h
24 24
25 #include "core/dom/ChildNodeList.h" 25 #include "core/dom/ChildNodeList.h"
26 #include "core/dom/EmptyNodeList.h" 26 #include "core/dom/EmptyNodeList.h"
27 #include "core/dom/LiveNodeList.h" 27 #include "core/dom/LiveNodeList.h"
28 #include "core/dom/MutationObserverRegistration.h" 28 #include "core/dom/MutationObserverRegistration.h"
29 #include "core/dom/QualifiedName.h" 29 #include "core/dom/QualifiedName.h"
30 #include "core/dom/TagCollection.h" 30 #include "core/dom/TagCollection.h"
31 #include "core/page/Page.h" 31 #include "core/page/Page.h"
32 #include "platform/heap/Handle.h"
32 #include "wtf/HashSet.h" 33 #include "wtf/HashSet.h"
33 #include "wtf/OwnPtr.h" 34 #include "wtf/OwnPtr.h"
34 #include "wtf/PassOwnPtr.h" 35 #include "wtf/PassOwnPtr.h"
35 #include "wtf/text/AtomicString.h" 36 #include "wtf/text/AtomicString.h"
36 #include "wtf/text/StringHash.h" 37 #include "wtf/text/StringHash.h"
37 38
38 namespace WebCore { 39 namespace WebCore {
39 40
40 class LabelsNodeList; 41 class LabelsNodeList;
41 class RadioNodeList; 42 class RadioNodeList;
(...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after
202 } 203 }
203 204
204 bool deleteThisAndUpdateNodeRareDataIfAboutToRemoveLastList(Node&); 205 bool deleteThisAndUpdateNodeRareDataIfAboutToRemoveLastList(Node&);
205 206
206 // Can be a ChildNodeList or an EmptyNodeList. 207 // Can be a ChildNodeList or an EmptyNodeList.
207 NodeList* m_childNodeList; 208 NodeList* m_childNodeList;
208 NodeListAtomicNameCacheMap m_atomicNameCaches; 209 NodeListAtomicNameCacheMap m_atomicNameCaches;
209 TagCollectionCacheNS m_tagCollectionCacheNS; 210 TagCollectionCacheNS m_tagCollectionCacheNS;
210 }; 211 };
211 212
212 class NodeMutationObserverData { 213 class NodeMutationObserverData FINAL : public NoBaseWillBeGarbageCollected<NodeM utationObserverData> {
213 WTF_MAKE_NONCOPYABLE(NodeMutationObserverData); WTF_MAKE_FAST_ALLOCATED; 214 WTF_MAKE_NONCOPYABLE(NodeMutationObserverData);
215 WTF_MAKE_FAST_ALLOCATED_WILL_BE_REMOVED;
214 public: 216 public:
215 Vector<OwnPtr<MutationObserverRegistration> > registry; 217 WillBeHeapVector<OwnPtrWillBeMember<MutationObserverRegistration> > registry ;
216 HashSet<MutationObserverRegistration*> transientRegistry; 218 WillBeHeapHashSet<RawPtrWillBeMember<MutationObserverRegistration> > transie ntRegistry;
Erik Corry 2014/04/22 12:46:55 I suppose these raw pointers were only cycle-break
haraken 2014/04/22 13:03:07 It would depend on how you see these pointers. In
sof 2014/04/22 13:05:29 Ownership with these transients raw pointers lie w
217 219
218 static PassOwnPtr<NodeMutationObserverData> create() { return adoptPtr(new N odeMutationObserverData); } 220 static PassOwnPtrWillBeRawPtr<NodeMutationObserverData> create()
221 {
222 return adoptPtrWillBeNoop(new NodeMutationObserverData);
223 }
224
225 void trace(Visitor* visitor)
226 {
227 visitor->trace(registry);
228 visitor->trace(transientRegistry);
229 }
219 230
220 private: 231 private:
221 NodeMutationObserverData() { } 232 NodeMutationObserverData() { }
222 }; 233 };
223 234
224 class NodeRareData : public NodeRareDataBase { 235 class NodeRareData : public NodeRareDataBase {
225 WTF_MAKE_NONCOPYABLE(NodeRareData); WTF_MAKE_FAST_ALLOCATED; 236 WTF_MAKE_NONCOPYABLE(NodeRareData); WTF_MAKE_FAST_ALLOCATED;
226 public: 237 public:
227 static PassOwnPtr<NodeRareData> create(RenderObject* renderer) { return adop tPtr(new NodeRareData(renderer)); } 238 static PassOwnPtr<NodeRareData> create(RenderObject* renderer)
239 {
240 return adoptPtr(new NodeRareData(renderer));
241 }
242
243 void dispose();
228 244
229 void clearNodeLists() { m_nodeLists.clear(); } 245 void clearNodeLists() { m_nodeLists.clear(); }
230 NodeListsNodeData* nodeLists() const { return m_nodeLists.get(); } 246 NodeListsNodeData* nodeLists() const { return m_nodeLists.get(); }
231 NodeListsNodeData& ensureNodeLists() 247 NodeListsNodeData& ensureNodeLists()
232 { 248 {
233 if (!m_nodeLists) 249 if (!m_nodeLists)
234 m_nodeLists = NodeListsNodeData::create(); 250 m_nodeLists = NodeListsNodeData::create();
235 return *m_nodeLists; 251 return *m_nodeLists;
236 } 252 }
237 253
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
271 protected: 287 protected:
272 NodeRareData(RenderObject* renderer) 288 NodeRareData(RenderObject* renderer)
273 : NodeRareDataBase(renderer) 289 : NodeRareDataBase(renderer)
274 , m_connectedFrameCount(0) 290 , m_connectedFrameCount(0)
275 , m_elementFlags(0) 291 , m_elementFlags(0)
276 , m_restyleFlags(0) 292 , m_restyleFlags(0)
277 { } 293 { }
278 294
279 private: 295 private:
280 OwnPtr<NodeListsNodeData> m_nodeLists; 296 OwnPtr<NodeListsNodeData> m_nodeLists;
281 OwnPtr<NodeMutationObserverData> m_mutationObserverData; 297 OwnPtrWillBePersistent<NodeMutationObserverData> m_mutationObserverData;
282 298
283 unsigned m_connectedFrameCount : ConnectedFrameCountBits; 299 unsigned m_connectedFrameCount : ConnectedFrameCountBits;
284 unsigned m_elementFlags : NumberOfElementFlags; 300 unsigned m_elementFlags : NumberOfElementFlags;
285 unsigned m_restyleFlags : NumberOfDynamicRestyleFlags; 301 unsigned m_restyleFlags : NumberOfDynamicRestyleFlags;
286 }; 302 };
287 303
288 inline bool NodeListsNodeData::deleteThisAndUpdateNodeRareDataIfAboutToRemoveLas tList(Node& ownerNode) 304 inline bool NodeListsNodeData::deleteThisAndUpdateNodeRareDataIfAboutToRemoveLas tList(Node& ownerNode)
289 { 305 {
290 ASSERT(ownerNode.nodeLists() == this); 306 ASSERT(ownerNode.nodeLists() == this);
291 if ((m_childNodeList ? 1 : 0) + m_atomicNameCaches.size() + m_tagCollectionC acheNS.size() != 1) 307 if ((m_childNodeList ? 1 : 0) + m_atomicNameCaches.size() + m_tagCollectionC acheNS.size() != 1)
292 return false; 308 return false;
293 ownerNode.clearNodeLists(); 309 ownerNode.clearNodeLists();
294 return true; 310 return true;
295 } 311 }
296 312
297 } // namespace WebCore 313 } // namespace WebCore
298 314
299 #endif // NodeRareData_h 315 #endif // NodeRareData_h
OLDNEW
« no previous file with comments | « Source/core/dom/Node.cpp ('k') | Source/core/dom/NodeRareData.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698