From 7505fe3457a1ea1b438138ed49e8637eb852583c Mon Sep 17 00:00:00 2001 From: Jonathan Kew Date: Wed, 2 Mar 2016 12:15:19 +0000 Subject: [PATCH] Bug 1252347 - Provide missing implementations of nsIBaseWindow::SetPositionDesktopPix. r=emk --- docshell/base/nsDocShell.cpp | 12 ++++++++---- embedding/browser/nsDocShellTreeOwner.cpp | 11 +++++++---- embedding/browser/nsWebBrowser.cpp | 14 ++++++++++---- 3 files changed, 25 insertions(+), 12 deletions(-) diff --git a/docshell/base/nsDocShell.cpp b/docshell/base/nsDocShell.cpp index 587d6a871d1..eb6472d28f1 100644 --- a/docshell/base/nsDocShell.cpp +++ b/docshell/base/nsDocShell.cpp @@ -5820,10 +5820,14 @@ nsDocShell::SetPosition(int32_t aX, int32_t aY) 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; + nsCOMPtr ownerWindow(do_QueryInterface(mTreeOwner)); + if (ownerWindow) { + return ownerWindow->SetPositionDesktopPix(aX, aY); + } + + double scale = 1.0; + GetDevicePixelsPerDesktopPixel(&scale); + return SetPosition(NSToIntRound(aX * scale), NSToIntRound(aY * scale)); } NS_IMETHODIMP diff --git a/embedding/browser/nsDocShellTreeOwner.cpp b/embedding/browser/nsDocShellTreeOwner.cpp index dfe990e498f..03443645ce1 100644 --- a/embedding/browser/nsDocShellTreeOwner.cpp +++ b/embedding/browser/nsDocShellTreeOwner.cpp @@ -573,10 +573,13 @@ nsDocShellTreeOwner::GetDevicePixelsPerDesktopPixel(double* aScale) 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; + if (mWebBrowser) { + return mWebBrowser->SetPositionDesktopPix(aX, aY); + } + + double scale = 1.0; + GetDevicePixelsPerDesktopPixel(&scale); + return SetPosition(NSToIntRound(aX * scale), NSToIntRound(aY * scale)); } NS_IMETHODIMP diff --git a/embedding/browser/nsWebBrowser.cpp b/embedding/browser/nsWebBrowser.cpp index d656503d394..532b443ed52 100644 --- a/embedding/browser/nsWebBrowser.cpp +++ b/embedding/browser/nsWebBrowser.cpp @@ -1305,10 +1305,16 @@ nsWebBrowser::GetDevicePixelsPerDesktopPixel(double* aScale) 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; + // XXX jfkthame + // It's not clear to me whether this will be fully correct across + // potential multi-screen, mixed-DPI configurations for all platforms; + // we might need to add code paths that make it possible to pass the + // desktop-pix parameters all the way through to the native widget, + // to avoid the risk of device-pixel coords mapping to the wrong + // display on OS X with mixed retina/non-retina screens. + double scale = 1.0; + GetDevicePixelsPerDesktopPixel(&scale); + return SetPosition(NSToIntRound(aX * scale), NSToIntRound(aY * scale)); } NS_IMETHODIMP