Bug 943668 - ensure window.screenX and .screenY return css pixels. r=roc
authorMark Hammond <mhammond@skippinet.com.au>
Tue, 03 Dec 2013 16:36:33 +1100
changeset 173203 9d996ae7fc46ae0e7de42241b714b39b997f1828
parent 173202 ddd2dbbd9b2df8155d02c27fad4094ac1f545da2
child 173204 8d562b33673102fe9cc785b61a5055911ad110ec
push id3224
push userlsblakk@mozilla.com
push dateTue, 04 Feb 2014 01:06:49 +0000
treeherdermozilla-beta@60c04d0987f1 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersroc
bugs943668
milestone28.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 943668 - ensure window.screenX and .screenY return css pixels. r=roc
dom/base/nsGlobalWindow.cpp
dom/base/nsGlobalWindow.h
--- a/dom/base/nsGlobalWindow.cpp
+++ b/dom/base/nsGlobalWindow.cpp
@@ -4721,32 +4721,34 @@ nsGlobalWindow::SetOuterHeight(int32_t a
   SetOuterHeight(aOuterHeight, rv);
 
   return rv.ErrorCode();
 }
 
 nsIntPoint
 nsGlobalWindow::GetScreenXY(ErrorResult& aError)
 {
-  FORWARD_TO_OUTER_OR_THROW(GetScreenXY, (aError), aError, nsIntPoint(0, 0));
+  MOZ_ASSERT(IsOuterWindow());
 
   nsCOMPtr<nsIBaseWindow> treeOwnerAsWin = GetTreeOwnerWindow();
   if (!treeOwnerAsWin) {
     aError.Throw(NS_ERROR_FAILURE);
     return nsIntPoint(0, 0);
   }
 
   int32_t x = 0, y = 0;
   aError = treeOwnerAsWin->GetPosition(&x, &y);
   return nsIntPoint(x, y);
 }
 
 int32_t
 nsGlobalWindow::GetScreenX(ErrorResult& aError)
 {
+  FORWARD_TO_OUTER_OR_THROW(GetScreenX, (aError), aError, 0);
+
   return DevToCSSIntPixels(GetScreenXY(aError).x);
 }
 
 NS_IMETHODIMP
 nsGlobalWindow::GetScreenX(int32_t* aScreenX)
 {
   ErrorResult rv;
   *aScreenX = GetScreenX(rv);
@@ -5086,16 +5088,18 @@ nsGlobalWindow::SetScreenX(int32_t aScre
   SetScreenX(aScreenX, rv);
 
   return rv.ErrorCode();
 }
 
 int32_t
 nsGlobalWindow::GetScreenY(ErrorResult& aError)
 {
+  FORWARD_TO_OUTER_OR_THROW(GetScreenY, (aError), aError, 0);
+
   return DevToCSSIntPixels(GetScreenXY(aError).y);
 }
 
 NS_IMETHODIMP
 nsGlobalWindow::GetScreenY(int32_t* aScreenY)
 {
   ErrorResult rv;
   *aScreenY = GetScreenY(rv);
--- a/dom/base/nsGlobalWindow.h
+++ b/dom/base/nsGlobalWindow.h
@@ -1286,17 +1286,17 @@ protected:
                            mozilla::ErrorResult& aError);
   nsresult GetComputedStyleHelper(nsIDOMElement* aElt,
                                   const nsAString& aPseudoElt,
                                   bool aDefaultStylesOnly,
                                   nsIDOMCSSStyleDeclaration** aReturn);
 
   void PreloadLocalStorage();
 
-  // Returns device pixels.
+  // Returns device pixels.  Outer windows only.
   nsIntPoint GetScreenXY(mozilla::ErrorResult& aError);
 
   int32_t RequestAnimationFrame(const nsIDocument::FrameRequestCallbackHolder& aCallback,
                                 mozilla::ErrorResult& aError);
 
   nsGlobalWindow* InnerForSetTimeoutOrInterval(mozilla::ErrorResult& aError);
 
   mozilla::dom::Element* GetRealFrameElement(mozilla::ErrorResult& aError);