Line data Source code
1 : /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 : /* vim: set ts=8 sts=2 et sw=2 tw=80: */
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
34 : : public nsIWebBrowserFind
35 : , public nsIWebBrowserFindInFrames
36 : {
37 : public:
38 : nsWebBrowserFind();
39 :
40 : // nsISupports
41 : NS_DECL_ISUPPORTS
42 :
43 : // nsIWebBrowserFind
44 : NS_DECL_NSIWEBBROWSERFIND
45 :
46 : // nsIWebBrowserFindInFrames
47 : NS_DECL_NSIWEBBROWSERFINDINFRAMES
48 :
49 : protected:
50 : virtual ~nsWebBrowserFind();
51 :
52 0 : bool CanFindNext() { return mSearchString.Length() != 0; }
53 :
54 : nsresult SearchInFrame(nsPIDOMWindowOuter* aWindow, bool aWrapping,
55 : bool* aDidFind);
56 :
57 : nsresult OnStartSearchFrame(nsPIDOMWindowOuter* aWindow);
58 : nsresult OnEndSearchFrame(nsPIDOMWindowOuter* aWindow);
59 :
60 : already_AddRefed<nsISelection> GetFrameSelection(nsPIDOMWindowOuter* aWindow);
61 : nsresult ClearFrameSelection(nsPIDOMWindowOuter* aWindow);
62 :
63 : nsresult OnFind(nsPIDOMWindowOuter* aFoundWindow);
64 :
65 : void SetSelectionAndScroll(nsPIDOMWindowOuter* aWindow, nsIDOMRange* aRange);
66 :
67 : nsresult GetRootNode(nsIDOMDocument* aDomDoc, nsIDOMNode** aNode);
68 : nsresult GetSearchLimits(nsIDOMRange* aRange,
69 : nsIDOMRange* aStartPt, nsIDOMRange* aEndPt,
70 : nsIDOMDocument* aDoc, nsISelection* aSel,
71 : bool aWrap);
72 : nsresult SetRangeAroundDocument(nsIDOMRange* aSearchRange,
73 : nsIDOMRange* aStartPoint,
74 : nsIDOMRange* aEndPoint,
75 : nsIDOMDocument* aDoc);
76 :
77 : protected:
78 : nsString mSearchString;
79 :
80 : bool mFindBackwards;
81 : bool mWrapFind;
82 : bool mEntireWord;
83 : bool mMatchCase;
84 :
85 : bool mSearchSubFrames;
86 : bool mSearchParentFrames;
87 :
88 : // These are all weak because who knows if windows can go away during our
89 : // lifetime.
90 : nsWeakPtr mCurrentSearchFrame;
91 : nsWeakPtr mRootSearchFrame;
92 : nsWeakPtr mLastFocusedWindow;
93 : };
94 :
95 : #endif
|