michael@0: /* -*- Mode: c++; c-basic-offset: 4; tab-width: 20; indent-tabs-mode: nil; -*- michael@0: * This Source Code Form is subject to the terms of the Mozilla Public michael@0: * License, v. 2.0. If a copy of the MPL was not distributed with this michael@0: * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ michael@0: michael@0: #ifndef AndroidJavaWrappers_h__ michael@0: #define AndroidJavaWrappers_h__ michael@0: michael@0: #include michael@0: #include michael@0: #include michael@0: michael@0: #include "nsGeoPosition.h" michael@0: #include "nsRect.h" michael@0: #include "nsString.h" michael@0: #include "nsTArray.h" michael@0: #include "nsIObserver.h" michael@0: #include "nsIAndroidBridge.h" michael@0: #include "mozilla/gfx/Rect.h" michael@0: #include "mozilla/dom/Touch.h" michael@0: #include "mozilla/EventForwards.h" michael@0: #include "InputData.h" michael@0: #include "Units.h" michael@0: michael@0: //#define FORCE_ALOG 1 michael@0: michael@0: class nsIAndroidDisplayport; michael@0: class nsIAndroidViewport; michael@0: class nsIWidget; michael@0: michael@0: namespace mozilla { michael@0: michael@0: class AutoLocalJNIFrame; michael@0: michael@0: void InitAndroidJavaWrappers(JNIEnv *jEnv); michael@0: michael@0: /* michael@0: * Note: do not store global refs to any WrappedJavaObject; michael@0: * these are live only during a particular JNI method, as michael@0: * NewGlobalRef is -not- called on the jobject. michael@0: * michael@0: * If this is needed, WrappedJavaObject can be extended to michael@0: * handle it. michael@0: */ michael@0: michael@0: class RefCountedJavaObject { michael@0: public: michael@0: RefCountedJavaObject(JNIEnv* env, jobject obj) : mRefCnt(0), mObject(env->NewGlobalRef(obj)) {} michael@0: michael@0: ~RefCountedJavaObject(); michael@0: michael@0: int32_t AddRef() { return ++mRefCnt; } michael@0: michael@0: int32_t Release() { michael@0: int32_t refcnt = --mRefCnt; michael@0: if (refcnt == 0) michael@0: delete this; michael@0: return refcnt; michael@0: } michael@0: michael@0: jobject GetObject() { return mObject; } michael@0: private: michael@0: int32_t mRefCnt; michael@0: jobject mObject; michael@0: }; michael@0: michael@0: class WrappedJavaObject { michael@0: public: michael@0: WrappedJavaObject() : michael@0: wrapped_obj(nullptr) michael@0: { } michael@0: michael@0: WrappedJavaObject(jobject jobj) : wrapped_obj(nullptr) { michael@0: Init(jobj); michael@0: } michael@0: michael@0: void Init(jobject jobj) { michael@0: wrapped_obj = jobj; michael@0: } michael@0: michael@0: bool isNull() const { michael@0: return wrapped_obj == nullptr; michael@0: } michael@0: michael@0: jobject wrappedObject() const { michael@0: return wrapped_obj; michael@0: } michael@0: michael@0: protected: michael@0: jobject wrapped_obj; michael@0: }; michael@0: michael@0: class AutoGlobalWrappedJavaObject : protected WrappedJavaObject{ michael@0: public: michael@0: AutoGlobalWrappedJavaObject() : michael@0: wrapped_obj(nullptr) michael@0: { } michael@0: michael@0: AutoGlobalWrappedJavaObject(jobject jobj, JNIEnv* env) : wrapped_obj(nullptr) { michael@0: Init(jobj, env); michael@0: } michael@0: michael@0: virtual ~AutoGlobalWrappedJavaObject(); michael@0: void Dispose(); michael@0: michael@0: void Init(jobject jobj, JNIEnv* env) { michael@0: if (!isNull()) { michael@0: env->DeleteGlobalRef(wrapped_obj); michael@0: } michael@0: wrapped_obj = env->NewGlobalRef(jobj); michael@0: } michael@0: michael@0: bool isNull() const { michael@0: return wrapped_obj == nullptr; michael@0: } michael@0: michael@0: jobject wrappedObject() const { michael@0: return wrapped_obj; michael@0: } michael@0: michael@0: protected: michael@0: jobject wrapped_obj; michael@0: }; michael@0: michael@0: class AndroidPoint : public WrappedJavaObject michael@0: { michael@0: public: michael@0: static void InitPointClass(JNIEnv *jEnv); michael@0: michael@0: AndroidPoint() { } michael@0: AndroidPoint(JNIEnv *jenv, jobject jobj) { michael@0: Init(jenv, jobj); michael@0: } michael@0: michael@0: void Init(JNIEnv *jenv, jobject jobj); michael@0: michael@0: int X() { return mX; } michael@0: int Y() { return mY; } michael@0: michael@0: protected: michael@0: int mX; michael@0: int mY; michael@0: michael@0: static jclass jPointClass; michael@0: static jfieldID jXField; michael@0: static jfieldID jYField; michael@0: }; michael@0: michael@0: class AndroidRect : public WrappedJavaObject michael@0: { michael@0: public: michael@0: static void InitRectClass(JNIEnv *jEnv); michael@0: michael@0: AndroidRect() { } michael@0: AndroidRect(JNIEnv *jenv, jobject jobj) { michael@0: Init(jenv, jobj); michael@0: } michael@0: michael@0: void Init(JNIEnv *jenv, jobject jobj); michael@0: michael@0: int Bottom() { return mBottom; } michael@0: int Left() { return mLeft; } michael@0: int Right() { return mRight; } michael@0: int Top() { return mTop; } michael@0: int Width() { return mRight - mLeft; } michael@0: int Height() { return mBottom - mTop; } michael@0: michael@0: protected: michael@0: int mBottom; michael@0: int mLeft; michael@0: int mRight; michael@0: int mTop; michael@0: michael@0: static jclass jRectClass; michael@0: static jfieldID jBottomField; michael@0: static jfieldID jLeftField; michael@0: static jfieldID jRightField; michael@0: static jfieldID jTopField; michael@0: }; michael@0: michael@0: class AndroidRectF : public WrappedJavaObject michael@0: { michael@0: public: michael@0: static void InitRectFClass(JNIEnv *jEnv); michael@0: michael@0: AndroidRectF() { } michael@0: AndroidRectF(JNIEnv *jenv, jobject jobj) { michael@0: Init(jenv, jobj); michael@0: } michael@0: michael@0: void Init(JNIEnv *jenv, jobject jobj); michael@0: michael@0: float Bottom() { return mBottom; } michael@0: float Left() { return mLeft; } michael@0: float Right() { return mRight; } michael@0: float Top() { return mTop; } michael@0: float Width() { return mRight - mLeft; } michael@0: float Height() { return mBottom - mTop; } michael@0: michael@0: protected: michael@0: float mBottom; michael@0: float mLeft; michael@0: float mRight; michael@0: float mTop; michael@0: michael@0: static jclass jRectClass; michael@0: static jfieldID jBottomField; michael@0: static jfieldID jLeftField; michael@0: static jfieldID jRightField; michael@0: static jfieldID jTopField; michael@0: }; michael@0: michael@0: class AndroidLayerRendererFrame : public WrappedJavaObject { michael@0: public: michael@0: static void InitLayerRendererFrameClass(JNIEnv *jEnv); michael@0: michael@0: void Init(JNIEnv *env, jobject jobj); michael@0: void Dispose(JNIEnv *env); michael@0: michael@0: bool BeginDrawing(AutoLocalJNIFrame *jniFrame); michael@0: bool DrawBackground(AutoLocalJNIFrame *jniFrame); michael@0: bool DrawForeground(AutoLocalJNIFrame *jniFrame); michael@0: bool EndDrawing(AutoLocalJNIFrame *jniFrame); michael@0: michael@0: private: michael@0: static jclass jLayerRendererFrameClass; michael@0: static jmethodID jBeginDrawingMethod; michael@0: static jmethodID jDrawBackgroundMethod; michael@0: static jmethodID jDrawForegroundMethod; michael@0: static jmethodID jEndDrawingMethod; michael@0: }; michael@0: michael@0: enum { michael@0: // These keycode masks are not defined in android/keycodes.h: michael@0: AKEYCODE_ESCAPE = 111, michael@0: AKEYCODE_FORWARD_DEL = 112, michael@0: AKEYCODE_CTRL_LEFT = 113, michael@0: AKEYCODE_CTRL_RIGHT = 114, michael@0: AKEYCODE_CAPS_LOCK = 115, michael@0: AKEYCODE_SCROLL_LOCK = 116, michael@0: AKEYCODE_META_LEFT = 117, michael@0: AKEYCODE_META_RIGHT = 118, michael@0: AKEYCODE_FUNCTION = 119, michael@0: AKEYCODE_SYSRQ = 120, michael@0: AKEYCODE_BREAK = 121, michael@0: AKEYCODE_MOVE_HOME = 122, michael@0: AKEYCODE_MOVE_END = 123, michael@0: AKEYCODE_INSERT = 124, michael@0: AKEYCODE_FORWARD = 125, michael@0: AKEYCODE_MEDIA_PLAY = 126, michael@0: AKEYCODE_MEDIA_PAUSE = 127, michael@0: AKEYCODE_MEDIA_CLOSE = 128, michael@0: AKEYCODE_MEDIA_EJECT = 129, michael@0: AKEYCODE_MEDIA_RECORD = 130, michael@0: AKEYCODE_F1 = 131, michael@0: AKEYCODE_F2 = 132, michael@0: AKEYCODE_F3 = 133, michael@0: AKEYCODE_F4 = 134, michael@0: AKEYCODE_F5 = 135, michael@0: AKEYCODE_F6 = 136, michael@0: AKEYCODE_F7 = 137, michael@0: AKEYCODE_F8 = 138, michael@0: AKEYCODE_F9 = 139, michael@0: AKEYCODE_F10 = 140, michael@0: AKEYCODE_F11 = 141, michael@0: AKEYCODE_F12 = 142, michael@0: AKEYCODE_NUM_LOCK = 143, michael@0: AKEYCODE_NUMPAD_0 = 144, michael@0: AKEYCODE_NUMPAD_1 = 145, michael@0: AKEYCODE_NUMPAD_2 = 146, michael@0: AKEYCODE_NUMPAD_3 = 147, michael@0: AKEYCODE_NUMPAD_4 = 148, michael@0: AKEYCODE_NUMPAD_5 = 149, michael@0: AKEYCODE_NUMPAD_6 = 150, michael@0: AKEYCODE_NUMPAD_7 = 151, michael@0: AKEYCODE_NUMPAD_8 = 152, michael@0: AKEYCODE_NUMPAD_9 = 153, michael@0: AKEYCODE_NUMPAD_DIVIDE = 154, michael@0: AKEYCODE_NUMPAD_MULTIPLY = 155, michael@0: AKEYCODE_NUMPAD_SUBTRACT = 156, michael@0: AKEYCODE_NUMPAD_ADD = 157, michael@0: AKEYCODE_NUMPAD_DOT = 158, michael@0: AKEYCODE_NUMPAD_COMMA = 159, michael@0: AKEYCODE_NUMPAD_ENTER = 160, michael@0: AKEYCODE_NUMPAD_EQUALS = 161, michael@0: AKEYCODE_NUMPAD_LEFT_PAREN = 162, michael@0: AKEYCODE_NUMPAD_RIGHT_PAREN = 163, michael@0: AKEYCODE_VOLUME_MUTE = 164, michael@0: AKEYCODE_INFO = 165, michael@0: AKEYCODE_CHANNEL_UP = 166, michael@0: AKEYCODE_CHANNEL_DOWN = 167, michael@0: AKEYCODE_ZOOM_IN = 168, michael@0: AKEYCODE_ZOOM_OUT = 169, michael@0: AKEYCODE_TV = 170, michael@0: AKEYCODE_WINDOW = 171, michael@0: AKEYCODE_GUIDE = 172, michael@0: AKEYCODE_DVR = 173, michael@0: AKEYCODE_BOOKMARK = 174, michael@0: AKEYCODE_CAPTIONS = 175, michael@0: AKEYCODE_SETTINGS = 176, michael@0: AKEYCODE_TV_POWER = 177, michael@0: AKEYCODE_TV_INPUT = 178, michael@0: AKEYCODE_STB_POWER = 179, michael@0: AKEYCODE_STB_INPUT = 180, michael@0: AKEYCODE_AVR_POWER = 181, michael@0: AKEYCODE_AVR_INPUT = 182, michael@0: AKEYCODE_PROG_RED = 183, michael@0: AKEYCODE_PROG_GREEN = 184, michael@0: AKEYCODE_PROG_YELLOW = 185, michael@0: AKEYCODE_PROG_BLUE = 186, michael@0: AKEYCODE_APP_SWITCH = 187, michael@0: AKEYCODE_BUTTON_1 = 188, michael@0: AKEYCODE_BUTTON_2 = 189, michael@0: AKEYCODE_BUTTON_3 = 190, michael@0: AKEYCODE_BUTTON_4 = 191, michael@0: AKEYCODE_BUTTON_5 = 192, michael@0: AKEYCODE_BUTTON_6 = 193, michael@0: AKEYCODE_BUTTON_7 = 194, michael@0: AKEYCODE_BUTTON_8 = 195, michael@0: AKEYCODE_BUTTON_9 = 196, michael@0: AKEYCODE_BUTTON_10 = 197, michael@0: AKEYCODE_BUTTON_11 = 198, michael@0: AKEYCODE_BUTTON_12 = 199, michael@0: AKEYCODE_BUTTON_13 = 200, michael@0: AKEYCODE_BUTTON_14 = 201, michael@0: AKEYCODE_BUTTON_15 = 202, michael@0: AKEYCODE_BUTTON_16 = 203, michael@0: AKEYCODE_LANGUAGE_SWITCH = 204, michael@0: AKEYCODE_MANNER_MODE = 205, michael@0: AKEYCODE_3D_MODE = 206, michael@0: AKEYCODE_CONTACTS = 207, michael@0: AKEYCODE_CALENDAR = 208, michael@0: AKEYCODE_MUSIC = 209, michael@0: AKEYCODE_CALCULATOR = 210, michael@0: AKEYCODE_ZENKAKU_HANKAKU = 211, michael@0: AKEYCODE_EISU = 212, michael@0: AKEYCODE_MUHENKAN = 213, michael@0: AKEYCODE_HENKAN = 214, michael@0: AKEYCODE_KATAKANA_HIRAGANA = 215, michael@0: AKEYCODE_YEN = 216, michael@0: AKEYCODE_RO = 217, michael@0: AKEYCODE_KANA = 218, michael@0: AKEYCODE_ASSIST = 219, michael@0: michael@0: AMETA_FUNCTION_ON = 0x00000008, michael@0: AMETA_CTRL_ON = 0x00001000, michael@0: AMETA_CTRL_LEFT_ON = 0x00002000, michael@0: AMETA_CTRL_RIGHT_ON = 0x00004000, michael@0: AMETA_META_ON = 0x00010000, michael@0: AMETA_META_LEFT_ON = 0x00020000, michael@0: AMETA_META_RIGHT_ON = 0x00040000, michael@0: AMETA_CAPS_LOCK_ON = 0x00100000, michael@0: AMETA_NUM_LOCK_ON = 0x00200000, michael@0: AMETA_SCROLL_LOCK_ON = 0x00400000, michael@0: michael@0: AMETA_ALT_MASK = AMETA_ALT_LEFT_ON | AMETA_ALT_RIGHT_ON | AMETA_ALT_ON, michael@0: AMETA_CTRL_MASK = AMETA_CTRL_LEFT_ON | AMETA_CTRL_RIGHT_ON | AMETA_CTRL_ON, michael@0: AMETA_META_MASK = AMETA_META_LEFT_ON | AMETA_META_RIGHT_ON | AMETA_META_ON, michael@0: AMETA_SHIFT_MASK = AMETA_SHIFT_LEFT_ON | AMETA_SHIFT_RIGHT_ON | AMETA_SHIFT_ON, michael@0: }; michael@0: michael@0: class nsAndroidDisplayport MOZ_FINAL : public nsIAndroidDisplayport michael@0: { michael@0: public: michael@0: NS_DECL_ISUPPORTS michael@0: virtual nsresult GetLeft(float *aLeft) { *aLeft = mLeft; return NS_OK; } michael@0: virtual nsresult GetTop(float *aTop) { *aTop = mTop; return NS_OK; } michael@0: virtual nsresult GetRight(float *aRight) { *aRight = mRight; return NS_OK; } michael@0: virtual nsresult GetBottom(float *aBottom) { *aBottom = mBottom; return NS_OK; } michael@0: virtual nsresult GetResolution(float *aResolution) { *aResolution = mResolution; return NS_OK; } michael@0: virtual nsresult SetLeft(float aLeft) { mLeft = aLeft; return NS_OK; } michael@0: virtual nsresult SetTop(float aTop) { mTop = aTop; return NS_OK; } michael@0: virtual nsresult SetRight(float aRight) { mRight = aRight; return NS_OK; } michael@0: virtual nsresult SetBottom(float aBottom) { mBottom = aBottom; return NS_OK; } michael@0: virtual nsresult SetResolution(float aResolution) { mResolution = aResolution; return NS_OK; } michael@0: michael@0: nsAndroidDisplayport(AndroidRectF aRect, float aResolution): michael@0: mLeft(aRect.Left()), mTop(aRect.Top()), mRight(aRect.Right()), mBottom(aRect.Bottom()), mResolution(aResolution) {} michael@0: michael@0: private: michael@0: ~nsAndroidDisplayport() {} michael@0: float mLeft, mTop, mRight, mBottom, mResolution; michael@0: }; michael@0: michael@0: class AndroidMotionEvent michael@0: { michael@0: public: michael@0: enum { michael@0: ACTION_DOWN = 0, michael@0: ACTION_UP = 1, michael@0: ACTION_MOVE = 2, michael@0: ACTION_CANCEL = 3, michael@0: ACTION_OUTSIDE = 4, michael@0: ACTION_POINTER_DOWN = 5, michael@0: ACTION_POINTER_UP = 6, michael@0: ACTION_HOVER_MOVE = 7, michael@0: ACTION_HOVER_ENTER = 9, michael@0: ACTION_HOVER_EXIT = 10, michael@0: ACTION_MAGNIFY_START = 11, michael@0: ACTION_MAGNIFY = 12, michael@0: ACTION_MAGNIFY_END = 13, michael@0: EDGE_TOP = 0x00000001, michael@0: EDGE_BOTTOM = 0x00000002, michael@0: EDGE_LEFT = 0x00000004, michael@0: EDGE_RIGHT = 0x00000008, michael@0: SAMPLE_X = 0, michael@0: SAMPLE_Y = 1, michael@0: SAMPLE_PRESSURE = 2, michael@0: SAMPLE_SIZE = 3, michael@0: NUM_SAMPLE_DATA = 4, michael@0: dummy_java_enum_list_end michael@0: }; michael@0: }; michael@0: michael@0: class AndroidLocation : public WrappedJavaObject michael@0: { michael@0: public: michael@0: static void InitLocationClass(JNIEnv *jEnv); michael@0: static nsGeoPosition* CreateGeoPosition(JNIEnv *jenv, jobject jobj); michael@0: static jclass jLocationClass; michael@0: static jmethodID jGetLatitudeMethod; michael@0: static jmethodID jGetLongitudeMethod; michael@0: static jmethodID jGetAltitudeMethod; michael@0: static jmethodID jGetAccuracyMethod; michael@0: static jmethodID jGetBearingMethod; michael@0: static jmethodID jGetSpeedMethod; michael@0: static jmethodID jGetTimeMethod; michael@0: }; michael@0: michael@0: class AndroidGeckoEvent : public WrappedJavaObject michael@0: { michael@0: private: michael@0: AndroidGeckoEvent() { michael@0: } michael@0: michael@0: void Init(JNIEnv *jenv, jobject jobj); michael@0: void Init(int aType); michael@0: void Init(AndroidGeckoEvent *aResizeEvent); michael@0: michael@0: public: michael@0: static void InitGeckoEventClass(JNIEnv *jEnv); michael@0: michael@0: static AndroidGeckoEvent* MakeNativePoke() { michael@0: AndroidGeckoEvent *event = new AndroidGeckoEvent(); michael@0: event->Init(NATIVE_POKE); michael@0: return event; michael@0: } michael@0: michael@0: static AndroidGeckoEvent* MakeIMEEvent(int aAction) { michael@0: AndroidGeckoEvent *event = new AndroidGeckoEvent(); michael@0: event->Init(IME_EVENT); michael@0: event->mAction = aAction; michael@0: return event; michael@0: } michael@0: michael@0: static AndroidGeckoEvent* MakeDrawEvent(const nsIntRect& aRect) { michael@0: AndroidGeckoEvent *event = new AndroidGeckoEvent(); michael@0: event->Init(DRAW); michael@0: event->mRect = aRect; michael@0: return event; michael@0: } michael@0: michael@0: static AndroidGeckoEvent* MakeFromJavaObject(JNIEnv *jenv, jobject jobj) { michael@0: AndroidGeckoEvent *event = new AndroidGeckoEvent(); michael@0: event->Init(jenv, jobj); michael@0: return event; michael@0: } michael@0: michael@0: static AndroidGeckoEvent* CopyResizeEvent(AndroidGeckoEvent *aResizeEvent) { michael@0: AndroidGeckoEvent *event = new AndroidGeckoEvent(); michael@0: event->Init(aResizeEvent); michael@0: return event; michael@0: } michael@0: michael@0: static AndroidGeckoEvent* MakeBroadcastEvent(const nsCString& topic, const nsCString& data) { michael@0: AndroidGeckoEvent* event = new AndroidGeckoEvent(); michael@0: event->Init(BROADCAST); michael@0: CopyUTF8toUTF16(topic, event->mCharacters); michael@0: CopyUTF8toUTF16(data, event->mCharactersExtra); michael@0: return event; michael@0: } michael@0: michael@0: static AndroidGeckoEvent* MakeAddObserver(const nsAString &key, nsIObserver *observer) { michael@0: AndroidGeckoEvent *event = new AndroidGeckoEvent(); michael@0: event->Init(ADD_OBSERVER); michael@0: event->mCharacters.Assign(key); michael@0: event->mObserver = observer; michael@0: return event; michael@0: } michael@0: michael@0: int Action() { return mAction; } michael@0: int Type() { return mType; } michael@0: bool AckNeeded() { return mAckNeeded; } michael@0: int64_t Time() { return mTime; } michael@0: const nsTArray& Points() { return mPoints; } michael@0: const nsTArray& PointIndicies() { return mPointIndicies; } michael@0: const nsTArray& Pressures() { return mPressures; } michael@0: const nsTArray& Orientations() { return mOrientations; } michael@0: const nsTArray& PointRadii() { return mPointRadii; } michael@0: const nsTArray& PrefNames() { return mPrefNames; } michael@0: double X() { return mX; } michael@0: double Y() { return mY; } michael@0: double Z() { return mZ; } michael@0: const nsIntRect& Rect() { return mRect; } michael@0: nsAString& Characters() { return mCharacters; } michael@0: nsAString& CharactersExtra() { return mCharactersExtra; } michael@0: nsAString& Data() { return mData; } michael@0: int KeyCode() { return mKeyCode; } michael@0: int MetaState() { return mMetaState; } michael@0: uint32_t DomKeyLocation() { return mDomKeyLocation; } michael@0: Modifiers DOMModifiers() const; michael@0: bool IsAltPressed() const { return (mMetaState & AMETA_ALT_MASK) != 0; } michael@0: bool IsShiftPressed() const { return (mMetaState & AMETA_SHIFT_MASK) != 0; } michael@0: bool IsCtrlPressed() const { return (mMetaState & AMETA_CTRL_MASK) != 0; } michael@0: bool IsMetaPressed() const { return (mMetaState & AMETA_META_MASK) != 0; } michael@0: int Flags() { return mFlags; } michael@0: int UnicodeChar() { return mUnicodeChar; } michael@0: int BaseUnicodeChar() { return mBaseUnicodeChar; } michael@0: int DOMPrintableKeyValue() { return mDOMPrintableKeyValue; } michael@0: int RepeatCount() const { return mRepeatCount; } michael@0: int Count() { return mCount; } michael@0: int Start() { return mStart; } michael@0: int End() { return mEnd; } michael@0: int PointerIndex() { return mPointerIndex; } michael@0: int RangeType() { return mRangeType; } michael@0: int RangeStyles() { return mRangeStyles; } michael@0: int RangeLineStyle() { return mRangeLineStyle; } michael@0: bool RangeBoldLine() { return mRangeBoldLine; } michael@0: int RangeForeColor() { return mRangeForeColor; } michael@0: int RangeBackColor() { return mRangeBackColor; } michael@0: int RangeLineColor() { return mRangeLineColor; } michael@0: nsGeoPosition* GeoPosition() { return mGeoPosition; } michael@0: int ConnectionType() { return mConnectionType; } michael@0: bool IsWifi() { return mIsWifi; } michael@0: int DHCPGateway() { return mDHCPGateway; } michael@0: short ScreenOrientation() { return mScreenOrientation; } michael@0: RefCountedJavaObject* ByteBuffer() { return mByteBuffer; } michael@0: int Width() { return mWidth; } michael@0: int Height() { return mHeight; } michael@0: int RequestId() { return mCount; } // for convenience michael@0: WidgetTouchEvent MakeTouchEvent(nsIWidget* widget); michael@0: MultiTouchInput MakeMultiTouchInput(nsIWidget* widget); michael@0: WidgetMouseEvent MakeMouseEvent(nsIWidget* widget); michael@0: void UnionRect(nsIntRect const& aRect); michael@0: nsIObserver *Observer() { return mObserver; } michael@0: michael@0: protected: michael@0: int mAction; michael@0: int mType; michael@0: bool mAckNeeded; michael@0: int64_t mTime; michael@0: nsTArray mPoints; michael@0: nsTArray mPointRadii; michael@0: nsTArray mPointIndicies; michael@0: nsTArray mOrientations; michael@0: nsTArray mPressures; michael@0: nsIntRect mRect; michael@0: int mFlags, mMetaState; michael@0: uint32_t mDomKeyLocation; michael@0: int mKeyCode, mUnicodeChar, mBaseUnicodeChar, mDOMPrintableKeyValue; michael@0: int mRepeatCount; michael@0: int mCount; michael@0: int mStart, mEnd; michael@0: int mRangeType, mRangeStyles, mRangeLineStyle; michael@0: bool mRangeBoldLine; michael@0: int mRangeForeColor, mRangeBackColor, mRangeLineColor; michael@0: double mX, mY, mZ; michael@0: int mPointerIndex; michael@0: nsString mCharacters, mCharactersExtra, mData; michael@0: nsRefPtr mGeoPosition; michael@0: int mConnectionType; michael@0: bool mIsWifi; michael@0: int mDHCPGateway; michael@0: short mScreenOrientation; michael@0: nsRefPtr mByteBuffer; michael@0: int mWidth, mHeight; michael@0: nsCOMPtr mObserver; michael@0: nsTArray mPrefNames; michael@0: michael@0: void ReadIntArray(nsTArray &aVals, michael@0: JNIEnv *jenv, michael@0: jfieldID field, michael@0: int32_t count); michael@0: void ReadFloatArray(nsTArray &aVals, michael@0: JNIEnv *jenv, michael@0: jfieldID field, michael@0: int32_t count); michael@0: void ReadPointArray(nsTArray &mPoints, michael@0: JNIEnv *jenv, michael@0: jfieldID field, michael@0: int32_t count); michael@0: void ReadStringArray(nsTArray &aStrings, michael@0: JNIEnv *jenv, michael@0: jfieldID field); michael@0: void ReadRectField(JNIEnv *jenv); michael@0: void ReadCharactersField(JNIEnv *jenv); michael@0: void ReadCharactersExtraField(JNIEnv *jenv); michael@0: void ReadDataField(JNIEnv *jenv); michael@0: void ReadStringFromJString(nsString &aString, JNIEnv *jenv, jstring s); michael@0: michael@0: uint32_t ReadDomKeyLocation(JNIEnv* jenv, jobject jGeckoEventObj); michael@0: michael@0: static jclass jGeckoEventClass; michael@0: static jfieldID jActionField; michael@0: static jfieldID jTypeField; michael@0: static jfieldID jAckNeededField; michael@0: static jfieldID jTimeField; michael@0: static jfieldID jPoints; michael@0: static jfieldID jPointIndicies; michael@0: static jfieldID jOrientations; michael@0: static jfieldID jPressures; michael@0: static jfieldID jPointRadii; michael@0: static jfieldID jXField; michael@0: static jfieldID jYField; michael@0: static jfieldID jZField; michael@0: static jfieldID jDistanceField; michael@0: static jfieldID jRectField; michael@0: static jfieldID jNativeWindowField; michael@0: michael@0: static jfieldID jCharactersField; michael@0: static jfieldID jCharactersExtraField; michael@0: static jfieldID jDataField; michael@0: static jfieldID jDOMPrintableKeyValueField; michael@0: static jfieldID jKeyCodeField; michael@0: static jfieldID jMetaStateField; michael@0: static jfieldID jDomKeyLocationField; michael@0: static jfieldID jFlagsField; michael@0: static jfieldID jCountField; michael@0: static jfieldID jStartField; michael@0: static jfieldID jEndField; michael@0: static jfieldID jPointerIndexField; michael@0: static jfieldID jUnicodeCharField; michael@0: static jfieldID jBaseUnicodeCharField; michael@0: static jfieldID jRepeatCountField; michael@0: static jfieldID jRangeTypeField; michael@0: static jfieldID jRangeStylesField; michael@0: static jfieldID jRangeLineStyleField; michael@0: static jfieldID jRangeBoldLineField; michael@0: static jfieldID jRangeForeColorField; michael@0: static jfieldID jRangeBackColorField; michael@0: static jfieldID jRangeLineColorField; michael@0: static jfieldID jLocationField; michael@0: static jfieldID jPrefNamesField; michael@0: michael@0: static jfieldID jConnectionTypeField; michael@0: static jfieldID jIsWifiField; michael@0: static jfieldID jDHCPGatewayField; michael@0: michael@0: static jfieldID jScreenOrientationField; michael@0: static jfieldID jByteBufferField; michael@0: michael@0: static jfieldID jWidthField; michael@0: static jfieldID jHeightField; michael@0: michael@0: static jclass jDomKeyLocationClass; michael@0: static jfieldID jDomKeyLocationValueField; michael@0: michael@0: public: michael@0: enum { michael@0: NATIVE_POKE = 0, michael@0: KEY_EVENT = 1, michael@0: MOTION_EVENT = 2, michael@0: SENSOR_EVENT = 3, michael@0: LOCATION_EVENT = 5, michael@0: IME_EVENT = 6, michael@0: DRAW = 7, michael@0: SIZE_CHANGED = 8, michael@0: APP_BACKGROUNDING = 9, michael@0: APP_FOREGROUNDING = 10, michael@0: LOAD_URI = 12, michael@0: NOOP = 15, michael@0: FORCED_RESIZE = 16, // used internally in nsAppShell/nsWindow michael@0: BROADCAST = 19, michael@0: VIEWPORT = 20, michael@0: VISITED = 21, michael@0: NETWORK_CHANGED = 22, michael@0: THUMBNAIL = 25, michael@0: SCREENORIENTATION_CHANGED = 27, michael@0: COMPOSITOR_CREATE = 28, michael@0: COMPOSITOR_PAUSE = 29, michael@0: COMPOSITOR_RESUME = 30, michael@0: NATIVE_GESTURE_EVENT = 31, michael@0: IME_KEY_EVENT = 32, michael@0: CALL_OBSERVER = 33, michael@0: REMOVE_OBSERVER = 34, michael@0: LOW_MEMORY = 35, michael@0: NETWORK_LINK_CHANGE = 36, michael@0: TELEMETRY_HISTOGRAM_ADD = 37, michael@0: ADD_OBSERVER = 38, michael@0: PREFERENCES_OBSERVE = 39, michael@0: PREFERENCES_GET = 40, michael@0: PREFERENCES_REMOVE_OBSERVERS = 41, michael@0: TELEMETRY_UI_SESSION_START = 42, michael@0: TELEMETRY_UI_SESSION_STOP = 43, michael@0: TELEMETRY_UI_EVENT = 44, michael@0: dummy_java_enum_list_end michael@0: }; michael@0: michael@0: enum { michael@0: // Memory pressure levels. Keep these in sync with those in MemoryMonitor.java. michael@0: MEMORY_PRESSURE_NONE = 0, michael@0: MEMORY_PRESSURE_CLEANUP = 1, michael@0: MEMORY_PRESSURE_LOW = 2, michael@0: MEMORY_PRESSURE_MEDIUM = 3, michael@0: MEMORY_PRESSURE_HIGH = 4 michael@0: }; michael@0: michael@0: enum { michael@0: // Internal Gecko events michael@0: IME_FLUSH_CHANGES = -2, michael@0: IME_UPDATE_CONTEXT = -1, michael@0: // Events from Java to Gecko michael@0: IME_SYNCHRONIZE = 0, michael@0: IME_REPLACE_TEXT = 1, michael@0: IME_SET_SELECTION = 2, michael@0: IME_ADD_COMPOSITION_RANGE = 3, michael@0: IME_UPDATE_COMPOSITION = 4, michael@0: IME_REMOVE_COMPOSITION = 5, michael@0: IME_ACKNOWLEDGE_FOCUS = 6, michael@0: dummy_ime_enum_list_end michael@0: }; michael@0: }; michael@0: michael@0: class nsJNIString : public nsString michael@0: { michael@0: public: michael@0: nsJNIString(jstring jstr, JNIEnv *jenv); michael@0: }; michael@0: michael@0: } michael@0: michael@0: #endif