OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org) | 2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org) |
3 * (C) 1999 Antti Koivisto (koivisto@kde.org) | 3 * (C) 1999 Antti Koivisto (koivisto@kde.org) |
4 * (C) 2001 Dirk Mueller (mueller@kde.org) | 4 * (C) 2001 Dirk Mueller (mueller@kde.org) |
5 * Copyright (C) 2004, 2006, 2007 Apple Inc. All rights reserved. | 5 * Copyright (C) 2004, 2006, 2007 Apple Inc. All rights reserved. |
6 * Copyright (C) 2014 Samsung Electronics. All rights reserved. | 6 * Copyright (C) 2014 Samsung Electronics. All rights reserved. |
7 * | 7 * |
8 * This library is free software; you can redistribute it and/or | 8 * This library is free software; you can redistribute it and/or |
9 * modify it under the terms of the GNU Library General Public | 9 * modify it under the terms of the GNU Library General Public |
10 * License as published by the Free Software Foundation; either | 10 * License as published by the Free Software Foundation; either |
(...skipping 13 matching lines...) Expand all Loading... |
24 | 24 |
25 #ifndef LiveNodeListBase_h | 25 #ifndef LiveNodeListBase_h |
26 #define LiveNodeListBase_h | 26 #define LiveNodeListBase_h |
27 | 27 |
28 #include "HTMLNames.h" | 28 #include "HTMLNames.h" |
29 #include "core/dom/Document.h" | 29 #include "core/dom/Document.h" |
30 #include "core/dom/Element.h" | 30 #include "core/dom/Element.h" |
31 #include "core/dom/ElementTraversal.h" | 31 #include "core/dom/ElementTraversal.h" |
32 #include "core/dom/NodeTraversal.h" | 32 #include "core/dom/NodeTraversal.h" |
33 #include "core/html/CollectionType.h" | 33 #include "core/html/CollectionType.h" |
| 34 #include "platform/heap/Handle.h" |
34 | 35 |
35 namespace WebCore { | 36 namespace WebCore { |
36 | 37 |
37 enum NodeListRootType { | 38 enum NodeListRootType { |
38 NodeListIsRootedAtNode, | 39 NodeListIsRootedAtNode, |
39 NodeListIsRootedAtDocument | 40 NodeListIsRootedAtDocument |
40 }; | 41 }; |
41 | 42 |
42 class LiveNodeListBase { | 43 class LiveNodeListBase : public WillBeGarbageCollectedMixin { |
43 public: | 44 public: |
44 LiveNodeListBase(ContainerNode& ownerNode, NodeListRootType rootType, NodeLi
stInvalidationType invalidationType, | 45 LiveNodeListBase(ContainerNode& ownerNode, NodeListRootType rootType, NodeLi
stInvalidationType invalidationType, |
45 CollectionType collectionType) | 46 CollectionType collectionType) |
46 : m_ownerNode(ownerNode) | 47 : m_ownerNode(ownerNode) |
47 , m_rootType(rootType) | 48 , m_rootType(rootType) |
48 , m_invalidationType(invalidationType) | 49 , m_invalidationType(invalidationType) |
49 , m_collectionType(collectionType) | 50 , m_collectionType(collectionType) |
50 { | 51 { |
51 ASSERT(m_rootType == static_cast<unsigned>(rootType)); | 52 ASSERT(m_rootType == static_cast<unsigned>(rootType)); |
52 ASSERT(m_invalidationType == static_cast<unsigned>(invalidationType)); | 53 ASSERT(m_invalidationType == static_cast<unsigned>(invalidationType)); |
53 ASSERT(m_collectionType == static_cast<unsigned>(collectionType)); | 54 ASSERT(m_collectionType == static_cast<unsigned>(collectionType)); |
54 | 55 |
55 document().registerNodeList(this); | 56 document().registerNodeList(this); |
56 } | 57 } |
57 | 58 |
58 virtual ~LiveNodeListBase() | 59 virtual ~LiveNodeListBase() |
59 { | 60 { |
| 61 #if !ENABLE(OILPAN) |
60 document().unregisterNodeList(this); | 62 document().unregisterNodeList(this); |
| 63 #endif |
61 } | 64 } |
62 | 65 |
63 ContainerNode& rootNode() const; | 66 ContainerNode& rootNode() const; |
64 | 67 |
65 void didMoveToDocument(Document& oldDocument, Document& newDocument); | 68 void didMoveToDocument(Document& oldDocument, Document& newDocument); |
66 ALWAYS_INLINE bool isRootedAtDocument() const { return m_rootType == NodeLis
tIsRootedAtDocument; } | 69 ALWAYS_INLINE bool isRootedAtDocument() const { return m_rootType == NodeLis
tIsRootedAtDocument; } |
67 ALWAYS_INLINE NodeListInvalidationType invalidationType() const { return sta
tic_cast<NodeListInvalidationType>(m_invalidationType); } | 70 ALWAYS_INLINE NodeListInvalidationType invalidationType() const { return sta
tic_cast<NodeListInvalidationType>(m_invalidationType); } |
68 ALWAYS_INLINE CollectionType type() const { return static_cast<CollectionTyp
e>(m_collectionType); } | 71 ALWAYS_INLINE CollectionType type() const { return static_cast<CollectionTyp
e>(m_collectionType); } |
69 ContainerNode& ownerNode() const { return *m_ownerNode; } | 72 ContainerNode& ownerNode() const { return *m_ownerNode; } |
70 | 73 |
(...skipping 13 matching lines...) Expand all Loading... |
84 static Element* lastMatchingElement(const NodeListType&); | 87 static Element* lastMatchingElement(const NodeListType&); |
85 template <class NodeListType> | 88 template <class NodeListType> |
86 static Element* nextMatchingElement(const NodeListType&, Element& current); | 89 static Element* nextMatchingElement(const NodeListType&, Element& current); |
87 template <class NodeListType> | 90 template <class NodeListType> |
88 static Element* previousMatchingElement(const NodeListType&, Element& curren
t); | 91 static Element* previousMatchingElement(const NodeListType&, Element& curren
t); |
89 template <class NodeListType> | 92 template <class NodeListType> |
90 static Element* traverseMatchingElementsForwardToOffset(const NodeListType&,
unsigned offset, Element& currentElement, unsigned& currentOffset); | 93 static Element* traverseMatchingElementsForwardToOffset(const NodeListType&,
unsigned offset, Element& currentElement, unsigned& currentOffset); |
91 template <class NodeListType> | 94 template <class NodeListType> |
92 static Element* traverseMatchingElementsBackwardToOffset(const NodeListType&
, unsigned offset, Element& currentElement, unsigned& currentOffset); | 95 static Element* traverseMatchingElementsBackwardToOffset(const NodeListType&
, unsigned offset, Element& currentElement, unsigned& currentOffset); |
93 | 96 |
| 97 void trace(Visitor* visitor) { visitor->trace(m_ownerNode); } |
| 98 |
94 private: | 99 private: |
95 RefPtr<ContainerNode> m_ownerNode; // Cannot be null. | 100 RefPtrWillBeMember<ContainerNode> m_ownerNode; // Cannot be null. |
96 const unsigned m_rootType : 1; | 101 const unsigned m_rootType : 1; |
97 const unsigned m_invalidationType : 4; | 102 const unsigned m_invalidationType : 4; |
98 const unsigned m_collectionType : 5; | 103 const unsigned m_collectionType : 5; |
99 }; | 104 }; |
100 | 105 |
101 ALWAYS_INLINE bool LiveNodeListBase::shouldInvalidateTypeOnAttributeChange(NodeL
istInvalidationType type, const QualifiedName& attrName) | 106 ALWAYS_INLINE bool LiveNodeListBase::shouldInvalidateTypeOnAttributeChange(NodeL
istInvalidationType type, const QualifiedName& attrName) |
102 { | 107 { |
103 switch (type) { | 108 switch (type) { |
104 case InvalidateOnClassAttrChange: | 109 case InvalidateOnClassAttrChange: |
105 return attrName == HTMLNames::classAttr; | 110 return attrName == HTMLNames::classAttr; |
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
184 while ((previous = previousMatchingElement(nodeList, *previous))) { | 189 while ((previous = previousMatchingElement(nodeList, *previous))) { |
185 if (--currentOffset == offset) | 190 if (--currentOffset == offset) |
186 return previous; | 191 return previous; |
187 } | 192 } |
188 return 0; | 193 return 0; |
189 } | 194 } |
190 | 195 |
191 } // namespace WebCore | 196 } // namespace WebCore |
192 | 197 |
193 #endif // LiveNodeListBase_h | 198 #endif // LiveNodeListBase_h |
OLD | NEW |