Bug 1451098 Part 1: Add asserts to widget/gtk/nsWindow.cpp to fail early when setting an invalid window size.
MozReview-Commit-ID: GHq7ik6EyIl
--- a/widget/gtk/nsWindow.cpp
+++ b/widget/gtk/nsWindow.cpp
@@ -4152,16 +4152,18 @@ nsWindow::NativeResize()
}
GdkRectangle size = DevicePixelsToGdkSizeRoundUp(mBounds.Size());
LOG(("nsWindow::NativeResize [%p] %d %d\n", (void *)this,
size.width, size.height));
if (mIsTopLevel) {
+ MOZ_ASSERT(size.width > 0 && size.height > 0,
+ "Can't resize window smaller than 1x1.");
gtk_window_resize(GTK_WINDOW(mShell), size.width, size.height);
}
else if (mContainer) {
GtkWidget *widget = GTK_WIDGET(mContainer);
GtkAllocation allocation, prev_allocation;
gtk_widget_get_allocation(widget, &prev_allocation);
allocation.x = prev_allocation.x;
allocation.y = prev_allocation.y;
@@ -4209,16 +4211,18 @@ nsWindow::NativeMoveResize()
LOG(("nsWindow::NativeMoveResize [%p] %d %d %d %d\n", (void *)this,
topLeft.x, topLeft.y, size.width, size.height));
if (mIsTopLevel) {
// x and y give the position of the window manager frame top-left.
gtk_window_move(GTK_WINDOW(mShell), topLeft.x, topLeft.y);
// This sets the client window size.
+ MOZ_ASSERT(size.width > 0 && size.height > 0,
+ "Can't resize window smaller than 1x1.");
gtk_window_resize(GTK_WINDOW(mShell), size.width, size.height);
}
else if (mContainer) {
GtkAllocation allocation;
allocation.x = topLeft.x;
allocation.y = topLeft.y;
allocation.width = size.width;
allocation.height = size.height;
@@ -4932,16 +4936,18 @@ FullscreenTransitionWindow::FullscreenTr
GdkWindow* gdkWin = gtk_widget_get_window(aWidget);
GdkScreen* screen = gtk_widget_get_screen(aWidget);
gint monitorNum = gdk_screen_get_monitor_at_window(screen, gdkWin);
GdkRectangle monitorRect;
gdk_screen_get_monitor_geometry(screen, monitorNum, &monitorRect);
gtk_window_set_screen(gtkWin, screen);
gtk_window_move(gtkWin, monitorRect.x, monitorRect.y);
+ MOZ_ASSERT(monitorRect.width > 0 && monitorRect.height > 0,
+ "Can't resize window smaller than 1x1.");
gtk_window_resize(gtkWin, monitorRect.width, monitorRect.height);
GdkColor bgColor;
bgColor.red = bgColor.green = bgColor.blue = 0;
gtk_widget_modify_bg(mWindow, GTK_STATE_NORMAL, &bgColor);
gtk_window_set_opacity(gtkWin, 0.0);
gtk_widget_show(mWindow);