Bug 1160014 part 2 - Move some procedures in nsBaseWidget::MakeFullScreen to individual methods. r=roc

The two new methods will be reused by code in later patches.

--HG--
extra : source : 3387749f3d18e5c8dc6a6b0dab74903cff7ea57f
This commit is contained in:
Xidorn Quan 2015-07-13 20:44:36 +10:00
Родитель de00198603
Коммит 68dd069739
2 изменённых файлов: 46 добавлений и 27 удалений

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

@ -792,37 +792,19 @@ NS_IMETHODIMP nsBaseWidget::MakeFullScreen(bool aFullScreen, nsIScreen* aScreen)
if (aFullScreen) {
if (!mOriginalBounds)
mOriginalBounds = new nsIntRect();
GetScreenBounds(*mOriginalBounds);
// convert dev pix to display pix for window manipulation
CSSToLayoutDeviceScale scale = GetDefaultScale();
mOriginalBounds->x = NSToIntRound(mOriginalBounds->x / scale.scale);
mOriginalBounds->y = NSToIntRound(mOriginalBounds->y / scale.scale);
mOriginalBounds->width = NSToIntRound(mOriginalBounds->width / scale.scale);
mOriginalBounds->height = NSToIntRound(mOriginalBounds->height / scale.scale);
*mOriginalBounds = GetScaledScreenBounds();
// Move to top-left corner of screen and size to the screen dimensions
nsCOMPtr<nsIScreenManager> screenManager;
screenManager = do_GetService("@mozilla.org/gfx/screenmanager;1");
NS_ASSERTION(screenManager, "Unable to grab screenManager.");
if (screenManager) {
nsCOMPtr<nsIScreen> screen = aScreen;
if (!screen) {
// no screen was passed in, use the one that the window is on
screenManager->ScreenForRect(mOriginalBounds->x,
mOriginalBounds->y,
mOriginalBounds->width,
mOriginalBounds->height,
getter_AddRefs(screen));
screen = GetWidgetScreen();
}
if (screen) {
int32_t left, top, width, height;
if (NS_SUCCEEDED(screen->GetRectDisplayPix(&left, &top, &width, &height))) {
Resize(left, top, width, height, true);
}
}
}
} else if (mOriginalBounds) {
Resize(mOriginalBounds->x, mOriginalBounds->y, mOriginalBounds->width,
mOriginalBounds->height, true);
@ -1758,6 +1740,36 @@ nsBaseWidget::GetRootAccessible()
#endif // ACCESSIBILITY
nsIntRect
nsBaseWidget::GetScaledScreenBounds()
{
nsIntRect bounds;
GetScreenBounds(bounds);
CSSToLayoutDeviceScale scale = GetDefaultScale();
bounds.x = NSToIntRound(bounds.x / scale.scale);
bounds.y = NSToIntRound(bounds.y / scale.scale);
bounds.width = NSToIntRound(bounds.width / scale.scale);
bounds.height = NSToIntRound(bounds.height / scale.scale);
return bounds;
}
already_AddRefed<nsIScreen>
nsBaseWidget::GetWidgetScreen()
{
nsCOMPtr<nsIScreenManager> screenManager;
screenManager = do_GetService("@mozilla.org/gfx/screenmanager;1");
if (!screenManager) {
return nullptr;
}
nsIntRect bounds = GetScaledScreenBounds();
nsCOMPtr<nsIScreen> screen;
screenManager->ScreenForRect(bounds.x, bounds.y,
bounds.width, bounds.height,
getter_AddRefs(screen));
return screen.forget();
}
nsresult
nsIWidget::SynthesizeNativeTouchTap(nsIntPoint aPointerScreenPoint, bool aLongTap,
nsIObserver* aObserver)

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

@ -284,6 +284,13 @@ public:
return aClientSize;
}
// return the widget's outside dimensions
// in global coordinates in display pixel.
nsIntRect GetScaledScreenBounds();
// return the screen the widget is in.
already_AddRefed<nsIScreen> GetWidgetScreen();
// return true if this is a popup widget with a native titlebar
bool IsPopupWithTitleBar() const
{