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 * | 6 * |
6 * This library is free software; you can redistribute it and/or | 7 * This library is free software; you can redistribute it and/or |
7 * modify it under the terms of the GNU Library General Public | 8 * modify it under the terms of the GNU Library General Public |
8 * License as published by the Free Software Foundation; either | 9 * License as published by the Free Software Foundation; either |
9 * 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. |
10 * | 11 * |
11 * This library is distributed in the hope that it will be useful, | 12 * This library is distributed in the hope that it will be useful, |
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of | 13 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
14 * Library General Public License for more details. | 15 * Library General Public License for more details. |
(...skipping 24 matching lines...) Expand all Loading... |
39 }; | 40 }; |
40 | 41 |
41 static PassRefPtr<HTMLCollection> create(ContainerNode* base, CollectionType
); | 42 static PassRefPtr<HTMLCollection> create(ContainerNode* base, CollectionType
); |
42 virtual ~HTMLCollection(); | 43 virtual ~HTMLCollection(); |
43 virtual void invalidateCache() const OVERRIDE; | 44 virtual void invalidateCache() const OVERRIDE; |
44 | 45 |
45 // DOM API | 46 // DOM API |
46 unsigned length() const { return m_collectionIndexCache.nodeCount(*this); } | 47 unsigned length() const { return m_collectionIndexCache.nodeCount(*this); } |
47 Element* item(unsigned offset) const { return m_collectionIndexCache.nodeAt(
*this, offset); } | 48 Element* item(unsigned offset) const { return m_collectionIndexCache.nodeAt(
*this, offset); } |
48 virtual Element* namedItem(const AtomicString& name) const; | 49 virtual Element* namedItem(const AtomicString& name) const; |
| 50 bool namedPropertyQuery(const AtomicString&, ExceptionState&); |
| 51 void namedPropertyEnumerator(Vector<String>& names, ExceptionState&); |
49 | 52 |
50 // Non-DOM API | 53 // Non-DOM API |
51 void namedItems(const AtomicString& name, Vector<RefPtr<Element> >&) const; | 54 void namedItems(const AtomicString& name, Vector<RefPtr<Element> >&) const; |
52 bool isEmpty() const { return m_collectionIndexCache.isEmpty(*this); } | 55 bool isEmpty() const { return m_collectionIndexCache.isEmpty(*this); } |
53 bool hasExactlyOneItem() const { return m_collectionIndexCache.hasExactlyOne
Node(*this); } | 56 bool hasExactlyOneItem() const { return m_collectionIndexCache.hasExactlyOne
Node(*this); } |
54 | 57 |
55 // CollectionIndexCache API. | 58 // CollectionIndexCache API. |
56 bool canTraverseBackward() const { return !overridesItemAfter(); } | 59 bool canTraverseBackward() const { return !overridesItemAfter(); } |
57 Element* itemBefore(const Element* previousItem) const; | 60 Element* itemBefore(const Element* previousItem) const; |
58 Element* traverseToFirstElement(const ContainerNode& root) const; | 61 Element* traverseToFirstElement(const ContainerNode& root) const; |
(...skipping 10 matching lines...) Expand all Loading... |
69 void setHasNameCache() const { m_isNameCacheValid = true; } | 72 void setHasNameCache() const { m_isNameCacheValid = true; } |
70 | 73 |
71 typedef HashMap<StringImpl*, OwnPtr<Vector<Element*> > > NodeCacheMap; | 74 typedef HashMap<StringImpl*, OwnPtr<Vector<Element*> > > NodeCacheMap; |
72 Vector<Element*>* idCache(const AtomicString& name) const { return m_idCache
.get(name.impl()); } | 75 Vector<Element*>* idCache(const AtomicString& name) const { return m_idCache
.get(name.impl()); } |
73 Vector<Element*>* nameCache(const AtomicString& name) const { return m_nameC
ache.get(name.impl()); } | 76 Vector<Element*>* nameCache(const AtomicString& name) const { return m_nameC
ache.get(name.impl()); } |
74 void appendIdCache(const AtomicString& name, Element* element) const { appen
d(m_idCache, name, element); } | 77 void appendIdCache(const AtomicString& name, Element* element) const { appen
d(m_idCache, name, element); } |
75 void appendNameCache(const AtomicString& name, Element* element) const { app
end(m_nameCache, name, element); } | 78 void appendNameCache(const AtomicString& name, Element* element) const { app
end(m_nameCache, name, element); } |
76 | 79 |
77 private: | 80 private: |
78 Element* traverseNextElement(Element& previous, const ContainerNode& root) c
onst; | 81 Element* traverseNextElement(Element& previous, const ContainerNode& root) c
onst; |
| 82 virtual void supportedPropertyNames(Vector<String>& names); |
79 | 83 |
80 static void append(NodeCacheMap&, const AtomicString&, Element*); | 84 static void append(NodeCacheMap&, const AtomicString&, Element*); |
81 void invalidateIdNameCacheMaps() const | 85 void invalidateIdNameCacheMaps() const |
82 { | 86 { |
83 m_idCache.clear(); | 87 m_idCache.clear(); |
84 m_nameCache.clear(); | 88 m_nameCache.clear(); |
85 m_isNameCacheValid = false; | 89 m_isNameCacheValid = false; |
86 } | 90 } |
87 | 91 |
88 const unsigned m_overridesItemAfter : 1; | 92 const unsigned m_overridesItemAfter : 1; |
89 mutable unsigned m_isNameCacheValid : 1; | 93 mutable unsigned m_isNameCacheValid : 1; |
90 mutable NodeCacheMap m_idCache; | 94 mutable NodeCacheMap m_idCache; |
91 mutable NodeCacheMap m_nameCache; | 95 mutable NodeCacheMap m_nameCache; |
92 mutable CollectionIndexCache<HTMLCollection, Element> m_collectionIndexCache
; | 96 mutable CollectionIndexCache<HTMLCollection, Element> m_collectionIndexCache
; |
93 | 97 |
94 friend class LiveNodeListBase; | 98 friend class LiveNodeListBase; |
95 }; | 99 }; |
96 | 100 |
97 } // namespace | 101 } // namespace |
98 | 102 |
99 #endif | 103 #endif |
OLD | NEW |