From e1edc2634791e9aad357b5ba2e264ab0df9c55f2 Mon Sep 17 00:00:00 2001 From: Ms2ger Date: Sun, 29 Jun 2014 17:31:12 +0200 Subject: [PATCH] Bug 968804 - Part k: Add outer window assertions to GetScrollXY; r=khuey --- dom/base/nsGlobalWindow.cpp | 17 +++++++++-------- dom/base/nsGlobalWindow.h | 5 +++-- 2 files changed, 12 insertions(+), 10 deletions(-) diff --git a/dom/base/nsGlobalWindow.cpp b/dom/base/nsGlobalWindow.cpp index 8a33325e0fb5..707f5f060ed9 100644 --- a/dom/base/nsGlobalWindow.cpp +++ b/dom/base/nsGlobalWindow.cpp @@ -5728,10 +5728,9 @@ nsGlobalWindow::GetScrollMaxY(int32_t* aScrollMaxY) } CSSIntPoint -nsGlobalWindow::GetScrollXY(bool aDoFlush, ErrorResult& aError) +nsGlobalWindow::GetScrollXY(bool aDoFlush) { - FORWARD_TO_OUTER_OR_THROW(GetScrollXY, (aDoFlush, aError), aError, - CSSIntPoint(0, 0)); + MOZ_ASSERT(IsOuterWindow()); if (aDoFlush) { FlushPendingNotifications(Flush_Layout); @@ -5749,7 +5748,7 @@ nsGlobalWindow::GetScrollXY(bool aDoFlush, ErrorResult& aError) // Oh, well. This is the expensive case -- the window is scrolled and we // didn't actually flush yet. Repeat, but with a flush, since the content // may get shorter and hence our scroll position may decrease. - return GetScrollXY(true, aError); + return GetScrollXY(true); } return sf->GetScrollPositionCSSPixels(); @@ -5758,7 +5757,8 @@ nsGlobalWindow::GetScrollXY(bool aDoFlush, ErrorResult& aError) int32_t nsGlobalWindow::GetScrollX(ErrorResult& aError) { - return GetScrollXY(false, aError).x; + FORWARD_TO_OUTER_OR_THROW(GetScrollX, (aError), aError, 0); + return GetScrollXY(false).x; } NS_IMETHODIMP @@ -5766,14 +5766,15 @@ nsGlobalWindow::GetScrollX(int32_t* aScrollX) { NS_ENSURE_ARG_POINTER(aScrollX); ErrorResult rv; - *aScrollX = GetScrollXY(false, rv).x; + *aScrollX = GetScrollX(rv); return rv.ErrorCode(); } int32_t nsGlobalWindow::GetScrollY(ErrorResult& aError) { - return GetScrollXY(false, aError).y; + FORWARD_TO_OUTER_OR_THROW(GetScrollY, (aError), aError, 0); + return GetScrollXY(false).y; } NS_IMETHODIMP @@ -5781,7 +5782,7 @@ nsGlobalWindow::GetScrollY(int32_t* aScrollY) { NS_ENSURE_ARG_POINTER(aScrollY); ErrorResult rv; - *aScrollY = GetScrollXY(false, rv).y; + *aScrollY = GetScrollY(rv); return rv.ErrorCode(); } diff --git a/dom/base/nsGlobalWindow.h b/dom/base/nsGlobalWindow.h index 3ed3d947e3bc..b72dfe006831 100644 --- a/dom/base/nsGlobalWindow.h +++ b/dom/base/nsGlobalWindow.h @@ -1279,8 +1279,9 @@ protected: // If aDoFlush is true, we'll flush our own layout; otherwise we'll try to // just flush our parent and only flush ourselves if we think we need to. - mozilla::CSSIntPoint GetScrollXY(bool aDoFlush, mozilla::ErrorResult& aError); - nsresult GetScrollXY(int32_t* aScrollX, int32_t* aScrollY, bool aDoFlush); + // Outer windows only. + mozilla::CSSIntPoint GetScrollXY(bool aDoFlush); + void GetScrollMaxXY(int32_t* aScrollMaxX, int32_t* aScrollMaxY, mozilla::ErrorResult& aError);