summaryrefslogtreecommitdiff
path: root/Source/WebCore/html/HTMLCollection.cpp
diff options
context:
space:
mode:
authorSimon Hausmann <simon.hausmann@nokia.com>2012-01-11 10:03:25 +0100
committerSimon Hausmann <simon.hausmann@nokia.com>2012-01-11 10:03:25 +0100
commitd11f84f5b5cdc0d92a08af01b13472fdd5f9acb9 (patch)
treeb318cf594dc1da2fa48224005945c9157f35bb41 /Source/WebCore/html/HTMLCollection.cpp
parent6300a96eca9f152b379f1bcf3d9efdc5572d989a (diff)
downloadqtwebkit-d11f84f5b5cdc0d92a08af01b13472fdd5f9acb9.tar.gz
Imported WebKit commit 75bb2fc5882d2e1b3d5572c2961507996cbca5e3 (http://svn.webkit.org/repository/webkit/trunk@104681)
Diffstat (limited to 'Source/WebCore/html/HTMLCollection.cpp')
-rw-r--r--Source/WebCore/html/HTMLCollection.cpp37
1 files changed, 3 insertions, 34 deletions
diff --git a/Source/WebCore/html/HTMLCollection.cpp b/Source/WebCore/html/HTMLCollection.cpp
index 0803fe9cc..e6f2eac0a 100644
--- a/Source/WebCore/html/HTMLCollection.cpp
+++ b/Source/WebCore/html/HTMLCollection.cpp
@@ -41,6 +41,7 @@ HTMLCollection::HTMLCollection(Node* base, CollectionType type)
, m_type(type)
, m_base(base)
{
+ ASSERT(m_base);
m_cache.clear();
}
@@ -76,24 +77,17 @@ bool HTMLCollection::shouldIncludeChildren(CollectionType type)
return false;
}
-PassRefPtr<HTMLCollection> HTMLCollection::create(Node* base, CollectionType type)
+PassOwnPtr<HTMLCollection> HTMLCollection::create(Node* base, CollectionType type)
{
- return adoptRef(new HTMLCollection(base, type));
+ return adoptPtr(new HTMLCollection(base, type));
}
HTMLCollection::~HTMLCollection()
{
}
-void HTMLCollection::detachFromNode()
-{
- m_base = 0;
-}
-
void HTMLCollection::invalidateCacheIfNeeded() const
{
- ASSERT(m_base);
-
uint64_t docversion = static_cast<HTMLDocument*>(m_base->document())->domTreeVersion();
if (m_cache.version == docversion)
@@ -161,8 +155,6 @@ static Node* nextNodeOrSibling(Node* base, Node* node, bool includeChildren)
Element* HTMLCollection::itemAfter(Element* previous) const
{
- ASSERT(m_base);
-
Node* current;
if (!previous)
current = m_base->firstChild();
@@ -182,8 +174,6 @@ Element* HTMLCollection::itemAfter(Element* previous) const
unsigned HTMLCollection::calcLength() const
{
- ASSERT(m_base);
-
unsigned len = 0;
for (Element* current = itemAfter(0); current; current = itemAfter(current))
++len;
@@ -194,9 +184,6 @@ unsigned HTMLCollection::calcLength() const
// calculation every time if anything has changed
unsigned HTMLCollection::length() const
{
- if (!m_base)
- return 0;
-
invalidateCacheIfNeeded();
if (!m_cache.hasLength) {
m_cache.length = calcLength();
@@ -207,9 +194,6 @@ unsigned HTMLCollection::length() const
Node* HTMLCollection::item(unsigned index) const
{
- if (!m_base)
- return 0;
-
invalidateCacheIfNeeded();
if (m_cache.current && m_cache.position == index)
return m_cache.current;
@@ -236,7 +220,6 @@ Node* HTMLCollection::firstItem() const
Node* HTMLCollection::nextItem() const
{
- ASSERT(m_base);
invalidateCacheIfNeeded();
// Look for the 'second' item. The first one is currentItem, already given back.
@@ -276,9 +259,6 @@ bool HTMLCollection::checkForNameMatch(Element* element, bool checkName, const A
Node* HTMLCollection::namedItem(const AtomicString& name) const
{
- if (!m_base)
- return 0;
-
// http://msdn.microsoft.com/workshop/author/dhtml/reference/methods/nameditem.asp
// This method first searches for an object with a matching id
// attribute. If a match is not found, the method then searches for an
@@ -306,8 +286,6 @@ Node* HTMLCollection::namedItem(const AtomicString& name) const
void HTMLCollection::updateNameCache() const
{
- ASSERT(m_base);
-
if (m_cache.hasNameCache)
return;
@@ -328,9 +306,6 @@ void HTMLCollection::updateNameCache() const
bool HTMLCollection::hasNamedItem(const AtomicString& name) const
{
- if (!m_base)
- return false;
-
if (name.isEmpty())
return false;
@@ -352,9 +327,6 @@ bool HTMLCollection::hasNamedItem(const AtomicString& name) const
void HTMLCollection::namedItems(const AtomicString& name, Vector<RefPtr<Node> >& result) const
{
- if (!m_base)
- return;
-
ASSERT(result.isEmpty());
if (name.isEmpty())
return;
@@ -374,9 +346,6 @@ void HTMLCollection::namedItems(const AtomicString& name, Vector<RefPtr<Node> >&
PassRefPtr<NodeList> HTMLCollection::tags(const String& name)
{
- if (!m_base)
- return 0;
-
return m_base->getElementsByTagName(name);
}