diff --git a/widget/android/nsWindow.cpp b/widget/android/nsWindow.cpp index f1bfe65b0f88..7bd33fbafe15 100644 --- a/widget/android/nsWindow.cpp +++ b/widget/android/nsWindow.cpp @@ -131,6 +131,18 @@ static const int32_t INPUT_RESULT_HANDLED = static const int32_t INPUT_RESULT_HANDLED_CONTENT = java::PanZoomController::INPUT_RESULT_HANDLED_CONTENT; +/** + * Width and height from the last nsWindow::Resize call, used for setting + * dimensions of a new window under the heuristic that a new window is likely + * to be the same size as a previous window. + * + * A default size of 1x1 confuses MobileViewportManager, so we use 0x0 instead. + * This is also a little more fitting since we don't yet have a surface yet + * (and therefore a valid size) and 0x0 is usually recognized as invalid. + */ +static int32_t gLastWidth = 0; +static int32_t gLastHeight = 0; + template class nsWindow::WindowEvent : public Runnable { bool IsStaleCall() { @@ -1498,11 +1510,7 @@ nsresult nsWindow::Create(nsIWidget* aParent, nsNativeWidget aNativeParent, mParent = parent; } - // A default size of 1x1 confuses MobileViewportManager, so - // use 0x0 instead. This is also a little more fitting since - // we don't yet have a surface yet (and therefore a valid size) - // and 0x0 is usually recognized as invalid. - Resize(0, 0, false); + Resize(gLastWidth, gLastHeight, false); CreateLayerManager(); @@ -1702,8 +1710,8 @@ void nsWindow::Resize(double aX, double aY, double aWidth, double aHeight, mBounds.x = NSToIntRound(aX); mBounds.y = NSToIntRound(aY); - mBounds.width = NSToIntRound(aWidth); - mBounds.height = NSToIntRound(aHeight); + mBounds.width = gLastWidth = NSToIntRound(aWidth); + mBounds.height = gLastHeight = NSToIntRound(aHeight); if (needSizeDispatch) { OnSizeChanged(gfx::IntSize::Truncate(aWidth, aHeight));