| 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 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 56 } | 56 } |
| 57 | 57 |
| 58 virtual ~LiveNodeListBase() | 58 virtual ~LiveNodeListBase() |
| 59 { | 59 { |
| 60 document().unregisterNodeList(this); | 60 document().unregisterNodeList(this); |
| 61 } | 61 } |
| 62 | 62 |
| 63 ContainerNode& rootNode() const; | 63 ContainerNode& rootNode() const; |
| 64 | 64 |
| 65 void didMoveToDocument(Document& oldDocument, Document& newDocument); | 65 void didMoveToDocument(Document& oldDocument, Document& newDocument); |
| 66 ALWAYS_INLINE bool hasIdNameCache() const { return !isLiveNodeListType(type(
)); } | |
| 67 ALWAYS_INLINE bool isRootedAtDocument() const { return m_rootType == NodeLis
tIsRootedAtDocument; } | 66 ALWAYS_INLINE bool isRootedAtDocument() const { return m_rootType == NodeLis
tIsRootedAtDocument; } |
| 68 ALWAYS_INLINE NodeListInvalidationType invalidationType() const { return sta
tic_cast<NodeListInvalidationType>(m_invalidationType); } | 67 ALWAYS_INLINE NodeListInvalidationType invalidationType() const { return sta
tic_cast<NodeListInvalidationType>(m_invalidationType); } |
| 69 ALWAYS_INLINE CollectionType type() const { return static_cast<CollectionTyp
e>(m_collectionType); } | 68 ALWAYS_INLINE CollectionType type() const { return static_cast<CollectionTyp
e>(m_collectionType); } |
| 70 ContainerNode& ownerNode() const { return *m_ownerNode; } | 69 ContainerNode& ownerNode() const { return *m_ownerNode; } |
| 71 ALWAYS_INLINE void invalidateCache(const QualifiedName* attrName) const | 70 |
| 72 { | |
| 73 if (!attrName || shouldInvalidateTypeOnAttributeChange(invalidationType(
), *attrName)) | |
| 74 invalidateCache(); | |
| 75 else if (hasIdNameCache() && (*attrName == HTMLNames::idAttr || *attrNam
e == HTMLNames::nameAttr)) | |
| 76 invalidateIdNameCacheMaps(); | |
| 77 } | |
| 78 virtual void invalidateCache(Document* oldDocument = 0) const = 0; | 71 virtual void invalidateCache(Document* oldDocument = 0) const = 0; |
| 72 void invalidateCacheForAttribute(const QualifiedName*) const; |
| 79 | 73 |
| 80 static bool shouldInvalidateTypeOnAttributeChange(NodeListInvalidationType,
const QualifiedName&); | 74 static bool shouldInvalidateTypeOnAttributeChange(NodeListInvalidationType,
const QualifiedName&); |
| 81 | 75 |
| 82 protected: | 76 protected: |
| 83 Document& document() const { return m_ownerNode->document(); } | 77 Document& document() const { return m_ownerNode->document(); } |
| 84 | 78 |
| 85 ALWAYS_INLINE NodeListRootType rootType() const { return static_cast<NodeLis
tRootType>(m_rootType); } | 79 ALWAYS_INLINE NodeListRootType rootType() const { return static_cast<NodeLis
tRootType>(m_rootType); } |
| 86 | 80 |
| 87 template <class NodeListType> | 81 template <class NodeListType> |
| 88 static Element* firstMatchingElement(const NodeListType&); | 82 static Element* firstMatchingElement(const NodeListType&); |
| 89 template <class NodeListType> | 83 template <class NodeListType> |
| 90 static Element* lastMatchingElement(const NodeListType&); | 84 static Element* lastMatchingElement(const NodeListType&); |
| 91 template <class NodeListType> | 85 template <class NodeListType> |
| 92 static Element* nextMatchingElement(const NodeListType&, Element& current); | 86 static Element* nextMatchingElement(const NodeListType&, Element& current); |
| 93 template <class NodeListType> | 87 template <class NodeListType> |
| 94 static Element* previousMatchingElement(const NodeListType&, Element& curren
t); | 88 static Element* previousMatchingElement(const NodeListType&, Element& curren
t); |
| 95 template <class NodeListType> | 89 template <class NodeListType> |
| 96 static Element* traverseMatchingElementsForwardToOffset(const NodeListType&,
unsigned offset, Element& currentElement, unsigned& currentOffset); | 90 static Element* traverseMatchingElementsForwardToOffset(const NodeListType&,
unsigned offset, Element& currentElement, unsigned& currentOffset); |
| 97 template <class NodeListType> | 91 template <class NodeListType> |
| 98 static Element* traverseMatchingElementsBackwardToOffset(const NodeListType&
, unsigned offset, Element& currentElement, unsigned& currentOffset); | 92 static Element* traverseMatchingElementsBackwardToOffset(const NodeListType&
, unsigned offset, Element& currentElement, unsigned& currentOffset); |
| 99 | 93 |
| 100 private: | 94 private: |
| 101 void invalidateIdNameCacheMaps() const; | |
| 102 | |
| 103 RefPtr<ContainerNode> m_ownerNode; // Cannot be null. | 95 RefPtr<ContainerNode> m_ownerNode; // Cannot be null. |
| 104 const unsigned m_rootType : 1; | 96 const unsigned m_rootType : 1; |
| 105 const unsigned m_invalidationType : 4; | 97 const unsigned m_invalidationType : 4; |
| 106 const unsigned m_collectionType : 5; | 98 const unsigned m_collectionType : 5; |
| 107 }; | 99 }; |
| 108 | 100 |
| 109 ALWAYS_INLINE bool LiveNodeListBase::shouldInvalidateTypeOnAttributeChange(NodeL
istInvalidationType type, const QualifiedName& attrName) | 101 ALWAYS_INLINE bool LiveNodeListBase::shouldInvalidateTypeOnAttributeChange(NodeL
istInvalidationType type, const QualifiedName& attrName) |
| 110 { | 102 { |
| 111 switch (type) { | 103 switch (type) { |
| 112 case InvalidateOnClassAttrChange: | 104 case InvalidateOnClassAttrChange: |
| (...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 192 while ((previous = previousMatchingElement(nodeList, *previous))) { | 184 while ((previous = previousMatchingElement(nodeList, *previous))) { |
| 193 if (--currentOffset == offset) | 185 if (--currentOffset == offset) |
| 194 return previous; | 186 return previous; |
| 195 } | 187 } |
| 196 return 0; | 188 return 0; |
| 197 } | 189 } |
| 198 | 190 |
| 199 } // namespace WebCore | 191 } // namespace WebCore |
| 200 | 192 |
| 201 #endif // LiveNodeListBase_h | 193 #endif // LiveNodeListBase_h |
| OLD | NEW |