Bug 890156 - patch 2 - Expose DevicePixelsPerDesktopPixel through nsIBaseWindow and its implementations. r=emk

This commit is contained in:
Jonathan Kew 2015-11-25 19:12:07 +00:00
parent ac01696be2
commit db11f6d02a
7 changed files with 69 additions and 1 deletions

View File

@ -5782,6 +5782,23 @@ nsDocShell::GetUnscaledDevicePixelsPerCSSPixel(double* aScale)
return NS_OK;
}
NS_IMETHODIMP
nsDocShell::GetDevicePixelsPerDesktopPixel(double* aScale)
{
if (mParentWidget) {
*aScale = mParentWidget->GetDesktopToDeviceScale().scale;
return NS_OK;
}
nsCOMPtr<nsIBaseWindow> ownerWindow(do_QueryInterface(mTreeOwner));
if (ownerWindow) {
return ownerWindow->GetDevicePixelsPerDesktopPixel(aScale);
}
*aScale = 1.0;
return NS_OK;
}
NS_IMETHODIMP
nsDocShell::SetPosition(int32_t aX, int32_t aY)
{

View File

@ -560,6 +560,17 @@ nsDocShellTreeOwner::GetUnscaledDevicePixelsPerCSSPixel(double* aScale)
return NS_OK;
}
NS_IMETHODIMP
nsDocShellTreeOwner::GetDevicePixelsPerDesktopPixel(double* aScale)
{
if (mWebBrowser) {
return mWebBrowser->GetDevicePixelsPerDesktopPixel(aScale);
}
*aScale = 1.0;
return NS_OK;
}
NS_IMETHODIMP
nsDocShellTreeOwner::SetPosition(int32_t aX, int32_t aY)
{

View File

@ -1294,6 +1294,14 @@ nsWebBrowser::GetUnscaledDevicePixelsPerCSSPixel(double* aScale)
return NS_OK;
}
NS_IMETHODIMP
nsWebBrowser::GetDevicePixelsPerDesktopPixel(double* aScale)
{
*aScale = mParentWidget ? mParentWidget->GetDesktopToDeviceScale().scale
: 1.0;
return NS_OK;
}
NS_IMETHODIMP
nsWebBrowser::SetPosition(int32_t aX, int32_t aY)
{

View File

@ -21,7 +21,7 @@ typedef voidPtr nativeWindow;
* but rather a common set that nearly all windowed objects support.
*/
[scriptable, uuid(9DA319F3-EEE6-4504-81A5-6A19CF6215BF)]
[scriptable, uuid(ca635529-a977-4552-9b8a-66187e54d882)]
interface nsIBaseWindow : nsISupports
{
/*
@ -192,6 +192,20 @@ interface nsIBaseWindow : nsISupports
*/
readonly attribute double unscaledDevicePixelsPerCSSPixel;
/*
The number of device pixels per display pixel on this window's current
screen. (The meaning of "display pixel" varies across OS environments;
it is the pixel units used by the desktop environment to manage screen
real estate and window positioning, which may correspond to (per-screen)
device pixels, or may be a virtual coordinate space that covers a multi-
monitor, mixed-dpi desktop space.)
This is the value returned by DevicePixelsPerDesktopPixel() of the underlying
widget.
Note that this may change if the window is moved between screens with
differing resolutions.
*/
readonly attribute double devicePixelsPerDesktopPixel;
/**
* Give the window focus.
*/

View File

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

View File

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

View File

@ -557,6 +557,12 @@ NS_IMETHODIMP nsXULWindow::Destroy()
return NS_OK;
}
NS_IMETHODIMP nsXULWindow::GetDevicePixelsPerDesktopPixel(double *aScale)
{
*aScale = mWindow ? mWindow->GetDesktopToDeviceScale().scale : 1.0;
return NS_OK;
}
NS_IMETHODIMP nsXULWindow::GetUnscaledDevicePixelsPerCSSPixel(double *aScale)
{
*aScale = mWindow ? mWindow->GetDefaultScale().scale : 1.0;