Bug 1447056 part 1 - Avoid unnecessary resizing calls in GTK to align with other widgets. r?karlt draft
authorXidorn Quan <me@upsuper.org>
Fri, 23 Mar 2018 12:24:11 +1100
changeset 771471 94eb2c8ee9acc0d694c8318d729ecce9700cce1b
parent 771415 83793ef1734f1302120e8276b6683ff96201a572
child 771472 91a56b4c1645b928c8ad11d3310bc4b4d0998b84
push id103678
push userxquan@mozilla.com
push dateFri, 23 Mar 2018 01:51:44 +0000
reviewerskarlt
bugs1447056
milestone61.0a1
Bug 1447056 part 1 - Avoid unnecessary resizing calls in GTK to align with other widgets. r?karlt MozReview-Commit-ID: AaTuZiVdx9K
widget/gtk/nsWindow.cpp
--- 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();