mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-10 03:45:46 +00:00
older and wiser, making previous attempt to return correct clientrect actually work. r:saari@netscape.com
This commit is contained in:
parent
849a797fa5
commit
0c12e35c43
@ -42,6 +42,7 @@ nsDeviceContextWin :: nsDeviceContextWin()
|
||||
mHeightFloat = 0.0f;
|
||||
mWidth = -1;
|
||||
mHeight = -1;
|
||||
mClientRectConverted = PR_FALSE;
|
||||
mSpec = nsnull;
|
||||
}
|
||||
|
||||
@ -113,10 +114,6 @@ void nsDeviceContextWin :: CommonInit(HDC aDC)
|
||||
mPaletteInfo.sizePalette = (PRUint8)::GetDeviceCaps(aDC, SIZEPALETTE);
|
||||
mPaletteInfo.numReserved = (PRUint8)::GetDeviceCaps(aDC, NUMRESERVED);
|
||||
|
||||
// Weird little dance ensues. width is stored in pixels, converted to twips
|
||||
// (and stored) on the occasion of the first call of the accessor method.
|
||||
// Not feeling much like that's a useful optimization and wanting to store
|
||||
// two versions of clientrect as well, clientrect is just stored in twips.
|
||||
mClientRect.width = ::GetDeviceCaps(aDC, HORZRES);
|
||||
mClientRect.height = ::GetDeviceCaps(aDC, VERTRES);
|
||||
mWidthFloat = (float)mClientRect.width;
|
||||
@ -125,13 +122,11 @@ void nsDeviceContextWin :: CommonInit(HDC aDC)
|
||||
{
|
||||
RECT workArea;
|
||||
::SystemParametersInfo(SPI_GETWORKAREA, 0, &workArea, 0);
|
||||
mClientRect.x = NSToIntRound(workArea.left * mDevUnitsToAppUnits);
|
||||
mClientRect.y = NSToIntRound(workArea.top * mDevUnitsToAppUnits);
|
||||
mClientRect.x = workArea.left;
|
||||
mClientRect.y = workArea.top;
|
||||
mClientRect.width = workArea.right - workArea.left;
|
||||
mClientRect.height = workArea.bottom - workArea.top;
|
||||
}
|
||||
mClientRect.width = NSToIntRound(mClientRect.width * mDevUnitsToAppUnits);
|
||||
mClientRect.height = NSToIntRound(mClientRect.height * mDevUnitsToAppUnits);
|
||||
|
||||
DeviceContextImpl::CommonInit();
|
||||
}
|
||||
@ -559,6 +554,14 @@ NS_IMETHODIMP nsDeviceContextWin :: GetDeviceSurfaceDimensions(PRInt32 &aWidth,
|
||||
|
||||
NS_IMETHODIMP nsDeviceContextWin :: GetClientRect(nsRect &aRect)
|
||||
{
|
||||
if (!mClientRectConverted) {
|
||||
mClientRect.x = NSToIntRound(mClientRect.x * mDevUnitsToAppUnits);
|
||||
mClientRect.y = NSToIntRound(mClientRect.y * mDevUnitsToAppUnits);
|
||||
mClientRect.width = NSToIntRound(mClientRect.width * mDevUnitsToAppUnits);
|
||||
mClientRect.height = NSToIntRound(mClientRect.height * mDevUnitsToAppUnits);
|
||||
mClientRectConverted = PR_TRUE;
|
||||
}
|
||||
|
||||
aRect = mClientRect;
|
||||
return NS_OK;
|
||||
}
|
||||
|
@ -85,6 +85,7 @@ protected:
|
||||
PRInt32 mWidth;
|
||||
PRInt32 mHeight;
|
||||
nsRect mClientRect;
|
||||
PRBool mClientRectConverted;
|
||||
nsIDeviceContextSpec *mSpec;
|
||||
|
||||
public:
|
||||
|
Loading…
Reference in New Issue
Block a user