diff --git a/layout/xul/base/src/nsMenuPopupFrame.cpp b/layout/xul/base/src/nsMenuPopupFrame.cpp index e3cc432b3d83..81e2f93a0bba 100644 --- a/layout/xul/base/src/nsMenuPopupFrame.cpp +++ b/layout/xul/base/src/nsMenuPopupFrame.cpp @@ -1318,10 +1318,11 @@ nsMenuPopupFrame::GetConstraintRect(const nsRect& aAnchorRect, // so we should use the same screen. Otherwise, use the screen where the // anchor is located. nsRect rect = mInContentShell ? aRootScreenRect : aAnchorRect; - int32_t width = rect.width > 0 ? presContext->AppUnitsToDevPixels(rect.width) : 1; - int32_t height = rect.height > 0 ? presContext->AppUnitsToDevPixels(rect.height) : 1; - sm->ScreenForRect(presContext->AppUnitsToDevPixels(rect.x), - presContext->AppUnitsToDevPixels(rect.y), + // nsIScreenManager::ScreenForRect wants the coordinates in CSS pixels + int32_t width = NS_MAX(1, nsPresContext::AppUnitsToIntCSSPixels(rect.width)); + int32_t height = NS_MAX(1, nsPresContext::AppUnitsToIntCSSPixels(rect.height)); + sm->ScreenForRect(nsPresContext::AppUnitsToIntCSSPixels(rect.x), + nsPresContext::AppUnitsToIntCSSPixels(rect.y), width, height, getter_AddRefs(screen)); if (screen) { // get the total screen area if the popup is allowed to overlap it.