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