LCOV - code coverage report
Current view: directory - toolkit/components/typeaheadfind - nsTypeAheadFind.h (source / functions) Found Hit Coverage
Test: app.info Lines: 9 0 0.0 %
Date: 2012-06-02 Functions: 1 0 0.0 %

       1                 : /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
       2                 : /* ***** BEGIN LICENSE BLOCK *****
       3                 :  * Version: MPL 1.1/GPL 2.0/LGPL 2.1
       4                 :  *
       5                 :  * The contents of this file are subject to the Mozilla Public License Version
       6                 :  * 1.1 (the "License"); you may not use this file except in compliance with
       7                 :  * the License. You may obtain a copy of the License at
       8                 :  * http://www.mozilla.org/MPL/
       9                 :  *
      10                 :  * Software distributed under the License is distributed on an "AS IS" basis,
      11                 :  * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
      12                 :  * for the specific language governing rights and limitations under the
      13                 :  * License.
      14                 :  *
      15                 :  * The Original Code is mozilla.org code.
      16                 :  *
      17                 :  * The Initial Developer of the Original Code is
      18                 :  * Netscape Communications Corporation.
      19                 :  * Portions created by the Initial Developer are Copyright (C) 1998
      20                 :  * the Initial Developer. All Rights Reserved.
      21                 :  *
      22                 :  * Contributor(s):
      23                 :  *   Aaron Leventhal (aaronl@netscape.com)
      24                 :  *   Blake Ross      (blake@cs.stanford.edu)
      25                 :  *   Masayuki Nakano (masayuki@d-toybox.com)
      26                 :  *
      27                 :  * Alternatively, the contents of this file may be used under the terms of
      28                 :  * either the GNU General Public License Version 2 or later (the "GPL"), or
      29                 :  * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
      30                 :  * in which case the provisions of the GPL or the LGPL are applicable instead
      31                 :  * of those above. If you wish to allow use of your version of this file only
      32                 :  * under the terms of either the GPL or the LGPL, and not to allow others to
      33                 :  * use your version of this file under the terms of the MPL, indicate your
      34                 :  * decision by deleting the provisions above and replace them with the notice
      35                 :  * and other provisions required by the GPL or the LGPL. If you do not delete
      36                 :  * the provisions above, a recipient may use your version of this file under
      37                 :  * the terms of any one of the MPL, the GPL or the LGPL.
      38                 :  *
      39                 :  * ***** END LICENSE BLOCK ***** */
      40                 : 
      41                 : #include "nsISelectionController.h"
      42                 : #include "nsIController.h"
      43                 : #include "nsIControllers.h"
      44                 : #include "nsIObserver.h"
      45                 : #include "nsUnicharUtils.h"
      46                 : #include "nsIFind.h"
      47                 : #include "nsIWebBrowserFind.h"
      48                 : #include "nsWeakReference.h"
      49                 : #include "nsISelection.h"
      50                 : #include "nsIDOMRange.h"
      51                 : #include "nsIDocShellTreeItem.h"
      52                 : #include "nsITypeAheadFind.h"
      53                 : #include "nsISound.h"
      54                 : 
      55                 : class nsIPresShell;
      56                 : class nsPresContext;
      57                 : 
      58                 : #define TYPEAHEADFIND_NOTFOUND_WAV_URL \
      59                 :         "chrome://global/content/notfound.wav"
      60                 : 
      61                 : class nsTypeAheadFind : public nsITypeAheadFind,
      62                 :                         public nsIObserver,
      63                 :                         public nsSupportsWeakReference
      64                 : {
      65                 : public:
      66                 :   nsTypeAheadFind();
      67                 :   virtual ~nsTypeAheadFind();
      68                 : 
      69                 :   NS_DECL_ISUPPORTS
      70                 :   NS_DECL_NSITYPEAHEADFIND
      71                 :   NS_DECL_NSIOBSERVER
      72                 : 
      73                 : protected:
      74                 :   nsresult PrefsReset();
      75                 : 
      76                 :   void SaveFind();
      77                 :   void PlayNotFoundSound(); 
      78                 :   nsresult GetWebBrowserFind(nsIDocShell *aDocShell,
      79                 :                              nsIWebBrowserFind **aWebBrowserFind);
      80                 : 
      81                 :   void RangeStartsInsideLink(nsIDOMRange *aRange, nsIPresShell *aPresShell, 
      82                 :                              bool *aIsInsideLink, bool *aIsStartingLink);
      83                 : 
      84                 :   void GetSelection(nsIPresShell *aPresShell, nsISelectionController **aSelCon, 
      85                 :                     nsISelection **aDomSel);
      86                 :   bool IsRangeVisible(nsIPresShell *aPresShell, nsPresContext *aPresContext,
      87                 :                         nsIDOMRange *aRange, bool aMustBeVisible, 
      88                 :                         bool aGetTopVisibleLeaf, nsIDOMRange **aNewRange,
      89                 :                         bool *aUsesIndependentSelection);
      90                 :   nsresult FindItNow(nsIPresShell *aPresShell, bool aIsLinksOnly,
      91                 :                      bool aIsFirstVisiblePreferred, bool aFindPrev,
      92                 :                      PRUint16* aResult);
      93                 :   nsresult GetSearchContainers(nsISupports *aContainer,
      94                 :                                nsISelectionController *aSelectionController,
      95                 :                                bool aIsFirstVisiblePreferred,
      96                 :                                bool aFindPrev, nsIPresShell **aPresShell,
      97                 :                                nsPresContext **aPresContext);
      98                 : 
      99                 :   // Get the pres shell from mPresShell and return it only if it is still
     100                 :   // attached to the DOM window.
     101                 :   NS_HIDDEN_(already_AddRefed<nsIPresShell>) GetPresShell();
     102                 : 
     103                 :   // Current find state
     104                 :   nsString mTypeAheadBuffer;
     105                 :   nsCString mNotFoundSoundURL;
     106                 : 
     107                 :   // PRBools are used instead of PRPackedBools because the address of the
     108                 :   // boolean variable is getting passed into a method.
     109                 :   bool mStartLinksOnlyPref;
     110                 :   bool mCaretBrowsingOn;
     111                 :   nsCOMPtr<nsIDOMElement> mFoundLink;     // Most recent elem found, if a link
     112                 :   nsCOMPtr<nsIDOMElement> mFoundEditable; // Most recent elem found, if editable
     113                 :   nsCOMPtr<nsIDOMWindow> mCurrentWindow;
     114                 :   // mLastFindLength is the character length of the last find string.  It is used for
     115                 :   // disabling the "not found" sound when using backspace or delete
     116                 :   PRUint32 mLastFindLength;
     117                 : 
     118                 :   // Sound is played asynchronously on some platforms.
     119                 :   // If we destroy mSoundInterface before sound has played, it won't play
     120                 :   nsCOMPtr<nsISound> mSoundInterface;
     121                 :   bool mIsSoundInitialized;
     122                 :   
     123                 :   // where selection was when user started the find
     124                 :   nsCOMPtr<nsIDOMRange> mStartFindRange;
     125                 :   nsCOMPtr<nsIDOMRange> mSearchRange;
     126                 :   nsCOMPtr<nsIDOMRange> mStartPointRange;
     127                 :   nsCOMPtr<nsIDOMRange> mEndPointRange;
     128                 : 
     129                 :   // Cached useful interfaces
     130                 :   nsCOMPtr<nsIFind> mFind;
     131                 : 
     132                 :   bool mCaseSensitive;
     133                 : 
     134               0 :   bool EnsureFind() {
     135               0 :     if (mFind) {
     136               0 :       return true;
     137                 :     }
     138                 : 
     139               0 :     mFind = do_CreateInstance("@mozilla.org/embedcomp/rangefind;1");
     140               0 :     if (!mFind) {
     141               0 :       return false;
     142                 :     }
     143                 : 
     144               0 :     mFind->SetCaseSensitive(mCaseSensitive);
     145               0 :     mFind->SetWordBreaker(nsnull);
     146                 : 
     147               0 :     return true;
     148                 :   }
     149                 : 
     150                 :   nsCOMPtr<nsIWebBrowserFind> mWebBrowserFind;
     151                 : 
     152                 :   // The focused content window that we're listening to and its cached objects
     153                 :   nsWeakPtr mDocShell;
     154                 :   nsWeakPtr mPresShell;
     155                 :   nsWeakPtr mSelectionController;
     156                 :                                           // Most recent match's controller
     157                 : };

Generated by: LCOV version 1.7