From 49ef0e6172e8124d30eaba78f8d2e70a047835e0 Mon Sep 17 00:00:00 2001 From: "ashuk%eng.sun.com" Date: Fri, 3 Nov 2000 01:27:47 +0000 Subject: [PATCH] author=ashuk Bug=50282,44330,53397 r=a=edburns git-svn-id: svn://10.0.0.236/trunk@82252 18797224-902f-48f8-a5cc-f745e15eee43 --- .../wrapper_native/CurrentPageImpl.java | 21 +++---- .../webclient/src_moz/CurrentPageImpl.cpp | 38 ++++++++--- mozilla/java/webclient/src_moz/nsActions.cpp | 63 +++++++++++++++++++ mozilla/java/webclient/src_moz/nsActions.h | 34 ++++++++++ 4 files changed, 133 insertions(+), 23 deletions(-) diff --git a/mozilla/java/webclient/classes_spec/org/mozilla/webclient/wrapper_native/CurrentPageImpl.java b/mozilla/java/webclient/classes_spec/org/mozilla/webclient/wrapper_native/CurrentPageImpl.java index c34bb73f32e..35eab3ca3da 100644 --- a/mozilla/java/webclient/classes_spec/org/mozilla/webclient/wrapper_native/CurrentPageImpl.java +++ b/mozilla/java/webclient/classes_spec/org/mozilla/webclient/wrapper_native/CurrentPageImpl.java @@ -103,23 +103,18 @@ public void findInPage(String stringToFind, boolean forward, boolean matchCase) ParameterCheck.nonNull(stringToFind); myFactory.throwExceptionIfNotInitialized(); - /* synchronized(myBrowserControl) { + synchronized(myBrowserControl) { nativeFindInPage(nativeWebShell, stringToFind, forward, matchCase); - }*/ - - throw new UnimplementedException("\nUnimplementedException -----\n API Function CurrentPage::findInPage is not implemented in Webclient release 0.9\n"); - + } } public void findNextInPage(boolean forward) { myFactory.throwExceptionIfNotInitialized(); - /* synchronized(myBrowserControl) { + synchronized(myBrowserControl) { nativeFindNextInPage(nativeWebShell, forward); - }*/ - - throw new UnimplementedException("\nUnimplementedException -----\n API Function CurrentPage::findNextInPage is not implemented in Webclient release 0.9\n"); + } } public String getCurrentURL() @@ -216,11 +211,9 @@ public void resetFind() { myFactory.throwExceptionIfNotInitialized(); - /* synchronized(myBrowserControl) { + synchronized(myBrowserControl) { nativeResetFind(nativeWebShell); - }*/ - - throw new UnimplementedException("\nUnimplementedException -----\n API Function CurrentPage::resetFind is not implemented in Webclient release 0.9\n"); + } } public void selectAll() @@ -268,7 +261,7 @@ public static void main(String [] args) Assert.setEnabled(true); Log.setApplicationName("CurrentPageImpl"); Log.setApplicationVersion("0.0"); - Log.setApplicationVersionDate("$Id: CurrentPageImpl.java,v 1.9 2000-11-02 23:33:12 edburns%acm.org Exp $"); + Log.setApplicationVersionDate("$Id: CurrentPageImpl.java,v 1.10 2000-11-03 01:26:59 ashuk%eng.sun.com Exp $"); } diff --git a/mozilla/java/webclient/src_moz/CurrentPageImpl.cpp b/mozilla/java/webclient/src_moz/CurrentPageImpl.cpp index 871b9768c74..5428b408920 100644 --- a/mozilla/java/webclient/src_moz/CurrentPageImpl.cpp +++ b/mozilla/java/webclient/src_moz/CurrentPageImpl.cpp @@ -76,7 +76,12 @@ JNIEXPORT void JNICALL Java_org_mozilla_webclient_wrapper_1native_CurrentPageImp } nsCOMPtr contentViewerEdit(do_QueryInterface(contentViewer)); - rv = contentViewerEdit->CopySelection(); + + if (initContext->initComplete) { + wsCopySelectionEvent * actionEvent = new wsCopySelectionEvent(contentViewerEdit); + PLEvent * event = (PLEvent*) *actionEvent; + ::util_PostEvent(initContext, event); + } } @@ -107,8 +112,8 @@ JNIEXPORT void JNICALL Java_org_mozilla_webclient_wrapper_1native_CurrentPageImp if (initContext->docShell != nsnull) { nsCOMPtr interfaceRequestor(do_QueryInterface(initContext->docShell)); nsCOMPtr url = nsnull; - // PENDING(edburns): commented out for 52883 - // rv = initContext->docShell->GetCurrentURI(getter_AddRefs(url)); + + rv = initContext->webNavigation->GetCurrentURI(getter_AddRefs(url)); if (NS_FAILED(rv) || nsnull == url) { ::util_ThrowExceptionToJava(env, "Exception: NULL URL passed to Find call"); return; @@ -169,7 +174,12 @@ JNIEXPORT void JNICALL Java_org_mozilla_webclient_wrapper_1native_CurrentPageImp // Pass searchContext to findComponent for the actual find call PRBool found = PR_TRUE; - findComponent->FindNext(srchcontext, &found); + + if (initContext->initComplete) { + wsFindEvent * actionEvent = new wsFindEvent(findComponent, srchcontext); + PLEvent * event = (PLEvent*) *actionEvent; + ::util_PostEvent(initContext, event); + } // Save in initContext struct for future findNextInPage calls initContext->searchContext = srchcontext; @@ -212,7 +222,12 @@ JNIEXPORT void JNICALL Java_org_mozilla_webclient_wrapper_1native_CurrentPageImp // Pass searchContext to findComponent for the actual find call PRBool found = PR_TRUE; - findComponent->FindNext(searchContext, &found); + + if (initContext->initComplete) { + wsFindEvent * actionEvent = new wsFindEvent(findComponent, searchContext); + PLEvent * event = (PLEvent*) *actionEvent; + ::util_PostEvent(initContext, event); + } } @@ -348,8 +363,11 @@ JNIEXPORT void JNICALL Java_org_mozilla_webclient_wrapper_1native_CurrentPageImp { WebShellInitContext* initContext = (WebShellInitContext *) webShellPtr; initContext->searchContext = nsnull; + } + + /* * Class: org_mozilla_webclient_wrapper_0005fnative_CurrentPageImpl * Method: nativeSelectAll @@ -369,8 +387,10 @@ JNIEXPORT void JNICALL Java_org_mozilla_webclient_wrapper_1native_CurrentPageImp } nsCOMPtr contentViewerEdit(do_QueryInterface(contentViewer)); - rv = contentViewerEdit->SelectAll(); - if (NS_FAILED(rv)) { - ::util_ThrowExceptionToJava(env, "Exception: can't do SelectAll through contentViewerEdit"); - } + + if (initContext->initComplete) { + wsSelectAllEvent * actionEvent = new wsSelectAllEvent(contentViewerEdit); + PLEvent * event = (PLEvent*) *actionEvent; + ::util_PostEvent(initContext, event); + } } diff --git a/mozilla/java/webclient/src_moz/nsActions.cpp b/mozilla/java/webclient/src_moz/nsActions.cpp index 00ba87c80ba..2e922f8edf2 100644 --- a/mozilla/java/webclient/src_moz/nsActions.cpp +++ b/mozilla/java/webclient/src_moz/nsActions.cpp @@ -39,6 +39,9 @@ #include "nsIURI.h" #include "nsIDocShellTreeItem.h" #include "nsIWebNavigation.h" +#include "nsIFindComponent.h" +#include "nsISearchContext.h" +#include "nsIContentViewerEdit.h" #include "ns_util.h" @@ -751,5 +754,65 @@ wsDeallocateInitContextEvent::handleEvent () } // handleEvent() + +void * +wsFindEvent::handleEvent () +{ + void *result = nsnull; + + if (mFindComponent && mSearchContext) { + PRBool found = PR_TRUE; + nsresult rv = mFindComponent->FindNext(mSearchContext, &found); + result = (void *) rv; + } + return result; +} + +wsFindEvent::wsFindEvent(nsIFindComponent * findcomponent, nsISearchContext * srchcontext) : + nsActionEvent(), + mFindComponent(findcomponent), + mSearchContext(srchcontext) +{ +} + + +void * +wsSelectAllEvent::handleEvent () +{ + void *result = nsnull; + + if (mContentViewerEdit) { + nsresult rv = mContentViewerEdit->SelectAll(); + result = (void *) rv; + } + return result; +} + +wsSelectAllEvent::wsSelectAllEvent(nsIContentViewerEdit * contentViewerEdit) : + nsActionEvent(), + mContentViewerEdit(contentViewerEdit) +{ +} + + +void * +wsCopySelectionEvent::handleEvent () +{ + void *result = nsnull; + + if (mContentViewerEdit) { + nsresult rv = mContentViewerEdit->CopySelection(); + result = (void *) rv; + } + return result; +} + +wsCopySelectionEvent::wsCopySelectionEvent(nsIContentViewerEdit * contentViewerEdit) : + nsActionEvent(), + mContentViewerEdit(contentViewerEdit) +{ +} + + // EOF diff --git a/mozilla/java/webclient/src_moz/nsActions.h b/mozilla/java/webclient/src_moz/nsActions.h index a3dbcc83c0c..4ec4126943f 100644 --- a/mozilla/java/webclient/src_moz/nsActions.h +++ b/mozilla/java/webclient/src_moz/nsActions.h @@ -41,6 +41,9 @@ #include "nsISHistory.h" #include "nsIBaseWindow.h" #include "nsIWebNavigation.h" +#include "nsIFindComponent.h" +#include "nsISearchContext.h" +#include "nsIContentViewerEdit.h" #include "nsString.h" #include "plevent.h" @@ -356,6 +359,37 @@ protected: WebShellInitContext *mInitContext; }; +class wsFindEvent : public nsActionEvent { +public: + wsFindEvent(nsIFindComponent *findComponent, + nsISearchContext * srchcontext); + void * handleEvent (void); + +protected: + nsIFindComponent * mFindComponent; + nsISearchContext * mSearchContext; +}; + + +class wsSelectAllEvent : public nsActionEvent { +public: + wsSelectAllEvent(nsIContentViewerEdit * contentViewerEdit); + void * handleEvent (void); + +protected: + nsIContentViewerEdit * mContentViewerEdit; +}; + + +class wsCopySelectionEvent : public nsActionEvent { +public: + wsCopySelectionEvent(nsIContentViewerEdit * contentViewerEdit); + void * handleEvent (void); + +protected: + nsIContentViewerEdit * mContentViewerEdit; +}; + #endif /* nsActions_h___ */