mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-11 12:25:53 +00:00
Add Find, FindNext, and RunUnitTest calls.
This commit is contained in:
parent
2239a8a64e
commit
67e42b6137
@ -45,7 +45,8 @@ interface EditorAppCore : BaseAppCore
|
||||
|
||||
void selectAll();
|
||||
|
||||
void find(in DOMString searchTerm, in boolean matchCase, in boolean searchDown);
|
||||
void find();
|
||||
void findNext();
|
||||
|
||||
void beginBatchChanges();
|
||||
void endBatchChanges();
|
||||
@ -79,4 +80,6 @@ interface EditorAppCore : BaseAppCore
|
||||
void removeWordFromDictionary(in DOMString word);
|
||||
DOMString getPersonalDictionaryWord();
|
||||
void closeSpellChecking();
|
||||
|
||||
void runUnitTests();
|
||||
};
|
||||
|
@ -95,7 +95,9 @@ public:
|
||||
|
||||
NS_IMETHOD SelectAll()=0;
|
||||
|
||||
NS_IMETHOD Find(const nsString& aSearchTerm, PRBool aMatchCase, PRBool aSearchDown)=0;
|
||||
NS_IMETHOD Find()=0;
|
||||
|
||||
NS_IMETHOD FindNext()=0;
|
||||
|
||||
NS_IMETHOD BeginBatchChanges()=0;
|
||||
|
||||
@ -150,6 +152,8 @@ public:
|
||||
NS_IMETHOD GetPersonalDictionaryWord(nsString& aReturn)=0;
|
||||
|
||||
NS_IMETHOD CloseSpellChecking()=0;
|
||||
|
||||
NS_IMETHOD RunUnitTests()=0;
|
||||
};
|
||||
|
||||
|
||||
@ -183,7 +187,8 @@ public:
|
||||
NS_IMETHOD Copy(); \
|
||||
NS_IMETHOD Paste(); \
|
||||
NS_IMETHOD SelectAll(); \
|
||||
NS_IMETHOD Find(const nsString& aSearchTerm, PRBool aMatchCase, PRBool aSearchDown); \
|
||||
NS_IMETHOD Find(); \
|
||||
NS_IMETHOD FindNext(); \
|
||||
NS_IMETHOD BeginBatchChanges(); \
|
||||
NS_IMETHOD EndBatchChanges(); \
|
||||
NS_IMETHOD InsertText(const nsString& aTextToInsert); \
|
||||
@ -211,6 +216,7 @@ public:
|
||||
NS_IMETHOD RemoveWordFromDictionary(const nsString& aWord); \
|
||||
NS_IMETHOD GetPersonalDictionaryWord(nsString& aReturn); \
|
||||
NS_IMETHOD CloseSpellChecking(); \
|
||||
NS_IMETHOD RunUnitTests(); \
|
||||
|
||||
|
||||
|
||||
@ -244,7 +250,8 @@ public:
|
||||
NS_IMETHOD Copy() { return _to Copy(); } \
|
||||
NS_IMETHOD Paste() { return _to Paste(); } \
|
||||
NS_IMETHOD SelectAll() { return _to SelectAll(); } \
|
||||
NS_IMETHOD Find(const nsString& aSearchTerm, PRBool aMatchCase, PRBool aSearchDown) { return _to Find(aSearchTerm, aMatchCase, aSearchDown); } \
|
||||
NS_IMETHOD Find() { return _to Find(); } \
|
||||
NS_IMETHOD FindNext() { return _to FindNext(); } \
|
||||
NS_IMETHOD BeginBatchChanges() { return _to BeginBatchChanges(); } \
|
||||
NS_IMETHOD EndBatchChanges() { return _to EndBatchChanges(); } \
|
||||
NS_IMETHOD InsertText(const nsString& aTextToInsert) { return _to InsertText(aTextToInsert); } \
|
||||
@ -272,6 +279,7 @@ public:
|
||||
NS_IMETHOD RemoveWordFromDictionary(const nsString& aWord) { return _to RemoveWordFromDictionary(aWord); } \
|
||||
NS_IMETHOD GetPersonalDictionaryWord(nsString& aReturn) { return _to GetPersonalDictionaryWord(aReturn); } \
|
||||
NS_IMETHOD CloseSpellChecking() { return _to CloseSpellChecking(); } \
|
||||
NS_IMETHOD RunUnitTests() { return _to RunUnitTests(); } \
|
||||
|
||||
|
||||
extern "C" NS_DOM nsresult NS_InitEditorAppCoreClass(nsIScriptContext *aContext, void **aPrototype);
|
||||
|
@ -59,6 +59,7 @@
|
||||
|
||||
#include "nsIFileWidget.h"
|
||||
#include "nsIDOMToolkitCore.h"
|
||||
#include "nsIFindComponent.h"
|
||||
|
||||
///////////////////////////////////////
|
||||
// Editor Includes
|
||||
@ -649,39 +650,19 @@ nsEditorAppCore::SetEnableCallback(const nsString& aScript)
|
||||
NS_IMETHODIMP
|
||||
nsEditorAppCore::LoadUrl(const nsString& aUrl)
|
||||
{
|
||||
nsCOMPtr<nsIScriptGlobalObject> globalObj( do_QueryInterface(mContentWindow) );
|
||||
if (globalObj)
|
||||
{
|
||||
nsCOMPtr<nsIWebShell> webShell;
|
||||
globalObj->GetWebShell(getter_AddRefs(webShell));
|
||||
if (webShell)
|
||||
webShell->LoadURL(aUrl.GetUnicode());
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
if (!mContentAreaWebShell)
|
||||
return NS_ERROR_NOT_INITIALIZED;
|
||||
|
||||
return mContentAreaWebShell->LoadURL(aUrl.GetUnicode());
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsEditorAppCore::PrepareDocumentForEditing()
|
||||
{
|
||||
nsresult rv = NS_OK;
|
||||
|
||||
NS_PRECONDITION(mContentWindow, "Content window not set yet");
|
||||
if (!mContentWindow)
|
||||
if (!mContentAreaWebShell)
|
||||
return NS_ERROR_NOT_INITIALIZED;
|
||||
|
||||
nsCOMPtr<nsIScriptGlobalObject> globalObj( do_QueryInterface(mContentWindow) );
|
||||
if (!globalObj) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIWebShell> webShell;
|
||||
globalObj->GetWebShell(getter_AddRefs(webShell));
|
||||
if (webShell) {
|
||||
DoEditorMode(webShell);
|
||||
}
|
||||
|
||||
return rv;
|
||||
return DoEditorMode(mContentAreaWebShell);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
@ -706,22 +687,20 @@ nsEditorAppCore::SetContentWindow(nsIDOMWindow* aWin)
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
|
||||
mContentWindow = aWin;
|
||||
//NS_ADDREF(aWin);
|
||||
|
||||
mContentScriptContext = GetScriptContext(aWin);
|
||||
mContentScriptContext = GetScriptContext(mContentWindow); // XXX does this AddRef?
|
||||
|
||||
nsCOMPtr<nsIScriptGlobalObject> globalObj( do_QueryInterface(mContentWindow) );
|
||||
if (!globalObj)
|
||||
nsresult rv;
|
||||
nsCOMPtr<nsIScriptGlobalObject> globalObj = do_QueryInterface(mContentWindow, &rv);
|
||||
if (NS_FAILED(rv) || !globalObj)
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
nsCOMPtr<nsIWebShell> webShell;
|
||||
globalObj->GetWebShell(getter_AddRefs(webShell));
|
||||
if (webShell)
|
||||
{
|
||||
webShell->SetDocLoaderObserver((nsIDocumentLoaderObserver *)this);
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
if (!webShell)
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
mContentAreaWebShell = webShell; // dont AddRef
|
||||
return mContentAreaWebShell->SetDocLoaderObserver((nsIDocumentLoaderObserver *)this);
|
||||
}
|
||||
|
||||
|
||||
@ -1200,11 +1179,43 @@ nsEditorAppCore::InsertText(const nsString& textToInsert)
|
||||
return err;
|
||||
}
|
||||
|
||||
// Both Find and FindNext call through here.
|
||||
NS_IMETHODIMP
|
||||
nsEditorAppCore::DoFind(PRBool aFindNext)
|
||||
{
|
||||
if (!mContentAreaWebShell)
|
||||
return NS_ERROR_NOT_INITIALIZED;
|
||||
|
||||
// Get find component.
|
||||
nsIFindComponent *finder;
|
||||
nsresult rv = nsServiceManager::GetService( NS_IFINDCOMPONENT_PROGID,
|
||||
nsIFindComponent::GetIID(),
|
||||
(nsISupports**)&finder );
|
||||
if ( NS_SUCCEEDED(rv) && finder )
|
||||
{
|
||||
rv = (aFindNext) ? finder->FindNext(mContentAreaWebShell) : finder->Find(mContentAreaWebShell);
|
||||
|
||||
// Release the service.
|
||||
nsServiceManager::ReleaseService( NS_IFINDCOMPONENT_PROGID, finder );
|
||||
}
|
||||
else
|
||||
{
|
||||
NS_ASSERTION(0, "GetService failed for find component.");
|
||||
}
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsEditorAppCore::Find(const nsString& aSearchTerm, PRBool aMatchCase, PRBool aSearchDown)
|
||||
nsEditorAppCore::Find()
|
||||
{
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
return DoFind(PR_FALSE);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsEditorAppCore::FindNext()
|
||||
{
|
||||
return DoFind(PR_TRUE);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
@ -1879,6 +1890,10 @@ nsEditorAppCore::DeleteSuggestedWordList()
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
#ifdef XP_MAC
|
||||
#pragma mark -
|
||||
#endif
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsEditorAppCore::BeginBatchChanges()
|
||||
{
|
||||
@ -1970,6 +1985,24 @@ nsEditorAppCore::ExecuteScript(nsIScriptContext * aContext, const nsString& aScr
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsEditorAppCore::RunUnitTests()
|
||||
{
|
||||
PRInt32 numTests = 0;
|
||||
PRInt32 numTestsFailed = 0;
|
||||
|
||||
nsresult err = NS_OK;
|
||||
nsCOMPtr<nsIEditor> editor = do_QueryInterface(mEditor);
|
||||
if (editor)
|
||||
err = editor->DebugUnitTests(&numTests, &numTestsFailed);
|
||||
|
||||
#ifdef APP_DEBUG
|
||||
printf("\nRan %ld tests, of which %ld failed\n", numTests, numTestsFailed);
|
||||
#endif
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
#ifdef XP_MAC
|
||||
#pragma mark -
|
||||
#endif
|
||||
|
@ -132,7 +132,8 @@ class nsEditorAppCore : public nsBaseAppCore,
|
||||
NS_IMETHOD SelectAll();
|
||||
|
||||
NS_IMETHOD InsertText(const nsString& textToInsert);
|
||||
NS_IMETHOD Find(const nsString& aSearchTerm, PRBool aMatchCase, PRBool aSearchDown);
|
||||
NS_IMETHOD Find();
|
||||
NS_IMETHOD FindNext();
|
||||
|
||||
// These next two will be replaced with the SetElementProperties
|
||||
NS_IMETHOD InsertLink();
|
||||
@ -155,6 +156,8 @@ class nsEditorAppCore : public nsBaseAppCore,
|
||||
NS_IMETHOD BeginBatchChanges();
|
||||
NS_IMETHOD EndBatchChanges();
|
||||
|
||||
NS_IMETHOD RunUnitTests();
|
||||
|
||||
// nsIDocumentLoaderObserver
|
||||
NS_IMETHOD OnStartDocumentLoad(nsIDocumentLoader* loader, nsIURL* aURL, const char* aCommand);
|
||||
NS_IMETHOD OnEndDocumentLoad(nsIDocumentLoader* loader, nsIURL *aUrl, PRInt32 aStatus);
|
||||
@ -187,6 +190,7 @@ class nsEditorAppCore : public nsBaseAppCore,
|
||||
void SetButtonImage(nsIDOMNode * aParentNode, PRInt32 aBtnNum, const nsString &aResName);
|
||||
NS_IMETHOD CreateWindowWithURL(const char* urlStr);
|
||||
NS_IMETHOD PrepareDocumentForEditing();
|
||||
NS_IMETHOD DoFind(PRBool aFindNext);
|
||||
|
||||
nsString mEnableScript;
|
||||
nsString mDisableScript;
|
||||
@ -194,11 +198,12 @@ class nsEditorAppCore : public nsBaseAppCore,
|
||||
nsIScriptContext *mToolbarScriptContext;
|
||||
nsIScriptContext *mContentScriptContext;
|
||||
|
||||
nsIDOMWindow *mToolbarWindow; // weak reference
|
||||
nsIDOMWindow *mContentWindow; // weak reference
|
||||
nsIDOMWindow *mToolbarWindow; // weak reference
|
||||
nsIDOMWindow *mContentWindow; // weak reference
|
||||
|
||||
nsIWebShellWindow *mWebShellWin; // weak reference
|
||||
nsIWebShell *mWebShell; // weak reference
|
||||
nsIWebShellWindow *mWebShellWin; // weak reference
|
||||
nsIWebShell *mWebShell; // weak reference
|
||||
nsIWebShell *mContentAreaWebShell; // weak reference
|
||||
|
||||
EEditorType mEditorType;
|
||||
nsString mEditorTypeString; // string which describes which editor type will be instantiated (lowercased)
|
||||
|
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue
Block a user