2010-06-03 13:56:36 -07:00
|
|
|
/* -*- Mode: c++; c-basic-offset: 4; tab-width: 20; indent-tabs-mode: nil; -*-
|
2012-05-21 04:12:37 -07:00
|
|
|
* 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/. */
|
2010-06-03 13:56:36 -07:00
|
|
|
|
|
|
|
#include "AndroidJavaWrappers.h"
|
|
|
|
#include "AndroidBridge.h"
|
2013-09-09 05:57:36 -07:00
|
|
|
#include "AndroidBridgeUtilities.h"
|
2012-09-12 14:47:08 -07:00
|
|
|
#include "nsIAndroidBridge.h"
|
2013-04-09 15:56:03 -07:00
|
|
|
#include "nsIDOMKeyEvent.h"
|
2013-05-17 13:17:53 -07:00
|
|
|
#include "nsIWidget.h"
|
|
|
|
#include "nsGUIEvent.h"
|
2010-06-03 13:56:36 -07:00
|
|
|
|
|
|
|
using namespace mozilla;
|
2013-05-17 13:17:53 -07:00
|
|
|
using namespace mozilla::dom;
|
2010-06-03 13:56:36 -07:00
|
|
|
|
|
|
|
jclass AndroidGeckoEvent::jGeckoEventClass = 0;
|
|
|
|
jfieldID AndroidGeckoEvent::jActionField = 0;
|
|
|
|
jfieldID AndroidGeckoEvent::jTypeField = 0;
|
2013-03-10 15:43:30 -07:00
|
|
|
jfieldID AndroidGeckoEvent::jAckNeededField = 0;
|
2010-06-03 13:56:36 -07:00
|
|
|
jfieldID AndroidGeckoEvent::jTimeField = 0;
|
2012-01-24 16:31:33 -08:00
|
|
|
jfieldID AndroidGeckoEvent::jPoints = 0;
|
|
|
|
jfieldID AndroidGeckoEvent::jPointIndicies = 0;
|
|
|
|
jfieldID AndroidGeckoEvent::jPressures = 0;
|
|
|
|
jfieldID AndroidGeckoEvent::jPointRadii = 0;
|
|
|
|
jfieldID AndroidGeckoEvent::jOrientations = 0;
|
2011-06-19 22:36:17 -07:00
|
|
|
jfieldID AndroidGeckoEvent::jXField = 0;
|
|
|
|
jfieldID AndroidGeckoEvent::jYField = 0;
|
|
|
|
jfieldID AndroidGeckoEvent::jZField = 0;
|
2011-10-29 03:35:29 -07:00
|
|
|
jfieldID AndroidGeckoEvent::jDistanceField = 0;
|
2010-06-03 13:56:36 -07:00
|
|
|
jfieldID AndroidGeckoEvent::jRectField = 0;
|
|
|
|
jfieldID AndroidGeckoEvent::jNativeWindowField = 0;
|
|
|
|
|
|
|
|
jfieldID AndroidGeckoEvent::jCharactersField = 0;
|
2011-11-14 19:12:14 -08:00
|
|
|
jfieldID AndroidGeckoEvent::jCharactersExtraField = 0;
|
2013-06-15 14:40:27 -07:00
|
|
|
jfieldID AndroidGeckoEvent::jDataField = 0;
|
2010-06-03 13:56:36 -07:00
|
|
|
jfieldID AndroidGeckoEvent::jKeyCodeField = 0;
|
|
|
|
jfieldID AndroidGeckoEvent::jMetaStateField = 0;
|
2012-09-12 17:48:29 -07:00
|
|
|
jfieldID AndroidGeckoEvent::jDomKeyLocationField = 0;
|
2010-06-03 13:56:36 -07:00
|
|
|
jfieldID AndroidGeckoEvent::jFlagsField = 0;
|
|
|
|
jfieldID AndroidGeckoEvent::jUnicodeCharField = 0;
|
2013-03-29 07:54:01 -07:00
|
|
|
jfieldID AndroidGeckoEvent::jBaseUnicodeCharField = 0;
|
2012-04-19 13:55:33 -07:00
|
|
|
jfieldID AndroidGeckoEvent::jRepeatCountField = 0;
|
2010-06-03 13:56:36 -07:00
|
|
|
jfieldID AndroidGeckoEvent::jCountField = 0;
|
2012-11-01 13:11:02 -07:00
|
|
|
jfieldID AndroidGeckoEvent::jStartField = 0;
|
|
|
|
jfieldID AndroidGeckoEvent::jEndField = 0;
|
2012-01-24 16:31:33 -08:00
|
|
|
jfieldID AndroidGeckoEvent::jPointerIndexField = 0;
|
2010-08-04 12:47:26 -07:00
|
|
|
jfieldID AndroidGeckoEvent::jRangeTypeField = 0;
|
|
|
|
jfieldID AndroidGeckoEvent::jRangeStylesField = 0;
|
2012-12-06 11:35:59 -08:00
|
|
|
jfieldID AndroidGeckoEvent::jRangeLineStyleField = 0;
|
|
|
|
jfieldID AndroidGeckoEvent::jRangeBoldLineField = 0;
|
2010-08-04 12:47:26 -07:00
|
|
|
jfieldID AndroidGeckoEvent::jRangeForeColorField = 0;
|
|
|
|
jfieldID AndroidGeckoEvent::jRangeBackColorField = 0;
|
2012-12-06 11:35:59 -08:00
|
|
|
jfieldID AndroidGeckoEvent::jRangeLineColorField = 0;
|
2010-06-04 14:14:43 -07:00
|
|
|
jfieldID AndroidGeckoEvent::jLocationField = 0;
|
2012-01-17 10:40:39 -08:00
|
|
|
jfieldID AndroidGeckoEvent::jBandwidthField = 0;
|
|
|
|
jfieldID AndroidGeckoEvent::jCanBeMeteredField = 0;
|
2013-07-11 08:39:36 -07:00
|
|
|
jfieldID AndroidGeckoEvent::jIsWifiField = 0;
|
|
|
|
jfieldID AndroidGeckoEvent::jDHCPGatewayField = 0;
|
2012-03-20 06:09:45 -07:00
|
|
|
jfieldID AndroidGeckoEvent::jScreenOrientationField = 0;
|
2012-06-14 09:08:51 -07:00
|
|
|
jfieldID AndroidGeckoEvent::jByteBufferField = 0;
|
2013-03-20 15:45:07 -07:00
|
|
|
jfieldID AndroidGeckoEvent::jWidthField = 0;
|
|
|
|
jfieldID AndroidGeckoEvent::jHeightField = 0;
|
2013-09-04 06:58:08 -07:00
|
|
|
jfieldID AndroidGeckoEvent::jPrefNamesField = 0;
|
2010-06-03 13:56:36 -07:00
|
|
|
|
2013-04-09 15:56:03 -07:00
|
|
|
jclass AndroidGeckoEvent::jDomKeyLocationClass = 0;
|
|
|
|
jfieldID AndroidGeckoEvent::jDomKeyLocationValueField = 0;
|
|
|
|
|
2010-06-03 13:56:36 -07:00
|
|
|
jclass AndroidPoint::jPointClass = 0;
|
|
|
|
jfieldID AndroidPoint::jXField = 0;
|
|
|
|
jfieldID AndroidPoint::jYField = 0;
|
|
|
|
|
|
|
|
jclass AndroidRect::jRectClass = 0;
|
|
|
|
jfieldID AndroidRect::jBottomField = 0;
|
|
|
|
jfieldID AndroidRect::jLeftField = 0;
|
|
|
|
jfieldID AndroidRect::jRightField = 0;
|
|
|
|
jfieldID AndroidRect::jTopField = 0;
|
|
|
|
|
2012-09-12 14:47:08 -07:00
|
|
|
jclass AndroidRectF::jRectClass = 0;
|
|
|
|
jfieldID AndroidRectF::jBottomField = 0;
|
|
|
|
jfieldID AndroidRectF::jLeftField = 0;
|
|
|
|
jfieldID AndroidRectF::jRightField = 0;
|
|
|
|
jfieldID AndroidRectF::jTopField = 0;
|
|
|
|
|
2010-06-04 14:14:43 -07:00
|
|
|
jclass AndroidLocation::jLocationClass = 0;
|
|
|
|
jmethodID AndroidLocation::jGetLatitudeMethod = 0;
|
|
|
|
jmethodID AndroidLocation::jGetLongitudeMethod = 0;
|
|
|
|
jmethodID AndroidLocation::jGetAltitudeMethod = 0;
|
|
|
|
jmethodID AndroidLocation::jGetAccuracyMethod = 0;
|
|
|
|
jmethodID AndroidLocation::jGetBearingMethod = 0;
|
|
|
|
jmethodID AndroidLocation::jGetSpeedMethod = 0;
|
|
|
|
jmethodID AndroidLocation::jGetTimeMethod = 0;
|
|
|
|
|
2012-02-02 22:07:05 -08:00
|
|
|
jclass AndroidGeckoLayerClient::jGeckoLayerClientClass = 0;
|
2012-09-12 14:47:08 -07:00
|
|
|
jclass AndroidGeckoLayerClient::jViewportClass = 0;
|
|
|
|
jclass AndroidGeckoLayerClient::jDisplayportClass = 0;
|
2012-03-12 08:50:21 -07:00
|
|
|
jmethodID AndroidGeckoLayerClient::jSetFirstPaintViewport = 0;
|
2012-05-23 07:51:39 -07:00
|
|
|
jmethodID AndroidGeckoLayerClient::jSetPageRect = 0;
|
2012-03-17 08:08:22 -07:00
|
|
|
jmethodID AndroidGeckoLayerClient::jSyncViewportInfoMethod = 0;
|
2013-04-26 10:26:39 -07:00
|
|
|
jmethodID AndroidGeckoLayerClient::jSyncFrameMetricsMethod = 0;
|
2012-02-22 11:45:44 -08:00
|
|
|
jmethodID AndroidGeckoLayerClient::jCreateFrameMethod = 0;
|
|
|
|
jmethodID AndroidGeckoLayerClient::jActivateProgramMethod = 0;
|
|
|
|
jmethodID AndroidGeckoLayerClient::jDeactivateProgramMethod = 0;
|
2012-09-12 14:47:08 -07:00
|
|
|
jmethodID AndroidGeckoLayerClient::jGetDisplayPort = 0;
|
2013-05-30 06:55:23 -07:00
|
|
|
jmethodID AndroidGeckoLayerClient::jContentDocumentChanged = 0;
|
|
|
|
jmethodID AndroidGeckoLayerClient::jIsContentDocumentDisplayed = 0;
|
2012-09-12 14:47:08 -07:00
|
|
|
jmethodID AndroidGeckoLayerClient::jViewportCtor = 0;
|
|
|
|
jfieldID AndroidGeckoLayerClient::jDisplayportPosition = 0;
|
|
|
|
jfieldID AndroidGeckoLayerClient::jDisplayportResolution = 0;
|
2012-10-15 01:33:34 -07:00
|
|
|
jmethodID AndroidGeckoLayerClient::jProgressiveUpdateCallbackMethod = 0;
|
2012-02-09 22:58:18 -08:00
|
|
|
|
|
|
|
jclass AndroidLayerRendererFrame::jLayerRendererFrameClass = 0;
|
|
|
|
jmethodID AndroidLayerRendererFrame::jBeginDrawingMethod = 0;
|
|
|
|
jmethodID AndroidLayerRendererFrame::jDrawBackgroundMethod = 0;
|
|
|
|
jmethodID AndroidLayerRendererFrame::jDrawForegroundMethod = 0;
|
|
|
|
jmethodID AndroidLayerRendererFrame::jEndDrawingMethod = 0;
|
2012-02-03 23:31:05 -08:00
|
|
|
|
|
|
|
jclass AndroidViewTransform::jViewTransformClass = 0;
|
|
|
|
jfieldID AndroidViewTransform::jXField = 0;
|
|
|
|
jfieldID AndroidViewTransform::jYField = 0;
|
|
|
|
jfieldID AndroidViewTransform::jScaleField = 0;
|
2013-03-07 02:17:33 -08:00
|
|
|
jfieldID AndroidViewTransform::jFixedLayerMarginLeft = 0;
|
|
|
|
jfieldID AndroidViewTransform::jFixedLayerMarginTop = 0;
|
|
|
|
jfieldID AndroidViewTransform::jFixedLayerMarginRight = 0;
|
|
|
|
jfieldID AndroidViewTransform::jFixedLayerMarginBottom = 0;
|
2013-04-25 10:47:08 -07:00
|
|
|
jfieldID AndroidViewTransform::jOffsetXField = 0;
|
|
|
|
jfieldID AndroidViewTransform::jOffsetYField = 0;
|
2012-02-03 15:48:26 -08:00
|
|
|
|
2012-10-15 01:33:34 -07:00
|
|
|
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;
|
|
|
|
|
2012-06-14 09:08:51 -07:00
|
|
|
RefCountedJavaObject::~RefCountedJavaObject() {
|
|
|
|
if (mObject)
|
|
|
|
GetJNIForThread()->DeleteGlobalRef(mObject);
|
|
|
|
mObject = NULL;
|
|
|
|
}
|
|
|
|
|
2010-06-03 13:56:36 -07:00
|
|
|
void
|
|
|
|
mozilla::InitAndroidJavaWrappers(JNIEnv *jEnv)
|
|
|
|
{
|
|
|
|
AndroidGeckoEvent::InitGeckoEventClass(jEnv);
|
|
|
|
AndroidPoint::InitPointClass(jEnv);
|
2010-06-04 14:14:43 -07:00
|
|
|
AndroidLocation::InitLocationClass(jEnv);
|
2011-11-14 19:12:14 -08:00
|
|
|
AndroidRect::InitRectClass(jEnv);
|
2012-09-12 14:47:08 -07:00
|
|
|
AndroidRectF::InitRectFClass(jEnv);
|
2012-02-02 22:07:05 -08:00
|
|
|
AndroidGeckoLayerClient::InitGeckoLayerClientClass(jEnv);
|
2012-02-09 22:58:18 -08:00
|
|
|
AndroidLayerRendererFrame::InitLayerRendererFrameClass(jEnv);
|
2012-02-03 23:31:05 -08:00
|
|
|
AndroidViewTransform::InitViewTransformClass(jEnv);
|
2012-10-15 01:33:34 -07:00
|
|
|
AndroidProgressiveUpdateData::InitProgressiveUpdateDataClass(jEnv);
|
2010-06-03 13:56:36 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
AndroidGeckoEvent::InitGeckoEventClass(JNIEnv *jEnv)
|
|
|
|
{
|
|
|
|
initInit();
|
|
|
|
|
|
|
|
jGeckoEventClass = getClassGlobalRef("org/mozilla/gecko/GeckoEvent");
|
|
|
|
|
|
|
|
jActionField = getField("mAction", "I");
|
|
|
|
jTypeField = getField("mType", "I");
|
2013-03-10 15:43:30 -07:00
|
|
|
jAckNeededField = getField("mAckNeeded", "Z");
|
2010-06-03 13:56:36 -07:00
|
|
|
jTimeField = getField("mTime", "J");
|
2012-01-24 16:31:33 -08:00
|
|
|
jPoints = getField("mPoints", "[Landroid/graphics/Point;");
|
|
|
|
jPointIndicies = getField("mPointIndicies", "[I");
|
|
|
|
jOrientations = getField("mOrientations", "[F");
|
|
|
|
jPressures = getField("mPressures", "[F");
|
|
|
|
jPointRadii = getField("mPointRadii", "[Landroid/graphics/Point;");
|
2011-06-19 22:36:17 -07:00
|
|
|
jXField = getField("mX", "D");
|
|
|
|
jYField = getField("mY", "D");
|
|
|
|
jZField = getField("mZ", "D");
|
2010-06-03 13:56:36 -07:00
|
|
|
jRectField = getField("mRect", "Landroid/graphics/Rect;");
|
|
|
|
|
|
|
|
jCharactersField = getField("mCharacters", "Ljava/lang/String;");
|
2011-11-14 19:12:14 -08:00
|
|
|
jCharactersExtraField = getField("mCharactersExtra", "Ljava/lang/String;");
|
2013-06-15 14:40:27 -07:00
|
|
|
jDataField = getField("mData", "Ljava/lang/String;");
|
2010-06-03 13:56:36 -07:00
|
|
|
jKeyCodeField = getField("mKeyCode", "I");
|
|
|
|
jMetaStateField = getField("mMetaState", "I");
|
2013-04-08 13:21:52 -07:00
|
|
|
jDomKeyLocationField = getField("mDomKeyLocation", "Lorg/mozilla/gecko/GeckoEvent$DomKeyLocation;");
|
2010-06-03 13:56:36 -07:00
|
|
|
jFlagsField = getField("mFlags", "I");
|
|
|
|
jUnicodeCharField = getField("mUnicodeChar", "I");
|
2013-03-29 07:54:01 -07:00
|
|
|
jBaseUnicodeCharField = getField("mBaseUnicodeChar", "I");
|
2012-04-19 13:55:33 -07:00
|
|
|
jRepeatCountField = getField("mRepeatCount", "I");
|
2010-06-03 13:56:36 -07:00
|
|
|
jCountField = getField("mCount", "I");
|
2012-11-01 13:11:02 -07:00
|
|
|
jStartField = getField("mStart", "I");
|
|
|
|
jEndField = getField("mEnd", "I");
|
2012-01-24 16:31:33 -08:00
|
|
|
jPointerIndexField = getField("mPointerIndex", "I");
|
2010-08-04 12:47:26 -07:00
|
|
|
jRangeTypeField = getField("mRangeType", "I");
|
|
|
|
jRangeStylesField = getField("mRangeStyles", "I");
|
2012-12-06 11:35:59 -08:00
|
|
|
jRangeLineStyleField = getField("mRangeLineStyle", "I");
|
|
|
|
jRangeBoldLineField = getField("mRangeBoldLine", "Z");
|
2010-08-04 12:47:26 -07:00
|
|
|
jRangeForeColorField = getField("mRangeForeColor", "I");
|
|
|
|
jRangeBackColorField = getField("mRangeBackColor", "I");
|
2012-12-06 11:35:59 -08:00
|
|
|
jRangeLineColorField = getField("mRangeLineColor", "I");
|
2010-06-04 14:14:43 -07:00
|
|
|
jLocationField = getField("mLocation", "Landroid/location/Location;");
|
2012-01-17 10:40:39 -08:00
|
|
|
jBandwidthField = getField("mBandwidth", "D");
|
|
|
|
jCanBeMeteredField = getField("mCanBeMetered", "Z");
|
2013-07-11 08:39:36 -07:00
|
|
|
jIsWifiField = getField("mIsWifi", "Z");
|
|
|
|
jDHCPGatewayField = getField("mDHCPGateway", "I");
|
2012-03-20 06:09:45 -07:00
|
|
|
jScreenOrientationField = getField("mScreenOrientation", "S");
|
2012-06-14 09:08:51 -07:00
|
|
|
jByteBufferField = getField("mBuffer", "Ljava/nio/ByteBuffer;");
|
2013-03-20 15:45:07 -07:00
|
|
|
jWidthField = getField("mWidth", "I");
|
|
|
|
jHeightField = getField("mHeight", "I");
|
2013-09-04 06:58:08 -07:00
|
|
|
jPrefNamesField = getField("mPrefNames", "[Ljava/lang/String;");
|
2013-04-09 15:56:03 -07:00
|
|
|
|
|
|
|
// Init GeckoEvent.DomKeyLocation enum
|
|
|
|
jDomKeyLocationClass = getClassGlobalRef("org/mozilla/gecko/GeckoEvent$DomKeyLocation");
|
|
|
|
jDomKeyLocationValueField = getField("value", "I");
|
2010-06-03 13:56:36 -07:00
|
|
|
}
|
|
|
|
|
2010-06-04 14:14:43 -07:00
|
|
|
void
|
|
|
|
AndroidLocation::InitLocationClass(JNIEnv *jEnv)
|
|
|
|
{
|
|
|
|
initInit();
|
|
|
|
|
|
|
|
jLocationClass = getClassGlobalRef("android/location/Location");
|
|
|
|
jGetLatitudeMethod = getMethod("getLatitude", "()D");
|
|
|
|
jGetLongitudeMethod = getMethod("getLongitude", "()D");
|
|
|
|
jGetAltitudeMethod = getMethod("getAltitude", "()D");
|
|
|
|
jGetAccuracyMethod = getMethod("getAccuracy", "()F");
|
|
|
|
jGetBearingMethod = getMethod("getBearing", "()F");
|
|
|
|
jGetSpeedMethod = getMethod("getSpeed", "()F");
|
|
|
|
jGetTimeMethod = getMethod("getTime", "()J");
|
|
|
|
}
|
|
|
|
|
|
|
|
nsGeoPosition*
|
|
|
|
AndroidLocation::CreateGeoPosition(JNIEnv *jenv, jobject jobj)
|
|
|
|
{
|
2012-05-04 08:08:47 -07:00
|
|
|
AutoLocalJNIFrame jniFrame(jenv);
|
|
|
|
|
2010-06-04 14:14:43 -07:00
|
|
|
double latitude = jenv->CallDoubleMethod(jobj, jGetLatitudeMethod);
|
2012-05-04 08:08:47 -07:00
|
|
|
if (jniFrame.CheckForException()) return NULL;
|
2010-06-04 14:14:43 -07:00
|
|
|
double longitude = jenv->CallDoubleMethod(jobj, jGetLongitudeMethod);
|
2012-05-04 08:08:47 -07:00
|
|
|
if (jniFrame.CheckForException()) return NULL;
|
2010-06-04 14:14:43 -07:00
|
|
|
double altitude = jenv->CallDoubleMethod(jobj, jGetAltitudeMethod);
|
2012-05-04 08:08:47 -07:00
|
|
|
if (jniFrame.CheckForException()) return NULL;
|
2010-06-04 14:14:43 -07:00
|
|
|
float accuracy = jenv->CallFloatMethod (jobj, jGetAccuracyMethod);
|
2012-05-04 08:08:47 -07:00
|
|
|
if (jniFrame.CheckForException()) return NULL;
|
2010-06-04 14:14:43 -07:00
|
|
|
float bearing = jenv->CallFloatMethod (jobj, jGetBearingMethod);
|
2012-05-04 08:08:47 -07:00
|
|
|
if (jniFrame.CheckForException()) return NULL;
|
2010-06-04 14:14:43 -07:00
|
|
|
float speed = jenv->CallFloatMethod (jobj, jGetSpeedMethod);
|
2012-05-04 08:08:47 -07:00
|
|
|
if (jniFrame.CheckForException()) return NULL;
|
2010-06-04 14:14:43 -07:00
|
|
|
long long time = jenv->CallLongMethod (jobj, jGetTimeMethod);
|
2012-05-04 08:08:47 -07:00
|
|
|
if (jniFrame.CheckForException()) return NULL;
|
2010-06-04 14:14:43 -07:00
|
|
|
|
|
|
|
return new nsGeoPosition(latitude, longitude,
|
|
|
|
altitude, accuracy,
|
|
|
|
accuracy, bearing,
|
|
|
|
speed, time);
|
|
|
|
}
|
|
|
|
|
2010-06-03 13:56:36 -07:00
|
|
|
void
|
|
|
|
AndroidPoint::InitPointClass(JNIEnv *jEnv)
|
|
|
|
{
|
|
|
|
initInit();
|
|
|
|
|
|
|
|
jPointClass = getClassGlobalRef("android/graphics/Point");
|
|
|
|
|
|
|
|
jXField = getField("x", "I");
|
|
|
|
jYField = getField("y", "I");
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
AndroidRect::InitRectClass(JNIEnv *jEnv)
|
|
|
|
{
|
|
|
|
initInit();
|
|
|
|
|
|
|
|
jRectClass = getClassGlobalRef("android/graphics/Rect");
|
|
|
|
|
|
|
|
jBottomField = getField("bottom", "I");
|
|
|
|
jLeftField = getField("left", "I");
|
|
|
|
jTopField = getField("top", "I");
|
|
|
|
jRightField = getField("right", "I");
|
|
|
|
}
|
|
|
|
|
2012-09-12 14:47:08 -07:00
|
|
|
void
|
|
|
|
AndroidRectF::InitRectFClass(JNIEnv *jEnv)
|
|
|
|
{
|
|
|
|
initInit();
|
|
|
|
|
|
|
|
jRectClass = getClassGlobalRef("android/graphics/RectF");
|
|
|
|
|
|
|
|
jBottomField = getField("bottom", "F");
|
|
|
|
jLeftField = getField("left", "F");
|
|
|
|
jTopField = getField("top", "F");
|
|
|
|
jRightField = getField("right", "F");
|
|
|
|
}
|
|
|
|
|
2012-02-02 22:07:05 -08:00
|
|
|
void
|
|
|
|
AndroidGeckoLayerClient::InitGeckoLayerClientClass(JNIEnv *jEnv)
|
|
|
|
{
|
|
|
|
initInit();
|
|
|
|
|
|
|
|
jGeckoLayerClientClass = getClassGlobalRef("org/mozilla/gecko/gfx/GeckoLayerClient");
|
|
|
|
|
2013-09-09 05:57:36 -07:00
|
|
|
jProgressiveUpdateCallbackMethod = getMethod("progressiveUpdateCallback",
|
|
|
|
"(ZFFFFFZ)Lorg/mozilla/gecko/gfx/ProgressiveUpdateData;");
|
2013-06-11 06:46:51 -07:00
|
|
|
jSetFirstPaintViewport = getMethod("setFirstPaintViewport", "(FFFFFFF)V");
|
2012-06-13 10:49:40 -07:00
|
|
|
jSetPageRect = getMethod("setPageRect", "(FFFF)V");
|
2012-03-17 08:08:22 -07:00
|
|
|
jSyncViewportInfoMethod = getMethod("syncViewportInfo",
|
2012-03-19 21:06:56 -07:00
|
|
|
"(IIIIFZ)Lorg/mozilla/gecko/gfx/ViewTransform;");
|
2013-04-26 10:26:39 -07:00
|
|
|
jSyncFrameMetricsMethod = getMethod("syncFrameMetrics",
|
|
|
|
"(FFFFFFFZIIIIFZ)Lorg/mozilla/gecko/gfx/ViewTransform;");
|
2012-02-13 20:20:38 -08:00
|
|
|
jCreateFrameMethod = getMethod("createFrame", "()Lorg/mozilla/gecko/gfx/LayerRenderer$Frame;");
|
2012-02-13 13:55:10 -08:00
|
|
|
jActivateProgramMethod = getMethod("activateProgram", "()V");
|
|
|
|
jDeactivateProgramMethod = getMethod("deactivateProgram", "()V");
|
2012-11-07 08:47:08 -08:00
|
|
|
jGetDisplayPort = getMethod("getDisplayPort", "(ZZILorg/mozilla/gecko/gfx/ImmutableViewportMetrics;)Lorg/mozilla/gecko/gfx/DisplayPortMetrics;");
|
2013-05-30 06:55:23 -07:00
|
|
|
jContentDocumentChanged = getMethod("contentDocumentChanged", "()V");
|
|
|
|
jIsContentDocumentDisplayed = getMethod("isContentDocumentDisplayed", "()Z");
|
2012-09-12 14:47:08 -07:00
|
|
|
|
2013-09-09 05:57:36 -07:00
|
|
|
jViewportClass = getClassGlobalRef("org/mozilla/gecko/gfx/ImmutableViewportMetrics");
|
|
|
|
jViewportCtor = getMethod("<init>", "(FFFFFFFFFFFFF)V");
|
2012-09-12 14:47:08 -07:00
|
|
|
|
2013-09-09 05:57:36 -07:00
|
|
|
jDisplayportClass = getClassGlobalRef("org/mozilla/gecko/gfx/DisplayPortMetrics");
|
|
|
|
jDisplayportPosition = getField("mPosition", "Landroid/graphics/RectF;");
|
|
|
|
jDisplayportResolution = getField("resolution", "F");
|
2012-02-09 22:58:18 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
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");
|
2012-02-03 23:31:05 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
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");
|
2013-03-07 02:17:33 -08:00
|
|
|
jFixedLayerMarginLeft = getField("fixedLayerMarginLeft", "F");
|
|
|
|
jFixedLayerMarginTop = getField("fixedLayerMarginTop", "F");
|
|
|
|
jFixedLayerMarginRight = getField("fixedLayerMarginRight", "F");
|
|
|
|
jFixedLayerMarginBottom = getField("fixedLayerMarginBottom", "F");
|
2013-04-25 10:47:08 -07:00
|
|
|
jOffsetXField = getField("offsetX", "F");
|
|
|
|
jOffsetYField = getField("offsetY", "F");
|
2012-02-03 15:48:26 -08:00
|
|
|
}
|
|
|
|
|
2012-10-15 01:33:34 -07:00
|
|
|
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");
|
|
|
|
}
|
|
|
|
|
2010-06-03 13:56:36 -07:00
|
|
|
#undef initInit
|
|
|
|
#undef initClassGlobalRef
|
|
|
|
#undef getField
|
|
|
|
#undef getMethod
|
|
|
|
|
|
|
|
void
|
2012-01-24 16:31:33 -08:00
|
|
|
AndroidGeckoEvent::ReadPointArray(nsTArray<nsIntPoint> &points,
|
|
|
|
JNIEnv *jenv,
|
|
|
|
jfieldID field,
|
2012-08-22 08:56:38 -07:00
|
|
|
int32_t count)
|
2010-06-03 13:56:36 -07:00
|
|
|
{
|
2012-01-24 16:31:33 -08:00
|
|
|
jobjectArray jObjArray = (jobjectArray)jenv->GetObjectField(wrapped_obj, field);
|
2012-08-22 08:56:38 -07:00
|
|
|
for (int32_t i = 0; i < count; i++) {
|
2012-01-24 16:31:33 -08:00
|
|
|
jobject jObj = jenv->GetObjectArrayElement(jObjArray, i);
|
|
|
|
AndroidPoint jpoint(jenv, jObj);
|
|
|
|
|
|
|
|
nsIntPoint p(jpoint.X(), jpoint.Y());
|
|
|
|
points.AppendElement(p);
|
|
|
|
}
|
2010-06-03 13:56:36 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2012-01-24 16:31:33 -08:00
|
|
|
AndroidGeckoEvent::ReadIntArray(nsTArray<int> &aVals,
|
|
|
|
JNIEnv *jenv,
|
|
|
|
jfieldID field,
|
2012-08-22 08:56:38 -07:00
|
|
|
int32_t count)
|
2010-06-03 13:56:36 -07:00
|
|
|
{
|
2012-01-24 16:31:33 -08:00
|
|
|
jintArray jIntArray = (jintArray)jenv->GetObjectField(wrapped_obj, field);
|
2012-09-14 12:02:51 -07:00
|
|
|
jint *vals = jenv->GetIntArrayElements(jIntArray, NULL);
|
2012-08-22 08:56:38 -07:00
|
|
|
for (int32_t i = 0; i < count; i++) {
|
2012-01-24 16:31:33 -08:00
|
|
|
aVals.AppendElement(vals[i]);
|
|
|
|
}
|
|
|
|
jenv->ReleaseIntArrayElements(jIntArray, vals, JNI_ABORT);
|
2010-06-03 13:56:36 -07:00
|
|
|
}
|
|
|
|
|
2012-01-24 07:39:53 -08:00
|
|
|
void
|
2012-01-24 16:31:33 -08:00
|
|
|
AndroidGeckoEvent::ReadFloatArray(nsTArray<float> &aVals,
|
|
|
|
JNIEnv *jenv,
|
|
|
|
jfieldID field,
|
2012-08-22 08:56:38 -07:00
|
|
|
int32_t count)
|
2012-01-24 07:39:53 -08:00
|
|
|
{
|
2012-01-24 16:31:33 -08:00
|
|
|
jfloatArray jFloatArray = (jfloatArray)jenv->GetObjectField(wrapped_obj, field);
|
2012-09-14 12:02:51 -07:00
|
|
|
jfloat *vals = jenv->GetFloatArrayElements(jFloatArray, NULL);
|
2012-08-22 08:56:38 -07:00
|
|
|
for (int32_t i = 0; i < count; i++) {
|
2012-01-24 16:31:33 -08:00
|
|
|
aVals.AppendElement(vals[i]);
|
|
|
|
}
|
|
|
|
jenv->ReleaseFloatArrayElements(jFloatArray, vals, JNI_ABORT);
|
2010-06-03 13:56:36 -07:00
|
|
|
}
|
|
|
|
|
2013-09-04 06:58:08 -07:00
|
|
|
void
|
|
|
|
AndroidGeckoEvent::ReadStringArray(nsTArray<nsString> &array,
|
|
|
|
JNIEnv *jenv,
|
|
|
|
jfieldID field)
|
|
|
|
{
|
|
|
|
jarray jArray = (jarray)jenv->GetObjectField(wrapped_obj, field);
|
|
|
|
jsize length = jenv->GetArrayLength(jArray);
|
|
|
|
jobjectArray jStringArray = (jobjectArray)jArray;
|
|
|
|
nsString *strings = array.AppendElements(length);
|
|
|
|
for (jsize i = 0; i < length; ++i) {
|
|
|
|
jstring javastring = (jstring) jenv->GetObjectArrayElement(jStringArray, i);
|
|
|
|
ReadStringFromJString(strings[i], jenv, javastring);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-06-03 13:56:36 -07:00
|
|
|
void
|
|
|
|
AndroidGeckoEvent::ReadRectField(JNIEnv *jenv)
|
|
|
|
{
|
|
|
|
AndroidRect r(jenv, jenv->GetObjectField(wrappedObject(), jRectField));
|
|
|
|
if (!r.isNull()) {
|
|
|
|
mRect.SetRect(r.Left(),
|
|
|
|
r.Top(),
|
2012-02-09 09:28:10 -08:00
|
|
|
r.Width(),
|
|
|
|
r.Height());
|
2010-06-03 13:56:36 -07:00
|
|
|
} else {
|
2011-04-18 20:07:23 -07:00
|
|
|
mRect.SetEmpty();
|
2010-06-03 13:56:36 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2013-09-04 06:58:00 -07:00
|
|
|
AndroidGeckoEvent::ReadStringFromJString(nsString &aString, JNIEnv *jenv,
|
|
|
|
jstring s)
|
2010-06-03 13:56:36 -07:00
|
|
|
{
|
|
|
|
if (!s) {
|
2013-09-04 06:58:00 -07:00
|
|
|
aString.SetIsVoid(true);
|
2010-06-03 13:56:36 -07:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
int len = jenv->GetStringLength(s);
|
2013-09-04 06:58:00 -07:00
|
|
|
aString.SetLength(len);
|
|
|
|
jenv->GetStringRegion(s, 0, len, aString.BeginWriting());
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
AndroidGeckoEvent::ReadCharactersField(JNIEnv *jenv)
|
|
|
|
{
|
|
|
|
jstring s = (jstring) jenv->GetObjectField(wrapped_obj, jCharactersField);
|
|
|
|
ReadStringFromJString(mCharacters, jenv, s);
|
2010-06-03 13:56:36 -07:00
|
|
|
}
|
|
|
|
|
2011-11-14 19:12:14 -08:00
|
|
|
void
|
|
|
|
AndroidGeckoEvent::ReadCharactersExtraField(JNIEnv *jenv)
|
|
|
|
{
|
|
|
|
jstring s = (jstring) jenv->GetObjectField(wrapped_obj, jCharactersExtraField);
|
2013-09-04 06:58:00 -07:00
|
|
|
ReadStringFromJString(mCharactersExtra, jenv, s);
|
2011-11-14 19:12:14 -08:00
|
|
|
}
|
|
|
|
|
2013-06-15 14:40:27 -07:00
|
|
|
void
|
|
|
|
AndroidGeckoEvent::ReadDataField(JNIEnv *jenv)
|
|
|
|
{
|
|
|
|
jstring s = (jstring) jenv->GetObjectField(wrapped_obj, jDataField);
|
2013-09-04 06:58:00 -07:00
|
|
|
ReadStringFromJString(mData, jenv, s);
|
2013-06-15 14:40:27 -07:00
|
|
|
}
|
|
|
|
|
2011-11-14 19:12:14 -08:00
|
|
|
void
|
2013-04-17 14:39:12 -07:00
|
|
|
AndroidGeckoEvent::UnionRect(nsIntRect const& aRect)
|
2011-11-14 19:12:14 -08:00
|
|
|
{
|
2013-04-17 14:39:12 -07:00
|
|
|
mRect = aRect.Union(mRect);
|
2011-11-14 19:12:14 -08:00
|
|
|
}
|
|
|
|
|
2013-04-09 15:56:03 -07:00
|
|
|
uint32_t
|
|
|
|
AndroidGeckoEvent::ReadDomKeyLocation(JNIEnv* jenv, jobject jGeckoEventObj)
|
|
|
|
{
|
|
|
|
jobject enumObject = jenv->GetObjectField(jGeckoEventObj,
|
|
|
|
jDomKeyLocationField);
|
|
|
|
MOZ_ASSERT(enumObject);
|
|
|
|
int enumValue = jenv->GetIntField(enumObject, jDomKeyLocationValueField);
|
|
|
|
MOZ_ASSERT(enumValue >= nsIDOMKeyEvent::DOM_KEY_LOCATION_STANDARD &&
|
|
|
|
enumValue <= nsIDOMKeyEvent::DOM_KEY_LOCATION_JOYSTICK);
|
|
|
|
return static_cast<uint32_t>(enumValue);
|
|
|
|
}
|
|
|
|
|
2010-06-03 13:56:36 -07:00
|
|
|
void
|
|
|
|
AndroidGeckoEvent::Init(JNIEnv *jenv, jobject jobj)
|
|
|
|
{
|
|
|
|
NS_ASSERTION(!wrapped_obj, "Init called on non-null wrapped_obj!");
|
|
|
|
|
|
|
|
wrapped_obj = jobj;
|
|
|
|
|
|
|
|
if (!jobj)
|
|
|
|
return;
|
|
|
|
|
|
|
|
mAction = jenv->GetIntField(jobj, jActionField);
|
|
|
|
mType = jenv->GetIntField(jobj, jTypeField);
|
2013-03-10 15:43:30 -07:00
|
|
|
mAckNeeded = jenv->GetBooleanField(jobj, jAckNeededField);
|
2010-06-03 13:56:36 -07:00
|
|
|
|
|
|
|
switch (mType) {
|
|
|
|
case SIZE_CHANGED:
|
2012-02-24 07:51:41 -08:00
|
|
|
ReadPointArray(mPoints, jenv, jPoints, 2);
|
2010-06-03 13:56:36 -07:00
|
|
|
break;
|
|
|
|
|
|
|
|
case KEY_EVENT:
|
2013-03-29 07:54:01 -07:00
|
|
|
case IME_KEY_EVENT:
|
2010-06-03 13:56:36 -07:00
|
|
|
mTime = jenv->GetLongField(jobj, jTimeField);
|
|
|
|
mMetaState = jenv->GetIntField(jobj, jMetaStateField);
|
2013-04-09 15:56:03 -07:00
|
|
|
mDomKeyLocation = ReadDomKeyLocation(jenv, jobj);
|
2010-06-03 13:56:36 -07:00
|
|
|
mFlags = jenv->GetIntField(jobj, jFlagsField);
|
|
|
|
mKeyCode = jenv->GetIntField(jobj, jKeyCodeField);
|
|
|
|
mUnicodeChar = jenv->GetIntField(jobj, jUnicodeCharField);
|
2013-03-29 07:54:01 -07:00
|
|
|
mBaseUnicodeChar = jenv->GetIntField(jobj, jBaseUnicodeCharField);
|
2012-04-19 13:55:33 -07:00
|
|
|
mRepeatCount = jenv->GetIntField(jobj, jRepeatCountField);
|
2010-06-03 13:56:36 -07:00
|
|
|
ReadCharactersField(jenv);
|
|
|
|
break;
|
|
|
|
|
2012-10-02 13:18:21 -07:00
|
|
|
case NATIVE_GESTURE_EVENT:
|
|
|
|
mTime = jenv->GetLongField(jobj, jTimeField);
|
|
|
|
mMetaState = jenv->GetIntField(jobj, jMetaStateField);
|
|
|
|
mCount = jenv->GetIntField(jobj, jCountField);
|
|
|
|
ReadPointArray(mPoints, jenv, jPoints, mCount);
|
|
|
|
mX = jenv->GetDoubleField(jobj, jXField);
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
2010-06-03 13:56:36 -07:00
|
|
|
case MOTION_EVENT:
|
|
|
|
mTime = jenv->GetLongField(jobj, jTimeField);
|
2010-12-21 14:36:28 -08:00
|
|
|
mMetaState = jenv->GetIntField(jobj, jMetaStateField);
|
2010-07-07 14:34:12 -07:00
|
|
|
mCount = jenv->GetIntField(jobj, jCountField);
|
2012-01-24 16:31:33 -08:00
|
|
|
mPointerIndex = jenv->GetIntField(jobj, jPointerIndexField);
|
|
|
|
|
|
|
|
ReadPointArray(mPointRadii, jenv, jPointRadii, mCount);
|
|
|
|
ReadFloatArray(mOrientations, jenv, jOrientations, mCount);
|
|
|
|
ReadFloatArray(mPressures, jenv, jPressures, mCount);
|
|
|
|
ReadPointArray(mPoints, jenv, jPoints, mCount);
|
|
|
|
ReadIntArray(mPointIndicies, jenv, jPointIndicies, mCount);
|
|
|
|
|
2010-06-03 13:56:36 -07:00
|
|
|
break;
|
|
|
|
|
|
|
|
case IME_EVENT:
|
2012-11-01 13:11:02 -07:00
|
|
|
mStart = jenv->GetIntField(jobj, jStartField);
|
|
|
|
mEnd = jenv->GetIntField(jobj, jEndField);
|
|
|
|
|
|
|
|
if (mAction == IME_REPLACE_TEXT) {
|
|
|
|
ReadCharactersField(jenv);
|
|
|
|
} else if (mAction == IME_UPDATE_COMPOSITION ||
|
|
|
|
mAction == IME_ADD_COMPOSITION_RANGE) {
|
2010-08-04 12:47:26 -07:00
|
|
|
mRangeType = jenv->GetIntField(jobj, jRangeTypeField);
|
|
|
|
mRangeStyles = jenv->GetIntField(jobj, jRangeStylesField);
|
2012-12-06 11:35:59 -08:00
|
|
|
mRangeLineStyle =
|
|
|
|
jenv->GetIntField(jobj, jRangeLineStyleField);
|
|
|
|
mRangeBoldLine =
|
|
|
|
jenv->GetBooleanField(jobj, jRangeBoldLineField);
|
2010-08-04 12:47:26 -07:00
|
|
|
mRangeForeColor =
|
|
|
|
jenv->GetIntField(jobj, jRangeForeColorField);
|
|
|
|
mRangeBackColor =
|
|
|
|
jenv->GetIntField(jobj, jRangeBackColorField);
|
2012-12-06 11:35:59 -08:00
|
|
|
mRangeLineColor =
|
|
|
|
jenv->GetIntField(jobj, jRangeLineColorField);
|
2010-08-04 12:47:26 -07:00
|
|
|
}
|
2010-06-03 13:56:36 -07:00
|
|
|
break;
|
|
|
|
|
|
|
|
case DRAW:
|
|
|
|
ReadRectField(jenv);
|
|
|
|
break;
|
|
|
|
|
2012-03-13 16:57:51 -07:00
|
|
|
case SENSOR_EVENT:
|
|
|
|
mX = jenv->GetDoubleField(jobj, jXField);
|
|
|
|
mY = jenv->GetDoubleField(jobj, jYField);
|
|
|
|
mZ = jenv->GetDoubleField(jobj, jZField);
|
|
|
|
mFlags = jenv->GetIntField(jobj, jFlagsField);
|
2012-03-20 23:36:17 -07:00
|
|
|
mMetaState = jenv->GetIntField(jobj, jMetaStateField);
|
2012-03-13 16:57:51 -07:00
|
|
|
break;
|
2011-06-19 22:36:17 -07:00
|
|
|
|
2010-06-04 14:14:43 -07:00
|
|
|
case LOCATION_EVENT: {
|
|
|
|
jobject location = jenv->GetObjectField(jobj, jLocationField);
|
|
|
|
mGeoPosition = AndroidLocation::CreateGeoPosition(jenv, location);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2010-06-18 10:42:51 -07:00
|
|
|
case LOAD_URI: {
|
|
|
|
ReadCharactersField(jenv);
|
2012-04-13 19:45:25 -07:00
|
|
|
ReadCharactersExtraField(jenv);
|
2010-06-18 10:42:51 -07:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2011-12-22 03:35:32 -08:00
|
|
|
case VIEWPORT:
|
2011-11-14 19:12:14 -08:00
|
|
|
case BROADCAST: {
|
|
|
|
ReadCharactersField(jenv);
|
|
|
|
ReadCharactersExtraField(jenv);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2012-01-17 10:40:39 -08:00
|
|
|
case NETWORK_CHANGED: {
|
|
|
|
mBandwidth = jenv->GetDoubleField(jobj, jBandwidthField);
|
|
|
|
mCanBeMetered = jenv->GetBooleanField(jobj, jCanBeMeteredField);
|
2013-07-11 08:39:36 -07:00
|
|
|
mIsWifi = jenv->GetBooleanField(jobj, jIsWifiField);
|
|
|
|
mDHCPGateway = jenv->GetIntField(jobj, jDHCPGatewayField);
|
2012-01-17 10:40:39 -08:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2012-01-24 06:59:31 -08:00
|
|
|
case VISITED: {
|
|
|
|
ReadCharactersField(jenv);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2012-12-15 07:43:52 -08:00
|
|
|
case THUMBNAIL: {
|
2012-02-20 13:37:51 -08:00
|
|
|
mMetaState = jenv->GetIntField(jobj, jMetaStateField);
|
2012-12-15 07:43:52 -08:00
|
|
|
ReadPointArray(mPoints, jenv, jPoints, 1);
|
2012-06-14 09:08:51 -07:00
|
|
|
mByteBuffer = new RefCountedJavaObject(jenv, jenv->GetObjectField(jobj, jByteBufferField));
|
2012-04-24 12:13:36 -07:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2012-03-20 06:09:45 -07:00
|
|
|
case SCREENORIENTATION_CHANGED: {
|
|
|
|
mScreenOrientation = jenv->GetShortField(jobj, jScreenOrientationField);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2013-03-20 15:45:07 -07:00
|
|
|
case COMPOSITOR_CREATE: {
|
|
|
|
mWidth = jenv->GetIntField(jobj, jWidthField);
|
|
|
|
mHeight = jenv->GetIntField(jobj, jHeightField);
|
|
|
|
break;
|
2013-06-15 14:40:27 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
case CALL_OBSERVER: {
|
|
|
|
ReadCharactersField(jenv);
|
|
|
|
ReadCharactersExtraField(jenv);
|
|
|
|
ReadDataField(jenv);
|
|
|
|
break;
|
2013-06-17 14:09:09 -07:00
|
|
|
}
|
|
|
|
|
2013-06-19 10:55:35 -07:00
|
|
|
case REMOVE_OBSERVER: {
|
|
|
|
ReadCharactersField(jenv);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2013-06-17 14:09:09 -07:00
|
|
|
case LOW_MEMORY: {
|
|
|
|
mMetaState = jenv->GetIntField(jobj, jMetaStateField);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
case NETWORK_LINK_CHANGE: {
|
|
|
|
ReadCharactersField(jenv);
|
|
|
|
break;
|
2013-03-20 15:45:07 -07:00
|
|
|
}
|
|
|
|
|
2013-08-15 12:03:47 -07:00
|
|
|
case TELEMETRY_HISTOGRAM_ADD: {
|
|
|
|
ReadCharactersField(jenv);
|
|
|
|
mCount = jenv->GetIntField(jobj, jCountField);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2013-09-04 06:58:08 -07:00
|
|
|
case PREFERENCES_OBSERVE:
|
|
|
|
case PREFERENCES_GET: {
|
|
|
|
ReadStringArray(mPrefNames, jenv, jPrefNamesField);
|
|
|
|
mCount = jenv->GetIntField(jobj, jCountField);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2010-06-03 13:56:36 -07:00
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2012-03-20 23:36:17 -07:00
|
|
|
#ifdef DEBUG_ANDROID_EVENTS
|
2011-01-18 16:25:20 -08:00
|
|
|
ALOG("AndroidGeckoEvent: %p : %d", (void*)jobj, mType);
|
2010-06-03 13:56:36 -07:00
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
AndroidGeckoEvent::Init(int aType)
|
|
|
|
{
|
|
|
|
mType = aType;
|
2013-03-14 13:19:24 -07:00
|
|
|
mAckNeeded = false;
|
2010-06-03 13:56:36 -07:00
|
|
|
}
|
|
|
|
|
2011-08-09 09:08:19 -07:00
|
|
|
void
|
|
|
|
AndroidGeckoEvent::Init(AndroidGeckoEvent *aResizeEvent)
|
|
|
|
{
|
|
|
|
NS_ASSERTION(aResizeEvent->Type() == SIZE_CHANGED, "Init called on non-SIZE_CHANGED event");
|
|
|
|
|
|
|
|
mType = FORCED_RESIZE;
|
2013-03-14 13:19:24 -07:00
|
|
|
mAckNeeded = false;
|
2011-08-09 09:08:19 -07:00
|
|
|
mTime = aResizeEvent->mTime;
|
2012-01-24 16:31:33 -08:00
|
|
|
mPoints = aResizeEvent->mPoints; // x,y coordinates
|
2011-08-09 09:08:19 -07:00
|
|
|
}
|
|
|
|
|
2013-04-17 14:39:10 -07:00
|
|
|
nsTouchEvent
|
|
|
|
AndroidGeckoEvent::MakeTouchEvent(nsIWidget* widget)
|
|
|
|
{
|
|
|
|
int type = NS_EVENT_NULL;
|
|
|
|
int startIndex = 0;
|
|
|
|
int endIndex = Count();
|
|
|
|
|
2013-04-17 14:39:11 -07:00
|
|
|
switch (Action()) {
|
2013-04-17 14:39:10 -07:00
|
|
|
case AndroidMotionEvent::ACTION_DOWN:
|
|
|
|
case AndroidMotionEvent::ACTION_POINTER_DOWN: {
|
|
|
|
type = NS_TOUCH_START;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case AndroidMotionEvent::ACTION_MOVE: {
|
|
|
|
type = NS_TOUCH_MOVE;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case AndroidMotionEvent::ACTION_UP:
|
|
|
|
case AndroidMotionEvent::ACTION_POINTER_UP: {
|
|
|
|
type = NS_TOUCH_END;
|
|
|
|
// for pointer-up events we only want the data from
|
|
|
|
// the one pointer that went up
|
|
|
|
startIndex = PointerIndex();
|
|
|
|
endIndex = startIndex + 1;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case AndroidMotionEvent::ACTION_OUTSIDE:
|
|
|
|
case AndroidMotionEvent::ACTION_CANCEL: {
|
|
|
|
type = NS_TOUCH_CANCEL;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
nsTouchEvent event(true, type, widget);
|
|
|
|
if (type == NS_EVENT_NULL) {
|
|
|
|
// An event we don't know about
|
|
|
|
return event;
|
|
|
|
}
|
|
|
|
|
|
|
|
event.modifiers = 0;
|
|
|
|
event.time = Time();
|
|
|
|
event.InitBasicModifiers(IsCtrlPressed(),
|
|
|
|
IsAltPressed(),
|
|
|
|
IsShiftPressed(),
|
|
|
|
IsMetaPressed());
|
|
|
|
|
|
|
|
const nsIntPoint& offset = widget->WidgetToScreenOffset();
|
|
|
|
event.touches.SetCapacity(endIndex - startIndex);
|
|
|
|
for (int i = startIndex; i < endIndex; i++) {
|
2013-07-04 06:02:29 -07:00
|
|
|
// In this code branch, we are dispatching this event directly
|
|
|
|
// into Gecko (as opposed to going through the AsyncPanZoomController),
|
|
|
|
// and the Points() array has points in CSS pixels, which we need
|
|
|
|
// to convert.
|
|
|
|
nsIntPoint pt(
|
|
|
|
(Points()[i].x * widget->GetDefaultScale()) - offset.x,
|
|
|
|
(Points()[i].y * widget->GetDefaultScale()) - offset.y);
|
|
|
|
nsIntPoint radii(
|
|
|
|
PointRadii()[i].x * widget->GetDefaultScale(),
|
|
|
|
PointRadii()[i].y * widget->GetDefaultScale());
|
2013-05-17 13:17:53 -07:00
|
|
|
nsRefPtr<Touch> t = new Touch(PointIndicies()[i],
|
2013-07-04 06:02:29 -07:00
|
|
|
pt,
|
|
|
|
radii,
|
2013-05-17 13:17:53 -07:00
|
|
|
Orientations()[i],
|
|
|
|
Pressures()[i]);
|
2013-04-17 14:39:10 -07:00
|
|
|
event.touches.AppendElement(t);
|
|
|
|
}
|
|
|
|
|
|
|
|
return event;
|
|
|
|
}
|
|
|
|
|
2013-04-26 10:24:28 -07:00
|
|
|
MultiTouchInput
|
|
|
|
AndroidGeckoEvent::MakeMultiTouchInput(nsIWidget* widget)
|
|
|
|
{
|
|
|
|
MultiTouchInput::MultiTouchType type = (MultiTouchInput::MultiTouchType)-1;
|
|
|
|
int startIndex = 0;
|
|
|
|
int endIndex = Count();
|
|
|
|
|
|
|
|
switch (Action()) {
|
|
|
|
case AndroidMotionEvent::ACTION_DOWN:
|
|
|
|
case AndroidMotionEvent::ACTION_POINTER_DOWN: {
|
|
|
|
type = MultiTouchInput::MULTITOUCH_START;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case AndroidMotionEvent::ACTION_MOVE: {
|
|
|
|
type = MultiTouchInput::MULTITOUCH_MOVE;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case AndroidMotionEvent::ACTION_UP:
|
|
|
|
case AndroidMotionEvent::ACTION_POINTER_UP: {
|
|
|
|
// for pointer-up events we only want the data from
|
|
|
|
// the one pointer that went up
|
|
|
|
startIndex = PointerIndex();
|
|
|
|
endIndex = startIndex + 1;
|
|
|
|
type = MultiTouchInput::MULTITOUCH_END;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case AndroidMotionEvent::ACTION_OUTSIDE:
|
|
|
|
case AndroidMotionEvent::ACTION_CANCEL: {
|
|
|
|
type = MultiTouchInput::MULTITOUCH_CANCEL;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
MultiTouchInput event(type, Time());
|
|
|
|
|
|
|
|
if (type < 0) {
|
|
|
|
// An event we don't know about
|
|
|
|
return event;
|
|
|
|
}
|
|
|
|
|
|
|
|
const nsIntPoint& offset = widget->WidgetToScreenOffset();
|
|
|
|
event.mTouches.SetCapacity(endIndex - startIndex);
|
|
|
|
for (int i = startIndex; i < endIndex; i++) {
|
2013-06-11 15:13:11 -07:00
|
|
|
nsIntPoint point = Points()[i] - offset;
|
|
|
|
nsIntPoint radius = PointRadii()[i];
|
2013-04-26 10:24:28 -07:00
|
|
|
SingleTouchData data(PointIndicies()[i],
|
2013-06-11 15:13:11 -07:00
|
|
|
ScreenIntPoint::FromUnknownPoint(
|
|
|
|
gfx::IntPoint(point.x, point.y)),
|
|
|
|
ScreenSize::FromUnknownSize(
|
|
|
|
gfx::Size(radius.x, radius.y)),
|
2013-04-26 10:24:28 -07:00
|
|
|
Orientations()[i],
|
|
|
|
Pressures()[i]);
|
|
|
|
event.mTouches.AppendElement(data);
|
|
|
|
}
|
|
|
|
|
|
|
|
return event;
|
|
|
|
}
|
|
|
|
|
2011-11-14 19:12:14 -08:00
|
|
|
void
|
|
|
|
AndroidPoint::Init(JNIEnv *jenv, jobject jobj)
|
|
|
|
{
|
|
|
|
if (jobj) {
|
|
|
|
mX = jenv->GetIntField(jobj, jXField);
|
|
|
|
mY = jenv->GetIntField(jobj, jYField);
|
|
|
|
} else {
|
|
|
|
mX = 0;
|
|
|
|
mY = 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-02-03 15:48:26 -08:00
|
|
|
void
|
2012-02-22 11:45:44 -08:00
|
|
|
AndroidGeckoLayerClient::Init(jobject jobj)
|
2012-02-03 15:48:26 -08:00
|
|
|
{
|
2012-07-30 07:20:58 -07:00
|
|
|
NS_ASSERTION(wrapped_obj == nullptr, "Init called on non-null wrapped_obj!");
|
2012-02-03 15:48:26 -08:00
|
|
|
wrapped_obj = jobj;
|
2012-02-03 23:31:05 -08:00
|
|
|
}
|
|
|
|
|
2012-02-09 22:58:18 -08:00
|
|
|
void
|
2012-05-04 08:08:46 -07:00
|
|
|
AndroidLayerRendererFrame::Init(JNIEnv *env, jobject jobj)
|
2012-02-09 22:58:18 -08:00
|
|
|
{
|
2012-02-09 23:55:13 -08:00
|
|
|
if (!isNull()) {
|
2012-05-04 08:08:46 -07:00
|
|
|
Dispose(env);
|
2012-02-09 23:55:13 -08:00
|
|
|
}
|
|
|
|
|
2012-05-04 08:08:46 -07:00
|
|
|
wrapped_obj = env->NewGlobalRef(jobj);
|
2012-02-09 23:55:13 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2012-05-04 08:08:46 -07:00
|
|
|
AndroidLayerRendererFrame::Dispose(JNIEnv *env)
|
2012-02-09 23:55:13 -08:00
|
|
|
{
|
|
|
|
if (isNull()) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2012-05-04 08:08:46 -07:00
|
|
|
env->DeleteGlobalRef(wrapped_obj);
|
2012-02-09 23:55:13 -08:00
|
|
|
wrapped_obj = 0;
|
2012-02-09 22:58:18 -08:00
|
|
|
}
|
|
|
|
|
2012-02-03 23:31:05 -08:00
|
|
|
void
|
|
|
|
AndroidViewTransform::Init(jobject jobj)
|
|
|
|
{
|
2012-07-30 07:20:58 -07:00
|
|
|
NS_ABORT_IF_FALSE(wrapped_obj == nullptr, "Init called on non-null wrapped_obj!");
|
2012-02-03 23:31:05 -08:00
|
|
|
wrapped_obj = jobj;
|
2012-02-03 15:48:26 -08:00
|
|
|
}
|
|
|
|
|
2012-10-15 01:33:34 -07:00
|
|
|
void
|
|
|
|
AndroidProgressiveUpdateData::Init(jobject jobj)
|
|
|
|
{
|
|
|
|
NS_ABORT_IF_FALSE(wrapped_obj == nullptr, "Init called on non-null wrapped_obj!");
|
|
|
|
wrapped_obj = jobj;
|
|
|
|
}
|
|
|
|
|
2012-03-12 08:50:21 -07:00
|
|
|
void
|
2013-06-21 14:03:56 -07:00
|
|
|
AndroidGeckoLayerClient::SetFirstPaintViewport(const LayerIntPoint& aOffset, const CSSToLayerScale& aZoom, const CSSRect& aCssPageRect)
|
2012-03-12 08:50:21 -07:00
|
|
|
{
|
|
|
|
NS_ASSERTION(!isNull(), "SetFirstPaintViewport called on null layer client!");
|
2012-07-13 14:34:58 -07:00
|
|
|
JNIEnv *env = GetJNIForThread(); // this is called on the compositor thread
|
2012-03-12 08:50:21 -07:00
|
|
|
if (!env)
|
|
|
|
return;
|
|
|
|
|
2012-05-04 08:08:47 -07:00
|
|
|
AutoLocalJNIFrame jniFrame(env, 0);
|
2013-06-21 14:03:56 -07:00
|
|
|
return env->CallVoidMethod(wrapped_obj, jSetFirstPaintViewport, (float)aOffset.x, (float)aOffset.y, aZoom.scale,
|
2012-05-23 07:51:39 -07:00
|
|
|
aCssPageRect.x, aCssPageRect.y, aCssPageRect.XMost(), aCssPageRect.YMost());
|
2012-03-12 08:50:21 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2013-06-03 06:52:44 -07:00
|
|
|
AndroidGeckoLayerClient::SetPageRect(const CSSRect& aCssPageRect)
|
2012-03-12 08:50:21 -07:00
|
|
|
{
|
2012-05-23 07:51:39 -07:00
|
|
|
NS_ASSERTION(!isNull(), "SetPageRect called on null layer client!");
|
2012-07-13 14:34:58 -07:00
|
|
|
JNIEnv *env = GetJNIForThread(); // this is called on the compositor thread
|
2012-03-12 08:50:21 -07:00
|
|
|
if (!env)
|
|
|
|
return;
|
|
|
|
|
2012-05-04 08:08:47 -07:00
|
|
|
AutoLocalJNIFrame jniFrame(env, 0);
|
2012-06-13 10:49:40 -07:00
|
|
|
return env->CallVoidMethod(wrapped_obj, jSetPageRect,
|
2012-05-23 07:51:39 -07:00
|
|
|
aCssPageRect.x, aCssPageRect.y, aCssPageRect.XMost(), aCssPageRect.YMost());
|
2012-03-12 08:50:21 -07:00
|
|
|
}
|
|
|
|
|
2012-03-13 21:15:11 -07:00
|
|
|
void
|
2013-06-21 14:03:56 -07:00
|
|
|
AndroidGeckoLayerClient::SyncViewportInfo(const LayerIntRect& aDisplayPort, const CSSToLayerScale& aDisplayResolution,
|
|
|
|
bool aLayersUpdated, ScreenPoint& aScrollOffset, CSSToScreenScale& aScale,
|
2013-07-22 01:50:13 -07:00
|
|
|
LayerMargin& aFixedLayerMargins, ScreenPoint& aOffset)
|
2012-03-13 21:15:11 -07:00
|
|
|
{
|
2012-03-17 08:08:22 -07:00
|
|
|
NS_ASSERTION(!isNull(), "SyncViewportInfo called on null layer client!");
|
2012-07-13 14:34:58 -07:00
|
|
|
JNIEnv *env = GetJNIForThread(); // this is called on the compositor thread
|
2012-03-13 21:15:11 -07:00
|
|
|
if (!env)
|
|
|
|
return;
|
|
|
|
|
2012-05-04 08:08:47 -07:00
|
|
|
AutoLocalJNIFrame jniFrame(env);
|
2012-03-13 21:15:11 -07:00
|
|
|
|
2012-03-17 08:08:22 -07:00
|
|
|
jobject viewTransformJObj = env->CallObjectMethod(wrapped_obj, jSyncViewportInfoMethod,
|
|
|
|
aDisplayPort.x, aDisplayPort.y,
|
2012-03-19 21:05:45 -07:00
|
|
|
aDisplayPort.width, aDisplayPort.height,
|
2013-06-21 14:03:56 -07:00
|
|
|
aDisplayResolution.scale, aLayersUpdated);
|
2012-05-04 08:08:47 -07:00
|
|
|
if (jniFrame.CheckForException())
|
|
|
|
return;
|
|
|
|
|
2012-03-13 21:15:11 -07:00
|
|
|
NS_ABORT_IF_FALSE(viewTransformJObj, "No view transform object!");
|
2012-05-04 08:08:47 -07:00
|
|
|
|
|
|
|
AndroidViewTransform viewTransform;
|
2012-03-13 21:15:11 -07:00
|
|
|
viewTransform.Init(viewTransformJObj);
|
|
|
|
|
2013-06-03 06:53:32 -07:00
|
|
|
aScrollOffset = ScreenPoint(viewTransform.GetX(env), viewTransform.GetY(env));
|
2013-06-21 14:03:56 -07:00
|
|
|
aScale.scale = viewTransform.GetScale(env);
|
2013-03-07 02:17:33 -08:00
|
|
|
viewTransform.GetFixedLayerMargins(env, aFixedLayerMargins);
|
2013-04-25 10:47:08 -07:00
|
|
|
|
2013-05-01 11:12:08 -07:00
|
|
|
aOffset.x = viewTransform.GetOffsetX(env);
|
|
|
|
aOffset.y = viewTransform.GetOffsetY(env);
|
2012-03-13 21:15:11 -07:00
|
|
|
}
|
|
|
|
|
2013-04-26 10:26:39 -07:00
|
|
|
void
|
2013-06-14 13:11:29 -07:00
|
|
|
AndroidGeckoLayerClient::SyncFrameMetrics(const ScreenPoint& aScrollOffset, float aZoom, const CSSRect& aCssPageRect,
|
2013-06-21 14:03:56 -07:00
|
|
|
bool aLayersUpdated, const CSSRect& aDisplayPort, const CSSToLayerScale& aDisplayResolution,
|
2013-07-22 01:50:13 -07:00
|
|
|
bool aIsFirstPaint, LayerMargin& aFixedLayerMargins, ScreenPoint& aOffset)
|
2013-04-26 10:26:39 -07:00
|
|
|
{
|
|
|
|
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
|
2013-06-21 14:03:56 -07:00
|
|
|
LayerRect dpUnrounded = aDisplayPort * aDisplayResolution;
|
2013-06-14 13:11:29 -07:00
|
|
|
dpUnrounded += LayerPoint::FromUnknownPoint(aScrollOffset.ToUnknownPoint());
|
2013-06-14 13:11:31 -07:00
|
|
|
LayerIntRect dp = gfx::RoundedToInt(dpUnrounded);
|
2013-04-26 10:26:39 -07:00
|
|
|
|
|
|
|
jobject viewTransformJObj = env->CallObjectMethod(wrapped_obj, jSyncFrameMetricsMethod,
|
2013-05-01 11:12:08 -07:00
|
|
|
aScrollOffset.x, aScrollOffset.y, aZoom,
|
2013-04-26 10:26:39 -07:00
|
|
|
aCssPageRect.x, aCssPageRect.y, aCssPageRect.XMost(), aCssPageRect.YMost(),
|
2013-06-21 14:03:56 -07:00
|
|
|
aLayersUpdated, dp.x, dp.y, dp.width, dp.height, aDisplayResolution.scale,
|
2013-04-26 10:26:39 -07:00
|
|
|
aIsFirstPaint);
|
|
|
|
|
|
|
|
if (jniFrame.CheckForException())
|
|
|
|
return;
|
|
|
|
|
|
|
|
NS_ABORT_IF_FALSE(viewTransformJObj, "No view transform object!");
|
|
|
|
|
|
|
|
AndroidViewTransform viewTransform;
|
|
|
|
viewTransform.Init(viewTransformJObj);
|
|
|
|
viewTransform.GetFixedLayerMargins(env, aFixedLayerMargins);
|
2013-05-01 11:12:08 -07:00
|
|
|
aOffset.x = viewTransform.GetOffsetX(env);
|
|
|
|
aOffset.y = viewTransform.GetOffsetY(env);
|
2013-04-26 10:26:39 -07:00
|
|
|
}
|
|
|
|
|
2012-10-05 07:41:03 -07:00
|
|
|
bool
|
2012-10-15 01:33:34 -07:00
|
|
|
AndroidGeckoLayerClient::ProgressiveUpdateCallback(bool aHasPendingNewThebesContent,
|
2013-06-10 06:05:42 -07:00
|
|
|
const LayerRect& aDisplayPort,
|
2012-10-15 01:33:34 -07:00
|
|
|
float aDisplayResolution,
|
2012-11-21 14:34:19 -08:00
|
|
|
bool aDrawingCritical,
|
2012-10-15 01:33:34 -07:00
|
|
|
gfx::Rect& aViewport,
|
|
|
|
float& aScaleX,
|
|
|
|
float& aScaleY)
|
2012-10-05 07:41:03 -07:00
|
|
|
{
|
|
|
|
JNIEnv *env = AndroidBridge::GetJNIEnv();
|
|
|
|
if (!env)
|
|
|
|
return false;
|
|
|
|
|
2012-11-16 12:13:57 -08:00
|
|
|
AutoJObject progressiveUpdateDataJObj(env, env->CallObjectMethod(wrapped_obj,
|
|
|
|
jProgressiveUpdateCallbackMethod,
|
|
|
|
aHasPendingNewThebesContent,
|
|
|
|
(float)aDisplayPort.x,
|
|
|
|
(float)aDisplayPort.y,
|
|
|
|
(float)aDisplayPort.width,
|
|
|
|
(float)aDisplayPort.height,
|
2012-11-21 14:34:19 -08:00
|
|
|
aDisplayResolution,
|
|
|
|
!aDrawingCritical));
|
2012-11-16 12:13:57 -08:00
|
|
|
if (env->ExceptionCheck()) {
|
|
|
|
env->ExceptionDescribe();
|
|
|
|
env->ExceptionClear();
|
2012-10-05 07:41:03 -07:00
|
|
|
return false;
|
2012-11-16 12:13:57 -08:00
|
|
|
}
|
2012-10-05 07:41:03 -07:00
|
|
|
|
2012-10-15 01:33:34 -07:00
|
|
|
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);
|
2012-10-05 07:41:03 -07:00
|
|
|
}
|
|
|
|
|
2012-09-12 14:47:08 -07:00
|
|
|
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,
|
2012-11-12 18:44:59 -08:00
|
|
|
cssPageLeft, cssPageTop, cssPageRight, cssPageBottom,
|
|
|
|
x, y, x + width, y + height,
|
|
|
|
zoom);
|
2012-09-12 14:47:08 -07:00
|
|
|
return jobj;
|
|
|
|
}
|
|
|
|
|
2013-05-30 11:26:02 -07:00
|
|
|
class nsAndroidDisplayport MOZ_FINAL : public nsIAndroidDisplayport
|
2012-09-12 14:47:08 -07:00
|
|
|
{
|
|
|
|
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();
|
|
|
|
}
|
|
|
|
|
2013-05-30 06:55:23 -07:00
|
|
|
void
|
|
|
|
AndroidGeckoLayerClient::ContentDocumentChanged(AutoLocalJNIFrame *jniFrame)
|
|
|
|
{
|
|
|
|
jniFrame->GetEnv()->CallVoidMethod(wrapped_obj, jContentDocumentChanged);
|
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
|
|
|
AndroidGeckoLayerClient::IsContentDocumentDisplayed(AutoLocalJNIFrame *jniFrame)
|
|
|
|
{
|
|
|
|
return jniFrame->GetEnv()->CallBooleanMethod(wrapped_obj, jIsContentDocumentDisplayed);
|
|
|
|
}
|
|
|
|
|
2012-05-04 08:08:47 -07:00
|
|
|
bool
|
2012-05-08 06:35:59 -07:00
|
|
|
AndroidGeckoLayerClient::CreateFrame(AutoLocalJNIFrame *jniFrame, AndroidLayerRendererFrame& aFrame)
|
2012-02-09 22:58:18 -08:00
|
|
|
{
|
2012-05-08 06:35:59 -07:00
|
|
|
if (!jniFrame || !jniFrame->GetEnv())
|
|
|
|
return false;
|
2012-05-04 08:08:47 -07:00
|
|
|
|
2012-05-08 06:35:59 -07:00
|
|
|
jobject frameJObj = jniFrame->GetEnv()->CallObjectMethod(wrapped_obj, jCreateFrameMethod);
|
|
|
|
if (jniFrame->CheckForException())
|
2012-05-04 08:08:47 -07:00
|
|
|
return false;
|
2012-02-09 22:58:18 -08:00
|
|
|
NS_ABORT_IF_FALSE(frameJObj, "No frame object!");
|
2012-05-04 08:08:47 -07:00
|
|
|
|
2012-05-08 06:35:59 -07:00
|
|
|
aFrame.Init(jniFrame->GetEnv(), frameJObj);
|
2012-05-04 08:08:47 -07:00
|
|
|
return true;
|
2012-02-09 22:58:18 -08:00
|
|
|
}
|
|
|
|
|
2012-05-08 06:35:59 -07:00
|
|
|
bool
|
|
|
|
AndroidGeckoLayerClient::ActivateProgram(AutoLocalJNIFrame *jniFrame)
|
2012-02-13 13:55:10 -08:00
|
|
|
{
|
2012-05-08 06:35:59 -07:00
|
|
|
if (!jniFrame || !jniFrame->GetEnv())
|
|
|
|
return false;
|
|
|
|
|
|
|
|
jniFrame->GetEnv()->CallVoidMethod(wrapped_obj, jActivateProgramMethod);
|
|
|
|
if (jniFrame->CheckForException())
|
|
|
|
return false;
|
|
|
|
|
|
|
|
return true;
|
2012-02-13 13:55:10 -08:00
|
|
|
}
|
|
|
|
|
2012-05-08 06:35:59 -07:00
|
|
|
bool
|
|
|
|
AndroidGeckoLayerClient::DeactivateProgram(AutoLocalJNIFrame *jniFrame)
|
2012-02-13 13:55:10 -08:00
|
|
|
{
|
2012-05-08 06:35:59 -07:00
|
|
|
if (!jniFrame || !jniFrame->GetEnv())
|
|
|
|
return false;
|
|
|
|
|
|
|
|
jniFrame->GetEnv()->CallVoidMethod(wrapped_obj, jDeactivateProgramMethod);
|
|
|
|
if (jniFrame->CheckForException())
|
|
|
|
return false;
|
|
|
|
|
|
|
|
return true;
|
2012-02-13 13:55:10 -08:00
|
|
|
}
|
|
|
|
|
2012-05-08 06:35:59 -07:00
|
|
|
bool
|
|
|
|
AndroidLayerRendererFrame::BeginDrawing(AutoLocalJNIFrame *jniFrame)
|
2012-02-09 22:58:18 -08:00
|
|
|
{
|
2012-05-08 06:35:59 -07:00
|
|
|
if (!jniFrame || !jniFrame->GetEnv())
|
|
|
|
return false;
|
|
|
|
|
|
|
|
jniFrame->GetEnv()->CallVoidMethod(wrapped_obj, jBeginDrawingMethod);
|
|
|
|
if (jniFrame->CheckForException())
|
|
|
|
return false;
|
|
|
|
|
|
|
|
return true;
|
2012-02-09 22:58:18 -08:00
|
|
|
}
|
|
|
|
|
2012-05-08 06:35:59 -07:00
|
|
|
bool
|
|
|
|
AndroidLayerRendererFrame::DrawBackground(AutoLocalJNIFrame *jniFrame)
|
2012-02-09 22:58:18 -08:00
|
|
|
{
|
2012-05-08 06:35:59 -07:00
|
|
|
if (!jniFrame || !jniFrame->GetEnv())
|
|
|
|
return false;
|
|
|
|
|
|
|
|
jniFrame->GetEnv()->CallVoidMethod(wrapped_obj, jDrawBackgroundMethod);
|
|
|
|
if (jniFrame->CheckForException())
|
|
|
|
return false;
|
|
|
|
|
|
|
|
return true;
|
2012-02-09 22:58:18 -08:00
|
|
|
}
|
|
|
|
|
2012-05-08 06:35:59 -07:00
|
|
|
bool
|
|
|
|
AndroidLayerRendererFrame::DrawForeground(AutoLocalJNIFrame *jniFrame)
|
2012-02-09 22:58:18 -08:00
|
|
|
{
|
2012-05-08 06:35:59 -07:00
|
|
|
if (!jniFrame || !jniFrame->GetEnv())
|
|
|
|
return false;
|
|
|
|
|
|
|
|
jniFrame->GetEnv()->CallVoidMethod(wrapped_obj, jDrawForegroundMethod);
|
|
|
|
if (jniFrame->CheckForException())
|
|
|
|
return false;
|
|
|
|
|
|
|
|
return true;
|
2012-02-09 22:58:18 -08:00
|
|
|
}
|
|
|
|
|
2012-05-08 06:35:59 -07:00
|
|
|
bool
|
|
|
|
AndroidLayerRendererFrame::EndDrawing(AutoLocalJNIFrame *jniFrame)
|
2012-02-09 22:58:18 -08:00
|
|
|
{
|
2012-05-08 06:35:59 -07:00
|
|
|
if (!jniFrame || !jniFrame->GetEnv())
|
|
|
|
return false;
|
|
|
|
|
|
|
|
jniFrame->GetEnv()->CallVoidMethod(wrapped_obj, jEndDrawingMethod);
|
|
|
|
if (jniFrame->CheckForException())
|
|
|
|
return false;
|
|
|
|
|
|
|
|
return true;
|
2012-02-09 22:58:18 -08:00
|
|
|
}
|
|
|
|
|
2012-02-03 23:31:05 -08:00
|
|
|
float
|
2012-04-23 18:06:41 -07:00
|
|
|
AndroidViewTransform::GetX(JNIEnv *env)
|
2012-02-03 23:31:05 -08:00
|
|
|
{
|
|
|
|
if (!env)
|
|
|
|
return 0.0f;
|
|
|
|
return env->GetFloatField(wrapped_obj, jXField);
|
|
|
|
}
|
|
|
|
|
|
|
|
float
|
2012-04-23 18:06:41 -07:00
|
|
|
AndroidViewTransform::GetY(JNIEnv *env)
|
2012-02-03 23:31:05 -08:00
|
|
|
{
|
|
|
|
if (!env)
|
|
|
|
return 0.0f;
|
|
|
|
return env->GetFloatField(wrapped_obj, jYField);
|
|
|
|
}
|
|
|
|
|
|
|
|
float
|
2012-04-23 18:06:41 -07:00
|
|
|
AndroidViewTransform::GetScale(JNIEnv *env)
|
2012-02-03 23:31:05 -08:00
|
|
|
{
|
|
|
|
if (!env)
|
|
|
|
return 0.0f;
|
|
|
|
return env->GetFloatField(wrapped_obj, jScaleField);
|
|
|
|
}
|
|
|
|
|
2013-03-07 02:17:33 -08:00
|
|
|
void
|
2013-07-22 01:50:13 -07:00
|
|
|
AndroidViewTransform::GetFixedLayerMargins(JNIEnv *env, LayerMargin &aFixedLayerMargins)
|
2013-03-07 02:17:33 -08:00
|
|
|
{
|
|
|
|
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);
|
|
|
|
}
|
|
|
|
|
2013-04-25 10:47:08 -07:00
|
|
|
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);
|
|
|
|
}
|
|
|
|
|
2012-10-15 01:33:34 -07:00
|
|
|
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);
|
|
|
|
}
|
|
|
|
|
2010-06-03 13:56:36 -07:00
|
|
|
void
|
|
|
|
AndroidRect::Init(JNIEnv *jenv, jobject jobj)
|
|
|
|
{
|
2012-07-30 07:20:58 -07:00
|
|
|
NS_ASSERTION(wrapped_obj == nullptr, "Init called on non-null wrapped_obj!");
|
2010-06-03 13:56:36 -07:00
|
|
|
|
|
|
|
wrapped_obj = jobj;
|
|
|
|
|
|
|
|
if (jobj) {
|
|
|
|
mTop = jenv->GetIntField(jobj, jTopField);
|
|
|
|
mLeft = jenv->GetIntField(jobj, jLeftField);
|
|
|
|
mRight = jenv->GetIntField(jobj, jRightField);
|
|
|
|
mBottom = jenv->GetIntField(jobj, jBottomField);
|
|
|
|
} else {
|
|
|
|
mTop = 0;
|
|
|
|
mLeft = 0;
|
|
|
|
mRight = 0;
|
|
|
|
mBottom = 0;
|
|
|
|
}
|
|
|
|
}
|
2010-06-14 12:04:16 -07:00
|
|
|
|
2012-09-12 14:47:08 -07:00
|
|
|
void
|
|
|
|
AndroidRectF::Init(JNIEnv *jenv, jobject jobj)
|
|
|
|
{
|
|
|
|
NS_ASSERTION(wrapped_obj == nullptr, "Init called on non-null wrapped_obj!");
|
|
|
|
|
|
|
|
wrapped_obj = jobj;
|
|
|
|
|
|
|
|
if (jobj) {
|
|
|
|
mTop = jenv->GetFloatField(jobj, jTopField);
|
|
|
|
mLeft = jenv->GetFloatField(jobj, jLeftField);
|
|
|
|
mRight = jenv->GetFloatField(jobj, jRightField);
|
|
|
|
mBottom = jenv->GetFloatField(jobj, jBottomField);
|
|
|
|
} else {
|
|
|
|
mTop = 0;
|
|
|
|
mLeft = 0;
|
|
|
|
mRight = 0;
|
|
|
|
mBottom = 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-06-14 19:17:37 -07:00
|
|
|
nsJNIString::nsJNIString(jstring jstr, JNIEnv *jenv)
|
2010-06-14 12:04:16 -07:00
|
|
|
{
|
2010-06-15 16:39:43 -07:00
|
|
|
if (!jstr) {
|
2011-10-17 07:59:28 -07:00
|
|
|
SetIsVoid(true);
|
2010-06-15 16:39:43 -07:00
|
|
|
return;
|
|
|
|
}
|
2010-06-14 19:17:37 -07:00
|
|
|
JNIEnv *jni = jenv;
|
2012-04-28 09:55:59 -07:00
|
|
|
if (!jni) {
|
2012-01-29 12:39:30 -08:00
|
|
|
jni = AndroidBridge::GetJNIEnv();
|
2012-04-28 09:55:59 -07:00
|
|
|
if (!jni) {
|
|
|
|
SetIsVoid(true);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
2011-01-25 10:51:29 -08:00
|
|
|
const jchar* jCharPtr = jni->GetStringChars(jstr, NULL);
|
2011-03-01 16:03:38 -08:00
|
|
|
|
|
|
|
if (!jCharPtr) {
|
2011-10-17 07:59:28 -07:00
|
|
|
SetIsVoid(true);
|
2011-01-25 10:51:29 -08:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2011-03-01 16:03:38 -08:00
|
|
|
jsize len = jni->GetStringLength(jstr);
|
|
|
|
|
|
|
|
if (len <= 0) {
|
2011-10-17 07:59:28 -07:00
|
|
|
SetIsVoid(true);
|
2011-03-01 16:03:38 -08:00
|
|
|
} else {
|
|
|
|
Assign(jCharPtr, len);
|
|
|
|
}
|
2010-06-14 19:17:37 -07:00
|
|
|
jni->ReleaseStringChars(jstr, jCharPtr);
|
2010-06-14 12:04:16 -07:00
|
|
|
}
|