Bug 1451098 Part 1: Add asserts to widget/gtk/nsWindow.cpp to fail early when setting an invalid window size. draft
authorBrad Werth <bwerth@mozilla.com>
Fri, 23 Mar 2018 15:40:02 -0700
changeset 776807 49a00dfb356fe43dbaac6659dae77f7465b77e30
parent 776748 5ec55f7a95f94cf39d57cdf36abecab914ea48eb
child 776808 41bad8d12f6605f7bf4a6927796a53e96e418797
push id105004
push userbwerth@mozilla.com
push dateTue, 03 Apr 2018 19:42:10 +0000
bugs1451098
milestone61.0a1
Bug 1451098 Part 1: Add asserts to widget/gtk/nsWindow.cpp to fail early when setting an invalid window size. MozReview-Commit-ID: GHq7ik6EyIl
widget/gtk/nsWindow.cpp
--- 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);