[tbb-commits] [tor-browser] 32/37: Bug 1745595 - type ResizeInt() parameters to specify units. r=stransky, a=RyanVM

gitolite role git at cupani.torproject.org
Wed Jun 22 18:27:41 UTC 2022


This is an automated email from the git hooks/post-receive script.

richard pushed a commit to branch tor-browser-91.11.0esr-11.5-1
in repository tor-browser.

commit 8eaccebe3720887d83baa0d78b8aedd2e7fc3c83
Author: Karl Tomlinson <karlt+ at karlt.net>
AuthorDate: Thu Jun 9 00:49:36 2022 +0000

    Bug 1745595 - type ResizeInt() parameters to specify units. r=stransky, a=RyanVM
    
    Differential Revision: https://phabricator.services.mozilla.com/D147727
---
 widget/gtk/nsWindow.cpp | 41 ++++++++++++++++++-----------------------
 widget/gtk/nsWindow.h   |  4 ++--
 2 files changed, 20 insertions(+), 25 deletions(-)

diff --git a/widget/gtk/nsWindow.cpp b/widget/gtk/nsWindow.cpp
index 66f851855cfec..ae0064ddda0af 100644
--- a/widget/gtk/nsWindow.cpp
+++ b/widget/gtk/nsWindow.cpp
@@ -1138,14 +1138,10 @@ void nsWindow::Show(bool aState) {
   NativeShow(aState);
 }
 
-void nsWindow::ResizeInt(int aX, int aY, int aWidth, int aHeight, bool aMove,
-                         bool aRepaint) {
-  LOG(("nsWindow::ResizeInt [%p] x:%d y:%d -> w:%d h:%d repaint %d aMove %d\n",
-       (void*)this, aX, aY, aWidth, aHeight, aRepaint, aMove));
-
-  ConstrainSize(&aWidth, &aHeight);
-
-  LOG(("  ConstrainSize: w:%d h;%d\n", aWidth, aHeight));
+void nsWindow::ResizeInt(const Maybe<LayoutDeviceIntPoint>& aMove,
+                         LayoutDeviceIntSize aSize, bool aRepaint) {
+  LOG(("nsWindow::ResizeInt [%p] w:%d h:%d repaint %d\n", (void*)this,
+       aSize.width, aSize.height, aRepaint));
 
   // If we used to have insane bounds, we may have skipped actually positioning
   // the widget in NativeMoveResizeWaylandPopup, in which case we need to
@@ -1154,14 +1150,18 @@ void nsWindow::ResizeInt(int aX, int aY, int aWidth, int aHeight, bool aMove,
       !AreBoundsSane() && IsWaylandPopup();
 
   if (aMove) {
-    mBounds.x = aX;
-    mBounds.y = aY;
+    mBounds.x = aMove->x;
+    mBounds.y = aMove->y;
+    LOG(("  with move to left:%d top:%d", aMove->x, aMove->y));
   }
 
-  // For top-level windows, aWidth and aHeight should possibly be
+  ConstrainSize(&aSize.width, &aSize.height);
+  LOG(("  ConstrainSize: w:%d h;%d\n", aSize.width, aSize.height));
+
+  // For top-level windows, aSize should possibly be
   // interpreted as frame bounds, but NativeResize treats these as window
   // bounds (Bug 581866).
-  mBounds.SizeTo(aWidth, aHeight);
+  mBounds.SizeTo(aSize);
 
   // We set correct mBounds in advance here. This can be invalided by state
   // event.
@@ -1195,10 +1195,9 @@ 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);
+  auto size = LayoutDeviceIntSize::Round(scale * aWidth, scale * aHeight);
 
-  ResizeInt(0, 0, width, height, /* aMove */ false, aRepaint);
+  ResizeInt(Nothing(), size, aRepaint);
 }
 
 void nsWindow::Resize(double aX, double aY, double aWidth, double aHeight,
@@ -1208,13 +1207,10 @@ void nsWindow::Resize(double aX, double aY, double aWidth, double aHeight,
 
   double scale =
       BoundsUseDesktopPixels() ? GetDesktopToDeviceScale().scale : 1.0;
-  int32_t width = NSToIntRound(scale * aWidth);
-  int32_t height = NSToIntRound(scale * aHeight);
-
-  int32_t x = NSToIntRound(scale * aX);
-  int32_t y = NSToIntRound(scale * aY);
+  auto size = LayoutDeviceIntSize::Round(scale * aWidth, scale * aHeight);
+  auto topLeft = LayoutDeviceIntPoint::Round(scale * aX, scale * aY);
 
-  ResizeInt(x, y, width, height, /* aMove */ true, aRepaint);
+  ResizeInt(Some(topLeft), size, aRepaint);
 }
 
 void nsWindow::Enable(bool aState) { mEnabled = aState; }
@@ -5598,8 +5594,7 @@ nsresult nsWindow::Create(nsIWidget* aParent, nsNativeWidget aNativeParent,
 
   // resize so that everything is set to the right dimensions
   if (!mIsTopLevel) {
-    ResizeInt(mBounds.x, mBounds.y, mBounds.width, mBounds.height,
-              /* aMove */ false, /* aRepaint */ false);
+    ResizeInt(Nothing(), mBounds.Size(), /* aRepaint */ false);
   }
 
 #ifdef MOZ_X11
diff --git a/widget/gtk/nsWindow.h b/widget/gtk/nsWindow.h
index c94b7eee5037f..664f29fa7e962 100644
--- a/widget/gtk/nsWindow.h
+++ b/widget/gtk/nsWindow.h
@@ -494,8 +494,8 @@ class nsWindow final : public nsBaseWidget {
   nsWindow* GetTransientForWindowIfPopup();
   bool IsHandlingTouchSequence(GdkEventSequence* aSequence);
 
-  void ResizeInt(int aX, int aY, int aWidth, int aHeight, bool aMove,
-                 bool aRepaint);
+  void ResizeInt(const mozilla::Maybe<LayoutDeviceIntPoint>& aMove,
+                 LayoutDeviceIntSize aSize, bool aRepaint);
   void NativeMoveResizeWaylandPopup(GdkPoint* aPosition, GdkRectangle* aSize);
 
   // Returns true if the given point (in device pixels) is within a resizer

-- 
To stop receiving notification emails like this one, please contact
the administrator of this repository.


More information about the tbb-commits mailing list