Bug 1247335 - patch 1 - Provide a desktop-pixel variant of SetPosition on nsIBaseWindow and its implementations. r=emk

This commit is contained in:
Jonathan Kew 2016-02-18 10:46:16 +00:00
Родитель 83b2b79f9d
Коммит cb99502b79
8 изменённых файлов: 67 добавлений и 9 удалений

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

@ -5814,6 +5814,15 @@ nsDocShell::SetPosition(int32_t aX, int32_t aY)
return NS_OK;
}
NS_IMETHODIMP
nsDocShell::SetPositionDesktopPix(int32_t aX, int32_t aY)
{
// Added to nsIBaseWindow in bug 1247335;
// implement if a use-case is found.
NS_ASSERTION(false, "implement me!");
return NS_ERROR_NOT_IMPLEMENTED;
}
NS_IMETHODIMP
nsDocShell::GetPosition(int32_t* aX, int32_t* aY)
{

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

@ -7063,7 +7063,6 @@ nsGlobalWindow::MoveToOuter(int32_t aXPos, int32_t aYPos, ErrorResult& aError, b
getter_AddRefs(screen));
}
LayoutDevicePoint devPos;
if (screen) {
int32_t screenLeftDeskPx, screenTopDeskPx, w, h;
screen->GetRectDisplayPix(&screenLeftDeskPx, &screenTopDeskPx, &w, &h);
@ -7072,20 +7071,19 @@ nsGlobalWindow::MoveToOuter(int32_t aXPos, int32_t aYPos, ErrorResult& aError, b
double scale;
screen->GetDefaultCSSScaleFactor(&scale);
devPos = cssPos * CSSToLayoutDeviceScale(scale);
LayoutDevicePoint devPos = cssPos * CSSToLayoutDeviceScale(scale);
int32_t screenLeftDevPx, screenTopDevPx;
screen->GetRect(&screenLeftDevPx, &screenTopDevPx, &w, &h);
devPos.x += screenLeftDevPx;
devPos.y += screenTopDevPx;
screen->GetContentsScaleFactor(&scale);
DesktopPoint deskPos = devPos / DesktopToLayoutDeviceScale(scale);
aError = treeOwnerAsWin->SetPositionDesktopPix(screenLeftDeskPx + deskPos.x,
screenTopDeskPx + deskPos.y);
} else {
// We couldn't find a screen? Just assume a 1:1 mapping.
CSSIntPoint cssPos(aXPos, aXPos);
CheckSecurityLeftAndTop(&cssPos.x, &cssPos.y, aCallerIsChrome);
devPos = cssPos * CSSToLayoutDeviceScale(1.0);
LayoutDevicePoint devPos = cssPos * CSSToLayoutDeviceScale(1.0);
aError = treeOwnerAsWin->SetPosition(devPos.x, devPos.y);
}
aError = treeOwnerAsWin->SetPosition(devPos.x, devPos.y);
}
void

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

@ -570,6 +570,15 @@ nsDocShellTreeOwner::GetDevicePixelsPerDesktopPixel(double* aScale)
return NS_OK;
}
NS_IMETHODIMP
nsDocShellTreeOwner::SetPositionDesktopPix(int32_t aX, int32_t aY)
{
// Added to nsIBaseWindow in bug 1247335;
// implement if a use-case is found.
NS_ASSERTION(false, "implement me!");
return NS_ERROR_NOT_IMPLEMENTED;
}
NS_IMETHODIMP
nsDocShellTreeOwner::SetPosition(int32_t aX, int32_t aY)
{

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

@ -1302,6 +1302,15 @@ nsWebBrowser::GetDevicePixelsPerDesktopPixel(double* aScale)
return NS_OK;
}
NS_IMETHODIMP
nsWebBrowser::SetPositionDesktopPix(int32_t aX, int32_t aY)
{
// Added to nsIBaseWindow in bug 1247335;
// implement if a use-case is found.
NS_ASSERTION(false, "implement me!");
return NS_ERROR_NOT_IMPLEMENTED;
}
NS_IMETHODIMP
nsWebBrowser::SetPosition(int32_t aX, int32_t aY)
{

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

@ -91,6 +91,12 @@ interface nsIBaseWindow : nsISupports
*/
void setPosition(in long x, in long y);
/*
Ditto, with arguments in global desktop pixels rather than (potentially
ambiguous) device pixels
*/
void setPositionDesktopPix(in long x, in long y);
/*
Gets the current x and y coordinates of the control. This is relatie to the
parent window.

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

@ -388,6 +388,12 @@ NS_IMETHODIMP nsChromeTreeOwner::GetDevicePixelsPerDesktopPixel(double *aScale)
return mXULWindow->GetDevicePixelsPerDesktopPixel(aScale);
}
NS_IMETHODIMP nsChromeTreeOwner::SetPositionDesktopPix(int32_t x, int32_t y)
{
NS_ENSURE_STATE(mXULWindow);
return mXULWindow->SetPositionDesktopPix(x, y);
}
NS_IMETHODIMP nsChromeTreeOwner::SetPosition(int32_t x, int32_t y)
{
NS_ENSURE_STATE(mXULWindow);

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

@ -628,6 +628,12 @@ NS_IMETHODIMP nsContentTreeOwner::GetDevicePixelsPerDesktopPixel(double* aScale)
return mXULWindow->GetDevicePixelsPerDesktopPixel(aScale);
}
NS_IMETHODIMP nsContentTreeOwner::SetPositionDesktopPix(int32_t aX, int32_t aY)
{
NS_ENSURE_STATE(mXULWindow);
return mXULWindow->SetPositionDesktopPix(aX, aY);
}
NS_IMETHODIMP nsContentTreeOwner::SetPosition(int32_t aX, int32_t aY)
{
NS_ENSURE_STATE(mXULWindow);

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

@ -615,6 +615,21 @@ nsXULWindow::GetScaleForDestinationPosition(int32_t aX, int32_t aY)
return scale;
}
NS_IMETHODIMP nsXULWindow::SetPositionDesktopPix(int32_t aX, int32_t aY)
{
nsresult rv = mWindow->Move(aX, aY);
NS_ENSURE_SUCCESS(rv, NS_ERROR_FAILURE);
if (!mChromeLoaded) {
// If we're called before the chrome is loaded someone obviously wants this
// window at this position. We don't persist this one-time position.
mIgnoreXULPosition = true;
return NS_OK;
}
PersistentAttributesDirty(PAD_POSITION);
SavePersistentAttributes();
return NS_OK;
}
NS_IMETHODIMP nsXULWindow::SetPosition(int32_t aX, int32_t aY)
{
// Don't reset the window's size mode here - platforms that don't want to move