Skip to content

Commit

Permalink
bug 794038 pt 0.9 - provide an unscaledDevicePixelsPerCSSPixel attrib…
Browse files Browse the repository at this point in the history
…ute on nsIBaseWindow to expose the default device-pix/css-pix ratio. r=roc
  • Loading branch information
jfkthame committed Oct 16, 2012
1 parent 49b40a7 commit 9325209
Show file tree
Hide file tree
Showing 7 changed files with 63 additions and 2 deletions.
17 changes: 17 additions & 0 deletions docshell/base/nsDocShell.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4933,6 +4933,23 @@ nsDocShell::Destroy()
return NS_OK;
}

NS_IMETHODIMP
nsDocShell::GetUnscaledDevicePixelsPerCSSPixel(double *aScale)
{
if (mParentWidget) {
*aScale = mParentWidget->GetDefaultScale();
return NS_OK;
}

nsCOMPtr<nsIBaseWindow> ownerWindow(do_QueryInterface(mTreeOwner));
if (ownerWindow) {
return ownerWindow->GetUnscaledDevicePixelsPerCSSPixel(aScale);
}

*aScale = 1.0;
return NS_OK;
}

NS_IMETHODIMP
nsDocShell::SetPosition(int32_t x, int32_t y)
{
Expand Down
11 changes: 11 additions & 0 deletions embedding/browser/webBrowser/nsDocShellTreeOwner.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -470,6 +470,17 @@ nsDocShellTreeOwner::Destroy()
return NS_ERROR_NULL_POINTER;
}

NS_IMETHODIMP
nsDocShellTreeOwner::GetUnscaledDevicePixelsPerCSSPixel(double *aScale)
{
if (mWebBrowser) {
return mWebBrowser->GetUnscaledDevicePixelsPerCSSPixel(aScale);
}

*aScale = 1.0;
return NS_OK;
}

NS_IMETHODIMP
nsDocShellTreeOwner::SetPosition(int32_t aX, int32_t aY)
{
Expand Down
6 changes: 6 additions & 0 deletions embedding/browser/webBrowser/nsWebBrowser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1239,6 +1239,12 @@ NS_IMETHODIMP nsWebBrowser::Destroy()
return NS_OK;
}

NS_IMETHODIMP nsWebBrowser::GetUnscaledDevicePixelsPerCSSPixel(double *aScale)
{
*aScale = mParentWidget ? mParentWidget->GetDefaultScale() : 1.0;
return NS_OK;
}

NS_IMETHODIMP nsWebBrowser::SetPosition(int32_t aX, int32_t aY)
{
int32_t cx = 0;
Expand Down
13 changes: 11 additions & 2 deletions widget/nsIBaseWindow.idl
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ typedef voidPtr nativeWindow;
* but rather a common set that nearly all windowed objects support.
*/

[scriptable, uuid(7144AC8B-6702-4A4B-A73D-D1D4E9717E46)]
[scriptable, uuid(9DA319F3-EEE6-4504-81A5-6A19CF6215BF)]
interface nsIBaseWindow : nsISupports
{
/*
Expand Down Expand Up @@ -182,7 +182,16 @@ interface nsIBaseWindow : nsISupports
lives if it has not had to create its own widget.
*/
[noscript] readonly attribute nsIWidget mainWidget;


/*
The number of device pixels per CSS pixel used on this window's current
screen at the default zoom level.
This is the value returned by GetDefaultScale() of the underlying widget.
Note that this may change if the window is moved between screens with
differing resolutions.
*/
readonly attribute double unscaledDevicePixelsPerCSSPixel;

/**
* Give the window focus.
*/
Expand Down
6 changes: 6 additions & 0 deletions xpfe/appshell/src/nsChromeTreeOwner.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -348,6 +348,12 @@ NS_IMETHODIMP nsChromeTreeOwner::Destroy()
return mXULWindow->Destroy();
}

NS_IMETHODIMP nsChromeTreeOwner::GetUnscaledDevicePixelsPerCSSPixel(double *aScale)
{
NS_ENSURE_STATE(mXULWindow);
return mXULWindow->GetUnscaledDevicePixelsPerCSSPixel(aScale);
}

NS_IMETHODIMP nsChromeTreeOwner::SetPosition(int32_t x, int32_t y)
{
NS_ENSURE_STATE(mXULWindow);
Expand Down
6 changes: 6 additions & 0 deletions xpfe/appshell/src/nsContentTreeOwner.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -565,6 +565,12 @@ NS_IMETHODIMP nsContentTreeOwner::Destroy()
return mXULWindow->Destroy();
}

NS_IMETHODIMP nsContentTreeOwner::GetUnscaledDevicePixelsPerCSSPixel(double* aScale)
{
NS_ENSURE_STATE(mXULWindow);
return mXULWindow->GetUnscaledDevicePixelsPerCSSPixel(aScale);
}

NS_IMETHODIMP nsContentTreeOwner::SetPosition(int32_t aX, int32_t aY)
{
NS_ENSURE_STATE(mXULWindow);
Expand Down
6 changes: 6 additions & 0 deletions xpfe/appshell/src/nsXULWindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -531,6 +531,12 @@ NS_IMETHODIMP nsXULWindow::Destroy()
return NS_OK;
}

NS_IMETHODIMP nsXULWindow::GetUnscaledDevicePixelsPerCSSPixel(double *aScale)
{
*aScale = mWindow ? mWindow->GetDefaultScale() : 1.0;
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
Expand Down

0 comments on commit 9325209

Please sign in to comment.