From 711d526c7d23b2d3207b1fa8b8eb1cc684298b69 Mon Sep 17 00:00:00 2001 From: "ashuk%eng.sun.com" Date: Mon, 24 Jul 2000 21:15:03 +0000 Subject: [PATCH] author = ashuk r = edburns a = edburns Fix for Bugs: 44774, 44775 and 41780 git-svn-id: svn://10.0.0.236/trunk@74690 18797224-902f-48f8-a5cc-f745e15eee43 --- .../webclient/src_moz/CurrentPageImpl.cpp | 26 +++++++++++++++++-- mozilla/java/webclient/src_moz/jni_util.h | 5 +++- 2 files changed, 28 insertions(+), 3 deletions(-) diff --git a/mozilla/java/webclient/src_moz/CurrentPageImpl.cpp b/mozilla/java/webclient/src_moz/CurrentPageImpl.cpp index b8c4dadaa59..195e39df75a 100644 --- a/mozilla/java/webclient/src_moz/CurrentPageImpl.cpp +++ b/mozilla/java/webclient/src_moz/CurrentPageImpl.cpp @@ -71,6 +71,12 @@ JNIEXPORT void JNICALL Java_org_mozilla_webclient_wrapper_1native_CurrentPageImp nsIContentViewer* contentViewer ; nsresult rv = nsnull; rv = initContext->docShell->GetContentViewer(&contentViewer); + if (NS_FAILED(rv)) { + initContext->initFailCode = kGetContentViewerError; + ::util_ThrowExceptionToJava(env, "Exception: cant get ContentViewer from DocShell"); + return; + } + nsCOMPtr contentViewerEdit(do_QueryInterface(contentViewer)); rv = contentViewerEdit->CopySelection(); @@ -101,7 +107,11 @@ JNIEXPORT void JNICALL Java_org_mozilla_webclient_wrapper_1native_CurrentPageImp nsCOMPtr interfaceRequestor(do_QueryInterface(initContext->docShell)); nsCOMPtr domWindow; rv = interfaceRequestor->GetInterface(NS_GET_IID(nsIDOMWindow), getter_AddRefs(domWindow)); - + if (NS_FAILED(rv)) { + initContext->initFailCode = kGetDOMWindowError; + ::util_ThrowExceptionToJava(env, "Exception: cant get DOMWindow from DocShell"); + return; + } nsCOMPtr searchContext; rv = findComponent->CreateContext(domWindow, nsnull, getter_AddRefs(searchContext)); @@ -111,7 +121,7 @@ JNIEXPORT void JNICALL Java_org_mozilla_webclient_wrapper_1native_CurrentPageImp return; } - nsCOMPtr srchcontext; + nsCOMPtr srchcontext; rv = searchContext->QueryInterface(NS_GET_IID(nsISearchContext), getter_AddRefs(srchcontext)); if (NS_FAILED(rv)) { initContext->initFailCode = kSearchContextError; @@ -124,6 +134,12 @@ JNIEXPORT void JNICALL Java_org_mozilla_webclient_wrapper_1native_CurrentPageImp PRUnichar * srchString = (PRUnichar *) ::util_GetStringChars(env, searchString); + // Check if String is NULL + if (nsnull == srchString) { + ::util_ThrowExceptionToJava(env, "Exception: NULL String passed to Find call"); + return; + } + srchcontext->SetSearchString(srchString); srchcontext->SetSearchBackwards(!forward); srchcontext->SetCaseSensitive(matchCase); @@ -320,6 +336,12 @@ JNIEXPORT void JNICALL Java_org_mozilla_webclient_wrapper_1native_CurrentPageImp nsIContentViewer* contentViewer ; nsresult rv = nsnull; rv = initContext->docShell->GetContentViewer(&contentViewer); + if (NS_FAILED(rv)) { + initContext->initFailCode = kGetContentViewerError; + ::util_ThrowExceptionToJava(env, "Exception: cant get ContentViewer from DocShell"); + return; + } + nsCOMPtr contentViewerEdit(do_QueryInterface(contentViewer)); rv = contentViewerEdit->SelectAll(); if (NS_FAILED(rv)) { diff --git a/mozilla/java/webclient/src_moz/jni_util.h b/mozilla/java/webclient/src_moz/jni_util.h index 6de0c3fa69e..54be82dae71 100644 --- a/mozilla/java/webclient/src_moz/jni_util.h +++ b/mozilla/java/webclient/src_moz/jni_util.h @@ -111,9 +111,12 @@ enum { kHistoryWebShellError, kClipboardWebShellError, kFindComponentError, - kSearchContextError + kSearchContextError, + kGetContentViewerError, + kGetDOMWindowError }; + extern JavaVM *gVm; // defined in jni_util.cpp void util_ThrowExceptionToJava (JNIEnv * env, const char * message);