зеркало из https://github.com/mozilla/gecko-dev.git
fix for bug 74908 r=jag, sr=shaver
the find component shouldn't be an appshell component, so it doesn't need to be loaded at startup.
This commit is contained in:
Родитель
37a9ef2da3
Коммит
96d16a52dc
|
@ -20,8 +20,6 @@
|
|||
* Contributor(s):
|
||||
*/
|
||||
|
||||
#include "nsIAppShellComponent.idl"
|
||||
|
||||
#include "nsIEditorShell.idl"
|
||||
|
||||
%{C++
|
||||
|
@ -29,102 +27,101 @@ class nsIDOMWindowInternal;
|
|||
class nsIEditorShell;
|
||||
%}
|
||||
|
||||
/*----------------------------- nsIFindComponent -------------------------------
|
||||
| This file describes the interface for Mozilla's pluggable "find" component |
|
||||
| that provides the implementation of the browser's "find in document" |
|
||||
| function (and perhaps will be generalized to support similar searching in |
|
||||
| other contexts). |
|
||||
| |
|
||||
| The component itself is a singleton (one per executing application). To |
|
||||
| handle searching on a per-document basis, this interface supplies a |
|
||||
| CreateContext() function that creates a search context (generally, on a |
|
||||
| per document, and thus per-browser-window, basis). |
|
||||
| |
|
||||
| The component itself will "remember" the last string searched (via any |
|
||||
| context). This way, a search in a new context (browser window) will be |
|
||||
| able to search for the same string (by default). |
|
||||
| |
|
||||
| Clients (e.g., the browser window object) will generally use this interface |
|
||||
| in this manner: |
|
||||
| 1. Hold a reference to the singleton "find component". |
|
||||
| 2. On initial search, ask that component to create a search "context." |
|
||||
| 3. Reset the context whenever the underlying web shell changes (but since |
|
||||
| a browser will usually reuse a single web shell, this won't be of |
|
||||
| concern except in obscure cases). |
|
||||
| 4. Forward "find" and "find next" requests to the component, along |
|
||||
| with the appropriate search context object. |
|
||||
| 5. Release() the search context object and the find component when the |
|
||||
| browser window closes. |
|
||||
------------------------------------------------------------------------------*/
|
||||
[scriptable, uuid(a6cf90ee-15b3-11d2-932e-00805f8add32)]
|
||||
interface nsIFindComponent : nsIAppShellComponent
|
||||
/*----------------------------- nsIFindComponent ------------------------------
|
||||
| This file describes the interface for Mozilla's pluggable "find" component |
|
||||
| that provides the implementation of the browser's "find in document" |
|
||||
| function (and perhaps will be generalized to support similar searching in |
|
||||
| other contexts). |
|
||||
| |
|
||||
| The component itself is a singleton (one per executing application). To |
|
||||
| handle searching on a per-document basis, this interface supplies a |
|
||||
| CreateContext() function that creates a search context (generally, on a |
|
||||
| per document, and thus per-browser-window, basis). |
|
||||
| |
|
||||
| The component itself will "remember" the last string searched (via any |
|
||||
| context). This way, a search in a new context (browser window) will be |
|
||||
| able to search for the same string (by default). |
|
||||
| |
|
||||
| Clients (e.g., the browser window object) will generally use this interface |
|
||||
| in this manner: |
|
||||
| 1. Hold a reference to the singleton "find component". |
|
||||
| 2. On initial search, ask that component to create a search "context." |
|
||||
| 3. Reset the context whenever the underlying web shell changes (but since |
|
||||
| a browser will usually reuse a single web shell, this won't be of |
|
||||
| concern except in obscure cases). |
|
||||
| 4. Forward "find" and "find next" requests to the component, along |
|
||||
| with the appropriate search context object. |
|
||||
| 5. Release() the search context object and the find component when the |
|
||||
| browser window closes. |
|
||||
-----------------------------------------------------------------------------*/
|
||||
[scriptable, uuid(a6cf90ee-15b3-11d2-932e-00805f8add32)]interface nsIFindComponent : nsISupports
|
||||
{
|
||||
|
||||
/*---------------------------- CreateContext -------------------------------
|
||||
| Create a "search context" for the given document. Subsequent Find and |
|
||||
| FindNext requests that provide the returned search context will find |
|
||||
| the appropriate search string in aWebShell. |
|
||||
| |
|
||||
| The editor that's passed in is only required for replace. If you pass |
|
||||
| in a read-only webshell, then pass nsnull for the editor. |
|
||||
| |
|
||||
| The result is of the xpcom equivalent of an opaque type. It's true type |
|
||||
| is defined by the implementation of this interface. Clients ought never |
|
||||
| have to do QueryInterface to convert this to something more elaborate. |
|
||||
| Clients do have to call Release() when they're no longer interested in |
|
||||
| this search context. |
|
||||
--------------------------------------------------------------------------*/
|
||||
/*---------------------------- CreateContext ------------------------------
|
||||
| Create a "search context" for the given document. Subsequent Find and |
|
||||
| FindNext requests that provide the returned search context will find |
|
||||
| the appropriate search string in aWebShell. |
|
||||
| |
|
||||
| The editor that's passed in is only required for replace. If you pass |
|
||||
| in a read-only webshell, then pass nsnull for the editor. |
|
||||
| |
|
||||
| The result is of the xpcom equivalent of an opaque type. It's true type|
|
||||
| is defined by the implementation of this interface. Clients ought never|
|
||||
| have to do QueryInterface to convert this to something more elaborate. |
|
||||
| Clients do have to call Release() when they're no longer interested in |
|
||||
| this search context. |
|
||||
-------------------------------------------------------------------------*/
|
||||
nsISupports createContext(in nsIDOMWindowInternal aWindow, in nsIEditorShell aEditor);
|
||||
|
||||
/*--------------------------------- Find -----------------------------------
|
||||
| Finds the "first" occurrence of a string in the given search context |
|
||||
| (i.e., document). |
|
||||
| |
|
||||
| Please note that you don't provide the string to search for! |
|
||||
| |
|
||||
| This might seem odd, but that's the way it's designed. Prompting the |
|
||||
| user for the string (and for various search options such as "ignore |
|
||||
| case" and "search backward") is up to the implementation of this |
|
||||
| component. |
|
||||
--------------------------------------------------------------------------*/
|
||||
/*--------------------------------- Find ----------------------------------
|
||||
| Finds the "first" occurrence of a string in the given search context |
|
||||
| (i.e., document). |
|
||||
| |
|
||||
| Please note that you don't provide the string to search for! |
|
||||
| |
|
||||
| This might seem odd, but that's the way it's designed. Prompting the |
|
||||
| user for the string (and for various search options such as "ignore |
|
||||
| case" and "search backward") is up to the implementation of this |
|
||||
| component. |
|
||||
-------------------------------------------------------------------------*/
|
||||
boolean find( in nsISupports aContext );
|
||||
|
||||
/*------------------------------- FindNext ---------------------------------
|
||||
| Finds the next occurrence (of the previously searched for string) in |
|
||||
| the given search context (document). |
|
||||
| |
|
||||
| If no previous Find has been performed with this context, then the |
|
||||
| find component will use the last find performed for any context. |
|
||||
--------------------------------------------------------------------------*/
|
||||
/*------------------------------- FindNext --------------------------------
|
||||
| Finds the next occurrence (of the previously searched for string) in |
|
||||
| the given search context (document). |
|
||||
| |
|
||||
| If no previous Find has been performed with this context, then the |
|
||||
| find component will use the last find performed for any context. |
|
||||
-------------------------------------------------------------------------*/
|
||||
boolean findNext( in nsISupports aContext );
|
||||
|
||||
/*--------------------------------- Replace --------------------------------
|
||||
| Replace the currently selected text. It is intended that the string used |
|
||||
| for replacement is sourced internally to the component (e.g. from a |
|
||||
| search/replace dialog). |
|
||||
| |
|
||||
| Returns an error if the current context does not allow replacement. |
|
||||
--------------------------------------------------------------------------*/
|
||||
/*--------------------------------- Replace -------------------------------
|
||||
| Replace the currently selected text. It is intended that the string used|
|
||||
| for replacement is sourced internally to the component (e.g. from a |
|
||||
| search/replace dialog). |
|
||||
| |
|
||||
| Returns an error if the current context does not allow replacement. |
|
||||
-------------------------------------------------------------------------*/
|
||||
void replace( in nsISupports aContext );
|
||||
|
||||
/*------------------------------- ReplaceNext ------------------------------
|
||||
| Replaces the currently selected text, then searches for next occurrence |
|
||||
| (of previously searched for string) in the given search context |
|
||||
| (document). If allOccurrences is TRUE, all occurrences of previously |
|
||||
/*------------------------------- ReplaceNext -----------------------------
|
||||
| Replaces the currently selected text, then searches for next occurrence |
|
||||
| (of previously searched for string) in the given search context |
|
||||
| (document). If allOccurrences is TRUE, all occurrences of previously |
|
||||
| searched for string will be replaced during this method call.
|
||||
--------------------------------------------------------------------------*/
|
||||
-------------------------------------------------------------------------*/
|
||||
boolean replaceNext( in nsISupports aContext, in boolean allOccurrences );
|
||||
|
||||
/*----------------------------- ResetContext -------------------------------
|
||||
| Reset the given search context to search a new web shell. Generally, |
|
||||
| this will be the equivalent of calling Release() on the old context and |
|
||||
| then creating a new one for aNewWebShell. |
|
||||
/*----------------------------- ResetContext ------------------------------
|
||||
| Reset the given search context to search a new web shell. Generally, |
|
||||
| this will be the equivalent of calling Release() on the old context and |
|
||||
| then creating a new one for aNewWebShell. |
|
||||
--------------------------------------------------------------------------*/
|
||||
void resetContext(in nsISupports aContext, in nsIDOMWindowInternal aWindow,
|
||||
in nsIEditorShell aEditor );
|
||||
};
|
||||
|
||||
%{C++
|
||||
#define NS_IFINDCOMPONENT_CONTRACTID NS_IAPPSHELLCOMPONENT_CONTRACTID "/find;1"
|
||||
#define NS_IFINDCOMPONENT_CONTRACTID "@mozilla.org/appshell/component/find;1"
|
||||
#define NS_IFINDCOMPONENT_CLASSNAME "Mozilla Find Component"
|
||||
%}
|
||||
|
|
|
@ -26,8 +26,9 @@
|
|||
#include "nsCOMPtr.h"
|
||||
#include "nsString.h"
|
||||
#include "pratom.h"
|
||||
#include "prio.h"
|
||||
#include "prprf.h"
|
||||
|
||||
#include "nsIAppShellService.h"
|
||||
#include "nsIDOMDocument.h"
|
||||
#include "nsIDocument.h"
|
||||
#include "nsITextServicesDocument.h"
|
||||
|
@ -35,10 +36,11 @@
|
|||
#include "nsIDocShell.h"
|
||||
#include "nsIPresShell.h"
|
||||
#include "nsIContent.h"
|
||||
#include "nsIURL.h"
|
||||
#include "nsIFactory.h"
|
||||
#include "nsIServiceManager.h"
|
||||
#include "nsIDOMWindowInternal.h"
|
||||
|
||||
#include "nsIURL.h"
|
||||
|
||||
#include "nsIServiceManager.h"
|
||||
#include "nsIScriptGlobalObject.h"
|
||||
|
||||
#include "nsISound.h"
|
||||
|
@ -48,9 +50,13 @@
|
|||
#include "nsIFindAndReplace.h"
|
||||
#include "nsIEditor.h"
|
||||
|
||||
#include "nsIGenericFactory.h"
|
||||
|
||||
#ifdef DEBUG
|
||||
#define DEBUG_FIND
|
||||
#define DEBUG_PRINTF PR_fprintf
|
||||
#else
|
||||
#define DEBUG_PRINTF (void)
|
||||
#endif
|
||||
|
||||
|
||||
|
@ -419,6 +425,8 @@ nsFindComponent::nsFindComponent()
|
|||
// Initialize "last" stuff from prefs, if we wanted to be really clever...
|
||||
}
|
||||
|
||||
NS_IMPL_ISUPPORTS1(nsFindComponent, nsIFindComponent)
|
||||
|
||||
// dtor
|
||||
nsFindComponent::~nsFindComponent()
|
||||
{
|
||||
|
@ -540,7 +548,7 @@ nsFindComponent::Find(nsISupports *aContext, PRBool *aDidFind)
|
|||
}
|
||||
}
|
||||
|
||||
if (aContext && GetAppShell())
|
||||
if (aContext)
|
||||
{
|
||||
nsCOMPtr<nsISearchContext> context = do_QueryInterface( aContext, &rv );
|
||||
if (NS_FAILED(rv))
|
||||
|
@ -628,7 +636,7 @@ nsFindComponent::Replace( nsISupports *aContext )
|
|||
}
|
||||
}
|
||||
|
||||
if (aContext && GetAppShell())
|
||||
if (aContext)
|
||||
{
|
||||
nsCOMPtr<nsISearchContext> context = do_QueryInterface( aContext, &rv );
|
||||
if (NS_FAILED(rv))
|
||||
|
@ -698,7 +706,16 @@ nsFindComponent::ResetContext( nsISupports *aContext,
|
|||
// nsFindComponent::Context implementation...
|
||||
NS_IMPL_ISUPPORTS1( nsFindComponent::Context, nsISearchContext)
|
||||
|
||||
NS_IMPL_IAPPSHELLCOMPONENT( nsFindComponent, nsIFindComponent, NS_IFINDCOMPONENT_CONTRACTID, 0 )
|
||||
NS_GENERIC_FACTORY_CONSTRUCTOR(nsFindComponent)
|
||||
|
||||
static nsModuleComponentInfo components[] = {
|
||||
{ NS_IFINDCOMPONENT_CLASSNAME,
|
||||
NS_FINDCOMPONENT_CID,
|
||||
NS_IFINDCOMPONENT_CONTRACTID,
|
||||
nsFindComponentConstructor}
|
||||
};
|
||||
|
||||
NS_IMPL_NSGETMODULE("nsFindComponent", components)
|
||||
|
||||
#ifdef XP_WIN32
|
||||
//in addition to returning a version number for this module,
|
||||
|
|
|
@ -19,7 +19,6 @@
|
|||
*
|
||||
* Contributor(s):
|
||||
*/
|
||||
#include "nsIAppShellComponentImpl.h"
|
||||
#include "nsIFindComponent.h"
|
||||
#include "nsISearchContext.h"
|
||||
#include "nsCOMPtr.h"
|
||||
|
@ -31,7 +30,7 @@ class nsITextServicesDocument;
|
|||
#define NS_FINDCOMPONENT_CID \
|
||||
{ 0x4aa267a0, 0xf81d, 0x11d2, { 0x80, 0x67, 0x0, 0x60, 0x8, 0x11, 0xa9, 0xc3} }
|
||||
|
||||
class nsFindComponent : public nsIFindComponent, public nsAppShellComponentImpl
|
||||
class nsFindComponent : public nsIFindComponent
|
||||
{
|
||||
public:
|
||||
NS_DEFINE_STATIC_CID_ACCESSOR( NS_FINDCOMPONENT_CID );
|
||||
|
@ -43,9 +42,6 @@ public:
|
|||
// This class implements the nsISupports interface functions.
|
||||
NS_DECL_ISUPPORTS
|
||||
|
||||
// This class implements the nsIAppShellComponent interface functions.
|
||||
NS_DECL_NSIAPPSHELLCOMPONENT
|
||||
|
||||
// This class implements the nsIFindComponent interface functions.
|
||||
NS_DECL_NSIFINDCOMPONENT
|
||||
|
||||
|
@ -92,5 +88,4 @@ protected:
|
|||
PRBool mLastCaseSensitive;
|
||||
PRBool mLastSearchBackwards;
|
||||
PRBool mLastWrapSearch;
|
||||
nsInstanceCounter mInstanceCounter;
|
||||
}; // nsFindComponent
|
||||
|
|
Загрузка…
Ссылка в новой задаче