Bug 943668 - Ensure window.screenX and .screenY return css pixels. r=roc, a=bajaj
authorMark Hammond <mhammond@skippinet.com.au>
Tue, 03 Dec 2013 16:36:33 +1100
changeset 167619 5b7edf1432472363786370382013ec47962c394f
parent 167618 d53119cbd9e5c495eebcdb897cb1a514d99d7489
child 167620 5368478c4dde86a6adcbcff8c62423f4ed3aa307
push id428
push userbbajaj@mozilla.com
push dateTue, 28 Jan 2014 00:16:25 +0000
treeherdermozilla-release@cd72a7ff3a75 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersroc, bajaj
bugs943668
milestone27.0a2
Bug 943668 - Ensure window.screenX and .screenY return css pixels. r=roc, a=bajaj
dom/base/nsGlobalWindow.cpp
dom/base/nsGlobalWindow.h
--- a/dom/base/nsGlobalWindow.cpp
+++ b/dom/base/nsGlobalWindow.cpp
@@ -4693,32 +4693,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);
@@ -5056,16 +5058,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
@@ -1270,17 +1270,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);