Bug 1154125 - Ensure the context has up-to-date device pixel DPI scaling before using it in calling nsViewManager::SetWindowDimensions. r=mstange
authorJonathan Kew <jkew@mozilla.com>
Thu, 30 Jun 2016 12:27:29 +0100
changeset 383192 480bd162d285a6136cd900699eb6cb3e03545f2d
parent 383191 53c93df54e84c8a9585f45ea3019148f4b57cfad
child 383193 df6b25262c658e87715c98990d36a6b7fd8f8a0a
push id21963
push userdmitchell@mozilla.com
push dateFri, 01 Jul 2016 19:54:18 +0000
reviewersmstange
bugs1154125
milestone50.0a1
Bug 1154125 - Ensure the context has up-to-date device pixel DPI scaling before using it in calling nsViewManager::SetWindowDimensions. r=mstange
layout/base/nsDocumentViewer.cpp
--- a/layout/base/nsDocumentViewer.cpp
+++ b/layout/base/nsDocumentViewer.cpp
@@ -1914,16 +1914,24 @@ nsDocumentViewer::SetBoundsWithFlags(con
 
   if (mWindow && !mAttachedToParent) {
     // Resize the widget, but don't trigger repaint. Layout will generate
     // repaint requests during reflow.
     mWindow->Resize(aBounds.x, aBounds.y,
                     aBounds.width, aBounds.height,
                     false);
   } else if (mPresContext && mViewManager) {
+    // Ensure presContext's deviceContext is up to date, as we sometimes get
+    // here before a resolution-change notification has been fully handled
+    // during display configuration changes, especially when there are lots
+    // of windows/widgets competing to handle the notifications.
+    // (See bug 1154125.)
+    if (mPresContext->DeviceContext()->CheckDPIChange()) {
+      mPresContext->UIResolutionChanged();
+    }
     int32_t p2a = mPresContext->AppUnitsPerDevPixel();
     mViewManager->SetWindowDimensions(NSIntPixelsToAppUnits(mBounds.width, p2a),
                                       NSIntPixelsToAppUnits(mBounds.height, p2a),
                                       !!(aFlags & nsIContentViewer::eDelayResize));
   }
 
   // If there's a previous viewer, it's the one that's actually showing,
   // so be sure to resize it as well so it paints over the right area.