summaryrefslogtreecommitdiff
path: root/Source/WebCore/html/HTMLCollection.cpp
diff options
context:
space:
mode:
authorSimon Hausmann <simon.hausmann@nokia.com>2012-06-27 09:28:46 +0200
committerSimon Hausmann <simon.hausmann@nokia.com>2012-06-27 09:28:46 +0200
commit6668b07fcd51f86be243b9e08e667224e30c0cf8 (patch)
tree64f466e09b68a77ae1156c0d35cd5b95e18a34ca /Source/WebCore/html/HTMLCollection.cpp
parente7923d9de38974f0c6fb7646c898a6ea618261e8 (diff)
downloadqtwebkit-6668b07fcd51f86be243b9e08e667224e30c0cf8.tar.gz
Imported WebKit commit 26cd9bd8ab0471ffe987c9b60368f63dc0f1f31b (http://svn.webkit.org/repository/webkit/trunk@121325)
New snapshot with more Windows build fixes
Diffstat (limited to 'Source/WebCore/html/HTMLCollection.cpp')
-rw-r--r--Source/WebCore/html/HTMLCollection.cpp70
1 files changed, 27 insertions, 43 deletions
diff --git a/Source/WebCore/html/HTMLCollection.cpp b/Source/WebCore/html/HTMLCollection.cpp
index c20c464e8..1129cabd9 100644
--- a/Source/WebCore/html/HTMLCollection.cpp
+++ b/Source/WebCore/html/HTMLCollection.cpp
@@ -36,16 +36,7 @@ namespace WebCore {
using namespace HTMLNames;
-HTMLCollection::HTMLCollection(Node* base, CollectionType type)
- : m_includeChildren(shouldIncludeChildren(type))
- , m_type(type)
- , m_base(base)
-{
- ASSERT(m_base);
- m_cache.clear();
-}
-
-bool HTMLCollection::shouldIncludeChildren(CollectionType type)
+static bool shouldIncludeChildren(CollectionType type)
{
switch (type) {
case DocAll:
@@ -78,6 +69,15 @@ bool HTMLCollection::shouldIncludeChildren(CollectionType type)
return false;
}
+HTMLCollection::HTMLCollection(Node* base, CollectionType type)
+ : m_includeChildren(shouldIncludeChildren(type))
+ , m_type(type)
+ , m_base(base)
+{
+ ASSERT(m_base);
+ m_cache.clear();
+}
+
PassOwnPtr<HTMLCollection> HTMLCollection::create(Node* base, CollectionType type)
{
return adoptPtr(new HTMLCollection(base, type));
@@ -199,39 +199,23 @@ unsigned HTMLCollection::length() const
Node* HTMLCollection::item(unsigned index) const
{
- invalidateCacheIfNeeded();
- if (m_cache.current && m_cache.position == index)
- return m_cache.current;
- if (m_cache.hasLength && m_cache.length <= index)
- return 0;
- if (!m_cache.current || m_cache.position > index) {
- m_cache.current = itemAfter(0);
- m_cache.position = 0;
- if (!m_cache.current)
- return 0;
- }
- Element* e = m_cache.current;
- for (unsigned pos = m_cache.position; e && pos < index; pos++)
- e = itemAfter(e);
- m_cache.current = e;
- m_cache.position = index;
- return m_cache.current;
-}
-
-Node* HTMLCollection::firstItem() const
-{
- return item(0);
-}
-
-Node* HTMLCollection::nextItem() const
-{
- invalidateCacheIfNeeded();
-
- // Look for the 'second' item. The first one is currentItem, already given back.
- Element* retval = itemAfter(m_cache.current);
- m_cache.current = retval;
- m_cache.position++;
- return retval;
+ invalidateCacheIfNeeded();
+ if (m_cache.current && m_cache.position == index)
+ return m_cache.current;
+ if (m_cache.hasLength && m_cache.length <= index)
+ return 0;
+ if (!m_cache.current || m_cache.position > index) {
+ m_cache.current = itemAfter(0);
+ m_cache.position = 0;
+ if (!m_cache.current)
+ return 0;
+ }
+ Element* e = m_cache.current;
+ for (unsigned pos = m_cache.position; e && pos < index; pos++)
+ e = itemAfter(e);
+ m_cache.current = e;
+ m_cache.position = index;
+ return m_cache.current;
}
static inline bool nameShouldBeVisibleInDocumentAll(HTMLElement* element)