diff --git a/java/webclient/build.xml b/java/webclient/build.xml index b353927d1a0..a511327d4ff 100644 --- a/java/webclient/build.xml +++ b/java/webclient/build.xml @@ -96,10 +96,8 @@ executable="gmake"/> - - - + @@ -182,10 +180,8 @@ - - - + @@ -195,10 +191,8 @@ failonerror="yes"> - - - + diff --git a/java/webclient/src_moz/CBrowserContainer.cpp b/java/webclient/src_moz/CBrowserContainer.cpp index 3a220007317..404f419b5cc 100644 --- a/java/webclient/src_moz/CBrowserContainer.cpp +++ b/java/webclient/src_moz/CBrowserContainer.cpp @@ -58,7 +58,7 @@ CBrowserContainer::CBrowserContainer(nsIWebBrowser *pOwner, JNIEnv *env, mDomEventTarget(nsnull), inverseDepth(-1), properties(nsnull), currentDOMEvent(nsnull) { - NS_INIT_REFCNT(); + NS_INIT_ISUPPORTS(); // initialize the string constants (including properties keys) if (!util_StringConstantsAreInitialized()) { util_InitStringConstants(); diff --git a/java/webclient/src_moz/CurrentPageActionEvents.cpp b/java/webclient/src_moz/CurrentPageActionEvents.cpp index cecdbc54718..630546d8c30 100644 --- a/java/webclient/src_moz/CurrentPageActionEvents.cpp +++ b/java/webclient/src_moz/CurrentPageActionEvents.cpp @@ -33,19 +33,19 @@ #include "CurrentPageActionEvents.h" #include "nsIDOMWindowInternal.h" -#include "nsISearchContext.h" #include "nsIDocShell.h" #include "nsIContentViewer.h" #include "nsIContentViewer.h" #include "nsIContentViewerEdit.h" #include "nsIInterfaceRequestor.h" +#include "nsIInterfaceRequestorUtils.h" #include "nsCOMPtr.h" #include "nsIServiceManager.h" #include "nsIURI.h" #include "nsIHistoryEntry.h" #include "nsString.h" #include "nsReadableUtils.h" -#include "nsIFindComponent.h" +#include "nsIWebBrowserFind.h" wsCopySelectionEvent::wsCopySelectionEvent(WebShellInitContext *yourInitContext) : nsActionEvent(), @@ -102,99 +102,48 @@ wsFindEvent::handleEvent () JNIEnv *env = (JNIEnv *) JNU_GetEnv(gVm, JNI_VERSION); if (mInitContext) { - //First get the FindComponent object - nsCOMPtr findComponent; - findComponent = do_GetService(NS_IFINDCOMPONENT_CONTRACTID, &rv); + //First get the nsIWebBrowserFind object + nsCOMPtr findComponent; + nsCOMPtr + findRequestor(do_GetInterface(mInitContext->webBrowser)); + + rv = findRequestor->GetInterface(NS_GET_IID(nsIWebBrowserFind), + getter_AddRefs(findComponent)); if (NS_FAILED(rv) || nsnull == findComponent) { return (void *) rv; } - - nsCOMPtr searchContext; - // get the nsISearchContext - // No seachString means this is Find, not FindNext. + + // If this a Find, not a FindNext, we must make the + // nsIWebBrowserFind instance aware of the string to search. if (mSearchString) { - nsCOMPtr domWindowInternal; - if (mInitContext->docShell != nsnull) { - nsCOMPtr interfaceRequestor(do_QueryInterface(mInitContext->docShell)); - nsCOMPtr url = nsnull; - - rv = mInitContext->webNavigation->GetCurrentURI(getter_AddRefs(url)); - if (NS_FAILED(rv) || nsnull == url) { - return (void *) rv; - } - - if (interfaceRequestor != nsnull) { - rv = interfaceRequestor->GetInterface(NS_GET_IID(nsIDOMWindowInternal), - getter_AddRefs(domWindowInternal)); - if (NS_FAILED(rv) || nsnull == domWindowInternal) { - return (void *) rv; - } - } - else - { - mInitContext->initFailCode = kFindComponentError; - return (void *) rv; - } - } - else { - mInitContext->initFailCode = kFindComponentError; - return (void *) rv; - } + PRUnichar * srchString = nsnull; - // if we get here, we have a domWindowInternal - - rv = findComponent->CreateContext(domWindowInternal, nsnull, getter_AddRefs(searchContext)); - if (NS_FAILED(rv)) { - mInitContext->initFailCode = kSearchContextError; - return (void *) rv; - } - - } - else { - // this is findNext - searchContext = mInitContext->searchContext; - } - if (!searchContext) { - mInitContext->initFailCode = kSearchContextError; - return (void *) NS_ERROR_FAILURE; - } - - nsCOMPtr srchcontext; - rv = searchContext->QueryInterface(NS_GET_IID(nsISearchContext), getter_AddRefs(srchcontext)); - if (NS_FAILED(rv)) { - mInitContext->initFailCode = kSearchContextError; - return (void *) rv; - } - - PRUnichar * aString; - srchcontext->GetSearchString(& aString); - - PRUnichar * srchString = nsnull; - if (mSearchString) { - srchString = (PRUnichar *) ::util_GetStringChars(env, mSearchString); + srchString = (PRUnichar *) ::util_GetStringChars(env, + mSearchString); // Check if String is NULL if (nsnull == srchString) { return (void *) NS_ERROR_NULL_POINTER; } - - srchcontext->SetSearchString(srchString); - srchcontext->SetSearchBackwards(!mForward); - srchcontext->SetCaseSensitive(mMatchCase); - } - - PRBool found = PR_TRUE; - rv = findComponent->FindNext(srchcontext, &found); - result = (void *) rv; - if (mSearchString) { + rv = findComponent->SetSearchString(srchString); + if (NS_FAILED(rv)) { + mInitContext->initFailCode = kFindComponentError; + return (void *) rv; + } ::util_ReleaseStringChars(env, mSearchString, srchString); ::util_DeleteGlobalRef(env, mSearchString); mSearchString = nsnull; + } - // Save in initContext struct for future findNextInPage calls - mInitContext->searchContext = srchcontext; + findComponent->SetFindBackwards(!mForward); + findComponent->SetMatchCase(mMatchCase); + + + PRBool found = PR_TRUE; + rv = findComponent->FindNext(&found); + result = (void *) rv; } return result; diff --git a/java/webclient/src_moz/CurrentPageActionEvents.h b/java/webclient/src_moz/CurrentPageActionEvents.h index 58073faca2d..5ce1c72fc90 100644 --- a/java/webclient/src_moz/CurrentPageActionEvents.h +++ b/java/webclient/src_moz/CurrentPageActionEvents.h @@ -35,7 +35,6 @@ #include "nsActions.h" #include "nsIContentViewerEdit.h" -#include "nsISearchContext.h" #include "nsISHistory.h" #include "ns_util.h" diff --git a/java/webclient/src_moz/CurrentPageImpl.cpp b/java/webclient/src_moz/CurrentPageImpl.cpp index d55cc2044f4..4972c730572 100644 --- a/java/webclient/src_moz/CurrentPageImpl.cpp +++ b/java/webclient/src_moz/CurrentPageImpl.cpp @@ -94,10 +94,9 @@ JNIEXPORT void JNICALL Java_org_mozilla_webclient_wrapper_1native_CurrentPageImp WebShellInitContext* initContext = (WebShellInitContext *) webShellPtr; //First get the FindComponent object - // Pass searchContext to findComponent for the actual find call PRBool found = PR_TRUE; - if (initContext->initComplete && initContext->searchContext) { + if (initContext->initComplete) { wsFindEvent * actionEvent = new wsFindEvent(initContext); PLEvent * event = (PLEvent*) *actionEvent; ::util_PostEvent(initContext, event); @@ -237,7 +236,6 @@ JNIEXPORT void JNICALL Java_org_mozilla_webclient_wrapper_1native_CurrentPageImp (JNIEnv * env, jobject obj, jint webShellPtr) { WebShellInitContext* initContext = (WebShellInitContext *) webShellPtr; - initContext->searchContext = nsnull; } diff --git a/java/webclient/src_moz/InputStreamShim.cpp b/java/webclient/src_moz/InputStreamShim.cpp index c1441a74318..2002c6691ef 100644 --- a/java/webclient/src_moz/InputStreamShim.cpp +++ b/java/webclient/src_moz/InputStreamShim.cpp @@ -38,7 +38,7 @@ InputStreamShim::InputStreamShim(jobject yourJavaStreamRef, mCountFromMozilla(0), mAvailable(0), mAvailableForMozilla(0), mNumRead(0), mDoClose(PR_FALSE), mDidClose(PR_FALSE), mLock(nsnull) { - NS_INIT_REFCNT(); + NS_INIT_ISUPPORTS(); mLock = PR_NewLock(); JNIEnv *env = (JNIEnv *) JNU_GetEnv(gVm, JNI_VERSION); } diff --git a/java/webclient/src_moz/NavigationActionEvents.cpp b/java/webclient/src_moz/NavigationActionEvents.cpp index cfb807b3a25..7a9fb668afd 100644 --- a/java/webclient/src_moz/NavigationActionEvents.cpp +++ b/java/webclient/src_moz/NavigationActionEvents.cpp @@ -206,8 +206,7 @@ wsLoadFromStreamEvent::~wsLoadFromStreamEvent () * wsPostEvent */ wsPostEvent::wsPostEvent(WebShellInitContext *yourInitContext, - const PRUnichar *absoluteUrlToCopy, - PRInt32 absoluteUrlLength, + nsIURI *absoluteUri, const PRUnichar *targetToCopy, PRInt32 targetLength, PRInt32 postDataLength, @@ -217,8 +216,7 @@ wsPostEvent::wsPostEvent(WebShellInitContext *yourInitContext, nsActionEvent(), mInitContext(yourInitContext) { - mAbsoluteURL = new nsString(absoluteUrlToCopy, absoluteUrlLength); - + mAbsoluteURI = absoluteUri; if (targetToCopy != nsnull){ mTarget = new nsString(targetToCopy, targetLength); } @@ -320,7 +318,7 @@ wsPostEvent::handleEvent () rv = lh->OnLinkClick(content, eLinkVerb_Replace, - mAbsoluteURL->get(), + mAbsoluteURI, ((mTarget != nsnull) ? mTarget->get() : nsnull), postDataStream, headersDataStream); @@ -331,8 +329,7 @@ wsPostEvent::handleEvent () wsPostEvent::~wsPostEvent () { - if (mAbsoluteURL != nsnull) - delete mAbsoluteURL; + mAbsoluteURI = nsnull; if (mTarget != nsnull) delete mTarget; mPostData = nsnull; diff --git a/java/webclient/src_moz/NavigationActionEvents.h b/java/webclient/src_moz/NavigationActionEvents.h index 6ccda90e4d5..7afc3ca2d4d 100644 --- a/java/webclient/src_moz/NavigationActionEvents.h +++ b/java/webclient/src_moz/NavigationActionEvents.h @@ -37,6 +37,7 @@ #include "nsActions.h" #include "nsIWebNavigation.h" #include "nsString.h" +#include "nsIURI.h" #include "ns_util.h" struct WebShellInitContext; @@ -81,8 +82,7 @@ protected: class wsPostEvent : public nsActionEvent { public: wsPostEvent(WebShellInitContext *yourInitContext, - const PRUnichar *absoluteUrlToCopy, - PRInt32 absoluteUrlLength, + nsIURI *absoluteUrl, const PRUnichar *targetToCopy, PRInt32 targetLength, PRInt32 postDataLength, @@ -98,7 +98,7 @@ private: protected: WebShellInitContext *mInitContext; - nsString *mAbsoluteURL; + nsCOMPtr mAbsoluteURI; nsString *mTarget; const char *mPostData; const char *mPostHeaders; diff --git a/java/webclient/src_moz/NavigationImpl.cpp b/java/webclient/src_moz/NavigationImpl.cpp index 8ec37779d03..61f18b7b7dc 100644 --- a/java/webclient/src_moz/NavigationImpl.cpp +++ b/java/webclient/src_moz/NavigationImpl.cpp @@ -31,6 +31,10 @@ #include "NavigationImpl.h" #include "NavigationActionEvents.h" +#include "nsIServiceManagerUtils.h" +#include "nsIIOService.h" +#include "nsIURI.h" +#include "nsNetCID.h" #include "ns_util.h" @@ -159,6 +163,15 @@ JNIEXPORT void JNICALL Java_org_mozilla_webclient_wrapper_1native_NavigationImpl const char *postHeadersChars = nsnull; char *headersAndData = nsnull; wsPostEvent *actionEvent = nsnull; + nsresult rv = NS_OK; + nsCOMPtr ioService = do_GetService(NS_IOSERVICE_CONTRACTID, + &rv); + nsCOMPtr uri; + NS_ConvertUCS2toUTF8 uriACString(urlChars); + + if (!ioService || NS_FAILED(rv)) { + return; + } if (initContext == nsnull || !initContext->initComplete) { ::util_ThrowExceptionToJava(env, "Exception: null webShellPtr passed to nativePost"); @@ -219,10 +232,15 @@ JNIEXPORT void JNICALL Java_org_mozilla_webclient_wrapper_1native_NavigationImpl } } + rv = ioService->NewURI(uriACString, nsnull, nsnull, + getter_AddRefs(uri)); + if (!uri || NS_FAILED(rv)) { + goto NPFS_CLEANUP; + } + if (!(actionEvent = new wsPostEvent(initContext, - urlChars, - urlLen, + uri, targetChars, targetLen, (PRInt32) postDataLength, diff --git a/java/webclient/src_moz/WindowControlActionEvents.cpp b/java/webclient/src_moz/WindowControlActionEvents.cpp index 8932f9c69c3..9c89d3a4d1b 100644 --- a/java/webclient/src_moz/WindowControlActionEvents.cpp +++ b/java/webclient/src_moz/WindowControlActionEvents.cpp @@ -37,6 +37,9 @@ #include "nsIDocShellTreeItem.h" #include "nsEmbedAPI.h" // for NS_TermEmbedding +#ifdef _WIN32 +#include +#endif /* @@ -137,7 +140,6 @@ wsDeallocateInitContextEvent::handleEvent () mInitContext->w = -1; mInitContext->h = -1; mInitContext->gtkWinPtr = nsnull; - mInitContext->searchContext = nsnull; // make sure we aren't listening anymore. This needs to be done // before currentDocument = nsnull @@ -151,7 +153,7 @@ wsDeallocateInitContextEvent::handleEvent () if (isLastWindow) { NS_TermEmbedding(); #ifdef _WIN32 - _exit(0); + exit(0); #endif } return (void *) NS_OK; diff --git a/java/webclient/src_moz/WindowControlImpl.cpp b/java/webclient/src_moz/WindowControlImpl.cpp index f3c70d0e756..7d7e2744b96 100644 --- a/java/webclient/src_moz/WindowControlImpl.cpp +++ b/java/webclient/src_moz/WindowControlImpl.cpp @@ -98,7 +98,6 @@ JNIEXPORT jint JNICALL Java_org_mozilla_webclient_wrapper_1native_WindowControlI initContext->y = y; initContext->w = width; initContext->h = height; - initContext->searchContext = nsnull; initContext->currentDocument = nsnull; initContext->browserContainer = nsnull; util_InitializeShareInitContext(&(initContext->shareContext)); diff --git a/java/webclient/src_moz/ns_util.h b/java/webclient/src_moz/ns_util.h index 4a0ee66aaf7..41e82e1e591 100644 --- a/java/webclient/src_moz/ns_util.h +++ b/java/webclient/src_moz/ns_util.h @@ -48,7 +48,6 @@ #include "nsIThread.h" // for PRThread #include "nsIWebShell.h" // for nsIWebShell #include "nsIEventQueueService.h" // for PLEventQueue -#include "nsISearchContext.h" // for Find #include "nsIDOMDocument.h" #include "wcIBrowserContainer.h" // our BrowserContainer @@ -101,7 +100,6 @@ struct WebShellInitContext { int w; int h; int gtkWinPtr; - nsCOMPtr searchContext; nsCOMPtr currentDocument; nsCOMPtr browserContainer; // This struct contains all per-window information not specific to mozilla @@ -118,7 +116,6 @@ enum { kHistoryWebShellError, kClipboardWebShellError, kFindComponentError, - kSearchContextError, kGetContentViewerError, kGetDOMWindowError }; diff --git a/java/webclient/src_moz/win32/Makefile.in b/java/webclient/src_moz/win32/Makefile.in new file mode 100644 index 00000000000..e69de29bb2d diff --git a/java/webclient/src_moz/wsRDFObserver.cpp b/java/webclient/src_moz/wsRDFObserver.cpp index 68c04428728..f19054b64fb 100644 --- a/java/webclient/src_moz/wsRDFObserver.cpp +++ b/java/webclient/src_moz/wsRDFObserver.cpp @@ -40,7 +40,7 @@ NS_INTERFACE_MAP_END wsRDFObserver::wsRDFObserver() { - NS_INIT_REFCNT(); + NS_INIT_ISUPPORTS(); } wsRDFObserver::~wsRDFObserver() {} diff --git a/java/webclient/src_share/Makefile.in b/java/webclient/src_share/Makefile.in index 64166a32b92..c2909c0e6ca 100644 --- a/java/webclient/src_share/Makefile.in +++ b/java/webclient/src_share/Makefile.in @@ -52,9 +52,13 @@ ifneq ($(BAL_INTERFACE),) INCLUDES := -I../bal -I../bal/solaris $(INCLUDES) else ifeq ($(OS_ARCH),Linux) -INCLUDES := -I$(JDKHOME)/include -I$(JDKHOME)/include/linux $(INCLUDES) +INCLUDES := -I$(MOZ_JDKHOME)/include -I$(MOZ_JDKHOME)/include/linux $(INCLUDES) else -INCLUDES := -I$(JDKHOME)/include -I$(JDKHOME)/include/solaris $(INCLUDES) +ifeq ($(OS_ARCH),WINNT) +INCLUDES := -I$(MOZ_JDKHOME)/include -I$(MOZ_JDKHOME)/include/win32 $(INCLUDES) +else +INCLUDES := -I$(MOZ_JDKHOME)/include -I$(MOZ_JDKHOME)/include/solaris $(INCLUDES) +endif endif endif