bug 610834 - New windows opened don't get painted until resized r=fabrice

This commit is contained in:
James Willcox 2011-08-09 12:08:19 -04:00
Родитель ea82c9c0d4
Коммит c00fdd5056
6 изменённых файлов: 49 добавлений и 15 удалений

Просмотреть файл

@ -384,12 +384,6 @@ var Browser = {
let event = document.createEvent("Events");
event.initEvent("UIReady", true, false);
window.dispatchEvent(event);
// If we have an opener this was not the first window opened and will not
// receive an initial resize event. instead we fire the resize handler manually
// Bug 610834
if (window.opener)
resizeHandler({ target: window });
},
_alertShown: function _alertShown() {

Просмотреть файл

@ -457,6 +457,19 @@ AndroidGeckoEvent::Init(int x1, int y1, int x2, int y2)
mRect.SetEmpty();
}
void
AndroidGeckoEvent::Init(AndroidGeckoEvent *aResizeEvent)
{
NS_ASSERTION(aResizeEvent->Type() == SIZE_CHANGED, "Init called on non-SIZE_CHANGED event");
mType = FORCED_RESIZE;
mTime = aResizeEvent->mTime;
mP0.x = aResizeEvent->mP0.x;
mP0.y = aResizeEvent->mP0.y;
mP1.x = aResizeEvent->mP1.x;
mP1.y = aResizeEvent->mP1.y;
}
void
AndroidGeckoSurfaceView::Init(jobject jobj)
{

Просмотреть файл

@ -386,10 +386,14 @@ public:
AndroidGeckoEvent(JNIEnv *jenv, jobject jobj) {
Init(jenv, jobj);
}
AndroidGeckoEvent(AndroidGeckoEvent *aResizeEvent) {
Init(aResizeEvent);
}
void Init(JNIEnv *jenv, jobject jobj);
void Init(int aType);
void Init(int x1, int y1, int x2, int y2);
void Init(AndroidGeckoEvent *aResizeEvent);
int Action() { return mAction; }
int Type() { return mType; }
@ -487,6 +491,7 @@ public:
SURFACE_CREATED = 13,
SURFACE_DESTROYED = 14,
GECKO_EVENT_SYNC = 15,
FORCED_RESIZE = 16,
dummy_java_enum_list_end
};

Просмотреть файл

@ -74,6 +74,7 @@ PRLogModuleInfo *gWidgetLog = nsnull;
nsDeviceMotionSystem *gDeviceMotionSystem = nsnull;
nsIGeolocationUpdate *gLocationCallback = nsnull;
nsAutoPtr<mozilla::AndroidGeckoEvent> gLastSizeChange;
nsAppShell *nsAppShell::gAppShell = nsnull;
@ -380,6 +381,15 @@ nsAppShell::ProcessNextNativeEvent(PRBool mayWait)
break;
}
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);
}
nsWindow::OnGlobalAndroidEvent(curEvent);
break;
}
default:
nsWindow::OnGlobalAndroidEvent(curEvent);
}
@ -389,6 +399,13 @@ nsAppShell::ProcessNextNativeEvent(PRBool mayWait)
return true;
}
void
nsAppShell::ResendLastResizeEvent(nsWindow* aDest) {
if (gLastSizeChange) {
nsWindow::OnGlobalAndroidEvent(gLastSizeChange);
}
}
AndroidGeckoEvent*
nsAppShell::GetNextEvent()
{

Просмотреть файл

@ -52,6 +52,8 @@ bool ProcessNextEvent();
void NotifyEvent();
}
class nsWindow;
class nsAppShell :
public nsBaseAppShell
{
@ -81,6 +83,7 @@ public:
void CallObserver(const nsAString &aObserverKey, const nsAString &aTopic, const nsAString &aData);
void RemoveObserver(const nsAString &aObserverKey);
void NotifyObservers(nsISupports *aSupports, const char *aTopic, const PRUnichar *aData);
void ResendLastResizeEvent(nsWindow* aDest);
protected:
virtual void ScheduleNativeEventCallback();

Просмотреть файл

@ -448,14 +448,6 @@ nsWindow::Resize(PRInt32 aX,
PRBool needSizeDispatch = aWidth != mBounds.width || aHeight != mBounds.height;
if (IsTopLevel()) {
ALOG("... ignoring Resize sizes on toplevel window");
aX = 0;
aY = 0;
aWidth = gAndroidBounds.width;
aHeight = gAndroidBounds.height;
}
mBounds.x = aX;
mBounds.y = aY;
mBounds.width = aWidth;
@ -586,6 +578,8 @@ nsWindow::BringToFront()
nsGUIEvent event(PR_TRUE, NS_ACTIVATE, this);
DispatchEvent(&event);
// force a window resize
nsAppShell::gAppShell->ResendLastResizeEvent(this);
nsAppShell::gAppShell->PostEvent(new AndroidGeckoEvent(-1, -1, -1, -1));
}
@ -738,11 +732,19 @@ nsWindow::OnGlobalAndroidEvent(AndroidGeckoEvent *ae)
return;
switch (ae->Type()) {
case AndroidGeckoEvent::FORCED_RESIZE:
win->mBounds.width = 0;
win->mBounds.height = 0;
// also resize the children
for (PRUint32 i = 0; i < win->mChildren.Length(); i++) {
win->mChildren[i]->mBounds.width = 0;
win->mChildren[i]->mBounds.height = 0;
}
case AndroidGeckoEvent::SIZE_CHANGED: {
int nw = ae->P0().x;
int nh = ae->P0().y;
if (nw != gAndroidBounds.width ||
if (ae->Type() == AndroidGeckoEvent::FORCED_RESIZE || nw != gAndroidBounds.width ||
nh != gAndroidBounds.height) {
gAndroidBounds.width = nw;