1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* This Source Code Form is subject to the terms of the Mozilla Public
3 * License, v. 2.0. If a copy of the MPL was not distributed with this
4 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
6 #ifndef nsFilteredContentIterator_h__
7 #define nsFilteredContentIterator_h__
10 #include "nsCycleCollectionParticipant.h"
11 #include "nsIContentIterator.h"
12 #include "nsISupportsImpl.h"
19 class nsITextServicesFilter
;
22 class nsFilteredContentIterator MOZ_FINAL
: public nsIContentIterator
26 // nsISupports interface...
27 NS_DECL_CYCLE_COLLECTING_ISUPPORTS
28 NS_DECL_CYCLE_COLLECTION_CLASS(nsFilteredContentIterator
)
30 explicit nsFilteredContentIterator(nsITextServicesFilter
* aFilter
);
32 /* nsIContentIterator */
33 virtual nsresult
Init(nsINode
* aRoot
) MOZ_OVERRIDE
;
34 virtual nsresult
Init(nsIDOMRange
* aRange
) MOZ_OVERRIDE
;
35 virtual void First() MOZ_OVERRIDE
;
36 virtual void Last() MOZ_OVERRIDE
;
37 virtual void Next() MOZ_OVERRIDE
;
38 virtual void Prev() MOZ_OVERRIDE
;
39 virtual nsINode
*GetCurrentNode() MOZ_OVERRIDE
;
40 virtual bool IsDone() MOZ_OVERRIDE
;
41 virtual nsresult
PositionAt(nsINode
* aCurNode
) MOZ_OVERRIDE
;
44 bool DidSkip() { return mDidSkip
; }
45 void ClearDidSkip() { mDidSkip
= false; }
48 nsFilteredContentIterator() { }
50 virtual ~nsFilteredContentIterator();
52 // enum to give us the direction
53 typedef enum {eDirNotSet
, eForward
, eBackward
} eDirectionType
;
54 nsresult
AdvanceNode(nsIDOMNode
* aNode
, nsIDOMNode
*& aNewNode
, eDirectionType aDir
);
55 void CheckAdvNode(nsIDOMNode
* aNode
, bool& aDidSkip
, eDirectionType aDir
);
56 nsresult
SwitchDirections(bool aChangeToForward
);
58 nsCOMPtr
<nsIContentIterator
> mCurrentIterator
;
59 nsCOMPtr
<nsIContentIterator
> mIterator
;
60 nsCOMPtr
<nsIContentIterator
> mPreIterator
;
62 nsCOMPtr
<nsIAtom
> mBlockQuoteAtom
;
63 nsCOMPtr
<nsIAtom
> mScriptAtom
;
64 nsCOMPtr
<nsIAtom
> mTextAreaAtom
;
65 nsCOMPtr
<nsIAtom
> mSelectAreaAtom
;
66 nsCOMPtr
<nsIAtom
> mMapAtom
;
68 nsCOMPtr
<nsITextServicesFilter
> mFilter
;
69 nsRefPtr
<nsRange
> mRange
;
72 eDirectionType mDirection
;