mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-24 21:31:04 +00:00
Backed out 6 changesets (bug 913985) for suspicion of causing intermittent Android crashes on a CLOSED TREE.
Backed out changeset de21920d2b8e (bug 913985) Backed out changeset f0f5497d65bb (bug 913985) Backed out changeset 1e16ca4ad801 (bug 913985) Backed out changeset 9c069a0820ea (bug 913985) Backed out changeset 274df3abc991 (bug 913985) Backed out changeset 05fe8b17516a (bug 913985) --HG-- rename : build/annotationProcessors/AnnotationInfo.java => build/annotationProcessors/MethodWithAnnotationInfo.java rename : build/annotationProcessors/utils/AlphabeticAnnotatableEntityComparator.java => build/annotationProcessors/utils/AlphabeticMethodComparator.java rename : build/annotationProcessors/utils/GeneratableElementIterator.java => build/annotationProcessors/utils/GeneratableEntryPointIterator.java rename : mobile/android/base/mozglue/generatorannotations/WrapElementForJNI.java => mobile/android/base/mozglue/GeneratableAndroidBridgeTarget.java rename : mobile/android/base/mozglue/generatorannotations/OptionalGeneratedParameter.java => mobile/android/base/mozglue/OptionalGeneratedParameter.java
This commit is contained in:
parent
c9ffd01d65
commit
4875847fa7
@ -4,10 +4,8 @@
|
||||
|
||||
package org.mozilla.gecko.annotationProcessors;
|
||||
|
||||
import org.mozilla.gecko.annotationProcessors.classloader.AnnotatableEntity;
|
||||
import org.mozilla.gecko.annotationProcessors.classloader.ClassWithOptions;
|
||||
import org.mozilla.gecko.annotationProcessors.classloader.IterableJarLoadingURLClassLoader;
|
||||
import org.mozilla.gecko.annotationProcessors.utils.GeneratableElementIterator;
|
||||
import org.mozilla.gecko.annotationProcessors.utils.GeneratableEntryPointIterator;
|
||||
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
@ -18,12 +16,6 @@ public class AnnotationProcessor {
|
||||
public static final String OUTFILE = "GeneratedJNIWrappers.cpp";
|
||||
public static final String HEADERFILE = "GeneratedJNIWrappers.h";
|
||||
|
||||
public static final String GENERATED_COMMENT =
|
||||
"// GENERATED CODE\n" +
|
||||
"// Generated by the Java program at /build/annotationProcessors at compile time from\n" +
|
||||
"// annotations on Java methods. To update, change the annotations on the corresponding Java\n" +
|
||||
"// methods and rerun the build. Manually updating this file will cause your build to fail.\n\n";
|
||||
|
||||
public static void main(String[] args) {
|
||||
// We expect a list of jars on the commandline. If missing, whinge about it.
|
||||
if (args.length <= 1) {
|
||||
@ -41,121 +33,44 @@ public class AnnotationProcessor {
|
||||
long s = System.currentTimeMillis();
|
||||
|
||||
// Get an iterator over the classes in the jar files given...
|
||||
Iterator<ClassWithOptions> jarClassIterator = IterableJarLoadingURLClassLoader.getIteratorOverJars(args);
|
||||
Iterator<Class<?>> jarClassIterator = IterableJarLoadingURLClassLoader.getIteratorOverJars(args);
|
||||
|
||||
StringBuilder headerFile = new StringBuilder(GENERATED_COMMENT);
|
||||
headerFile.append("#ifndef GeneratedJNIWrappers_h__\n" +
|
||||
"#define GeneratedJNIWrappers_h__\n\n" +
|
||||
"#include \"nsXPCOMStrings.h\"\n" +
|
||||
"#include \"AndroidJavaWrappers.h\"\n" +
|
||||
"\n" +
|
||||
"namespace mozilla {\n" +
|
||||
"namespace widget {\n" +
|
||||
"namespace android {\n" +
|
||||
"void InitStubs(JNIEnv *jEnv);\n\n");
|
||||
|
||||
StringBuilder implementationFile = new StringBuilder(GENERATED_COMMENT);
|
||||
implementationFile.append("#include \"GeneratedJNIWrappers.h\"\n" +
|
||||
"#include \"AndroidBridgeUtilities.h\"\n" +
|
||||
"#include \"nsXPCOMStrings.h\"\n" +
|
||||
"#include \"AndroidBridge.h\"\n" +
|
||||
"\n" +
|
||||
"namespace mozilla {\n" +
|
||||
"namespace widget {\n" +
|
||||
"namespace android {\n");
|
||||
|
||||
// Used to track the calls to the various class-specific initialisation functions.
|
||||
StringBuilder stubInitialiser = new StringBuilder();
|
||||
stubInitialiser.append("void InitStubs(JNIEnv *jEnv) {\n");
|
||||
CodeGenerator generatorInstance = new CodeGenerator();
|
||||
|
||||
while (jarClassIterator.hasNext()) {
|
||||
ClassWithOptions aClassTuple = jarClassIterator.next();
|
||||
|
||||
CodeGenerator generatorInstance;
|
||||
Class<?> aClass = jarClassIterator.next();
|
||||
|
||||
// Get an iterator over the appropriately generated methods of this class
|
||||
Iterator<AnnotatableEntity> methodIterator = new GeneratableElementIterator(aClassTuple.wrappedClass);
|
||||
Iterator<MethodWithAnnotationInfo> methodIterator = new GeneratableEntryPointIterator(aClass.getDeclaredMethods());
|
||||
|
||||
if (!methodIterator.hasNext()) {
|
||||
continue;
|
||||
}
|
||||
generatorInstance = new CodeGenerator(aClassTuple.wrappedClass, aClassTuple.generatedName);
|
||||
|
||||
stubInitialiser.append(" ").append(aClassTuple.generatedName).append("::InitStubs(jEnv);\n");
|
||||
|
||||
// Iterate all annotated members in this class..
|
||||
// Iterate all annotated methods in this class..
|
||||
while (methodIterator.hasNext()) {
|
||||
AnnotatableEntity aElementTuple = methodIterator.next();
|
||||
switch (aElementTuple.mEntityType) {
|
||||
case METHOD:
|
||||
generatorInstance.generateMethod(aElementTuple);
|
||||
break;
|
||||
case FIELD:
|
||||
generatorInstance.generateField(aElementTuple);
|
||||
break;
|
||||
case CONSTRUCTOR:
|
||||
generatorInstance.generateConstructor(aElementTuple);
|
||||
break;
|
||||
}
|
||||
MethodWithAnnotationInfo aMethodTuple = methodIterator.next();
|
||||
generatorInstance.generateMethod(aMethodTuple, aClass);
|
||||
}
|
||||
|
||||
headerFile.append(generatorInstance.getHeaderFileContents());
|
||||
implementationFile.append(generatorInstance.getWrapperFileContents());
|
||||
}
|
||||
|
||||
implementationFile.append('\n');
|
||||
stubInitialiser.append("}");
|
||||
implementationFile.append(stubInitialiser);
|
||||
|
||||
implementationFile.append("\n} /* android */\n" +
|
||||
"} /* widget */\n" +
|
||||
"} /* mozilla */\n");
|
||||
|
||||
headerFile.append("\n} /* android */\n" +
|
||||
"} /* widget */\n" +
|
||||
"} /* mozilla */\n" +
|
||||
"#endif\n");
|
||||
|
||||
writeOutputFiles(headerFile, implementationFile);
|
||||
writeOutputFiles(generatorInstance);
|
||||
long e = System.currentTimeMillis();
|
||||
System.out.println("Annotation processing complete in " + (e - s) + "ms");
|
||||
}
|
||||
|
||||
private static void writeOutputFiles(StringBuilder aHeaderFile, StringBuilder aImplementationFile) {
|
||||
FileOutputStream headerStream = null;
|
||||
private static void writeOutputFiles(CodeGenerator aGenerator) {
|
||||
try {
|
||||
headerStream = new FileOutputStream(OUTFILE);
|
||||
headerStream.write(aImplementationFile.toString().getBytes());
|
||||
FileOutputStream outStream = new FileOutputStream(OUTFILE);
|
||||
outStream.write(aGenerator.getWrapperFileContents());
|
||||
} catch (IOException e) {
|
||||
System.err.println("Unable to write " + OUTFILE + ". Perhaps a permissions issue?");
|
||||
e.printStackTrace(System.err);
|
||||
} finally {
|
||||
if (headerStream != null) {
|
||||
try {
|
||||
headerStream.close();
|
||||
} catch (IOException e) {
|
||||
System.err.println("Unable to close headerStream due to "+e);
|
||||
e.printStackTrace(System.err);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
FileOutputStream outStream = null;
|
||||
try {
|
||||
outStream = new FileOutputStream(HEADERFILE);
|
||||
outStream.write(aHeaderFile.toString().getBytes());
|
||||
FileOutputStream headerStream = new FileOutputStream(HEADERFILE);
|
||||
headerStream.write(aGenerator.getHeaderFileContents());
|
||||
} catch (IOException e) {
|
||||
System.err.println("Unable to write " + HEADERFILE + ". Perhaps a permissions issue?");
|
||||
System.err.println("Unable to write " + OUTFILE + ". Perhaps a permissions issue?");
|
||||
e.printStackTrace(System.err);
|
||||
} finally {
|
||||
if (outStream != null) {
|
||||
try {
|
||||
outStream.close();
|
||||
} catch (IOException e) {
|
||||
System.err.println("Unable to close outStream due to "+e);
|
||||
e.printStackTrace(System.err);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -4,236 +4,82 @@
|
||||
|
||||
package org.mozilla.gecko.annotationProcessors;
|
||||
|
||||
import org.mozilla.gecko.annotationProcessors.classloader.AnnotatableEntity;
|
||||
import org.mozilla.gecko.annotationProcessors.utils.Utils;
|
||||
|
||||
import java.lang.annotation.Annotation;
|
||||
import java.lang.reflect.Constructor;
|
||||
import java.lang.reflect.Field;
|
||||
import java.lang.reflect.Member;
|
||||
import java.lang.reflect.Method;
|
||||
import java.lang.reflect.Modifier;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
|
||||
public class CodeGenerator {
|
||||
private static final Class<?>[] EMPTY_CLASS_ARRAY = new Class<?>[0];
|
||||
private static final Annotation[][] GETTER_ARGUMENT_ANNOTATIONS = new Annotation[0][0];
|
||||
private static final Annotation[][] SETTER_ARGUMENT_ANNOTATIONS = new Annotation[1][0];
|
||||
|
||||
// Buffers holding the strings to ultimately be written to the output files.
|
||||
private final StringBuilder zeroingCode = new StringBuilder();
|
||||
private final StringBuilder wrapperStartupCode = new StringBuilder();
|
||||
private final StringBuilder wrapperMethodBodies = new StringBuilder();
|
||||
private final StringBuilder headerPublic = new StringBuilder();
|
||||
private final StringBuilder headerProtected = new StringBuilder();
|
||||
private final StringBuilder headerFields = new StringBuilder();
|
||||
private final StringBuilder headerMethods = new StringBuilder();
|
||||
|
||||
private final HashSet<String> seenClasses = new HashSet<String>();
|
||||
|
||||
private final String mCClassName;
|
||||
|
||||
private final Class<?> mClassToWrap;
|
||||
|
||||
private boolean mHasEncounteredDefaultConstructor;
|
||||
|
||||
// Used for creating unique names for method ID fields in the face of
|
||||
private final HashMap<Member, String> mMembersToIds = new HashMap<Member, String>();
|
||||
private final HashSet<String> mTakenMemberNames = new HashSet<String>();
|
||||
private int mNameMunger;
|
||||
|
||||
public CodeGenerator(Class<?> aClass, String aGeneratedName) {
|
||||
mClassToWrap = aClass;
|
||||
mCClassName = aGeneratedName;
|
||||
private final String GENERATED_COMMENT = "// GENERATED CODE\n" +
|
||||
"// Generated by the Java program at /build/annotationProcessors at compile time from\n" +
|
||||
"// annotations on Java methods. To update, change the annotations on the corresponding Java\n" +
|
||||
"// methods and rerun the build. Manually updating this file will cause your build to fail.\n\n";
|
||||
|
||||
public CodeGenerator() {
|
||||
// Write the file header things. Includes and so forth.
|
||||
// GeneratedJNIWrappers.cpp is generated as the concatenation of wrapperStartupCode with
|
||||
// wrapperMethodBodies. Similarly, GeneratedJNIWrappers.h is the concatenation of headerPublic
|
||||
// with headerProtected.
|
||||
wrapperStartupCode.append("void ").append(mCClassName).append("::InitStubs(JNIEnv *jEnv) {\n" +
|
||||
" initInit();\n");
|
||||
|
||||
// wrapperMethodBodies. Similarly, GeneratedJNIWrappers.h is the concatenation of headerFields
|
||||
// with headerMethods.
|
||||
wrapperStartupCode.append(GENERATED_COMMENT);
|
||||
wrapperStartupCode.append(
|
||||
"#include \"nsXPCOMStrings.h\"\n" +
|
||||
"#include \"AndroidBridge.h\"\n" +
|
||||
"#include \"AndroidBridgeUtilities.h\"\n" +
|
||||
"\n" +
|
||||
"#ifdef DEBUG\n" +
|
||||
"#define ALOG_BRIDGE(args...) ALOG(args)\n" +
|
||||
"#else\n" +
|
||||
"#define ALOG_BRIDGE(args...) ((void)0)\n" +
|
||||
"#endif\n" +
|
||||
"\n" +
|
||||
"using namespace mozilla;\n" +
|
||||
"void AndroidBridge::InitStubs(JNIEnv *jEnv) {\n" +
|
||||
" initInit();\n");
|
||||
// Now we write the various GetStaticMethodID calls here...
|
||||
headerPublic.append("class ").append(mCClassName).append(" : public AutoGlobalWrappedJavaObject {\n" +
|
||||
"public:\n" +
|
||||
" static void InitStubs(JNIEnv *jEnv);\n");
|
||||
headerProtected.append("protected:");
|
||||
|
||||
generateWrapperMethod();
|
||||
}
|
||||
|
||||
/**
|
||||
* Emit a static method which takes an instance of the class being wrapped and returns an instance
|
||||
* of the C++ wrapper class backed by that object.
|
||||
*/
|
||||
private void generateWrapperMethod() {
|
||||
headerPublic.append(" static ").append(mCClassName).append("* Wrap(jobject obj);\n" +
|
||||
" ").append(mCClassName).append("(jobject obj, JNIEnv* env) : AutoGlobalWrappedJavaObject(obj, env) {};\n");
|
||||
|
||||
wrapperMethodBodies.append("\n").append(mCClassName).append("* ").append(mCClassName).append("::Wrap(jobject obj) {\n" +
|
||||
" JNIEnv *env = GetJNIForThread();\n\n" +
|
||||
" if (!env) {\n" +
|
||||
" ALOG_BRIDGE(\"Aborted: No env - %s\", __PRETTY_FUNCTION__);\n" +
|
||||
" return NULL;\n" +
|
||||
" }\n\n" +
|
||||
" ").append(mCClassName).append("* ret = new ").append(mCClassName).append("(obj, env);\n" +
|
||||
" env->DeleteLocalRef(obj);\n" +
|
||||
" return ret;\n" +
|
||||
"}\n");
|
||||
}
|
||||
|
||||
private void generateMemberCommon(Member theMethod, String aCMethodName, Class<?> aClass) {
|
||||
ensureClassHeaderAndStartup(aClass);
|
||||
writeMemberIdField(theMethod, aCMethodName);
|
||||
writeStartupCode(theMethod);
|
||||
headerFields.append("protected:\n\n");
|
||||
headerMethods.append(GENERATED_COMMENT);
|
||||
headerMethods.append("public:\n\n");
|
||||
}
|
||||
|
||||
/**
|
||||
* Append the appropriate generated code to the buffers for the method provided.
|
||||
*
|
||||
* @param aMethodTuple The Java method, plus annotation data.
|
||||
* @param aMethodTuple The Java method, plus the name for the generated method.
|
||||
* @param aClass The class to which the Java method belongs.
|
||||
*/
|
||||
public void generateMethod(AnnotatableEntity aMethodTuple) {
|
||||
public void generateMethod(MethodWithAnnotationInfo aMethodTuple, Class<?> aClass) {
|
||||
// Unpack the tuple and extract some useful fields from the Method..
|
||||
Method theMethod = aMethodTuple.getMethod();
|
||||
Method aMethod = aMethodTuple.method;
|
||||
String CMethodName = aMethodTuple.wrapperName;
|
||||
|
||||
String CMethodName = aMethodTuple.mAnnotationInfo.wrapperName;
|
||||
String javaMethodName = aMethod.getName();
|
||||
|
||||
generateMemberCommon(theMethod, CMethodName, mClassToWrap);
|
||||
ensureClassHeaderAndStartup(aClass);
|
||||
|
||||
boolean isFieldStatic = Utils.isMemberStatic(theMethod);
|
||||
boolean shallGenerateStatic = isFieldStatic || aMethodTuple.mAnnotationInfo.isStatic;
|
||||
|
||||
Class<?>[] parameterTypes = theMethod.getParameterTypes();
|
||||
Class<?> returnType = theMethod.getReturnType();
|
||||
writeHeaderField(CMethodName);
|
||||
writeStartupCode(CMethodName, javaMethodName, aMethod, aClass);
|
||||
|
||||
// Get the C++ method signature for this method.
|
||||
String implementationSignature = Utils.getCImplementationMethodSignature(parameterTypes, returnType, CMethodName, mCClassName);
|
||||
String headerSignature = Utils.getCHeaderMethodSignature(parameterTypes, theMethod.getParameterAnnotations(), returnType, CMethodName, mCClassName, shallGenerateStatic);
|
||||
String implementationSignature = Utils.getCImplementationMethodSignature(aMethod, CMethodName);
|
||||
String headerSignature = Utils.getCHeaderMethodSignature(aMethod, CMethodName, aMethodTuple.isStatic);
|
||||
|
||||
// Add the header signature to the header file.
|
||||
writeSignatureToHeader(headerSignature);
|
||||
headerMethods.append(headerSignature);
|
||||
headerMethods.append(";\n");
|
||||
|
||||
// Use the implementation signature to generate the method body...
|
||||
writeMethodBody(implementationSignature, CMethodName, theMethod, mClassToWrap, aMethodTuple.mAnnotationInfo.isStatic, aMethodTuple.mAnnotationInfo.isMultithreaded);
|
||||
}
|
||||
|
||||
private void generateGetterOrSetterBody(Class<?> aFieldType, String aFieldName, boolean aIsFieldStatic, boolean isSetter) {
|
||||
StringBuilder argumentContent = null;
|
||||
|
||||
if (isSetter) {
|
||||
Class<?>[] setterArguments = new Class<?>[]{aFieldType};
|
||||
// Marshall the argument..
|
||||
argumentContent = getArgumentMarshalling(setterArguments);
|
||||
}
|
||||
|
||||
boolean isObjectReturningMethod = Utils.isObjectType(aFieldType);
|
||||
wrapperMethodBodies.append(" ");
|
||||
if (isSetter) {
|
||||
wrapperMethodBodies.append("env->Set");
|
||||
} else {
|
||||
wrapperMethodBodies.append("return ");
|
||||
|
||||
if (isObjectReturningMethod) {
|
||||
wrapperMethodBodies.append("static_cast<").append(Utils.getCReturnType(aFieldType)).append(">(");
|
||||
}
|
||||
|
||||
wrapperMethodBodies.append("env->Get");
|
||||
}
|
||||
|
||||
if (aIsFieldStatic) {
|
||||
wrapperMethodBodies.append("Static");
|
||||
}
|
||||
wrapperMethodBodies.append(Utils.getFieldType(aFieldType))
|
||||
.append("Field(");
|
||||
|
||||
// Static will require the class and the field id. Nonstatic, the object and the field id.
|
||||
if (aIsFieldStatic) {
|
||||
wrapperMethodBodies.append(Utils.getClassReferenceName(mClassToWrap));
|
||||
} else {
|
||||
wrapperMethodBodies.append("wrapped_obj");
|
||||
}
|
||||
wrapperMethodBodies.append(", j")
|
||||
.append(aFieldName);
|
||||
if (isSetter) {
|
||||
wrapperMethodBodies.append(argumentContent);
|
||||
}
|
||||
|
||||
if (!isSetter && isObjectReturningMethod) {
|
||||
wrapperMethodBodies.append(')');
|
||||
}
|
||||
wrapperMethodBodies.append(");\n" +
|
||||
"}\n");
|
||||
}
|
||||
|
||||
public void generateField(AnnotatableEntity aFieldTuple) {
|
||||
Field theField = aFieldTuple.getField();
|
||||
|
||||
// Handles a peculiar case when dealing with enum types. We don't care about this field.
|
||||
// It just gets in the way and stops our code from compiling.
|
||||
if (theField.getName().equals("$VALUES")) {
|
||||
return;
|
||||
}
|
||||
|
||||
String CFieldName = aFieldTuple.mAnnotationInfo.wrapperName;
|
||||
|
||||
Class<?> fieldType = theField.getType();
|
||||
|
||||
generateMemberCommon(theField, CFieldName, mClassToWrap);
|
||||
|
||||
boolean isFieldStatic = Utils.isMemberStatic(theField);
|
||||
boolean isFieldFinal = Utils.isMemberFinal(theField);
|
||||
boolean shallGenerateStatic = isFieldStatic || aFieldTuple.mAnnotationInfo.isStatic;
|
||||
|
||||
String getterName = "get" + CFieldName;
|
||||
String getterSignature = Utils.getCImplementationMethodSignature(EMPTY_CLASS_ARRAY, fieldType, getterName, mCClassName);
|
||||
String getterHeaderSignature = Utils.getCHeaderMethodSignature(EMPTY_CLASS_ARRAY, GETTER_ARGUMENT_ANNOTATIONS, fieldType, getterName, mCClassName, shallGenerateStatic);
|
||||
|
||||
writeSignatureToHeader(getterHeaderSignature);
|
||||
|
||||
writeFunctionStartupBoilerPlate(getterSignature, fieldType, isFieldStatic, true);
|
||||
|
||||
generateGetterOrSetterBody(fieldType, CFieldName, isFieldStatic, false);
|
||||
|
||||
// If field not final, also generate a setter function.
|
||||
if (!isFieldFinal) {
|
||||
String setterName = "set" + CFieldName;
|
||||
|
||||
Class<?>[] setterArguments = new Class<?>[]{fieldType};
|
||||
|
||||
String setterSignature = Utils.getCImplementationMethodSignature(setterArguments, Void.class, setterName, mCClassName);
|
||||
String setterHeaderSignature = Utils.getCHeaderMethodSignature(setterArguments, SETTER_ARGUMENT_ANNOTATIONS, Void.class, setterName, mCClassName, shallGenerateStatic);
|
||||
|
||||
writeSignatureToHeader(setterHeaderSignature);
|
||||
|
||||
writeFunctionStartupBoilerPlate(setterSignature, Void.class, isFieldStatic, true);
|
||||
|
||||
generateGetterOrSetterBody(fieldType, CFieldName, isFieldStatic, true);
|
||||
}
|
||||
}
|
||||
|
||||
public void generateConstructor(AnnotatableEntity aCtorTuple) {
|
||||
// Unpack the tuple and extract some useful fields from the Method..
|
||||
Constructor theCtor = aCtorTuple.getConstructor();
|
||||
String CMethodName = mCClassName;
|
||||
|
||||
generateMemberCommon(theCtor, mCClassName, mClassToWrap);
|
||||
|
||||
String implementationSignature = Utils.getCImplementationMethodSignature(theCtor.getParameterTypes(), Void.class, CMethodName, mCClassName);
|
||||
String headerSignature = Utils.getCHeaderMethodSignature(theCtor.getParameterTypes(), theCtor.getParameterAnnotations(), Void.class, CMethodName, mCClassName, false);
|
||||
|
||||
// Slice off the "void " from the start of the constructor declaration.
|
||||
headerSignature = headerSignature.substring(5);
|
||||
implementationSignature = implementationSignature.substring(5);
|
||||
|
||||
// Add the header signatures to the header file.
|
||||
writeSignatureToHeader(headerSignature);
|
||||
|
||||
// Use the implementation signature to generate the method body...
|
||||
writeCtorBody(implementationSignature, theCtor, aCtorTuple.mAnnotationInfo.isMultithreaded);
|
||||
|
||||
if (theCtor.getParameterTypes().length == 0) {
|
||||
mHasEncounteredDefaultConstructor = true;
|
||||
}
|
||||
writeMethodBody(implementationSignature, CMethodName, aMethod, aClass, aMethodTuple.isStatic, aMethodTuple.isMultithreaded);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -248,169 +94,18 @@ public class CodeGenerator {
|
||||
return;
|
||||
}
|
||||
|
||||
zeroingCode.append("jclass ")
|
||||
.append(mCClassName)
|
||||
.append("::")
|
||||
.append(Utils.getClassReferenceName(aClass))
|
||||
.append(" = 0;\n");
|
||||
|
||||
// Add a field to hold the reference...
|
||||
headerProtected.append("\n static jclass ")
|
||||
.append(Utils.getClassReferenceName(aClass))
|
||||
.append(";\n");
|
||||
headerFields.append("\njclass ");
|
||||
headerFields.append(Utils.getClassReferenceName(aClass));
|
||||
headerFields.append(";\n");
|
||||
|
||||
// Add startup code to populate it..
|
||||
wrapperStartupCode.append('\n')
|
||||
.append(Utils.getStartupLineForClass(aClass));
|
||||
wrapperStartupCode.append('\n');
|
||||
wrapperStartupCode.append(Utils.getStartupLineForClass(aClass));
|
||||
|
||||
seenClasses.add(className);
|
||||
}
|
||||
|
||||
/**
|
||||
* Write out the function startup boilerplate for the method described. Check for environment
|
||||
* existence,
|
||||
* @param methodSignature
|
||||
* @param returnType
|
||||
* @param aIsStatic
|
||||
* @param aIsThreaded
|
||||
*/
|
||||
private void writeFunctionStartupBoilerPlate(String methodSignature, Class<?> returnType, boolean aIsStatic, boolean aIsThreaded) {
|
||||
// The start-of-function boilerplate. Does the bridge exist? Does the env exist? etc.
|
||||
wrapperMethodBodies.append('\n')
|
||||
.append(methodSignature)
|
||||
.append(" {\n");
|
||||
|
||||
wrapperMethodBodies.append(" JNIEnv *env = ");
|
||||
if (!aIsThreaded) {
|
||||
wrapperMethodBodies.append("AndroidBridge::GetJNIEnv();\n");
|
||||
} else {
|
||||
wrapperMethodBodies.append("GetJNIForThread();\n");
|
||||
}
|
||||
wrapperMethodBodies.append(" if (!env) {\n" +
|
||||
" ALOG_BRIDGE(\"Aborted: No env - %s\", __PRETTY_FUNCTION__);\n" +
|
||||
" return").append(Utils.getFailureReturnForType(returnType)).append(";\n" +
|
||||
" }\n\n");
|
||||
}
|
||||
|
||||
/**
|
||||
* Write out the appropriate JNI frame pushing boilerplate for a call to the member provided (
|
||||
* which must be a constructor or method).
|
||||
*
|
||||
* @param aMethod A constructor/method being wrapped.
|
||||
* @param aIsObjectReturningMethod Does the method being wrapped return an object?
|
||||
*/
|
||||
private void writeFramePushBoilerplate(Member aMethod, boolean aIsObjectReturningMethod) {
|
||||
if (aMethod instanceof Field) {
|
||||
throw new IllegalArgumentException("Tried to push frame for a FIELD?!");
|
||||
}
|
||||
|
||||
Method m;
|
||||
Constructor c;
|
||||
|
||||
Class<?> returnType;
|
||||
|
||||
int localReferencesNeeded;
|
||||
if (aMethod instanceof Method) {
|
||||
m = (Method) aMethod;
|
||||
returnType = m.getReturnType();
|
||||
localReferencesNeeded = Utils.enumerateReferenceArguments(m.getParameterTypes());
|
||||
} else {
|
||||
c = (Constructor) aMethod;
|
||||
returnType = Void.class;
|
||||
localReferencesNeeded = Utils.enumerateReferenceArguments(c.getParameterTypes());
|
||||
}
|
||||
|
||||
// Determine the number of local refs required for our local frame..
|
||||
// AutoLocalJNIFrame is not applicable here due to it's inability to handle return values.
|
||||
if (aIsObjectReturningMethod) {
|
||||
localReferencesNeeded++;
|
||||
}
|
||||
wrapperMethodBodies.append(" if (env->PushLocalFrame(").append(localReferencesNeeded).append(") != 0) {\n" +
|
||||
" ALOG_BRIDGE(\"Exceptional exit of: %s\", __PRETTY_FUNCTION__);\n" +
|
||||
" env->ExceptionDescribe();\n"+
|
||||
" env->ExceptionClear();\n" +
|
||||
" return").append(Utils.getFailureReturnForType(returnType)).append(";\n" +
|
||||
" }\n\n");
|
||||
|
||||
}
|
||||
|
||||
private StringBuilder getArgumentMarshalling(Class<?>[] argumentTypes) {
|
||||
StringBuilder argumentContent = new StringBuilder();
|
||||
|
||||
// If we have >2 arguments, use the jvalue[] calling approach.
|
||||
argumentContent.append(", ");
|
||||
if (argumentTypes.length > 2) {
|
||||
wrapperMethodBodies.append(" jvalue args[").append(argumentTypes.length).append("];\n");
|
||||
for (int aT = 0; aT < argumentTypes.length; aT++) {
|
||||
wrapperMethodBodies.append(" args[").append(aT).append("].")
|
||||
.append(Utils.getArrayArgumentMashallingLine(argumentTypes[aT], "a" + aT));
|
||||
}
|
||||
|
||||
// The only argument is the array of arguments.
|
||||
argumentContent.append("args");
|
||||
wrapperMethodBodies.append('\n');
|
||||
} else {
|
||||
// Otherwise, use the vanilla calling approach.
|
||||
boolean needsNewline = false;
|
||||
for (int aT = 0; aT < argumentTypes.length; aT++) {
|
||||
// If the argument is a string-esque type, create a jstring from it, otherwise
|
||||
// it can be passed directly.
|
||||
if (Utils.isCharSequence(argumentTypes[aT])) {
|
||||
wrapperMethodBodies.append(" jstring j").append(aT).append(" = AndroidBridge::NewJavaString(env, a").append(aT).append(");\n");
|
||||
needsNewline = true;
|
||||
// Ensure we refer to the newly constructed Java string - not to the original
|
||||
// parameter to the wrapper function.
|
||||
argumentContent.append('j').append(aT);
|
||||
} else {
|
||||
argumentContent.append('a').append(aT);
|
||||
}
|
||||
if (aT != argumentTypes.length - 1) {
|
||||
argumentContent.append(", ");
|
||||
}
|
||||
}
|
||||
if (needsNewline) {
|
||||
wrapperMethodBodies.append('\n');
|
||||
}
|
||||
}
|
||||
|
||||
return argumentContent;
|
||||
}
|
||||
|
||||
private void writeCtorBody(String implementationSignature, Constructor theCtor, boolean aIsThreaded) {
|
||||
Class<?>[] argumentTypes = theCtor.getParameterTypes();
|
||||
|
||||
writeFunctionStartupBoilerPlate(implementationSignature, Void.class, false, aIsThreaded);
|
||||
|
||||
writeFramePushBoilerplate(theCtor, false);
|
||||
|
||||
// Marshall arguments for this constructor, if any...
|
||||
boolean hasArguments = argumentTypes.length != 0;
|
||||
|
||||
StringBuilder argumentContent = new StringBuilder();
|
||||
if (hasArguments) {
|
||||
argumentContent = getArgumentMarshalling(argumentTypes);
|
||||
}
|
||||
|
||||
// The call into Java
|
||||
wrapperMethodBodies.append(" Init(env->NewObject");
|
||||
if (argumentTypes.length > 2) {
|
||||
wrapperMethodBodies.append('A');
|
||||
}
|
||||
|
||||
wrapperMethodBodies.append('(');
|
||||
|
||||
|
||||
// Call takes class id, method id of constructor method, then arguments.
|
||||
wrapperMethodBodies.append(Utils.getClassReferenceName(mClassToWrap)).append(", ");
|
||||
|
||||
wrapperMethodBodies.append(mMembersToIds.get(theCtor))
|
||||
// Tack on the arguments, if any..
|
||||
.append(argumentContent)
|
||||
.append("), env);\n" +
|
||||
" env->PopLocalFrame(NULL);\n" +
|
||||
"}\n");
|
||||
}
|
||||
|
||||
/**
|
||||
* Generates the method body of the C++ wrapper function for the Java method indicated.
|
||||
*
|
||||
@ -424,11 +119,44 @@ public class CodeGenerator {
|
||||
Class<?>[] argumentTypes = aMethod.getParameterTypes();
|
||||
Class<?> returnType = aMethod.getReturnType();
|
||||
|
||||
writeFunctionStartupBoilerPlate(methodSignature, returnType, aIsStaticBridgeMethod, aIsMultithreaded);
|
||||
// The start-of-function boilerplate. Does the bridge exist? Does the env exist? etc.
|
||||
wrapperMethodBodies.append('\n');
|
||||
wrapperMethodBodies.append(methodSignature);
|
||||
|
||||
boolean isObjectReturningMethod = !returnType.getCanonicalName().equals("void") && Utils.isObjectType(returnType);
|
||||
wrapperMethodBodies.append(" {\n");
|
||||
|
||||
writeFramePushBoilerplate(aMethod, isObjectReturningMethod);
|
||||
// Static stubs check the bridge instance has been created before trying to run.
|
||||
if (aIsStaticBridgeMethod) {
|
||||
wrapperMethodBodies.append(" if (!sBridge) {\n" +
|
||||
" ALOG_BRIDGE(\"Aborted: No sBridge - %s\", __PRETTY_FUNCTION__);\n" +
|
||||
" return").append(Utils.getFailureReturnForType(returnType)).append(";\n" +
|
||||
" }\n\n");
|
||||
}
|
||||
wrapperMethodBodies.append(" JNIEnv *env = ");
|
||||
if (!aIsMultithreaded) {
|
||||
wrapperMethodBodies.append("GetJNIEnv();\n");
|
||||
} else {
|
||||
wrapperMethodBodies.append("GetJNIForThread();\n");
|
||||
}
|
||||
wrapperMethodBodies.append(" if (!env) {\n" +
|
||||
" ALOG_BRIDGE(\"Aborted: No env - %s\", __PRETTY_FUNCTION__);\n" +
|
||||
" return").append(Utils.getFailureReturnForType(returnType)).append(";\n" +
|
||||
" }\n\n");
|
||||
|
||||
boolean isObjectReturningMethod = !returnType.getCanonicalName().equals("void") && Utils.doesReturnObjectType(aMethod);
|
||||
|
||||
// Determine the number of local refs required for our local frame..
|
||||
// AutoLocalJNIFrame is not applicable here due to it's inability to handle return values.
|
||||
int localReferencesNeeded = Utils.enumerateReferenceArguments(aMethod);
|
||||
if (isObjectReturningMethod) {
|
||||
localReferencesNeeded++;
|
||||
}
|
||||
wrapperMethodBodies.append(" if (env->PushLocalFrame(").append(localReferencesNeeded).append(") != 0) {\n" +
|
||||
" ALOG_BRIDGE(\"Exceptional exit of: %s\", __PRETTY_FUNCTION__);\n" +
|
||||
" env->ExceptionDescribe();\n"+
|
||||
" env->ExceptionClear();\n" +
|
||||
" return").append(Utils.getFailureReturnForType(returnType)).append(";\n" +
|
||||
" }\n\n");
|
||||
|
||||
// Marshall arguments, if we have any.
|
||||
boolean hasArguments = argumentTypes.length != 0;
|
||||
@ -440,10 +168,43 @@ public class CodeGenerator {
|
||||
// argumentContent).
|
||||
StringBuilder argumentContent = new StringBuilder();
|
||||
if (hasArguments) {
|
||||
argumentContent = getArgumentMarshalling(argumentTypes);
|
||||
argumentContent.append(", ");
|
||||
// If we have >2 arguments, use the jvalue[] calling approach.
|
||||
if (argumentTypes.length > 2) {
|
||||
wrapperMethodBodies.append(" jvalue args[").append(argumentTypes.length).append("];\n");
|
||||
for (int aT = 0; aT < argumentTypes.length; aT++) {
|
||||
wrapperMethodBodies.append(" args[").append(aT).append("].");
|
||||
wrapperMethodBodies.append(Utils.getArrayArgumentMashallingLine(argumentTypes[aT], "a" + aT));
|
||||
}
|
||||
|
||||
// The only argument is the array of arguments.
|
||||
argumentContent.append("args");
|
||||
wrapperMethodBodies.append('\n');
|
||||
} else {
|
||||
// Otherwise, use the vanilla calling approach.
|
||||
boolean needsNewline = false;
|
||||
for (int aT = 0; aT < argumentTypes.length; aT++) {
|
||||
// If the argument is a string-esque type, create a jstring from it, otherwise
|
||||
// it can be passed directly.
|
||||
if (Utils.isCharSequence(argumentTypes[aT])) {
|
||||
wrapperMethodBodies.append(" jstring j").append(aT).append(" = NewJavaString(env, a").append(aT).append(");\n");
|
||||
needsNewline = true;
|
||||
// Ensure we refer to the newly constructed Java string - not to the original
|
||||
// parameter to the wrapper function.
|
||||
argumentContent.append('j').append(aT);
|
||||
} else {
|
||||
argumentContent.append('a').append(aT);
|
||||
}
|
||||
if (aT != argumentTypes.length - 1) {
|
||||
argumentContent.append(", ");
|
||||
}
|
||||
}
|
||||
if (needsNewline) {
|
||||
wrapperMethodBodies.append('\n');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Allocate a temporary variable to hold the return type from Java.
|
||||
wrapperMethodBodies.append(" ");
|
||||
if (!returnType.getCanonicalName().equals("void")) {
|
||||
if (isObjectReturningMethod) {
|
||||
@ -454,11 +215,11 @@ public class CodeGenerator {
|
||||
wrapperMethodBodies.append(" temp = ");
|
||||
}
|
||||
|
||||
boolean isStaticJavaMethod = Utils.isMemberStatic(aMethod);
|
||||
boolean isStaticJavaMethod = Utils.isMethodStatic(aMethod);
|
||||
|
||||
// The call into Java
|
||||
wrapperMethodBodies.append("env->")
|
||||
.append(Utils.getCallPrefix(returnType, isStaticJavaMethod));
|
||||
wrapperMethodBodies.append("env->");
|
||||
wrapperMethodBodies.append(Utils.getCallPrefix(returnType, isStaticJavaMethod));
|
||||
if (argumentTypes.length > 2) {
|
||||
wrapperMethodBodies.append('A');
|
||||
}
|
||||
@ -466,18 +227,28 @@ public class CodeGenerator {
|
||||
wrapperMethodBodies.append('(');
|
||||
// If the underlying Java method is nonstatic, we provide the target object to the JNI.
|
||||
if (!isStaticJavaMethod) {
|
||||
wrapperMethodBodies.append("wrapped_obj, ");
|
||||
wrapperMethodBodies.append("aTarget, ");
|
||||
} else {
|
||||
// If this is a static underlying Java method, we need to use the class reference in our
|
||||
// If the stub to be generated is static, we need to use the singleton to access the class
|
||||
// reference.
|
||||
if (aIsStaticBridgeMethod) {
|
||||
wrapperMethodBodies.append("sBridge->");
|
||||
}
|
||||
// If this is a static underlyin Java method, we need to use the class reference in our
|
||||
// call.
|
||||
wrapperMethodBodies.append(Utils.getClassReferenceName(aClass)).append(", ");
|
||||
}
|
||||
|
||||
wrapperMethodBodies.append(mMembersToIds.get(aMethod));
|
||||
// Write the method id out..
|
||||
if (aIsStaticBridgeMethod) {
|
||||
wrapperMethodBodies.append("sBridge->");
|
||||
}
|
||||
wrapperMethodBodies.append('j');
|
||||
wrapperMethodBodies.append(aCMethodName);
|
||||
|
||||
// Tack on the arguments, if any..
|
||||
wrapperMethodBodies.append(argumentContent)
|
||||
.append(");\n\n");
|
||||
wrapperMethodBodies.append(argumentContent);
|
||||
wrapperMethodBodies.append(");\n\n");
|
||||
|
||||
// Check for exception and return the failure value..
|
||||
wrapperMethodBodies.append(" if (env->ExceptionCheck()) {\n" +
|
||||
@ -486,14 +257,14 @@ public class CodeGenerator {
|
||||
" env->ExceptionClear();\n" +
|
||||
" env->PopLocalFrame(NULL);\n" +
|
||||
" return").append(Utils.getFailureReturnForType(returnType)).append(";\n" +
|
||||
" }\n\n");
|
||||
" }\n");
|
||||
|
||||
// If we're returning an object, pop the callee's stack frame extracting our ref as the return
|
||||
// value.
|
||||
if (isObjectReturningMethod) {
|
||||
wrapperMethodBodies.append(" ")
|
||||
.append(Utils.getCReturnType(returnType))
|
||||
.append(" ret = static_cast<").append(Utils.getCReturnType(returnType)).append(">(env->PopLocalFrame(temp));\n" +
|
||||
wrapperMethodBodies.append(" ");
|
||||
wrapperMethodBodies.append(Utils.getCReturnType(returnType));
|
||||
wrapperMethodBodies.append(" ret = static_cast<").append(Utils.getCReturnType(returnType)).append(">(env->PopLocalFrame(temp));\n" +
|
||||
" return ret;\n");
|
||||
} else if (!returnType.getCanonicalName().equals("void")) {
|
||||
// If we're a primitive-returning function, just return the directly-obtained primative
|
||||
@ -508,83 +279,35 @@ public class CodeGenerator {
|
||||
}
|
||||
|
||||
/**
|
||||
* Generates the code to get the id of the given member on startup.
|
||||
* Generates the code to get the method id of the given method on startup.
|
||||
*
|
||||
* @param aMember The Java member being wrapped.
|
||||
* @param aCMethodName The C method name of the method being generated.
|
||||
* @param aJavaMethodName The name of the Java method being wrapped.
|
||||
* @param aMethod The Java method being wrapped.
|
||||
*/
|
||||
private void writeStartupCode(Member aMember) {
|
||||
wrapperStartupCode.append(" ")
|
||||
.append(mMembersToIds.get(aMember))
|
||||
.append(" = get");
|
||||
if (Utils.isMemberStatic(aMember)) {
|
||||
private void writeStartupCode(String aCMethodName, String aJavaMethodName, Method aMethod, Class<?> aClass) {
|
||||
wrapperStartupCode.append(" j");
|
||||
wrapperStartupCode.append(aCMethodName);
|
||||
wrapperStartupCode.append(" = get");
|
||||
if (Utils.isMethodStatic(aMethod)) {
|
||||
wrapperStartupCode.append("Static");
|
||||
}
|
||||
|
||||
boolean isField = aMember instanceof Field;
|
||||
if (isField) {
|
||||
wrapperStartupCode.append("Field(\"");
|
||||
} else {
|
||||
wrapperStartupCode.append("Method(\"");
|
||||
}
|
||||
if (aMember instanceof Constructor) {
|
||||
wrapperStartupCode.append("<init>");
|
||||
} else {
|
||||
wrapperStartupCode.append(aMember.getName());
|
||||
}
|
||||
|
||||
wrapperStartupCode.append("\", \"")
|
||||
.append(Utils.getTypeSignatureStringForMember(aMember))
|
||||
.append("\");\n");
|
||||
}
|
||||
|
||||
private void writeZeroingFor(Member aMember, final String aMemberName) {
|
||||
if (aMember instanceof Field) {
|
||||
zeroingCode.append("jfieldID ");
|
||||
} else {
|
||||
zeroingCode.append("jmethodID ");
|
||||
}
|
||||
zeroingCode.append(mCClassName)
|
||||
.append("::")
|
||||
.append(aMemberName)
|
||||
.append(" = 0;\n");
|
||||
wrapperStartupCode.append("Method(\"");
|
||||
wrapperStartupCode.append(aJavaMethodName);
|
||||
wrapperStartupCode.append("\", \"");
|
||||
wrapperStartupCode.append(Utils.getTypeSignatureString(aMethod));
|
||||
wrapperStartupCode.append("\");\n");
|
||||
}
|
||||
|
||||
/**
|
||||
* Write the field declaration for the C++ id field of the given member.
|
||||
* Create a method id field in the header file for the C method name provided.
|
||||
*
|
||||
* @param aMember Member for which an id field needs to be generated.
|
||||
* @param aMethodName C method name to generate a method id field for.
|
||||
*/
|
||||
private void writeMemberIdField(Member aMember, final String aCMethodName) {
|
||||
String memberName = 'j'+ aCMethodName;
|
||||
|
||||
if (aMember instanceof Field) {
|
||||
headerProtected.append(" static jfieldID ");
|
||||
} else {
|
||||
headerProtected.append(" static jmethodID ");
|
||||
}
|
||||
|
||||
while(mTakenMemberNames.contains(memberName)) {
|
||||
memberName = 'j' + aCMethodName + mNameMunger;
|
||||
mNameMunger++;
|
||||
}
|
||||
|
||||
writeZeroingFor(aMember, memberName);
|
||||
mMembersToIds.put(aMember, memberName);
|
||||
mTakenMemberNames.add(memberName);
|
||||
|
||||
headerProtected.append(memberName)
|
||||
.append(";\n");
|
||||
}
|
||||
|
||||
/**
|
||||
* Helper function to add a provided method signature to the public section of the generated header.
|
||||
*
|
||||
* @param aSignature The header to add.
|
||||
*/
|
||||
private void writeSignatureToHeader(String aSignature) {
|
||||
headerPublic.append(" ")
|
||||
.append(aSignature)
|
||||
.append(";\n");
|
||||
private void writeHeaderField(String aMethodName) {
|
||||
headerFields.append("jmethodID j");
|
||||
headerFields.append(aMethodName);
|
||||
headerFields.append(";\n");
|
||||
}
|
||||
|
||||
/**
|
||||
@ -592,13 +315,11 @@ public class CodeGenerator {
|
||||
*
|
||||
* @return The bytes to be written to the wrappers file.
|
||||
*/
|
||||
public String getWrapperFileContents() {
|
||||
public byte[] getWrapperFileContents() {
|
||||
wrapperStartupCode.append("}\n");
|
||||
zeroingCode.append(wrapperStartupCode)
|
||||
.append(wrapperMethodBodies);
|
||||
wrapperStartupCode.append(wrapperMethodBodies);
|
||||
wrapperMethodBodies.setLength(0);
|
||||
wrapperStartupCode.setLength(0);
|
||||
return zeroingCode.toString();
|
||||
return wrapperStartupCode.toString().getBytes();
|
||||
}
|
||||
|
||||
/**
|
||||
@ -606,13 +327,10 @@ public class CodeGenerator {
|
||||
*
|
||||
* @return The bytes to be written to the header file.
|
||||
*/
|
||||
public String getHeaderFileContents() {
|
||||
if (!mHasEncounteredDefaultConstructor) {
|
||||
headerPublic.append(" ").append(mCClassName).append("() : AutoGlobalWrappedJavaObject() {};\n");
|
||||
}
|
||||
headerProtected.append("};\n\n");
|
||||
headerPublic.append(headerProtected);
|
||||
headerProtected.setLength(0);
|
||||
return headerPublic.toString();
|
||||
public byte[] getHeaderFileContents() {
|
||||
headerFields.append('\n');
|
||||
headerFields.append(headerMethods);
|
||||
headerMethods.setLength(0);
|
||||
return headerFields.toString().getBytes();
|
||||
}
|
||||
}
|
||||
|
@ -4,15 +4,19 @@
|
||||
|
||||
package org.mozilla.gecko.annotationProcessors;
|
||||
|
||||
import java.lang.reflect.Method;
|
||||
|
||||
/**
|
||||
* Object holding annotation data. Used by GeneratableElementIterator.
|
||||
* Object holding method and annotation. Used by GeneratableEntryPointIterator.
|
||||
*/
|
||||
public class AnnotationInfo {
|
||||
public class MethodWithAnnotationInfo {
|
||||
public final Method method;
|
||||
public final String wrapperName;
|
||||
public final boolean isStatic;
|
||||
public final boolean isMultithreaded;
|
||||
|
||||
public AnnotationInfo(String aWrapperName, boolean aIsStatic, boolean aIsMultithreaded) {
|
||||
public MethodWithAnnotationInfo(Method aMethod, String aWrapperName, boolean aIsStatic, boolean aIsMultithreaded) {
|
||||
method = aMethod;
|
||||
wrapperName = aWrapperName;
|
||||
isStatic = aIsStatic;
|
||||
isMultithreaded = aIsMultithreaded;
|
@ -1,57 +0,0 @@
|
||||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
package org.mozilla.gecko.annotationProcessors.classloader;
|
||||
|
||||
import org.mozilla.gecko.annotationProcessors.AnnotationInfo;
|
||||
|
||||
import java.lang.reflect.Constructor;
|
||||
import java.lang.reflect.Field;
|
||||
import java.lang.reflect.Member;
|
||||
import java.lang.reflect.Method;
|
||||
|
||||
/**
|
||||
* Union type to hold either a method, field, or ctor. Allows us to iterate "The generatable stuff", despite
|
||||
* the fact that such things can be of either flavour.
|
||||
*/
|
||||
public class AnnotatableEntity {
|
||||
public enum ENTITY_TYPE {METHOD, FIELD, CONSTRUCTOR}
|
||||
|
||||
private final Member mMember;
|
||||
public final ENTITY_TYPE mEntityType;
|
||||
|
||||
public final AnnotationInfo mAnnotationInfo;
|
||||
|
||||
public AnnotatableEntity(Member aObject, AnnotationInfo aAnnotationInfo) {
|
||||
mMember = aObject;
|
||||
mAnnotationInfo = aAnnotationInfo;
|
||||
|
||||
if (aObject instanceof Method) {
|
||||
mEntityType = ENTITY_TYPE.METHOD;
|
||||
} else if (aObject instanceof Field) {
|
||||
mEntityType = ENTITY_TYPE.FIELD;
|
||||
} else {
|
||||
mEntityType = ENTITY_TYPE.CONSTRUCTOR;
|
||||
}
|
||||
}
|
||||
|
||||
public Method getMethod() {
|
||||
if (mEntityType != ENTITY_TYPE.METHOD) {
|
||||
throw new UnsupportedOperationException("Attempt to cast to unsupported member type.");
|
||||
}
|
||||
return (Method) mMember;
|
||||
}
|
||||
public Field getField() {
|
||||
if (mEntityType != ENTITY_TYPE.FIELD) {
|
||||
throw new UnsupportedOperationException("Attempt to cast to unsupported member type.");
|
||||
}
|
||||
return (Field) mMember;
|
||||
}
|
||||
public Constructor getConstructor() {
|
||||
if (mEntityType != ENTITY_TYPE.CONSTRUCTOR) {
|
||||
throw new UnsupportedOperationException("Attempt to cast to unsupported member type.");
|
||||
}
|
||||
return (Constructor) mMember;
|
||||
}
|
||||
}
|
@ -1,15 +0,0 @@
|
||||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
package org.mozilla.gecko.annotationProcessors.classloader;
|
||||
|
||||
public class ClassWithOptions {
|
||||
public final Class<?> wrappedClass;
|
||||
public final String generatedName;
|
||||
|
||||
public ClassWithOptions(Class<?> someClass, String name) {
|
||||
wrappedClass = someClass;
|
||||
generatedName = name;
|
||||
}
|
||||
}
|
@ -21,6 +21,8 @@ import java.util.jar.JarFile;
|
||||
* classNames is kept sorted to ensure iteration order is consistent across program invocations.
|
||||
* Otherwise, we'd forever be reporting the outdatedness of the generated code as we permute its
|
||||
* contents.
|
||||
* This classloader does not support inner classes. (You probably shouldn't be putting JNI entry
|
||||
* points in inner classes anyway)
|
||||
*/
|
||||
public class IterableJarLoadingURLClassLoader extends URLClassLoader {
|
||||
LinkedList<String> classNames = new LinkedList<String>();
|
||||
@ -33,7 +35,7 @@ public class IterableJarLoadingURLClassLoader extends URLClassLoader {
|
||||
* @param args A list of jar file names an iterator over the classes of which is desired.
|
||||
* @return An iterator over the top level classes in the jar files provided, in arbitrary order.
|
||||
*/
|
||||
public static Iterator<ClassWithOptions> getIteratorOverJars(String[] args) {
|
||||
public static Iterator<Class<?>> getIteratorOverJars(String[] args) {
|
||||
URL[] urlArray = new URL[args.length];
|
||||
LinkedList<String> aClassNames = new LinkedList<String>();
|
||||
|
||||
@ -49,7 +51,10 @@ public class IterableJarLoadingURLClassLoader extends URLClassLoader {
|
||||
continue;
|
||||
}
|
||||
final String className = fName.substring(0, fName.length() - 6).replace('/', '.');
|
||||
|
||||
// Inner classes are not supported.
|
||||
if (className.contains("$")) {
|
||||
continue;
|
||||
}
|
||||
aClassNames.add(className);
|
||||
}
|
||||
} catch (IOException e) {
|
||||
|
@ -4,15 +4,12 @@
|
||||
|
||||
package org.mozilla.gecko.annotationProcessors.classloader;
|
||||
|
||||
import java.lang.annotation.Annotation;
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.Iterator;
|
||||
|
||||
/**
|
||||
* Class for iterating over an IterableJarLoadingURLClassLoader's classes.
|
||||
*/
|
||||
public class JarClassIterator implements Iterator<ClassWithOptions> {
|
||||
public class JarClassIterator implements Iterator<Class<?>> {
|
||||
private IterableJarLoadingURLClassLoader mTarget;
|
||||
private Iterator<String> mTargetClassListIterator;
|
||||
|
||||
@ -27,46 +24,10 @@ public class JarClassIterator implements Iterator<ClassWithOptions> {
|
||||
}
|
||||
|
||||
@Override
|
||||
public ClassWithOptions next() {
|
||||
public Class<?> next() {
|
||||
String className = mTargetClassListIterator.next();
|
||||
try {
|
||||
Class<?> ret = mTarget.loadClass(className);
|
||||
if (ret.getCanonicalName() == null || "null".equals(ret.getCanonicalName())) {
|
||||
// Anonymous inner class - unsupported.
|
||||
return next();
|
||||
} else {
|
||||
String generateName = null;
|
||||
for (Annotation annotation : ret.getAnnotations()) {
|
||||
Class<?> annotationType = annotation.annotationType();
|
||||
if (annotationType.getCanonicalName().equals("org.mozilla.gecko.mozglue.generatorannotations.GeneratorOptions")) {
|
||||
try {
|
||||
// Determine the explicitly-given name of the stub to generate, if any.
|
||||
final Method generateNameMethod = annotationType.getDeclaredMethod("generatedClassName");
|
||||
generateNameMethod.setAccessible(true);
|
||||
generateName = (String) generateNameMethod.invoke(annotation);
|
||||
break;
|
||||
} catch (NoSuchMethodException e) {
|
||||
System.err.println("Unable to find expected field on GeneratorOptions annotation. Did the signature change?");
|
||||
e.printStackTrace(System.err);
|
||||
System.exit(3);
|
||||
} catch (IllegalAccessException e) {
|
||||
System.err.println("IllegalAccessException reading fields on GeneratorOptions annotation. Seems the semantics of Reflection have changed...");
|
||||
e.printStackTrace(System.err);
|
||||
System.exit(4);
|
||||
} catch (InvocationTargetException e) {
|
||||
System.err.println("InvocationTargetException reading fields on GeneratorOptions annotation. This really shouldn't happen.");
|
||||
e.printStackTrace(System.err);
|
||||
System.exit(5);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (generateName == null) {
|
||||
generateName = ret.getSimpleName();
|
||||
}
|
||||
|
||||
return new ClassWithOptions(ret, generateName);
|
||||
}
|
||||
return mTarget.loadClass(className);
|
||||
} catch (ClassNotFoundException e) {
|
||||
System.err.println("Unable to enumerate class: " + className + ". Corrupted jar file?");
|
||||
e.printStackTrace();
|
||||
|
@ -1,81 +0,0 @@
|
||||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
package org.mozilla.gecko.annotationProcessors.utils;
|
||||
|
||||
import java.lang.reflect.Constructor;
|
||||
import java.lang.reflect.Field;
|
||||
import java.lang.reflect.Member;
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.Comparator;
|
||||
|
||||
public class AlphabeticAnnotatableEntityComparator<T extends Member> implements Comparator<T> {
|
||||
@Override
|
||||
public int compare(T aLhs, T aRhs) {
|
||||
// Constructors, Methods, Fields.
|
||||
boolean lIsConstructor = aLhs instanceof Constructor;
|
||||
boolean rIsConstructor = aRhs instanceof Constructor;
|
||||
boolean lIsMethod = aLhs instanceof Method;
|
||||
boolean rIsField = aRhs instanceof Field;
|
||||
|
||||
if (lIsConstructor) {
|
||||
if (!rIsConstructor) {
|
||||
return -1;
|
||||
}
|
||||
} else if (lIsMethod) {
|
||||
if (rIsConstructor) {
|
||||
return 1;
|
||||
} else if (rIsField) {
|
||||
return -1;
|
||||
}
|
||||
} else {
|
||||
if (!rIsField) {
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
// Verify these objects are the same type and cast them.
|
||||
if (aLhs instanceof Method) {
|
||||
return compare((Method) aLhs, (Method) aRhs);
|
||||
} else if (aLhs instanceof Field) {
|
||||
return compare((Field) aLhs, (Field) aRhs);
|
||||
} else {
|
||||
return compare((Constructor) aLhs, (Constructor) aRhs);
|
||||
}
|
||||
}
|
||||
|
||||
// Alas, the type system fails us.
|
||||
private static int compare(Method aLhs, Method aRhs) {
|
||||
// Initially, attempt to differentiate the methods be name alone..
|
||||
String lName = aLhs.getName();
|
||||
String rName = aRhs.getName();
|
||||
|
||||
int ret = lName.compareTo(rName);
|
||||
if (ret != 0) {
|
||||
return ret;
|
||||
}
|
||||
|
||||
// The names were the same, so we need to compare signatures to find their uniqueness..
|
||||
lName = Utils.getTypeSignatureStringForMethod(aLhs);
|
||||
rName = Utils.getTypeSignatureStringForMethod(aRhs);
|
||||
|
||||
return lName.compareTo(rName);
|
||||
}
|
||||
|
||||
private static int compare(Constructor aLhs, Constructor aRhs) {
|
||||
// The names will be the same, so we need to compare signatures to find their uniqueness..
|
||||
String lName = Utils.getTypeSignatureString(aLhs);
|
||||
String rName = Utils.getTypeSignatureString(aRhs);
|
||||
|
||||
return lName.compareTo(rName);
|
||||
}
|
||||
|
||||
private static int compare(Field aLhs, Field aRhs) {
|
||||
// Compare field names..
|
||||
String lName = aLhs.getName();
|
||||
String rName = aRhs.getName();
|
||||
|
||||
return lName.compareTo(rName);
|
||||
}
|
||||
}
|
@ -0,0 +1,28 @@
|
||||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
package org.mozilla.gecko.annotationProcessors.utils;
|
||||
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.Comparator;
|
||||
|
||||
public class AlphabeticMethodComparator implements Comparator<Method> {
|
||||
@Override
|
||||
public int compare(Method lhs, Method rhs) {
|
||||
// Initially, attempt to differentiate the methods be name alone..
|
||||
String lName = lhs.getName();
|
||||
String rName = rhs.getName();
|
||||
|
||||
int ret = lName.compareTo(rName);
|
||||
if (ret != 0) {
|
||||
return ret;
|
||||
}
|
||||
|
||||
// The names were the same, so we need to compare signatures to find their uniqueness..
|
||||
lName = Utils.getTypeSignatureString(lhs);
|
||||
rName = Utils.getTypeSignatureString(rhs);
|
||||
|
||||
return lName.compareTo(rName);
|
||||
}
|
||||
}
|
@ -4,58 +4,31 @@
|
||||
|
||||
package org.mozilla.gecko.annotationProcessors.utils;
|
||||
|
||||
import org.mozilla.gecko.annotationProcessors.AnnotationInfo;
|
||||
import org.mozilla.gecko.annotationProcessors.classloader.AnnotatableEntity;
|
||||
import org.mozilla.gecko.annotationProcessors.MethodWithAnnotationInfo;
|
||||
|
||||
import java.lang.annotation.Annotation;
|
||||
import java.lang.reflect.AnnotatedElement;
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.lang.reflect.Member;
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Iterator over the methods in a given method list which have the WrappedJNIMethod
|
||||
* Iterator over the methods in a given method list which have the GeneratableAndroidBridgeTarget
|
||||
* annotation. Returns an object containing both the annotation (Which may contain interesting
|
||||
* parameters) and the argument.
|
||||
*/
|
||||
public class GeneratableElementIterator implements Iterator<AnnotatableEntity> {
|
||||
private final Member[] mObjects;
|
||||
private AnnotatableEntity mNextReturnValue;
|
||||
private int mElementIndex;
|
||||
public class GeneratableEntryPointIterator implements Iterator<MethodWithAnnotationInfo> {
|
||||
private final Method[] mMethods;
|
||||
private MethodWithAnnotationInfo mNextReturnValue;
|
||||
private int mMethodIndex;
|
||||
|
||||
private boolean mIterateEveryEntry;
|
||||
|
||||
public GeneratableElementIterator(Class<?> aClass) {
|
||||
// Get all the elements of this class as AccessibleObjects.
|
||||
Member[] aMethods = aClass.getDeclaredMethods();
|
||||
Member[] aFields = aClass.getDeclaredFields();
|
||||
Member[] aCtors = aClass.getConstructors();
|
||||
|
||||
// Shove them all into one buffer.
|
||||
Member[] objs = new Member[aMethods.length + aFields.length + aCtors.length];
|
||||
int offset = 0;
|
||||
System.arraycopy(aMethods, 0, objs, 0, aMethods.length);
|
||||
offset += aMethods.length;
|
||||
System.arraycopy(aFields, 0, objs, offset, aFields.length);
|
||||
offset += aFields.length;
|
||||
System.arraycopy(aCtors, 0, objs, offset, aCtors.length);
|
||||
|
||||
// Sort the elements to ensure determinism.
|
||||
Arrays.sort(objs, new AlphabeticAnnotatableEntityComparator());
|
||||
|
||||
mObjects = objs;
|
||||
|
||||
// Check for "Wrap ALL the things" flag.
|
||||
for (Annotation annotation : aClass.getDeclaredAnnotations()) {
|
||||
final String annotationTypeName = annotation.annotationType().getName();
|
||||
|
||||
if (annotationTypeName.equals("org.mozilla.gecko.mozglue.generatorannotations.WrapEntireClassForJNI")) {
|
||||
mIterateEveryEntry = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
public GeneratableEntryPointIterator(Method[] aMethods) {
|
||||
// Sort the methods into alphabetical order by name, to ensure we always iterate methods
|
||||
// in the same order..
|
||||
Arrays.sort(aMethods, new AlphabeticMethodComparator());
|
||||
mMethods = aMethods;
|
||||
|
||||
findNextValue();
|
||||
}
|
||||
@ -65,15 +38,15 @@ public class GeneratableElementIterator implements Iterator<AnnotatableEntity> {
|
||||
* one exists. Otherwise cache null, so hasNext returns false.
|
||||
*/
|
||||
private void findNextValue() {
|
||||
while (mElementIndex < mObjects.length) {
|
||||
Member candidateElement = mObjects[mElementIndex];
|
||||
mElementIndex++;
|
||||
for (Annotation annotation : ((AnnotatedElement) candidateElement).getDeclaredAnnotations()) {
|
||||
// WrappedJNIMethod has a parameter. Use Reflection to obtain it.
|
||||
while (mMethodIndex < mMethods.length) {
|
||||
Method candidateMethod = mMethods[mMethodIndex];
|
||||
mMethodIndex++;
|
||||
for (Annotation annotation : candidateMethod.getDeclaredAnnotations()) {
|
||||
// GeneratableAndroidBridgeTarget has a parameter. Use Reflection to obtain it.
|
||||
Class<? extends Annotation> annotationType = annotation.annotationType();
|
||||
final String annotationTypeName = annotationType.getName();
|
||||
|
||||
if (annotationTypeName.equals("org.mozilla.gecko.mozglue.generatorannotations.WrapElementForJNI")) {
|
||||
if (annotationTypeName.equals("org.mozilla.gecko.mozglue.GeneratableAndroidBridgeTarget")) {
|
||||
String stubName = null;
|
||||
boolean isStaticStub = false;
|
||||
boolean isMultithreadedStub = false;
|
||||
@ -93,38 +66,28 @@ public class GeneratableElementIterator implements Iterator<AnnotatableEntity> {
|
||||
multithreadedStubMethod.setAccessible(true);
|
||||
isMultithreadedStub = (Boolean) multithreadedStubMethod.invoke(annotation);
|
||||
} catch (NoSuchMethodException e) {
|
||||
System.err.println("Unable to find expected field on WrappedJNIMethod annotation. Did the signature change?");
|
||||
System.err.println("Unable to find expected field on GeneratableAndroidBridgeTarget annotation. Did the signature change?");
|
||||
e.printStackTrace(System.err);
|
||||
System.exit(3);
|
||||
} catch (IllegalAccessException e) {
|
||||
System.err.println("IllegalAccessException reading fields on WrappedJNIMethod annotation. Seems the semantics of Reflection have changed...");
|
||||
System.err.println("IllegalAccessException reading fields on GeneratableAndroidBridgeTarget annotation. Seems the semantics of Reflection have changed...");
|
||||
e.printStackTrace(System.err);
|
||||
System.exit(4);
|
||||
} catch (InvocationTargetException e) {
|
||||
System.err.println("InvocationTargetException reading fields on WrappedJNIMethod annotation. This really shouldn't happen.");
|
||||
System.err.println("InvocationTargetException reading fields on GeneratableAndroidBridgeTarget annotation. This really shouldn't happen.");
|
||||
e.printStackTrace(System.err);
|
||||
System.exit(5);
|
||||
}
|
||||
|
||||
// If the element name was not explicitly given in the annotation generate one...
|
||||
// If the method name was not explicitly given in the annotation generate one...
|
||||
if (stubName.isEmpty()) {
|
||||
String elementName = candidateElement.getName();
|
||||
stubName = elementName.substring(0, 1).toUpperCase() + elementName.substring(1);
|
||||
String aMethodName = candidateMethod.getName();
|
||||
stubName = aMethodName.substring(0, 1).toUpperCase() + aMethodName.substring(1);
|
||||
}
|
||||
|
||||
AnnotationInfo annotationInfo = new AnnotationInfo(stubName, isStaticStub, isMultithreadedStub);
|
||||
mNextReturnValue = new AnnotatableEntity(candidateElement, annotationInfo);
|
||||
mNextReturnValue = new MethodWithAnnotationInfo(candidateMethod, stubName, isStaticStub, isMultithreadedStub);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
// If no annotation found, we might be expected to generate anyway using default arguments,
|
||||
// thanks to the "Generate everything" annotation.
|
||||
if (mIterateEveryEntry) {
|
||||
AnnotationInfo annotationInfo = new AnnotationInfo(candidateElement.getName(), false, false);
|
||||
mNextReturnValue = new AnnotatableEntity(candidateElement, annotationInfo);
|
||||
return;
|
||||
}
|
||||
}
|
||||
mNextReturnValue = null;
|
||||
}
|
||||
@ -135,14 +98,14 @@ public class GeneratableElementIterator implements Iterator<AnnotatableEntity> {
|
||||
}
|
||||
|
||||
@Override
|
||||
public AnnotatableEntity next() {
|
||||
AnnotatableEntity ret = mNextReturnValue;
|
||||
public MethodWithAnnotationInfo next() {
|
||||
MethodWithAnnotationInfo ret = mNextReturnValue;
|
||||
findNextValue();
|
||||
return ret;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void remove() {
|
||||
throw new UnsupportedOperationException("Removal of methods from GeneratableElementIterator not supported.");
|
||||
throw new UnsupportedOperationException("Removal of methods from GeneratableEntryPointIterator not supported.");
|
||||
}
|
||||
}
|
@ -5,9 +5,6 @@
|
||||
package org.mozilla.gecko.annotationProcessors.utils;
|
||||
|
||||
import java.lang.annotation.Annotation;
|
||||
import java.lang.reflect.Constructor;
|
||||
import java.lang.reflect.Field;
|
||||
import java.lang.reflect.Member;
|
||||
import java.lang.reflect.Method;
|
||||
import java.lang.reflect.Modifier;
|
||||
import java.util.HashMap;
|
||||
@ -73,23 +70,9 @@ public class Utils {
|
||||
sInstanceCallTypes.put("short", "CallShortMethod");
|
||||
}
|
||||
|
||||
private static final HashMap<String, String> sFieldTypes = new HashMap<String, String>();
|
||||
|
||||
static {
|
||||
sFieldTypes.put("int", "Int");
|
||||
sFieldTypes.put("boolean", "Boolean");
|
||||
sFieldTypes.put("long", "Long");
|
||||
sFieldTypes.put("double", "Double");
|
||||
sFieldTypes.put("float", "Float");
|
||||
sFieldTypes.put("char", "Char");
|
||||
sFieldTypes.put("byte", "Byte");
|
||||
sFieldTypes.put("short", "Short");
|
||||
}
|
||||
|
||||
private static final HashMap<String, String> sFailureReturns = new HashMap<String, String>();
|
||||
|
||||
static {
|
||||
sFailureReturns.put("java.lang.Void", "");
|
||||
sFailureReturns.put("void", "");
|
||||
sFailureReturns.put("int", " 0");
|
||||
sFailureReturns.put("boolean", " false");
|
||||
@ -104,7 +87,6 @@ public class Utils {
|
||||
private static final HashMap<String, String> sCanonicalSignatureParts = new HashMap<String, String>();
|
||||
|
||||
static {
|
||||
sCanonicalSignatureParts.put("java/lang/Void", "V");
|
||||
sCanonicalSignatureParts.put("void", "V");
|
||||
sCanonicalSignatureParts.put("int", "I");
|
||||
sCanonicalSignatureParts.put("boolean", "Z");
|
||||
@ -182,9 +164,7 @@ public class Utils {
|
||||
* @return A string representation of the C++ return type.
|
||||
*/
|
||||
public static String getCReturnType(Class<?> type) {
|
||||
if (type.getCanonicalName().equals("java.lang.Void")) {
|
||||
return "void";
|
||||
}
|
||||
// Since there's only one thing we want to do differently...
|
||||
String cParameterType = getCParameterType(type);
|
||||
if (cParameterType.equals("const nsAString&")) {
|
||||
return "jstring";
|
||||
@ -193,21 +173,6 @@ public class Utils {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the type-specific part of the JNI function to use to get or set a field of a given type.
|
||||
*
|
||||
* @param aFieldType The Java type of the field.
|
||||
* @return A string representation of the JNI call function substring to use.
|
||||
*/
|
||||
public static String getFieldType(Class<?> aFieldType) {
|
||||
String name = aFieldType.getCanonicalName();
|
||||
|
||||
if (sFieldTypes.containsKey(name)) {
|
||||
return sFieldTypes.get(name);
|
||||
}
|
||||
return "Object";
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the appropriate JNI call function to use to invoke a Java method with the given return
|
||||
* type. This, plus a call postfix (Such as "A") forms a complete JNI call function name.
|
||||
@ -247,15 +212,15 @@ public class Utils {
|
||||
}
|
||||
|
||||
/**
|
||||
* Helper method to get the type signature for methods, given argument and return type.
|
||||
* Allows for the near-identical logic needed for constructors and methods to be shared.
|
||||
* (Alas, constructor does not extend method)
|
||||
* Get the canonical JNI type signature for a method.
|
||||
*
|
||||
* @param arguments Argument types of the underlying method.
|
||||
* @param returnType Return type of the underlying method.
|
||||
* @return The canonical Java type string for the method. eg. (IIIIFZ)Lorg/mozilla/gecko/gfx/ViewTransform;
|
||||
* @param aMethod The method to generate a signature for.
|
||||
* @return The canonical JNI type signature for this method.
|
||||
*/
|
||||
private static String getTypeSignatureInternal(Class<?>[] arguments, Class<?> returnType) {
|
||||
public static String getTypeSignatureString(Method aMethod) {
|
||||
Class<?>[] arguments = aMethod.getParameterTypes();
|
||||
Class<?> returnType = aMethod.getReturnType();
|
||||
|
||||
StringBuilder sb = new StringBuilder();
|
||||
sb.append('(');
|
||||
// For each argument, write its signature component to the buffer..
|
||||
@ -269,69 +234,7 @@ public class Utils {
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the canonical JNI type signature for a Field.
|
||||
*
|
||||
* @param aField The field to generate a signature for.
|
||||
* @return The canonical JNI type signature for this method.
|
||||
*/
|
||||
protected static String getTypeSignatureStringForField(Field aField) {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
writeTypeSignature(sb, aField.getType());
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the canonical JNI type signature for a method.
|
||||
*
|
||||
* @param aMethod The method to generate a signature for.
|
||||
* @return The canonical JNI type signature for this method.
|
||||
*/
|
||||
protected static String getTypeSignatureStringForMethod(Method aMethod) {
|
||||
Class<?>[] arguments = aMethod.getParameterTypes();
|
||||
Class<?> returnType = aMethod.getReturnType();
|
||||
|
||||
return getTypeSignatureInternal(arguments, returnType);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the canonical JNI type signature for a Constructor.
|
||||
*
|
||||
* @param aConstructor The Constructor to generate a signature for.
|
||||
* @return The canonical JNI type signature for this method.
|
||||
*/
|
||||
protected static String getTypeSignatureStringForConstructor(Constructor aConstructor) {
|
||||
Class<?>[] arguments = aConstructor.getParameterTypes();
|
||||
|
||||
return getTypeSignatureInternal(arguments, Void.class);
|
||||
}
|
||||
|
||||
public static String getTypeSignatureStringForMember(Member aMember) {
|
||||
if (aMember instanceof Method) {
|
||||
return getTypeSignatureStringForMethod((Method) aMember);
|
||||
} else if (aMember instanceof Field) {
|
||||
return getTypeSignatureStringForField((Field) aMember);
|
||||
} else {
|
||||
return getTypeSignatureStringForConstructor((Constructor) aMember);
|
||||
}
|
||||
}
|
||||
|
||||
public static String getTypeSignatureString(Constructor aConstructor) {
|
||||
Class<?>[] arguments = aConstructor.getParameterTypes();
|
||||
|
||||
StringBuilder sb = new StringBuilder();
|
||||
sb.append('(');
|
||||
// For each argument, write its signature component to the buffer..
|
||||
for (int i = 0; i < arguments.length; i++) {
|
||||
writeTypeSignature(sb, arguments[i]);
|
||||
}
|
||||
|
||||
// Constructors always return Void.
|
||||
sb.append(")V");
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* Helper method used by getTypeSignatureStringForMethod to build the signature. Write the subsignature
|
||||
* Helper method used by getTypeSignatureString to build the signature. Write the subsignature
|
||||
* of a given type into the buffer.
|
||||
*
|
||||
* @param sb The buffer to write into.
|
||||
@ -339,7 +242,6 @@ public class Utils {
|
||||
*/
|
||||
private static void writeTypeSignature(StringBuilder sb, Class<?> c) {
|
||||
String name = c.getCanonicalName().replaceAll("\\.", "/");
|
||||
|
||||
// Determine if this is an array type and, if so, peel away the array operators..
|
||||
int len = name.length();
|
||||
while (name.endsWith("[]")) {
|
||||
@ -347,17 +249,6 @@ public class Utils {
|
||||
name = name.substring(0, len - 2);
|
||||
}
|
||||
|
||||
if (c.isArray()) {
|
||||
c = c.getComponentType();
|
||||
}
|
||||
|
||||
Class<?> containerClass = c.getDeclaringClass();
|
||||
if (containerClass != null) {
|
||||
// Is an inner class. Add the $ symbol.
|
||||
final int lastSlash = name.lastIndexOf('/');
|
||||
name = name.substring(0, lastSlash) + '$' + name.substring(lastSlash+1);
|
||||
}
|
||||
|
||||
// Look in the hashmap for the remainder...
|
||||
if (sCanonicalSignatureParts.containsKey(name)) {
|
||||
// It was a primitive type, so lookup was a success.
|
||||
@ -374,31 +265,38 @@ public class Utils {
|
||||
* Produces a C method signature, sans semicolon, for the given Java Method. Useful for both
|
||||
* generating header files and method bodies.
|
||||
*
|
||||
* @param aArgumentTypes Argument types of the Java method being wrapped.
|
||||
* @param aReturnType Return type of the Java method being wrapped.
|
||||
* @param aCMethodName Name of the method to generate in the C++ class.
|
||||
* @param aCClassName Name of the C++ class into which the method is declared.
|
||||
* @return The C++ method implementation signature for the method described.
|
||||
* @param aMethod The Java method to generate the corresponding wrapper signature for.
|
||||
* @param aCMethodName The name of the generated method this is to be the signatgure for.
|
||||
* @return The generated method signature.
|
||||
*/
|
||||
public static String getCImplementationMethodSignature(Class<?>[] aArgumentTypes, Class<?> aReturnType, String aCMethodName, String aCClassName) {
|
||||
StringBuilder retBuffer = new StringBuilder();
|
||||
public static String getCImplementationMethodSignature(Method aMethod, String aCMethodName) {
|
||||
Class<?>[] argumentTypes = aMethod.getParameterTypes();
|
||||
Class<?> returnType = aMethod.getReturnType();
|
||||
|
||||
retBuffer.append(getCReturnType(aReturnType));
|
||||
retBuffer.append(' ');
|
||||
retBuffer.append(aCClassName);
|
||||
retBuffer.append("::");
|
||||
StringBuilder retBuffer = new StringBuilder();
|
||||
// Write return type..
|
||||
retBuffer.append(getCReturnType(returnType));
|
||||
retBuffer.append(" AndroidBridge::");
|
||||
retBuffer.append(aCMethodName);
|
||||
retBuffer.append('(');
|
||||
|
||||
// For an instance method, the first argument is the target object.
|
||||
if (!isMethodStatic(aMethod)) {
|
||||
retBuffer.append("jobject aTarget");
|
||||
if (argumentTypes.length > 0) {
|
||||
retBuffer.append(", ");
|
||||
}
|
||||
}
|
||||
|
||||
// Write argument types...
|
||||
for (int aT = 0; aT < aArgumentTypes.length; aT++) {
|
||||
retBuffer.append(getCParameterType(aArgumentTypes[aT]));
|
||||
for (int aT = 0; aT < argumentTypes.length; aT++) {
|
||||
retBuffer.append(getCParameterType(argumentTypes[aT]));
|
||||
retBuffer.append(" a");
|
||||
// We, imaginatively, call our arguments a1, a2, a3...
|
||||
// The only way to preserve the names from Java would be to parse the
|
||||
// Java source, which would be computationally hard.
|
||||
retBuffer.append(aT);
|
||||
if (aT != aArgumentTypes.length - 1) {
|
||||
if (aT != argumentTypes.length - 1) {
|
||||
retBuffer.append(", ");
|
||||
}
|
||||
}
|
||||
@ -414,18 +312,14 @@ public class Utils {
|
||||
* @param aCMethodName The name of the generated method this is to be the signatgure for.
|
||||
* @return The generated method signature.
|
||||
*/
|
||||
/**
|
||||
*
|
||||
* @param aArgumentTypes Argument types of the Java method being wrapped.
|
||||
* @param aArgumentAnnotations The annotations on the Java method arguments. Used to specify
|
||||
* default values etc.
|
||||
* @param aReturnType Return type of the Java method being wrapped.
|
||||
* @param aCMethodName Name of the method to generate in the C++ class.
|
||||
* @param aCClassName Name of the C++ class into which the method is declared.e
|
||||
* @param aIsStaticStub true if the generated C++ method should be static, false otherwise.
|
||||
* @return The generated C++ header method signature for the method described.
|
||||
*/
|
||||
public static String getCHeaderMethodSignature(Class<?>[] aArgumentTypes, Annotation[][] aArgumentAnnotations, Class<?> aReturnType, String aCMethodName, String aCClassName, boolean aIsStaticStub) {
|
||||
public static String getCHeaderMethodSignature(Method aMethod, String aCMethodName, boolean aIsStaticStub) {
|
||||
Class<?>[] argumentTypes = aMethod.getParameterTypes();
|
||||
|
||||
// The annotations on the parameters of this method, in declaration order.
|
||||
// Importantly - the same order as those in argumentTypes.
|
||||
Annotation[][] argumentAnnotations = aMethod.getParameterAnnotations();
|
||||
Class<?> returnType = aMethod.getReturnType();
|
||||
|
||||
StringBuilder retBuffer = new StringBuilder();
|
||||
|
||||
// Add the static keyword, if applicable.
|
||||
@ -434,14 +328,22 @@ public class Utils {
|
||||
}
|
||||
|
||||
// Write return type..
|
||||
retBuffer.append(getCReturnType(aReturnType));
|
||||
retBuffer.append(getCReturnType(returnType));
|
||||
retBuffer.append(' ');
|
||||
retBuffer.append(aCMethodName);
|
||||
retBuffer.append('(');
|
||||
|
||||
// For an instance method, the first argument is the target object.
|
||||
if (!isMethodStatic(aMethod)) {
|
||||
retBuffer.append("jobject aTarget");
|
||||
if (argumentTypes.length > 0) {
|
||||
retBuffer.append(", ");
|
||||
}
|
||||
}
|
||||
|
||||
// Write argument types...
|
||||
for (int aT = 0; aT < aArgumentTypes.length; aT++) {
|
||||
retBuffer.append(getCParameterType(aArgumentTypes[aT]));
|
||||
for (int aT = 0; aT < argumentTypes.length; aT++) {
|
||||
retBuffer.append(getCParameterType(argumentTypes[aT]));
|
||||
retBuffer.append(" a");
|
||||
// We, imaginatively, call our arguments a1, a2, a3...
|
||||
// The only way to preserve the names from Java would be to parse the
|
||||
@ -449,9 +351,9 @@ public class Utils {
|
||||
retBuffer.append(aT);
|
||||
|
||||
// Append the default value, if there is one..
|
||||
retBuffer.append(getDefaultValueString(aArgumentTypes[aT], aArgumentAnnotations[aT]));
|
||||
retBuffer.append(getDefaultValueString(argumentTypes[aT], argumentAnnotations[aT]));
|
||||
|
||||
if (aT != aArgumentTypes.length - 1) {
|
||||
if (aT != argumentTypes.length - 1) {
|
||||
retBuffer.append(", ");
|
||||
}
|
||||
}
|
||||
@ -473,7 +375,7 @@ public class Utils {
|
||||
for (int i = 0; i < aArgumentAnnotations.length; i++) {
|
||||
Class<? extends Annotation> annotationType = aArgumentAnnotations[i].annotationType();
|
||||
final String annotationTypeName = annotationType.getName();
|
||||
if (annotationTypeName.equals("org.mozilla.gecko.mozglue.generatorannotations.OptionalGeneratedParameter")) {
|
||||
if (annotationTypeName.equals("org.mozilla.gecko.mozglue.OptionalGeneratedParameter")) {
|
||||
return " = " + getDefaultParameterValueForType(aArgumentType);
|
||||
}
|
||||
}
|
||||
@ -503,13 +405,14 @@ public class Utils {
|
||||
/**
|
||||
* Helper method that returns the number of reference types in the arguments of m.
|
||||
*
|
||||
* @param aArgs The method arguments to consider.
|
||||
* @param m The method to consider.
|
||||
* @return How many of the arguments of m are nonprimitive.
|
||||
*/
|
||||
public static int enumerateReferenceArguments(Class<?>[] aArgs) {
|
||||
public static int enumerateReferenceArguments(Method m) {
|
||||
int ret = 0;
|
||||
for (int i = 0; i < aArgs.length; i++) {
|
||||
String name = aArgs[i].getCanonicalName();
|
||||
Class<?>[] args = m.getParameterTypes();
|
||||
for (int i = 0; i < args.length; i++) {
|
||||
String name = args[i].getCanonicalName();
|
||||
if (!sBasicCTypes.containsKey(name)) {
|
||||
ret++;
|
||||
}
|
||||
@ -549,7 +452,7 @@ public class Utils {
|
||||
sb.append(" = ").append(argName).append(";\n");
|
||||
} else {
|
||||
if (isCharSequence(type)) {
|
||||
sb.append("l = AndroidBridge::NewJavaString(env, ").append(argName).append(");\n");
|
||||
sb.append("l = NewJavaString(env, ").append(argName).append(");\n");
|
||||
} else {
|
||||
sb.append("l = ").append(argName).append(";\n");
|
||||
}
|
||||
@ -559,13 +462,15 @@ public class Utils {
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if the type provided is an object type. Returns false otherwise
|
||||
* Returns true if the method provided returns an object type. Returns false if it returns a
|
||||
* primitive type.
|
||||
*
|
||||
* @param aType The type to consider.
|
||||
* @return true if the method provided is an object type, false otherwise.
|
||||
* @param aMethod The method to consider.
|
||||
* @return true if the method provided returns an object type, false otherwise.
|
||||
*/
|
||||
public static boolean isObjectType(Class<?> aType) {
|
||||
return !sBasicCTypes.containsKey(aType.getCanonicalName());
|
||||
public static boolean doesReturnObjectType(Method aMethod) {
|
||||
Class<?> returnType = aMethod.getReturnType();
|
||||
return !sBasicCTypes.containsKey(returnType.getCanonicalName());
|
||||
}
|
||||
|
||||
/**
|
||||
@ -590,16 +495,7 @@ public class Utils {
|
||||
sb.append(" ");
|
||||
sb.append(getClassReferenceName(aClass));
|
||||
sb.append(" = getClassGlobalRef(\"");
|
||||
|
||||
String name = aClass.getCanonicalName().replaceAll("\\.", "/");
|
||||
Class<?> containerClass = aClass.getDeclaringClass();
|
||||
if (containerClass != null) {
|
||||
// Is an inner class. Add the $ symbol.
|
||||
final int lastSlash = name.lastIndexOf('/');
|
||||
name = name.substring(0, lastSlash) + '$' + name.substring(lastSlash+1);
|
||||
}
|
||||
|
||||
sb.append(name);
|
||||
sb.append(aClass.getCanonicalName().replaceAll("\\.", "/"));
|
||||
sb.append("\");\n");
|
||||
return sb.toString();
|
||||
}
|
||||
@ -624,21 +520,11 @@ public class Utils {
|
||||
|
||||
/**
|
||||
* Helper method to read the modifier bits of the given method to determine if it is static.
|
||||
* @param aMember The Member to check.
|
||||
* @param aMethod The Method to check.
|
||||
* @return true of the method is declared static, false otherwise.
|
||||
*/
|
||||
public static boolean isMemberStatic(Member aMember) {
|
||||
int aMethodModifiers = aMember.getModifiers();
|
||||
public static boolean isMethodStatic(Method aMethod) {
|
||||
int aMethodModifiers = aMethod.getModifiers();
|
||||
return Modifier.isStatic(aMethodModifiers);
|
||||
}
|
||||
|
||||
/**
|
||||
* Helper method to read the modifier bits of the given method to determine if it is static.
|
||||
* @param aMember The Member to check.
|
||||
* @return true of the method is declared static, false otherwise.
|
||||
*/
|
||||
public static boolean isMemberFinal(Member aMember) {
|
||||
int aMethodModifiers = aMember.getModifiers();
|
||||
return Modifier.isFinal(aMethodModifiers);
|
||||
}
|
||||
}
|
||||
|
@ -1559,8 +1559,8 @@ ContentParent::RecvGetShowPasswordSetting(bool* showPassword)
|
||||
*showPassword = true;
|
||||
#ifdef MOZ_WIDGET_ANDROID
|
||||
NS_ASSERTION(AndroidBridge::Bridge() != nullptr, "AndroidBridge is not available");
|
||||
|
||||
*showPassword = GeckoAppShell::GetShowPasswordSetting();
|
||||
if (AndroidBridge::Bridge() != nullptr)
|
||||
*showPassword = AndroidBridge::Bridge()->GetShowPasswordSetting();
|
||||
#endif
|
||||
return true;
|
||||
}
|
||||
|
@ -2260,7 +2260,11 @@ _getvalue(NPP npp, NPNVariable variable, void *result)
|
||||
}
|
||||
|
||||
case kJavaContext_ANPGetValue: {
|
||||
jobject ret = GeckoAppShell::GetContext();
|
||||
AndroidBridge *bridge = AndroidBridge::Bridge();
|
||||
if (!bridge)
|
||||
return NPERR_GENERIC_ERROR;
|
||||
|
||||
jobject ret = bridge->GetContext();
|
||||
if (!ret)
|
||||
return NPERR_GENERIC_ERROR;
|
||||
|
||||
|
@ -865,7 +865,7 @@ void nsNPAPIPluginInstance::NotifyFullScreen(bool aFullScreen)
|
||||
SendLifecycleEvent(this, mFullScreen ? kEnterFullScreen_ANPLifecycleAction : kExitFullScreen_ANPLifecycleAction);
|
||||
|
||||
if (mFullScreen && mFullScreenOrientation != dom::eScreenOrientation_None) {
|
||||
GeckoAppShell::LockScreenOrientation(mFullScreenOrientation);
|
||||
AndroidBridge::Bridge()->LockScreenOrientation(mFullScreenOrientation);
|
||||
}
|
||||
}
|
||||
|
||||
@ -922,11 +922,11 @@ void nsNPAPIPluginInstance::SetFullScreenOrientation(uint32_t orientation)
|
||||
// We're already fullscreen so immediately apply the orientation change
|
||||
|
||||
if (mFullScreenOrientation != dom::eScreenOrientation_None) {
|
||||
GeckoAppShell::LockScreenOrientation(mFullScreenOrientation);
|
||||
AndroidBridge::Bridge()->LockScreenOrientation(mFullScreenOrientation);
|
||||
} else if (oldOrientation != dom::eScreenOrientation_None) {
|
||||
// We applied an orientation when we entered fullscreen, but
|
||||
// we don't want it anymore
|
||||
GeckoAppShell::UnlockScreenOrientation();
|
||||
AndroidBridge::Bridge()->UnlockScreenOrientation();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1658,7 +1658,9 @@ void nsPluginInstanceOwner::RemovePluginView()
|
||||
if (!mInstance || !mJavaView)
|
||||
return;
|
||||
|
||||
GeckoAppShell::RemovePluginView((jobject)mJavaView, mFullScreen);
|
||||
if (AndroidBridge::Bridge())
|
||||
AndroidBridge::Bridge()->RemovePluginView((jobject)mJavaView, mFullScreen);
|
||||
|
||||
AndroidBridge::GetJNIEnv()->DeleteGlobalRef((jobject)mJavaView);
|
||||
mJavaView = nullptr;
|
||||
|
||||
|
@ -26,7 +26,9 @@ AndroidLocationProvider::~AndroidLocationProvider()
|
||||
NS_IMETHODIMP
|
||||
AndroidLocationProvider::Startup()
|
||||
{
|
||||
GeckoAppShell::EnableLocation(true);
|
||||
if (!AndroidBridge::Bridge())
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
AndroidBridge::Bridge()->EnableLocation(true);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
@ -42,13 +44,17 @@ AndroidLocationProvider::Watch(nsIGeolocationUpdate* aCallback)
|
||||
NS_IMETHODIMP
|
||||
AndroidLocationProvider::Shutdown()
|
||||
{
|
||||
GeckoAppShell::EnableLocation(false);
|
||||
if (!AndroidBridge::Bridge())
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
AndroidBridge::Bridge()->EnableLocation(false);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
AndroidLocationProvider::SetHighAccuracy(bool enable)
|
||||
{
|
||||
GeckoAppShell::EnableLocationHighAccuracy(enable);
|
||||
if (!AndroidBridge::Bridge())
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
AndroidBridge::Bridge()->EnableLocationHighAccuracy(enable);
|
||||
return NS_OK;
|
||||
}
|
||||
|
@ -14,6 +14,10 @@ NS_IMPL_ISUPPORTS1(nsHapticFeedback, nsIHapticFeedback)
|
||||
NS_IMETHODIMP
|
||||
nsHapticFeedback::PerformSimpleAction(int32_t aType)
|
||||
{
|
||||
GeckoAppShell::PerformHapticFeedback(aType == LongPress);
|
||||
return NS_OK;
|
||||
AndroidBridge* bridge = AndroidBridge::Bridge();
|
||||
if (bridge) {
|
||||
bridge->PerformHapticFeedback(aType == LongPress);
|
||||
return NS_OK;
|
||||
}
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
@ -2418,7 +2418,7 @@ public:
|
||||
#endif
|
||||
|
||||
virtual already_AddRefed<TextureImage>
|
||||
CreateDirectTextureImage(::android::GraphicBuffer* aBuffer, GLenum aWrapMode)
|
||||
CreateDirectTextureImage(android::GraphicBuffer* aBuffer, GLenum aWrapMode)
|
||||
{ return nullptr; }
|
||||
|
||||
// Before reads from offscreen texture
|
||||
|
@ -210,7 +210,7 @@ nsSurfaceTexture::~nsSurfaceTexture()
|
||||
return;
|
||||
|
||||
if (mSurfaceTexture && env) {
|
||||
GeckoAppShell::UnregisterSurfaceTextureFrameListener(mSurfaceTexture);
|
||||
AndroidBridge::Bridge()->UnregisterSurfaceTextureFrameListener(mSurfaceTexture);
|
||||
|
||||
env->DeleteGlobalRef(mSurfaceTexture);
|
||||
mSurfaceTexture = nullptr;
|
||||
@ -239,9 +239,9 @@ void
|
||||
nsSurfaceTexture::SetFrameAvailableCallback(nsIRunnable* aRunnable)
|
||||
{
|
||||
if (aRunnable)
|
||||
GeckoAppShell::RegisterSurfaceTextureFrameListener(mSurfaceTexture, mID);
|
||||
AndroidBridge::Bridge()->RegisterSurfaceTextureFrameListener(mSurfaceTexture, mID);
|
||||
else
|
||||
GeckoAppShell::UnregisterSurfaceTextureFrameListener(mSurfaceTexture);
|
||||
AndroidBridge::Bridge()->UnregisterSurfaceTextureFrameListener(mSurfaceTexture);
|
||||
|
||||
mFrameAvailableCallback = aRunnable;
|
||||
}
|
||||
|
@ -14,7 +14,6 @@
|
||||
|
||||
using namespace mozilla::dom;
|
||||
using namespace mozilla::hal;
|
||||
using namespace mozilla::widget::android;
|
||||
|
||||
namespace mozilla {
|
||||
namespace hal_impl {
|
||||
@ -55,55 +54,97 @@ CancelVibrate(const WindowIdentifier &)
|
||||
{
|
||||
// Ignore WindowIdentifier parameter.
|
||||
|
||||
GeckoAppShell::CancelVibrate();
|
||||
AndroidBridge* b = AndroidBridge::Bridge();
|
||||
if (b)
|
||||
b->CancelVibrate();
|
||||
}
|
||||
|
||||
void
|
||||
EnableBatteryNotifications()
|
||||
{
|
||||
GeckoAppShell::EnableBatteryNotifications();
|
||||
AndroidBridge* bridge = AndroidBridge::Bridge();
|
||||
if (!bridge) {
|
||||
return;
|
||||
}
|
||||
|
||||
bridge->EnableBatteryNotifications();
|
||||
}
|
||||
|
||||
void
|
||||
DisableBatteryNotifications()
|
||||
{
|
||||
GeckoAppShell::DisableBatteryNotifications();
|
||||
AndroidBridge* bridge = AndroidBridge::Bridge();
|
||||
if (!bridge) {
|
||||
return;
|
||||
}
|
||||
|
||||
bridge->DisableBatteryNotifications();
|
||||
}
|
||||
|
||||
void
|
||||
GetCurrentBatteryInformation(hal::BatteryInformation* aBatteryInfo)
|
||||
{
|
||||
AndroidBridge::Bridge()->GetCurrentBatteryInformation(aBatteryInfo);
|
||||
AndroidBridge* bridge = AndroidBridge::Bridge();
|
||||
if (!bridge) {
|
||||
return;
|
||||
}
|
||||
|
||||
bridge->GetCurrentBatteryInformation(aBatteryInfo);
|
||||
}
|
||||
|
||||
void
|
||||
EnableNetworkNotifications()
|
||||
{
|
||||
GeckoAppShell::EnableNetworkNotifications();
|
||||
AndroidBridge* bridge = AndroidBridge::Bridge();
|
||||
if (!bridge) {
|
||||
return;
|
||||
}
|
||||
|
||||
bridge->EnableNetworkNotifications();
|
||||
}
|
||||
|
||||
void
|
||||
DisableNetworkNotifications()
|
||||
{
|
||||
GeckoAppShell::DisableNetworkNotifications();
|
||||
AndroidBridge* bridge = AndroidBridge::Bridge();
|
||||
if (!bridge) {
|
||||
return;
|
||||
}
|
||||
|
||||
bridge->DisableNetworkNotifications();
|
||||
}
|
||||
|
||||
void
|
||||
GetCurrentNetworkInformation(hal::NetworkInformation* aNetworkInfo)
|
||||
{
|
||||
AndroidBridge::Bridge()->GetCurrentNetworkInformation(aNetworkInfo);
|
||||
AndroidBridge* bridge = AndroidBridge::Bridge();
|
||||
if (!bridge) {
|
||||
return;
|
||||
}
|
||||
|
||||
bridge->GetCurrentNetworkInformation(aNetworkInfo);
|
||||
}
|
||||
|
||||
void
|
||||
EnableScreenConfigurationNotifications()
|
||||
{
|
||||
GeckoAppShell::EnableScreenOrientationNotifications();
|
||||
AndroidBridge* bridge = AndroidBridge::Bridge();
|
||||
if (!bridge) {
|
||||
return;
|
||||
}
|
||||
|
||||
bridge->EnableScreenOrientationNotifications();
|
||||
}
|
||||
|
||||
void
|
||||
DisableScreenConfigurationNotifications()
|
||||
{
|
||||
GeckoAppShell::DisableScreenOrientationNotifications();
|
||||
AndroidBridge* bridge = AndroidBridge::Bridge();
|
||||
if (!bridge) {
|
||||
return;
|
||||
}
|
||||
|
||||
bridge->DisableScreenOrientationNotifications();
|
||||
}
|
||||
|
||||
void
|
||||
@ -140,6 +181,11 @@ GetCurrentScreenConfiguration(ScreenConfiguration* aScreenConfiguration)
|
||||
bool
|
||||
LockScreenOrientation(const ScreenOrientation& aOrientation)
|
||||
{
|
||||
AndroidBridge* bridge = AndroidBridge::Bridge();
|
||||
if (!bridge) {
|
||||
return false;
|
||||
}
|
||||
|
||||
switch (aOrientation) {
|
||||
// The Android backend only supports these orientations.
|
||||
case eScreenOrientation_PortraitPrimary:
|
||||
@ -148,7 +194,7 @@ LockScreenOrientation(const ScreenOrientation& aOrientation)
|
||||
case eScreenOrientation_LandscapePrimary:
|
||||
case eScreenOrientation_LandscapeSecondary:
|
||||
case eScreenOrientation_LandscapePrimary | eScreenOrientation_LandscapeSecondary:
|
||||
GeckoAppShell::LockScreenOrientation(aOrientation);
|
||||
bridge->LockScreenOrientation(aOrientation);
|
||||
return true;
|
||||
default:
|
||||
return false;
|
||||
@ -158,7 +204,12 @@ LockScreenOrientation(const ScreenOrientation& aOrientation)
|
||||
void
|
||||
UnlockScreenOrientation()
|
||||
{
|
||||
GeckoAppShell::UnlockScreenOrientation();
|
||||
AndroidBridge* bridge = AndroidBridge::Bridge();
|
||||
if (!bridge) {
|
||||
return;
|
||||
}
|
||||
|
||||
bridge->UnlockScreenOrientation();
|
||||
}
|
||||
|
||||
} // hal_impl
|
||||
|
@ -13,12 +13,12 @@ namespace hal_impl {
|
||||
|
||||
void
|
||||
EnableSensorNotifications(SensorType aSensor) {
|
||||
GeckoAppShell::EnableSensor(aSensor);
|
||||
AndroidBridge::Bridge()->EnableSensor(aSensor);
|
||||
}
|
||||
|
||||
void
|
||||
DisableSensorNotifications(SensorType aSensor) {
|
||||
GeckoAppShell::DisableSensor(aSensor);
|
||||
AndroidBridge::Bridge()->DisableSensor(aSensor);
|
||||
}
|
||||
|
||||
} // hal_impl
|
||||
|
@ -91,7 +91,7 @@ MessagePump::Run(MessagePump::Delegate* aDelegate)
|
||||
// This processes messages in the Android Looper. Note that we only
|
||||
// get here if the normal Gecko event loop has been awoken above.
|
||||
// Bug 750713
|
||||
did_work |= GeckoAppShell::PumpMessageLoop();
|
||||
did_work |= AndroidBridge::Bridge()->PumpMessageLoop();
|
||||
#endif
|
||||
|
||||
did_work |= aDelegate->DoDelayedWork(&delayed_work_time_);
|
||||
|
@ -11,8 +11,8 @@ import org.mozilla.gecko.gfx.GfxInfoThread;
|
||||
import org.mozilla.gecko.gfx.LayerView;
|
||||
import org.mozilla.gecko.gfx.PanZoomController;
|
||||
import org.mozilla.gecko.mozglue.GeckoLoader;
|
||||
import org.mozilla.gecko.mozglue.generatorannotations.WrapElementForJNI;
|
||||
import org.mozilla.gecko.mozglue.generatorannotations.OptionalGeneratedParameter;
|
||||
import org.mozilla.gecko.mozglue.GeneratableAndroidBridgeTarget;
|
||||
import org.mozilla.gecko.mozglue.OptionalGeneratedParameter;
|
||||
import org.mozilla.gecko.util.EventDispatcher;
|
||||
import org.mozilla.gecko.util.GeckoEventListener;
|
||||
import org.mozilla.gecko.util.HardwareUtils;
|
||||
@ -373,14 +373,14 @@ public class GeckoAppShell
|
||||
/*
|
||||
* The Gecko-side API: API methods that Gecko calls
|
||||
*/
|
||||
@WrapElementForJNI(generateStatic = true)
|
||||
@GeneratableAndroidBridgeTarget(generateStatic = true)
|
||||
public static void notifyIME(int type) {
|
||||
if (mEditableListener != null) {
|
||||
mEditableListener.notifyIME(type);
|
||||
}
|
||||
}
|
||||
|
||||
@WrapElementForJNI(generateStatic = true)
|
||||
@GeneratableAndroidBridgeTarget(generateStatic = true)
|
||||
public static void notifyIMEContext(int state, String typeHint,
|
||||
String modeHint, String actionHint) {
|
||||
if (mEditableListener != null) {
|
||||
@ -389,7 +389,7 @@ public class GeckoAppShell
|
||||
}
|
||||
}
|
||||
|
||||
@WrapElementForJNI(generateStatic = true)
|
||||
@GeneratableAndroidBridgeTarget(generateStatic = true)
|
||||
public static void notifyIMEChange(String text, int start, int end, int newEnd) {
|
||||
if (newEnd < 0) { // Selection change
|
||||
mEditableListener.onSelectionChange(start, end);
|
||||
@ -433,7 +433,7 @@ public class GeckoAppShell
|
||||
}
|
||||
|
||||
// Signal the Java thread that it's time to wake up
|
||||
@WrapElementForJNI
|
||||
@GeneratableAndroidBridgeTarget
|
||||
public static void acknowledgeEvent() {
|
||||
synchronized (sEventAckLock) {
|
||||
sWaitingForEventAck = false;
|
||||
@ -472,7 +472,7 @@ public class GeckoAppShell
|
||||
return lastKnownLocation;
|
||||
}
|
||||
|
||||
@WrapElementForJNI
|
||||
@GeneratableAndroidBridgeTarget
|
||||
public static void enableLocation(final boolean enable) {
|
||||
ThreadUtils.postToUiThread(new Runnable() {
|
||||
@Override
|
||||
@ -528,12 +528,12 @@ public class GeckoAppShell
|
||||
}
|
||||
}
|
||||
|
||||
@WrapElementForJNI
|
||||
@GeneratableAndroidBridgeTarget
|
||||
public static void enableLocationHighAccuracy(final boolean enable) {
|
||||
mLocationHighAccuracy = enable;
|
||||
}
|
||||
|
||||
@WrapElementForJNI
|
||||
@GeneratableAndroidBridgeTarget
|
||||
public static void enableSensor(int aSensortype) {
|
||||
GeckoInterface gi = getGeckoInterface();
|
||||
if (gi == null)
|
||||
@ -588,7 +588,7 @@ public class GeckoAppShell
|
||||
}
|
||||
}
|
||||
|
||||
@WrapElementForJNI
|
||||
@GeneratableAndroidBridgeTarget
|
||||
public static void disableSensor(int aSensortype) {
|
||||
GeckoInterface gi = getGeckoInterface();
|
||||
if (gi == null)
|
||||
@ -632,7 +632,7 @@ public class GeckoAppShell
|
||||
}
|
||||
}
|
||||
|
||||
@WrapElementForJNI
|
||||
@GeneratableAndroidBridgeTarget
|
||||
public static void moveTaskToBack() {
|
||||
if (getGeckoInterface() != null)
|
||||
getGeckoInterface().getActivity().moveTaskToBack(true);
|
||||
@ -643,7 +643,7 @@ public class GeckoAppShell
|
||||
// Native Fennec doesn't care because the Java code already knows the selection indexes.
|
||||
}
|
||||
|
||||
@WrapElementForJNI(stubName = "NotifyXreExit")
|
||||
@GeneratableAndroidBridgeTarget(stubName = "NotifyXreExit")
|
||||
static void onXreExit() {
|
||||
// The launch state can only be Launched or GeckoRunning at this point
|
||||
GeckoThread.setLaunchState(GeckoThread.LaunchState.GeckoExiting);
|
||||
@ -659,7 +659,7 @@ public class GeckoAppShell
|
||||
System.exit(0);
|
||||
}
|
||||
|
||||
@WrapElementForJNI
|
||||
@GeneratableAndroidBridgeTarget
|
||||
static void scheduleRestart() {
|
||||
gRestartScheduled = true;
|
||||
}
|
||||
@ -702,7 +702,7 @@ public class GeckoAppShell
|
||||
|
||||
// "Installs" an application by creating a shortcut
|
||||
// This is the entry point from AndroidBridge.h
|
||||
@WrapElementForJNI
|
||||
@GeneratableAndroidBridgeTarget
|
||||
static void createShortcut(String aTitle, String aURI, String aIconData, String aType) {
|
||||
if ("webapp".equals(aType)) {
|
||||
Log.w(LOGTAG, "createShortcut with no unique URI should not be used for aType = webapp!");
|
||||
@ -897,7 +897,7 @@ public class GeckoAppShell
|
||||
return bitmap;
|
||||
}
|
||||
|
||||
@WrapElementForJNI(stubName = "GetHandlersForMimeTypeWrapper")
|
||||
@GeneratableAndroidBridgeTarget(stubName = "GetHandlersForMimeTypeWrapper")
|
||||
static String[] getHandlersForMimeType(String aMimeType, String aAction) {
|
||||
Intent intent = getIntentForActionString(aAction);
|
||||
if (aMimeType != null && aMimeType.length() > 0)
|
||||
@ -905,7 +905,7 @@ public class GeckoAppShell
|
||||
return getHandlersForIntent(intent);
|
||||
}
|
||||
|
||||
@WrapElementForJNI(stubName = "GetHandlersForURLWrapper")
|
||||
@GeneratableAndroidBridgeTarget(stubName = "GetHandlersForURLWrapper")
|
||||
static String[] getHandlersForURL(String aURL, String aAction) {
|
||||
// aURL may contain the whole URL or just the protocol
|
||||
Uri uri = aURL.indexOf(':') >= 0 ? Uri.parse(aURL) : new Uri.Builder().scheme(aURL).build();
|
||||
@ -948,12 +948,12 @@ public class GeckoAppShell
|
||||
return new Intent(aAction);
|
||||
}
|
||||
|
||||
@WrapElementForJNI(stubName = "GetExtensionFromMimeTypeWrapper")
|
||||
@GeneratableAndroidBridgeTarget(stubName = "GetExtensionFromMimeTypeWrapper")
|
||||
static String getExtensionFromMimeType(String aMimeType) {
|
||||
return MimeTypeMap.getSingleton().getExtensionFromMimeType(aMimeType);
|
||||
}
|
||||
|
||||
@WrapElementForJNI(stubName = "GetMimeTypeFromExtensionsWrapper")
|
||||
@GeneratableAndroidBridgeTarget(stubName = "GetMimeTypeFromExtensionsWrapper")
|
||||
static String getMimeTypeFromExtensions(String aFileExt) {
|
||||
StringTokenizer st = new StringTokenizer(aFileExt, ".,; ");
|
||||
String type = null;
|
||||
@ -1086,7 +1086,7 @@ public class GeckoAppShell
|
||||
* @param title the title to use in <code>ACTION_SEND</code> intents.
|
||||
* @return true if the activity started successfully; false otherwise.
|
||||
*/
|
||||
@WrapElementForJNI
|
||||
@GeneratableAndroidBridgeTarget
|
||||
public static boolean openUriExternal(String targetURI,
|
||||
String mimeType,
|
||||
@OptionalGeneratedParameter String packageName,
|
||||
@ -1272,7 +1272,7 @@ public class GeckoAppShell
|
||||
}
|
||||
}
|
||||
|
||||
@WrapElementForJNI(stubName = "ShowAlertNotificationWrapper")
|
||||
@GeneratableAndroidBridgeTarget(stubName = "ShowAlertNotificationWrapper")
|
||||
public static void showAlertNotification(String aImageUrl, String aAlertTitle, String aAlertText,
|
||||
String aAlertCookie, String aAlertName) {
|
||||
// The intent to launch when the user clicks the expanded notification
|
||||
@ -1299,13 +1299,13 @@ public class GeckoAppShell
|
||||
sNotificationClient.add(notificationID, aImageUrl, aAlertTitle, aAlertText, contentIntent);
|
||||
}
|
||||
|
||||
@WrapElementForJNI
|
||||
@GeneratableAndroidBridgeTarget
|
||||
public static void alertsProgressListener_OnProgress(String aAlertName, long aProgress, long aProgressMax, String aAlertText) {
|
||||
int notificationID = aAlertName.hashCode();
|
||||
sNotificationClient.update(notificationID, aProgress, aProgressMax, aAlertText);
|
||||
}
|
||||
|
||||
@WrapElementForJNI
|
||||
@GeneratableAndroidBridgeTarget
|
||||
public static void closeNotification(String aAlertName) {
|
||||
String alertCookie = mAlertCookies.get(aAlertName);
|
||||
if (alertCookie != null) {
|
||||
@ -1333,7 +1333,7 @@ public class GeckoAppShell
|
||||
closeNotification(aAlertName);
|
||||
}
|
||||
|
||||
@WrapElementForJNI(stubName = "GetDpiWrapper")
|
||||
@GeneratableAndroidBridgeTarget(stubName = "GetDpiWrapper")
|
||||
public static int getDpi() {
|
||||
if (sDensityDpi == 0) {
|
||||
sDensityDpi = getContext().getResources().getDisplayMetrics().densityDpi;
|
||||
@ -1342,7 +1342,7 @@ public class GeckoAppShell
|
||||
return sDensityDpi;
|
||||
}
|
||||
|
||||
@WrapElementForJNI
|
||||
@GeneratableAndroidBridgeTarget()
|
||||
public static float getDensity() {
|
||||
return getContext().getResources().getDisplayMetrics().density;
|
||||
}
|
||||
@ -1377,7 +1377,7 @@ public class GeckoAppShell
|
||||
* Returns the colour depth of the default screen. This will either be
|
||||
* 24 or 16.
|
||||
*/
|
||||
@WrapElementForJNI(stubName = "GetScreenDepthWrapper")
|
||||
@GeneratableAndroidBridgeTarget(stubName = "GetScreenDepthWrapper")
|
||||
public static synchronized int getScreenDepth() {
|
||||
if (sScreenDepth == 0) {
|
||||
sScreenDepth = 16;
|
||||
@ -1400,27 +1400,27 @@ public class GeckoAppShell
|
||||
sScreenDepth = aScreenDepth;
|
||||
}
|
||||
|
||||
@WrapElementForJNI
|
||||
@GeneratableAndroidBridgeTarget
|
||||
public static void setFullScreen(boolean fullscreen) {
|
||||
if (getGeckoInterface() != null)
|
||||
getGeckoInterface().setFullScreen(fullscreen);
|
||||
}
|
||||
|
||||
@WrapElementForJNI(stubName = "ShowFilePickerForExtensionsWrapper")
|
||||
@GeneratableAndroidBridgeTarget(stubName = "ShowFilePickerForExtensionsWrapper")
|
||||
public static String showFilePickerForExtensions(String aExtensions) {
|
||||
if (getGeckoInterface() != null)
|
||||
return sActivityHelper.showFilePicker(getGeckoInterface().getActivity(), getMimeTypeFromExtensions(aExtensions));
|
||||
return "";
|
||||
}
|
||||
|
||||
@WrapElementForJNI(stubName = "ShowFilePickerForMimeTypeWrapper")
|
||||
@GeneratableAndroidBridgeTarget(stubName = "ShowFilePickerForMimeTypeWrapper")
|
||||
public static String showFilePickerForMimeType(String aMimeType) {
|
||||
if (getGeckoInterface() != null)
|
||||
return sActivityHelper.showFilePicker(getGeckoInterface().getActivity(), aMimeType);
|
||||
return "";
|
||||
}
|
||||
|
||||
@WrapElementForJNI
|
||||
@GeneratableAndroidBridgeTarget
|
||||
public static void performHapticFeedback(boolean aIsLongPress) {
|
||||
// Don't perform haptic feedback if a vibration is currently playing,
|
||||
// because the haptic feedback will nuke the vibration.
|
||||
@ -1437,14 +1437,14 @@ public class GeckoAppShell
|
||||
return (Vibrator) layerView.getContext().getSystemService(Context.VIBRATOR_SERVICE);
|
||||
}
|
||||
|
||||
@WrapElementForJNI(stubName = "Vibrate1")
|
||||
@GeneratableAndroidBridgeTarget(stubName = "Vibrate1")
|
||||
public static void vibrate(long milliseconds) {
|
||||
sVibrationEndTime = System.nanoTime() + milliseconds * 1000000;
|
||||
sVibrationMaybePlaying = true;
|
||||
vibrator().vibrate(milliseconds);
|
||||
}
|
||||
|
||||
@WrapElementForJNI(stubName = "VibrateA")
|
||||
@GeneratableAndroidBridgeTarget(stubName = "VibrateA")
|
||||
public static void vibrate(long[] pattern, int repeat) {
|
||||
// If pattern.length is even, the last element in the pattern is a
|
||||
// meaningless delay, so don't include it in vibrationDuration.
|
||||
@ -1459,21 +1459,21 @@ public class GeckoAppShell
|
||||
vibrator().vibrate(pattern, repeat);
|
||||
}
|
||||
|
||||
@WrapElementForJNI
|
||||
@GeneratableAndroidBridgeTarget
|
||||
public static void cancelVibrate() {
|
||||
sVibrationMaybePlaying = false;
|
||||
sVibrationEndTime = 0;
|
||||
vibrator().cancel();
|
||||
}
|
||||
|
||||
@WrapElementForJNI
|
||||
@GeneratableAndroidBridgeTarget
|
||||
public static void showInputMethodPicker() {
|
||||
InputMethodManager imm = (InputMethodManager)
|
||||
getContext().getSystemService(Context.INPUT_METHOD_SERVICE);
|
||||
imm.showInputMethodPicker();
|
||||
}
|
||||
|
||||
@WrapElementForJNI
|
||||
@GeneratableAndroidBridgeTarget
|
||||
public static void setKeepScreenOn(final boolean on) {
|
||||
ThreadUtils.postToUiThread(new Runnable() {
|
||||
@Override
|
||||
@ -1483,7 +1483,7 @@ public class GeckoAppShell
|
||||
});
|
||||
}
|
||||
|
||||
@WrapElementForJNI
|
||||
@GeneratableAndroidBridgeTarget
|
||||
public static void notifyDefaultPrevented(final boolean defaultPrevented) {
|
||||
ThreadUtils.postToUiThread(new Runnable() {
|
||||
@Override
|
||||
@ -1497,7 +1497,7 @@ public class GeckoAppShell
|
||||
});
|
||||
}
|
||||
|
||||
@WrapElementForJNI
|
||||
@GeneratableAndroidBridgeTarget
|
||||
public static boolean isNetworkLinkUp() {
|
||||
ConnectivityManager cm = (ConnectivityManager)
|
||||
getContext().getSystemService(Context.CONNECTIVITY_SERVICE);
|
||||
@ -1507,7 +1507,7 @@ public class GeckoAppShell
|
||||
return true;
|
||||
}
|
||||
|
||||
@WrapElementForJNI
|
||||
@GeneratableAndroidBridgeTarget
|
||||
public static boolean isNetworkLinkKnown() {
|
||||
ConnectivityManager cm = (ConnectivityManager)
|
||||
getContext().getSystemService(Context.CONNECTIVITY_SERVICE);
|
||||
@ -1516,7 +1516,7 @@ public class GeckoAppShell
|
||||
return true;
|
||||
}
|
||||
|
||||
@WrapElementForJNI
|
||||
@GeneratableAndroidBridgeTarget
|
||||
public static void setSelectedLocale(String localeCode) {
|
||||
/* Bug 713464: This method is still called from Gecko side.
|
||||
Earlier we had an option to run Firefox in a language other than system's language.
|
||||
@ -1549,7 +1549,7 @@ public class GeckoAppShell
|
||||
}
|
||||
|
||||
|
||||
@WrapElementForJNI(stubName = "GetSystemColoursWrapper")
|
||||
@GeneratableAndroidBridgeTarget(stubName = "GetSystemColoursWrapper")
|
||||
public static int[] getSystemColors() {
|
||||
// attrsAppearance[] must correspond to AndroidSystemColors structure in android/AndroidBridge.h
|
||||
final int[] attrsAppearance = {
|
||||
@ -1586,7 +1586,7 @@ public class GeckoAppShell
|
||||
return result;
|
||||
}
|
||||
|
||||
@WrapElementForJNI
|
||||
@GeneratableAndroidBridgeTarget
|
||||
public static void killAnyZombies() {
|
||||
GeckoProcessesVisitor visitor = new GeckoProcessesVisitor() {
|
||||
@Override
|
||||
@ -1742,7 +1742,7 @@ public class GeckoAppShell
|
||||
} catch (Exception e) { }
|
||||
}
|
||||
|
||||
@WrapElementForJNI
|
||||
@GeneratableAndroidBridgeTarget
|
||||
public static void scanMedia(String aFile, String aMimeType) {
|
||||
// If the platform didn't give us a mimetype, try to guess one from the filename
|
||||
if (TextUtils.isEmpty(aMimeType)) {
|
||||
@ -1756,7 +1756,7 @@ public class GeckoAppShell
|
||||
GeckoMediaScannerClient.startScan(context, aFile, aMimeType);
|
||||
}
|
||||
|
||||
@WrapElementForJNI(stubName = "GetIconForExtensionWrapper")
|
||||
@GeneratableAndroidBridgeTarget(stubName = "GetIconForExtensionWrapper")
|
||||
public static byte[] getIconForExtension(String aExt, int iconSize) {
|
||||
try {
|
||||
if (iconSize <= 0)
|
||||
@ -1814,7 +1814,7 @@ public class GeckoAppShell
|
||||
return activityInfo.loadIcon(pm);
|
||||
}
|
||||
|
||||
@WrapElementForJNI
|
||||
@GeneratableAndroidBridgeTarget
|
||||
public static boolean getShowPasswordSetting() {
|
||||
try {
|
||||
int showPassword =
|
||||
@ -1827,7 +1827,7 @@ public class GeckoAppShell
|
||||
}
|
||||
}
|
||||
|
||||
@WrapElementForJNI(stubName = "AddPluginViewWrapper")
|
||||
@GeneratableAndroidBridgeTarget(stubName = "AddPluginViewWrapper")
|
||||
public static void addPluginView(View view,
|
||||
float x, float y,
|
||||
float w, float h,
|
||||
@ -1836,7 +1836,7 @@ public class GeckoAppShell
|
||||
getGeckoInterface().addPluginView(view, new RectF(x, y, x + w, y + h), isFullScreen);
|
||||
}
|
||||
|
||||
@WrapElementForJNI
|
||||
@GeneratableAndroidBridgeTarget
|
||||
public static void removePluginView(View view, boolean isFullScreen) {
|
||||
if (getGeckoInterface() != null)
|
||||
getGeckoInterface().removePluginView(view, isFullScreen);
|
||||
@ -2060,7 +2060,7 @@ public class GeckoAppShell
|
||||
|
||||
private static ContextGetter sContextGetter;
|
||||
|
||||
@WrapElementForJNI(allowMultithread = true)
|
||||
@GeneratableAndroidBridgeTarget(allowMultithread = true)
|
||||
public static Context getContext() {
|
||||
return sContextGetter.getContext();
|
||||
}
|
||||
@ -2118,7 +2118,7 @@ public class GeckoAppShell
|
||||
static byte[] sCameraBuffer = null;
|
||||
|
||||
|
||||
@WrapElementForJNI(stubName = "InitCameraWrapper")
|
||||
@GeneratableAndroidBridgeTarget(stubName = "InitCameraWrapper")
|
||||
static int[] initCamera(String aContentType, int aCamera, int aWidth, int aHeight) {
|
||||
ThreadUtils.postToUiThread(new Runnable() {
|
||||
@Override
|
||||
@ -2219,7 +2219,7 @@ public class GeckoAppShell
|
||||
return result;
|
||||
}
|
||||
|
||||
@WrapElementForJNI
|
||||
@GeneratableAndroidBridgeTarget
|
||||
static synchronized void closeCamera() {
|
||||
ThreadUtils.postToUiThread(new Runnable() {
|
||||
@Override
|
||||
@ -2271,32 +2271,32 @@ public class GeckoAppShell
|
||||
/*
|
||||
* Battery API related methods.
|
||||
*/
|
||||
@WrapElementForJNI
|
||||
@GeneratableAndroidBridgeTarget
|
||||
public static void enableBatteryNotifications() {
|
||||
GeckoBatteryManager.enableNotifications();
|
||||
}
|
||||
|
||||
@WrapElementForJNI(stubName = "HandleGeckoMessageWrapper")
|
||||
@GeneratableAndroidBridgeTarget(stubName = "HandleGeckoMessageWrapper")
|
||||
public static String handleGeckoMessage(String message) {
|
||||
return sEventDispatcher.dispatchEvent(message);
|
||||
}
|
||||
|
||||
@WrapElementForJNI
|
||||
@GeneratableAndroidBridgeTarget
|
||||
public static void disableBatteryNotifications() {
|
||||
GeckoBatteryManager.disableNotifications();
|
||||
}
|
||||
|
||||
@WrapElementForJNI(stubName = "GetCurrentBatteryInformationWrapper")
|
||||
@GeneratableAndroidBridgeTarget(stubName = "GetCurrentBatteryInformationWrapper")
|
||||
public static double[] getCurrentBatteryInformation() {
|
||||
return GeckoBatteryManager.getCurrentInformation();
|
||||
}
|
||||
|
||||
@WrapElementForJNI(stubName = "CheckURIVisited")
|
||||
@GeneratableAndroidBridgeTarget(stubName = "CheckURIVisited")
|
||||
static void checkUriVisited(String uri) {
|
||||
GlobalHistory.getInstance().checkUriVisited(uri);
|
||||
}
|
||||
|
||||
@WrapElementForJNI(stubName = "MarkURIVisited")
|
||||
@GeneratableAndroidBridgeTarget(stubName = "MarkURIVisited")
|
||||
static void markUriVisited(final String uri) {
|
||||
ThreadUtils.postToBackgroundThread(new Runnable() {
|
||||
@Override
|
||||
@ -2306,7 +2306,7 @@ public class GeckoAppShell
|
||||
});
|
||||
}
|
||||
|
||||
@WrapElementForJNI(stubName = "SetURITitle")
|
||||
@GeneratableAndroidBridgeTarget(stubName = "SetURITitle")
|
||||
static void setUriTitle(final String uri, final String title) {
|
||||
ThreadUtils.postToBackgroundThread(new Runnable() {
|
||||
@Override
|
||||
@ -2316,7 +2316,7 @@ public class GeckoAppShell
|
||||
});
|
||||
}
|
||||
|
||||
@WrapElementForJNI
|
||||
@GeneratableAndroidBridgeTarget
|
||||
static void hideProgressDialog() {
|
||||
// unused stub
|
||||
}
|
||||
@ -2324,7 +2324,7 @@ public class GeckoAppShell
|
||||
/*
|
||||
* WebSMS related methods.
|
||||
*/
|
||||
@WrapElementForJNI(stubName = "SendMessageWrapper")
|
||||
@GeneratableAndroidBridgeTarget(stubName = "SendMessageWrapper")
|
||||
public static void sendMessage(String aNumber, String aMessage, int aRequestId) {
|
||||
if (SmsManager.getInstance() == null) {
|
||||
return;
|
||||
@ -2333,7 +2333,7 @@ public class GeckoAppShell
|
||||
SmsManager.getInstance().send(aNumber, aMessage, aRequestId);
|
||||
}
|
||||
|
||||
@WrapElementForJNI(stubName = "GetMessageWrapper")
|
||||
@GeneratableAndroidBridgeTarget(stubName = "GetMessageWrapper")
|
||||
public static void getMessage(int aMessageId, int aRequestId) {
|
||||
if (SmsManager.getInstance() == null) {
|
||||
return;
|
||||
@ -2342,7 +2342,7 @@ public class GeckoAppShell
|
||||
SmsManager.getInstance().getMessage(aMessageId, aRequestId);
|
||||
}
|
||||
|
||||
@WrapElementForJNI(stubName = "DeleteMessageWrapper")
|
||||
@GeneratableAndroidBridgeTarget(stubName = "DeleteMessageWrapper")
|
||||
public static void deleteMessage(int aMessageId, int aRequestId) {
|
||||
if (SmsManager.getInstance() == null) {
|
||||
return;
|
||||
@ -2351,7 +2351,7 @@ public class GeckoAppShell
|
||||
SmsManager.getInstance().deleteMessage(aMessageId, aRequestId);
|
||||
}
|
||||
|
||||
@WrapElementForJNI(stubName = "CreateMessageListWrapper")
|
||||
@GeneratableAndroidBridgeTarget(stubName = "CreateMessageListWrapper")
|
||||
public static void createMessageList(long aStartDate, long aEndDate, String[] aNumbers, int aNumbersCount, int aDeliveryState, boolean aReverse, int aRequestId) {
|
||||
if (SmsManager.getInstance() == null) {
|
||||
return;
|
||||
@ -2360,7 +2360,7 @@ public class GeckoAppShell
|
||||
SmsManager.getInstance().createMessageList(aStartDate, aEndDate, aNumbers, aNumbersCount, aDeliveryState, aReverse, aRequestId);
|
||||
}
|
||||
|
||||
@WrapElementForJNI(stubName = "GetNextMessageInListWrapper")
|
||||
@GeneratableAndroidBridgeTarget(stubName = "GetNextMessageInListWrapper")
|
||||
public static void getNextMessageInList(int aListId, int aRequestId) {
|
||||
if (SmsManager.getInstance() == null) {
|
||||
return;
|
||||
@ -2369,7 +2369,7 @@ public class GeckoAppShell
|
||||
SmsManager.getInstance().getNextMessageInList(aListId, aRequestId);
|
||||
}
|
||||
|
||||
@WrapElementForJNI
|
||||
@GeneratableAndroidBridgeTarget
|
||||
public static void clearMessageList(int aListId) {
|
||||
if (SmsManager.getInstance() == null) {
|
||||
return;
|
||||
@ -2379,7 +2379,7 @@ public class GeckoAppShell
|
||||
}
|
||||
|
||||
/* Called by JNI from AndroidBridge, and by reflection from tests/BaseTest.java.in */
|
||||
@WrapElementForJNI
|
||||
@GeneratableAndroidBridgeTarget
|
||||
public static boolean isTablet() {
|
||||
return HardwareUtils.isTablet();
|
||||
}
|
||||
@ -2392,17 +2392,17 @@ public class GeckoAppShell
|
||||
}
|
||||
}
|
||||
|
||||
@WrapElementForJNI(stubName = "GetCurrentNetworkInformationWrapper")
|
||||
@GeneratableAndroidBridgeTarget(stubName = "GetCurrentNetworkInformationWrapper")
|
||||
public static double[] getCurrentNetworkInformation() {
|
||||
return GeckoNetworkManager.getInstance().getCurrentInformation();
|
||||
}
|
||||
|
||||
@WrapElementForJNI
|
||||
@GeneratableAndroidBridgeTarget
|
||||
public static void enableNetworkNotifications() {
|
||||
GeckoNetworkManager.getInstance().enableNotifications();
|
||||
}
|
||||
|
||||
@WrapElementForJNI
|
||||
@GeneratableAndroidBridgeTarget
|
||||
public static void disableNetworkNotifications() {
|
||||
GeckoNetworkManager.getInstance().disableNotifications();
|
||||
}
|
||||
@ -2516,32 +2516,32 @@ public class GeckoAppShell
|
||||
return decodeBase64(s.getBytes(), flags);
|
||||
}
|
||||
|
||||
@WrapElementForJNI(stubName = "GetScreenOrientationWrapper")
|
||||
@GeneratableAndroidBridgeTarget(stubName = "GetScreenOrientationWrapper")
|
||||
public static short getScreenOrientation() {
|
||||
return GeckoScreenOrientationListener.getInstance().getScreenOrientation();
|
||||
}
|
||||
|
||||
@WrapElementForJNI
|
||||
@GeneratableAndroidBridgeTarget
|
||||
public static void enableScreenOrientationNotifications() {
|
||||
GeckoScreenOrientationListener.getInstance().enableNotifications();
|
||||
}
|
||||
|
||||
@WrapElementForJNI
|
||||
@GeneratableAndroidBridgeTarget
|
||||
public static void disableScreenOrientationNotifications() {
|
||||
GeckoScreenOrientationListener.getInstance().disableNotifications();
|
||||
}
|
||||
|
||||
@WrapElementForJNI
|
||||
@GeneratableAndroidBridgeTarget
|
||||
public static void lockScreenOrientation(int aOrientation) {
|
||||
GeckoScreenOrientationListener.getInstance().lockScreenOrientation(aOrientation);
|
||||
}
|
||||
|
||||
@WrapElementForJNI
|
||||
@GeneratableAndroidBridgeTarget
|
||||
public static void unlockScreenOrientation() {
|
||||
GeckoScreenOrientationListener.getInstance().unlockScreenOrientation();
|
||||
}
|
||||
|
||||
@WrapElementForJNI
|
||||
@GeneratableAndroidBridgeTarget
|
||||
public static boolean pumpMessageLoop() {
|
||||
Handler geckoHandler = ThreadUtils.sGeckoHandler;
|
||||
Message msg = getNextMessageFromQueue(ThreadUtils.sGeckoQueue);
|
||||
@ -2563,7 +2563,7 @@ public class GeckoAppShell
|
||||
|
||||
static native void notifyFilePickerResult(String filePath, long id);
|
||||
|
||||
@WrapElementForJNI(stubName = "ShowFilePickerAsyncWrapper")
|
||||
@GeneratableAndroidBridgeTarget(stubName = "ShowFilePickerAsyncWrapper")
|
||||
public static void showFilePickerAsync(String aMimeType, final long id) {
|
||||
sActivityHelper.showFilePickerAsync(getGeckoInterface().getActivity(), aMimeType, new ActivityHandlerHelper.FileResultHandler() {
|
||||
public void gotFile(String filename) {
|
||||
@ -2572,18 +2572,18 @@ public class GeckoAppShell
|
||||
});
|
||||
}
|
||||
|
||||
@WrapElementForJNI
|
||||
@GeneratableAndroidBridgeTarget
|
||||
public static void notifyWakeLockChanged(String topic, String state) {
|
||||
if (getGeckoInterface() != null)
|
||||
getGeckoInterface().notifyWakeLockChanged(topic, state);
|
||||
}
|
||||
|
||||
@WrapElementForJNI(stubName = "GetGfxInfoDataWrapper")
|
||||
@GeneratableAndroidBridgeTarget(stubName = "GetGfxInfoDataWrapper")
|
||||
public static String getGfxInfoData() {
|
||||
return GfxInfoThread.getData();
|
||||
}
|
||||
|
||||
@WrapElementForJNI
|
||||
@GeneratableAndroidBridgeTarget
|
||||
public static void registerSurfaceTextureFrameListener(Object surfaceTexture, final int id) {
|
||||
((SurfaceTexture)surfaceTexture).setOnFrameAvailableListener(new SurfaceTexture.OnFrameAvailableListener() {
|
||||
@Override
|
||||
@ -2593,12 +2593,12 @@ public class GeckoAppShell
|
||||
});
|
||||
}
|
||||
|
||||
@WrapElementForJNI(allowMultithread = true)
|
||||
@GeneratableAndroidBridgeTarget(allowMultithread = true)
|
||||
public static void unregisterSurfaceTextureFrameListener(Object surfaceTexture) {
|
||||
((SurfaceTexture)surfaceTexture).setOnFrameAvailableListener(null);
|
||||
}
|
||||
|
||||
@WrapElementForJNI
|
||||
@GeneratableAndroidBridgeTarget
|
||||
public static boolean unlockProfile() {
|
||||
// Try to kill any zombie Fennec's that might be running
|
||||
GeckoAppShell.killAnyZombies();
|
||||
@ -2612,7 +2612,7 @@ public class GeckoAppShell
|
||||
return false;
|
||||
}
|
||||
|
||||
@WrapElementForJNI(stubName = "GetProxyForURIWrapper")
|
||||
@GeneratableAndroidBridgeTarget(stubName = "GetProxyForURIWrapper")
|
||||
public static String getProxyForURI(String spec, String scheme, String host, int port) {
|
||||
URI uri = null;
|
||||
try {
|
||||
|
@ -7,8 +7,6 @@ package org.mozilla.gecko;
|
||||
|
||||
import org.mozilla.gecko.gfx.DisplayPortMetrics;
|
||||
import org.mozilla.gecko.gfx.ImmutableViewportMetrics;
|
||||
import org.mozilla.gecko.mozglue.generatorannotations.GeneratorOptions;
|
||||
import org.mozilla.gecko.mozglue.generatorannotations.WrapEntireClassForJNI;
|
||||
|
||||
import android.content.res.Resources;
|
||||
import android.graphics.Point;
|
||||
@ -85,8 +83,6 @@ public class GeckoEvent {
|
||||
* The DomKeyLocation enum encapsulates the DOM KeyboardEvent's constants.
|
||||
* @see https://developer.mozilla.org/en-US/docs/DOM/KeyboardEvent#Key_location_constants
|
||||
*/
|
||||
@GeneratorOptions(generatedClassName = "JavaDomKeyLocation")
|
||||
@WrapEntireClassForJNI
|
||||
public enum DomKeyLocation {
|
||||
DOM_KEY_LOCATION_STANDARD(0),
|
||||
DOM_KEY_LOCATION_LEFT(1),
|
||||
|
@ -8,7 +8,7 @@ package org.mozilla.gecko;
|
||||
import android.os.SystemClock;
|
||||
import android.util.Log;
|
||||
|
||||
import org.mozilla.gecko.mozglue.generatorannotations.WrapElementForJNI;
|
||||
import org.mozilla.gecko.mozglue.GeneratableAndroidBridgeTarget;
|
||||
|
||||
import java.lang.Thread;
|
||||
import java.util.HashMap;
|
||||
@ -126,7 +126,7 @@ public class GeckoJavaSampler {
|
||||
}
|
||||
|
||||
|
||||
@WrapElementForJNI(allowMultithread = true, stubName = "GetThreadNameJavaProfilingWrapper")
|
||||
@GeneratableAndroidBridgeTarget(allowMultithread = true, stubName = "GetThreadNameJavaProfilingWrapper")
|
||||
public synchronized static String getThreadName(int aThreadId) {
|
||||
if (aThreadId == 0 && sMainThread != null) {
|
||||
return sMainThread.getName();
|
||||
@ -138,7 +138,7 @@ public class GeckoJavaSampler {
|
||||
return sSamplingRunnable.getSample(aThreadId, aSampleId);
|
||||
}
|
||||
|
||||
@WrapElementForJNI(allowMultithread = true, stubName = "GetSampleTimeJavaProfiling")
|
||||
@GeneratableAndroidBridgeTarget(allowMultithread = true, stubName = "GetSampleTimeJavaProfiling")
|
||||
public synchronized static double getSampleTime(int aThreadId, int aSampleId) {
|
||||
Sample sample = getSample(aThreadId, aSampleId);
|
||||
if (sample != null) {
|
||||
@ -152,7 +152,7 @@ public class GeckoJavaSampler {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@WrapElementForJNI(allowMultithread = true, stubName = "GetFrameNameJavaProfilingWrapper")
|
||||
@GeneratableAndroidBridgeTarget(allowMultithread = true, stubName = "GetFrameNameJavaProfilingWrapper")
|
||||
public synchronized static String getFrameName(int aThreadId, int aSampleId, int aFrameId) {
|
||||
Sample sample = getSample(aThreadId, aSampleId);
|
||||
if (sample != null && aFrameId < sample.mFrames.length) {
|
||||
@ -165,7 +165,7 @@ public class GeckoJavaSampler {
|
||||
return null;
|
||||
}
|
||||
|
||||
@WrapElementForJNI(allowMultithread = true, stubName = "StartJavaProfiling")
|
||||
@GeneratableAndroidBridgeTarget(allowMultithread = true, stubName = "StartJavaProfiling")
|
||||
public static void start(int aInterval, int aSamples) {
|
||||
synchronized (GeckoJavaSampler.class) {
|
||||
if (sSamplingRunnable != null) {
|
||||
@ -177,21 +177,21 @@ public class GeckoJavaSampler {
|
||||
}
|
||||
}
|
||||
|
||||
@WrapElementForJNI(allowMultithread = true, stubName = "PauseJavaProfiling")
|
||||
@GeneratableAndroidBridgeTarget(allowMultithread = true, stubName = "PauseJavaProfiling")
|
||||
public static void pause() {
|
||||
synchronized (GeckoJavaSampler.class) {
|
||||
sSamplingRunnable.mPauseSampler = true;
|
||||
}
|
||||
}
|
||||
|
||||
@WrapElementForJNI(allowMultithread = true, stubName = "UnpauseJavaProfiling")
|
||||
@GeneratableAndroidBridgeTarget(allowMultithread = true, stubName = "UnpauseJavaProfiling")
|
||||
public static void unpause() {
|
||||
synchronized (GeckoJavaSampler.class) {
|
||||
sSamplingRunnable.mPauseSampler = false;
|
||||
}
|
||||
}
|
||||
|
||||
@WrapElementForJNI(allowMultithread = true, stubName = "StopJavaProfiling")
|
||||
@GeneratableAndroidBridgeTarget(allowMultithread = true, stubName = "StopJavaProfiling")
|
||||
public static void stop() {
|
||||
synchronized (GeckoJavaSampler.class) {
|
||||
if (sSamplingThread == null) {
|
||||
|
@ -9,12 +9,10 @@ include $(topsrcdir)/mobile/android/base/android-services-files.mk
|
||||
MOZGLUE_JAVA_FILES := \
|
||||
mozglue/ByteBufferInputStream.java \
|
||||
mozglue/DirectBufferAllocator.java \
|
||||
mozglue/generatorannotations/GeneratorOptions.java \
|
||||
mozglue/generatorannotations/OptionalGeneratedParameter.java \
|
||||
mozglue/generatorannotations/WrapEntireClassForJNI.java \
|
||||
mozglue/generatorannotations/WrapElementForJNI.java \
|
||||
mozglue/GeneratableAndroidBridgeTarget.java \
|
||||
mozglue/NativeReference.java \
|
||||
mozglue/NativeZip.java \
|
||||
mozglue/OptionalGeneratedParameter.java \
|
||||
$(NULL)
|
||||
|
||||
MOZGLUE_PP_JAVA_FILES := \
|
||||
@ -1310,13 +1308,11 @@ jni-stubs.inc: jars/gecko-browser.jar jars/gecko-mozglue.jar jars/gecko-util.jar
|
||||
ANNOTATION_PROCESSOR_JAVA_FILES = \
|
||||
build/annotationProcessors/AnnotationProcessor.java \
|
||||
build/annotationProcessors/CodeGenerator.java \
|
||||
build/annotationProcessors/AnnotationInfo.java \
|
||||
build/annotationProcessors/classloader/AnnotatableEntity.java \
|
||||
build/annotationProcessors/classloader/ClassWithOptions.java \
|
||||
build/annotationProcessors/MethodWithAnnotationInfo.java \
|
||||
build/annotationProcessors/classloader/IterableJarLoadingURLClassLoader.java \
|
||||
build/annotationProcessors/classloader/JarClassIterator.java \
|
||||
build/annotationProcessors/utils/AlphabeticAnnotatableEntityComparator.java \
|
||||
build/annotationProcessors/utils/GeneratableElementIterator.java \
|
||||
build/annotationProcessors/utils/AlphabeticMethodComparator.java \
|
||||
build/annotationProcessors/utils/GeneratableEntryPointIterator.java \
|
||||
build/annotationProcessors/utils/Utils.java \
|
||||
$(NULL)
|
||||
|
||||
|
@ -4,11 +4,8 @@
|
||||
|
||||
package org.mozilla.gecko;
|
||||
|
||||
import org.mozilla.gecko.mozglue.generatorannotations.WrapEntireClassForJNI;
|
||||
|
||||
import java.nio.ByteBuffer;
|
||||
|
||||
@WrapEntireClassForJNI
|
||||
public class SurfaceBits {
|
||||
public int width;
|
||||
public int height;
|
||||
|
@ -9,7 +9,7 @@ import org.mozilla.gecko.db.BrowserDB;
|
||||
import org.mozilla.gecko.gfx.BitmapUtils;
|
||||
import org.mozilla.gecko.gfx.IntSize;
|
||||
import org.mozilla.gecko.mozglue.DirectBufferAllocator;
|
||||
import org.mozilla.gecko.mozglue.generatorannotations.WrapElementForJNI;
|
||||
import org.mozilla.gecko.mozglue.GeneratableAndroidBridgeTarget;
|
||||
|
||||
import android.graphics.Bitmap;
|
||||
import android.util.Log;
|
||||
@ -144,7 +144,7 @@ public final class ThumbnailHelper {
|
||||
}
|
||||
|
||||
/* This method is invoked by JNI once the thumbnail data is ready. */
|
||||
@WrapElementForJNI(stubName = "SendThumbnail")
|
||||
@GeneratableAndroidBridgeTarget(stubName = "SendThumbnail")
|
||||
public static void notifyThumbnail(ByteBuffer data, int tabId, boolean success) {
|
||||
Tab tab = Tabs.getInstance().getTab(tabId);
|
||||
ThumbnailHelper helper = ThumbnailHelper.getInstance();
|
||||
|
@ -5,7 +5,6 @@
|
||||
|
||||
package org.mozilla.gecko.gfx;
|
||||
|
||||
import org.mozilla.gecko.mozglue.generatorannotations.WrapElementForJNI;
|
||||
import org.mozilla.gecko.util.FloatUtils;
|
||||
|
||||
import android.graphics.RectF;
|
||||
@ -19,16 +18,13 @@ import android.graphics.RectF;
|
||||
* subsection of that with compositor scaling.
|
||||
*/
|
||||
public final class DisplayPortMetrics {
|
||||
@WrapElementForJNI
|
||||
public final float resolution;
|
||||
@WrapElementForJNI
|
||||
private final RectF mPosition;
|
||||
|
||||
public DisplayPortMetrics() {
|
||||
this(0, 0, 0, 0, 1);
|
||||
}
|
||||
|
||||
@WrapElementForJNI
|
||||
public DisplayPortMetrics(float left, float top, float right, float bottom, float resolution) {
|
||||
this.resolution = resolution;
|
||||
mPosition = new RectF(left, top, right, bottom);
|
||||
|
@ -8,7 +8,7 @@ package org.mozilla.gecko.gfx;
|
||||
import org.mozilla.gecko.GeckoAppShell;
|
||||
import org.mozilla.gecko.GeckoEvent;
|
||||
import org.mozilla.gecko.GeckoThread;
|
||||
import org.mozilla.gecko.mozglue.generatorannotations.WrapElementForJNI;
|
||||
import org.mozilla.gecko.mozglue.GeneratableAndroidBridgeTarget;
|
||||
import org.mozilla.gecko.util.ThreadUtils;
|
||||
|
||||
import android.util.Log;
|
||||
@ -263,7 +263,7 @@ public class GLController {
|
||||
throw new GLControllerException("No suitable EGL configuration found");
|
||||
}
|
||||
|
||||
@WrapElementForJNI(allowMultithread = true, stubName = "ProvideEGLSurfaceWrapper")
|
||||
@GeneratableAndroidBridgeTarget(allowMultithread = true, stubName = "ProvideEGLSurfaceWrapper")
|
||||
private EGLSurface provideEGLSurface() {
|
||||
return mEGLSurface;
|
||||
}
|
||||
|
@ -11,7 +11,6 @@ import org.mozilla.gecko.GeckoEvent;
|
||||
import org.mozilla.gecko.Tab;
|
||||
import org.mozilla.gecko.Tabs;
|
||||
import org.mozilla.gecko.ZoomConstraints;
|
||||
import org.mozilla.gecko.mozglue.generatorannotations.WrapElementForJNI;
|
||||
import org.mozilla.gecko.util.EventDispatcher;
|
||||
import org.mozilla.gecko.util.FloatUtils;
|
||||
import org.mozilla.gecko.util.ThreadUtils;
|
||||
@ -410,7 +409,7 @@ public class GeckoLayerClient implements LayerView.Listener, PanZoomTarget
|
||||
return mDisplayPort;
|
||||
}
|
||||
|
||||
@WrapElementForJNI
|
||||
/* This is invoked by JNI on the gecko thread */
|
||||
DisplayPortMetrics getDisplayPort(boolean pageSizeUpdate, boolean isBrowserContentDisplayed, int tabId, ImmutableViewportMetrics metrics) {
|
||||
Tabs tabs = Tabs.getInstance();
|
||||
if (tabs.isSelectedTab(tabs.getTab(tabId)) && isBrowserContentDisplayed) {
|
||||
@ -427,12 +426,12 @@ public class GeckoLayerClient implements LayerView.Listener, PanZoomTarget
|
||||
}
|
||||
}
|
||||
|
||||
@WrapElementForJNI
|
||||
/* This is invoked by JNI on the gecko thread */
|
||||
void contentDocumentChanged() {
|
||||
mContentDocumentIsDisplayed = false;
|
||||
}
|
||||
|
||||
@WrapElementForJNI
|
||||
/* This is invoked by JNI on the gecko thread */
|
||||
boolean isContentDocumentDisplayed() {
|
||||
return mContentDocumentIsDisplayed;
|
||||
}
|
||||
@ -442,7 +441,6 @@ public class GeckoLayerClient implements LayerView.Listener, PanZoomTarget
|
||||
// to abort the current update and continue with any subsequent ones. This
|
||||
// is useful for slow-to-render pages when the display-port starts lagging
|
||||
// behind enough that continuing to draw it is wasted effort.
|
||||
@WrapElementForJNI(allowMultithread = true)
|
||||
public ProgressiveUpdateData progressiveUpdateCallback(boolean aHasPendingNewThebesContent,
|
||||
float x, float y, float width, float height,
|
||||
float resolution, boolean lowPrecision) {
|
||||
@ -550,13 +548,13 @@ public class GeckoLayerClient implements LayerView.Listener, PanZoomTarget
|
||||
}
|
||||
}
|
||||
|
||||
/** The compositor invokes this function just before compositing a frame where the document
|
||||
/** This function is invoked by Gecko via JNI; be careful when modifying signature.
|
||||
* The compositor invokes this function just before compositing a frame where the document
|
||||
* is different from the document composited on the last frame. In these cases, the viewport
|
||||
* information we have in Java is no longer valid and needs to be replaced with the new
|
||||
* viewport information provided. setPageRect will never be invoked on the same frame that
|
||||
* this function is invoked on; and this function will always be called prior to syncViewportInfo.
|
||||
*/
|
||||
@WrapElementForJNI(allowMultithread = true)
|
||||
public void setFirstPaintViewport(float offsetX, float offsetY, float zoom,
|
||||
float cssPageLeft, float cssPageTop, float cssPageRight, float cssPageBottom) {
|
||||
synchronized (getLock()) {
|
||||
@ -609,12 +607,12 @@ public class GeckoLayerClient implements LayerView.Listener, PanZoomTarget
|
||||
mContentDocumentIsDisplayed = true;
|
||||
}
|
||||
|
||||
/** The compositor invokes this function whenever it determines that the page rect
|
||||
/** This function is invoked by Gecko via JNI; be careful when modifying signature.
|
||||
* The compositor invokes this function whenever it determines that the page rect
|
||||
* has changed (based on the information it gets from layout). If setFirstPaintViewport
|
||||
* is invoked on a frame, then this function will not be. For any given frame, this
|
||||
* function will be invoked before syncViewportInfo.
|
||||
*/
|
||||
@WrapElementForJNI(allowMultithread = true)
|
||||
public void setPageRect(float cssPageLeft, float cssPageTop, float cssPageRight, float cssPageBottom) {
|
||||
synchronized (getLock()) {
|
||||
RectF cssPageRect = new RectF(cssPageLeft, cssPageTop, cssPageRight, cssPageBottom);
|
||||
@ -627,7 +625,8 @@ public class GeckoLayerClient implements LayerView.Listener, PanZoomTarget
|
||||
}
|
||||
}
|
||||
|
||||
/** The compositor invokes this function on every frame to figure out what part of the
|
||||
/** This function is invoked by Gecko via JNI; be careful when modifying signature.
|
||||
* The compositor invokes this function on every frame to figure out what part of the
|
||||
* page to display, and to inform Java of the current display port. Since it is called
|
||||
* on every frame, it needs to be ultra-fast.
|
||||
* It avoids taking any locks or allocating any objects. We keep around a
|
||||
@ -635,7 +634,6 @@ public class GeckoLayerClient implements LayerView.Listener, PanZoomTarget
|
||||
* everytime we're called. NOTE: we might be able to return a ImmutableViewportMetrics
|
||||
* which would avoid the copy into mCurrentViewTransform.
|
||||
*/
|
||||
@WrapElementForJNI(allowMultithread = true)
|
||||
public ViewTransform syncViewportInfo(int x, int y, int width, int height, float resolution, boolean layersUpdated) {
|
||||
// getViewportMetrics is thread safe so we don't need to synchronize.
|
||||
// We save the viewport metrics here, so we later use it later in
|
||||
@ -689,7 +687,7 @@ public class GeckoLayerClient implements LayerView.Listener, PanZoomTarget
|
||||
return mCurrentViewTransform;
|
||||
}
|
||||
|
||||
@WrapElementForJNI(allowMultithread = true)
|
||||
/* Invoked by JNI from the compositor thread */
|
||||
public ViewTransform syncFrameMetrics(float offsetX, float offsetY, float zoom,
|
||||
float cssPageLeft, float cssPageTop, float cssPageRight, float cssPageBottom,
|
||||
boolean layersUpdated, int x, int y, int width, int height, float resolution,
|
||||
@ -703,7 +701,7 @@ public class GeckoLayerClient implements LayerView.Listener, PanZoomTarget
|
||||
return syncViewportInfo(x, y, width, height, resolution, layersUpdated);
|
||||
}
|
||||
|
||||
@WrapElementForJNI(allowMultithread = true)
|
||||
/** This function is invoked by Gecko via JNI; be careful when modifying signature. */
|
||||
public LayerRenderer.Frame createFrame() {
|
||||
// Create the shaders and textures if necessary.
|
||||
if (!mLayerRendererInitialized) {
|
||||
@ -715,12 +713,12 @@ public class GeckoLayerClient implements LayerView.Listener, PanZoomTarget
|
||||
return mLayerRenderer.createFrame(mFrameMetrics);
|
||||
}
|
||||
|
||||
@WrapElementForJNI(allowMultithread = true)
|
||||
/** This function is invoked by Gecko via JNI; be careful when modifying signature. */
|
||||
public void activateProgram() {
|
||||
mLayerRenderer.activateDefaultProgram();
|
||||
}
|
||||
|
||||
@WrapElementForJNI(allowMultithread = true)
|
||||
/** This function is invoked by Gecko via JNI; be careful when modifying signature. */
|
||||
public void deactivateProgram() {
|
||||
mLayerRenderer.deactivateDefaultProgram();
|
||||
}
|
||||
|
@ -5,7 +5,6 @@
|
||||
|
||||
package org.mozilla.gecko.gfx;
|
||||
|
||||
import org.mozilla.gecko.mozglue.generatorannotations.WrapElementForJNI;
|
||||
import org.mozilla.gecko.util.FloatUtils;
|
||||
|
||||
import android.graphics.PointF;
|
||||
@ -53,8 +52,7 @@ public class ImmutableViewportMetrics {
|
||||
/** This constructor is used by native code in AndroidJavaWrappers.cpp, be
|
||||
* careful when modifying the signature.
|
||||
*/
|
||||
@WrapElementForJNI(allowMultithread = true)
|
||||
public ImmutableViewportMetrics(float aPageRectLeft, float aPageRectTop,
|
||||
private ImmutableViewportMetrics(float aPageRectLeft, float aPageRectTop,
|
||||
float aPageRectRight, float aPageRectBottom, float aCssPageRectLeft,
|
||||
float aCssPageRectTop, float aCssPageRectRight, float aCssPageRectBottom,
|
||||
float aViewportRectLeft, float aViewportRectTop, float aViewportRectRight,
|
||||
|
@ -12,8 +12,6 @@ import org.mozilla.gecko.Tabs;
|
||||
import org.mozilla.gecko.gfx.Layer.RenderContext;
|
||||
import org.mozilla.gecko.gfx.RenderTask;
|
||||
import org.mozilla.gecko.mozglue.DirectBufferAllocator;
|
||||
import org.mozilla.gecko.mozglue.generatorannotations.GeneratorOptions;
|
||||
import org.mozilla.gecko.mozglue.generatorannotations.WrapElementForJNI;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.SharedPreferences;
|
||||
@ -21,6 +19,7 @@ import android.graphics.Bitmap;
|
||||
import android.graphics.Canvas;
|
||||
import android.graphics.Color;
|
||||
import android.graphics.Matrix;
|
||||
import android.graphics.Point;
|
||||
import android.graphics.PointF;
|
||||
import android.graphics.Rect;
|
||||
import android.graphics.RectF;
|
||||
@ -438,7 +437,6 @@ public class LayerRenderer implements Tabs.OnTabsChangedListener {
|
||||
}
|
||||
}
|
||||
|
||||
@GeneratorOptions(generatedClassName = "LayerRendererFrame")
|
||||
public class Frame {
|
||||
// The timestamp recording the start of this frame.
|
||||
private long mFrameStartTime;
|
||||
@ -492,7 +490,6 @@ public class LayerRenderer implements Tabs.OnTabsChangedListener {
|
||||
}
|
||||
|
||||
/** This function is invoked via JNI; be careful when modifying signature. */
|
||||
@WrapElementForJNI(allowMultithread = true)
|
||||
public void beginDrawing() {
|
||||
mFrameStartTime = System.nanoTime();
|
||||
|
||||
@ -582,7 +579,6 @@ public class LayerRenderer implements Tabs.OnTabsChangedListener {
|
||||
}
|
||||
|
||||
/** This function is invoked via JNI; be careful when modifying signature. */
|
||||
@WrapElementForJNI(allowMultithread = true)
|
||||
public void drawBackground() {
|
||||
GLES20.glDisable(GLES20.GL_SCISSOR_TEST);
|
||||
|
||||
@ -615,7 +611,6 @@ public class LayerRenderer implements Tabs.OnTabsChangedListener {
|
||||
}
|
||||
|
||||
/** This function is invoked via JNI; be careful when modifying signature. */
|
||||
@WrapElementForJNI(allowMultithread = true)
|
||||
public void drawForeground() {
|
||||
/* Draw any extra layers that were added (likely plugins) */
|
||||
if (mExtraLayers.size() > 0) {
|
||||
@ -666,7 +661,6 @@ public class LayerRenderer implements Tabs.OnTabsChangedListener {
|
||||
}
|
||||
|
||||
/** This function is invoked via JNI; be careful when modifying signature. */
|
||||
@WrapElementForJNI(allowMultithread = true)
|
||||
public void endDrawing() {
|
||||
// If a layer update requires further work, schedule another redraw
|
||||
if (!mUpdated)
|
||||
|
@ -12,7 +12,7 @@ import org.mozilla.gecko.PrefsHelper;
|
||||
import org.mozilla.gecko.R;
|
||||
import org.mozilla.gecko.TouchEventInterceptor;
|
||||
import org.mozilla.gecko.ZoomConstraints;
|
||||
import org.mozilla.gecko.mozglue.generatorannotations.WrapElementForJNI;
|
||||
import org.mozilla.gecko.mozglue.GeneratableAndroidBridgeTarget;
|
||||
import org.mozilla.gecko.util.EventDispatcher;
|
||||
|
||||
import android.content.Context;
|
||||
@ -508,7 +508,7 @@ public class LayerView extends FrameLayout {
|
||||
return mTextureView.getSurfaceTexture();
|
||||
}
|
||||
|
||||
@WrapElementForJNI(allowMultithread = true, stubName = "RegisterCompositorWrapper")
|
||||
@GeneratableAndroidBridgeTarget(allowMultithread = true, stubName = "RegisterCompositorWrapper")
|
||||
public static GLController registerCxxCompositor() {
|
||||
try {
|
||||
LayerView layerView = GeckoAppShell.getLayerView();
|
||||
|
@ -7,7 +7,7 @@ package org.mozilla.gecko.gfx;
|
||||
|
||||
import org.mozilla.gecko.GeckoEvent;
|
||||
import org.mozilla.gecko.GeckoThread;
|
||||
import org.mozilla.gecko.mozglue.generatorannotations.WrapElementForJNI;
|
||||
import org.mozilla.gecko.mozglue.GeneratableAndroidBridgeTarget;
|
||||
import org.mozilla.gecko.util.EventDispatcher;
|
||||
import org.mozilla.gecko.util.GeckoEventListener;
|
||||
|
||||
@ -83,12 +83,12 @@ class NativePanZoomController implements PanZoomController, GeckoEventListener {
|
||||
public native void setOverScrollMode(int overscrollMode);
|
||||
public native int getOverScrollMode();
|
||||
|
||||
@WrapElementForJNI(allowMultithread = true, stubName = "RequestContentRepaintWrapper")
|
||||
@GeneratableAndroidBridgeTarget(allowMultithread = true, stubName = "RequestContentRepaintWrapper")
|
||||
private void requestContentRepaint(float x, float y, float width, float height, float resolution) {
|
||||
mTarget.forceRedraw(new DisplayPortMetrics(x, y, x + width, y + height, resolution));
|
||||
}
|
||||
|
||||
@WrapElementForJNI(allowMultithread = true, stubName = "PostDelayedCallbackWrapper")
|
||||
@GeneratableAndroidBridgeTarget(allowMultithread = true, stubName = "PostDelayedCallbackWrapper")
|
||||
private void postDelayedCallback(long delay) {
|
||||
mTarget.postDelayed(mCallbackRunnable, delay);
|
||||
}
|
||||
|
@ -5,15 +5,12 @@
|
||||
|
||||
package org.mozilla.gecko.gfx;
|
||||
|
||||
import org.mozilla.gecko.mozglue.generatorannotations.WrapEntireClassForJNI;
|
||||
|
||||
/**
|
||||
* This is the data structure that's returned by the progressive tile update
|
||||
* callback function. It encompasses the current viewport and a boolean value
|
||||
* representing whether the front-end is interested in the current progressive
|
||||
* update continuing.
|
||||
*/
|
||||
@WrapEntireClassForJNI
|
||||
public class ProgressiveUpdateData {
|
||||
public float x;
|
||||
public float y;
|
||||
|
@ -5,9 +5,6 @@
|
||||
|
||||
package org.mozilla.gecko.gfx;
|
||||
|
||||
import org.mozilla.gecko.mozglue.generatorannotations.WrapEntireClassForJNI;
|
||||
|
||||
@WrapEntireClassForJNI
|
||||
public class ViewTransform {
|
||||
public float x;
|
||||
public float y;
|
||||
|
@ -2,7 +2,7 @@
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
package org.mozilla.gecko.mozglue.generatorannotations;
|
||||
package org.mozilla.gecko.mozglue;
|
||||
|
||||
import java.lang.annotation.Retention;
|
||||
import java.lang.annotation.RetentionPolicy;
|
||||
@ -21,7 +21,7 @@ import java.lang.annotation.RetentionPolicy;
|
||||
* and may lead to subtle bugs.
|
||||
*/
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
public @interface WrapElementForJNI {
|
||||
public @interface GeneratableAndroidBridgeTarget {
|
||||
// Optional parameter specifying the name of the generated method stub. If omitted, the name
|
||||
// of the Java method will be used.
|
||||
String stubName() default "";
|
@ -5,8 +5,6 @@
|
||||
|
||||
package org.mozilla.gecko.mozglue;
|
||||
|
||||
import org.mozilla.gecko.mozglue.generatorannotations.WrapElementForJNI;
|
||||
|
||||
import java.io.InputStream;
|
||||
import java.nio.ByteBuffer;
|
||||
import java.util.zip.Inflater;
|
||||
@ -70,7 +68,6 @@ public class NativeZip implements NativeReference {
|
||||
private static native void _release(long obj);
|
||||
private native InputStream _getInputStream(long obj, String path);
|
||||
|
||||
@WrapElementForJNI
|
||||
private InputStream createInputStream(ByteBuffer buffer, int compression) {
|
||||
if (compression != STORE && compression != DEFLATE) {
|
||||
throw new IllegalArgumentException("Unexpected compression: " + compression);
|
||||
|
@ -2,7 +2,7 @@
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
package org.mozilla.gecko.mozglue.generatorannotations;
|
||||
package org.mozilla.gecko.mozglue;
|
||||
|
||||
import java.lang.annotation.Retention;
|
||||
import java.lang.annotation.RetentionPolicy;
|
@ -1,14 +0,0 @@
|
||||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
package org.mozilla.gecko.mozglue.generatorannotations;
|
||||
|
||||
import java.lang.annotation.Retention;
|
||||
import java.lang.annotation.RetentionPolicy;
|
||||
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
public @interface GeneratorOptions {
|
||||
// Specifies a custom name for the generated C++ class. If left empty, is AndroidJavaClassName.
|
||||
String generatedClassName() default "";
|
||||
}
|
@ -1,15 +0,0 @@
|
||||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
package org.mozilla.gecko.mozglue.generatorannotations;
|
||||
|
||||
import java.lang.annotation.Retention;
|
||||
import java.lang.annotation.RetentionPolicy;
|
||||
|
||||
/**
|
||||
* Handy shortcut annotation. Functionally equivalent to tagging every member individually with default
|
||||
* settings.
|
||||
*/
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
public @interface WrapEntireClassForJNI {}
|
@ -17,8 +17,6 @@
|
||||
|
||||
package org.mozilla.gecko.sqlite;
|
||||
|
||||
import org.mozilla.gecko.mozglue.generatorannotations.WrapElementForJNI;
|
||||
|
||||
import android.database.AbstractCursor;
|
||||
import android.database.CursorIndexOutOfBoundsException;
|
||||
|
||||
@ -52,7 +50,6 @@ public class MatrixBlobCursor extends AbstractCursor {
|
||||
* determines column ordering elsewhere in this cursor
|
||||
* @param initialCapacity in rows
|
||||
*/
|
||||
@WrapElementForJNI
|
||||
public MatrixBlobCursor(String[] columnNames, int initialCapacity) {
|
||||
this.columnNames = columnNames;
|
||||
this.columnCount = columnNames.length;
|
||||
@ -70,7 +67,6 @@ public class MatrixBlobCursor extends AbstractCursor {
|
||||
* @param columnNames names of the columns, the ordering of which
|
||||
* determines column ordering elsewhere in this cursor
|
||||
*/
|
||||
@WrapElementForJNI
|
||||
public MatrixBlobCursor(String[] columnNames) {
|
||||
this(columnNames, 16);
|
||||
}
|
||||
@ -116,7 +112,6 @@ public class MatrixBlobCursor extends AbstractCursor {
|
||||
* @param columnValues in the same order as the the column names specified
|
||||
* at cursor construction time
|
||||
*/
|
||||
@WrapElementForJNI
|
||||
public void addRow(Object[] columnValues) {
|
||||
if (columnValues.length != columnCount) {
|
||||
throw new IllegalArgumentException("columnNames.length = "
|
||||
@ -138,7 +133,6 @@ public class MatrixBlobCursor extends AbstractCursor {
|
||||
* @param columnValues in the same order as the the column names specified
|
||||
* at cursor construction time
|
||||
*/
|
||||
@WrapElementForJNI
|
||||
public void addRow(Iterable<?> columnValues) {
|
||||
int start = rowCount * columnCount;
|
||||
int end = start + columnCount;
|
||||
@ -171,7 +165,6 @@ public class MatrixBlobCursor extends AbstractCursor {
|
||||
}
|
||||
|
||||
/** Optimization for {@link ArrayList}. */
|
||||
@WrapElementForJNI
|
||||
private void addRow(ArrayList<?> columnValues, int start) {
|
||||
int size = columnValues.size();
|
||||
if (size != columnCount) {
|
||||
|
@ -5,9 +5,6 @@
|
||||
|
||||
package org.mozilla.gecko.sqlite;
|
||||
|
||||
import org.mozilla.gecko.mozglue.generatorannotations.WrapEntireClassForJNI;
|
||||
|
||||
@WrapEntireClassForJNI
|
||||
public class SQLiteBridgeException extends RuntimeException {
|
||||
static final long serialVersionUID = 1L;
|
||||
|
||||
|
@ -9,7 +9,7 @@ import android.content.Context;
|
||||
import android.os.Build;
|
||||
import android.util.Log;
|
||||
|
||||
import org.mozilla.gecko.mozglue.generatorannotations.WrapElementForJNI;
|
||||
import org.mozilla.gecko.mozglue.GeneratableAndroidBridgeTarget;
|
||||
|
||||
import java.util.concurrent.SynchronousQueue;
|
||||
|
||||
@ -29,7 +29,7 @@ public final class Clipboard {
|
||||
mContext = c;
|
||||
}
|
||||
|
||||
@WrapElementForJNI(stubName = "GetClipboardTextWrapper")
|
||||
@GeneratableAndroidBridgeTarget(stubName = "GetClipboardTextWrapper")
|
||||
public static String getText() {
|
||||
// If we're on the UI thread or the background thread, we have a looper on the thread
|
||||
// and can just call this directly. For any other threads, post the call to the
|
||||
@ -55,7 +55,7 @@ public final class Clipboard {
|
||||
}
|
||||
}
|
||||
|
||||
@WrapElementForJNI(stubName = "SetClipboardText")
|
||||
@GeneratableAndroidBridgeTarget(stubName = "SetClipboardText")
|
||||
public static void setText(final CharSequence text) {
|
||||
ThreadUtils.postToBackgroundThread(new Runnable() {
|
||||
@Override
|
||||
@ -79,25 +79,6 @@ public final class Clipboard {
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if the clipboard is nonempty, false otherwise.
|
||||
*
|
||||
* @return true if the clipboard is nonempty, false otherwise.
|
||||
*/
|
||||
@WrapElementForJNI
|
||||
public static boolean hasText() {
|
||||
String text = getText();
|
||||
return text != null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Deletes all text from the clipboard.
|
||||
*/
|
||||
@WrapElementForJNI
|
||||
public static void clearText() {
|
||||
setText(null);
|
||||
}
|
||||
|
||||
private static android.content.ClipboardManager getClipboardManager11(Context context) {
|
||||
// In API Level 11 and above, CLIPBOARD_SERVICE returns android.content.ClipboardManager,
|
||||
// which is a subclass of android.text.ClipboardManager.
|
||||
|
@ -50,7 +50,10 @@ nsAndroidHistory::RegisterVisitedCallback(nsIURI *aURI, Link *aContent)
|
||||
}
|
||||
list->AppendElement(aContent);
|
||||
|
||||
GeckoAppShell::CheckURIVisited(uriString);
|
||||
AndroidBridge *bridge = AndroidBridge::Bridge();
|
||||
if (bridge) {
|
||||
bridge->CheckURIVisited(uriString);
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
@ -93,23 +96,27 @@ nsAndroidHistory::VisitURI(nsIURI *aURI, nsIURI *aLastVisitedURI, uint32_t aFlag
|
||||
if (aFlags & VisitFlags::UNRECOVERABLE_ERROR)
|
||||
return NS_OK;
|
||||
|
||||
nsAutoCString uri;
|
||||
nsresult rv = aURI->GetSpec(uri);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
NS_ConvertUTF8toUTF16 uriString(uri);
|
||||
GeckoAppShell::MarkURIVisited(uriString);
|
||||
AndroidBridge *bridge = AndroidBridge::Bridge();
|
||||
if (bridge) {
|
||||
nsAutoCString uri;
|
||||
nsresult rv = aURI->GetSpec(uri);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
NS_ConvertUTF8toUTF16 uriString(uri);
|
||||
bridge->MarkURIVisited(uriString);
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsAndroidHistory::SetURITitle(nsIURI *aURI, const nsAString& aTitle)
|
||||
{
|
||||
if (AndroidBridge::Bridge()) {
|
||||
AndroidBridge *bridge = AndroidBridge::Bridge();
|
||||
if (bridge) {
|
||||
nsAutoCString uri;
|
||||
nsresult rv = aURI->GetSpec(uri);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
NS_ConvertUTF8toUTF16 uriString(uri);
|
||||
GeckoAppShell::SetURITitle(uriString, aTitle);
|
||||
bridge->SetURITitle(uriString, aTitle);
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
@ -8,8 +8,6 @@
|
||||
|
||||
#include "AndroidBridge.h"
|
||||
|
||||
using namespace mozilla::widget::android;
|
||||
|
||||
NS_IMPL_ISUPPORTS1(nsShellService, nsIShellService)
|
||||
|
||||
NS_IMETHODIMP
|
||||
@ -24,6 +22,6 @@ nsShellService::CreateShortcut(const nsAString& aTitle, const nsAString& aURI, c
|
||||
if (!aTitle.Length() || !aURI.Length() || !aIconData.Length())
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
GeckoAppShell::CreateShortcut(aTitle, aURI, aIconData, aIntent);
|
||||
mozilla::AndroidBridge::Bridge()->CreateShortcut(aTitle, aURI, aIconData, aIntent);
|
||||
return NS_OK;
|
||||
}
|
||||
|
@ -80,7 +80,7 @@ Tickler::Init()
|
||||
MOZ_ASSERT(!mThread);
|
||||
MOZ_ASSERT(!mFD);
|
||||
|
||||
GeckoAppShell::EnableNetworkNotifications();
|
||||
AndroidBridge::Bridge()->EnableNetworkNotifications();
|
||||
|
||||
mFD = PR_OpenUDPSocket(PR_AF_INET);
|
||||
if (!mFD)
|
||||
|
@ -90,7 +90,7 @@ bool CameraStreamImpl::Init(const nsCString& contentType, const uint32_t& camera
|
||||
}
|
||||
|
||||
void CameraStreamImpl::Close() {
|
||||
GeckoAppShell::CloseCamera();
|
||||
AndroidBridge::Bridge()->CloseCamera();
|
||||
mCallback = nullptr;
|
||||
}
|
||||
|
||||
|
@ -10,8 +10,6 @@
|
||||
|
||||
#include "AndroidBridge.h"
|
||||
|
||||
using namespace mozilla::widget::android;
|
||||
|
||||
NS_IMPL_ISUPPORTS1(nsAndroidNetworkLinkService,
|
||||
nsINetworkLinkService)
|
||||
|
||||
@ -33,7 +31,7 @@ nsAndroidNetworkLinkService::GetIsLinkUp(bool *aIsUp)
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
*aIsUp = GeckoAppShell::IsNetworkLinkUp();
|
||||
*aIsUp = mozilla::AndroidBridge::Bridge()->IsNetworkLinkUp();
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
@ -42,7 +40,7 @@ nsAndroidNetworkLinkService::GetLinkStatusKnown(bool *aIsKnown)
|
||||
{
|
||||
NS_ENSURE_TRUE(mozilla::AndroidBridge::Bridge(), NS_ERROR_NOT_IMPLEMENTED);
|
||||
|
||||
*aIsKnown = GeckoAppShell::IsNetworkLinkKnown();
|
||||
*aIsKnown = mozilla::AndroidBridge::Bridge()->IsNetworkLinkKnown();
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
@ -10,7 +10,6 @@
|
||||
|
||||
#ifdef MOZ_WIDGET_ANDROID
|
||||
#include "AndroidBridge.h"
|
||||
using namespace mozilla::widget::android;
|
||||
#else
|
||||
|
||||
#include "nsXPCOM.h"
|
||||
@ -124,7 +123,7 @@ NS_IMETHODIMP nsAlertsService::CloseAlert(const nsAString& aAlertName)
|
||||
}
|
||||
|
||||
#ifdef MOZ_WIDGET_ANDROID
|
||||
GeckoAppShell::CloseNotification(aAlertName);
|
||||
mozilla::AndroidBridge::Bridge()->CloseNotification(aAlertName);
|
||||
return NS_OK;
|
||||
#else
|
||||
|
||||
@ -145,7 +144,7 @@ NS_IMETHODIMP nsAlertsService::OnProgress(const nsAString & aAlertName,
|
||||
const nsAString & aAlertText)
|
||||
{
|
||||
#ifdef MOZ_WIDGET_ANDROID
|
||||
GeckoAppShell::AlertsProgressListener_OnProgress(aAlertName, aProgress, aProgressMax, aAlertText);
|
||||
mozilla::AndroidBridge::Bridge()->AlertsProgressListener_OnProgress(aAlertName, aProgress, aProgressMax, aAlertText);
|
||||
return NS_OK;
|
||||
#else
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
@ -155,7 +154,7 @@ NS_IMETHODIMP nsAlertsService::OnProgress(const nsAString & aAlertName,
|
||||
NS_IMETHODIMP nsAlertsService::OnCancel(const nsAString & aAlertName)
|
||||
{
|
||||
#ifdef MOZ_WIDGET_ANDROID
|
||||
GeckoAppShell::CloseNotification(aAlertName);
|
||||
mozilla::AndroidBridge::Bridge()->CloseNotification(aAlertName);
|
||||
return NS_OK;
|
||||
#else
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
|
@ -51,7 +51,6 @@
|
||||
|
||||
#ifdef MOZ_WIDGET_ANDROID
|
||||
#include "AndroidBridge.h"
|
||||
using namespace mozilla::widget::android;
|
||||
#endif
|
||||
|
||||
#ifdef MOZ_WIDGET_GTK
|
||||
@ -2776,7 +2775,7 @@ nsDownload::SetState(DownloadState aState)
|
||||
if (mimeInfo)
|
||||
mimeInfo->GetMIMEType(contentType);
|
||||
|
||||
GeckoAppShell::ScanMedia(path, NS_ConvertUTF8toUTF16(contentType));
|
||||
mozilla::AndroidBridge::Bridge()->ScanMedia(path, NS_ConvertUTF8toUTF16(contentType));
|
||||
#endif
|
||||
}
|
||||
|
||||
|
@ -118,7 +118,7 @@ nsresult DownloadPlatform::DownloadDone(nsIURI* aSource, nsIFile* aTarget,
|
||||
#endif
|
||||
#ifdef MOZ_WIDGET_ANDROID
|
||||
if (!aContentType.IsEmpty()) {
|
||||
mozilla::widget::android::GeckoAppShell::ScanMedia(path, NS_ConvertUTF8toUTF16(aContentType));
|
||||
mozilla::AndroidBridge::Bridge()->ScanMedia(path, NS_ConvertUTF8toUTF16(aContentType));
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
@ -75,7 +75,7 @@ GeckoStart(void *data, const nsXREAppData *appData)
|
||||
if (result)
|
||||
LOG("XRE_main returned %d", result);
|
||||
|
||||
mozilla::widget::android::GeckoAppShell::NotifyXreExit();
|
||||
mozilla::AndroidBridge::Bridge()->NotifyXreExit();
|
||||
|
||||
free(targs[0]);
|
||||
nsMemory::Free(data);
|
||||
|
@ -1647,7 +1647,7 @@ static nsresult LaunchChild(nsINativeAppSupport* aNative,
|
||||
SaveToEnv("MOZ_LAUNCHED_CHILD=1");
|
||||
|
||||
#if defined(MOZ_WIDGET_ANDROID)
|
||||
mozilla::widget::android::GeckoAppShell::ScheduleRestart();
|
||||
mozilla::AndroidBridge::Bridge()->ScheduleRestart();
|
||||
#else
|
||||
#if defined(XP_MACOSX)
|
||||
CommandLineServiceMac::SetupMacCommandLine(gRestartArgc, gRestartArgv, true);
|
||||
@ -1759,7 +1759,7 @@ ProfileLockedDialog(nsIFile* aProfileDir, nsIFile* aProfileLocalDir,
|
||||
if (aUnlocker) {
|
||||
int32_t button;
|
||||
#ifdef MOZ_WIDGET_ANDROID
|
||||
mozilla::widget::android::GeckoAppShell::KillAnyZombies();
|
||||
mozilla::AndroidBridge::Bridge()->KillAnyZombies();
|
||||
button = 1;
|
||||
#else
|
||||
const uint32_t flags =
|
||||
@ -1786,7 +1786,7 @@ ProfileLockedDialog(nsIFile* aProfileDir, nsIFile* aProfileLocalDir,
|
||||
}
|
||||
} else {
|
||||
#ifdef MOZ_WIDGET_ANDROID
|
||||
if (mozilla::widget::android::GeckoAppShell::UnlockProfile()) {
|
||||
if (mozilla::AndroidBridge::Bridge()->UnlockProfile()) {
|
||||
return NS_LockProfilePath(aProfileDir, aProfileLocalDir,
|
||||
nullptr, aResult);
|
||||
}
|
||||
|
@ -230,7 +230,7 @@ typename Builder::Object BuildJavaThreadJSObject(Builder& b)
|
||||
b.DefineProperty(sample, "frames", frames);
|
||||
b.ArrayPush(samples, sample);
|
||||
|
||||
double sampleTime = GeckoJavaSampler::GetSampleTimeJavaProfiling(0, sampleId);
|
||||
double sampleTime = AndroidBridge::Bridge()->GetSampleTimeJavaProfiling(0, sampleId);
|
||||
b.DefineProperty(sample, "time", sampleTime);
|
||||
}
|
||||
typename Builder::RootedObject frame(b.context(), b.CreateObject());
|
||||
@ -282,12 +282,12 @@ void TableTicker::BuildJSObject(Builder& b, typename Builder::ObjectHandle profi
|
||||
|
||||
#if defined(SPS_OS_android) && !defined(MOZ_WIDGET_GONK)
|
||||
if (ProfileJava()) {
|
||||
GeckoJavaSampler::PauseJavaProfiling();
|
||||
AndroidBridge::Bridge()->PauseJavaProfiling();
|
||||
|
||||
typename Builder::RootedObject javaThread(b.context(), BuildJavaThreadJSObject(b));
|
||||
b.ArrayPush(threads, javaThread);
|
||||
|
||||
GeckoJavaSampler::UnpauseJavaProfiling();
|
||||
AndroidBridge::Bridge()->UnpauseJavaProfiling();
|
||||
}
|
||||
#endif
|
||||
|
||||
|
@ -27,7 +27,6 @@
|
||||
|
||||
#if defined(SPS_OS_android) && !defined(MOZ_WIDGET_GONK)
|
||||
#include "AndroidBridge.h"
|
||||
using namespace mozilla::widget::android;
|
||||
#endif
|
||||
|
||||
mozilla::ThreadLocal<PseudoStack *> tlsPseudoStack;
|
||||
@ -599,7 +598,7 @@ void mozilla_sampler_start(int aProfileEntries, double aInterval,
|
||||
if (javaInterval < 10) {
|
||||
aInterval = 10;
|
||||
}
|
||||
GeckoJavaSampler::StartJavaProfiling(javaInterval, 1000);
|
||||
mozilla::AndroidBridge::Bridge()->StartJavaProfiling(javaInterval, 1000);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
@ -6,8 +6,6 @@
|
||||
#include "nsAndroidHandlerApp.h"
|
||||
#include "AndroidBridge.h"
|
||||
|
||||
using namespace mozilla::widget::android;
|
||||
|
||||
|
||||
NS_IMPL_ISUPPORTS2(nsAndroidHandlerApp, nsIHandlerApp, nsISharingHandlerApp)
|
||||
|
||||
@ -67,16 +65,24 @@ nsAndroidHandlerApp::Equals(nsIHandlerApp *aHandlerApp, bool *aRetval)
|
||||
NS_IMETHODIMP
|
||||
nsAndroidHandlerApp::LaunchWithURI(nsIURI *aURI, nsIInterfaceRequestor *aWindowContext)
|
||||
{
|
||||
if (!mozilla::AndroidBridge::Bridge())
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
nsCString uriSpec;
|
||||
aURI->GetSpec(uriSpec);
|
||||
return GeckoAppShell::OpenUriExternal(NS_ConvertUTF8toUTF16(uriSpec), NS_ConvertUTF8toUTF16(mMimeType), mPackageName, mClassName, mAction) ?
|
||||
return mozilla::AndroidBridge::Bridge()->
|
||||
OpenUriExternal(NS_ConvertUTF8toUTF16(uriSpec), NS_ConvertUTF8toUTF16(mMimeType), mPackageName, mClassName, mAction) ?
|
||||
NS_OK : NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsAndroidHandlerApp::Share(const nsAString & data, const nsAString & title)
|
||||
{
|
||||
return GeckoAppShell::OpenUriExternal(data, NS_ConvertUTF8toUTF16(mMimeType), mPackageName,
|
||||
if (!mozilla::AndroidBridge::Bridge())
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
return mozilla::AndroidBridge::Bridge()->
|
||||
OpenUriExternal(data, NS_ConvertUTF8toUTF16(mMimeType), mPackageName,
|
||||
mClassName, mAction) ? NS_OK : NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
|
@ -31,7 +31,12 @@ nsExternalSharingAppService::ShareWithDefault(const nsAString & data,
|
||||
{
|
||||
NS_NAMED_LITERAL_STRING(sendAction, "android.intent.action.SEND");
|
||||
const nsString emptyString = EmptyString();
|
||||
return GeckoAppShell::OpenUriExternal(data, mime, emptyString,emptyString, sendAction, title) ? NS_OK : NS_ERROR_FAILURE;
|
||||
if (AndroidBridge::Bridge())
|
||||
return AndroidBridge::Bridge()->
|
||||
OpenUriExternal(data, mime,
|
||||
emptyString,emptyString, sendAction, title) ? NS_OK : NS_ERROR_FAILURE;
|
||||
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
|
@ -10,8 +10,6 @@
|
||||
#include "nsStringEnumerator.h"
|
||||
#include "nsNetUtil.h"
|
||||
|
||||
using namespace mozilla::widget::android;
|
||||
|
||||
NS_IMPL_ISUPPORTS2(nsMIMEInfoAndroid, nsIMIMEInfo, nsIHandlerInfo)
|
||||
|
||||
NS_IMETHODIMP
|
||||
@ -30,7 +28,11 @@ nsMIMEInfoAndroid::LoadUriInternal(nsIURI * aURI)
|
||||
nsCString uriScheme;
|
||||
aURI->GetScheme(uriScheme);
|
||||
|
||||
return GeckoAppShell::OpenUriExternal(NS_ConvertUTF8toUTF16(uriSpec), (mType.Equals(uriScheme) || mType.Equals(uriSpec)) ? EmptyString() : NS_ConvertUTF8toUTF16(mType)) ? NS_OK : NS_ERROR_FAILURE;
|
||||
if (mozilla::AndroidBridge::Bridge())
|
||||
return mozilla::AndroidBridge::Bridge()->
|
||||
OpenUriExternal(NS_ConvertUTF8toUTF16(uriSpec), (mType.Equals(uriScheme) || mType.Equals(uriSpec)) ? EmptyString() : NS_ConvertUTF8toUTF16(mType)) ? NS_OK : NS_ERROR_FAILURE;
|
||||
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
|
||||
|
@ -37,8 +37,13 @@
|
||||
#include "mozilla/ClearOnShutdown.h"
|
||||
#include "nsPrintfCString.h"
|
||||
|
||||
#ifdef DEBUG
|
||||
#define ALOG_BRIDGE(args...) ALOG(args)
|
||||
#else
|
||||
#define ALOG_BRIDGE(args...) ((void)0)
|
||||
#endif
|
||||
|
||||
using namespace mozilla;
|
||||
using namespace mozilla::widget::android;
|
||||
|
||||
NS_IMPL_ISUPPORTS0(nsFilePickerCallback)
|
||||
|
||||
@ -162,13 +167,14 @@ AndroidBridge::Init(JNIEnv *jEnv)
|
||||
|
||||
mJNIEnv = nullptr;
|
||||
mThread = -1;
|
||||
mGLControllerObj = NULL;
|
||||
mGLControllerObj = nullptr;
|
||||
mOpenedGraphicsLibraries = false;
|
||||
mHasNativeBitmapAccess = false;
|
||||
mHasNativeWindowAccess = false;
|
||||
mHasNativeWindowFallback = false;
|
||||
|
||||
initInit();
|
||||
InitStubs(jEnv);
|
||||
|
||||
#ifdef MOZ_WEBSMS_BACKEND
|
||||
mAndroidSmsMessageClass = getClassGlobalRef("android/telephony/SmsMessage");
|
||||
@ -266,52 +272,6 @@ jstring AndroidBridge::NewJavaString(AutoLocalJNIFrame* frame, const nsACString&
|
||||
return NewJavaString(frame, NS_ConvertUTF8toUTF16(string));
|
||||
}
|
||||
|
||||
extern "C" {
|
||||
__attribute__ ((visibility("default")))
|
||||
JNIEnv * GetJNIForThread()
|
||||
{
|
||||
JNIEnv *jEnv = NULL;
|
||||
JavaVM *jVm = mozilla::AndroidBridge::GetVM();
|
||||
if (!jVm) {
|
||||
__android_log_print(ANDROID_LOG_INFO, "GetJNIForThread", "Returned a null VM");
|
||||
return NULL;
|
||||
}
|
||||
jEnv = static_cast<JNIEnv*>(PR_GetThreadPrivate(sJavaEnvThreadIndex));
|
||||
|
||||
if (jEnv)
|
||||
return jEnv;
|
||||
|
||||
int status = jVm->GetEnv((void**) &jEnv, JNI_VERSION_1_2);
|
||||
if (status) {
|
||||
|
||||
status = jVm->AttachCurrentThread(&jEnv, NULL);
|
||||
if (status) {
|
||||
__android_log_print(ANDROID_LOG_INFO, "GetJNIForThread", "Could not attach");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
PR_SetThreadPrivate(sJavaEnvThreadIndex, jEnv);
|
||||
}
|
||||
if (!jEnv) {
|
||||
__android_log_print(ANDROID_LOG_INFO, "GetJNIForThread", "returning NULL");
|
||||
}
|
||||
return jEnv;
|
||||
}
|
||||
}
|
||||
|
||||
void AutoGlobalWrappedJavaObject::Dispose() {
|
||||
if (isNull()) {
|
||||
return;
|
||||
}
|
||||
|
||||
GetJNIForThread()->DeleteGlobalRef(wrapped_obj);
|
||||
wrapped_obj = NULL;
|
||||
}
|
||||
|
||||
AutoGlobalWrappedJavaObject::~AutoGlobalWrappedJavaObject() {
|
||||
Dispose();
|
||||
}
|
||||
|
||||
static void
|
||||
getHandlersFromStringArray(JNIEnv *aJNIEnv, jobjectArray jArr, jsize aLen,
|
||||
nsIMutableArray *aHandlersArray,
|
||||
@ -351,7 +311,7 @@ AndroidBridge::GetHandlersForMimeType(const nsAString& aMimeType,
|
||||
if (!env)
|
||||
return false;
|
||||
|
||||
jobjectArray arr = GeckoAppShell::GetHandlersForMimeTypeWrapper(aMimeType, aAction);
|
||||
jobjectArray arr = GetHandlersForMimeTypeWrapper(aMimeType, aAction);
|
||||
if (!arr)
|
||||
return false;
|
||||
|
||||
@ -380,7 +340,7 @@ AndroidBridge::GetHandlersForURL(const nsAString& aURL,
|
||||
if (!env)
|
||||
return false;
|
||||
|
||||
jobjectArray arr = GeckoAppShell::GetHandlersForURLWrapper(aURL, aAction);
|
||||
jobjectArray arr = GetHandlersForURLWrapper(aURL, aAction);
|
||||
if (!arr)
|
||||
return false;
|
||||
|
||||
@ -405,7 +365,7 @@ AndroidBridge::GetMimeTypeFromExtensions(const nsACString& aFileExt, nsCString&
|
||||
if (!env)
|
||||
return;
|
||||
|
||||
jstring jstrType = GeckoAppShell::GetMimeTypeFromExtensionsWrapper(NS_ConvertUTF8toUTF16(aFileExt));
|
||||
jstring jstrType = GetMimeTypeFromExtensionsWrapper(NS_ConvertUTF8toUTF16(aFileExt));
|
||||
if (!jstrType) {
|
||||
return;
|
||||
}
|
||||
@ -424,7 +384,7 @@ AndroidBridge::GetExtensionFromMimeType(const nsACString& aMimeType, nsACString&
|
||||
if (!env)
|
||||
return;
|
||||
|
||||
jstring jstrExt = GeckoAppShell::GetExtensionFromMimeTypeWrapper(NS_ConvertUTF8toUTF16(aMimeType));
|
||||
jstring jstrExt = GetExtensionFromMimeTypeWrapper(NS_ConvertUTF8toUTF16(aMimeType));
|
||||
if (!jstrExt) {
|
||||
return;
|
||||
}
|
||||
@ -443,7 +403,7 @@ AndroidBridge::GetClipboardText(nsAString& aText)
|
||||
if (!env)
|
||||
return false;
|
||||
|
||||
jstring result = Clipboard::GetClipboardTextWrapper();
|
||||
jstring result = GetClipboardTextWrapper();
|
||||
if (!result)
|
||||
return false;
|
||||
|
||||
@ -454,6 +414,36 @@ AndroidBridge::GetClipboardText(nsAString& aText)
|
||||
return true;
|
||||
}
|
||||
|
||||
bool
|
||||
AndroidBridge::ClipboardHasText()
|
||||
{
|
||||
ALOG_BRIDGE("AndroidBridge::ClipboardHasText");
|
||||
|
||||
JNIEnv *env = GetJNIEnv();
|
||||
if (!env)
|
||||
return false;
|
||||
|
||||
AutoLocalJNIFrame jniFrame(env);
|
||||
|
||||
jstring jStr = GetClipboardTextWrapper();
|
||||
bool ret = jStr;
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
void
|
||||
AndroidBridge::EmptyClipboard()
|
||||
{
|
||||
ALOG_BRIDGE("AndroidBridge::EmptyClipboard");
|
||||
|
||||
JNIEnv *env = GetJNIEnv();
|
||||
if (!env)
|
||||
return;
|
||||
|
||||
AutoLocalJNIFrame jniFrame(env, 0);
|
||||
env->CallStaticVoidMethod(mClipboardClass, jSetClipboardText, nullptr);
|
||||
}
|
||||
|
||||
void
|
||||
AndroidBridge::ShowAlertNotification(const nsAString& aImageUrl,
|
||||
const nsAString& aAlertTitle,
|
||||
@ -467,7 +457,7 @@ AndroidBridge::ShowAlertNotification(const nsAString& aImageUrl,
|
||||
nsAppShell::gAppShell->PostEvent(AndroidGeckoEvent::MakeAddObserver(aAlertName, aAlertListener));
|
||||
}
|
||||
|
||||
GeckoAppShell::ShowAlertNotificationWrapper(aImageUrl, aAlertTitle, aAlertText, aAlertCookie, aAlertName);
|
||||
ShowAlertNotificationWrapper(aImageUrl, aAlertTitle, aAlertText, aAlertCookie, aAlertName);
|
||||
}
|
||||
|
||||
int
|
||||
@ -479,7 +469,7 @@ AndroidBridge::GetDPI()
|
||||
|
||||
const int DEFAULT_DPI = 160;
|
||||
|
||||
sDPI = GeckoAppShell::GetDpiWrapper();
|
||||
sDPI = GetDpiWrapper();
|
||||
if (!sDPI) {
|
||||
return DEFAULT_DPI;
|
||||
}
|
||||
@ -498,7 +488,7 @@ AndroidBridge::GetScreenDepth()
|
||||
|
||||
const int DEFAULT_DEPTH = 16;
|
||||
|
||||
sDepth = GeckoAppShell::GetScreenDepthWrapper();
|
||||
sDepth = GetScreenDepthWrapper();
|
||||
if (!sDepth)
|
||||
return DEFAULT_DEPTH;
|
||||
|
||||
@ -512,7 +502,7 @@ AndroidBridge::ShowFilePickerForExtensions(nsAString& aFilePath, const nsAString
|
||||
if (!env)
|
||||
return;
|
||||
|
||||
jstring jstr = GeckoAppShell::ShowFilePickerForExtensionsWrapper(aExtensions);
|
||||
jstring jstr = ShowFilePickerForExtensionsWrapper(aExtensions);
|
||||
if (jstr == nullptr) {
|
||||
return;
|
||||
}
|
||||
@ -528,7 +518,7 @@ AndroidBridge::ShowFilePickerForMimeType(nsAString& aFilePath, const nsAString&
|
||||
if (!env)
|
||||
return;
|
||||
|
||||
jstring jstr = GeckoAppShell::ShowFilePickerForMimeTypeWrapper(aMimeType);
|
||||
jstring jstr = ShowFilePickerForMimeTypeWrapper(aMimeType);
|
||||
if (jstr == nullptr) {
|
||||
return;
|
||||
}
|
||||
@ -541,7 +531,19 @@ void
|
||||
AndroidBridge::ShowFilePickerAsync(const nsAString& aMimeType, nsFilePickerCallback* callback)
|
||||
{
|
||||
callback->AddRef();
|
||||
GeckoAppShell::ShowFilePickerAsyncWrapper(aMimeType, (int64_t) callback);
|
||||
ShowFilePickerAsyncWrapper(aMimeType, (int64_t) callback);
|
||||
}
|
||||
|
||||
void
|
||||
AndroidBridge::HideProgressDialogOnce()
|
||||
{
|
||||
static bool once = false;
|
||||
if (once)
|
||||
return;
|
||||
|
||||
HideProgressDialog();
|
||||
|
||||
once = true;
|
||||
}
|
||||
|
||||
void
|
||||
@ -569,7 +571,7 @@ AndroidBridge::Vibrate(const nsTArray<uint32_t>& aPattern)
|
||||
ALOG_BRIDGE(" invalid vibration duration < 0");
|
||||
return;
|
||||
}
|
||||
GeckoAppShell::Vibrate1(d);
|
||||
Vibrate1(d);
|
||||
return;
|
||||
}
|
||||
|
||||
@ -595,7 +597,7 @@ AndroidBridge::Vibrate(const nsTArray<uint32_t>& aPattern)
|
||||
}
|
||||
env->ReleaseLongArrayElements(array, elts, 0);
|
||||
|
||||
GeckoAppShell::VibrateA(array, -1/*don't repeat*/);
|
||||
VibrateA(array, -1/*don't repeat*/);
|
||||
}
|
||||
|
||||
void
|
||||
@ -612,7 +614,7 @@ AndroidBridge::GetSystemColors(AndroidSystemColors *aColors)
|
||||
|
||||
AutoLocalJNIFrame jniFrame(env);
|
||||
|
||||
jintArray arr = GeckoAppShell::GetSystemColoursWrapper();
|
||||
jintArray arr = GetSystemColoursWrapper();
|
||||
if (!arr)
|
||||
return;
|
||||
|
||||
@ -650,7 +652,7 @@ AndroidBridge::GetIconForExtension(const nsACString& aFileExt, uint32_t aIconSiz
|
||||
|
||||
AutoLocalJNIFrame jniFrame(env);
|
||||
|
||||
jbyteArray arr = GeckoAppShell::GetIconForExtensionWrapper(NS_ConvertUTF8toUTF16(aFileExt), aIconSize);
|
||||
jbyteArray arr = GetIconForExtensionWrapper(NS_ConvertUTF8toUTF16(aFileExt), aIconSize);
|
||||
|
||||
NS_ASSERTION(arr != nullptr, "AndroidBridge::GetIconForExtension: Returned pixels array is null!");
|
||||
if (!arr)
|
||||
@ -678,11 +680,14 @@ AndroidBridge::SetLayerClient(JNIEnv* env, jobject jobj)
|
||||
|
||||
if (resetting) {
|
||||
// clear out the old layer client
|
||||
env->DeleteGlobalRef(mLayerClient->wrappedObject());
|
||||
delete mLayerClient;
|
||||
mLayerClient = NULL;
|
||||
}
|
||||
|
||||
mLayerClient = GeckoLayerClient::Wrap(jobj);
|
||||
AndroidGeckoLayerClient *client = new AndroidGeckoLayerClient();
|
||||
client->Init(env->NewGlobalRef(jobj));
|
||||
mLayerClient = client;
|
||||
|
||||
if (resetting) {
|
||||
// since we are re-linking the new java objects to Gecko, we need to get
|
||||
@ -695,17 +700,26 @@ AndroidBridge::SetLayerClient(JNIEnv* env, jobject jobj)
|
||||
void
|
||||
AndroidBridge::RegisterCompositor(JNIEnv *env)
|
||||
{
|
||||
if (mGLControllerObj != NULL && !mGLControllerObj->isNull()) {
|
||||
ALOG_BRIDGE("AndroidBridge::RegisterCompositor");
|
||||
if (mGLControllerObj) {
|
||||
// we already have this set up, no need to do it again
|
||||
return;
|
||||
}
|
||||
|
||||
jobject glController = LayerView::RegisterCompositorWrapper();
|
||||
if (!env) {
|
||||
env = GetJNIForThread(); // called on the compositor thread
|
||||
}
|
||||
if (!env) {
|
||||
return;
|
||||
}
|
||||
|
||||
jobject glController = RegisterCompositorWrapper();
|
||||
if (!glController) {
|
||||
return;
|
||||
}
|
||||
|
||||
mGLControllerObj = GLController::Wrap(glController);
|
||||
mGLControllerObj = env->NewGlobalRef(glController);
|
||||
env->DeleteLocalRef(glController);
|
||||
}
|
||||
|
||||
EGLSurface
|
||||
@ -721,7 +735,7 @@ AndroidBridge::ProvideEGLSurface()
|
||||
return NULL;
|
||||
}
|
||||
|
||||
jobject eglSurface = mGLControllerObj->ProvideEGLSurfaceWrapper();
|
||||
jobject eglSurface = ProvideEGLSurfaceWrapper(mGLControllerObj);
|
||||
if (!eglSurface)
|
||||
return NULL;
|
||||
|
||||
@ -793,6 +807,11 @@ mozilla_AndroidBridge_SetMainThread(pthread_t thr)
|
||||
return AndroidBridge::Bridge()->SetMainThread(thr);
|
||||
}
|
||||
|
||||
jclass GetGeckoAppShellClass()
|
||||
{
|
||||
return mozilla::AndroidBridge::GetGeckoAppShellClass();
|
||||
}
|
||||
|
||||
void*
|
||||
AndroidBridge::GetNativeSurface(JNIEnv* env, jobject surface) {
|
||||
if (!env || !mHasNativeWindowFallback || !jSurfacePointerField)
|
||||
@ -989,7 +1008,7 @@ AndroidBridge::InitCamera(const nsCString& contentType, uint32_t camera, uint32_
|
||||
return false;
|
||||
|
||||
AutoLocalJNIFrame jniFrame(env);
|
||||
jintArray arr = GeckoAppShell::InitCameraWrapper(NS_ConvertUTF8toUTF16(contentType), (int32_t) camera, (int32_t) width, (int32_t) height);
|
||||
jintArray arr = InitCameraWrapper(NS_ConvertUTF8toUTF16(contentType), (int32_t) camera, (int32_t) width, (int32_t) height);
|
||||
|
||||
if (!arr)
|
||||
return false;
|
||||
@ -1020,7 +1039,7 @@ AndroidBridge::GetCurrentBatteryInformation(hal::BatteryInformation* aBatteryInf
|
||||
|
||||
// To prevent calling too many methods through JNI, the Java method returns
|
||||
// an array of double even if we actually want a double and a boolean.
|
||||
jdoubleArray arr = GeckoAppShell::GetCurrentBatteryInformationWrapper();
|
||||
jdoubleArray arr = GetCurrentBatteryInformationWrapper();
|
||||
if (!arr || env->GetArrayLength(arr) != 3) {
|
||||
return;
|
||||
}
|
||||
@ -1044,7 +1063,7 @@ AndroidBridge::HandleGeckoMessage(const nsAString &aMessage, nsAString &aRet)
|
||||
return;
|
||||
|
||||
AutoLocalJNIFrame jniFrame(env);
|
||||
jstring returnMessage = GeckoAppShell::HandleGeckoMessageWrapper(aMessage);
|
||||
jstring returnMessage = HandleGeckoMessageWrapper(aMessage);
|
||||
|
||||
if (!returnMessage)
|
||||
return;
|
||||
@ -1111,7 +1130,7 @@ AndroidBridge::SendMessage(const nsAString& aNumber,
|
||||
if (!QueueSmsRequest(aRequest, &requestId))
|
||||
return;
|
||||
|
||||
GeckoAppShell::SendMessageWrapper(aNumber, aMessage, requestId);
|
||||
SendMessageWrapper(aNumber, aMessage, requestId);
|
||||
}
|
||||
|
||||
void
|
||||
@ -1123,7 +1142,7 @@ AndroidBridge::GetMessage(int32_t aMessageId, nsIMobileMessageCallback* aRequest
|
||||
if (!QueueSmsRequest(aRequest, &requestId))
|
||||
return;
|
||||
|
||||
GeckoAppShell::GetMessageWrapper(aMessageId, requestId);
|
||||
GetMessageWrapper(aMessageId, requestId);
|
||||
}
|
||||
|
||||
void
|
||||
@ -1135,7 +1154,7 @@ AndroidBridge::DeleteMessage(int32_t aMessageId, nsIMobileMessageCallback* aRequ
|
||||
if (!QueueSmsRequest(aRequest, &requestId))
|
||||
return;
|
||||
|
||||
GeckoAppShell::DeleteMessageWrapper(aMessageId, requestId);
|
||||
DeleteMessageWrapper(aMessageId, requestId);
|
||||
}
|
||||
|
||||
void
|
||||
@ -1164,7 +1183,7 @@ AndroidBridge::CreateMessageList(const dom::mobilemessage::SmsFilterData& aFilte
|
||||
NewJavaString(&jniFrame, aFilter.numbers()[i]));
|
||||
}
|
||||
|
||||
GeckoAppShell::CreateMessageListWrapper(aFilter.startDate(), aFilter.endDate(),
|
||||
CreateMessageListWrapper(aFilter.startDate(), aFilter.endDate(),
|
||||
numbers, aFilter.numbers().Length(),
|
||||
aFilter.delivery(), aReverse, requestId);
|
||||
}
|
||||
@ -1178,7 +1197,7 @@ AndroidBridge::GetNextMessageInList(int32_t aListId, nsIMobileMessageCallback* a
|
||||
if (!QueueSmsRequest(aRequest, &requestId))
|
||||
return;
|
||||
|
||||
GeckoAppShell::GetNextMessageInListWrapper(aListId, requestId);
|
||||
GetNextMessageInListWrapper(aListId, requestId);
|
||||
}
|
||||
|
||||
bool
|
||||
@ -1230,7 +1249,7 @@ AndroidBridge::GetCurrentNetworkInformation(hal::NetworkInformation* aNetworkInf
|
||||
// To prevent calling too many methods through JNI, the Java method returns
|
||||
// an array of double even if we actually want a double, two booleans, and an integer.
|
||||
|
||||
jdoubleArray arr = GeckoAppShell::GetCurrentNetworkInformationWrapper();
|
||||
jdoubleArray arr = GetCurrentNetworkInformationWrapper();
|
||||
if (!arr || env->GetArrayLength(arr) != 4) {
|
||||
return;
|
||||
}
|
||||
@ -1423,7 +1442,7 @@ AndroidBridge::GetGlobalContextRef() {
|
||||
|
||||
AutoLocalJNIFrame jniFrame(env, 4);
|
||||
|
||||
jobject context = GeckoAppShell::GetContext();
|
||||
jobject context = GetContext();
|
||||
if (!context) {
|
||||
ALOG_BRIDGE("%s: Could not GetContext()", __FUNCTION__);
|
||||
return 0;
|
||||
@ -1474,22 +1493,21 @@ AndroidBridge::UnlockWindow(void* window)
|
||||
void
|
||||
AndroidBridge::SetFirstPaintViewport(const LayerIntPoint& aOffset, const CSSToLayerScale& aZoom, const CSSRect& aCssPageRect)
|
||||
{
|
||||
GeckoLayerClient *client = mLayerClient;
|
||||
AndroidGeckoLayerClient *client = mLayerClient;
|
||||
if (!client)
|
||||
return;
|
||||
|
||||
client->SetFirstPaintViewport((float)aOffset.x, (float)aOffset.y, aZoom.scale,
|
||||
aCssPageRect.x, aCssPageRect.y, aCssPageRect.XMost(), aCssPageRect.YMost());
|
||||
client->SetFirstPaintViewport(aOffset, aZoom, aCssPageRect);
|
||||
}
|
||||
|
||||
void
|
||||
AndroidBridge::SetPageRect(const CSSRect& aCssPageRect)
|
||||
{
|
||||
GeckoLayerClient *client = mLayerClient;
|
||||
AndroidGeckoLayerClient *client = mLayerClient;
|
||||
if (!client)
|
||||
return;
|
||||
|
||||
client->SetPageRect(aCssPageRect.x, aCssPageRect.y, aCssPageRect.XMost(), aCssPageRect.YMost());
|
||||
client->SetPageRect(aCssPageRect);
|
||||
}
|
||||
|
||||
void
|
||||
@ -1497,76 +1515,26 @@ AndroidBridge::SyncViewportInfo(const LayerIntRect& aDisplayPort, const CSSToLay
|
||||
bool aLayersUpdated, ScreenPoint& aScrollOffset, CSSToScreenScale& aScale,
|
||||
LayerMargin& aFixedLayerMargins, ScreenPoint& aOffset)
|
||||
{
|
||||
ALOG_BRIDGE("Enter: %s", __PRETTY_FUNCTION__);
|
||||
GeckoLayerClient *client = mLayerClient;
|
||||
if (!client) {
|
||||
ALOG_BRIDGE("Exceptional Exit: %s", __PRETTY_FUNCTION__);
|
||||
AndroidGeckoLayerClient *client = mLayerClient;
|
||||
if (!client)
|
||||
return;
|
||||
}
|
||||
|
||||
jobject viewTransformJObj = client->SyncViewportInfo(aDisplayPort.x, aDisplayPort.y,
|
||||
aDisplayPort.width, aDisplayPort.height,
|
||||
aDisplayResolution.scale, aLayersUpdated);
|
||||
|
||||
NS_ABORT_IF_FALSE(viewTransformJObj, "No view transform object!");
|
||||
if (!viewTransformJObj) {
|
||||
return;
|
||||
}
|
||||
|
||||
ViewTransform* viewTransform = ViewTransform::Wrap(viewTransformJObj);
|
||||
|
||||
aScrollOffset = ScreenPoint(viewTransform->getx(), viewTransform->gety());
|
||||
aScale.scale = viewTransform->getscale();
|
||||
|
||||
aFixedLayerMargins.top = viewTransform->getfixedLayerMarginTop();
|
||||
aFixedLayerMargins.right = viewTransform->getfixedLayerMarginRight();
|
||||
aFixedLayerMargins.bottom = viewTransform->getfixedLayerMarginBottom();
|
||||
aFixedLayerMargins.left = viewTransform->getfixedLayerMarginLeft();
|
||||
|
||||
aOffset.x = viewTransform->getoffsetX();
|
||||
aOffset.y = viewTransform->getoffsetY();
|
||||
|
||||
delete viewTransform;
|
||||
ALOG_BRIDGE("Exit: %s", __PRETTY_FUNCTION__);
|
||||
client->SyncViewportInfo(aDisplayPort, aDisplayResolution, aLayersUpdated,
|
||||
aScrollOffset, aScale, aFixedLayerMargins,
|
||||
aOffset);
|
||||
}
|
||||
|
||||
void AndroidBridge::SyncFrameMetrics(const ScreenPoint& aScrollOffset, float aZoom, const CSSRect& aCssPageRect,
|
||||
bool aLayersUpdated, const CSSRect& aDisplayPort, const CSSToLayerScale& aDisplayResolution,
|
||||
bool aIsFirstPaint, LayerMargin& aFixedLayerMargins, ScreenPoint& aOffset)
|
||||
{
|
||||
ALOG_BRIDGE("Enter: %s", __PRETTY_FUNCTION__);
|
||||
GeckoLayerClient *client = mLayerClient;
|
||||
if (!client) {
|
||||
ALOG_BRIDGE("Exceptional Exit: %s", __PRETTY_FUNCTION__);
|
||||
AndroidGeckoLayerClient *client = mLayerClient;
|
||||
if (!client)
|
||||
return;
|
||||
}
|
||||
|
||||
// convert the displayport rect from scroll-relative CSS pixels to document-relative device pixels
|
||||
LayerRect dpUnrounded = aDisplayPort * aDisplayResolution;
|
||||
dpUnrounded += LayerPoint::FromUnknownPoint(aScrollOffset.ToUnknownPoint());
|
||||
LayerIntRect dp = gfx::RoundedToInt(dpUnrounded);
|
||||
|
||||
jobject viewTransformJObj = client->SyncFrameMetrics(aScrollOffset.x, aScrollOffset.y, aZoom,
|
||||
aCssPageRect.x, aCssPageRect.y, aCssPageRect.XMost(), aCssPageRect.YMost(),
|
||||
aLayersUpdated, dp.x, dp.y, dp.width, dp.height, aDisplayResolution.scale,
|
||||
aIsFirstPaint);
|
||||
|
||||
NS_ABORT_IF_FALSE(viewTransformJObj, "No view transform object!");
|
||||
if (!viewTransformJObj) {
|
||||
return;
|
||||
}
|
||||
ViewTransform* viewTransform = ViewTransform::Wrap(viewTransformJObj);
|
||||
|
||||
aFixedLayerMargins.top = viewTransform->getfixedLayerMarginTop();
|
||||
aFixedLayerMargins.right = viewTransform->getfixedLayerMarginRight();
|
||||
aFixedLayerMargins.bottom = viewTransform->getfixedLayerMarginBottom();
|
||||
aFixedLayerMargins.left = viewTransform->getfixedLayerMarginLeft();
|
||||
|
||||
aOffset.x = viewTransform->getoffsetX();
|
||||
aOffset.y = viewTransform->getoffsetY();
|
||||
|
||||
delete viewTransform;
|
||||
ALOG_BRIDGE("Exit: %s", __PRETTY_FUNCTION__);
|
||||
client->SyncFrameMetrics(aScrollOffset, aZoom, aCssPageRect,
|
||||
aLayersUpdated, aDisplayPort, aDisplayResolution,
|
||||
aIsFirstPaint, aFixedLayerMargins, aOffset);
|
||||
}
|
||||
|
||||
AndroidBridge::AndroidBridge()
|
||||
@ -1631,12 +1599,45 @@ JavaThreadDetachFunc(void *arg)
|
||||
vm->DetachCurrentThread();
|
||||
}
|
||||
|
||||
extern "C" {
|
||||
__attribute__ ((visibility("default")))
|
||||
JNIEnv * GetJNIForThread()
|
||||
{
|
||||
JNIEnv *jEnv = NULL;
|
||||
JavaVM *jVm = mozilla::AndroidBridge::GetVM();
|
||||
if (!jVm) {
|
||||
__android_log_print(ANDROID_LOG_INFO, "GetJNIForThread", "Returned a null VM");
|
||||
return NULL;
|
||||
}
|
||||
jEnv = static_cast<JNIEnv*>(PR_GetThreadPrivate(sJavaEnvThreadIndex));
|
||||
|
||||
if (jEnv)
|
||||
return jEnv;
|
||||
|
||||
int status = jVm->GetEnv((void**) &jEnv, JNI_VERSION_1_2);
|
||||
if (status) {
|
||||
|
||||
status = jVm->AttachCurrentThread(&jEnv, NULL);
|
||||
if (status) {
|
||||
__android_log_print(ANDROID_LOG_INFO, "GetJNIForThread", "Could not attach");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
PR_SetThreadPrivate(sJavaEnvThreadIndex, jEnv);
|
||||
}
|
||||
if (!jEnv) {
|
||||
__android_log_print(ANDROID_LOG_INFO, "GetJNIForThread", "returning NULL");
|
||||
}
|
||||
return jEnv;
|
||||
}
|
||||
}
|
||||
|
||||
uint32_t
|
||||
AndroidBridge::GetScreenOrientation()
|
||||
{
|
||||
ALOG_BRIDGE("AndroidBridge::GetScreenOrientation");
|
||||
|
||||
int16_t orientation = GeckoAppShell::GetScreenOrientationWrapper();
|
||||
int16_t orientation = GetScreenOrientationWrapper();
|
||||
|
||||
if (!orientation)
|
||||
return dom::eScreenOrientation_None;
|
||||
@ -1660,7 +1661,7 @@ AndroidBridge::GetGfxInfoData(nsACString& aRet)
|
||||
return;
|
||||
|
||||
AutoLocalJNIFrame jniFrame(env);
|
||||
jstring jstrRet = GeckoAppShell::GetGfxInfoDataWrapper();
|
||||
jstring jstrRet = GetGfxInfoDataWrapper();
|
||||
|
||||
if (!jstrRet)
|
||||
return;
|
||||
@ -1681,7 +1682,7 @@ AndroidBridge::GetProxyForURI(const nsACString & aSpec,
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
AutoLocalJNIFrame jniFrame(env);
|
||||
jstring jstrRet = GeckoAppShell::GetProxyForURIWrapper(NS_ConvertUTF8toUTF16(aSpec),
|
||||
jstring jstrRet = GetProxyForURIWrapper(NS_ConvertUTF8toUTF16(aSpec),
|
||||
NS_ConvertUTF8toUTF16(aScheme),
|
||||
NS_ConvertUTF8toUTF16(aHost),
|
||||
aPort);
|
||||
@ -1717,7 +1718,7 @@ AndroidBridge::AddPluginView(jobject view, const LayoutDeviceRect& rect, bool is
|
||||
return;
|
||||
|
||||
CSSRect cssRect = rect / win->GetDefaultScale();
|
||||
GeckoAppShell::AddPluginViewWrapper(view, cssRect.x, cssRect.y, cssRect.width, cssRect.height, isFullScreen);
|
||||
AddPluginViewWrapper(view, cssRect.x, cssRect.y, cssRect.width, cssRect.height, isFullScreen);
|
||||
}
|
||||
|
||||
extern "C"
|
||||
@ -1734,7 +1735,7 @@ AndroidBridge::GetThreadNameJavaProfiling(uint32_t aThreadId, nsCString & aResul
|
||||
|
||||
AutoLocalJNIFrame jniFrame(env);
|
||||
|
||||
jstring jstrThreadName = GeckoJavaSampler::GetThreadNameJavaProfilingWrapper(aThreadId);
|
||||
jstring jstrThreadName = GetThreadNameJavaProfilingWrapper(aThreadId);
|
||||
|
||||
if (!jstrThreadName)
|
||||
return false;
|
||||
@ -1754,7 +1755,7 @@ AndroidBridge::GetFrameNameJavaProfiling(uint32_t aThreadId, uint32_t aSampleId,
|
||||
|
||||
AutoLocalJNIFrame jniFrame(env);
|
||||
|
||||
jstring jstrSampleName = GeckoJavaSampler::GetFrameNameJavaProfilingWrapper(aThreadId, aSampleId, aFrameId);
|
||||
jstring jstrSampleName = GetFrameNameJavaProfilingWrapper(aThreadId, aSampleId, aFrameId);
|
||||
|
||||
if (!jstrSampleName)
|
||||
return false;
|
||||
@ -1862,72 +1863,21 @@ nsresult AndroidBridge::CaptureThumbnail(nsIDOMWindow *window, int32_t bufW, int
|
||||
void
|
||||
AndroidBridge::GetDisplayPort(bool aPageSizeUpdate, bool aIsBrowserContentDisplayed, int32_t tabId, nsIAndroidViewport* metrics, nsIAndroidDisplayport** displayPort)
|
||||
{
|
||||
|
||||
ALOG_BRIDGE("Enter: %s", __PRETTY_FUNCTION__);
|
||||
JNIEnv* env = GetJNIEnv();
|
||||
if (!env || !mLayerClient || mLayerClient->isNull()) {
|
||||
|
||||
ALOG_BRIDGE("Exceptional Exit: %s", __PRETTY_FUNCTION__);
|
||||
if (!env || !mLayerClient)
|
||||
return;
|
||||
}
|
||||
AutoLocalJNIFrame jniFrame(env, 0);
|
||||
|
||||
float x, y, width, height,
|
||||
pageLeft, pageTop, pageRight, pageBottom,
|
||||
cssPageLeft, cssPageTop, cssPageRight, cssPageBottom,
|
||||
zoom;
|
||||
metrics->GetX(&x);
|
||||
metrics->GetY(&y);
|
||||
metrics->GetWidth(&width);
|
||||
metrics->GetHeight(&height);
|
||||
metrics->GetPageLeft(&pageLeft);
|
||||
metrics->GetPageTop(&pageTop);
|
||||
metrics->GetPageRight(&pageRight);
|
||||
metrics->GetPageBottom(&pageBottom);
|
||||
metrics->GetCssPageLeft(&cssPageLeft);
|
||||
metrics->GetCssPageTop(&cssPageTop);
|
||||
metrics->GetCssPageRight(&cssPageRight);
|
||||
metrics->GetCssPageBottom(&cssPageBottom);
|
||||
metrics->GetZoom(&zoom);
|
||||
|
||||
ImmutableViewportMetrics jmetrics = ImmutableViewportMetrics(pageLeft, pageTop, pageRight, pageBottom,
|
||||
cssPageLeft, cssPageTop, cssPageRight, cssPageBottom,
|
||||
x, y, x + width, y + height,
|
||||
zoom);
|
||||
|
||||
jobject jobj = mLayerClient->GetDisplayPort(aPageSizeUpdate, aIsBrowserContentDisplayed, tabId, jmetrics.wrappedObject());
|
||||
if (!jobj) {
|
||||
ALOG_BRIDGE("Exceptional Exit: %s", __PRETTY_FUNCTION__);
|
||||
return;
|
||||
}
|
||||
DisplayPortMetrics* displayPortMetrics = DisplayPortMetrics::Wrap(jobj);
|
||||
|
||||
AndroidRectF rect(env, displayPortMetrics->getMPosition());
|
||||
if (jniFrame.CheckForException()) {
|
||||
ALOG_BRIDGE("Exceptional Exit: %s", __PRETTY_FUNCTION__);
|
||||
return;
|
||||
}
|
||||
|
||||
float resolution = displayPortMetrics->getResolution();
|
||||
if (jniFrame.CheckForException()) {
|
||||
ALOG_BRIDGE("Exceptional Exit: %s", __PRETTY_FUNCTION__);
|
||||
return;
|
||||
}
|
||||
|
||||
*displayPort = new nsAndroidDisplayport(rect, resolution);
|
||||
(*displayPort)->AddRef();
|
||||
|
||||
delete displayPortMetrics;
|
||||
ALOG_BRIDGE("Exit: %s", __PRETTY_FUNCTION__);
|
||||
mLayerClient->GetDisplayPort(&jniFrame, aPageSizeUpdate, aIsBrowserContentDisplayed, tabId, metrics, displayPort);
|
||||
}
|
||||
|
||||
void
|
||||
AndroidBridge::ContentDocumentChanged()
|
||||
{
|
||||
if (!mLayerClient) {
|
||||
JNIEnv* env = GetJNIEnv();
|
||||
if (!env || !mLayerClient)
|
||||
return;
|
||||
}
|
||||
mLayerClient->ContentDocumentChanged();
|
||||
AutoLocalJNIFrame jniFrame(env, 0);
|
||||
mLayerClient->ContentDocumentChanged(&jniFrame);
|
||||
}
|
||||
|
||||
bool
|
||||
@ -1936,48 +1886,25 @@ AndroidBridge::IsContentDocumentDisplayed()
|
||||
JNIEnv* env = GetJNIEnv();
|
||||
if (!env || !mLayerClient)
|
||||
return false;
|
||||
|
||||
return mLayerClient->IsContentDocumentDisplayed();
|
||||
AutoLocalJNIFrame jniFrame(env, 0);
|
||||
return mLayerClient->IsContentDocumentDisplayed(&jniFrame);
|
||||
}
|
||||
|
||||
bool
|
||||
AndroidBridge::ProgressiveUpdateCallback(bool aHasPendingNewThebesContent, const LayerRect& aDisplayPort, float aDisplayResolution, bool aDrawingCritical, gfx::Rect& aViewport, float& aScaleX, float& aScaleY)
|
||||
{
|
||||
GeckoLayerClient *client = mLayerClient;
|
||||
if (!client) {
|
||||
ALOG_BRIDGE("Exceptional Exit: %s", __PRETTY_FUNCTION__);
|
||||
AndroidGeckoLayerClient *client = mLayerClient;
|
||||
if (!client)
|
||||
return false;
|
||||
}
|
||||
|
||||
jobject progressiveUpdateDataJObj = client->ProgressiveUpdateCallback(aHasPendingNewThebesContent,
|
||||
(float)aDisplayPort.x,
|
||||
(float)aDisplayPort.y,
|
||||
(float)aDisplayPort.width,
|
||||
(float)aDisplayPort.height,
|
||||
aDisplayResolution,
|
||||
!aDrawingCritical);
|
||||
|
||||
NS_ABORT_IF_FALSE(progressiveUpdateDataJObj, "No progressive update data!");
|
||||
|
||||
ProgressiveUpdateData* progressiveUpdateData = ProgressiveUpdateData::Wrap(progressiveUpdateDataJObj);
|
||||
|
||||
aViewport.x = progressiveUpdateData->getx();
|
||||
aViewport.y = progressiveUpdateData->gety();
|
||||
aViewport.width = progressiveUpdateData->getwidth();
|
||||
aViewport.height = progressiveUpdateData->getheight();
|
||||
aScaleX = aScaleY = progressiveUpdateData->getscale();
|
||||
|
||||
bool ret = progressiveUpdateData->getabort();
|
||||
delete progressiveUpdateData;
|
||||
|
||||
return ret;
|
||||
return client->ProgressiveUpdateCallback(aHasPendingNewThebesContent, aDisplayPort, aDisplayResolution, aDrawingCritical, aViewport, aScaleX, aScaleY);
|
||||
}
|
||||
|
||||
NativePanZoomController*
|
||||
jobject
|
||||
AndroidBridge::SetNativePanZoomController(jobject obj)
|
||||
{
|
||||
NativePanZoomController* old = mNativePanZoomController;
|
||||
mNativePanZoomController = NativePanZoomController::Wrap(obj);
|
||||
jobject old = mNativePanZoomController;
|
||||
mNativePanZoomController = obj;
|
||||
return old;
|
||||
}
|
||||
|
||||
@ -1989,7 +1916,8 @@ AndroidBridge::RequestContentRepaint(const mozilla::layers::FrameMetrics& aFrame
|
||||
CSSToScreenScale resolution = aFrameMetrics.mZoom;
|
||||
ScreenRect dp = (aFrameMetrics.mDisplayPort + aFrameMetrics.mScrollOffset) * resolution;
|
||||
|
||||
mNativePanZoomController->RequestContentRepaintWrapper(dp.x, dp.y, dp.width, dp.height, resolution.scale);
|
||||
RequestContentRepaintWrapper(mNativePanZoomController,
|
||||
dp.x, dp.y, dp.width, dp.height, resolution.scale);
|
||||
}
|
||||
|
||||
void
|
||||
@ -2046,7 +1974,7 @@ AndroidBridge::PostDelayedTask(Task* aTask, int aDelayMs)
|
||||
// if we're inserting it at the head of the queue, notify Java because
|
||||
// we need to get a callback at an earlier time than the last scheduled
|
||||
// callback
|
||||
mNativePanZoomController->PostDelayedCallbackWrapper((int64_t)aDelayMs);
|
||||
PostDelayedCallbackWrapper(mNativePanZoomController, (int64_t)aDelayMs);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -14,7 +14,7 @@
|
||||
#include "nsCOMPtr.h"
|
||||
#include "nsCOMArray.h"
|
||||
|
||||
#include "GeneratedJNIWrappers.h"
|
||||
#include "AndroidJavaWrappers.h"
|
||||
|
||||
#include "nsIMutableArray.h"
|
||||
#include "nsIMIMEInfo.h"
|
||||
@ -41,6 +41,7 @@ class nsIObserver;
|
||||
extern "C" JNIEnv * GetJNIForThread();
|
||||
|
||||
extern bool mozilla_AndroidBridge_SetMainThread(pthread_t);
|
||||
extern jclass GetGeckoAppShellClass();
|
||||
|
||||
namespace base {
|
||||
class Thread;
|
||||
@ -48,8 +49,6 @@ class Thread;
|
||||
|
||||
typedef void* EGLSurface;
|
||||
|
||||
using namespace mozilla::widget::android;
|
||||
|
||||
namespace mozilla {
|
||||
|
||||
namespace hal {
|
||||
@ -161,6 +160,10 @@ public:
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
static jclass GetGeckoAppShellClass() {
|
||||
return sBridge->mGeckoAppShellClass;
|
||||
}
|
||||
|
||||
// The bridge needs to be constructed via ConstructBridge first,
|
||||
// and then once the Gecko main thread is spun up (Gecko side),
|
||||
// SetMainThread should be called which will create the JNIEnv for
|
||||
@ -180,7 +183,7 @@ public:
|
||||
bool ProgressiveUpdateCallback(bool aHasPendingNewThebesContent, const LayerRect& aDisplayPort, float aDisplayResolution, bool aDrawingCritical, gfx::Rect& aViewport, float& aScaleX, float& aScaleY);
|
||||
|
||||
void SetLayerClient(JNIEnv* env, jobject jobj);
|
||||
GeckoLayerClient* GetLayerClient() { return mLayerClient; }
|
||||
AndroidGeckoLayerClient &GetLayerClient() { return *mLayerClient; }
|
||||
|
||||
bool GetHandlersForURL(const nsAString& aURL,
|
||||
nsIMutableArray* handlersArray = nullptr,
|
||||
@ -196,6 +199,10 @@ public:
|
||||
void GetExtensionFromMimeType(const nsACString& aMimeType, nsACString& aFileExt);
|
||||
|
||||
bool GetClipboardText(nsAString& aText);
|
||||
|
||||
void EmptyClipboard();
|
||||
|
||||
bool ClipboardHasText();
|
||||
|
||||
void ShowAlertNotification(const nsAString& aImageUrl,
|
||||
const nsAString& aAlertTitle,
|
||||
@ -213,6 +220,8 @@ public:
|
||||
|
||||
void Vibrate(const nsTArray<uint32_t>& aPattern);
|
||||
|
||||
void HideProgressDialogOnce();
|
||||
|
||||
void GetSystemColors(AndroidSystemColors *aColors);
|
||||
|
||||
void GetIconForExtension(const nsACString& aFileExt, uint32_t aIconSize, uint8_t * const aBuf);
|
||||
@ -332,7 +341,7 @@ protected:
|
||||
JNIEnv *mJNIEnv;
|
||||
pthread_t mThread;
|
||||
|
||||
GeckoLayerClient *mLayerClient = NULL;
|
||||
AndroidGeckoLayerClient *mLayerClient;
|
||||
|
||||
// the android.telephony.SmsMessage class
|
||||
jclass mAndroidSmsMessageClass;
|
||||
@ -373,7 +382,7 @@ protected:
|
||||
jclass jLayerView;
|
||||
|
||||
jfieldID jEGLSurfacePointerField;
|
||||
GLController *mGLControllerObj;
|
||||
jobject mGLControllerObj;
|
||||
|
||||
// some convinient types to have around
|
||||
jclass jStringClass;
|
||||
@ -397,14 +406,15 @@ protected:
|
||||
void (* Region_set)(void* region, void* rect);
|
||||
|
||||
private:
|
||||
NativePanZoomController* mNativePanZoomController;
|
||||
jobject mNativePanZoomController;
|
||||
// This will always be accessed from one thread (the APZC "controller"
|
||||
// thread, which is the Java UI thread), so we don't need to do locking
|
||||
// to touch it
|
||||
nsTArray<DelayedTask*> mDelayedTaskQueue;
|
||||
|
||||
public:
|
||||
NativePanZoomController* SetNativePanZoomController(jobject obj);
|
||||
#include "GeneratedJNIWrappers.h"
|
||||
jobject SetNativePanZoomController(jobject obj);
|
||||
// GeckoContentController methods
|
||||
void RequestContentRepaint(const mozilla::layers::FrameMetrics& aFrameMetrics) MOZ_OVERRIDE;
|
||||
void HandleDoubleTap(const CSSIntPoint& aPoint) MOZ_OVERRIDE;
|
||||
|
@ -17,17 +17,3 @@
|
||||
|
||||
#define getStaticMethod(fname, ftype) \
|
||||
AndroidBridge::GetStaticMethodID(jEnv, jClass, fname, ftype)
|
||||
|
||||
#ifndef ALOG
|
||||
#if defined(DEBUG) || defined(FORCE_ALOG)
|
||||
#define ALOG(args...) __android_log_print(ANDROID_LOG_INFO, "Gecko" , ## args)
|
||||
#else
|
||||
#define ALOG(args...) ((void)0)
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifdef DEBUG
|
||||
#define ALOG_BRIDGE(args...) ALOG(args)
|
||||
#else
|
||||
#define ALOG_BRIDGE(args...) ((void)0)
|
||||
#endif
|
||||
|
@ -861,10 +861,10 @@ Java_org_mozilla_gecko_gfx_NativePanZoomController_init(JNIEnv* env, jobject ins
|
||||
return;
|
||||
}
|
||||
|
||||
NativePanZoomController* oldRef = AndroidBridge::Bridge()->SetNativePanZoomController(instance);
|
||||
if (oldRef && !oldRef->isNull()) {
|
||||
jobject oldRef = AndroidBridge::Bridge()->SetNativePanZoomController(env->NewGlobalRef(instance));
|
||||
if (oldRef) {
|
||||
MOZ_ASSERT(false, "Registering a new NPZC when we already have one");
|
||||
delete oldRef;
|
||||
env->DeleteGlobalRef(oldRef);
|
||||
}
|
||||
}
|
||||
|
||||
@ -905,11 +905,11 @@ Java_org_mozilla_gecko_gfx_NativePanZoomController_destroy(JNIEnv* env, jobject
|
||||
return;
|
||||
}
|
||||
|
||||
NativePanZoomController* oldRef = AndroidBridge::Bridge()->SetNativePanZoomController(NULL);
|
||||
if (!oldRef || oldRef->isNull()) {
|
||||
jobject oldRef = AndroidBridge::Bridge()->SetNativePanZoomController(NULL);
|
||||
if (!oldRef) {
|
||||
MOZ_ASSERT(false, "Clearing a non-existent NPZC");
|
||||
} else {
|
||||
delete oldRef;
|
||||
env->DeleteGlobalRef(oldRef);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -14,6 +14,12 @@
|
||||
#include "nsThreadUtils.h"
|
||||
#include "AndroidBridge.h"
|
||||
|
||||
#ifdef DEBUG
|
||||
#define ALOG_BRIDGE(args...) ALOG(args)
|
||||
#else
|
||||
#define ALOG_BRIDGE(args...)
|
||||
#endif
|
||||
|
||||
extern "C" {
|
||||
jclass __jsjni_GetGlobalClassRef(const char *className);
|
||||
}
|
||||
|
@ -6,13 +6,13 @@
|
||||
#include "AndroidJavaWrappers.h"
|
||||
#include "AndroidBridge.h"
|
||||
#include "AndroidBridgeUtilities.h"
|
||||
#include "nsIAndroidBridge.h"
|
||||
#include "nsIDOMKeyEvent.h"
|
||||
#include "nsIWidget.h"
|
||||
#include "mozilla/TouchEvents.h"
|
||||
|
||||
using namespace mozilla;
|
||||
using namespace mozilla::dom;
|
||||
using namespace mozilla::widget::android;
|
||||
|
||||
jclass AndroidGeckoEvent::jGeckoEventClass = 0;
|
||||
jfieldID AndroidGeckoEvent::jActionField = 0;
|
||||
@ -91,6 +91,49 @@ jmethodID AndroidLocation::jGetBearingMethod = 0;
|
||||
jmethodID AndroidLocation::jGetSpeedMethod = 0;
|
||||
jmethodID AndroidLocation::jGetTimeMethod = 0;
|
||||
|
||||
jclass AndroidGeckoLayerClient::jGeckoLayerClientClass = 0;
|
||||
jclass AndroidGeckoLayerClient::jViewportClass = 0;
|
||||
jclass AndroidGeckoLayerClient::jDisplayportClass = 0;
|
||||
jmethodID AndroidGeckoLayerClient::jSetFirstPaintViewport = 0;
|
||||
jmethodID AndroidGeckoLayerClient::jSetPageRect = 0;
|
||||
jmethodID AndroidGeckoLayerClient::jSyncViewportInfoMethod = 0;
|
||||
jmethodID AndroidGeckoLayerClient::jSyncFrameMetricsMethod = 0;
|
||||
jmethodID AndroidGeckoLayerClient::jCreateFrameMethod = 0;
|
||||
jmethodID AndroidGeckoLayerClient::jActivateProgramMethod = 0;
|
||||
jmethodID AndroidGeckoLayerClient::jDeactivateProgramMethod = 0;
|
||||
jmethodID AndroidGeckoLayerClient::jGetDisplayPort = 0;
|
||||
jmethodID AndroidGeckoLayerClient::jContentDocumentChanged = 0;
|
||||
jmethodID AndroidGeckoLayerClient::jIsContentDocumentDisplayed = 0;
|
||||
jmethodID AndroidGeckoLayerClient::jViewportCtor = 0;
|
||||
jfieldID AndroidGeckoLayerClient::jDisplayportPosition = 0;
|
||||
jfieldID AndroidGeckoLayerClient::jDisplayportResolution = 0;
|
||||
jmethodID AndroidGeckoLayerClient::jProgressiveUpdateCallbackMethod = 0;
|
||||
|
||||
jclass AndroidLayerRendererFrame::jLayerRendererFrameClass = 0;
|
||||
jmethodID AndroidLayerRendererFrame::jBeginDrawingMethod = 0;
|
||||
jmethodID AndroidLayerRendererFrame::jDrawBackgroundMethod = 0;
|
||||
jmethodID AndroidLayerRendererFrame::jDrawForegroundMethod = 0;
|
||||
jmethodID AndroidLayerRendererFrame::jEndDrawingMethod = 0;
|
||||
|
||||
jclass AndroidViewTransform::jViewTransformClass = 0;
|
||||
jfieldID AndroidViewTransform::jXField = 0;
|
||||
jfieldID AndroidViewTransform::jYField = 0;
|
||||
jfieldID AndroidViewTransform::jScaleField = 0;
|
||||
jfieldID AndroidViewTransform::jFixedLayerMarginLeft = 0;
|
||||
jfieldID AndroidViewTransform::jFixedLayerMarginTop = 0;
|
||||
jfieldID AndroidViewTransform::jFixedLayerMarginRight = 0;
|
||||
jfieldID AndroidViewTransform::jFixedLayerMarginBottom = 0;
|
||||
jfieldID AndroidViewTransform::jOffsetXField = 0;
|
||||
jfieldID AndroidViewTransform::jOffsetYField = 0;
|
||||
|
||||
jclass AndroidProgressiveUpdateData::jProgressiveUpdateDataClass = 0;
|
||||
jfieldID AndroidProgressiveUpdateData::jXField = 0;
|
||||
jfieldID AndroidProgressiveUpdateData::jYField = 0;
|
||||
jfieldID AndroidProgressiveUpdateData::jWidthField = 0;
|
||||
jfieldID AndroidProgressiveUpdateData::jHeightField = 0;
|
||||
jfieldID AndroidProgressiveUpdateData::jScaleField = 0;
|
||||
jfieldID AndroidProgressiveUpdateData::jShouldAbortField = 0;
|
||||
|
||||
RefCountedJavaObject::~RefCountedJavaObject() {
|
||||
if (mObject)
|
||||
GetJNIForThread()->DeleteGlobalRef(mObject);
|
||||
@ -105,7 +148,10 @@ mozilla::InitAndroidJavaWrappers(JNIEnv *jEnv)
|
||||
AndroidLocation::InitLocationClass(jEnv);
|
||||
AndroidRect::InitRectClass(jEnv);
|
||||
AndroidRectF::InitRectFClass(jEnv);
|
||||
InitStubs(jEnv);
|
||||
AndroidGeckoLayerClient::InitGeckoLayerClientClass(jEnv);
|
||||
AndroidLayerRendererFrame::InitLayerRendererFrameClass(jEnv);
|
||||
AndroidViewTransform::InitViewTransformClass(jEnv);
|
||||
AndroidProgressiveUpdateData::InitProgressiveUpdateDataClass(jEnv);
|
||||
}
|
||||
|
||||
void
|
||||
@ -244,6 +290,82 @@ AndroidRectF::InitRectFClass(JNIEnv *jEnv)
|
||||
jRightField = getField("right", "F");
|
||||
}
|
||||
|
||||
void
|
||||
AndroidGeckoLayerClient::InitGeckoLayerClientClass(JNIEnv *jEnv)
|
||||
{
|
||||
initInit();
|
||||
|
||||
jGeckoLayerClientClass = getClassGlobalRef("org/mozilla/gecko/gfx/GeckoLayerClient");
|
||||
|
||||
jProgressiveUpdateCallbackMethod = getMethod("progressiveUpdateCallback",
|
||||
"(ZFFFFFZ)Lorg/mozilla/gecko/gfx/ProgressiveUpdateData;");
|
||||
jSetFirstPaintViewport = getMethod("setFirstPaintViewport", "(FFFFFFF)V");
|
||||
jSetPageRect = getMethod("setPageRect", "(FFFF)V");
|
||||
jSyncViewportInfoMethod = getMethod("syncViewportInfo",
|
||||
"(IIIIFZ)Lorg/mozilla/gecko/gfx/ViewTransform;");
|
||||
jSyncFrameMetricsMethod = getMethod("syncFrameMetrics",
|
||||
"(FFFFFFFZIIIIFZ)Lorg/mozilla/gecko/gfx/ViewTransform;");
|
||||
jCreateFrameMethod = getMethod("createFrame", "()Lorg/mozilla/gecko/gfx/LayerRenderer$Frame;");
|
||||
jActivateProgramMethod = getMethod("activateProgram", "()V");
|
||||
jDeactivateProgramMethod = getMethod("deactivateProgram", "()V");
|
||||
jGetDisplayPort = getMethod("getDisplayPort", "(ZZILorg/mozilla/gecko/gfx/ImmutableViewportMetrics;)Lorg/mozilla/gecko/gfx/DisplayPortMetrics;");
|
||||
jContentDocumentChanged = getMethod("contentDocumentChanged", "()V");
|
||||
jIsContentDocumentDisplayed = getMethod("isContentDocumentDisplayed", "()Z");
|
||||
|
||||
jViewportClass = getClassGlobalRef("org/mozilla/gecko/gfx/ImmutableViewportMetrics");
|
||||
jViewportCtor = getMethod("<init>", "(FFFFFFFFFFFFF)V");
|
||||
|
||||
jDisplayportClass = getClassGlobalRef("org/mozilla/gecko/gfx/DisplayPortMetrics");
|
||||
jDisplayportPosition = getField("mPosition", "Landroid/graphics/RectF;");
|
||||
jDisplayportResolution = getField("resolution", "F");
|
||||
}
|
||||
|
||||
void
|
||||
AndroidLayerRendererFrame::InitLayerRendererFrameClass(JNIEnv *jEnv)
|
||||
{
|
||||
initInit();
|
||||
|
||||
jLayerRendererFrameClass = getClassGlobalRef("org/mozilla/gecko/gfx/LayerRenderer$Frame");
|
||||
|
||||
jBeginDrawingMethod = getMethod("beginDrawing", "()V");
|
||||
jDrawBackgroundMethod = getMethod("drawBackground", "()V");
|
||||
jDrawForegroundMethod = getMethod("drawForeground", "()V");
|
||||
jEndDrawingMethod = getMethod("endDrawing", "()V");
|
||||
}
|
||||
|
||||
void
|
||||
AndroidViewTransform::InitViewTransformClass(JNIEnv *jEnv)
|
||||
{
|
||||
initInit();
|
||||
|
||||
jViewTransformClass = getClassGlobalRef("org/mozilla/gecko/gfx/ViewTransform");
|
||||
|
||||
jXField = getField("x", "F");
|
||||
jYField = getField("y", "F");
|
||||
jScaleField = getField("scale", "F");
|
||||
jFixedLayerMarginLeft = getField("fixedLayerMarginLeft", "F");
|
||||
jFixedLayerMarginTop = getField("fixedLayerMarginTop", "F");
|
||||
jFixedLayerMarginRight = getField("fixedLayerMarginRight", "F");
|
||||
jFixedLayerMarginBottom = getField("fixedLayerMarginBottom", "F");
|
||||
jOffsetXField = getField("offsetX", "F");
|
||||
jOffsetYField = getField("offsetY", "F");
|
||||
}
|
||||
|
||||
void
|
||||
AndroidProgressiveUpdateData::InitProgressiveUpdateDataClass(JNIEnv *jEnv)
|
||||
{
|
||||
initInit();
|
||||
|
||||
jProgressiveUpdateDataClass = getClassGlobalRef("org/mozilla/gecko/gfx/ProgressiveUpdateData");
|
||||
|
||||
jXField = getField("x", "F");
|
||||
jYField = getField("y", "F");
|
||||
jWidthField = getField("width", "F");
|
||||
jHeightField = getField("height", "F");
|
||||
jScaleField = getField("scale", "F");
|
||||
jShouldAbortField = getField("abort", "Z");
|
||||
}
|
||||
|
||||
#undef initInit
|
||||
#undef initClassGlobalRef
|
||||
#undef getField
|
||||
@ -723,8 +845,461 @@ AndroidPoint::Init(JNIEnv *jenv, jobject jobj)
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
AndroidGeckoLayerClient::Init(jobject jobj)
|
||||
{
|
||||
NS_ASSERTION(wrapped_obj == nullptr, "Init called on non-null wrapped_obj!");
|
||||
wrapped_obj = jobj;
|
||||
}
|
||||
|
||||
void
|
||||
AndroidLayerRendererFrame::Init(JNIEnv *env, jobject jobj)
|
||||
{
|
||||
if (!isNull()) {
|
||||
Dispose(env);
|
||||
}
|
||||
|
||||
wrapped_obj = env->NewGlobalRef(jobj);
|
||||
}
|
||||
|
||||
void
|
||||
AndroidLayerRendererFrame::Dispose(JNIEnv *env)
|
||||
{
|
||||
if (isNull()) {
|
||||
return;
|
||||
}
|
||||
|
||||
env->DeleteGlobalRef(wrapped_obj);
|
||||
wrapped_obj = 0;
|
||||
}
|
||||
|
||||
void
|
||||
AndroidViewTransform::Init(jobject jobj)
|
||||
{
|
||||
NS_ABORT_IF_FALSE(wrapped_obj == nullptr, "Init called on non-null wrapped_obj!");
|
||||
wrapped_obj = jobj;
|
||||
}
|
||||
|
||||
void
|
||||
AndroidProgressiveUpdateData::Init(jobject jobj)
|
||||
{
|
||||
NS_ABORT_IF_FALSE(wrapped_obj == nullptr, "Init called on non-null wrapped_obj!");
|
||||
wrapped_obj = jobj;
|
||||
}
|
||||
|
||||
void
|
||||
AndroidGeckoLayerClient::SetFirstPaintViewport(const LayerIntPoint& aOffset, const CSSToLayerScale& aZoom, const CSSRect& aCssPageRect)
|
||||
{
|
||||
NS_ASSERTION(!isNull(), "SetFirstPaintViewport called on null layer client!");
|
||||
JNIEnv *env = GetJNIForThread(); // this is called on the compositor thread
|
||||
if (!env)
|
||||
return;
|
||||
|
||||
AutoLocalJNIFrame jniFrame(env, 0);
|
||||
return env->CallVoidMethod(wrapped_obj, jSetFirstPaintViewport, (float)aOffset.x, (float)aOffset.y, aZoom.scale,
|
||||
aCssPageRect.x, aCssPageRect.y, aCssPageRect.XMost(), aCssPageRect.YMost());
|
||||
}
|
||||
|
||||
void
|
||||
AndroidGeckoLayerClient::SetPageRect(const CSSRect& aCssPageRect)
|
||||
{
|
||||
NS_ASSERTION(!isNull(), "SetPageRect called on null layer client!");
|
||||
JNIEnv *env = GetJNIForThread(); // this is called on the compositor thread
|
||||
if (!env)
|
||||
return;
|
||||
|
||||
AutoLocalJNIFrame jniFrame(env, 0);
|
||||
return env->CallVoidMethod(wrapped_obj, jSetPageRect,
|
||||
aCssPageRect.x, aCssPageRect.y, aCssPageRect.XMost(), aCssPageRect.YMost());
|
||||
}
|
||||
|
||||
void
|
||||
AndroidGeckoLayerClient::SyncViewportInfo(const LayerIntRect& aDisplayPort, const CSSToLayerScale& aDisplayResolution,
|
||||
bool aLayersUpdated, ScreenPoint& aScrollOffset, CSSToScreenScale& aScale,
|
||||
LayerMargin& aFixedLayerMargins, ScreenPoint& aOffset)
|
||||
{
|
||||
NS_ASSERTION(!isNull(), "SyncViewportInfo called on null layer client!");
|
||||
JNIEnv *env = GetJNIForThread(); // this is called on the compositor thread
|
||||
if (!env)
|
||||
return;
|
||||
|
||||
AutoLocalJNIFrame jniFrame(env);
|
||||
|
||||
jobject viewTransformJObj = env->CallObjectMethod(wrapped_obj, jSyncViewportInfoMethod,
|
||||
aDisplayPort.x, aDisplayPort.y,
|
||||
aDisplayPort.width, aDisplayPort.height,
|
||||
aDisplayResolution.scale, aLayersUpdated);
|
||||
if (jniFrame.CheckForException())
|
||||
return;
|
||||
|
||||
NS_ABORT_IF_FALSE(viewTransformJObj, "No view transform object!");
|
||||
|
||||
AndroidViewTransform viewTransform;
|
||||
viewTransform.Init(viewTransformJObj);
|
||||
|
||||
aScrollOffset = ScreenPoint(viewTransform.GetX(env), viewTransform.GetY(env));
|
||||
aScale.scale = viewTransform.GetScale(env);
|
||||
viewTransform.GetFixedLayerMargins(env, aFixedLayerMargins);
|
||||
|
||||
aOffset.x = viewTransform.GetOffsetX(env);
|
||||
aOffset.y = viewTransform.GetOffsetY(env);
|
||||
}
|
||||
|
||||
void
|
||||
AndroidGeckoLayerClient::SyncFrameMetrics(const ScreenPoint& aScrollOffset, float aZoom, const CSSRect& aCssPageRect,
|
||||
bool aLayersUpdated, const CSSRect& aDisplayPort, const CSSToLayerScale& aDisplayResolution,
|
||||
bool aIsFirstPaint, LayerMargin& aFixedLayerMargins, ScreenPoint& aOffset)
|
||||
{
|
||||
NS_ASSERTION(!isNull(), "SyncFrameMetrics called on null layer client!");
|
||||
JNIEnv *env = GetJNIForThread(); // this is called on the compositor thread
|
||||
if (!env)
|
||||
return;
|
||||
|
||||
AutoLocalJNIFrame jniFrame(env);
|
||||
|
||||
// convert the displayport rect from scroll-relative CSS pixels to document-relative device pixels
|
||||
LayerRect dpUnrounded = aDisplayPort * aDisplayResolution;
|
||||
dpUnrounded += LayerPoint::FromUnknownPoint(aScrollOffset.ToUnknownPoint());
|
||||
LayerIntRect dp = gfx::RoundedToInt(dpUnrounded);
|
||||
|
||||
jobject viewTransformJObj = env->CallObjectMethod(wrapped_obj, jSyncFrameMetricsMethod,
|
||||
aScrollOffset.x, aScrollOffset.y, aZoom,
|
||||
aCssPageRect.x, aCssPageRect.y, aCssPageRect.XMost(), aCssPageRect.YMost(),
|
||||
aLayersUpdated, dp.x, dp.y, dp.width, dp.height, aDisplayResolution.scale,
|
||||
aIsFirstPaint);
|
||||
|
||||
if (jniFrame.CheckForException())
|
||||
return;
|
||||
|
||||
NS_ABORT_IF_FALSE(viewTransformJObj, "No view transform object!");
|
||||
|
||||
AndroidViewTransform viewTransform;
|
||||
viewTransform.Init(viewTransformJObj);
|
||||
viewTransform.GetFixedLayerMargins(env, aFixedLayerMargins);
|
||||
aOffset.x = viewTransform.GetOffsetX(env);
|
||||
aOffset.y = viewTransform.GetOffsetY(env);
|
||||
}
|
||||
|
||||
bool
|
||||
AndroidGeckoLayerClient::ProgressiveUpdateCallback(bool aHasPendingNewThebesContent,
|
||||
const LayerRect& aDisplayPort,
|
||||
float aDisplayResolution,
|
||||
bool aDrawingCritical,
|
||||
gfx::Rect& aViewport,
|
||||
float& aScaleX,
|
||||
float& aScaleY)
|
||||
{
|
||||
JNIEnv *env = AndroidBridge::GetJNIEnv();
|
||||
if (!env)
|
||||
return false;
|
||||
|
||||
AutoJObject progressiveUpdateDataJObj(env, env->CallObjectMethod(wrapped_obj,
|
||||
jProgressiveUpdateCallbackMethod,
|
||||
aHasPendingNewThebesContent,
|
||||
(float)aDisplayPort.x,
|
||||
(float)aDisplayPort.y,
|
||||
(float)aDisplayPort.width,
|
||||
(float)aDisplayPort.height,
|
||||
aDisplayResolution,
|
||||
!aDrawingCritical));
|
||||
if (env->ExceptionCheck()) {
|
||||
env->ExceptionDescribe();
|
||||
env->ExceptionClear();
|
||||
return false;
|
||||
}
|
||||
|
||||
NS_ABORT_IF_FALSE(progressiveUpdateDataJObj, "No progressive update data!");
|
||||
|
||||
AndroidProgressiveUpdateData progressiveUpdateData(progressiveUpdateDataJObj);
|
||||
|
||||
aViewport.x = progressiveUpdateData.GetX(env);
|
||||
aViewport.y = progressiveUpdateData.GetY(env);
|
||||
aViewport.width = progressiveUpdateData.GetWidth(env);
|
||||
aViewport.height = progressiveUpdateData.GetHeight(env);
|
||||
aScaleX = aScaleY = progressiveUpdateData.GetScale(env);
|
||||
|
||||
return progressiveUpdateData.GetShouldAbort(env);
|
||||
}
|
||||
|
||||
jobject ConvertToJavaViewportMetrics(JNIEnv* env, nsIAndroidViewport* metrics) {
|
||||
float x, y, width, height,
|
||||
pageLeft, pageTop, pageRight, pageBottom,
|
||||
cssPageLeft, cssPageTop, cssPageRight, cssPageBottom,
|
||||
zoom;
|
||||
metrics->GetX(&x);
|
||||
metrics->GetY(&y);
|
||||
metrics->GetWidth(&width);
|
||||
metrics->GetHeight(&height);
|
||||
metrics->GetPageLeft(&pageLeft);
|
||||
metrics->GetPageTop(&pageTop);
|
||||
metrics->GetPageRight(&pageRight);
|
||||
metrics->GetPageBottom(&pageBottom);
|
||||
metrics->GetCssPageLeft(&cssPageLeft);
|
||||
metrics->GetCssPageTop(&cssPageTop);
|
||||
metrics->GetCssPageRight(&cssPageRight);
|
||||
metrics->GetCssPageBottom(&cssPageBottom);
|
||||
metrics->GetZoom(&zoom);
|
||||
|
||||
jobject jobj = env->NewObject(AndroidGeckoLayerClient::jViewportClass, AndroidGeckoLayerClient::jViewportCtor,
|
||||
pageLeft, pageTop, pageRight, pageBottom,
|
||||
cssPageLeft, cssPageTop, cssPageRight, cssPageBottom,
|
||||
x, y, x + width, y + height,
|
||||
zoom);
|
||||
return jobj;
|
||||
}
|
||||
|
||||
class nsAndroidDisplayport MOZ_FINAL : public nsIAndroidDisplayport
|
||||
{
|
||||
public:
|
||||
NS_DECL_ISUPPORTS
|
||||
virtual nsresult GetLeft(float *aLeft) { *aLeft = mLeft; return NS_OK; }
|
||||
virtual nsresult GetTop(float *aTop) { *aTop = mTop; return NS_OK; }
|
||||
virtual nsresult GetRight(float *aRight) { *aRight = mRight; return NS_OK; }
|
||||
virtual nsresult GetBottom(float *aBottom) { *aBottom = mBottom; return NS_OK; }
|
||||
virtual nsresult GetResolution(float *aResolution) { *aResolution = mResolution; return NS_OK; }
|
||||
virtual nsresult SetLeft(float aLeft) { mLeft = aLeft; return NS_OK; }
|
||||
virtual nsresult SetTop(float aTop) { mTop = aTop; return NS_OK; }
|
||||
virtual nsresult SetRight(float aRight) { mRight = aRight; return NS_OK; }
|
||||
virtual nsresult SetBottom(float aBottom) { mBottom = aBottom; return NS_OK; }
|
||||
virtual nsresult SetResolution(float aResolution) { mResolution = aResolution; return NS_OK; }
|
||||
|
||||
nsAndroidDisplayport(AndroidRectF aRect, float aResolution):
|
||||
mLeft(aRect.Left()), mTop(aRect.Top()), mRight(aRect.Right()), mBottom(aRect.Bottom()), mResolution(aResolution) {}
|
||||
|
||||
private:
|
||||
~nsAndroidDisplayport() {}
|
||||
float mLeft, mTop, mRight, mBottom, mResolution;
|
||||
};
|
||||
|
||||
NS_IMPL_ISUPPORTS1(nsAndroidDisplayport, nsIAndroidDisplayport)
|
||||
|
||||
void createDisplayPort(AutoLocalJNIFrame *jniFrame, jobject jobj, nsIAndroidDisplayport** displayPort) {
|
||||
JNIEnv* env = jniFrame->GetEnv();
|
||||
AndroidRectF rect(env, env->GetObjectField(jobj, AndroidGeckoLayerClient::jDisplayportPosition));
|
||||
if (jniFrame->CheckForException()) return;
|
||||
float resolution = env->GetFloatField(jobj, AndroidGeckoLayerClient::jDisplayportResolution);
|
||||
if (jniFrame->CheckForException()) return;
|
||||
*displayPort = new nsAndroidDisplayport(rect, resolution);
|
||||
}
|
||||
|
||||
void
|
||||
AndroidGeckoLayerClient::GetDisplayPort(AutoLocalJNIFrame *jniFrame, bool aPageSizeUpdate, bool aIsBrowserContentDisplayed, int32_t tabId, nsIAndroidViewport* metrics, nsIAndroidDisplayport** displayPort)
|
||||
{
|
||||
jobject jmetrics = ConvertToJavaViewportMetrics(jniFrame->GetEnv(), metrics);
|
||||
if (jniFrame->CheckForException()) return;
|
||||
if (!jmetrics)
|
||||
return;
|
||||
jobject jobj = jniFrame->GetEnv()->CallObjectMethod(wrapped_obj, jGetDisplayPort, aPageSizeUpdate, aIsBrowserContentDisplayed, tabId, jmetrics);
|
||||
if (jniFrame->CheckForException()) return;
|
||||
createDisplayPort(jniFrame, jobj, displayPort);
|
||||
(*displayPort)->AddRef();
|
||||
}
|
||||
|
||||
void
|
||||
AndroidGeckoLayerClient::ContentDocumentChanged(AutoLocalJNIFrame *jniFrame)
|
||||
{
|
||||
jniFrame->GetEnv()->CallVoidMethod(wrapped_obj, jContentDocumentChanged);
|
||||
}
|
||||
|
||||
bool
|
||||
AndroidGeckoLayerClient::IsContentDocumentDisplayed(AutoLocalJNIFrame *jniFrame)
|
||||
{
|
||||
return jniFrame->GetEnv()->CallBooleanMethod(wrapped_obj, jIsContentDocumentDisplayed);
|
||||
}
|
||||
|
||||
bool
|
||||
AndroidGeckoLayerClient::CreateFrame(AutoLocalJNIFrame *jniFrame, AndroidLayerRendererFrame& aFrame)
|
||||
{
|
||||
if (!jniFrame || !jniFrame->GetEnv())
|
||||
return false;
|
||||
|
||||
jobject frameJObj = jniFrame->GetEnv()->CallObjectMethod(wrapped_obj, jCreateFrameMethod);
|
||||
if (jniFrame->CheckForException())
|
||||
return false;
|
||||
NS_ABORT_IF_FALSE(frameJObj, "No frame object!");
|
||||
|
||||
aFrame.Init(jniFrame->GetEnv(), frameJObj);
|
||||
return true;
|
||||
}
|
||||
|
||||
bool
|
||||
AndroidGeckoLayerClient::ActivateProgram(AutoLocalJNIFrame *jniFrame)
|
||||
{
|
||||
if (!jniFrame || !jniFrame->GetEnv())
|
||||
return false;
|
||||
|
||||
jniFrame->GetEnv()->CallVoidMethod(wrapped_obj, jActivateProgramMethod);
|
||||
if (jniFrame->CheckForException())
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool
|
||||
AndroidGeckoLayerClient::DeactivateProgram(AutoLocalJNIFrame *jniFrame)
|
||||
{
|
||||
if (!jniFrame || !jniFrame->GetEnv())
|
||||
return false;
|
||||
|
||||
jniFrame->GetEnv()->CallVoidMethod(wrapped_obj, jDeactivateProgramMethod);
|
||||
if (jniFrame->CheckForException())
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool
|
||||
AndroidLayerRendererFrame::BeginDrawing(AutoLocalJNIFrame *jniFrame)
|
||||
{
|
||||
if (!jniFrame || !jniFrame->GetEnv())
|
||||
return false;
|
||||
|
||||
jniFrame->GetEnv()->CallVoidMethod(wrapped_obj, jBeginDrawingMethod);
|
||||
if (jniFrame->CheckForException())
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool
|
||||
AndroidLayerRendererFrame::DrawBackground(AutoLocalJNIFrame *jniFrame)
|
||||
{
|
||||
if (!jniFrame || !jniFrame->GetEnv())
|
||||
return false;
|
||||
|
||||
jniFrame->GetEnv()->CallVoidMethod(wrapped_obj, jDrawBackgroundMethod);
|
||||
if (jniFrame->CheckForException())
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool
|
||||
AndroidLayerRendererFrame::DrawForeground(AutoLocalJNIFrame *jniFrame)
|
||||
{
|
||||
if (!jniFrame || !jniFrame->GetEnv())
|
||||
return false;
|
||||
|
||||
jniFrame->GetEnv()->CallVoidMethod(wrapped_obj, jDrawForegroundMethod);
|
||||
if (jniFrame->CheckForException())
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool
|
||||
AndroidLayerRendererFrame::EndDrawing(AutoLocalJNIFrame *jniFrame)
|
||||
{
|
||||
if (!jniFrame || !jniFrame->GetEnv())
|
||||
return false;
|
||||
|
||||
jniFrame->GetEnv()->CallVoidMethod(wrapped_obj, jEndDrawingMethod);
|
||||
if (jniFrame->CheckForException())
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
float
|
||||
AndroidViewTransform::GetX(JNIEnv *env)
|
||||
{
|
||||
if (!env)
|
||||
return 0.0f;
|
||||
return env->GetFloatField(wrapped_obj, jXField);
|
||||
}
|
||||
|
||||
float
|
||||
AndroidViewTransform::GetY(JNIEnv *env)
|
||||
{
|
||||
if (!env)
|
||||
return 0.0f;
|
||||
return env->GetFloatField(wrapped_obj, jYField);
|
||||
}
|
||||
|
||||
float
|
||||
AndroidViewTransform::GetScale(JNIEnv *env)
|
||||
{
|
||||
if (!env)
|
||||
return 0.0f;
|
||||
return env->GetFloatField(wrapped_obj, jScaleField);
|
||||
}
|
||||
|
||||
void
|
||||
AndroidViewTransform::GetFixedLayerMargins(JNIEnv *env, LayerMargin &aFixedLayerMargins)
|
||||
{
|
||||
if (!env)
|
||||
return;
|
||||
|
||||
aFixedLayerMargins.top = env->GetFloatField(wrapped_obj, jFixedLayerMarginTop);
|
||||
aFixedLayerMargins.right = env->GetFloatField(wrapped_obj, jFixedLayerMarginRight);
|
||||
aFixedLayerMargins.bottom = env->GetFloatField(wrapped_obj, jFixedLayerMarginBottom);
|
||||
aFixedLayerMargins.left = env->GetFloatField(wrapped_obj, jFixedLayerMarginLeft);
|
||||
}
|
||||
|
||||
float
|
||||
AndroidViewTransform::GetOffsetX(JNIEnv *env)
|
||||
{
|
||||
if (!env)
|
||||
return 0.0f;
|
||||
return env->GetFloatField(wrapped_obj, jOffsetXField);
|
||||
}
|
||||
|
||||
float
|
||||
AndroidViewTransform::GetOffsetY(JNIEnv *env)
|
||||
{
|
||||
if (!env)
|
||||
return 0.0f;
|
||||
return env->GetFloatField(wrapped_obj, jOffsetYField);
|
||||
}
|
||||
|
||||
float
|
||||
AndroidProgressiveUpdateData::GetX(JNIEnv *env)
|
||||
{
|
||||
if (!env)
|
||||
return 0.0f;
|
||||
return env->GetFloatField(wrapped_obj, jXField);
|
||||
}
|
||||
|
||||
float
|
||||
AndroidProgressiveUpdateData::GetY(JNIEnv *env)
|
||||
{
|
||||
if (!env)
|
||||
return 0.0f;
|
||||
return env->GetFloatField(wrapped_obj, jYField);
|
||||
}
|
||||
|
||||
float
|
||||
AndroidProgressiveUpdateData::GetWidth(JNIEnv *env)
|
||||
{
|
||||
if (!env)
|
||||
return 0.0f;
|
||||
return env->GetFloatField(wrapped_obj, jWidthField);
|
||||
}
|
||||
|
||||
float
|
||||
AndroidProgressiveUpdateData::GetHeight(JNIEnv *env)
|
||||
{
|
||||
if (!env)
|
||||
return 0.0f;
|
||||
return env->GetFloatField(wrapped_obj, jHeightField);
|
||||
}
|
||||
|
||||
float
|
||||
AndroidProgressiveUpdateData::GetScale(JNIEnv *env)
|
||||
{
|
||||
if (!env)
|
||||
return 0.0f;
|
||||
return env->GetFloatField(wrapped_obj, jScaleField);
|
||||
}
|
||||
|
||||
bool
|
||||
AndroidProgressiveUpdateData::GetShouldAbort(JNIEnv *env)
|
||||
{
|
||||
if (!env)
|
||||
return false;
|
||||
return env->GetBooleanField(wrapped_obj, jShouldAbortField);
|
||||
}
|
||||
|
||||
void
|
||||
AndroidRect::Init(JNIEnv *jenv, jobject jobj)
|
||||
{
|
||||
|
@ -14,7 +14,6 @@
|
||||
#include "nsRect.h"
|
||||
#include "nsString.h"
|
||||
#include "nsTArray.h"
|
||||
#include "nsIAndroidBridge.h"
|
||||
#include "nsIObserver.h"
|
||||
#include "mozilla/gfx/Rect.h"
|
||||
#include "mozilla/dom/Touch.h"
|
||||
@ -24,12 +23,21 @@
|
||||
|
||||
//#define FORCE_ALOG 1
|
||||
|
||||
#ifndef ALOG
|
||||
#if defined(DEBUG) || defined(FORCE_ALOG)
|
||||
#define ALOG(args...) __android_log_print(ANDROID_LOG_INFO, "Gecko" , ## args)
|
||||
#else
|
||||
#define ALOG(args...) ((void)0)
|
||||
#endif
|
||||
#endif
|
||||
|
||||
class nsIAndroidDisplayport;
|
||||
class nsIAndroidViewport;
|
||||
class nsIWidget;
|
||||
|
||||
namespace mozilla {
|
||||
|
||||
class AndroidGeckoLayerClient;
|
||||
class AutoLocalJNIFrame;
|
||||
|
||||
void InitAndroidJavaWrappers(JNIEnv *jEnv);
|
||||
@ -67,10 +75,10 @@ private:
|
||||
class WrappedJavaObject {
|
||||
public:
|
||||
WrappedJavaObject() :
|
||||
wrapped_obj(NULL)
|
||||
wrapped_obj(0)
|
||||
{ }
|
||||
|
||||
WrappedJavaObject(jobject jobj) : wrapped_obj(NULL) {
|
||||
WrappedJavaObject(jobject jobj) {
|
||||
Init(jobj);
|
||||
}
|
||||
|
||||
@ -79,39 +87,7 @@ public:
|
||||
}
|
||||
|
||||
bool isNull() const {
|
||||
return wrapped_obj == NULL;
|
||||
}
|
||||
|
||||
jobject wrappedObject() const {
|
||||
return wrapped_obj;
|
||||
}
|
||||
|
||||
protected:
|
||||
jobject wrapped_obj;
|
||||
};
|
||||
|
||||
class AutoGlobalWrappedJavaObject : protected WrappedJavaObject{
|
||||
public:
|
||||
AutoGlobalWrappedJavaObject() :
|
||||
wrapped_obj(NULL)
|
||||
{ }
|
||||
|
||||
AutoGlobalWrappedJavaObject(jobject jobj, JNIEnv* env) : wrapped_obj(NULL) {
|
||||
Init(jobj, env);
|
||||
}
|
||||
|
||||
virtual ~AutoGlobalWrappedJavaObject();
|
||||
void Dispose();
|
||||
|
||||
void Init(jobject jobj, JNIEnv* env) {
|
||||
if (!isNull()) {
|
||||
env->DeleteGlobalRef(wrapped_obj);
|
||||
}
|
||||
wrapped_obj = env->NewGlobalRef(jobj);
|
||||
}
|
||||
|
||||
bool isNull() const {
|
||||
return wrapped_obj == NULL;
|
||||
return wrapped_obj == 0;
|
||||
}
|
||||
|
||||
jobject wrappedObject() const {
|
||||
@ -210,6 +186,128 @@ protected:
|
||||
static jfieldID jTopField;
|
||||
};
|
||||
|
||||
class AndroidViewTransform : public WrappedJavaObject {
|
||||
public:
|
||||
static void InitViewTransformClass(JNIEnv *jEnv);
|
||||
|
||||
void Init(jobject jobj);
|
||||
|
||||
AndroidViewTransform() {}
|
||||
AndroidViewTransform(jobject jobj) { Init(jobj); }
|
||||
|
||||
float GetX(JNIEnv *env);
|
||||
float GetY(JNIEnv *env);
|
||||
float GetScale(JNIEnv *env);
|
||||
void GetFixedLayerMargins(JNIEnv *env, LayerMargin &aFixedLayerMargins);
|
||||
float GetOffsetX(JNIEnv *env);
|
||||
float GetOffsetY(JNIEnv *env);
|
||||
|
||||
private:
|
||||
static jclass jViewTransformClass;
|
||||
static jfieldID jXField;
|
||||
static jfieldID jYField;
|
||||
static jfieldID jScaleField;
|
||||
static jfieldID jFixedLayerMarginLeft;
|
||||
static jfieldID jFixedLayerMarginTop;
|
||||
static jfieldID jFixedLayerMarginRight;
|
||||
static jfieldID jFixedLayerMarginBottom;
|
||||
static jfieldID jOffsetXField;
|
||||
static jfieldID jOffsetYField;
|
||||
};
|
||||
|
||||
class AndroidProgressiveUpdateData : public WrappedJavaObject {
|
||||
public:
|
||||
static void InitProgressiveUpdateDataClass(JNIEnv *jEnv);
|
||||
|
||||
void Init(jobject jobj);
|
||||
|
||||
AndroidProgressiveUpdateData() {}
|
||||
AndroidProgressiveUpdateData(jobject jobj) { Init(jobj); }
|
||||
|
||||
float GetX(JNIEnv *env);
|
||||
float GetY(JNIEnv *env);
|
||||
float GetWidth(JNIEnv *env);
|
||||
float GetHeight(JNIEnv *env);
|
||||
float GetScale(JNIEnv *env);
|
||||
bool GetShouldAbort(JNIEnv *env);
|
||||
|
||||
private:
|
||||
static jclass jProgressiveUpdateDataClass;
|
||||
static jfieldID jXField;
|
||||
static jfieldID jYField;
|
||||
static jfieldID jWidthField;
|
||||
static jfieldID jHeightField;
|
||||
static jfieldID jScaleField;
|
||||
static jfieldID jShouldAbortField;
|
||||
};
|
||||
|
||||
class AndroidLayerRendererFrame : public WrappedJavaObject {
|
||||
public:
|
||||
static void InitLayerRendererFrameClass(JNIEnv *jEnv);
|
||||
|
||||
void Init(JNIEnv *env, jobject jobj);
|
||||
void Dispose(JNIEnv *env);
|
||||
|
||||
bool BeginDrawing(AutoLocalJNIFrame *jniFrame);
|
||||
bool DrawBackground(AutoLocalJNIFrame *jniFrame);
|
||||
bool DrawForeground(AutoLocalJNIFrame *jniFrame);
|
||||
bool EndDrawing(AutoLocalJNIFrame *jniFrame);
|
||||
|
||||
private:
|
||||
static jclass jLayerRendererFrameClass;
|
||||
static jmethodID jBeginDrawingMethod;
|
||||
static jmethodID jDrawBackgroundMethod;
|
||||
static jmethodID jDrawForegroundMethod;
|
||||
static jmethodID jEndDrawingMethod;
|
||||
};
|
||||
|
||||
class AndroidGeckoLayerClient : public WrappedJavaObject {
|
||||
public:
|
||||
static void InitGeckoLayerClientClass(JNIEnv *jEnv);
|
||||
|
||||
void Init(jobject jobj);
|
||||
|
||||
AndroidGeckoLayerClient() {}
|
||||
AndroidGeckoLayerClient(jobject jobj) { Init(jobj); }
|
||||
|
||||
void SetFirstPaintViewport(const LayerIntPoint& aOffset, const CSSToLayerScale& aZoom, const CSSRect& aCssPageRect);
|
||||
void SetPageRect(const CSSRect& aCssPageRect);
|
||||
void SyncViewportInfo(const LayerIntRect& aDisplayPort, const CSSToLayerScale& aDisplayResolution,
|
||||
bool aLayersUpdated, ScreenPoint& aScrollOffset, CSSToScreenScale& aScale,
|
||||
LayerMargin& aFixedLayerMargins, ScreenPoint& aOffset);
|
||||
void SyncFrameMetrics(const ScreenPoint& aScrollOffset, float aZoom, const CSSRect& aCssPageRect,
|
||||
bool aLayersUpdated, const CSSRect& aDisplayPort, const CSSToLayerScale& aDisplayResolution,
|
||||
bool aIsFirstPaint, LayerMargin& aFixedLayerMargins, ScreenPoint& aOffset);
|
||||
bool ProgressiveUpdateCallback(bool aHasPendingNewThebesContent, const LayerRect& aDisplayPort, float aDisplayResolution, bool aDrawingCritical, gfx::Rect& aViewport, float& aScaleX, float& aScaleY);
|
||||
bool CreateFrame(AutoLocalJNIFrame *jniFrame, AndroidLayerRendererFrame& aFrame);
|
||||
bool ActivateProgram(AutoLocalJNIFrame *jniFrame);
|
||||
bool DeactivateProgram(AutoLocalJNIFrame *jniFrame);
|
||||
void GetDisplayPort(AutoLocalJNIFrame *jniFrame, bool aPageSizeUpdate, bool aIsBrowserContentDisplayed, int32_t tabId, nsIAndroidViewport* metrics, nsIAndroidDisplayport** displayPort);
|
||||
void ContentDocumentChanged(AutoLocalJNIFrame *jniFrame);
|
||||
bool IsContentDocumentDisplayed(AutoLocalJNIFrame *jniFrame);
|
||||
|
||||
protected:
|
||||
static jclass jGeckoLayerClientClass;
|
||||
static jmethodID jSetFirstPaintViewport;
|
||||
static jmethodID jSetPageRect;
|
||||
static jmethodID jSyncViewportInfoMethod;
|
||||
static jmethodID jSyncFrameMetricsMethod;
|
||||
static jmethodID jCreateFrameMethod;
|
||||
static jmethodID jActivateProgramMethod;
|
||||
static jmethodID jDeactivateProgramMethod;
|
||||
static jmethodID jGetDisplayPort;
|
||||
static jmethodID jContentDocumentChanged;
|
||||
static jmethodID jIsContentDocumentDisplayed;
|
||||
static jmethodID jProgressiveUpdateCallbackMethod;
|
||||
|
||||
public:
|
||||
static jclass jViewportClass;
|
||||
static jclass jDisplayportClass;
|
||||
static jmethodID jViewportCtor;
|
||||
static jfieldID jDisplayportPosition;
|
||||
static jfieldID jDisplayportResolution;
|
||||
};
|
||||
|
||||
enum {
|
||||
// These keycode masks are not defined in android/keycodes.h:
|
||||
AKEYCODE_ESCAPE = 111,
|
||||
@ -335,29 +433,6 @@ enum {
|
||||
AMETA_SHIFT_MASK = AMETA_SHIFT_LEFT_ON | AMETA_SHIFT_RIGHT_ON | AMETA_SHIFT_ON,
|
||||
};
|
||||
|
||||
class nsAndroidDisplayport MOZ_FINAL : public nsIAndroidDisplayport
|
||||
{
|
||||
public:
|
||||
NS_DECL_ISUPPORTS
|
||||
virtual nsresult GetLeft(float *aLeft) { *aLeft = mLeft; return NS_OK; }
|
||||
virtual nsresult GetTop(float *aTop) { *aTop = mTop; return NS_OK; }
|
||||
virtual nsresult GetRight(float *aRight) { *aRight = mRight; return NS_OK; }
|
||||
virtual nsresult GetBottom(float *aBottom) { *aBottom = mBottom; return NS_OK; }
|
||||
virtual nsresult GetResolution(float *aResolution) { *aResolution = mResolution; return NS_OK; }
|
||||
virtual nsresult SetLeft(float aLeft) { mLeft = aLeft; return NS_OK; }
|
||||
virtual nsresult SetTop(float aTop) { mTop = aTop; return NS_OK; }
|
||||
virtual nsresult SetRight(float aRight) { mRight = aRight; return NS_OK; }
|
||||
virtual nsresult SetBottom(float aBottom) { mBottom = aBottom; return NS_OK; }
|
||||
virtual nsresult SetResolution(float aResolution) { mResolution = aResolution; return NS_OK; }
|
||||
|
||||
nsAndroidDisplayport(AndroidRectF aRect, float aResolution):
|
||||
mLeft(aRect.Left()), mTop(aRect.Top()), mRight(aRect.Right()), mBottom(aRect.Bottom()), mResolution(aResolution) {}
|
||||
|
||||
private:
|
||||
~nsAndroidDisplayport() {}
|
||||
float mLeft, mTop, mRight, mBottom, mResolution;
|
||||
};
|
||||
|
||||
class AndroidMotionEvent
|
||||
{
|
||||
public:
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -1,523 +1,206 @@
|
||||
protected:
|
||||
|
||||
|
||||
jclass mGeckoAppShellClass;
|
||||
jmethodID jAcknowledgeEvent;
|
||||
jmethodID jAddPluginViewWrapper;
|
||||
jmethodID jAlertsProgressListener_OnProgress;
|
||||
jmethodID jCancelVibrate;
|
||||
jmethodID jCheckURIVisited;
|
||||
jmethodID jClearMessageList;
|
||||
jmethodID jCloseCamera;
|
||||
jmethodID jCloseNotification;
|
||||
jmethodID jCreateMessageListWrapper;
|
||||
jmethodID jCreateShortcut;
|
||||
jmethodID jDeleteMessageWrapper;
|
||||
jmethodID jDisableBatteryNotifications;
|
||||
jmethodID jDisableNetworkNotifications;
|
||||
jmethodID jDisableScreenOrientationNotifications;
|
||||
jmethodID jDisableSensor;
|
||||
jmethodID jEnableBatteryNotifications;
|
||||
jmethodID jEnableLocation;
|
||||
jmethodID jEnableLocationHighAccuracy;
|
||||
jmethodID jEnableNetworkNotifications;
|
||||
jmethodID jEnableScreenOrientationNotifications;
|
||||
jmethodID jEnableSensor;
|
||||
jmethodID jGetContext;
|
||||
jmethodID jGetCurrentBatteryInformationWrapper;
|
||||
jmethodID jGetCurrentNetworkInformationWrapper;
|
||||
jmethodID jGetDensity;
|
||||
jmethodID jGetDpiWrapper;
|
||||
jmethodID jGetExtensionFromMimeTypeWrapper;
|
||||
jmethodID jGetGfxInfoDataWrapper;
|
||||
jmethodID jGetHandlersForMimeTypeWrapper;
|
||||
jmethodID jGetHandlersForURLWrapper;
|
||||
jmethodID jGetIconForExtensionWrapper;
|
||||
jmethodID jGetMessageWrapper;
|
||||
jmethodID jGetMimeTypeFromExtensionsWrapper;
|
||||
jmethodID jGetNextMessageInListWrapper;
|
||||
jmethodID jGetProxyForURIWrapper;
|
||||
jmethodID jGetScreenDepthWrapper;
|
||||
jmethodID jGetScreenOrientationWrapper;
|
||||
jmethodID jGetShowPasswordSetting;
|
||||
jmethodID jGetSystemColoursWrapper;
|
||||
jmethodID jHandleGeckoMessageWrapper;
|
||||
jmethodID jHideProgressDialog;
|
||||
jmethodID jInitCameraWrapper;
|
||||
jmethodID jIsNetworkLinkKnown;
|
||||
jmethodID jIsNetworkLinkUp;
|
||||
jmethodID jIsTablet;
|
||||
jmethodID jKillAnyZombies;
|
||||
jmethodID jLockScreenOrientation;
|
||||
jmethodID jMarkURIVisited;
|
||||
jmethodID jMoveTaskToBack;
|
||||
jmethodID jNotifyDefaultPrevented;
|
||||
jmethodID jNotifyIME;
|
||||
jmethodID jNotifyIMEChange;
|
||||
jmethodID jNotifyIMEContext;
|
||||
jmethodID jNotifyWakeLockChanged;
|
||||
jmethodID jNotifyXreExit;
|
||||
jmethodID jOpenUriExternal;
|
||||
jmethodID jPerformHapticFeedback;
|
||||
jmethodID jPumpMessageLoop;
|
||||
jmethodID jRegisterSurfaceTextureFrameListener;
|
||||
jmethodID jRemovePluginView;
|
||||
jmethodID jScanMedia;
|
||||
jmethodID jScheduleRestart;
|
||||
jmethodID jSendMessageWrapper;
|
||||
jmethodID jSetFullScreen;
|
||||
jmethodID jSetKeepScreenOn;
|
||||
jmethodID jSetSelectedLocale;
|
||||
jmethodID jSetURITitle;
|
||||
jmethodID jShowAlertNotificationWrapper;
|
||||
jmethodID jShowFilePickerAsyncWrapper;
|
||||
jmethodID jShowFilePickerForExtensionsWrapper;
|
||||
jmethodID jShowFilePickerForMimeTypeWrapper;
|
||||
jmethodID jShowInputMethodPicker;
|
||||
jmethodID jUnlockProfile;
|
||||
jmethodID jUnlockScreenOrientation;
|
||||
jmethodID jUnregisterSurfaceTextureFrameListener;
|
||||
jmethodID jVibrate1;
|
||||
jmethodID jVibrateA;
|
||||
|
||||
jclass mGeckoJavaSamplerClass;
|
||||
jmethodID jGetFrameNameJavaProfilingWrapper;
|
||||
jmethodID jGetSampleTimeJavaProfiling;
|
||||
jmethodID jGetThreadNameJavaProfilingWrapper;
|
||||
jmethodID jPauseJavaProfiling;
|
||||
jmethodID jStartJavaProfiling;
|
||||
jmethodID jStopJavaProfiling;
|
||||
jmethodID jUnpauseJavaProfiling;
|
||||
|
||||
jclass mThumbnailHelperClass;
|
||||
jmethodID jSendThumbnail;
|
||||
|
||||
jclass mGLControllerClass;
|
||||
jmethodID jProvideEGLSurfaceWrapper;
|
||||
|
||||
jclass mLayerViewClass;
|
||||
jmethodID jRegisterCompositorWrapper;
|
||||
|
||||
jclass mNativePanZoomControllerClass;
|
||||
jmethodID jPostDelayedCallbackWrapper;
|
||||
jmethodID jRequestContentRepaintWrapper;
|
||||
|
||||
jclass mClipboardClass;
|
||||
jmethodID jGetClipboardTextWrapper;
|
||||
jmethodID jSetClipboardText;
|
||||
|
||||
// GENERATED CODE
|
||||
// Generated by the Java program at /build/annotationProcessors at compile time from
|
||||
// annotations on Java methods. To update, change the annotations on the corresponding Java
|
||||
// methods and rerun the build. Manually updating this file will cause your build to fail.
|
||||
|
||||
#ifndef GeneratedJNIWrappers_h__
|
||||
#define GeneratedJNIWrappers_h__
|
||||
|
||||
#include "nsXPCOMStrings.h"
|
||||
#include "AndroidJavaWrappers.h"
|
||||
|
||||
namespace mozilla {
|
||||
namespace widget {
|
||||
namespace android {
|
||||
void InitStubs(JNIEnv *jEnv);
|
||||
|
||||
class GeckoAppShell : public AutoGlobalWrappedJavaObject {
|
||||
public:
|
||||
static void InitStubs(JNIEnv *jEnv);
|
||||
static GeckoAppShell* Wrap(jobject obj);
|
||||
GeckoAppShell(jobject obj, JNIEnv* env) : AutoGlobalWrappedJavaObject(obj, env) {};
|
||||
static void AcknowledgeEvent();
|
||||
static void AddPluginViewWrapper(jobject a0, jfloat a1, jfloat a2, jfloat a3, jfloat a4, bool a5);
|
||||
static void AlertsProgressListener_OnProgress(const nsAString& a0, int64_t a1, int64_t a2, const nsAString& a3);
|
||||
static void CancelVibrate();
|
||||
static void CheckURIVisited(const nsAString& a0);
|
||||
static void ClearMessageList(int32_t a0);
|
||||
static void CloseCamera();
|
||||
static void CloseNotification(const nsAString& a0);
|
||||
static void CreateMessageListWrapper(int64_t a0, int64_t a1, jobjectArray a2, int32_t a3, int32_t a4, bool a5, int32_t a6);
|
||||
static void CreateShortcut(const nsAString& a0, const nsAString& a1, const nsAString& a2, const nsAString& a3);
|
||||
static void DeleteMessageWrapper(int32_t a0, int32_t a1);
|
||||
static void DisableBatteryNotifications();
|
||||
static void DisableNetworkNotifications();
|
||||
static void DisableScreenOrientationNotifications();
|
||||
static void DisableSensor(int32_t a0);
|
||||
static void EnableBatteryNotifications();
|
||||
static void EnableLocation(bool a0);
|
||||
static void EnableLocationHighAccuracy(bool a0);
|
||||
static void EnableNetworkNotifications();
|
||||
static void EnableScreenOrientationNotifications();
|
||||
static void EnableSensor(int32_t a0);
|
||||
static jobject GetContext();
|
||||
static jdoubleArray GetCurrentBatteryInformationWrapper();
|
||||
static jdoubleArray GetCurrentNetworkInformationWrapper();
|
||||
static jfloat GetDensity();
|
||||
static int32_t GetDpiWrapper();
|
||||
static jstring GetExtensionFromMimeTypeWrapper(const nsAString& a0);
|
||||
static jstring GetGfxInfoDataWrapper();
|
||||
static jobjectArray GetHandlersForMimeTypeWrapper(const nsAString& a0, const nsAString& a1);
|
||||
static jobjectArray GetHandlersForURLWrapper(const nsAString& a0, const nsAString& a1);
|
||||
static jbyteArray GetIconForExtensionWrapper(const nsAString& a0, int32_t a1);
|
||||
static void GetMessageWrapper(int32_t a0, int32_t a1);
|
||||
static jstring GetMimeTypeFromExtensionsWrapper(const nsAString& a0);
|
||||
static void GetNextMessageInListWrapper(int32_t a0, int32_t a1);
|
||||
static jstring GetProxyForURIWrapper(const nsAString& a0, const nsAString& a1, const nsAString& a2, int32_t a3);
|
||||
static int32_t GetScreenDepthWrapper();
|
||||
static int16_t GetScreenOrientationWrapper();
|
||||
static bool GetShowPasswordSetting();
|
||||
static jintArray GetSystemColoursWrapper();
|
||||
static jstring HandleGeckoMessageWrapper(const nsAString& a0);
|
||||
static void HideProgressDialog();
|
||||
static jintArray InitCameraWrapper(const nsAString& a0, int32_t a1, int32_t a2, int32_t a3);
|
||||
static bool IsNetworkLinkKnown();
|
||||
static bool IsNetworkLinkUp();
|
||||
static bool IsTablet();
|
||||
static void KillAnyZombies();
|
||||
static void LockScreenOrientation(int32_t a0);
|
||||
static void MarkURIVisited(const nsAString& a0);
|
||||
static void MoveTaskToBack();
|
||||
static void NotifyDefaultPrevented(bool a0);
|
||||
static void NotifyIME(int32_t a0);
|
||||
static void NotifyIMEChange(const nsAString& a0, int32_t a1, int32_t a2, int32_t a3);
|
||||
static void NotifyIMEContext(int32_t a0, const nsAString& a1, const nsAString& a2, const nsAString& a3);
|
||||
static void NotifyWakeLockChanged(const nsAString& a0, const nsAString& a1);
|
||||
static void NotifyXreExit();
|
||||
static bool OpenUriExternal(const nsAString& a0, const nsAString& a1, const nsAString& a2 = EmptyString(), const nsAString& a3 = EmptyString(), const nsAString& a4 = EmptyString(), const nsAString& a5 = EmptyString());
|
||||
static void PerformHapticFeedback(bool a0);
|
||||
static bool PumpMessageLoop();
|
||||
static void RegisterSurfaceTextureFrameListener(jobject a0, int32_t a1);
|
||||
static void RemovePluginView(jobject a0, bool a1);
|
||||
static void ScanMedia(const nsAString& a0, const nsAString& a1);
|
||||
static void ScheduleRestart();
|
||||
static void SendMessageWrapper(const nsAString& a0, const nsAString& a1, int32_t a2);
|
||||
static void SetFullScreen(bool a0);
|
||||
static void SetKeepScreenOn(bool a0);
|
||||
static void SetSelectedLocale(const nsAString& a0);
|
||||
static void SetURITitle(const nsAString& a0, const nsAString& a1);
|
||||
static void ShowAlertNotificationWrapper(const nsAString& a0, const nsAString& a1, const nsAString& a2, const nsAString& a3, const nsAString& a4);
|
||||
static void ShowFilePickerAsyncWrapper(const nsAString& a0, int64_t a1);
|
||||
static jstring ShowFilePickerForExtensionsWrapper(const nsAString& a0);
|
||||
static jstring ShowFilePickerForMimeTypeWrapper(const nsAString& a0);
|
||||
static void ShowInputMethodPicker();
|
||||
static bool UnlockProfile();
|
||||
static void UnlockScreenOrientation();
|
||||
static void UnregisterSurfaceTextureFrameListener(jobject a0);
|
||||
static void Vibrate1(int64_t a0);
|
||||
static void VibrateA(jlongArray a0, int32_t a1);
|
||||
GeckoAppShell() : AutoGlobalWrappedJavaObject() {};
|
||||
protected:
|
||||
static jclass mGeckoAppShellClass;
|
||||
static jmethodID jAcknowledgeEvent;
|
||||
static jmethodID jAddPluginViewWrapper;
|
||||
static jmethodID jAlertsProgressListener_OnProgress;
|
||||
static jmethodID jCancelVibrate;
|
||||
static jmethodID jCheckURIVisited;
|
||||
static jmethodID jClearMessageList;
|
||||
static jmethodID jCloseCamera;
|
||||
static jmethodID jCloseNotification;
|
||||
static jmethodID jCreateMessageListWrapper;
|
||||
static jmethodID jCreateShortcut;
|
||||
static jmethodID jDeleteMessageWrapper;
|
||||
static jmethodID jDisableBatteryNotifications;
|
||||
static jmethodID jDisableNetworkNotifications;
|
||||
static jmethodID jDisableScreenOrientationNotifications;
|
||||
static jmethodID jDisableSensor;
|
||||
static jmethodID jEnableBatteryNotifications;
|
||||
static jmethodID jEnableLocation;
|
||||
static jmethodID jEnableLocationHighAccuracy;
|
||||
static jmethodID jEnableNetworkNotifications;
|
||||
static jmethodID jEnableScreenOrientationNotifications;
|
||||
static jmethodID jEnableSensor;
|
||||
static jmethodID jGetContext;
|
||||
static jmethodID jGetCurrentBatteryInformationWrapper;
|
||||
static jmethodID jGetCurrentNetworkInformationWrapper;
|
||||
static jmethodID jGetDensity;
|
||||
static jmethodID jGetDpiWrapper;
|
||||
static jmethodID jGetExtensionFromMimeTypeWrapper;
|
||||
static jmethodID jGetGfxInfoDataWrapper;
|
||||
static jmethodID jGetHandlersForMimeTypeWrapper;
|
||||
static jmethodID jGetHandlersForURLWrapper;
|
||||
static jmethodID jGetIconForExtensionWrapper;
|
||||
static jmethodID jGetMessageWrapper;
|
||||
static jmethodID jGetMimeTypeFromExtensionsWrapper;
|
||||
static jmethodID jGetNextMessageInListWrapper;
|
||||
static jmethodID jGetProxyForURIWrapper;
|
||||
static jmethodID jGetScreenDepthWrapper;
|
||||
static jmethodID jGetScreenOrientationWrapper;
|
||||
static jmethodID jGetShowPasswordSetting;
|
||||
static jmethodID jGetSystemColoursWrapper;
|
||||
static jmethodID jHandleGeckoMessageWrapper;
|
||||
static jmethodID jHideProgressDialog;
|
||||
static jmethodID jInitCameraWrapper;
|
||||
static jmethodID jIsNetworkLinkKnown;
|
||||
static jmethodID jIsNetworkLinkUp;
|
||||
static jmethodID jIsTablet;
|
||||
static jmethodID jKillAnyZombies;
|
||||
static jmethodID jLockScreenOrientation;
|
||||
static jmethodID jMarkURIVisited;
|
||||
static jmethodID jMoveTaskToBack;
|
||||
static jmethodID jNotifyDefaultPrevented;
|
||||
static jmethodID jNotifyIME;
|
||||
static jmethodID jNotifyIMEChange;
|
||||
static jmethodID jNotifyIMEContext;
|
||||
static jmethodID jNotifyWakeLockChanged;
|
||||
static jmethodID jNotifyXreExit;
|
||||
static jmethodID jOpenUriExternal;
|
||||
static jmethodID jPerformHapticFeedback;
|
||||
static jmethodID jPumpMessageLoop;
|
||||
static jmethodID jRegisterSurfaceTextureFrameListener;
|
||||
static jmethodID jRemovePluginView;
|
||||
static jmethodID jScanMedia;
|
||||
static jmethodID jScheduleRestart;
|
||||
static jmethodID jSendMessageWrapper;
|
||||
static jmethodID jSetFullScreen;
|
||||
static jmethodID jSetKeepScreenOn;
|
||||
static jmethodID jSetSelectedLocale;
|
||||
static jmethodID jSetURITitle;
|
||||
static jmethodID jShowAlertNotificationWrapper;
|
||||
static jmethodID jShowFilePickerAsyncWrapper;
|
||||
static jmethodID jShowFilePickerForExtensionsWrapper;
|
||||
static jmethodID jShowFilePickerForMimeTypeWrapper;
|
||||
static jmethodID jShowInputMethodPicker;
|
||||
static jmethodID jUnlockProfile;
|
||||
static jmethodID jUnlockScreenOrientation;
|
||||
static jmethodID jUnregisterSurfaceTextureFrameListener;
|
||||
static jmethodID jVibrate1;
|
||||
static jmethodID jVibrateA;
|
||||
};
|
||||
|
||||
class JavaDomKeyLocation : public AutoGlobalWrappedJavaObject {
|
||||
public:
|
||||
static void InitStubs(JNIEnv *jEnv);
|
||||
static JavaDomKeyLocation* Wrap(jobject obj);
|
||||
JavaDomKeyLocation(jobject obj, JNIEnv* env) : AutoGlobalWrappedJavaObject(obj, env) {};
|
||||
static jobject valueOf(const nsAString& a0);
|
||||
static jobjectArray values();
|
||||
static jobject getDOM_KEY_LOCATION_JOYSTICK();
|
||||
static jobject getDOM_KEY_LOCATION_LEFT();
|
||||
static jobject getDOM_KEY_LOCATION_MOBILE();
|
||||
static jobject getDOM_KEY_LOCATION_NUMPAD();
|
||||
static jobject getDOM_KEY_LOCATION_RIGHT();
|
||||
static jobject getDOM_KEY_LOCATION_STANDARD();
|
||||
int32_t getvalue();
|
||||
JavaDomKeyLocation() : AutoGlobalWrappedJavaObject() {};
|
||||
protected:
|
||||
static jclass mDomKeyLocationClass;
|
||||
static jmethodID jvalueOf;
|
||||
static jmethodID jvalues;
|
||||
static jfieldID jDOM_KEY_LOCATION_JOYSTICK;
|
||||
static jfieldID jDOM_KEY_LOCATION_LEFT;
|
||||
static jfieldID jDOM_KEY_LOCATION_MOBILE;
|
||||
static jfieldID jDOM_KEY_LOCATION_NUMPAD;
|
||||
static jfieldID jDOM_KEY_LOCATION_RIGHT;
|
||||
static jfieldID jDOM_KEY_LOCATION_STANDARD;
|
||||
static jfieldID jvalue;
|
||||
};
|
||||
|
||||
class GeckoJavaSampler : public AutoGlobalWrappedJavaObject {
|
||||
public:
|
||||
static void InitStubs(JNIEnv *jEnv);
|
||||
static GeckoJavaSampler* Wrap(jobject obj);
|
||||
GeckoJavaSampler(jobject obj, JNIEnv* env) : AutoGlobalWrappedJavaObject(obj, env) {};
|
||||
static jstring GetFrameNameJavaProfilingWrapper(int32_t a0, int32_t a1, int32_t a2);
|
||||
static jdouble GetSampleTimeJavaProfiling(int32_t a0, int32_t a1);
|
||||
static jstring GetThreadNameJavaProfilingWrapper(int32_t a0);
|
||||
static void PauseJavaProfiling();
|
||||
static void StartJavaProfiling(int32_t a0, int32_t a1);
|
||||
static void StopJavaProfiling();
|
||||
static void UnpauseJavaProfiling();
|
||||
GeckoJavaSampler() : AutoGlobalWrappedJavaObject() {};
|
||||
protected:
|
||||
static jclass mGeckoJavaSamplerClass;
|
||||
static jmethodID jGetFrameNameJavaProfilingWrapper;
|
||||
static jmethodID jGetSampleTimeJavaProfiling;
|
||||
static jmethodID jGetThreadNameJavaProfilingWrapper;
|
||||
static jmethodID jPauseJavaProfiling;
|
||||
static jmethodID jStartJavaProfiling;
|
||||
static jmethodID jStopJavaProfiling;
|
||||
static jmethodID jUnpauseJavaProfiling;
|
||||
};
|
||||
|
||||
class SurfaceBits : public AutoGlobalWrappedJavaObject {
|
||||
public:
|
||||
static void InitStubs(JNIEnv *jEnv);
|
||||
static SurfaceBits* Wrap(jobject obj);
|
||||
SurfaceBits(jobject obj, JNIEnv* env) : AutoGlobalWrappedJavaObject(obj, env) {};
|
||||
SurfaceBits();
|
||||
jobject getbuffer();
|
||||
void setbuffer(jobject a0);
|
||||
int32_t getformat();
|
||||
void setformat(int32_t a0);
|
||||
int32_t getheight();
|
||||
void setheight(int32_t a0);
|
||||
int32_t getwidth();
|
||||
void setwidth(int32_t a0);
|
||||
protected:
|
||||
static jclass mSurfaceBitsClass;
|
||||
static jmethodID jSurfaceBits;
|
||||
static jfieldID jbuffer;
|
||||
static jfieldID jformat;
|
||||
static jfieldID jheight;
|
||||
static jfieldID jwidth;
|
||||
};
|
||||
|
||||
class ThumbnailHelper : public AutoGlobalWrappedJavaObject {
|
||||
public:
|
||||
static void InitStubs(JNIEnv *jEnv);
|
||||
static ThumbnailHelper* Wrap(jobject obj);
|
||||
ThumbnailHelper(jobject obj, JNIEnv* env) : AutoGlobalWrappedJavaObject(obj, env) {};
|
||||
static void SendThumbnail(jobject a0, int32_t a1, bool a2);
|
||||
ThumbnailHelper() : AutoGlobalWrappedJavaObject() {};
|
||||
protected:
|
||||
static jclass mThumbnailHelperClass;
|
||||
static jmethodID jSendThumbnail;
|
||||
};
|
||||
|
||||
class DisplayPortMetrics : public AutoGlobalWrappedJavaObject {
|
||||
public:
|
||||
static void InitStubs(JNIEnv *jEnv);
|
||||
static DisplayPortMetrics* Wrap(jobject obj);
|
||||
DisplayPortMetrics(jobject obj, JNIEnv* env) : AutoGlobalWrappedJavaObject(obj, env) {};
|
||||
DisplayPortMetrics(jfloat a0, jfloat a1, jfloat a2, jfloat a3, jfloat a4);
|
||||
jobject getMPosition();
|
||||
jfloat getResolution();
|
||||
DisplayPortMetrics() : AutoGlobalWrappedJavaObject() {};
|
||||
protected:
|
||||
static jclass mDisplayPortMetricsClass;
|
||||
static jmethodID jDisplayPortMetrics;
|
||||
static jfieldID jMPosition;
|
||||
static jfieldID jResolution;
|
||||
};
|
||||
|
||||
class GLController : public AutoGlobalWrappedJavaObject {
|
||||
public:
|
||||
static void InitStubs(JNIEnv *jEnv);
|
||||
static GLController* Wrap(jobject obj);
|
||||
GLController(jobject obj, JNIEnv* env) : AutoGlobalWrappedJavaObject(obj, env) {};
|
||||
jobject ProvideEGLSurfaceWrapper();
|
||||
GLController() : AutoGlobalWrappedJavaObject() {};
|
||||
protected:
|
||||
static jclass mGLControllerClass;
|
||||
static jmethodID jProvideEGLSurfaceWrapper;
|
||||
};
|
||||
|
||||
class GeckoLayerClient : public AutoGlobalWrappedJavaObject {
|
||||
public:
|
||||
static void InitStubs(JNIEnv *jEnv);
|
||||
static GeckoLayerClient* Wrap(jobject obj);
|
||||
GeckoLayerClient(jobject obj, JNIEnv* env) : AutoGlobalWrappedJavaObject(obj, env) {};
|
||||
void ActivateProgram();
|
||||
void ContentDocumentChanged();
|
||||
jobject CreateFrame();
|
||||
void DeactivateProgram();
|
||||
jobject GetDisplayPort(bool a0, bool a1, int32_t a2, jobject a3);
|
||||
bool IsContentDocumentDisplayed();
|
||||
jobject ProgressiveUpdateCallback(bool a0, jfloat a1, jfloat a2, jfloat a3, jfloat a4, jfloat a5, bool a6);
|
||||
void SetFirstPaintViewport(jfloat a0, jfloat a1, jfloat a2, jfloat a3, jfloat a4, jfloat a5, jfloat a6);
|
||||
void SetPageRect(jfloat a0, jfloat a1, jfloat a2, jfloat a3);
|
||||
jobject SyncFrameMetrics(jfloat a0, jfloat a1, jfloat a2, jfloat a3, jfloat a4, jfloat a5, jfloat a6, bool a7, int32_t a8, int32_t a9, int32_t a10, int32_t a11, jfloat a12, bool a13);
|
||||
jobject SyncViewportInfo(int32_t a0, int32_t a1, int32_t a2, int32_t a3, jfloat a4, bool a5);
|
||||
GeckoLayerClient() : AutoGlobalWrappedJavaObject() {};
|
||||
protected:
|
||||
static jclass mGeckoLayerClientClass;
|
||||
static jmethodID jActivateProgram;
|
||||
static jmethodID jContentDocumentChanged;
|
||||
static jmethodID jCreateFrame;
|
||||
static jmethodID jDeactivateProgram;
|
||||
static jmethodID jGetDisplayPort;
|
||||
static jmethodID jIsContentDocumentDisplayed;
|
||||
static jmethodID jProgressiveUpdateCallback;
|
||||
static jmethodID jSetFirstPaintViewport;
|
||||
static jmethodID jSetPageRect;
|
||||
static jmethodID jSyncFrameMetrics;
|
||||
static jmethodID jSyncViewportInfo;
|
||||
};
|
||||
|
||||
class ImmutableViewportMetrics : public AutoGlobalWrappedJavaObject {
|
||||
public:
|
||||
static void InitStubs(JNIEnv *jEnv);
|
||||
static ImmutableViewportMetrics* Wrap(jobject obj);
|
||||
ImmutableViewportMetrics(jobject obj, JNIEnv* env) : AutoGlobalWrappedJavaObject(obj, env) {};
|
||||
ImmutableViewportMetrics(jfloat a0, jfloat a1, jfloat a2, jfloat a3, jfloat a4, jfloat a5, jfloat a6, jfloat a7, jfloat a8, jfloat a9, jfloat a10, jfloat a11, jfloat a12);
|
||||
ImmutableViewportMetrics() : AutoGlobalWrappedJavaObject() {};
|
||||
protected:
|
||||
static jclass mImmutableViewportMetricsClass;
|
||||
static jmethodID jImmutableViewportMetrics;
|
||||
};
|
||||
|
||||
class LayerRendererFrame : public AutoGlobalWrappedJavaObject {
|
||||
public:
|
||||
static void InitStubs(JNIEnv *jEnv);
|
||||
static LayerRendererFrame* Wrap(jobject obj);
|
||||
LayerRendererFrame(jobject obj, JNIEnv* env) : AutoGlobalWrappedJavaObject(obj, env) {};
|
||||
void BeginDrawing();
|
||||
void DrawBackground();
|
||||
void DrawForeground();
|
||||
void EndDrawing();
|
||||
LayerRendererFrame() : AutoGlobalWrappedJavaObject() {};
|
||||
protected:
|
||||
static jclass mFrameClass;
|
||||
static jmethodID jBeginDrawing;
|
||||
static jmethodID jDrawBackground;
|
||||
static jmethodID jDrawForeground;
|
||||
static jmethodID jEndDrawing;
|
||||
};
|
||||
|
||||
class LayerView : public AutoGlobalWrappedJavaObject {
|
||||
public:
|
||||
static void InitStubs(JNIEnv *jEnv);
|
||||
static LayerView* Wrap(jobject obj);
|
||||
LayerView(jobject obj, JNIEnv* env) : AutoGlobalWrappedJavaObject(obj, env) {};
|
||||
static jobject RegisterCompositorWrapper();
|
||||
LayerView() : AutoGlobalWrappedJavaObject() {};
|
||||
protected:
|
||||
static jclass mLayerViewClass;
|
||||
static jmethodID jRegisterCompositorWrapper;
|
||||
};
|
||||
|
||||
class NativePanZoomController : public AutoGlobalWrappedJavaObject {
|
||||
public:
|
||||
static void InitStubs(JNIEnv *jEnv);
|
||||
static NativePanZoomController* Wrap(jobject obj);
|
||||
NativePanZoomController(jobject obj, JNIEnv* env) : AutoGlobalWrappedJavaObject(obj, env) {};
|
||||
void PostDelayedCallbackWrapper(int64_t a0);
|
||||
void RequestContentRepaintWrapper(jfloat a0, jfloat a1, jfloat a2, jfloat a3, jfloat a4);
|
||||
NativePanZoomController() : AutoGlobalWrappedJavaObject() {};
|
||||
protected:
|
||||
static jclass mNativePanZoomControllerClass;
|
||||
static jmethodID jPostDelayedCallbackWrapper;
|
||||
static jmethodID jRequestContentRepaintWrapper;
|
||||
};
|
||||
|
||||
class ProgressiveUpdateData : public AutoGlobalWrappedJavaObject {
|
||||
public:
|
||||
static void InitStubs(JNIEnv *jEnv);
|
||||
static ProgressiveUpdateData* Wrap(jobject obj);
|
||||
ProgressiveUpdateData(jobject obj, JNIEnv* env) : AutoGlobalWrappedJavaObject(obj, env) {};
|
||||
ProgressiveUpdateData();
|
||||
void setViewport(jobject a0);
|
||||
bool getabort();
|
||||
void setabort(bool a0);
|
||||
jfloat getheight();
|
||||
void setheight(jfloat a0);
|
||||
jfloat getscale();
|
||||
void setscale(jfloat a0);
|
||||
jfloat getwidth();
|
||||
void setwidth(jfloat a0);
|
||||
jfloat getx();
|
||||
void setx(jfloat a0);
|
||||
jfloat gety();
|
||||
void sety(jfloat a0);
|
||||
protected:
|
||||
static jclass mProgressiveUpdateDataClass;
|
||||
static jmethodID jProgressiveUpdateData;
|
||||
static jmethodID jsetViewport;
|
||||
static jfieldID jabort;
|
||||
static jfieldID jheight;
|
||||
static jfieldID jscale;
|
||||
static jfieldID jwidth;
|
||||
static jfieldID jx;
|
||||
static jfieldID jy;
|
||||
};
|
||||
|
||||
class ViewTransform : public AutoGlobalWrappedJavaObject {
|
||||
public:
|
||||
static void InitStubs(JNIEnv *jEnv);
|
||||
static ViewTransform* Wrap(jobject obj);
|
||||
ViewTransform(jobject obj, JNIEnv* env) : AutoGlobalWrappedJavaObject(obj, env) {};
|
||||
ViewTransform(jfloat a0, jfloat a1, jfloat a2);
|
||||
jfloat getfixedLayerMarginBottom();
|
||||
void setfixedLayerMarginBottom(jfloat a0);
|
||||
jfloat getfixedLayerMarginLeft();
|
||||
void setfixedLayerMarginLeft(jfloat a0);
|
||||
jfloat getfixedLayerMarginRight();
|
||||
void setfixedLayerMarginRight(jfloat a0);
|
||||
jfloat getfixedLayerMarginTop();
|
||||
void setfixedLayerMarginTop(jfloat a0);
|
||||
jfloat getoffsetX();
|
||||
void setoffsetX(jfloat a0);
|
||||
jfloat getoffsetY();
|
||||
void setoffsetY(jfloat a0);
|
||||
jfloat getscale();
|
||||
void setscale(jfloat a0);
|
||||
jfloat getx();
|
||||
void setx(jfloat a0);
|
||||
jfloat gety();
|
||||
void sety(jfloat a0);
|
||||
ViewTransform() : AutoGlobalWrappedJavaObject() {};
|
||||
protected:
|
||||
static jclass mViewTransformClass;
|
||||
static jmethodID jViewTransform;
|
||||
static jfieldID jfixedLayerMarginBottom;
|
||||
static jfieldID jfixedLayerMarginLeft;
|
||||
static jfieldID jfixedLayerMarginRight;
|
||||
static jfieldID jfixedLayerMarginTop;
|
||||
static jfieldID joffsetX;
|
||||
static jfieldID joffsetY;
|
||||
static jfieldID jscale;
|
||||
static jfieldID jx;
|
||||
static jfieldID jy;
|
||||
};
|
||||
|
||||
class NativeZip : public AutoGlobalWrappedJavaObject {
|
||||
public:
|
||||
static void InitStubs(JNIEnv *jEnv);
|
||||
static NativeZip* Wrap(jobject obj);
|
||||
NativeZip(jobject obj, JNIEnv* env) : AutoGlobalWrappedJavaObject(obj, env) {};
|
||||
jobject CreateInputStream(jobject a0, int32_t a1);
|
||||
NativeZip() : AutoGlobalWrappedJavaObject() {};
|
||||
protected:
|
||||
static jclass mNativeZipClass;
|
||||
static jmethodID jCreateInputStream;
|
||||
};
|
||||
|
||||
class MatrixBlobCursor : public AutoGlobalWrappedJavaObject {
|
||||
public:
|
||||
static void InitStubs(JNIEnv *jEnv);
|
||||
static MatrixBlobCursor* Wrap(jobject obj);
|
||||
MatrixBlobCursor(jobject obj, JNIEnv* env) : AutoGlobalWrappedJavaObject(obj, env) {};
|
||||
MatrixBlobCursor(jobjectArray a0);
|
||||
MatrixBlobCursor(jobjectArray a0, int32_t a1);
|
||||
void AddRow(jobject a0);
|
||||
void AddRow(jobject a0, int32_t a1);
|
||||
void AddRow(jobjectArray a0);
|
||||
MatrixBlobCursor() : AutoGlobalWrappedJavaObject() {};
|
||||
protected:
|
||||
static jclass mMatrixBlobCursorClass;
|
||||
static jmethodID jMatrixBlobCursor;
|
||||
static jmethodID jMatrixBlobCursor0;
|
||||
static jmethodID jAddRow;
|
||||
static jmethodID jAddRow1;
|
||||
static jmethodID jAddRow2;
|
||||
};
|
||||
|
||||
class SQLiteBridgeException : public AutoGlobalWrappedJavaObject {
|
||||
public:
|
||||
static void InitStubs(JNIEnv *jEnv);
|
||||
static SQLiteBridgeException* Wrap(jobject obj);
|
||||
SQLiteBridgeException(jobject obj, JNIEnv* env) : AutoGlobalWrappedJavaObject(obj, env) {};
|
||||
SQLiteBridgeException();
|
||||
SQLiteBridgeException(const nsAString& a0);
|
||||
static int64_t getserialVersionUID();
|
||||
protected:
|
||||
static jclass mSQLiteBridgeExceptionClass;
|
||||
static jmethodID jSQLiteBridgeException;
|
||||
static jmethodID jSQLiteBridgeException0;
|
||||
static jfieldID jserialVersionUID;
|
||||
};
|
||||
|
||||
class Clipboard : public AutoGlobalWrappedJavaObject {
|
||||
public:
|
||||
static void InitStubs(JNIEnv *jEnv);
|
||||
static Clipboard* Wrap(jobject obj);
|
||||
Clipboard(jobject obj, JNIEnv* env) : AutoGlobalWrappedJavaObject(obj, env) {};
|
||||
static void ClearText();
|
||||
static jstring GetClipboardTextWrapper();
|
||||
static bool HasText();
|
||||
static void SetClipboardText(const nsAString& a0);
|
||||
Clipboard() : AutoGlobalWrappedJavaObject() {};
|
||||
protected:
|
||||
static jclass mClipboardClass;
|
||||
static jmethodID jClearText;
|
||||
static jmethodID jGetClipboardTextWrapper;
|
||||
static jmethodID jHasText;
|
||||
static jmethodID jSetClipboardText;
|
||||
};
|
||||
|
||||
|
||||
} /* android */
|
||||
} /* widget */
|
||||
} /* mozilla */
|
||||
#endif
|
||||
void AcknowledgeEvent();
|
||||
void AddPluginViewWrapper(jobject a0, jfloat a1, jfloat a2, jfloat a3, jfloat a4, bool a5);
|
||||
void AlertsProgressListener_OnProgress(const nsAString& a0, int64_t a1, int64_t a2, const nsAString& a3);
|
||||
void CancelVibrate();
|
||||
void CheckURIVisited(const nsAString& a0);
|
||||
void ClearMessageList(int32_t a0);
|
||||
void CloseCamera();
|
||||
void CloseNotification(const nsAString& a0);
|
||||
void CreateMessageListWrapper(int64_t a0, int64_t a1, jobjectArray a2, int32_t a3, int32_t a4, bool a5, int32_t a6);
|
||||
void CreateShortcut(const nsAString& a0, const nsAString& a1, const nsAString& a2, const nsAString& a3);
|
||||
void DeleteMessageWrapper(int32_t a0, int32_t a1);
|
||||
void DisableBatteryNotifications();
|
||||
void DisableNetworkNotifications();
|
||||
void DisableScreenOrientationNotifications();
|
||||
void DisableSensor(int32_t a0);
|
||||
void EnableBatteryNotifications();
|
||||
void EnableLocation(bool a0);
|
||||
void EnableLocationHighAccuracy(bool a0);
|
||||
void EnableNetworkNotifications();
|
||||
void EnableScreenOrientationNotifications();
|
||||
void EnableSensor(int32_t a0);
|
||||
jobject GetContext();
|
||||
jdoubleArray GetCurrentBatteryInformationWrapper();
|
||||
jdoubleArray GetCurrentNetworkInformationWrapper();
|
||||
jfloat GetDensity();
|
||||
int32_t GetDpiWrapper();
|
||||
jstring GetExtensionFromMimeTypeWrapper(const nsAString& a0);
|
||||
jstring GetGfxInfoDataWrapper();
|
||||
jobjectArray GetHandlersForMimeTypeWrapper(const nsAString& a0, const nsAString& a1);
|
||||
jobjectArray GetHandlersForURLWrapper(const nsAString& a0, const nsAString& a1);
|
||||
jbyteArray GetIconForExtensionWrapper(const nsAString& a0, int32_t a1);
|
||||
void GetMessageWrapper(int32_t a0, int32_t a1);
|
||||
jstring GetMimeTypeFromExtensionsWrapper(const nsAString& a0);
|
||||
void GetNextMessageInListWrapper(int32_t a0, int32_t a1);
|
||||
jstring GetProxyForURIWrapper(const nsAString& a0, const nsAString& a1, const nsAString& a2, int32_t a3);
|
||||
int32_t GetScreenDepthWrapper();
|
||||
int16_t GetScreenOrientationWrapper();
|
||||
bool GetShowPasswordSetting();
|
||||
jintArray GetSystemColoursWrapper();
|
||||
jstring HandleGeckoMessageWrapper(const nsAString& a0);
|
||||
void HideProgressDialog();
|
||||
jintArray InitCameraWrapper(const nsAString& a0, int32_t a1, int32_t a2, int32_t a3);
|
||||
bool IsNetworkLinkKnown();
|
||||
bool IsNetworkLinkUp();
|
||||
bool IsTablet();
|
||||
void KillAnyZombies();
|
||||
void LockScreenOrientation(int32_t a0);
|
||||
void MarkURIVisited(const nsAString& a0);
|
||||
void MoveTaskToBack();
|
||||
void NotifyDefaultPrevented(bool a0);
|
||||
static void NotifyIME(int32_t a0);
|
||||
static void NotifyIMEChange(const nsAString& a0, int32_t a1, int32_t a2, int32_t a3);
|
||||
static void NotifyIMEContext(int32_t a0, const nsAString& a1, const nsAString& a2, const nsAString& a3);
|
||||
void NotifyWakeLockChanged(const nsAString& a0, const nsAString& a1);
|
||||
void NotifyXreExit();
|
||||
bool OpenUriExternal(const nsAString& a0, const nsAString& a1, const nsAString& a2 = EmptyString(), const nsAString& a3 = EmptyString(), const nsAString& a4 = EmptyString(), const nsAString& a5 = EmptyString());
|
||||
void PerformHapticFeedback(bool a0);
|
||||
bool PumpMessageLoop();
|
||||
void RegisterSurfaceTextureFrameListener(jobject a0, int32_t a1);
|
||||
void RemovePluginView(jobject a0, bool a1);
|
||||
void ScanMedia(const nsAString& a0, const nsAString& a1);
|
||||
void ScheduleRestart();
|
||||
void SendMessageWrapper(const nsAString& a0, const nsAString& a1, int32_t a2);
|
||||
void SetFullScreen(bool a0);
|
||||
void SetKeepScreenOn(bool a0);
|
||||
void SetSelectedLocale(const nsAString& a0);
|
||||
void SetURITitle(const nsAString& a0, const nsAString& a1);
|
||||
void ShowAlertNotificationWrapper(const nsAString& a0, const nsAString& a1, const nsAString& a2, const nsAString& a3, const nsAString& a4);
|
||||
void ShowFilePickerAsyncWrapper(const nsAString& a0, int64_t a1);
|
||||
jstring ShowFilePickerForExtensionsWrapper(const nsAString& a0);
|
||||
jstring ShowFilePickerForMimeTypeWrapper(const nsAString& a0);
|
||||
void ShowInputMethodPicker();
|
||||
bool UnlockProfile();
|
||||
void UnlockScreenOrientation();
|
||||
void UnregisterSurfaceTextureFrameListener(jobject a0);
|
||||
void Vibrate1(int64_t a0);
|
||||
void VibrateA(jlongArray a0, int32_t a1);
|
||||
jstring GetFrameNameJavaProfilingWrapper(int32_t a0, int32_t a1, int32_t a2);
|
||||
jdouble GetSampleTimeJavaProfiling(int32_t a0, int32_t a1);
|
||||
jstring GetThreadNameJavaProfilingWrapper(int32_t a0);
|
||||
void PauseJavaProfiling();
|
||||
void StartJavaProfiling(int32_t a0, int32_t a1);
|
||||
void StopJavaProfiling();
|
||||
void UnpauseJavaProfiling();
|
||||
void SendThumbnail(jobject a0, int32_t a1, bool a2);
|
||||
jobject ProvideEGLSurfaceWrapper(jobject aTarget);
|
||||
jobject RegisterCompositorWrapper();
|
||||
void PostDelayedCallbackWrapper(jobject aTarget, int64_t a0);
|
||||
void RequestContentRepaintWrapper(jobject aTarget, jfloat a0, jfloat a1, jfloat a2, jfloat a3, jfloat a4);
|
||||
jstring GetClipboardTextWrapper();
|
||||
void SetClipboardText(const nsAString& a0);
|
||||
|
@ -35,7 +35,6 @@
|
||||
#include "prenv.h"
|
||||
|
||||
#include "AndroidBridge.h"
|
||||
#include "AndroidBridgeUtilities.h"
|
||||
#include <android/log.h>
|
||||
#include <pthread.h>
|
||||
#include <wchar.h>
|
||||
@ -84,20 +83,20 @@ public:
|
||||
nsCOMPtr<nsIBrowserTab> tab;
|
||||
mBrowserApp->GetBrowserTab(mTabId, getter_AddRefs(tab));
|
||||
if (!tab) {
|
||||
ThumbnailHelper::SendThumbnail(buffer, mTabId, false);
|
||||
AndroidBridge::Bridge()->SendThumbnail(buffer, mTabId, false);
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
tab->GetWindow(getter_AddRefs(domWindow));
|
||||
if (!domWindow) {
|
||||
ThumbnailHelper::SendThumbnail(buffer, mTabId, false);
|
||||
AndroidBridge::Bridge()->SendThumbnail(buffer, mTabId, false);
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
NS_ASSERTION(mPoints.Length() == 1, "Thumbnail event does not have enough coordinates");
|
||||
|
||||
nsresult rv = AndroidBridge::Bridge()->CaptureThumbnail(domWindow, mPoints[0].x, mPoints[0].y, mTabId, buffer);
|
||||
ThumbnailHelper::SendThumbnail(buffer, mTabId, NS_SUCCEEDED(rv));
|
||||
AndroidBridge::Bridge()->SendThumbnail(buffer, mTabId, NS_SUCCEEDED(rv));
|
||||
return rv;
|
||||
}
|
||||
private:
|
||||
@ -112,7 +111,7 @@ class WakeLockListener MOZ_FINAL : public nsIDOMMozWakeLockListener {
|
||||
NS_DECL_ISUPPORTS;
|
||||
|
||||
nsresult Callback(const nsAString& topic, const nsAString& state) {
|
||||
GeckoAppShell::NotifyWakeLockChanged(topic, state);
|
||||
AndroidBridge::Bridge()->NotifyWakeLockChanged(topic, state);
|
||||
return NS_OK;
|
||||
}
|
||||
};
|
||||
@ -204,7 +203,7 @@ nsAppShell::Init()
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
if (match) {
|
||||
GeckoAppShell::SetSelectedLocale(EmptyString());
|
||||
bridge->SetSelectedLocale(EmptyString());
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
@ -214,7 +213,7 @@ nsAppShell::Init()
|
||||
rv = Preferences::GetString(PREFNAME_UA_LOCALE, &locale);
|
||||
}
|
||||
|
||||
GeckoAppShell::SetSelectedLocale(locale);
|
||||
bridge->SetSelectedLocale(locale);
|
||||
mAllowCoalescingTouches = Preferences::GetBool(PREFNAME_COALESCE_TOUCHES, true);
|
||||
return rv;
|
||||
}
|
||||
@ -236,12 +235,17 @@ nsAppShell::Observe(nsISupports* aSubject,
|
||||
NS_LITERAL_STRING(PREFNAME_COALESCE_TOUCHES)) ||
|
||||
nsDependentString(aData).Equals(
|
||||
NS_LITERAL_STRING(PREFNAME_MATCH_OS)))) {
|
||||
AndroidBridge* bridge = AndroidBridge::Bridge();
|
||||
if (!bridge) {
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
bool match;
|
||||
nsresult rv = Preferences::GetBool(PREFNAME_MATCH_OS, &match);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
if (match) {
|
||||
GeckoAppShell::SetSelectedLocale(EmptyString());
|
||||
bridge->SetSelectedLocale(EmptyString());
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
@ -251,7 +255,7 @@ nsAppShell::Observe(nsISupports* aSubject,
|
||||
locale = Preferences::GetString(PREFNAME_UA_LOCALE);
|
||||
}
|
||||
|
||||
GeckoAppShell::SetSelectedLocale(locale);
|
||||
bridge->SetSelectedLocale(locale);
|
||||
|
||||
mAllowCoalescingTouches = Preferences::GetBool(PREFNAME_COALESCE_TOUCHES, true);
|
||||
return NS_OK;
|
||||
@ -402,6 +406,10 @@ nsAppShell::ProcessNextNativeEvent(bool mayWait)
|
||||
if (!mBrowserApp)
|
||||
break;
|
||||
|
||||
AndroidBridge* bridge = AndroidBridge::Bridge();
|
||||
if (!bridge)
|
||||
break;
|
||||
|
||||
int32_t tabId = curEvent->MetaState();
|
||||
const nsTArray<nsIntPoint>& points = curEvent->Points();
|
||||
RefCountedJavaObject* buffer = curEvent->ByteBuffer();
|
||||
@ -593,7 +601,7 @@ nsAppShell::ProcessNextNativeEvent(bool mayWait)
|
||||
}
|
||||
|
||||
if (curEvent->AckNeeded()) {
|
||||
GeckoAppShell::AcknowledgeEvent();
|
||||
AndroidBridge::Bridge()->AcknowledgeEvent();
|
||||
}
|
||||
|
||||
EVLOG("nsAppShell: -- done event %p %d", (void*)curEvent.get(), curEvent->Type());
|
||||
|
@ -44,7 +44,11 @@ nsClipboard::SetData(nsITransferable *aTransferable,
|
||||
supportsString->GetData(buffer);
|
||||
|
||||
if (XRE_GetProcessType() == GeckoProcessType_Default) {
|
||||
Clipboard::SetClipboardText(buffer);
|
||||
if (AndroidBridge::Bridge())
|
||||
AndroidBridge::Bridge()->SetClipboardText(buffer);
|
||||
else
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
|
||||
} else {
|
||||
bool isPrivateData = false;
|
||||
aTransferable->GetIsPrivateData(&isPrivateData);
|
||||
@ -97,7 +101,8 @@ nsClipboard::EmptyClipboard(int32_t aWhichClipboard)
|
||||
if (aWhichClipboard != kGlobalClipboard)
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
if (XRE_GetProcessType() == GeckoProcessType_Default) {
|
||||
Clipboard::ClearText();
|
||||
if (AndroidBridge::Bridge())
|
||||
AndroidBridge::Bridge()->EmptyClipboard();
|
||||
} else {
|
||||
ContentChild::GetSingleton()->SendEmptyClipboard();
|
||||
}
|
||||
@ -114,7 +119,8 @@ nsClipboard::HasDataMatchingFlavors(const char **aFlavorList,
|
||||
if (aWhichClipboard != kGlobalClipboard)
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
if (XRE_GetProcessType() == GeckoProcessType_Default) {
|
||||
*aHasText = Clipboard::HasText();
|
||||
if (AndroidBridge::Bridge())
|
||||
*aHasText = AndroidBridge::Bridge()->ClipboardHasText();
|
||||
} else {
|
||||
ContentChild::GetSingleton()->SendClipboardHasText(aHasText);
|
||||
}
|
||||
|
@ -22,6 +22,6 @@ nsIMEPicker::~nsIMEPicker()
|
||||
/* void show (); */
|
||||
NS_IMETHODIMP nsIMEPicker::Show()
|
||||
{
|
||||
GeckoAppShell::ShowInputMethodPicker();
|
||||
AndroidBridge::Bridge()->ShowInputMethodPicker();
|
||||
return NS_OK;
|
||||
}
|
||||
|
@ -464,7 +464,10 @@ nsLookAndFeel::GetEchoPasswordImpl()
|
||||
{
|
||||
if (!mInitializedShowPassword) {
|
||||
if (XRE_GetProcessType() == GeckoProcessType_Default) {
|
||||
mShowPassword = GeckoAppShell::GetShowPasswordSetting();
|
||||
if (AndroidBridge::Bridge())
|
||||
mShowPassword = AndroidBridge::Bridge()->GetShowPasswordSetting();
|
||||
else
|
||||
NS_ASSERTION(AndroidBridge::Bridge() != nullptr, "AndroidBridge is not available!");
|
||||
} else {
|
||||
ContentChild::GetSingleton()->SendGetShowPasswordSetting(&mShowPassword);
|
||||
}
|
||||
|
@ -59,7 +59,7 @@ nsScreenAndroid::GetColorDepth(int32_t *aColorDepth)
|
||||
void
|
||||
nsScreenAndroid::ApplyMinimumBrightness(uint32_t aBrightness)
|
||||
{
|
||||
GeckoAppShell::SetKeepScreenOn(aBrightness == BRIGHTNESS_FULL);
|
||||
AndroidBridge::Bridge()->SetKeepScreenOn(aBrightness == BRIGHTNESS_FULL);
|
||||
}
|
||||
|
||||
NS_IMPL_ISUPPORTS1(nsScreenManagerAndroid, nsIScreenManager)
|
||||
|
@ -52,7 +52,6 @@ using mozilla::unused;
|
||||
#include "nsTArray.h"
|
||||
|
||||
#include "AndroidBridge.h"
|
||||
#include "AndroidBridgeUtilities.h"
|
||||
#include "android_npapi.h"
|
||||
|
||||
#include "imgIEncoder.h"
|
||||
@ -210,6 +209,11 @@ nsWindow::Create(nsIWidget *aParent,
|
||||
{
|
||||
ALOG("nsWindow[%p]::Create %p [%d %d %d %d]", (void*)this, (void*)aParent, aRect.x, aRect.y, aRect.width, aRect.height);
|
||||
nsWindow *parent = (nsWindow*) aParent;
|
||||
|
||||
if (!AndroidBridge::Bridge()) {
|
||||
aNativeParent = nullptr;
|
||||
}
|
||||
|
||||
if (aNativeParent) {
|
||||
if (parent) {
|
||||
ALOG("Ignoring native parent on Android window [%p], since parent was specified (%p %p)", (void*)this, (void*)aNativeParent, (void*)aParent);
|
||||
@ -349,7 +353,9 @@ nsWindow::GetDefaultScaleInternal()
|
||||
return density;
|
||||
}
|
||||
|
||||
density = GeckoAppShell::GetDensity();
|
||||
if (AndroidBridge::Bridge()) {
|
||||
density = AndroidBridge::Bridge()->GetDensity();
|
||||
}
|
||||
|
||||
if (!density) {
|
||||
density = 1.0;
|
||||
@ -513,7 +519,7 @@ nsWindow::SetSizeMode(int32_t aMode)
|
||||
{
|
||||
switch (aMode) {
|
||||
case nsSizeMode_Minimized:
|
||||
GeckoAppShell::MoveTaskToBack();
|
||||
AndroidBridge::Bridge()->MoveTaskToBack();
|
||||
break;
|
||||
case nsSizeMode_Fullscreen:
|
||||
MakeFullScreen(true);
|
||||
@ -565,6 +571,9 @@ nsWindow::SetFocus(bool aRaise)
|
||||
ALOG("nsWindow::SetFocus: can't set focus without raising, ignoring aRaise = false!");
|
||||
}
|
||||
|
||||
if (!AndroidBridge::Bridge())
|
||||
return NS_OK;
|
||||
|
||||
nsWindow *top = FindTopLevel();
|
||||
top->mFocus = this;
|
||||
top->BringToFront();
|
||||
@ -691,7 +700,7 @@ nsWindow::DispatchEvent(nsGUIEvent *aEvent)
|
||||
NS_IMETHODIMP
|
||||
nsWindow::MakeFullScreen(bool aFullScreen)
|
||||
{
|
||||
GeckoAppShell::SetFullScreen(aFullScreen);
|
||||
AndroidBridge::Bridge()->SetFullScreen(aFullScreen);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
@ -760,6 +769,9 @@ nsWindow::CreateLayerManager(int aCompositorWidth, int aCompositorHeight)
|
||||
void
|
||||
nsWindow::OnGlobalAndroidEvent(AndroidGeckoEvent *ae)
|
||||
{
|
||||
if (!AndroidBridge::Bridge())
|
||||
return;
|
||||
|
||||
nsWindow *win = TopWindow();
|
||||
if (!win)
|
||||
return;
|
||||
@ -937,6 +949,9 @@ nsWindow::OnGlobalAndroidEvent(AndroidGeckoEvent *ae)
|
||||
void
|
||||
nsWindow::OnAndroidEvent(AndroidGeckoEvent *ae)
|
||||
{
|
||||
if (!AndroidBridge::Bridge())
|
||||
return;
|
||||
|
||||
switch (ae->Type()) {
|
||||
case AndroidGeckoEvent::DRAW:
|
||||
OnDraw(ae);
|
||||
@ -1233,7 +1248,7 @@ bool nsWindow::OnMultitouchEvent(AndroidGeckoEvent *ae)
|
||||
// if this event is a down event, that means it's the start of a new block, and the
|
||||
// previous block should not be default-prevented
|
||||
bool defaultPrevented = isDownEvent ? false : preventDefaultActions;
|
||||
GeckoAppShell::NotifyDefaultPrevented(defaultPrevented);
|
||||
AndroidBridge::Bridge()->NotifyDefaultPrevented(defaultPrevented);
|
||||
sDefaultPreventedNotified = true;
|
||||
}
|
||||
|
||||
@ -1242,7 +1257,7 @@ bool nsWindow::OnMultitouchEvent(AndroidGeckoEvent *ae)
|
||||
// for the next event.
|
||||
if (isDownEvent) {
|
||||
if (preventDefaultActions) {
|
||||
GeckoAppShell::NotifyDefaultPrevented(true);
|
||||
AndroidBridge::Bridge()->NotifyDefaultPrevented(true);
|
||||
sDefaultPreventedNotified = true;
|
||||
} else {
|
||||
sDefaultPreventedNotified = false;
|
||||
@ -1844,10 +1859,10 @@ nsWindow::OnIMEEvent(AndroidGeckoEvent *ae)
|
||||
NotifyIMEOfTextChange(0, INT32_MAX / 2, INT32_MAX / 2);
|
||||
FlushIMEChanges();
|
||||
}
|
||||
GeckoAppShell::NotifyIME(AndroidBridge::NOTIFY_IME_REPLY_EVENT);
|
||||
AndroidBridge::NotifyIME(AndroidBridge::NOTIFY_IME_REPLY_EVENT);
|
||||
return;
|
||||
} else if (ae->Action() == AndroidGeckoEvent::IME_UPDATE_CONTEXT) {
|
||||
GeckoAppShell::NotifyIMEContext(mInputContext.mIMEState.mEnabled,
|
||||
AndroidBridge::NotifyIMEContext(mInputContext.mIMEState.mEnabled,
|
||||
mInputContext.mHTMLInputType,
|
||||
mInputContext.mHTMLInputInputmode,
|
||||
mInputContext.mActionHint);
|
||||
@ -1858,7 +1873,7 @@ nsWindow::OnIMEEvent(AndroidGeckoEvent *ae)
|
||||
// Still reply to events, but don't do anything else
|
||||
if (ae->Action() == AndroidGeckoEvent::IME_SYNCHRONIZE ||
|
||||
ae->Action() == AndroidGeckoEvent::IME_REPLACE_TEXT) {
|
||||
GeckoAppShell::NotifyIME(AndroidBridge::NOTIFY_IME_REPLY_EVENT);
|
||||
AndroidBridge::NotifyIME(AndroidBridge::NOTIFY_IME_REPLY_EVENT);
|
||||
}
|
||||
return;
|
||||
}
|
||||
@ -1871,7 +1886,7 @@ nsWindow::OnIMEEvent(AndroidGeckoEvent *ae)
|
||||
case AndroidGeckoEvent::IME_SYNCHRONIZE:
|
||||
{
|
||||
FlushIMEChanges();
|
||||
GeckoAppShell::NotifyIME(AndroidBridge::NOTIFY_IME_REPLY_EVENT);
|
||||
AndroidBridge::NotifyIME(AndroidBridge::NOTIFY_IME_REPLY_EVENT);
|
||||
}
|
||||
break;
|
||||
case AndroidGeckoEvent::IME_REPLACE_TEXT:
|
||||
@ -1903,7 +1918,7 @@ nsWindow::OnIMEEvent(AndroidGeckoEvent *ae)
|
||||
}
|
||||
mIMEKeyEvents.Clear();
|
||||
FlushIMEChanges();
|
||||
GeckoAppShell::NotifyIME(AndroidBridge::NOTIFY_IME_REPLY_EVENT);
|
||||
AndroidBridge::NotifyIME(AndroidBridge::NOTIFY_IME_REPLY_EVENT);
|
||||
break;
|
||||
}
|
||||
|
||||
@ -1925,7 +1940,7 @@ nsWindow::OnIMEEvent(AndroidGeckoEvent *ae)
|
||||
DispatchEvent(&event);
|
||||
}
|
||||
FlushIMEChanges();
|
||||
GeckoAppShell::NotifyIME(AndroidBridge::NOTIFY_IME_REPLY_EVENT);
|
||||
AndroidBridge::NotifyIME(AndroidBridge::NOTIFY_IME_REPLY_EVENT);
|
||||
}
|
||||
break;
|
||||
case AndroidGeckoEvent::IME_SET_SELECTION:
|
||||
@ -2103,7 +2118,7 @@ nsWindow::NotifyIME(NotificationToIME aNotification)
|
||||
case REQUEST_TO_COMMIT_COMPOSITION:
|
||||
//ALOGIME("IME: REQUEST_TO_COMMIT_COMPOSITION: s=%d", aState);
|
||||
RemoveIMEComposition();
|
||||
GeckoAppShell::NotifyIME(REQUEST_TO_COMMIT_COMPOSITION);
|
||||
AndroidBridge::NotifyIME(REQUEST_TO_COMMIT_COMPOSITION);
|
||||
return NS_OK;
|
||||
case REQUEST_TO_CANCEL_COMPOSITION:
|
||||
ALOGIME("IME: REQUEST_TO_CANCEL_COMPOSITION");
|
||||
@ -2121,11 +2136,11 @@ nsWindow::NotifyIME(NotificationToIME aNotification)
|
||||
DispatchEvent(&compEvent);
|
||||
}
|
||||
|
||||
GeckoAppShell::NotifyIME(REQUEST_TO_CANCEL_COMPOSITION);
|
||||
AndroidBridge::NotifyIME(REQUEST_TO_CANCEL_COMPOSITION);
|
||||
return NS_OK;
|
||||
case NOTIFY_IME_OF_FOCUS:
|
||||
ALOGIME("IME: NOTIFY_IME_OF_FOCUS");
|
||||
GeckoAppShell::NotifyIME(NOTIFY_IME_OF_FOCUS);
|
||||
AndroidBridge::NotifyIME(NOTIFY_IME_OF_FOCUS);
|
||||
return NS_OK;
|
||||
case NOTIFY_IME_OF_BLUR:
|
||||
ALOGIME("IME: NOTIFY_IME_OF_BLUR");
|
||||
@ -2137,7 +2152,7 @@ nsWindow::NotifyIME(NotificationToIME aNotification)
|
||||
mIMEComposing = false;
|
||||
mIMEComposingText.Truncate();
|
||||
|
||||
GeckoAppShell::NotifyIME(NOTIFY_IME_OF_BLUR);
|
||||
AndroidBridge::NotifyIME(NOTIFY_IME_OF_BLUR);
|
||||
return NS_OK;
|
||||
case NOTIFY_IME_OF_SELECTION_CHANGE:
|
||||
if (mIMEMaskSelectionUpdate) {
|
||||
@ -2197,7 +2212,7 @@ nsWindow::SetInputContext(const InputContext& aContext,
|
||||
|
||||
if (enabled == IMEState::ENABLED && aAction.UserMightRequestOpenVKB()) {
|
||||
// Don't reset keyboard when we should simply open the vkb
|
||||
GeckoAppShell::NotifyIME(AndroidBridge::NOTIFY_IME_OPEN_VKB);
|
||||
AndroidBridge::NotifyIME(AndroidBridge::NOTIFY_IME_OPEN_VKB);
|
||||
return;
|
||||
}
|
||||
|
||||
@ -2253,7 +2268,7 @@ nsWindow::FlushIMEChanges()
|
||||
if (!event.mSucceeded)
|
||||
return;
|
||||
|
||||
GeckoAppShell::NotifyIMEChange(event.mReply.mString,
|
||||
AndroidBridge::NotifyIMEChange(event.mReply.mString,
|
||||
change.mStart,
|
||||
change.mOldEnd,
|
||||
change.mNewEnd);
|
||||
@ -2268,7 +2283,7 @@ nsWindow::FlushIMEChanges()
|
||||
if (!event.mSucceeded)
|
||||
return;
|
||||
|
||||
GeckoAppShell::NotifyIMEChange(EmptyString(),
|
||||
AndroidBridge::NotifyIMEChange(EmptyString(),
|
||||
(int32_t) event.GetSelectionStart(),
|
||||
(int32_t) event.GetSelectionEnd(), -1);
|
||||
mIMESelectionChanged = false;
|
||||
@ -2363,47 +2378,44 @@ nsWindow::DrawWindowUnderlay(LayerManager* aManager, nsIntRect aRect)
|
||||
{
|
||||
JNIEnv *env = GetJNIForThread();
|
||||
NS_ABORT_IF_FALSE(env, "No JNI environment at DrawWindowUnderlay()!");
|
||||
if (!env) {
|
||||
if (!env)
|
||||
return;
|
||||
}
|
||||
|
||||
AutoLocalJNIFrame jniFrame(env);
|
||||
|
||||
GeckoLayerClient* client = AndroidBridge::Bridge()->GetLayerClient();
|
||||
if (!client || client->isNull()) {
|
||||
ALOG_BRIDGE("Exceptional Exit: %s", __PRETTY_FUNCTION__);
|
||||
AndroidGeckoLayerClient& client = AndroidBridge::Bridge()->GetLayerClient();
|
||||
if (!client.CreateFrame(&jniFrame, mLayerRendererFrame)) return;
|
||||
|
||||
if (!WidgetPaintsBackground())
|
||||
return;
|
||||
}
|
||||
|
||||
jobject frameObj = client->CreateFrame();
|
||||
NS_ABORT_IF_FALSE(frameObj, "No frame object!");
|
||||
|
||||
mLayerRendererFrame.Init(frameObj, env);
|
||||
if (!WidgetPaintsBackground()) {
|
||||
return;
|
||||
}
|
||||
|
||||
client->ActivateProgram();
|
||||
mLayerRendererFrame.BeginDrawing();
|
||||
mLayerRendererFrame.DrawBackground();
|
||||
client->DeactivateProgram(); // redundant, but in case somebody adds code after this...
|
||||
if (!client.ActivateProgram(&jniFrame)) return;
|
||||
if (!mLayerRendererFrame.BeginDrawing(&jniFrame)) return;
|
||||
if (!mLayerRendererFrame.DrawBackground(&jniFrame)) return;
|
||||
if (!client.DeactivateProgram(&jniFrame)) return; // redundant, but in case somebody adds code after this...
|
||||
}
|
||||
|
||||
void
|
||||
nsWindow::DrawWindowOverlay(LayerManager* aManager, nsIntRect aRect)
|
||||
{
|
||||
PROFILER_LABEL("nsWindow", "DrawWindowOverlay");
|
||||
JNIEnv *env = GetJNIForThread();
|
||||
NS_ABORT_IF_FALSE(env, "No JNI environment at DrawWindowOverlay()!");
|
||||
if (!env)
|
||||
return;
|
||||
|
||||
AutoLocalJNIFrame jniFrame(env);
|
||||
|
||||
NS_ABORT_IF_FALSE(!mLayerRendererFrame.isNull(),
|
||||
"Frame should have been created in DrawWindowUnderlay()!");
|
||||
|
||||
GeckoLayerClient* client = AndroidBridge::Bridge()->GetLayerClient();
|
||||
AndroidGeckoLayerClient& client = AndroidBridge::Bridge()->GetLayerClient();
|
||||
|
||||
client->ActivateProgram();
|
||||
mLayerRendererFrame.DrawForeground();
|
||||
mLayerRendererFrame.EndDrawing();
|
||||
client->DeactivateProgram();
|
||||
mLayerRendererFrame.Dispose();
|
||||
if (!client.ActivateProgram(&jniFrame)) return;
|
||||
if (!mLayerRendererFrame.DrawForeground(&jniFrame)) return;
|
||||
if (!mLayerRendererFrame.EndDrawing(&jniFrame)) return;
|
||||
if (!client.DeactivateProgram(&jniFrame)) return;
|
||||
mLayerRendererFrame.Dispose(env);
|
||||
}
|
||||
|
||||
// off-main-thread compositor fields and functions
|
||||
|
@ -11,7 +11,6 @@
|
||||
#include "nsIIdleServiceInternal.h"
|
||||
#include "nsTArray.h"
|
||||
#include "AndroidJavaWrappers.h"
|
||||
#include "GeneratedJNIWrappers.h"
|
||||
#include "mozilla/StaticPtr.h"
|
||||
#include "mozilla/TextEvents.h"
|
||||
|
||||
@ -233,7 +232,7 @@ private:
|
||||
void CreateLayerManager(int aCompositorWidth, int aCompositorHeight);
|
||||
void RedrawAll();
|
||||
|
||||
mozilla::widget::android::LayerRendererFrame mLayerRendererFrame;
|
||||
mozilla::AndroidLayerRendererFrame mLayerRendererFrame;
|
||||
|
||||
static mozilla::StaticRefPtr<mozilla::layers::APZCTreeManager> sApzcTreeManager;
|
||||
static mozilla::StaticRefPtr<mozilla::layers::LayerManager> sLayerManager;
|
||||
|
@ -22,7 +22,6 @@
|
||||
|
||||
#ifdef MOZ_WIDGET_ANDROID
|
||||
#include "AndroidBridge.h"
|
||||
using namespace mozilla::widget::android;
|
||||
#endif
|
||||
|
||||
#ifdef MOZ_WIDGET_GONK
|
||||
@ -142,7 +141,7 @@ nsSystemInfo::Init()
|
||||
android_sdk_version = version;
|
||||
if (version >= 8 && mozilla::AndroidBridge::Bridge()->GetStaticStringField("android/os/Build", "HARDWARE", str))
|
||||
SetPropertyAsAString(NS_LITERAL_STRING("hardware"), str);
|
||||
bool isTablet = GeckoAppShell::IsTablet();
|
||||
bool isTablet = mozilla::AndroidBridge::Bridge()->IsTablet();
|
||||
SetPropertyAsBool(NS_LITERAL_STRING("tablet"), isTablet);
|
||||
// NSPR "version" is the kernel version. For Android we want the Android version.
|
||||
// Rename SDK version to version and put the kernel version into kernel_version.
|
||||
|
@ -472,7 +472,7 @@ ParseManifest(NSLocationType type, FileLocation &file, char* buf, bool aChromeOn
|
||||
bool isTablet = false;
|
||||
if (mozilla::AndroidBridge::Bridge()) {
|
||||
mozilla::AndroidBridge::Bridge()->GetStaticStringField("android/os/Build$VERSION", "RELEASE", osVersion);
|
||||
isTablet = mozilla::widget::android::GeckoAppShell::IsTablet();
|
||||
isTablet = mozilla::AndroidBridge::Bridge()->IsTablet();
|
||||
}
|
||||
#endif
|
||||
|
||||
|
@ -1809,7 +1809,8 @@ nsLocalFile::Launch()
|
||||
|
||||
nsDependentCString fileUri = NS_LITERAL_CSTRING("file://");
|
||||
fileUri.Append(mPath);
|
||||
return GeckoAppShell::OpenUriExternal(NS_ConvertUTF8toUTF16(fileUri), NS_ConvertUTF8toUTF16(type)) ? NS_OK : NS_ERROR_FAILURE;
|
||||
mozilla::AndroidBridge* bridge = mozilla::AndroidBridge::Bridge();
|
||||
return bridge->OpenUriExternal(NS_ConvertUTF8toUTF16(fileUri), NS_ConvertUTF8toUTF16(type)) ? NS_OK : NS_ERROR_FAILURE;
|
||||
#elif defined(MOZ_WIDGET_COCOA)
|
||||
CFURLRef url;
|
||||
if (NS_SUCCEEDED(GetCFURL(&url))) {
|
||||
|
Loading…
Reference in New Issue
Block a user