| 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 * | 6 * |
| 7 * This library is free software; you can redistribute it and/or | 7 * This library is free software; you can redistribute it and/or |
| 8 * modify it under the terms of the GNU Library General Public | 8 * modify it under the terms of the GNU Library General Public |
| 9 * License as published by the Free Software Foundation; either | 9 * License as published by the Free Software Foundation; either |
| 10 * version 2 of the License, or (at your option) any later version. | 10 * version 2 of the License, or (at your option) any later version. |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 59 document().registerNodeList(this); | 59 document().registerNodeList(this); |
| 60 } | 60 } |
| 61 | 61 |
| 62 virtual ~LiveNodeListBase() | 62 virtual ~LiveNodeListBase() |
| 63 { | 63 { |
| 64 document().unregisterNodeList(this); | 64 document().unregisterNodeList(this); |
| 65 } | 65 } |
| 66 | 66 |
| 67 ContainerNode& rootNode() const; | 67 ContainerNode& rootNode() const; |
| 68 | 68 |
| 69 void didMoveToDocument(Document& oldDocument, Document& newDocument); |
| 69 ALWAYS_INLINE bool hasIdNameCache() const { return !isLiveNodeListType(type(
)); } | 70 ALWAYS_INLINE bool hasIdNameCache() const { return !isLiveNodeListType(type(
)); } |
| 70 ALWAYS_INLINE bool isRootedAtDocument() const { return m_rootType == NodeLis
tIsRootedAtDocument || m_rootType == NodeListIsRootedAtDocumentIfOwnerHasItemref
Attr; } | 71 ALWAYS_INLINE bool isRootedAtDocument() const { return m_rootType == NodeLis
tIsRootedAtDocument || m_rootType == NodeListIsRootedAtDocumentIfOwnerHasItemref
Attr; } |
| 71 ALWAYS_INLINE NodeListInvalidationType invalidationType() const { return sta
tic_cast<NodeListInvalidationType>(m_invalidationType); } | 72 ALWAYS_INLINE NodeListInvalidationType invalidationType() const { return sta
tic_cast<NodeListInvalidationType>(m_invalidationType); } |
| 72 ALWAYS_INLINE CollectionType type() const { return static_cast<CollectionTyp
e>(m_collectionType); } | 73 ALWAYS_INLINE CollectionType type() const { return static_cast<CollectionTyp
e>(m_collectionType); } |
| 73 ContainerNode* ownerNode() const { return m_ownerNode.get(); } | 74 ContainerNode* ownerNode() const { return m_ownerNode.get(); } |
| 74 ALWAYS_INLINE void invalidateCache(const QualifiedName* attrName) const | 75 ALWAYS_INLINE void invalidateCache(const QualifiedName* attrName) const |
| 75 { | 76 { |
| 76 if (!attrName || shouldInvalidateTypeOnAttributeChange(invalidationType(
), *attrName)) | 77 if (!attrName || shouldInvalidateTypeOnAttributeChange(invalidationType(
), *attrName)) |
| 77 invalidateCache(); | 78 invalidateCache(); |
| 78 else if (hasIdNameCache() && (*attrName == HTMLNames::idAttr || *attrNam
e == HTMLNames::nameAttr)) | 79 else if (hasIdNameCache() && (*attrName == HTMLNames::idAttr || *attrNam
e == HTMLNames::nameAttr)) |
| 79 invalidateIdNameCacheMaps(); | 80 invalidateIdNameCacheMaps(); |
| 80 } | 81 } |
| 81 virtual void invalidateCache() const = 0; | 82 virtual void invalidateCache(Document* oldDocument = 0) const = 0; |
| 82 | 83 |
| 83 static bool shouldInvalidateTypeOnAttributeChange(NodeListInvalidationType,
const QualifiedName&); | 84 static bool shouldInvalidateTypeOnAttributeChange(NodeListInvalidationType,
const QualifiedName&); |
| 84 | 85 |
| 85 protected: | 86 protected: |
| 86 Document& document() const { return m_ownerNode->document(); } | 87 Document& document() const { return m_ownerNode->document(); } |
| 87 | 88 |
| 88 ALWAYS_INLINE NodeListRootType rootType() const { return static_cast<NodeLis
tRootType>(m_rootType); } | 89 ALWAYS_INLINE NodeListRootType rootType() const { return static_cast<NodeLis
tRootType>(m_rootType); } |
| 89 | 90 |
| 90 template <typename Collection> | 91 template <typename Collection> |
| 91 static Element* iterateForPreviousNode(const Collection&, Node* current); | 92 static Element* iterateForPreviousNode(const Collection&, Node* current); |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 129 public: | 130 public: |
| 130 LiveNodeList(PassRefPtr<ContainerNode> ownerNode, CollectionType collectionT
ype, NodeListInvalidationType invalidationType, NodeListRootType rootType = Node
ListIsRootedAtNode) | 131 LiveNodeList(PassRefPtr<ContainerNode> ownerNode, CollectionType collectionT
ype, NodeListInvalidationType invalidationType, NodeListRootType rootType = Node
ListIsRootedAtNode) |
| 131 : LiveNodeListBase(ownerNode.get(), rootType, invalidationType, | 132 : LiveNodeListBase(ownerNode.get(), rootType, invalidationType, |
| 132 collectionType) | 133 collectionType) |
| 133 { } | 134 { } |
| 134 | 135 |
| 135 virtual unsigned length() const OVERRIDE FINAL { return m_collectionIndexCac
he.nodeCount(*this); } | 136 virtual unsigned length() const OVERRIDE FINAL { return m_collectionIndexCac
he.nodeCount(*this); } |
| 136 virtual Node* item(unsigned offset) const OVERRIDE FINAL { return m_collecti
onIndexCache.nodeAt(*this, offset); } | 137 virtual Node* item(unsigned offset) const OVERRIDE FINAL { return m_collecti
onIndexCache.nodeAt(*this, offset); } |
| 137 virtual bool nodeMatches(const Element&) const = 0; | 138 virtual bool nodeMatches(const Element&) const = 0; |
| 138 | 139 |
| 139 virtual void invalidateCache() const OVERRIDE FINAL; | 140 virtual void invalidateCache(Document* oldDocument) const OVERRIDE FINAL; |
| 140 bool shouldOnlyIncludeDirectChildren() const { return false; } | 141 bool shouldOnlyIncludeDirectChildren() const { return false; } |
| 141 | 142 |
| 142 // Collection IndexCache API. | 143 // Collection IndexCache API. |
| 143 bool canTraverseBackward() const { return true; } | 144 bool canTraverseBackward() const { return true; } |
| 144 Element* itemBefore(const Element* previousItem) const; | 145 Element* itemBefore(const Element* previousItem) const; |
| 145 Element* traverseToFirstElement(const ContainerNode& root) const; | 146 Element* traverseToFirstElement(const ContainerNode& root) const; |
| 146 Element* traverseForwardToOffset(unsigned offset, Element& currentNode, unsi
gned& currentOffset, const ContainerNode& root) const; | 147 Element* traverseForwardToOffset(unsigned offset, Element& currentNode, unsi
gned& currentOffset, const ContainerNode& root) const; |
| 147 | 148 |
| 148 private: | 149 private: |
| 149 virtual Node* virtualOwnerNode() const OVERRIDE FINAL; | 150 virtual Node* virtualOwnerNode() const OVERRIDE FINAL; |
| 150 | 151 |
| 151 mutable CollectionIndexCache<LiveNodeList, Element> m_collectionIndexCache; | 152 mutable CollectionIndexCache<LiveNodeList, Element> m_collectionIndexCache; |
| 152 }; | 153 }; |
| 153 | 154 |
| 154 } // namespace WebCore | 155 } // namespace WebCore |
| 155 | 156 |
| 156 #endif // LiveNodeList_h | 157 #endif // LiveNodeList_h |
| OLD | NEW |