PageRenderTime 20ms CodeModel.GetById 14ms app.highlight 3ms RepoModel.GetById 1ms app.codeStats 1ms

/embedding/components/find/src/nsWebBrowserFind.h

http://github.com/zpao/v8monkey
C Header | 137 lines | 60 code | 31 blank | 46 comment | 1 complexity | 4be6c5ddb606ceeeb1442c0565cfa7d1 MD5 | raw file
  1/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
  2 *
  3 * ***** BEGIN LICENSE BLOCK *****
  4 * Version: MPL 1.1/GPL 2.0/LGPL 2.1
  5 *
  6 * The contents of this file are subject to the Mozilla Public License Version
  7 * 1.1 (the "License"); you may not use this file except in compliance with
  8 * the License. You may obtain a copy of the License at
  9 * http://www.mozilla.org/MPL/
 10 *
 11 * Software distributed under the License is distributed on an "AS IS" basis,
 12 * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
 13 * for the specific language governing rights and limitations under the
 14 * License.
 15 *
 16 * The Original Code is the Mozilla browser.
 17 *
 18 * The Initial Developer of the Original Code is
 19 * Netscape Communications, Inc.
 20 * Portions created by the Initial Developer are Copyright (C) 1999
 21 * the Initial Developer. All Rights Reserved.
 22 *
 23 * Contributor(s):
 24 *   Conrad Carlen <ccarlen@netscape.com>
 25 *   Simon Fraser  <sfraser@netscape.com>
 26 *   Akkana Peck   <akkana@netscape.com>
 27 *
 28 * Alternatively, the contents of this file may be used under the terms of
 29 * either the GNU General Public License Version 2 or later (the "GPL"), or
 30 * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
 31 * in which case the provisions of the GPL or the LGPL are applicable instead
 32 * of those above. If you wish to allow use of your version of this file only
 33 * under the terms of either the GPL or the LGPL, and not to allow others to
 34 * use your version of this file under the terms of the MPL, indicate your
 35 * decision by deleting the provisions above and replace them with the notice
 36 * and other provisions required by the GPL or the LGPL. If you do not delete
 37 * the provisions above, a recipient may use your version of this file under
 38 * the terms of any one of the MPL, the GPL or the LGPL.
 39 *
 40 * ***** END LICENSE BLOCK ***** */
 41
 42#ifndef nsWebBrowserFindImpl_h__
 43#define nsWebBrowserFindImpl_h__
 44
 45#include "nsIWebBrowserFind.h"
 46
 47#include "nsCOMPtr.h"
 48#include "nsWeakReference.h"
 49
 50#include "nsIFind.h"
 51
 52#include "nsString.h"
 53
 54#define NS_WEB_BROWSER_FIND_CONTRACTID "@mozilla.org/embedcomp/find;1"
 55
 56#define NS_WEB_BROWSER_FIND_CID \
 57 {0x57cf9383, 0x3405, 0x11d5, {0xbe, 0x5b, 0xaa, 0x20, 0xfa, 0x2c, 0xf3, 0x7c}}
 58
 59class nsISelection;
 60class nsIDOMWindow;
 61
 62class nsIDocShell;
 63
 64//*****************************************************************************
 65// class nsWebBrowserFind
 66//*****************************************************************************   
 67
 68class nsWebBrowserFind  : public nsIWebBrowserFind,
 69                          public nsIWebBrowserFindInFrames
 70{
 71public:
 72                nsWebBrowserFind();
 73    virtual     ~nsWebBrowserFind();
 74    
 75    // nsISupports
 76    NS_DECL_ISUPPORTS
 77    
 78    // nsIWebBrowserFind
 79    NS_DECL_NSIWEBBROWSERFIND
 80                
 81    // nsIWebBrowserFindInFrames
 82    NS_DECL_NSIWEBBROWSERFINDINFRAMES
 83
 84
 85protected:
 86     
 87    bool        CanFindNext()
 88                { return mSearchString.Length() != 0; }
 89
 90    nsresult    SearchInFrame(nsIDOMWindow* aWindow, bool aWrapping,
 91                              bool* didFind);
 92
 93    nsresult    OnStartSearchFrame(nsIDOMWindow *aWindow);
 94    nsresult    OnEndSearchFrame(nsIDOMWindow *aWindow);
 95
 96    void        GetFrameSelection(nsIDOMWindow* aWindow, nsISelection** aSel);
 97    nsresult    ClearFrameSelection(nsIDOMWindow *aWindow);
 98    
 99    nsresult    OnFind(nsIDOMWindow *aFoundWindow);
100    
101    nsIDocShell *GetDocShellFromWindow(nsIDOMWindow *inWindow);
102
103    void        SetSelectionAndScroll(nsIDOMWindow* aWindow, 
104                                      nsIDOMRange* aRange);
105
106    nsresult    GetRootNode(nsIDOMDocument* aDomDoc, nsIDOMNode** aNode);
107    nsresult    GetSearchLimits(nsIDOMRange* aRange,
108                                nsIDOMRange* aStartPt,
109                                nsIDOMRange* aEndPt,
110                                nsIDOMDocument* aDoc,
111                                nsISelection* aSel,
112                                bool aWrap);
113    nsresult    SetRangeAroundDocument(nsIDOMRange* aSearchRange,
114                                       nsIDOMRange* aStartPoint,
115                                       nsIDOMRange* aEndPoint,
116                                       nsIDOMDocument* aDoc);
117    
118protected:
119
120    nsString        mSearchString;
121    
122    bool            mFindBackwards;
123    bool            mWrapFind;
124    bool            mEntireWord;
125    bool            mMatchCase;
126    
127    bool            mSearchSubFrames;
128    bool            mSearchParentFrames;
129
130    nsWeakPtr       mCurrentSearchFrame;    // who knows if windows can go away during our lifetime, hence weak
131    nsWeakPtr       mRootSearchFrame;       // who knows if windows can go away during our lifetime, hence weak
132    nsWeakPtr       mLastFocusedWindow;     // who knows if windows can go away during our lifetime, hence weak
133    
134    nsCOMPtr<nsIFind> mFind;
135};
136
137#endif