Bug 1447056 part 1 - Avoid unnecessary resizing calls in GTK to align with other widgets. r?karlt
MozReview-Commit-ID: AaTuZiVdx9K
--- a/widget/gtk/nsWindow.cpp
+++ b/widget/gtk/nsWindow.cpp
@@ -1114,16 +1114,21 @@ nsWindow::Show(bool aState)
void
nsWindow::Resize(double aWidth, double aHeight, bool aRepaint)
{
double scale = BoundsUseDesktopPixels() ? GetDesktopToDeviceScale().scale : 1.0;
int32_t width = NSToIntRound(scale * aWidth);
int32_t height = NSToIntRound(scale * aHeight);
ConstrainSize(&width, &height);
+ // Avoid unnecessary resizing calls
+ if (mBounds.IsEqualSize(width, height)) {
+ return;
+ }
+
// For top-level windows, aWidth and aHeight should possibly be
// interpreted as frame bounds, but NativeResize treats these as window
// bounds (Bug 581866).
mBounds.SizeTo(width, height);
if (!mCreated)
return;
@@ -1144,16 +1149,22 @@ nsWindow::Resize(double aX, double aY, d
{
double scale = BoundsUseDesktopPixels() ? GetDesktopToDeviceScale().scale : 1.0;
int32_t width = NSToIntRound(scale * aWidth);
int32_t height = NSToIntRound(scale * aHeight);
ConstrainSize(&width, &height);
int32_t x = NSToIntRound(scale * aX);
int32_t y = NSToIntRound(scale * aY);
+
+ // Avoid unnecessary resizing calls
+ if (mBounds.IsEqualRect(x, y, width, height)) {
+ return;
+ }
+
mBounds.x = x;
mBounds.y = y;
mBounds.SizeTo(width, height);
if (!mCreated)
return;
NativeMoveResize();