зеркало из https://github.com/mozilla/pjs.git
Added new method :
public Object PlugletTagInfo.getDOMElement(); (It is possible to use JavaDOM from pluglets now.) a=idk@eng.sun.com r=sdv@sparc.spb.su
This commit is contained in:
Родитель
34d719c42b
Коммит
707030a57c
|
@ -39,4 +39,22 @@ public interface PlugletTagInfo {
|
|||
* @return Returns the value of the named attribute as a <code>String</code>.
|
||||
*/
|
||||
public String getAttribute(String name);
|
||||
|
||||
/**
|
||||
* Returns the DOM element corresponding to the tag which references
|
||||
* this pluglet in the document.
|
||||
*
|
||||
* REMINDERS:
|
||||
* <ul>
|
||||
* <li> You need to have JavaDOM installed.
|
||||
* (see http://www.mozilla.org/projects/blacwood/dom)
|
||||
* </li>
|
||||
* <li>
|
||||
* You need to cast return value to org.w3c.dom.Element
|
||||
* </li>
|
||||
* </ul>
|
||||
* @return Return org.w3c.dom.Element correspondig to the tag
|
||||
*/
|
||||
public Object getDOMElement();
|
||||
}
|
||||
|
||||
|
|
|
@ -52,6 +52,7 @@ public class PlugletTagInfo2Impl implements PlugletTagInfo2 {
|
|||
}
|
||||
return result;
|
||||
}
|
||||
public native Object getDOMElement();
|
||||
public native String getParameter(String name);
|
||||
/* Get the type of the HTML tag that was used ot instantiate this
|
||||
* pluglet. Currently supported tags are EMBED, APPLET and OBJECT.
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/*
|
||||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
||||
* The contents of this file are subject to the Mozilla Public
|
||||
* License Version 1.1 (the "License"); you may not use this file
|
||||
* except in compliance with the License. You may obtain a copy of
|
||||
|
@ -23,6 +23,9 @@
|
|||
#include "PlugletLog.h"
|
||||
|
||||
static jfieldID peerFID = NULL;
|
||||
static jclass DOMAccessorImpl = NULL;
|
||||
static jmethodID getElementByHandle = NULL;
|
||||
|
||||
/*
|
||||
* Class: org_mozilla_pluglet_mozilla_PlugletTagInfo2Impl
|
||||
* Method: getAttributesArray
|
||||
|
@ -95,6 +98,41 @@ JNIEXPORT jstring JNICALL Java_org_mozilla_pluglet_mozilla_PlugletTagInfo2Impl_g
|
|||
return env->NewStringUTF(result);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Class: org_mozilla_pluglet_mozilla_PlugletTagInfo2Impl
|
||||
* Method: getDOMElement
|
||||
* Signature: ()Ljava/lang/Object;
|
||||
*/
|
||||
JNIEXPORT jobject JNICALL Java_org_mozilla_pluglet_mozilla_PlugletTagInfo2Impl_getDOMElement
|
||||
(JNIEnv *env, jobject jthis) {
|
||||
PR_LOG(PlugletLog::log, PR_LOG_DEBUG,
|
||||
("PlugletTagInfo2Impl.getDOMElement\n"));
|
||||
if ( !DOMAccessorImpl ) {
|
||||
DOMAccessorImpl = env->FindClass("org/mozilla/dom/DOMAccessorImpl");
|
||||
if (!DOMAccessorImpl) {
|
||||
return NULL;
|
||||
}
|
||||
DOMAccessorImpl = (jclass) env->NewGlobalRef(DOMAccessorImpl); // nb who is going to Delete this ref
|
||||
if (!DOMAccessorImpl) {
|
||||
return NULL;
|
||||
}
|
||||
getElementByHandle = env->GetStaticMethodID(DOMAccessorImpl,"getElementByHandle","(J)Lorg/w3c/dom/Element;");
|
||||
if (!getElementByHandle) {
|
||||
DOMAccessorImpl = NULL;
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
nsIPluginTagInfo2 * info = (nsIPluginTagInfo2*)env->GetLongField(jthis, peerFID);
|
||||
nsIDOMElement * elem = NULL;
|
||||
if (!info
|
||||
|| NS_FAILED(info->GetDOMElement(&elem))) {
|
||||
return NULL;
|
||||
}
|
||||
return env->CallStaticObjectMethod(DOMAccessorImpl,getElementByHandle,(jlong) elem);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Class: org_mozilla_pluglet_mozilla_PlugletTagInfo2Impl
|
||||
* Method: getParametersArray
|
||||
|
|
|
@ -1,23 +1,3 @@
|
|||
/*
|
||||
* The contents of this file are subject to the Mozilla Public
|
||||
* License Version 1.1 (the "License"); you may not use this file
|
||||
* except in compliance with the License. You may obtain a copy of
|
||||
* the License at http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS
|
||||
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
||||
* implied. See the License for the specific language governing
|
||||
* rights and limitations under the License.
|
||||
*
|
||||
* The Original Code is mozilla.org code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Sun Microsystems,
|
||||
* Inc. Portions created by Sun are
|
||||
* Copyright (C) 1999 Sun Microsystems, Inc. All
|
||||
* Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*/
|
||||
/* DO NOT EDIT THIS FILE - it is machine generated */
|
||||
#include <jni.h>
|
||||
/* Header for class org_mozilla_pluglet_mozilla_PlugletTagInfo2Impl */
|
||||
|
@ -47,10 +27,18 @@ JNIEXPORT jstring JNICALL Java_org_mozilla_pluglet_mozilla_PlugletTagInfo2Impl_g
|
|||
* Class: org_mozilla_pluglet_mozilla_PlugletTagInfo2Impl
|
||||
* Method: getParametersArray
|
||||
* Signature: ()[[Ljava/lang/String;
|
||||
*/
|
||||
*/
|
||||
JNIEXPORT jobjectArray JNICALL Java_org_mozilla_pluglet_mozilla_PlugletTagInfo2Impl_getParametersArray
|
||||
(JNIEnv *, jobject);
|
||||
|
||||
/*
|
||||
* Class: org_mozilla_pluglet_mozilla_PlugletTagInfo2Impl
|
||||
* Method: getDOMElement
|
||||
* Signature: ()Ljava/lang/Object;
|
||||
*/
|
||||
JNIEXPORT jobject JNICALL Java_org_mozilla_pluglet_mozilla_PlugletTagInfo2Impl_getDOMElement
|
||||
(JNIEnv *, jobject);
|
||||
|
||||
/*
|
||||
* Class: org_mozilla_pluglet_mozilla_PlugletTagInfo2Impl
|
||||
* Method: getParameter
|
||||
|
|
|
@ -178,6 +178,13 @@ void PlugletEngine::StartJVM(void) {
|
|||
("PlugletEngine::StartJVM\n"));
|
||||
JNIEnv *env = NULL;
|
||||
jint res;
|
||||
jsize jvmCount;
|
||||
JNI_GetCreatedJavaVMs(&jvm, 1, &jvmCount);
|
||||
if (jvmCount) {
|
||||
PR_LOG(PlugletLog::log, PR_LOG_DEBUG,
|
||||
("PlugletEngine::StartJVM we have running jvm. We do not need to start another one\n"));
|
||||
return;
|
||||
}
|
||||
JDK1_1InitArgs vm_args;
|
||||
char classpath[1024];
|
||||
JNI_GetDefaultJavaVMInitArgs(&vm_args);
|
||||
|
@ -186,7 +193,7 @@ void PlugletEngine::StartJVM(void) {
|
|||
sprintf(classpath, "%s%c%s",
|
||||
vm_args.classpath, PATH_SEPARATOR, PR_GetEnv("CLASSPATH"));
|
||||
PR_LOG(PlugletLog::log, PR_LOG_DEBUG,
|
||||
("PlugletEngine::StartJVM classpath=%s\n",classpath));
|
||||
("PlugletEngine::StartJVM classpath=%s\n",classpath));
|
||||
char **props = new char*[2];
|
||||
props[0]="java.compiler=NONE";
|
||||
props[1]=0;
|
||||
|
@ -195,10 +202,10 @@ void PlugletEngine::StartJVM(void) {
|
|||
/* Create the Java VM */
|
||||
res = JNI_CreateJavaVM(&jvm, &env, &vm_args);
|
||||
if(res < 0 ) {
|
||||
PR_LOG(PlugletLog::log, PR_LOG_DEBUG,
|
||||
PR_LOG(PlugletLog::log, PR_LOG_DEBUG,
|
||||
("PlugletEngine::StartJVM JNI_CreateJavaVM failed \n"));
|
||||
} else {
|
||||
PR_LOG(PlugletLog::log, PR_LOG_DEBUG,
|
||||
PR_LOG(PlugletLog::log, PR_LOG_DEBUG,
|
||||
("PlugletEngine::StartJVM jvm was started \n"));
|
||||
}
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче