mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 860940 - Add static factory-style methods to create AndroidGeckoEvent instances in widget code. r=cpeterson
This commit is contained in:
parent
0ad0bde863
commit
55b4f820a4
@ -61,7 +61,7 @@ Java_org_mozilla_gecko_GeckoAppShell_notifyGeckoOfEvent(JNIEnv *jenv, jclass jc,
|
||||
{
|
||||
// poke the appshell
|
||||
if (nsAppShell::gAppShell)
|
||||
nsAppShell::gAppShell->PostEvent(new AndroidGeckoEvent(jenv, event));
|
||||
nsAppShell::gAppShell->PostEvent(AndroidGeckoEvent::MakeFromJavaObject(jenv, event));
|
||||
}
|
||||
|
||||
NS_EXPORT void JNICALL
|
||||
|
@ -498,11 +498,9 @@ AndroidGeckoEvent::ReadCharactersExtraField(JNIEnv *jenv)
|
||||
}
|
||||
|
||||
void
|
||||
AndroidGeckoEvent::Init(int aType, nsIntRect const& aRect)
|
||||
AndroidGeckoEvent::UnionRect(nsIntRect const& aRect)
|
||||
{
|
||||
mType = aType;
|
||||
mAckNeeded = false;
|
||||
mRect = aRect;
|
||||
mRect = aRect.Union(mRect);
|
||||
}
|
||||
|
||||
uint32_t
|
||||
@ -671,14 +669,6 @@ AndroidGeckoEvent::Init(int aType)
|
||||
mAckNeeded = false;
|
||||
}
|
||||
|
||||
void
|
||||
AndroidGeckoEvent::Init(int aType, int aAction)
|
||||
{
|
||||
mType = aType;
|
||||
mAckNeeded = false;
|
||||
mAction = aAction;
|
||||
}
|
||||
|
||||
void
|
||||
AndroidGeckoEvent::Init(AndroidGeckoEvent *aResizeEvent)
|
||||
{
|
||||
|
@ -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;
|
||||
|
@ -269,7 +269,7 @@ nsAppShell::ScheduleNativeEventCallback()
|
||||
EVLOG("nsAppShell::ScheduleNativeEventCallback pth: %p thread: %p main: %d", (void*) pthread_self(), (void*) NS_GetCurrentThread(), NS_IsMainThread());
|
||||
|
||||
// this is valid to be called from any thread, so do so.
|
||||
PostEvent(new AndroidGeckoEvent(AndroidGeckoEvent::NATIVE_POKE));
|
||||
PostEvent(AndroidGeckoEvent::MakeNativePoke());
|
||||
}
|
||||
|
||||
bool
|
||||
@ -467,7 +467,7 @@ nsAppShell::ProcessNextNativeEvent(bool mayWait)
|
||||
case AndroidGeckoEvent::SIZE_CHANGED: {
|
||||
// store the last resize event to dispatch it to new windows with a FORCED_RESIZE event
|
||||
if (curEvent != gLastSizeChange) {
|
||||
gLastSizeChange = new AndroidGeckoEvent(curEvent);
|
||||
gLastSizeChange = AndroidGeckoEvent::CopyResizeEvent(curEvent);
|
||||
}
|
||||
nsWindow::OnGlobalAndroidEvent(curEvent);
|
||||
break;
|
||||
@ -603,12 +603,12 @@ nsAppShell::PostEvent(AndroidGeckoEvent *ae)
|
||||
|
||||
case AndroidGeckoEvent::DRAW:
|
||||
if (mQueuedDrawEvent) {
|
||||
#if defined(DEBUG) || defined(FORCE_ALOG)
|
||||
// coalesce this new draw event with the one already in the queue
|
||||
const nsIntRect& oldRect = mQueuedDrawEvent->Rect();
|
||||
const nsIntRect& newRect = ae->Rect();
|
||||
nsIntRect combinedRect = oldRect.Union(newRect);
|
||||
|
||||
#if defined(DEBUG) || defined(FORCE_ALOG)
|
||||
// XXX We may want to consider using regions instead of rectangles.
|
||||
// Print an error if we're upload a lot more than we would
|
||||
// if we handled this as two separate events.
|
||||
@ -623,7 +623,7 @@ nsAppShell::PostEvent(AndroidGeckoEvent *ae)
|
||||
// coalesce into the new draw event rather than the queued one because
|
||||
// it is not always safe to move draws earlier in the queue; there may
|
||||
// be events between the two draws that affect scroll position or something.
|
||||
ae->Init(AndroidGeckoEvent::DRAW, combinedRect);
|
||||
ae->UnionRect(mQueuedDrawEvent->Rect());
|
||||
|
||||
EVLOG("nsAppShell: Coalescing previous DRAW event at %p into new DRAW event %p", mQueuedDrawEvent, ae);
|
||||
mEventQueue.RemoveElement(mQueuedDrawEvent);
|
||||
|
@ -514,7 +514,7 @@ nsWindow::IsEnabled() const
|
||||
NS_IMETHODIMP
|
||||
nsWindow::Invalidate(const nsIntRect &aRect)
|
||||
{
|
||||
AndroidGeckoEvent *event = new AndroidGeckoEvent(AndroidGeckoEvent::DRAW, aRect);
|
||||
AndroidGeckoEvent *event = AndroidGeckoEvent::MakeDrawEvent(aRect);
|
||||
nsAppShell::gAppShell->PostEvent(event);
|
||||
return NS_OK;
|
||||
}
|
||||
@ -2038,8 +2038,7 @@ nsWindow::SetInputContext(const InputContext& aContext,
|
||||
if (mIMEUpdatingContext) {
|
||||
return;
|
||||
}
|
||||
AndroidGeckoEvent *event = new AndroidGeckoEvent(
|
||||
AndroidGeckoEvent::IME_EVENT,
|
||||
AndroidGeckoEvent *event = AndroidGeckoEvent::MakeIMEEvent(
|
||||
AndroidGeckoEvent::IME_UPDATE_CONTEXT);
|
||||
nsAppShell::gAppShell->PostEvent(event);
|
||||
mIMEUpdatingContext = true;
|
||||
@ -2068,8 +2067,8 @@ nsWindow::PostFlushIMEChanges()
|
||||
// Already posted
|
||||
return;
|
||||
}
|
||||
AndroidGeckoEvent *event = new AndroidGeckoEvent(
|
||||
AndroidGeckoEvent::IME_EVENT, AndroidGeckoEvent::IME_FLUSH_CHANGES);
|
||||
AndroidGeckoEvent *event = AndroidGeckoEvent::MakeIMEEvent(
|
||||
AndroidGeckoEvent::IME_FLUSH_CHANGES);
|
||||
nsAppShell::gAppShell->PostEvent(event);
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user