Bumping manifests a=b2g-bump
[gecko.git] / editor / txtsvc / nsFilteredContentIterator.h
blobcb9c1b217cf767e8e0c90f9eb7b6a5b3192e0633
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__
9 #include "nsCOMPtr.h"
10 #include "nsCycleCollectionParticipant.h"
11 #include "nsIContentIterator.h"
12 #include "nsISupportsImpl.h"
13 #include "nscore.h"
15 class nsIAtom;
16 class nsIDOMNode;
17 class nsIDOMRange;
18 class nsINode;
19 class nsITextServicesFilter;
21 class nsFilteredContentIterator MOZ_FINAL : public nsIContentIterator
23 public:
25 // nsISupports interface...
26 NS_DECL_CYCLE_COLLECTING_ISUPPORTS
27 NS_DECL_CYCLE_COLLECTION_CLASS(nsFilteredContentIterator)
29 explicit nsFilteredContentIterator(nsITextServicesFilter* aFilter);
31 /* nsIContentIterator */
32 virtual nsresult Init(nsINode* aRoot);
33 virtual nsresult Init(nsIDOMRange* aRange);
34 virtual void First();
35 virtual void Last();
36 virtual void Next();
37 virtual void Prev();
38 virtual nsINode *GetCurrentNode();
39 virtual bool IsDone();
40 virtual nsresult PositionAt(nsINode* aCurNode);
42 /* Helpers */
43 bool DidSkip() { return mDidSkip; }
44 void ClearDidSkip() { mDidSkip = false; }
46 protected:
47 nsFilteredContentIterator() { }
49 virtual ~nsFilteredContentIterator();
51 // enum to give us the direction
52 typedef enum {eDirNotSet, eForward, eBackward} eDirectionType;
53 nsresult AdvanceNode(nsIDOMNode* aNode, nsIDOMNode*& aNewNode, eDirectionType aDir);
54 void CheckAdvNode(nsIDOMNode* aNode, bool& aDidSkip, eDirectionType aDir);
55 nsresult SwitchDirections(bool aChangeToForward);
57 nsCOMPtr<nsIContentIterator> mCurrentIterator;
58 nsCOMPtr<nsIContentIterator> mIterator;
59 nsCOMPtr<nsIContentIterator> mPreIterator;
61 nsCOMPtr<nsIAtom> mBlockQuoteAtom;
62 nsCOMPtr<nsIAtom> mScriptAtom;
63 nsCOMPtr<nsIAtom> mTextAreaAtom;
64 nsCOMPtr<nsIAtom> mSelectAreaAtom;
65 nsCOMPtr<nsIAtom> mMapAtom;
67 nsCOMPtr<nsITextServicesFilter> mFilter;
68 nsCOMPtr<nsIDOMRange> mRange;
69 bool mDidSkip;
70 bool mIsOutOfRange;
71 eDirectionType mDirection;
74 #endif