bug 794038 pt 2.1 - update mSizeConstraints when the device resolution of the window changes. r=smichaud
authorJonathan Kew <jkew@mozilla.com>
Tue, 16 Oct 2012 20:41:20 +0100
changeset 110589 1ee9ac5c2a0a0a02b904a55d5c4ec1fbd9652225
parent 110588 430a6d608f0feacfbf991af8aa470b1db395532c
child 110590 0cedf8847b2d426862e134e0beb87f209fc99ca7
push id93
push usernmatsakis@mozilla.com
push dateWed, 31 Oct 2012 21:26:57 +0000
reviewerssmichaud
bugs794038
milestone19.0a1
bug 794038 pt 2.1 - update mSizeConstraints when the device resolution of the window changes. r=smichaud
widget/cocoa/nsCocoaWindow.mm
--- a/widget/cocoa/nsCocoaWindow.mm
+++ b/widget/cocoa/nsCocoaWindow.mm
@@ -1422,16 +1422,35 @@ nsCocoaWindow::BackingScaleFactorChanged
   CGFloat newScale = nsCocoaUtils::GetBackingScaleFactor(mWindow);
 
   // ignore notification if it hasn't really changed (or maybe we have
   // disabled HiDPI mode via prefs)
   if (mBackingScaleFactor == newScale) {
     return;
   }
 
+  if (mBackingScaleFactor > 0.0) {
+    // convert size constraints to the new device pixel coordinate space
+    double scaleFactor = newScale / mBackingScaleFactor;
+    mSizeConstraints.mMinSize.width =
+      NSToIntRound(mSizeConstraints.mMinSize.width * scaleFactor);
+    mSizeConstraints.mMinSize.height =
+      NSToIntRound(mSizeConstraints.mMinSize.height * scaleFactor);
+    if (mSizeConstraints.mMaxSize.width < NS_MAXSIZE) {
+      mSizeConstraints.mMaxSize.width =
+        NS_MIN(NS_MAXSIZE,
+               NSToIntRound(mSizeConstraints.mMaxSize.width * scaleFactor));
+    }
+    if (mSizeConstraints.mMaxSize.height < NS_MAXSIZE) {
+      mSizeConstraints.mMaxSize.height =
+        NS_MIN(NS_MAXSIZE,
+               NSToIntRound(mSizeConstraints.mMaxSize.height * scaleFactor));
+    }
+  }
+
   mBackingScaleFactor = newScale;
 
   if (!mWidgetListener || mWidgetListener->GetXULWindow()) {
     return;
   }
 
   nsIPresShell* presShell = mWidgetListener->GetPresShell();
   if (presShell) {