nsWebBrowserFind.h 2.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  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 nsWebBrowserFindImpl_h__
  6. #define nsWebBrowserFindImpl_h__
  7. #include "nsIWebBrowserFind.h"
  8. #include "nsCOMPtr.h"
  9. #include "nsWeakReference.h"
  10. #include "nsIFind.h"
  11. #include "nsString.h"
  12. #define NS_WEB_BROWSER_FIND_CONTRACTID "@mozilla.org/embedcomp/find;1"
  13. #define NS_WEB_BROWSER_FIND_CID \
  14. {0x57cf9383, 0x3405, 0x11d5, {0xbe, 0x5b, 0xaa, 0x20, 0xfa, 0x2c, 0xf3, 0x7c}}
  15. class nsISelection;
  16. class nsIDOMWindow;
  17. class nsIDocShell;
  18. //*****************************************************************************
  19. // class nsWebBrowserFind
  20. //*****************************************************************************
  21. class nsWebBrowserFind
  22. : public nsIWebBrowserFind
  23. , public nsIWebBrowserFindInFrames
  24. {
  25. public:
  26. nsWebBrowserFind();
  27. // nsISupports
  28. NS_DECL_ISUPPORTS
  29. // nsIWebBrowserFind
  30. NS_DECL_NSIWEBBROWSERFIND
  31. // nsIWebBrowserFindInFrames
  32. NS_DECL_NSIWEBBROWSERFINDINFRAMES
  33. protected:
  34. virtual ~nsWebBrowserFind();
  35. bool CanFindNext() { return mSearchString.Length() != 0; }
  36. nsresult SearchInFrame(nsPIDOMWindowOuter* aWindow, bool aWrapping,
  37. bool* aDidFind);
  38. nsresult OnStartSearchFrame(nsPIDOMWindowOuter* aWindow);
  39. nsresult OnEndSearchFrame(nsPIDOMWindowOuter* aWindow);
  40. already_AddRefed<nsISelection> GetFrameSelection(nsPIDOMWindowOuter* aWindow);
  41. nsresult ClearFrameSelection(nsPIDOMWindowOuter* aWindow);
  42. nsresult OnFind(nsPIDOMWindowOuter* aFoundWindow);
  43. void SetSelectionAndScroll(nsPIDOMWindowOuter* aWindow, nsIDOMRange* aRange);
  44. nsresult GetRootNode(nsIDOMDocument* aDomDoc, nsIDOMNode** aNode);
  45. nsresult GetSearchLimits(nsIDOMRange* aRange,
  46. nsIDOMRange* aStartPt, nsIDOMRange* aEndPt,
  47. nsIDOMDocument* aDoc, nsISelection* aSel,
  48. bool aWrap);
  49. nsresult SetRangeAroundDocument(nsIDOMRange* aSearchRange,
  50. nsIDOMRange* aStartPoint,
  51. nsIDOMRange* aEndPoint,
  52. nsIDOMDocument* aDoc);
  53. protected:
  54. nsString mSearchString;
  55. bool mFindBackwards;
  56. bool mWrapFind;
  57. bool mEntireWord;
  58. bool mMatchCase;
  59. bool mSearchSubFrames;
  60. bool mSearchParentFrames;
  61. // These are all weak because who knows if windows can go away during our
  62. // lifetime.
  63. nsWeakPtr mCurrentSearchFrame;
  64. nsWeakPtr mRootSearchFrame;
  65. nsWeakPtr mLastFocusedWindow;
  66. };
  67. #endif