| 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 24 matching lines...) Expand all Loading... |
| 35 DEFINE_WRAPPERTYPEINFO(); | 35 DEFINE_WRAPPERTYPEINFO(); |
| 36 WILL_BE_USING_GARBAGE_COLLECTED_MIXIN(HTMLCollection); | 36 WILL_BE_USING_GARBAGE_COLLECTED_MIXIN(HTMLCollection); |
| 37 public: | 37 public: |
| 38 enum ItemAfterOverrideType { | 38 enum ItemAfterOverrideType { |
| 39 OverridesItemAfter, | 39 OverridesItemAfter, |
| 40 DoesNotOverrideItemAfter, | 40 DoesNotOverrideItemAfter, |
| 41 }; | 41 }; |
| 42 | 42 |
| 43 static PassRefPtrWillBeRawPtr<HTMLCollection> create(ContainerNode& base, Co
llectionType); | 43 static PassRefPtrWillBeRawPtr<HTMLCollection> create(ContainerNode& base, Co
llectionType); |
| 44 virtual ~HTMLCollection(); | 44 virtual ~HTMLCollection(); |
| 45 virtual void invalidateCache(Document* oldDocument = 0) const OVERRIDE; | 45 virtual void invalidateCache(Document* oldDocument = 0) const override; |
| 46 void invalidateCacheForAttribute(const QualifiedName*) const; | 46 void invalidateCacheForAttribute(const QualifiedName*) const; |
| 47 | 47 |
| 48 // DOM API | 48 // DOM API |
| 49 unsigned length() const; | 49 unsigned length() const; |
| 50 Element* item(unsigned offset) const; | 50 Element* item(unsigned offset) const; |
| 51 virtual Element* namedItem(const AtomicString& name) const; | 51 virtual Element* namedItem(const AtomicString& name) const; |
| 52 bool namedPropertyQuery(const AtomicString&, ExceptionState&); | 52 bool namedPropertyQuery(const AtomicString&, ExceptionState&); |
| 53 void namedPropertyEnumerator(Vector<String>& names, ExceptionState&); | 53 void namedPropertyEnumerator(Vector<String>& names, ExceptionState&); |
| 54 | 54 |
| 55 // Non-DOM API | 55 // Non-DOM API |
| 56 void namedItems(const AtomicString& name, WillBeHeapVector<RefPtrWillBeMembe
r<Element> >&) const; | 56 void namedItems(const AtomicString& name, WillBeHeapVector<RefPtrWillBeMembe
r<Element> >&) const; |
| 57 bool isEmpty() const { return m_collectionItemsCache.isEmpty(*this); } | 57 bool isEmpty() const { return m_collectionItemsCache.isEmpty(*this); } |
| 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 virtual void trace(Visitor*); |
| 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 At
omicString& id) const { return m_idCache.get(id.impl()); } | 80 WillBeHeapVector<RawPtrWillBeMember<Element> >* getElementsById(const At
omicString& id) const { return m_idCache.get(id.impl()); } |
| 81 WillBeHeapVector<RawPtrWillBeMember<Element> >* getElementsByName(const
AtomicString& name) const { return m_nameCache.get(name.impl()); } | 81 WillBeHeapVector<RawPtrWillBeMember<Element> >* getElementsByName(const
AtomicString& 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); } |
| (...skipping 74 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 |