1
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2
/* ***** BEGIN LICENSE BLOCK *****
3
* Version: NPL 1.1/GPL 2.0/LGPL 2.1
5
* The contents of this file are subject to the Netscape Public License
6
* Version 1.1 (the "License"); you may not use this file except in
7
* compliance with the License. You may obtain a copy of the License at
8
* http://www.mozilla.org/NPL/
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
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.
23
* Akkana Peck <akkana@netscape.com>
26
* Alternatively, the contents of this file may be used under the terms of
27
* either the GNU General Public License Version 2 or later (the "GPL"), or
28
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
29
* in which case the provisions of the GPL or the LGPL are applicable instead
30
* of those above. If you wish to allow use of your version of this file only
31
* under the terms of either the GPL or the LGPL, and not to allow others to
32
* use your version of this file under the terms of the NPL, indicate your
33
* decision by deleting the provisions above and replace them with the notice
34
* and other provisions required by the GPL or the LGPL. If you do not delete
35
* the provisions above, a recipient may use your version of this file under
36
* the terms of any one of the NPL, the GPL or the LGPL.
38
* ***** END LICENSE BLOCK ***** */
46
#include "nsIDOMNode.h"
47
#include "nsIDOMRange.h"
48
#include "nsIContentIterator.h"
49
#include "nsIParserService.h"
50
#include "nsIWordBreaker.h"
55
#define NS_FIND_CONTRACTID "@mozilla.org/embedcomp/rangefind;1"
58
{0x471f4944, 0x1dd2, 0x11b2, {0x87, 0xac, 0x90, 0xbe, 0x0a, 0x51, 0xd6, 0x09}}
60
class nsFind : public nsIFind
70
static PRInt32 sInstanceCount;
72
// HTML tags we treat specially
73
static nsIAtom* sTextAtom;
74
static nsIAtom* sImgAtom;
75
static nsIAtom* sHRAtom;
77
static nsIAtom* sCommentAtom;
78
static nsIAtom* sScriptAtom;
79
static nsIAtom* sNoframesAtom;
80
static nsIAtom* sSelectAtom;
81
static nsIAtom* sTextareaAtom;
82
static nsIAtom* sThAtom;
83
static nsIAtom* sTdAtom;
85
// Parameters set from the interface:
86
//nsCOMPtr<nsIDOMRange> mRange; // search only in this range
87
PRPackedBool mFindBackward;
88
PRPackedBool mCaseSensitive;
90
nsCOMPtr<nsIWordBreaker> mWordBreaker;
91
nsCOMPtr<nsIParserService> mParserService;
94
nsCOMPtr<nsIDOMNode> mIterNode;
96
// Last block parent, so that we will notice crossing block boundaries:
97
nsCOMPtr<nsIDOMNode> mLastBlockParent;
98
nsresult GetBlockParent(nsIDOMNode* aNode, nsIDOMNode** aParent);
101
PRBool IsTextNode(nsIDOMNode* aNode);
102
PRBool IsBlockNode(nsIContent* aNode);
103
PRBool SkipNode(nsIContent* aNode);
104
PRBool IsVisibleNode(nsIDOMNode *aNode);
106
// Move in the right direction for our search:
107
nsresult NextNode(nsIDOMRange* aSearchRange,
108
nsIDOMRange* aStartPoint, nsIDOMRange* aEndPoint,
111
// Reset variables before returning -- don't hold any references.
114
// The iterator we use to move through the document:
115
nsresult InitIterator(nsIDOMRange* aSearchRange);
116
nsCOMPtr<nsIContentIterator> mIterator;