michael@0: /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ michael@0: /* This Source Code Form is subject to the terms of the Mozilla Public michael@0: * License, v. 2.0. If a copy of the MPL was not distributed with this michael@0: * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ michael@0: michael@0: #ifndef nsFind_h__ michael@0: #define nsFind_h__ michael@0: michael@0: #include "nsIFind.h" michael@0: michael@0: #include "nsAutoPtr.h" michael@0: #include "nsCOMPtr.h" michael@0: #include "nsCycleCollectionParticipant.h" michael@0: #include "nsIDOMNode.h" michael@0: #include "nsIDOMRange.h" michael@0: #include "nsIContentIterator.h" michael@0: #include "nsIWordBreaker.h" michael@0: michael@0: class nsIAtom; michael@0: class nsIContent; michael@0: michael@0: #define NS_FIND_CONTRACTID "@mozilla.org/embedcomp/rangefind;1" michael@0: michael@0: #define NS_FIND_CID \ michael@0: {0x471f4944, 0x1dd2, 0x11b2, {0x87, 0xac, 0x90, 0xbe, 0x0a, 0x51, 0xd6, 0x09}} michael@0: michael@0: class nsFindContentIterator; michael@0: michael@0: class nsFind : public nsIFind michael@0: { michael@0: public: michael@0: NS_DECL_CYCLE_COLLECTING_ISUPPORTS michael@0: NS_DECL_NSIFIND michael@0: NS_DECL_CYCLE_COLLECTION_CLASS(nsFind) michael@0: michael@0: nsFind(); michael@0: virtual ~nsFind(); michael@0: michael@0: static already_AddRefed CreateRange(nsINode* aNode); michael@0: michael@0: protected: michael@0: // Parameters set from the interface: michael@0: //nsCOMPtr mRange; // search only in this range michael@0: bool mFindBackward; michael@0: bool mCaseSensitive; michael@0: michael@0: nsCOMPtr mWordBreaker; michael@0: michael@0: int32_t mIterOffset; michael@0: nsCOMPtr mIterNode; michael@0: michael@0: // Last block parent, so that we will notice crossing block boundaries: michael@0: nsCOMPtr mLastBlockParent; michael@0: nsresult GetBlockParent(nsIDOMNode* aNode, nsIDOMNode** aParent); michael@0: michael@0: // Utility routines: michael@0: bool IsTextNode(nsIDOMNode* aNode); michael@0: bool IsBlockNode(nsIContent* aNode); michael@0: bool SkipNode(nsIContent* aNode); michael@0: bool IsVisibleNode(nsIDOMNode *aNode); michael@0: michael@0: // Move in the right direction for our search: michael@0: nsresult NextNode(nsIDOMRange* aSearchRange, michael@0: nsIDOMRange* aStartPoint, nsIDOMRange* aEndPoint, michael@0: bool aContinueOk); michael@0: michael@0: // Reset variables before returning -- don't hold any references. michael@0: void ResetAll(); michael@0: michael@0: // The iterator we use to move through the document: michael@0: nsresult InitIterator(nsIDOMNode* aStartNode, int32_t aStartOffset, michael@0: nsIDOMNode* aEndNode, int32_t aEndOffset); michael@0: nsRefPtr mIterator; michael@0: }; michael@0: michael@0: #endif // nsFind_h__