Back to index

lightning-sunbird  0.9+nobinonly
nsWebBrowserFind.h
Go to the documentation of this file.
00001 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
00002  *
00003  * ***** BEGIN LICENSE BLOCK *****
00004  * Version: MPL 1.1/GPL 2.0/LGPL 2.1
00005  *
00006  * The contents of this file are subject to the Mozilla Public License Version
00007  * 1.1 (the "License"); you may not use this file except in compliance with
00008  * the License. You may obtain a copy of the License at
00009  * http://www.mozilla.org/MPL/
00010  *
00011  * Software distributed under the License is distributed on an "AS IS" basis,
00012  * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
00013  * for the specific language governing rights and limitations under the
00014  * License.
00015  *
00016  * The Original Code is the Mozilla browser.
00017  *
00018  * The Initial Developer of the Original Code is
00019  * Netscape Communications, Inc.
00020  * Portions created by the Initial Developer are Copyright (C) 1999
00021  * the Initial Developer. All Rights Reserved.
00022  *
00023  * Contributor(s):
00024  *   Conrad Carlen <ccarlen@netscape.com>
00025  *   Simon Fraser  <sfraser@netscape.com>
00026  *   Akkana Peck   <akkana@netscape.com>
00027  *
00028  * Alternatively, the contents of this file may be used under the terms of
00029  * either the GNU General Public License Version 2 or later (the "GPL"), or
00030  * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
00031  * in which case the provisions of the GPL or the LGPL are applicable instead
00032  * of those above. If you wish to allow use of your version of this file only
00033  * under the terms of either the GPL or the LGPL, and not to allow others to
00034  * use your version of this file under the terms of the MPL, indicate your
00035  * decision by deleting the provisions above and replace them with the notice
00036  * and other provisions required by the GPL or the LGPL. If you do not delete
00037  * the provisions above, a recipient may use your version of this file under
00038  * the terms of any one of the MPL, the GPL or the LGPL.
00039  *
00040  * ***** END LICENSE BLOCK ***** */
00041 
00042 #ifndef nsWebBrowserFindImpl_h__
00043 #define nsWebBrowserFindImpl_h__
00044 
00045 #include "nsIWebBrowserFind.h"
00046 
00047 #include "nsCOMPtr.h"
00048 #include "nsWeakReference.h"
00049 
00050 #include "nsIFind.h"
00051 
00052 #include "nsString.h"
00053 
00054 #define NS_WEB_BROWSER_FIND_CONTRACTID "@mozilla.org/embedcomp/find;1"
00055 
00056 #define NS_WEB_BROWSER_FIND_CID \
00057  {0x57cf9383, 0x3405, 0x11d5, {0xbe, 0x5b, 0xaa, 0x20, 0xfa, 0x2c, 0xf3, 0x7c}}
00058 
00059 class nsISelection;
00060 class nsIDOMWindow;
00061 
00062 class nsIDocShell;
00063 
00064 //*****************************************************************************
00065 // class nsWebBrowserFind
00066 //*****************************************************************************   
00067 
00068 class nsWebBrowserFind  : public nsIWebBrowserFind,
00069                           public nsIWebBrowserFindInFrames
00070 {
00071 public:
00072                 nsWebBrowserFind();
00073     virtual     ~nsWebBrowserFind();
00074     
00075     // nsISupports
00076     NS_DECL_ISUPPORTS
00077     
00078     // nsIWebBrowserFind
00079     NS_DECL_NSIWEBBROWSERFIND
00080                 
00081     // nsIWebBrowserFindInFrames
00082     NS_DECL_NSIWEBBROWSERFINDINFRAMES
00083 
00084 
00085 protected:
00086      
00087     PRBool      CanFindNext()
00088                 { return mSearchString.Length() != 0; }
00089 
00090     nsresult    SearchInFrame(nsIDOMWindow* aWindow, PRBool aWrapping,
00091                               PRBool* didFind);
00092 
00093     nsresult    OnStartSearchFrame(nsIDOMWindow *aWindow);
00094     nsresult    OnEndSearchFrame(nsIDOMWindow *aWindow);
00095 
00096     void        GetFrameSelection(nsIDOMWindow* aWindow, nsISelection** aSel);
00097     nsresult    ClearFrameSelection(nsIDOMWindow *aWindow);
00098     
00099     nsresult    OnFind(nsIDOMWindow *aFoundWindow);
00100     
00101     nsIDocShell *GetDocShellFromWindow(nsIDOMWindow *inWindow);
00102 
00103     void        SetSelectionAndScroll(nsIDOMWindow* aWindow, 
00104                                       nsIDOMRange* aRange);
00105 
00106     nsresult    GetRootNode(nsIDOMDocument* aDomDoc, nsIDOMNode** aNode);
00107     nsresult    GetSearchLimits(nsIDOMRange* aRange,
00108                                 nsIDOMRange* aStartPt,
00109                                 nsIDOMRange* aEndPt,
00110                                 nsIDOMDocument* aDoc,
00111                                 nsISelection* aSel,
00112                                 PRBool aWrap);
00113     nsresult    SetRangeAroundDocument(nsIDOMRange* aSearchRange,
00114                                        nsIDOMRange* aStartPoint,
00115                                        nsIDOMRange* aEndPoint,
00116                                        nsIDOMDocument* aDoc);
00117     
00118 protected:
00119 
00120     nsString        mSearchString;
00121     
00122     PRPackedBool    mFindBackwards;
00123     PRPackedBool    mWrapFind;
00124     PRPackedBool    mEntireWord;
00125     PRPackedBool    mMatchCase;
00126     
00127     PRPackedBool    mSearchSubFrames;
00128     PRPackedBool    mSearchParentFrames;
00129 
00130     nsWeakPtr       mCurrentSearchFrame;    // who knows if windows can go away during our lifetime, hence weak
00131     nsWeakPtr       mRootSearchFrame;       // who knows if windows can go away during our lifetime, hence weak
00132     nsWeakPtr       mLastFocusedWindow;     // who knows if windows can go away during our lifetime, hence weak
00133     
00134     nsCOMPtr<nsIFind> mFind;
00135 };
00136 
00137 #endif