| OLD | NEW |
| 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, |
| 11 * but WITHOUT ANY WARRANTY; without even the implied warranty of | 11 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 13 * Library General Public License for more details. | 13 * Library General Public License for more details. |
| 14 * | 14 * |
| 15 * You should have received a copy of the GNU Library General Public License | 15 * You should have received a copy of the GNU Library General Public License |
| 16 * along with this library; see the file COPYING.LIB. If not, write to | 16 * along with this library; see the file COPYING.LIB. If not, write to |
| 17 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, | 17 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, |
| 18 * Boston, MA 02110-1301, USA. | 18 * Boston, MA 02110-1301, USA. |
| 19 * | 19 * |
| 20 */ | 20 */ |
| 21 | 21 |
| 22 #ifndef NodeRareData_h | 22 #ifndef NodeListsNodeData_h |
| 23 #define NodeRareData_h | 23 #define NodeListsNodeData_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" | |
| 28 #include "core/dom/MutationObserverRegistration.h" | |
| 29 #include "core/dom/QualifiedName.h" | 27 #include "core/dom/QualifiedName.h" |
| 30 #include "core/dom/TagCollection.h" | 28 #include "core/dom/TagCollection.h" |
| 29 #include "core/html/CollectionType.h" |
| 31 #include "platform/heap/Handle.h" | 30 #include "platform/heap/Handle.h" |
| 32 #include "wtf/HashSet.h" | |
| 33 #include "wtf/OwnPtr.h" | |
| 34 #include "wtf/PassOwnPtr.h" | |
| 35 #include "wtf/text/AtomicString.h" | 31 #include "wtf/text/AtomicString.h" |
| 36 #include "wtf/text/StringHash.h" | 32 #include "wtf/text/StringHash.h" |
| 37 | 33 |
| 38 namespace WebCore { | 34 namespace WebCore { |
| 39 | 35 |
| 40 class NodeListsNodeData FINAL : public NoBaseWillBeGarbageCollectedFinalized<Nod
eListsNodeData> { | 36 class NodeListsNodeData FINAL : public NoBaseWillBeGarbageCollectedFinalized<Nod
eListsNodeData> { |
| 41 WTF_MAKE_NONCOPYABLE(NodeListsNodeData); | 37 WTF_MAKE_NONCOPYABLE(NodeListsNodeData); |
| 42 WTF_MAKE_FAST_ALLOCATED_WILL_BE_REMOVED; | 38 WTF_MAKE_FAST_ALLOCATED_WILL_BE_REMOVED; |
| 43 public: | 39 public: |
| 44 void clearChildNodeListCache() | 40 void clearChildNodeListCache() |
| (...skipping 177 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 222 #if !ENABLE(OILPAN) | 218 #if !ENABLE(OILPAN) |
| 223 bool deleteThisAndUpdateNodeRareDataIfAboutToRemoveLastList(Node&); | 219 bool deleteThisAndUpdateNodeRareDataIfAboutToRemoveLastList(Node&); |
| 224 #endif | 220 #endif |
| 225 | 221 |
| 226 // Can be a ChildNodeList or an EmptyNodeList. | 222 // Can be a ChildNodeList or an EmptyNodeList. |
| 227 RawPtrWillBeWeakMember<NodeList> m_childNodeList; | 223 RawPtrWillBeWeakMember<NodeList> m_childNodeList; |
| 228 NodeListAtomicNameCacheMap m_atomicNameCaches; | 224 NodeListAtomicNameCacheMap m_atomicNameCaches; |
| 229 TagCollectionCacheNS m_tagCollectionCacheNS; | 225 TagCollectionCacheNS m_tagCollectionCacheNS; |
| 230 }; | 226 }; |
| 231 | 227 |
| 232 class NodeMutationObserverData FINAL : public NoBaseWillBeGarbageCollected<NodeM
utationObserverData> { | |
| 233 WTF_MAKE_NONCOPYABLE(NodeMutationObserverData); | |
| 234 WTF_MAKE_FAST_ALLOCATED_WILL_BE_REMOVED; | |
| 235 public: | |
| 236 WillBeHeapVector<OwnPtrWillBeMember<MutationObserverRegistration> > registry
; | |
| 237 WillBeHeapHashSet<RawPtrWillBeMember<MutationObserverRegistration> > transie
ntRegistry; | |
| 238 | |
| 239 static PassOwnPtrWillBeRawPtr<NodeMutationObserverData> create() | |
| 240 { | |
| 241 return adoptPtrWillBeNoop(new NodeMutationObserverData); | |
| 242 } | |
| 243 | |
| 244 void trace(Visitor* visitor) | |
| 245 { | |
| 246 visitor->trace(registry); | |
| 247 visitor->trace(transientRegistry); | |
| 248 } | |
| 249 | |
| 250 private: | |
| 251 NodeMutationObserverData() { } | |
| 252 }; | |
| 253 | |
| 254 class NodeRareData : public NoBaseWillBeGarbageCollectedFinalized<NodeRareData>,
public NodeRareDataBase { | |
| 255 WTF_MAKE_NONCOPYABLE(NodeRareData); | |
| 256 WTF_MAKE_FAST_ALLOCATED_WILL_BE_REMOVED; | |
| 257 public: | |
| 258 static NodeRareData* create(RenderObject* renderer) | |
| 259 { | |
| 260 return new NodeRareData(renderer); | |
| 261 } | |
| 262 | |
| 263 void clearNodeLists() { m_nodeLists.clear(); } | |
| 264 NodeListsNodeData* nodeLists() const { return m_nodeLists.get(); } | |
| 265 NodeListsNodeData& ensureNodeLists() | |
| 266 { | |
| 267 if (!m_nodeLists) | |
| 268 m_nodeLists = NodeListsNodeData::create(); | |
| 269 return *m_nodeLists; | |
| 270 } | |
| 271 | |
| 272 NodeMutationObserverData* mutationObserverData() { return m_mutationObserver
Data.get(); } | |
| 273 NodeMutationObserverData& ensureMutationObserverData() | |
| 274 { | |
| 275 if (!m_mutationObserverData) | |
| 276 m_mutationObserverData = NodeMutationObserverData::create(); | |
| 277 return *m_mutationObserverData; | |
| 278 } | |
| 279 | |
| 280 unsigned connectedSubframeCount() const { return m_connectedFrameCount; } | |
| 281 void incrementConnectedSubframeCount(unsigned amount) | |
| 282 { | |
| 283 m_connectedFrameCount += amount; | |
| 284 } | |
| 285 void decrementConnectedSubframeCount(unsigned amount) | |
| 286 { | |
| 287 ASSERT(m_connectedFrameCount); | |
| 288 ASSERT(amount <= m_connectedFrameCount); | |
| 289 m_connectedFrameCount -= amount; | |
| 290 } | |
| 291 | |
| 292 bool hasElementFlag(ElementFlags mask) const { return m_elementFlags & mask;
} | |
| 293 void setElementFlag(ElementFlags mask, bool value) { m_elementFlags = (m_ele
mentFlags & ~mask) | (-(int32_t)value & mask); } | |
| 294 void clearElementFlag(ElementFlags mask) { m_elementFlags &= ~mask; } | |
| 295 | |
| 296 bool hasRestyleFlag(DynamicRestyleFlags mask) const { return m_restyleFlags
& mask; } | |
| 297 void setRestyleFlag(DynamicRestyleFlags mask) { m_restyleFlags |= mask; RELE
ASE_ASSERT(m_restyleFlags); } | |
| 298 bool hasRestyleFlags() const { return m_restyleFlags; } | |
| 299 void clearRestyleFlags() { m_restyleFlags = 0; } | |
| 300 | |
| 301 enum { | |
| 302 ConnectedFrameCountBits = 10, // Must fit Page::maxNumberOfFrames. | |
| 303 }; | |
| 304 | |
| 305 void trace(Visitor*); | |
| 306 | |
| 307 void traceAfterDispatch(Visitor*); | |
| 308 void finalizeGarbageCollectedObject(); | |
| 309 | |
| 310 protected: | |
| 311 explicit NodeRareData(RenderObject* renderer) | |
| 312 : NodeRareDataBase(renderer) | |
| 313 , m_connectedFrameCount(0) | |
| 314 , m_elementFlags(0) | |
| 315 , m_restyleFlags(0) | |
| 316 , m_isElementRareData(false) | |
| 317 { } | |
| 318 | |
| 319 private: | |
| 320 OwnPtrWillBeMember<NodeListsNodeData> m_nodeLists; | |
| 321 OwnPtrWillBeMember<NodeMutationObserverData> m_mutationObserverData; | |
| 322 | |
| 323 unsigned m_connectedFrameCount : ConnectedFrameCountBits; | |
| 324 unsigned m_elementFlags : NumberOfElementFlags; | |
| 325 unsigned m_restyleFlags : NumberOfDynamicRestyleFlags; | |
| 326 protected: | |
| 327 unsigned m_isElementRareData : 1; | |
| 328 }; | |
| 329 | |
| 330 #if !ENABLE(OILPAN) | 228 #if !ENABLE(OILPAN) |
| 331 inline bool NodeListsNodeData::deleteThisAndUpdateNodeRareDataIfAboutToRemoveLas
tList(Node& ownerNode) | 229 inline bool NodeListsNodeData::deleteThisAndUpdateNodeRareDataIfAboutToRemoveLas
tList(Node& ownerNode) |
| 332 { | 230 { |
| 333 ASSERT(ownerNode.nodeLists() == this); | 231 ASSERT(ownerNode.nodeLists() == this); |
| 334 if ((m_childNodeList ? 1 : 0) + m_atomicNameCaches.size() + m_tagCollectionC
acheNS.size() != 1) | 232 if ((m_childNodeList ? 1 : 0) + m_atomicNameCaches.size() + m_tagCollectionC
acheNS.size() != 1) |
| 335 return false; | 233 return false; |
| 336 ownerNode.clearNodeLists(); | 234 ownerNode.clearNodeLists(); |
| 337 return true; | 235 return true; |
| 338 } | 236 } |
| 339 #endif | 237 #endif |
| 340 | 238 |
| 341 } // namespace WebCore | 239 } // namespace WebCore |
| 342 | 240 |
| 343 #endif // NodeRareData_h | 241 #endif // NodeListsNodeData_h |
| OLD | NEW |