1 // Copyright 2005 Ben Hutchings <ben@decadentplace.org.uk>.
2 // See the file "COPYING" for licence details.
4 #include "linkiterator.hpp"
8 #include <nsIDOMHTMLCollection.h>
9 #include <nsIDOMHTMLDocument.h>
11 LinkIterator::LinkIterator()
14 LinkIterator::LinkIterator(nsIDOMDocument * document)
16 nsCOMPtr<nsIDOMHTMLDocument> htmlDoc(do_QueryInterface(document));
20 htmlDoc->GetLinks(getter_AddRefs(collection_));
25 collection_->GetLength(&length_);
30 already_AddRefed<nsIDOMNode> LinkIterator::operator*() const
33 nsIDOMNode * result = 0;
34 collection_->Item(index_, &result);
36 return dont_AddRef(result);
39 LinkIterator & LinkIterator::operator++()
43 if (index_ == length_)
48 bool LinkIterator::operator==(const LinkIterator & other) const
50 return (collection_ == other.collection_
51 && (!collection_ || index_ == other.index_));