|
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/. */ |
|
5 |
|
6 #ifndef nsFind_h__ |
|
7 #define nsFind_h__ |
|
8 |
|
9 #include "nsIFind.h" |
|
10 |
|
11 #include "nsAutoPtr.h" |
|
12 #include "nsCOMPtr.h" |
|
13 #include "nsCycleCollectionParticipant.h" |
|
14 #include "nsIDOMNode.h" |
|
15 #include "nsIDOMRange.h" |
|
16 #include "nsIContentIterator.h" |
|
17 #include "nsIWordBreaker.h" |
|
18 |
|
19 class nsIAtom; |
|
20 class nsIContent; |
|
21 |
|
22 #define NS_FIND_CONTRACTID "@mozilla.org/embedcomp/rangefind;1" |
|
23 |
|
24 #define NS_FIND_CID \ |
|
25 {0x471f4944, 0x1dd2, 0x11b2, {0x87, 0xac, 0x90, 0xbe, 0x0a, 0x51, 0xd6, 0x09}} |
|
26 |
|
27 class nsFindContentIterator; |
|
28 |
|
29 class nsFind : public nsIFind |
|
30 { |
|
31 public: |
|
32 NS_DECL_CYCLE_COLLECTING_ISUPPORTS |
|
33 NS_DECL_NSIFIND |
|
34 NS_DECL_CYCLE_COLLECTION_CLASS(nsFind) |
|
35 |
|
36 nsFind(); |
|
37 virtual ~nsFind(); |
|
38 |
|
39 static already_AddRefed<nsIDOMRange> CreateRange(nsINode* aNode); |
|
40 |
|
41 protected: |
|
42 // Parameters set from the interface: |
|
43 //nsCOMPtr<nsIDOMRange> mRange; // search only in this range |
|
44 bool mFindBackward; |
|
45 bool mCaseSensitive; |
|
46 |
|
47 nsCOMPtr<nsIWordBreaker> mWordBreaker; |
|
48 |
|
49 int32_t mIterOffset; |
|
50 nsCOMPtr<nsIDOMNode> mIterNode; |
|
51 |
|
52 // Last block parent, so that we will notice crossing block boundaries: |
|
53 nsCOMPtr<nsIDOMNode> mLastBlockParent; |
|
54 nsresult GetBlockParent(nsIDOMNode* aNode, nsIDOMNode** aParent); |
|
55 |
|
56 // Utility routines: |
|
57 bool IsTextNode(nsIDOMNode* aNode); |
|
58 bool IsBlockNode(nsIContent* aNode); |
|
59 bool SkipNode(nsIContent* aNode); |
|
60 bool IsVisibleNode(nsIDOMNode *aNode); |
|
61 |
|
62 // Move in the right direction for our search: |
|
63 nsresult NextNode(nsIDOMRange* aSearchRange, |
|
64 nsIDOMRange* aStartPoint, nsIDOMRange* aEndPoint, |
|
65 bool aContinueOk); |
|
66 |
|
67 // Reset variables before returning -- don't hold any references. |
|
68 void ResetAll(); |
|
69 |
|
70 // The iterator we use to move through the document: |
|
71 nsresult InitIterator(nsIDOMNode* aStartNode, int32_t aStartOffset, |
|
72 nsIDOMNode* aEndNode, int32_t aEndOffset); |
|
73 nsRefPtr<nsFindContentIterator> mIterator; |
|
74 }; |
|
75 |
|
76 #endif // nsFind_h__ |