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 22 matching lines...) Expand all Loading... |
33 | 33 |
34 namespace WebCore { | 34 namespace WebCore { |
35 | 35 |
36 class HTMLCollection : public ScriptWrappable, public RefCounted<HTMLCollection>
, public LiveNodeListBase { | 36 class HTMLCollection : public ScriptWrappable, public RefCounted<HTMLCollection>
, public LiveNodeListBase { |
37 public: | 37 public: |
38 enum ItemAfterOverrideType { | 38 enum ItemAfterOverrideType { |
39 OverridesItemAfter, | 39 OverridesItemAfter, |
40 DoesNotOverrideItemAfter, | 40 DoesNotOverrideItemAfter, |
41 }; | 41 }; |
42 | 42 |
43 static PassRefPtr<HTMLCollection> create(ContainerNode* base, CollectionType
); | 43 static PassRefPtr<HTMLCollection> create(ContainerNode& base, CollectionType
); |
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 | 46 |
47 // DOM API | 47 // DOM API |
48 unsigned length() const { return m_collectionIndexCache.nodeCount(*this); } | 48 unsigned length() const { return m_collectionIndexCache.nodeCount(*this); } |
49 Element* item(unsigned offset) const { return m_collectionIndexCache.nodeAt(
*this, offset); } | 49 Element* item(unsigned offset) const { return m_collectionIndexCache.nodeAt(
*this, offset); } |
50 virtual Element* namedItem(const AtomicString& name) const; | 50 virtual Element* namedItem(const AtomicString& name) const; |
51 bool namedPropertyQuery(const AtomicString&, ExceptionState&); | 51 bool namedPropertyQuery(const AtomicString&, ExceptionState&); |
52 void namedPropertyEnumerator(Vector<String>& names, ExceptionState&); | 52 void namedPropertyEnumerator(Vector<String>& names, ExceptionState&); |
53 | 53 |
54 // Non-DOM API | 54 // Non-DOM API |
55 void namedItems(const AtomicString& name, Vector<RefPtr<Element> >&) const; | 55 void namedItems(const AtomicString& name, Vector<RefPtr<Element> >&) const; |
56 bool isEmpty() const { return m_collectionIndexCache.isEmpty(*this); } | 56 bool isEmpty() const { return m_collectionIndexCache.isEmpty(*this); } |
57 bool hasExactlyOneItem() const { return m_collectionIndexCache.hasExactlyOne
Node(*this); } | 57 bool hasExactlyOneItem() const { return m_collectionIndexCache.hasExactlyOne
Node(*this); } |
58 | 58 |
59 // CollectionIndexCache API. | 59 // CollectionIndexCache API. |
60 bool canTraverseBackward() const { return !overridesItemAfter(); } | 60 bool canTraverseBackward() const { return !overridesItemAfter(); } |
61 Element* itemBefore(const Element* previousItem) const; | 61 Element* itemBefore(const Element* previousItem) const; |
62 Element* traverseToFirstElement(const ContainerNode& root) const; | 62 Element* traverseToFirstElement(const ContainerNode& root) const; |
63 Element* traverseForwardToOffset(unsigned offset, Element& currentElement, u
nsigned& currentOffset, const ContainerNode& root) const; | 63 Element* traverseForwardToOffset(unsigned offset, Element& currentElement, u
nsigned& currentOffset, const ContainerNode& root) const; |
64 | 64 |
65 protected: | 65 protected: |
66 HTMLCollection(ContainerNode* base, CollectionType, ItemAfterOverrideType); | 66 HTMLCollection(ContainerNode& base, CollectionType, ItemAfterOverrideType); |
67 | 67 |
68 bool overridesItemAfter() const { return m_overridesItemAfter; } | 68 bool overridesItemAfter() const { return m_overridesItemAfter; } |
69 virtual Element* virtualItemAfter(Element*) const; | 69 virtual Element* virtualItemAfter(Element*) const; |
70 bool shouldOnlyIncludeDirectChildren() const { return m_shouldOnlyIncludeDir
ectChildren; } | 70 bool shouldOnlyIncludeDirectChildren() const { return m_shouldOnlyIncludeDir
ectChildren; } |
71 virtual void supportedPropertyNames(Vector<String>& names); | 71 virtual void supportedPropertyNames(Vector<String>& names); |
72 | 72 |
73 virtual void updateIdNameCache() const; | 73 virtual void updateIdNameCache() const; |
74 bool hasValidIdNameCache() const { return m_hasValidIdNameCache; } | 74 bool hasValidIdNameCache() const { return m_hasValidIdNameCache; } |
75 void setHasValidIdNameCache() const | 75 void setHasValidIdNameCache() const |
76 { | 76 { |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
116 mutable NodeCacheMap m_idCache; | 116 mutable NodeCacheMap m_idCache; |
117 mutable NodeCacheMap m_nameCache; | 117 mutable NodeCacheMap m_nameCache; |
118 mutable CollectionIndexCache<HTMLCollection, Element> m_collectionIndexCache
; | 118 mutable CollectionIndexCache<HTMLCollection, Element> m_collectionIndexCache
; |
119 | 119 |
120 friend class LiveNodeListBase; | 120 friend class LiveNodeListBase; |
121 }; | 121 }; |
122 | 122 |
123 } // namespace | 123 } // namespace |
124 | 124 |
125 #endif | 125 #endif |
OLD | NEW |