nsFind.h 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
  2. /* This Source Code Form is subject to the terms of the Mozilla Public
  3. * License, v. 2.0. If a copy of the MPL was not distributed with this
  4. * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
  5. #ifndef nsFind_h__
  6. #define nsFind_h__
  7. #include "nsIFind.h"
  8. #include "nsCOMPtr.h"
  9. #include "nsCycleCollectionParticipant.h"
  10. #include "nsIDOMNode.h"
  11. #include "nsIDOMRange.h"
  12. #include "nsIContentIterator.h"
  13. #include "nsIWordBreaker.h"
  14. class nsIContent;
  15. #define NS_FIND_CONTRACTID "@mozilla.org/embedcomp/rangefind;1"
  16. #define NS_FIND_CID \
  17. {0x471f4944, 0x1dd2, 0x11b2, {0x87, 0xac, 0x90, 0xbe, 0x0a, 0x51, 0xd6, 0x09}}
  18. class nsFindContentIterator;
  19. class nsFind : public nsIFind
  20. {
  21. public:
  22. NS_DECL_CYCLE_COLLECTING_ISUPPORTS
  23. NS_DECL_NSIFIND
  24. NS_DECL_CYCLE_COLLECTION_CLASS(nsFind)
  25. nsFind();
  26. protected:
  27. virtual ~nsFind();
  28. // Parameters set from the interface:
  29. //nsCOMPtr<nsIDOMRange> mRange; // search only in this range
  30. bool mFindBackward;
  31. bool mCaseSensitive;
  32. // Use "find entire words" mode by setting to a word breaker or null, to
  33. // disable "entire words" mode.
  34. nsCOMPtr<nsIWordBreaker> mWordBreaker;
  35. int32_t mIterOffset;
  36. nsCOMPtr<nsIDOMNode> mIterNode;
  37. // Last block parent, so that we will notice crossing block boundaries:
  38. nsCOMPtr<nsIDOMNode> mLastBlockParent;
  39. nsresult GetBlockParent(nsIDOMNode* aNode, nsIDOMNode** aParent);
  40. // Utility routines:
  41. bool IsTextNode(nsIDOMNode* aNode);
  42. bool IsBlockNode(nsIContent* aNode);
  43. bool SkipNode(nsIContent* aNode);
  44. bool IsVisibleNode(nsIDOMNode* aNode);
  45. // Move in the right direction for our search:
  46. nsresult NextNode(nsIDOMRange* aSearchRange,
  47. nsIDOMRange* aStartPoint, nsIDOMRange* aEndPoint,
  48. bool aContinueOk);
  49. // Get the first character from the next node (last if mFindBackward).
  50. char16_t PeekNextChar(nsIDOMRange* aSearchRange,
  51. nsIDOMRange* aStartPoint,
  52. nsIDOMRange* aEndPoint);
  53. // Reset variables before returning -- don't hold any references.
  54. void ResetAll();
  55. // The iterator we use to move through the document:
  56. nsresult InitIterator(nsIDOMNode* aStartNode, int32_t aStartOffset,
  57. nsIDOMNode* aEndNode, int32_t aEndOffset);
  58. RefPtr<nsFindContentIterator> mIterator;
  59. friend class PeekNextCharRestoreState;
  60. };
  61. #endif // nsFind_h__