Bug 860940 - Add static factory-style methods to create AndroidGeckoEvent instances in widget code. r=cpeterson

This commit is contained in:
Kartikaya Gupta
2013-04-17 17:39:12 -04:00
parent a56b5b95e4
commit 30b0f9b26e
5 changed files with 49 additions and 41 deletions

View File

@@ -589,31 +589,49 @@ public:
class AndroidGeckoEvent : public WrappedJavaObject
{
public:
static void InitGeckoEventClass(JNIEnv *jEnv);
AndroidGeckoEvent(int aType) {
Init(aType);
}
AndroidGeckoEvent(int aType, int aAction) {
Init(aType, aAction);
}
AndroidGeckoEvent(int aType, const nsIntRect &aRect) {
Init(aType, aRect);
}
AndroidGeckoEvent(JNIEnv *jenv, jobject jobj) {
Init(jenv, jobj);
}
AndroidGeckoEvent(AndroidGeckoEvent *aResizeEvent) {
Init(aResizeEvent);
private:
AndroidGeckoEvent() {
}
void Init(JNIEnv *jenv, jobject jobj);
void Init(int aType);
void Init(int aType, int aAction);
void Init(int aType, const nsIntRect &aRect);
void Init(AndroidGeckoEvent *aResizeEvent);
public:
static void InitGeckoEventClass(JNIEnv *jEnv);
static AndroidGeckoEvent* MakeNativePoke() {
AndroidGeckoEvent *event = new AndroidGeckoEvent();
event->Init(NATIVE_POKE);
return event;
}
static AndroidGeckoEvent* MakeIMEEvent(int aAction) {
AndroidGeckoEvent *event = new AndroidGeckoEvent();
event->Init(IME_EVENT);
event->mAction = aAction;
return event;
}
static AndroidGeckoEvent* MakeDrawEvent(const nsIntRect& aRect) {
AndroidGeckoEvent *event = new AndroidGeckoEvent();
event->Init(DRAW);
event->mRect = aRect;
return event;
}
static AndroidGeckoEvent* MakeFromJavaObject(JNIEnv *jenv, jobject jobj) {
AndroidGeckoEvent *event = new AndroidGeckoEvent();
event->Init(jenv, jobj);
return event;
}
static AndroidGeckoEvent* CopyResizeEvent(AndroidGeckoEvent *aResizeEvent) {
AndroidGeckoEvent *event = new AndroidGeckoEvent();
event->Init(aResizeEvent);
return event;
}
int Action() { return mAction; }
int Type() { return mType; }
bool AckNeeded() { return mAckNeeded; }
@@ -659,6 +677,7 @@ public:
int Width() { return mWidth; }
int Height() { return mHeight; }
nsTouchEvent MakeTouchEvent(nsIWidget* widget);
void UnionRect(nsIntRect const& aRect);
protected:
int mAction;