Bug 403067. mVisibleArea may get stale so use GetWindowDimensions() when we're going to do a SetWindowDimensions() with new dimensions. r+sr=dbaron

This commit is contained in:
roc+%cs.cmu.edu 2007-12-12 02:27:00 +00:00
Родитель 10a39dd9ba
Коммит 23193bfc9c
1 изменённых файлов: 18 добавлений и 8 удалений

Просмотреть файл

@ -739,14 +739,19 @@ void
nsPresContext::PreferenceChanged(const char* aPrefName)
{
if (!nsCRT::strcmp(aPrefName, "layout.css.dpi")) {
nsRect bounds(mVisibleArea);
bounds *= 1.0f / AppUnitsPerDevPixel();
// Re-fetch the view manager's window dimensions in case there's a deferred
// resize which hasn't affected our mVisibleArea yet
nscoord oldWidthAppUnits, oldHeightAppUnits;
nsIViewManager* vm = GetViewManager();
vm->GetWindowDimensions(&oldWidthAppUnits, &oldHeightAppUnits);
float oldWidthDevPixels = oldWidthAppUnits/AppUnitsPerDevPixel();
float oldHeightDevPixels = oldHeightAppUnits/AppUnitsPerDevPixel();
if (mDeviceContext->CheckDPIChange() && mShell) {
mDeviceContext->FlushFontCache();
nsIViewManager* vm = GetViewManager();
nscoord width = DevPixelsToAppUnits(bounds.width);
nscoord height = DevPixelsToAppUnits(bounds.height);
nscoord width = NSToCoordRound(oldWidthDevPixels*AppUnitsPerDevPixel());
nscoord height = NSToCoordRound(oldHeightDevPixels*AppUnitsPerDevPixel());
vm->SetWindowDimensions(width, height);
ClearStyleDataAndReflow();
@ -1156,13 +1161,18 @@ nsPresContext::SetFullZoom(float aZoom)
if (!mShell || mFullZoom == aZoom) {
return;
}
float oldWidth = mVisibleArea.width / float(mCurAppUnitsPerDevPixel);
float oldHeight = mVisibleArea.height / float(mCurAppUnitsPerDevPixel);
// Re-fetch the view manager's window dimensions in case there's a deferred
// resize which hasn't affected our mVisibleArea yet
nscoord oldWidthAppUnits, oldHeightAppUnits;
GetViewManager()->GetWindowDimensions(&oldWidthAppUnits, &oldHeightAppUnits);
float oldWidthDevPixels = oldWidthAppUnits / float(mCurAppUnitsPerDevPixel);
float oldHeightDevPixels = oldHeightAppUnits / float(mCurAppUnitsPerDevPixel);
if (mDeviceContext->SetPixelScale(aZoom)) {
mDeviceContext->FlushFontCache();
}
mFullZoom = aZoom;
GetViewManager()->SetWindowDimensions(oldWidth * AppUnitsPerDevPixel(), oldHeight * AppUnitsPerDevPixel());
GetViewManager()->SetWindowDimensions(NSToCoordRound(oldWidthDevPixels*AppUnitsPerDevPixel()),
NSToCoordRound(oldHeightDevPixels*AppUnitsPerDevPixel()));
ClearStyleDataAndReflow();
mCurAppUnitsPerDevPixel = AppUnitsPerDevPixel();
}