Line data Source code
1 : /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 : /* vim: set ts=8 sts=2 et sw=2 tw=80: */
3 : /* This Source Code Form is subject to the terms of the Mozilla Public
4 : * License, v. 2.0. If a copy of the MPL was not distributed with this
5 : * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
6 :
7 : #ifndef nsFind_h__
8 : #define nsFind_h__
9 :
10 : #include "nsIFind.h"
11 :
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 nsIContent;
20 :
21 : #define NS_FIND_CONTRACTID "@mozilla.org/embedcomp/rangefind;1"
22 :
23 : #define NS_FIND_CID \
24 : {0x471f4944, 0x1dd2, 0x11b2, {0x87, 0xac, 0x90, 0xbe, 0x0a, 0x51, 0xd6, 0x09}}
25 :
26 : class nsFindContentIterator;
27 :
28 : class nsFind : public nsIFind
29 : {
30 : public:
31 : NS_DECL_CYCLE_COLLECTING_ISUPPORTS
32 : NS_DECL_NSIFIND
33 0 : NS_DECL_CYCLE_COLLECTION_CLASS(nsFind)
34 :
35 : nsFind();
36 :
37 : protected:
38 : virtual ~nsFind();
39 :
40 : // Parameters set from the interface:
41 : //nsCOMPtr<nsIDOMRange> mRange; // search only in this range
42 : bool mFindBackward;
43 : bool mCaseSensitive;
44 :
45 : // Use "find entire words" mode by setting to a word breaker or null, to
46 : // disable "entire words" mode.
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 : // Get the first character from the next node (last if mFindBackward).
68 : char16_t PeekNextChar(nsIDOMRange* aSearchRange,
69 : nsIDOMRange* aStartPoint,
70 : nsIDOMRange* aEndPoint);
71 :
72 : // Reset variables before returning -- don't hold any references.
73 : void ResetAll();
74 :
75 : // The iterator we use to move through the document:
76 : nsresult InitIterator(nsIDOMNode* aStartNode, int32_t aStartOffset,
77 : nsIDOMNode* aEndNode, int32_t aEndOffset);
78 : RefPtr<nsFindContentIterator> mIterator;
79 :
80 : friend class PeekNextCharRestoreState;
81 : };
82 :
83 : #endif // nsFind_h__
|