Bug 452317 - FeedConverter.js: QueryInterface should throw NS_ERROR_NO_INTERFACE...
[wine-gecko.git] / embedding / components / find / src / nsFind.h
blob0c4ac1216b68d9167657057a3db8ee3574b03e92
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;
54 #define NS_FIND_CONTRACTID "@mozilla.org/embedcomp/rangefind;1"
56 #define NS_FIND_CID \
57 {0x471f4944, 0x1dd2, 0x11b2, {0x87, 0xac, 0x90, 0xbe, 0x0a, 0x51, 0xd6, 0x09}}
59 class nsFindContentIterator;
61 class nsFind : public nsIFind
63 public:
64 NS_DECL_ISUPPORTS
65 NS_DECL_NSIFIND
67 nsFind();
68 virtual ~nsFind();
70 static already_AddRefed<nsIDOMRange> CreateRange();
72 protected:
73 static PRInt32 sInstanceCount;
75 // HTML tags we treat specially
76 static nsIAtom* sImgAtom;
77 static nsIAtom* sHRAtom;
78 // Nodes we skip
79 static nsIAtom* sScriptAtom;
80 static nsIAtom* sNoframesAtom;
81 static nsIAtom* sSelectAtom;
82 static nsIAtom* sTextareaAtom;
83 static nsIAtom* sThAtom;
84 static nsIAtom* sTdAtom;
86 // Parameters set from the interface:
87 //nsCOMPtr<nsIDOMRange> mRange; // search only in this range
88 PRPackedBool mFindBackward;
89 PRPackedBool mCaseSensitive;
91 nsCOMPtr<nsIWordBreaker> mWordBreaker;
92 nsCOMPtr<nsIParserService> mParserService;
94 PRInt32 mIterOffset;
95 nsCOMPtr<nsIDOMNode> mIterNode;
97 // Last block parent, so that we will notice crossing block boundaries:
98 nsCOMPtr<nsIDOMNode> mLastBlockParent;
99 nsresult GetBlockParent(nsIDOMNode* aNode, nsIDOMNode** aParent);
101 // Utility routines:
102 PRBool IsTextNode(nsIDOMNode* aNode);
103 PRBool IsBlockNode(nsIContent* aNode);
104 PRBool SkipNode(nsIContent* aNode);
105 PRBool IsVisibleNode(nsIDOMNode *aNode);
107 // Move in the right direction for our search:
108 nsresult NextNode(nsIDOMRange* aSearchRange,
109 nsIDOMRange* aStartPoint, nsIDOMRange* aEndPoint,
110 PRBool aContinueOk);
112 // Reset variables before returning -- don't hold any references.
113 void ResetAll();
115 // The iterator we use to move through the document:
116 nsresult InitIterator(nsIDOMNode* aStartNode, PRInt32 aStartOffset,
117 nsIDOMNode* aEndNode, PRInt32 aEndOffset);
118 nsCOMPtr<nsFindContentIterator> mIterator;
121 #endif // nsFind_h__