1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/embedding/components/find/src/nsFind.h Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,76 @@ 1.4 +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ 1.5 +/* This Source Code Form is subject to the terms of the Mozilla Public 1.6 + * License, v. 2.0. If a copy of the MPL was not distributed with this 1.7 + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 1.8 + 1.9 +#ifndef nsFind_h__ 1.10 +#define nsFind_h__ 1.11 + 1.12 +#include "nsIFind.h" 1.13 + 1.14 +#include "nsAutoPtr.h" 1.15 +#include "nsCOMPtr.h" 1.16 +#include "nsCycleCollectionParticipant.h" 1.17 +#include "nsIDOMNode.h" 1.18 +#include "nsIDOMRange.h" 1.19 +#include "nsIContentIterator.h" 1.20 +#include "nsIWordBreaker.h" 1.21 + 1.22 +class nsIAtom; 1.23 +class nsIContent; 1.24 + 1.25 +#define NS_FIND_CONTRACTID "@mozilla.org/embedcomp/rangefind;1" 1.26 + 1.27 +#define NS_FIND_CID \ 1.28 + {0x471f4944, 0x1dd2, 0x11b2, {0x87, 0xac, 0x90, 0xbe, 0x0a, 0x51, 0xd6, 0x09}} 1.29 + 1.30 +class nsFindContentIterator; 1.31 + 1.32 +class nsFind : public nsIFind 1.33 +{ 1.34 +public: 1.35 + NS_DECL_CYCLE_COLLECTING_ISUPPORTS 1.36 + NS_DECL_NSIFIND 1.37 + NS_DECL_CYCLE_COLLECTION_CLASS(nsFind) 1.38 + 1.39 + nsFind(); 1.40 + virtual ~nsFind(); 1.41 + 1.42 + static already_AddRefed<nsIDOMRange> CreateRange(nsINode* aNode); 1.43 + 1.44 +protected: 1.45 + // Parameters set from the interface: 1.46 + //nsCOMPtr<nsIDOMRange> mRange; // search only in this range 1.47 + bool mFindBackward; 1.48 + bool mCaseSensitive; 1.49 + 1.50 + nsCOMPtr<nsIWordBreaker> mWordBreaker; 1.51 + 1.52 + int32_t mIterOffset; 1.53 + nsCOMPtr<nsIDOMNode> mIterNode; 1.54 + 1.55 + // Last block parent, so that we will notice crossing block boundaries: 1.56 + nsCOMPtr<nsIDOMNode> mLastBlockParent; 1.57 + nsresult GetBlockParent(nsIDOMNode* aNode, nsIDOMNode** aParent); 1.58 + 1.59 + // Utility routines: 1.60 + bool IsTextNode(nsIDOMNode* aNode); 1.61 + bool IsBlockNode(nsIContent* aNode); 1.62 + bool SkipNode(nsIContent* aNode); 1.63 + bool IsVisibleNode(nsIDOMNode *aNode); 1.64 + 1.65 + // Move in the right direction for our search: 1.66 + nsresult NextNode(nsIDOMRange* aSearchRange, 1.67 + nsIDOMRange* aStartPoint, nsIDOMRange* aEndPoint, 1.68 + bool aContinueOk); 1.69 + 1.70 + // Reset variables before returning -- don't hold any references. 1.71 + void ResetAll(); 1.72 + 1.73 + // The iterator we use to move through the document: 1.74 + nsresult InitIterator(nsIDOMNode* aStartNode, int32_t aStartOffset, 1.75 + nsIDOMNode* aEndNode, int32_t aEndOffset); 1.76 + nsRefPtr<nsFindContentIterator> mIterator; 1.77 +}; 1.78 + 1.79 +#endif // nsFind_h__