michael@0: /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ michael@0: /* This Source Code Form is subject to the terms of the Mozilla Public michael@0: * License, v. 2.0. If a copy of the MPL was not distributed with this michael@0: * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ michael@0: michael@0: #ifndef __nsIContentIterator_h___ michael@0: #define __nsIContentIterator_h___ michael@0: michael@0: #include "nsISupports.h" michael@0: #include "nsCOMPtr.h" michael@0: michael@0: class nsINode; michael@0: class nsIDOMRange; michael@0: michael@0: #define NS_ICONTENTITERATOR_IID \ michael@0: { 0x2550078e, 0xae87, 0x4914, \ michael@0: { 0xb3, 0x04, 0xe4, 0xd1, 0x46, 0x19, 0x3d, 0x5f } } michael@0: michael@0: class nsIContentIterator : public nsISupports michael@0: { michael@0: public: michael@0: NS_DECLARE_STATIC_IID_ACCESSOR(NS_ICONTENTITERATOR_IID) michael@0: michael@0: /* Initializes an iterator for the subtree rooted by the node aRoot michael@0: */ michael@0: virtual nsresult Init(nsINode* aRoot) = 0; michael@0: michael@0: /* Initializes an iterator for the subtree defined by the range aRange michael@0: Subclasses should make sure they implement both of these! michael@0: */ michael@0: virtual nsresult Init(nsIDOMRange* aRange) = 0; michael@0: michael@0: /** First will reset the list. michael@0: */ michael@0: virtual void First() = 0; michael@0: michael@0: /** Last will reset the list to the end. michael@0: */ michael@0: virtual void Last() = 0; michael@0: michael@0: /** Next will advance the list. michael@0: */ michael@0: virtual void Next() = 0; michael@0: michael@0: /** Prev will decrement the list. michael@0: */ michael@0: virtual void Prev() = 0; michael@0: michael@0: /** CurrentItem will return the current item, or null if the list is empty michael@0: * @return the current node michael@0: */ michael@0: virtual nsINode *GetCurrentNode() = 0; michael@0: michael@0: /** return if the collection is at the end. that is the beginning following a call to Prev michael@0: * and it is the end of the list following a call to next michael@0: * @return if the iterator is done. michael@0: */ michael@0: virtual bool IsDone() = 0; michael@0: michael@0: /** PositionAt will position the iterator to the supplied node michael@0: */ michael@0: virtual nsresult PositionAt(nsINode* aCurNode) = 0; michael@0: }; michael@0: michael@0: NS_DEFINE_STATIC_IID_ACCESSOR(nsIContentIterator, NS_ICONTENTITERATOR_IID) michael@0: michael@0: already_AddRefed NS_NewContentIterator(); michael@0: already_AddRefed NS_NewPreContentIterator(); michael@0: already_AddRefed NS_NewContentSubtreeIterator(); michael@0: michael@0: #endif // __nsIContentIterator_h___