bug 803030 - convert display to device pixels before creating the popup child view. r=smichaud

This commit is contained in:
Jonathan Kew 2012-10-18 11:38:26 +01:00
Родитель f3f7e1b020
Коммит bb8f6f0e44
1 изменённых файлов: 16 добавлений и 4 удалений

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

@ -195,7 +195,7 @@ static NSScreen *FindTargetScreenForRect(const nsIntRect& aRect)
// fits the rect to the screen that contains the largest area of it,
// or to aScreen if a screen is passed in
// NB: this operates with aRect in global CSS pixels
// NB: this operates with aRect in global display pixels
static void FitRectToVisibleAreaForScreen(nsIntRect &aRect, NSScreen *aScreen)
{
if (!aScreen) {
@ -239,7 +239,7 @@ static bool UseNativePopupWindows()
#endif /* MOZ_USE_NATIVE_POPUP_WINDOWS */
}
// aRect here is specified in CSS pixels
// aRect here is specified in global display pixels
nsresult nsCocoaWindow::Create(nsIWidget *aParent,
nsNativeWidget aNativeParent,
const nsIntRect &aRect,
@ -262,6 +262,10 @@ nsresult nsCocoaWindow::Create(nsIWidget *aParent,
// Ensure that the toolkit is created.
nsToolkit::GetToolkit();
// newBounds is still display (global screen) pixels at this point;
// fortunately, BaseCreate doesn't actually use it so we don't
// need to worry about trying to convert it to device pixels
// when we don't have a window (or dev context, perhaps) yet
Inherited::BaseCreate(aParent, newBounds, aContext, aInitData);
mParent = aParent;
@ -270,14 +274,22 @@ nsresult nsCocoaWindow::Create(nsIWidget *aParent,
if ((mWindowType == eWindowType_popup) && UseNativePopupWindows())
return NS_OK;
nsresult rv = CreateNativeWindow(nsCocoaUtils::GeckoRectToCocoaRect(newBounds),
mBorderStyle, false);
nsresult rv =
CreateNativeWindow(nsCocoaUtils::GeckoRectToCocoaRect(newBounds),
mBorderStyle, false);
NS_ENSURE_SUCCESS(rv, rv);
if (mWindowType == eWindowType_popup) {
if (aInitData->mIsDragPopup) {
[mWindow setIgnoresMouseEvents:YES];
}
// now we can convert newBounds to device pixels for the window we created,
// as the child view expects a rect expressed in the dev pix of its parent
double scale = BackingScaleFactor();
newBounds.x *= scale;
newBounds.y *= scale;
newBounds.width *= scale;
newBounds.height *= scale;
return CreatePopupContentView(newBounds, aContext);
}