mirror of
https://github.com/mozilla/gecko-dev.git
synced 2025-03-02 06:22:20 +00:00
Added stuff to implement Find features in CurrentPage interface
a=ashuk r=edburns Bug=20659 _Ashu
This commit is contained in:
parent
308b05817c
commit
7e45b0883a
@ -32,10 +32,18 @@
|
||||
#include "CurrentPageImpl.h"
|
||||
|
||||
#include "jni_util.h"
|
||||
#include "jni_util_export.h"
|
||||
#include "rdf_util.h"
|
||||
#include "nsActions.h"
|
||||
|
||||
#include "nsCRT.h"
|
||||
#include "nsIPresShell.h"
|
||||
#include "nsCOMPtr.h"
|
||||
#include "nsISupports.h"
|
||||
#include "nsIFindComponent.h"
|
||||
#include "nsISearchContext.h"
|
||||
#include "nsIServiceManager.h"
|
||||
|
||||
|
||||
JNIEXPORT void JNICALL Java_org_mozilla_webclient_wrapper_1native_CurrentPageImpl_nativeCopyCurrentSelectionToSystemClipboard
|
||||
(JNIEnv *env, jobject obj, jint webShellPtr)
|
||||
@ -72,28 +80,90 @@ JNIEXPORT void JNICALL Java_org_mozilla_webclient_wrapper_1native_CurrentPageImp
|
||||
* Signature: (Ljava/lang/String;ZZ)V
|
||||
*/
|
||||
JNIEXPORT void JNICALL Java_org_mozilla_webclient_wrapper_1native_CurrentPageImpl_nativeFindInPage
|
||||
(JNIEnv *, jobject, jstring, jboolean, jboolean)
|
||||
(JNIEnv *env, jobject obj, jint webShellPtr, jstring searchString, jboolean forward, jboolean matchCase)
|
||||
{
|
||||
|
||||
/****
|
||||
|
||||
As of 01/13/00, Find is blocked on this post to n.p.m.embedding:
|
||||
WebShellInitContext* initContext = (WebShellInitContext *) webShellPtr;
|
||||
|
||||
Message-ID: <85ln9l$p97$1@nnrp1.deja.com>
|
||||
//First get the FindComponent object
|
||||
nsresult rv;
|
||||
|
||||
NS_WITH_SERVICE(nsIFindComponent, findComponent, NS_IFINDCOMPONENT_PROGID, &rv);
|
||||
if (NS_FAILED(rv)) {
|
||||
initContext->initFailCode = kFindComponentError;
|
||||
::util_ThrowExceptionToJava(env, "Exception: can't access FindComponent Service");
|
||||
return;
|
||||
}
|
||||
|
||||
// Create a Search Context for the FindComponent
|
||||
nsCOMPtr<nsISupports> searchContext;
|
||||
rv = findComponent->CreateContext(initContext->webShell, nsnull, getter_AddRefs(searchContext));
|
||||
if (NS_FAILED(rv)) {
|
||||
initContext->initFailCode = kSearchContextError;
|
||||
::util_ThrowExceptionToJava(env, "Exception: can't create SearchContext for Find");
|
||||
return;
|
||||
}
|
||||
|
||||
***/
|
||||
nsCOMPtr<nsISearchContext> srchcontext;
|
||||
rv = searchContext->QueryInterface(NS_GET_IID(nsISearchContext), getter_AddRefs(srchcontext));
|
||||
if (NS_FAILED(rv)) {
|
||||
initContext->initFailCode = kSearchContextError;
|
||||
::util_ThrowExceptionToJava(env, "Exception: can't create SearchContext for Find");
|
||||
return;
|
||||
}
|
||||
|
||||
PRUnichar * aString;
|
||||
srchcontext->GetSearchString(& aString);
|
||||
|
||||
PRUnichar * srchString = (PRUnichar *) ::util_GetStringChars(env, searchString);
|
||||
|
||||
srchcontext->SetSearchString(srchString);
|
||||
srchcontext->SetSearchBackwards(!forward);
|
||||
srchcontext->SetCaseSensitive(matchCase);
|
||||
|
||||
// Pass searchContext to findComponent for the actual find call
|
||||
PRBool found = PR_TRUE;
|
||||
findComponent->FindNext(srchcontext, &found);
|
||||
|
||||
// Save in initContext struct for future findNextInPage calls
|
||||
initContext->searchContext = srchcontext;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* Class: org_mozilla_webclient_wrapper_0005fnative_CurrentPageImpl
|
||||
* Method: nativeFindNextInPage
|
||||
* Signature: (Z)V
|
||||
*/
|
||||
JNIEXPORT void JNICALL Java_org_mozilla_webclient_wrapper_1native_CurrentPageImpl_nativeFindNextInPage
|
||||
(JNIEnv *, jobject, jboolean)
|
||||
(JNIEnv *env, jobject obj, jint webShellPtr, jboolean forward)
|
||||
{
|
||||
|
||||
WebShellInitContext* initContext = (WebShellInitContext *) webShellPtr;
|
||||
//First get the FindComponent object
|
||||
nsresult rv;
|
||||
|
||||
NS_WITH_SERVICE(nsIFindComponent, findComponent, NS_IFINDCOMPONENT_PROGID, &rv);
|
||||
if (NS_FAILED(rv)) {
|
||||
initContext->initFailCode = kFindComponentError;
|
||||
::util_ThrowExceptionToJava(env, "Exception: can't access FindComponent Service");
|
||||
return;
|
||||
}
|
||||
|
||||
// Get the searchContext from the initContext struct
|
||||
nsCOMPtr<nsISearchContext> searchContext = initContext->searchContext;
|
||||
|
||||
if (nsnull == searchContext) {
|
||||
initContext->initFailCode = kSearchContextError;
|
||||
::util_ThrowExceptionToJava(env, "Exception: NULL SearchContext received for FindNext");
|
||||
return;
|
||||
}
|
||||
|
||||
// Pass searchContext to findComponent for the actual find call
|
||||
PRBool found = PR_TRUE;
|
||||
findComponent->FindNext(searchContext, &found);
|
||||
|
||||
}
|
||||
|
||||
/*
|
||||
@ -152,7 +222,7 @@ JNIEXPORT jstring JNICALL Java_org_mozilla_webclient_wrapper_1native_CurrentPage
|
||||
* Signature: ()Ljava/lang/String;
|
||||
*/
|
||||
JNIEXPORT jstring JNICALL Java_org_mozilla_webclient_wrapper_1native_CurrentPageImpl_nativeGetSource
|
||||
(JNIEnv *, jobject)
|
||||
(JNIEnv * env, jobject jobj)
|
||||
{
|
||||
jstring result = nsnull;
|
||||
|
||||
@ -165,8 +235,9 @@ JNIEXPORT jstring JNICALL Java_org_mozilla_webclient_wrapper_1native_CurrentPage
|
||||
* Signature: ()[B
|
||||
*/
|
||||
JNIEXPORT jbyteArray JNICALL Java_org_mozilla_webclient_wrapper_1native_CurrentPageImpl_nativeGetSourceBytes
|
||||
(JNIEnv *, jobject)
|
||||
(JNIEnv * env, jobject jobj)
|
||||
{
|
||||
|
||||
jbyteArray result = nsnull;
|
||||
|
||||
return result;
|
||||
@ -178,9 +249,10 @@ JNIEXPORT jbyteArray JNICALL Java_org_mozilla_webclient_wrapper_1native_CurrentP
|
||||
* Signature: ()V
|
||||
*/
|
||||
JNIEXPORT void JNICALL Java_org_mozilla_webclient_wrapper_1native_CurrentPageImpl_nativeResetFind
|
||||
(JNIEnv *, jobject)
|
||||
(JNIEnv * env, jobject obj, jint webShellPtr)
|
||||
{
|
||||
|
||||
WebShellInitContext* initContext = (WebShellInitContext *) webShellPtr;
|
||||
initContext->searchContext = nsnull;
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -427,12 +427,19 @@ nsresult InitMozillaStuff (WebShellInitContext * initContext)
|
||||
GtkMozArea * mozarea;
|
||||
mozarea = (GtkMozArea *) initContext->gtkWinPtr;
|
||||
superwin = mozarea->superwin;
|
||||
if (prLogModuleInfo) {
|
||||
PR_LOG(prLogModuleInfo, 3, ("Ashu Debugs - Inside InitMozillaStuff(%lx): - before Init Call...\n", initContext));
|
||||
}
|
||||
rv = initContext->webShell->Init((nsNativeWidget *)superwin, initContext->x, initContext->y, initContext->w, initContext->h);
|
||||
if (prLogModuleInfo) {
|
||||
PR_LOG(prLogModuleInfo, 3, ("Ashu Debugs - Inside InitMozillaStuff(%lx): - after Init Call...\n", initContext));
|
||||
}
|
||||
#else
|
||||
rv = initContext->webShell->Init((nsNativeWidget *)initContext->parentHWnd,
|
||||
initContext->x, initContext->y, initContext->w, initContext->h);
|
||||
#endif
|
||||
|
||||
|
||||
if (NS_FAILED(rv)) {
|
||||
initContext->initFailCode = kInitWebShellError;
|
||||
return rv;
|
||||
|
@ -93,6 +93,7 @@ JNIEXPORT jint JNICALL Java_org_mozilla_webclient_wrapper_1native_WindowControlI
|
||||
initContext->y = y;
|
||||
initContext->w = width;
|
||||
initContext->h = height;
|
||||
initContext->searchContext = nsnull;
|
||||
|
||||
#ifdef XP_UNIX
|
||||
initContext->gtkWinPtr =
|
||||
@ -140,6 +141,7 @@ Java_org_mozilla_webclient_wrapper_1native_WindowControlImpl_nativeDestroyInitCo
|
||||
initContext->w = -1;
|
||||
initContext->h = -1;
|
||||
initContext->gtkWinPtr = nsnull;
|
||||
initContext->searchContext = nsnull;
|
||||
|
||||
delete initContext;
|
||||
}
|
||||
|
@ -157,8 +157,7 @@ void rdf_recursiveResourceTraversal(nsCOMPtr<nsIRDFResource> currentResource)
|
||||
rdf_printArcLabels(currentResource);
|
||||
|
||||
// see if it has a name target
|
||||
// Ashu
|
||||
// used 1 instead of true
|
||||
|
||||
rv = gBookmarksDataSource->GetTarget(currentResource,
|
||||
kNC_Name, PR_TRUE,
|
||||
getter_AddRefs(node));
|
||||
@ -265,8 +264,7 @@ void rdf_recursiveResourceTraversal(nsCOMPtr<nsIRDFResource> currentResource)
|
||||
rdf_printArcLabels(currentResource);
|
||||
|
||||
// see if it has a URL target
|
||||
// Ashu
|
||||
// used 1 instead of true
|
||||
|
||||
rv = gBookmarksDataSource->GetTarget(currentResource,
|
||||
kNC_URL, PR_TRUE,
|
||||
getter_AddRefs(node));
|
||||
|
Loading…
x
Reference in New Issue
Block a user