1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/content/base/public/nsIContentIterator.h Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,71 @@ 1.4 +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ 1.5 +/* This Source Code Form is subject to the terms of the Mozilla Public 1.6 + * License, v. 2.0. If a copy of the MPL was not distributed with this 1.7 + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 1.8 + 1.9 +#ifndef __nsIContentIterator_h___ 1.10 +#define __nsIContentIterator_h___ 1.11 + 1.12 +#include "nsISupports.h" 1.13 +#include "nsCOMPtr.h" 1.14 + 1.15 +class nsINode; 1.16 +class nsIDOMRange; 1.17 + 1.18 +#define NS_ICONTENTITERATOR_IID \ 1.19 +{ 0x2550078e, 0xae87, 0x4914, \ 1.20 + { 0xb3, 0x04, 0xe4, 0xd1, 0x46, 0x19, 0x3d, 0x5f } } 1.21 + 1.22 +class nsIContentIterator : public nsISupports 1.23 +{ 1.24 +public: 1.25 + NS_DECLARE_STATIC_IID_ACCESSOR(NS_ICONTENTITERATOR_IID) 1.26 + 1.27 + /* Initializes an iterator for the subtree rooted by the node aRoot 1.28 + */ 1.29 + virtual nsresult Init(nsINode* aRoot) = 0; 1.30 + 1.31 + /* Initializes an iterator for the subtree defined by the range aRange 1.32 + Subclasses should make sure they implement both of these! 1.33 + */ 1.34 + virtual nsresult Init(nsIDOMRange* aRange) = 0; 1.35 + 1.36 + /** First will reset the list. 1.37 + */ 1.38 + virtual void First() = 0; 1.39 + 1.40 + /** Last will reset the list to the end. 1.41 + */ 1.42 + virtual void Last() = 0; 1.43 + 1.44 + /** Next will advance the list. 1.45 + */ 1.46 + virtual void Next() = 0; 1.47 + 1.48 + /** Prev will decrement the list. 1.49 + */ 1.50 + virtual void Prev() = 0; 1.51 + 1.52 + /** CurrentItem will return the current item, or null if the list is empty 1.53 + * @return the current node 1.54 + */ 1.55 + virtual nsINode *GetCurrentNode() = 0; 1.56 + 1.57 + /** return if the collection is at the end. that is the beginning following a call to Prev 1.58 + * and it is the end of the list following a call to next 1.59 + * @return if the iterator is done. 1.60 + */ 1.61 + virtual bool IsDone() = 0; 1.62 + 1.63 + /** PositionAt will position the iterator to the supplied node 1.64 + */ 1.65 + virtual nsresult PositionAt(nsINode* aCurNode) = 0; 1.66 +}; 1.67 + 1.68 +NS_DEFINE_STATIC_IID_ACCESSOR(nsIContentIterator, NS_ICONTENTITERATOR_IID) 1.69 + 1.70 +already_AddRefed<nsIContentIterator> NS_NewContentIterator(); 1.71 +already_AddRefed<nsIContentIterator> NS_NewPreContentIterator(); 1.72 +already_AddRefed<nsIContentIterator> NS_NewContentSubtreeIterator(); 1.73 + 1.74 +#endif // __nsIContentIterator_h___