Wed, 31 Dec 2014 06:09:35 +0100
Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.
michael@0 | 1 | /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ |
michael@0 | 2 | /* This Source Code Form is subject to the terms of the Mozilla Public |
michael@0 | 3 | * License, v. 2.0. If a copy of the MPL was not distributed with this |
michael@0 | 4 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ |
michael@0 | 5 | |
michael@0 | 6 | #ifndef nsFind_h__ |
michael@0 | 7 | #define nsFind_h__ |
michael@0 | 8 | |
michael@0 | 9 | #include "nsIFind.h" |
michael@0 | 10 | |
michael@0 | 11 | #include "nsAutoPtr.h" |
michael@0 | 12 | #include "nsCOMPtr.h" |
michael@0 | 13 | #include "nsCycleCollectionParticipant.h" |
michael@0 | 14 | #include "nsIDOMNode.h" |
michael@0 | 15 | #include "nsIDOMRange.h" |
michael@0 | 16 | #include "nsIContentIterator.h" |
michael@0 | 17 | #include "nsIWordBreaker.h" |
michael@0 | 18 | |
michael@0 | 19 | class nsIAtom; |
michael@0 | 20 | class nsIContent; |
michael@0 | 21 | |
michael@0 | 22 | #define NS_FIND_CONTRACTID "@mozilla.org/embedcomp/rangefind;1" |
michael@0 | 23 | |
michael@0 | 24 | #define NS_FIND_CID \ |
michael@0 | 25 | {0x471f4944, 0x1dd2, 0x11b2, {0x87, 0xac, 0x90, 0xbe, 0x0a, 0x51, 0xd6, 0x09}} |
michael@0 | 26 | |
michael@0 | 27 | class nsFindContentIterator; |
michael@0 | 28 | |
michael@0 | 29 | class nsFind : public nsIFind |
michael@0 | 30 | { |
michael@0 | 31 | public: |
michael@0 | 32 | NS_DECL_CYCLE_COLLECTING_ISUPPORTS |
michael@0 | 33 | NS_DECL_NSIFIND |
michael@0 | 34 | NS_DECL_CYCLE_COLLECTION_CLASS(nsFind) |
michael@0 | 35 | |
michael@0 | 36 | nsFind(); |
michael@0 | 37 | virtual ~nsFind(); |
michael@0 | 38 | |
michael@0 | 39 | static already_AddRefed<nsIDOMRange> CreateRange(nsINode* aNode); |
michael@0 | 40 | |
michael@0 | 41 | protected: |
michael@0 | 42 | // Parameters set from the interface: |
michael@0 | 43 | //nsCOMPtr<nsIDOMRange> mRange; // search only in this range |
michael@0 | 44 | bool mFindBackward; |
michael@0 | 45 | bool mCaseSensitive; |
michael@0 | 46 | |
michael@0 | 47 | nsCOMPtr<nsIWordBreaker> mWordBreaker; |
michael@0 | 48 | |
michael@0 | 49 | int32_t mIterOffset; |
michael@0 | 50 | nsCOMPtr<nsIDOMNode> mIterNode; |
michael@0 | 51 | |
michael@0 | 52 | // Last block parent, so that we will notice crossing block boundaries: |
michael@0 | 53 | nsCOMPtr<nsIDOMNode> mLastBlockParent; |
michael@0 | 54 | nsresult GetBlockParent(nsIDOMNode* aNode, nsIDOMNode** aParent); |
michael@0 | 55 | |
michael@0 | 56 | // Utility routines: |
michael@0 | 57 | bool IsTextNode(nsIDOMNode* aNode); |
michael@0 | 58 | bool IsBlockNode(nsIContent* aNode); |
michael@0 | 59 | bool SkipNode(nsIContent* aNode); |
michael@0 | 60 | bool IsVisibleNode(nsIDOMNode *aNode); |
michael@0 | 61 | |
michael@0 | 62 | // Move in the right direction for our search: |
michael@0 | 63 | nsresult NextNode(nsIDOMRange* aSearchRange, |
michael@0 | 64 | nsIDOMRange* aStartPoint, nsIDOMRange* aEndPoint, |
michael@0 | 65 | bool aContinueOk); |
michael@0 | 66 | |
michael@0 | 67 | // Reset variables before returning -- don't hold any references. |
michael@0 | 68 | void ResetAll(); |
michael@0 | 69 | |
michael@0 | 70 | // The iterator we use to move through the document: |
michael@0 | 71 | nsresult InitIterator(nsIDOMNode* aStartNode, int32_t aStartOffset, |
michael@0 | 72 | nsIDOMNode* aEndNode, int32_t aEndOffset); |
michael@0 | 73 | nsRefPtr<nsFindContentIterator> mIterator; |
michael@0 | 74 | }; |
michael@0 | 75 | |
michael@0 | 76 | #endif // nsFind_h__ |