|
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- |
|
2 * |
|
3 * This Source Code Form is subject to the terms of the Mozilla Public |
|
4 * License, v. 2.0. If a copy of the MPL was not distributed with this |
|
5 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ |
|
6 |
|
7 #ifndef nsWebBrowserFindImpl_h__ |
|
8 #define nsWebBrowserFindImpl_h__ |
|
9 |
|
10 #include "nsIWebBrowserFind.h" |
|
11 |
|
12 #include "nsCOMPtr.h" |
|
13 #include "nsWeakReference.h" |
|
14 |
|
15 #include "nsIFind.h" |
|
16 |
|
17 #include "nsString.h" |
|
18 |
|
19 #define NS_WEB_BROWSER_FIND_CONTRACTID "@mozilla.org/embedcomp/find;1" |
|
20 |
|
21 #define NS_WEB_BROWSER_FIND_CID \ |
|
22 {0x57cf9383, 0x3405, 0x11d5, {0xbe, 0x5b, 0xaa, 0x20, 0xfa, 0x2c, 0xf3, 0x7c}} |
|
23 |
|
24 class nsISelection; |
|
25 class nsIDOMWindow; |
|
26 |
|
27 class nsIDocShell; |
|
28 |
|
29 //***************************************************************************** |
|
30 // class nsWebBrowserFind |
|
31 //***************************************************************************** |
|
32 |
|
33 class nsWebBrowserFind : public nsIWebBrowserFind, |
|
34 public nsIWebBrowserFindInFrames |
|
35 { |
|
36 public: |
|
37 nsWebBrowserFind(); |
|
38 virtual ~nsWebBrowserFind(); |
|
39 |
|
40 // nsISupports |
|
41 NS_DECL_ISUPPORTS |
|
42 |
|
43 // nsIWebBrowserFind |
|
44 NS_DECL_NSIWEBBROWSERFIND |
|
45 |
|
46 // nsIWebBrowserFindInFrames |
|
47 NS_DECL_NSIWEBBROWSERFINDINFRAMES |
|
48 |
|
49 |
|
50 protected: |
|
51 |
|
52 bool CanFindNext() |
|
53 { return mSearchString.Length() != 0; } |
|
54 |
|
55 nsresult SearchInFrame(nsIDOMWindow* aWindow, bool aWrapping, |
|
56 bool* didFind); |
|
57 |
|
58 nsresult OnStartSearchFrame(nsIDOMWindow *aWindow); |
|
59 nsresult OnEndSearchFrame(nsIDOMWindow *aWindow); |
|
60 |
|
61 void GetFrameSelection(nsIDOMWindow* aWindow, nsISelection** aSel); |
|
62 nsresult ClearFrameSelection(nsIDOMWindow *aWindow); |
|
63 |
|
64 nsresult OnFind(nsIDOMWindow *aFoundWindow); |
|
65 |
|
66 nsIDocShell *GetDocShellFromWindow(nsIDOMWindow *inWindow); |
|
67 |
|
68 void SetSelectionAndScroll(nsIDOMWindow* aWindow, |
|
69 nsIDOMRange* aRange); |
|
70 |
|
71 nsresult GetRootNode(nsIDOMDocument* aDomDoc, nsIDOMNode** aNode); |
|
72 nsresult GetSearchLimits(nsIDOMRange* aRange, |
|
73 nsIDOMRange* aStartPt, |
|
74 nsIDOMRange* aEndPt, |
|
75 nsIDOMDocument* aDoc, |
|
76 nsISelection* aSel, |
|
77 bool aWrap); |
|
78 nsresult SetRangeAroundDocument(nsIDOMRange* aSearchRange, |
|
79 nsIDOMRange* aStartPoint, |
|
80 nsIDOMRange* aEndPoint, |
|
81 nsIDOMDocument* aDoc); |
|
82 |
|
83 protected: |
|
84 |
|
85 nsString mSearchString; |
|
86 |
|
87 bool mFindBackwards; |
|
88 bool mWrapFind; |
|
89 bool mEntireWord; |
|
90 bool mMatchCase; |
|
91 |
|
92 bool mSearchSubFrames; |
|
93 bool mSearchParentFrames; |
|
94 |
|
95 nsWeakPtr mCurrentSearchFrame; // who knows if windows can go away during our lifetime, hence weak |
|
96 nsWeakPtr mRootSearchFrame; // who knows if windows can go away during our lifetime, hence weak |
|
97 nsWeakPtr mLastFocusedWindow; // who knows if windows can go away during our lifetime, hence weak |
|
98 }; |
|
99 |
|
100 #endif |