Bug 470455 - test_database_sync_embed_visits.js leaks, r=sdwilsh
[wine-gecko.git] / embedding / components / find / src / nsFind.h
blob8eedd34729be148540afbb9712ac079dcc2cc92f
1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* ***** BEGIN LICENSE BLOCK *****
3 * Version: MPL 1.1/GPL 2.0/LGPL 2.1
5 * The contents of this file are subject to the Mozilla Public License Version
6 * 1.1 (the "License"); you may not use this file except in compliance with
7 * the License. You may obtain a copy of the License at
8 * http://www.mozilla.org/MPL/
10 * Software distributed under the License is distributed on an "AS IS" basis,
11 * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
12 * for the specific language governing rights and limitations under the
13 * License.
15 * The Original Code is mozilla.org code.
17 * The Initial Developer of the Original Code is
18 * Netscape Communications Corporation.
19 * Portions created by the Initial Developer are Copyright (C) 1998
20 * the Initial Developer. All Rights Reserved.
22 * Contributor(s):
23 * Akkana Peck <akkana@netscape.com>
25 * Alternatively, the contents of this file may be used under the terms of
26 * either the GNU General Public License Version 2 or later (the "GPL"), or
27 * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
28 * in which case the provisions of the GPL or the LGPL are applicable instead
29 * of those above. If you wish to allow use of your version of this file only
30 * under the terms of either the GPL or the LGPL, and not to allow others to
31 * use your version of this file under the terms of the MPL, indicate your
32 * decision by deleting the provisions above and replace them with the notice
33 * and other provisions required by the GPL or the LGPL. If you do not delete
34 * the provisions above, a recipient may use your version of this file under
35 * the terms of any one of the MPL, the GPL or the LGPL.
37 * ***** END LICENSE BLOCK ***** */
39 #ifndef nsFind_h__
40 #define nsFind_h__
42 #include "nsIFind.h"
44 #include "nsCOMPtr.h"
45 #include "nsIDOMNode.h"
46 #include "nsIDOMRange.h"
47 #include "nsIContentIterator.h"
48 #include "nsIParserService.h"
49 #include "nsIWordBreaker.h"
51 class nsIPresShell;
52 class nsIAtom;
53 class nsIContent;
55 #define NS_FIND_CONTRACTID "@mozilla.org/embedcomp/rangefind;1"
57 #define NS_FIND_CID \
58 {0x471f4944, 0x1dd2, 0x11b2, {0x87, 0xac, 0x90, 0xbe, 0x0a, 0x51, 0xd6, 0x09}}
60 class nsFindContentIterator;
62 class nsFind : public nsIFind
64 public:
65 NS_DECL_ISUPPORTS
66 NS_DECL_NSIFIND
68 nsFind();
69 virtual ~nsFind();
71 static already_AddRefed<nsIDOMRange> CreateRange();
73 protected:
74 static PRInt32 sInstanceCount;
76 // HTML tags we treat specially
77 static nsIAtom* sImgAtom;
78 static nsIAtom* sHRAtom;
79 // Nodes we skip
80 static nsIAtom* sScriptAtom;
81 static nsIAtom* sNoframesAtom;
82 static nsIAtom* sSelectAtom;
83 static nsIAtom* sTextareaAtom;
84 static nsIAtom* sThAtom;
85 static nsIAtom* sTdAtom;
87 // Parameters set from the interface:
88 //nsCOMPtr<nsIDOMRange> mRange; // search only in this range
89 PRPackedBool mFindBackward;
90 PRPackedBool mCaseSensitive;
92 nsCOMPtr<nsIWordBreaker> mWordBreaker;
93 nsCOMPtr<nsIParserService> mParserService;
95 PRInt32 mIterOffset;
96 nsCOMPtr<nsIDOMNode> mIterNode;
98 // Last block parent, so that we will notice crossing block boundaries:
99 nsCOMPtr<nsIDOMNode> mLastBlockParent;
100 nsresult GetBlockParent(nsIDOMNode* aNode, nsIDOMNode** aParent);
102 // Utility routines:
103 PRBool IsTextNode(nsIDOMNode* aNode);
104 PRBool IsBlockNode(nsIContent* aNode);
105 PRBool SkipNode(nsIContent* aNode);
106 PRBool IsVisibleNode(nsIDOMNode *aNode);
108 // Move in the right direction for our search:
109 nsresult NextNode(nsIDOMRange* aSearchRange,
110 nsIDOMRange* aStartPoint, nsIDOMRange* aEndPoint,
111 PRBool aContinueOk);
113 // Reset variables before returning -- don't hold any references.
114 void ResetAll();
116 // The iterator we use to move through the document:
117 nsresult InitIterator(nsIDOMNode* aStartNode, PRInt32 aStartOffset,
118 nsIDOMNode* aEndNode, PRInt32 aEndOffset);
119 nsCOMPtr<nsFindContentIterator> mIterator;
122 #endif // nsFind_h__