| 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 * Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008, 2011, 2012 Apple Inc. All r
ights reserved. | 4 * Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008, 2011, 2012 Apple Inc. All r
ights reserved. |
| 5 * Copyright (C) 2014 Samsung Electronics. All rights reserved. | 5 * Copyright (C) 2014 Samsung Electronics. 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 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 58 bool hasExactlyOneItem() const { return m_collectionItemsCache.hasExactlyOne
Node(*this); } | 58 bool hasExactlyOneItem() const { return m_collectionItemsCache.hasExactlyOne
Node(*this); } |
| 59 bool elementMatches(const Element&) const; | 59 bool elementMatches(const Element&) const; |
| 60 | 60 |
| 61 // CollectionIndexCache API. | 61 // CollectionIndexCache API. |
| 62 bool canTraverseBackward() const { return !overridesItemAfter(); } | 62 bool canTraverseBackward() const { return !overridesItemAfter(); } |
| 63 Element* traverseToFirst() const; | 63 Element* traverseToFirst() const; |
| 64 Element* traverseToLast() const; | 64 Element* traverseToLast() const; |
| 65 Element* traverseForwardToOffset(unsigned offset, Element& currentElement, u
nsigned& currentOffset) const; | 65 Element* traverseForwardToOffset(unsigned offset, Element& currentElement, u
nsigned& currentOffset) const; |
| 66 Element* traverseBackwardToOffset(unsigned offset, Element& currentElement,
unsigned& currentOffset) const; | 66 Element* traverseBackwardToOffset(unsigned offset, Element& currentElement,
unsigned& currentOffset) const; |
| 67 | 67 |
| 68 virtual void trace(Visitor*); | 68 DECLARE_VIRTUAL_TRACE(); |
| 69 | 69 |
| 70 protected: | 70 protected: |
| 71 HTMLCollection(ContainerNode& base, CollectionType, ItemAfterOverrideType); | 71 HTMLCollection(ContainerNode& base, CollectionType, ItemAfterOverrideType); |
| 72 | 72 |
| 73 class NamedItemCache final : public NoBaseWillBeGarbageCollected<NamedItemCa
che> { | 73 class NamedItemCache final : public NoBaseWillBeGarbageCollected<NamedItemCa
che> { |
| 74 public: | 74 public: |
| 75 static PassOwnPtrWillBeRawPtr<NamedItemCache> create() | 75 static PassOwnPtrWillBeRawPtr<NamedItemCache> create() |
| 76 { | 76 { |
| 77 return adoptPtrWillBeNoop(new NamedItemCache); | 77 return adoptPtrWillBeNoop(new NamedItemCache); |
| 78 } | 78 } |
| 79 | 79 |
| 80 WillBeHeapVector<RawPtrWillBeMember<Element>>* getElementsById(const Ato
micString& id) const { return m_idCache.get(id.impl()); } | 80 WillBeHeapVector<RawPtrWillBeMember<Element>>* getElementsById(const Ato
micString& id) const { return m_idCache.get(id.impl()); } |
| 81 WillBeHeapVector<RawPtrWillBeMember<Element>>* getElementsByName(const A
tomicString& name) const { return m_nameCache.get(name.impl()); } | 81 WillBeHeapVector<RawPtrWillBeMember<Element>>* getElementsByName(const A
tomicString& name) const { return m_nameCache.get(name.impl()); } |
| 82 void addElementWithId(const AtomicString& id, Element* element) { addEle
mentToMap(m_idCache, id, element); } | 82 void addElementWithId(const AtomicString& id, Element* element) { addEle
mentToMap(m_idCache, id, element); } |
| 83 void addElementWithName(const AtomicString& name, Element* element) { ad
dElementToMap(m_nameCache, name, element); } | 83 void addElementWithName(const AtomicString& name, Element* element) { ad
dElementToMap(m_nameCache, name, element); } |
| 84 | 84 |
| 85 void trace(Visitor* visitor) | 85 DEFINE_INLINE_TRACE() |
| 86 { | 86 { |
| 87 #if ENABLE(OILPAN) | 87 #if ENABLE(OILPAN) |
| 88 visitor->trace(m_idCache); | 88 visitor->trace(m_idCache); |
| 89 visitor->trace(m_nameCache); | 89 visitor->trace(m_nameCache); |
| 90 #endif | 90 #endif |
| 91 } | 91 } |
| 92 | 92 |
| 93 private: | 93 private: |
| 94 NamedItemCache(); | 94 NamedItemCache(); |
| 95 typedef WillBeHeapHashMap<StringImpl*, OwnPtrWillBeMember<WillBeHeapVect
or<RawPtrWillBeMember<Element>>>> StringToElementsMap; | 95 typedef WillBeHeapHashMap<StringImpl*, OwnPtrWillBeMember<WillBeHeapVect
or<RawPtrWillBeMember<Element>>>> StringToElementsMap; |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 158 { | 158 { |
| 159 if (!attrName || shouldInvalidateTypeOnAttributeChange(invalidationType(), *
attrName)) | 159 if (!attrName || shouldInvalidateTypeOnAttributeChange(invalidationType(), *
attrName)) |
| 160 invalidateCache(); | 160 invalidateCache(); |
| 161 else if (*attrName == HTMLNames::idAttr || *attrName == HTMLNames::nameAttr) | 161 else if (*attrName == HTMLNames::idAttr || *attrName == HTMLNames::nameAttr) |
| 162 invalidateIdNameCacheMaps(); | 162 invalidateIdNameCacheMaps(); |
| 163 } | 163 } |
| 164 | 164 |
| 165 } // namespace blink | 165 } // namespace blink |
| 166 | 166 |
| 167 #endif // HTMLCollection_h | 167 #endif // HTMLCollection_h |
| OLD | NEW |