Bug 1216072 - Pass aCallerIsChrome in more places. r=bz

This commit is contained in:
Bobby Holley 2015-10-19 12:07:28 -07:00
parent 3a52188931
commit 6925386103
2 changed files with 52 additions and 51 deletions

View File

@ -4961,7 +4961,7 @@ nsGlobalWindow::GetInnerWidth(int32_t* aInnerWidth)
}
void
nsGlobalWindow::SetInnerWidthOuter(int32_t aInnerWidth, ErrorResult& aError)
nsGlobalWindow::SetInnerWidthOuter(int32_t aInnerWidth, ErrorResult& aError, bool aCallerIsChrome)
{
MOZ_RELEASE_ASSERT(IsOuterWindow());
@ -4970,7 +4970,7 @@ nsGlobalWindow::SetInnerWidthOuter(int32_t aInnerWidth, ErrorResult& aError)
return;
}
CheckSecurityWidthAndHeight(&aInnerWidth, nullptr);
CheckSecurityWidthAndHeight(&aInnerWidth, nullptr, aCallerIsChrome);
RefPtr<nsIPresShell> presShell = mDocShell->GetPresShell();
@ -4999,7 +4999,7 @@ nsGlobalWindow::SetInnerWidthOuter(int32_t aInnerWidth, ErrorResult& aError)
void
nsGlobalWindow::SetInnerWidth(int32_t aInnerWidth, ErrorResult& aError)
{
FORWARD_TO_OUTER_OR_THROW(SetInnerWidthOuter, (aInnerWidth, aError), aError, );
FORWARD_TO_OUTER_OR_THROW(SetInnerWidthOuter, (aInnerWidth, aError, nsContentUtils::IsCallerChrome()), aError, );
}
void
@ -5013,14 +5013,14 @@ nsGlobalWindow::SetInnerWidth(JSContext* aCx, JS::Handle<JS::Value> aValue,
NS_IMETHODIMP
nsGlobalWindow::SetInnerWidth(int32_t aInnerWidth)
{
FORWARD_TO_INNER(SetInnerWidth, (aInnerWidth), NS_ERROR_UNEXPECTED);
FORWARD_TO_OUTER(SetInnerWidth, (aInnerWidth), NS_ERROR_UNEXPECTED);
if (IsFrame()) {
return NS_OK;
}
ErrorResult rv;
SetInnerWidth(aInnerWidth, rv);
SetInnerWidthOuter(aInnerWidth, rv, /* aCallerIsChrome = */ true);
return rv.StealNSResult();
}
@ -5062,7 +5062,7 @@ nsGlobalWindow::GetInnerHeight(int32_t* aInnerHeight)
}
void
nsGlobalWindow::SetInnerHeightOuter(int32_t aInnerHeight, ErrorResult& aError)
nsGlobalWindow::SetInnerHeightOuter(int32_t aInnerHeight, ErrorResult& aError, bool aCallerIsChrome)
{
MOZ_RELEASE_ASSERT(IsOuterWindow());
@ -5081,7 +5081,7 @@ nsGlobalWindow::SetInnerHeightOuter(int32_t aInnerHeight, ErrorResult& aError)
nsRect shellArea = presContext->GetVisibleArea();
nscoord height = aInnerHeight;
nscoord width = shellArea.width;
CheckSecurityWidthAndHeight(nullptr, &height);
CheckSecurityWidthAndHeight(nullptr, &height, aCallerIsChrome);
SetCSSViewportWidthAndHeight(width,
nsPresContext::CSSPixelsToAppUnits(height));
return;
@ -5092,14 +5092,14 @@ nsGlobalWindow::SetInnerHeightOuter(int32_t aInnerHeight, ErrorResult& aError)
nsCOMPtr<nsIBaseWindow> docShellAsWin(do_QueryInterface(mDocShell));
docShellAsWin->GetSize(&width, &height);
CheckSecurityWidthAndHeight(nullptr, &aInnerHeight);
CheckSecurityWidthAndHeight(nullptr, &aInnerHeight, aCallerIsChrome);
aError = SetDocShellWidthAndHeight(width, CSSToDevIntPixels(aInnerHeight));
}
void
nsGlobalWindow::SetInnerHeight(int32_t aInnerHeight, ErrorResult& aError)
{
FORWARD_TO_OUTER_OR_THROW(SetInnerHeightOuter, (aInnerHeight, aError), aError, );
FORWARD_TO_OUTER_OR_THROW(SetInnerHeightOuter, (aInnerHeight, aError, nsContentUtils::IsCallerChrome()), aError, );
}
void
@ -5113,14 +5113,14 @@ nsGlobalWindow::SetInnerHeight(JSContext* aCx, JS::Handle<JS::Value> aValue,
NS_IMETHODIMP
nsGlobalWindow::SetInnerHeight(int32_t aInnerHeight)
{
FORWARD_TO_INNER(SetInnerHeight, (aInnerHeight), NS_ERROR_UNEXPECTED);
FORWARD_TO_OUTER(SetInnerHeight, (aInnerHeight), NS_ERROR_UNEXPECTED);
if (IsFrame()) {
return NS_OK;
}
ErrorResult rv;
SetInnerHeight(aInnerHeight, rv);
SetInnerHeightOuter(aInnerHeight, rv, /* aCallerIsChrome = */ true);
return rv.StealNSResult();
}
@ -5225,7 +5225,7 @@ nsGlobalWindow::GetOuterHeight(int32_t* aOuterHeight)
void
nsGlobalWindow::SetOuterSize(int32_t aLengthCSSPixels, bool aIsWidth,
ErrorResult& aError)
ErrorResult& aError, bool aCallerIsChrome)
{
MOZ_ASSERT(IsOuterWindow());
@ -5236,7 +5236,8 @@ nsGlobalWindow::SetOuterSize(int32_t aLengthCSSPixels, bool aIsWidth,
}
CheckSecurityWidthAndHeight(aIsWidth ? &aLengthCSSPixels : nullptr,
aIsWidth ? nullptr : &aLengthCSSPixels);
aIsWidth ? nullptr : &aLengthCSSPixels,
aCallerIsChrome);
int32_t width, height;
aError = treeOwnerAsWin->GetSize(&width, &height);
@ -5254,17 +5255,17 @@ nsGlobalWindow::SetOuterSize(int32_t aLengthCSSPixels, bool aIsWidth,
}
void
nsGlobalWindow::SetOuterWidthOuter(int32_t aOuterWidth, ErrorResult& aError)
nsGlobalWindow::SetOuterWidthOuter(int32_t aOuterWidth, ErrorResult& aError, bool aCallerIsChrome)
{
MOZ_RELEASE_ASSERT(IsOuterWindow());
SetOuterSize(aOuterWidth, true, aError);
SetOuterSize(aOuterWidth, true, aError, aCallerIsChrome);
}
void
nsGlobalWindow::SetOuterWidth(int32_t aOuterWidth, ErrorResult& aError)
{
FORWARD_TO_OUTER_OR_THROW(SetOuterWidthOuter, (aOuterWidth, aError), aError, );
FORWARD_TO_OUTER_OR_THROW(SetOuterWidthOuter, (aOuterWidth, aError, nsContentUtils::IsCallerChrome()), aError, );
}
void
@ -5278,30 +5279,30 @@ nsGlobalWindow::SetOuterWidth(JSContext* aCx, JS::Handle<JS::Value> aValue,
NS_IMETHODIMP
nsGlobalWindow::SetOuterWidth(int32_t aOuterWidth)
{
FORWARD_TO_INNER(SetOuterWidth, (aOuterWidth), NS_ERROR_UNEXPECTED);
FORWARD_TO_OUTER(SetOuterWidth, (aOuterWidth), NS_ERROR_UNEXPECTED);
if (IsFrame()) {
return NS_OK;
}
ErrorResult rv;
SetOuterWidth(aOuterWidth, rv);
SetOuterWidthOuter(aOuterWidth, rv, /* aCallerIsChrome = */ true);
return rv.StealNSResult();
}
void
nsGlobalWindow::SetOuterHeightOuter(int32_t aOuterHeight, ErrorResult& aError)
nsGlobalWindow::SetOuterHeightOuter(int32_t aOuterHeight, ErrorResult& aError, bool aCallerIsChrome)
{
MOZ_RELEASE_ASSERT(IsOuterWindow());
SetOuterSize(aOuterHeight, false, aError);
SetOuterSize(aOuterHeight, false, aError, aCallerIsChrome);
}
void
nsGlobalWindow::SetOuterHeight(int32_t aOuterHeight, ErrorResult& aError)
{
FORWARD_TO_OUTER_OR_THROW(SetOuterHeightOuter, (aOuterHeight, aError), aError, );
FORWARD_TO_OUTER_OR_THROW(SetOuterHeightOuter, (aOuterHeight, aError, nsContentUtils::IsCallerChrome()), aError, );
}
void
@ -5315,14 +5316,14 @@ nsGlobalWindow::SetOuterHeight(JSContext* aCx, JS::Handle<JS::Value> aValue,
NS_IMETHODIMP
nsGlobalWindow::SetOuterHeight(int32_t aOuterHeight)
{
FORWARD_TO_INNER(SetOuterHeight, (aOuterHeight), NS_ERROR_UNEXPECTED);
FORWARD_TO_OUTER(SetOuterHeight, (aOuterHeight), NS_ERROR_UNEXPECTED);
if (IsFrame()) {
return NS_OK;
}
ErrorResult rv;
SetOuterHeight(aOuterHeight, rv);
SetOuterHeightOuter(aOuterHeight, rv, /* aCallerIsChrome = */ true);
return rv.StealNSResult();
}
@ -5644,7 +5645,7 @@ nsGlobalWindow::MatchMedia(const nsAString& aMediaQueryList,
}
void
nsGlobalWindow::SetScreenXOuter(int32_t aScreenX, ErrorResult& aError)
nsGlobalWindow::SetScreenXOuter(int32_t aScreenX, ErrorResult& aError, bool aCallerIsChrome)
{
MOZ_RELEASE_ASSERT(IsOuterWindow());
@ -5660,7 +5661,7 @@ nsGlobalWindow::SetScreenXOuter(int32_t aScreenX, ErrorResult& aError)
return;
}
CheckSecurityLeftAndTop(&aScreenX, nullptr);
CheckSecurityLeftAndTop(&aScreenX, nullptr, aCallerIsChrome);
x = CSSToDevIntPixels(aScreenX);
aError = treeOwnerAsWin->SetPosition(x, y);
@ -5669,7 +5670,7 @@ nsGlobalWindow::SetScreenXOuter(int32_t aScreenX, ErrorResult& aError)
void
nsGlobalWindow::SetScreenX(int32_t aScreenX, ErrorResult& aError)
{
FORWARD_TO_OUTER_OR_THROW(SetScreenXOuter, (aScreenX, aError), aError, );
FORWARD_TO_OUTER_OR_THROW(SetScreenXOuter, (aScreenX, aError, nsContentUtils::IsCallerChrome()), aError, );
}
void
@ -5683,14 +5684,14 @@ nsGlobalWindow::SetScreenX(JSContext* aCx, JS::Handle<JS::Value> aValue,
NS_IMETHODIMP
nsGlobalWindow::SetScreenX(int32_t aScreenX)
{
FORWARD_TO_INNER(SetScreenX, (aScreenX), NS_ERROR_UNEXPECTED);
FORWARD_TO_OUTER(SetScreenX, (aScreenX), NS_ERROR_UNEXPECTED);
if (IsFrame()) {
return NS_OK;
}
ErrorResult rv;
SetScreenX(aScreenX, rv);
SetScreenXOuter(aScreenX, rv, /* aCallerIsChrome = */ true);
return rv.StealNSResult();
}
@ -5730,7 +5731,7 @@ nsGlobalWindow::GetScreenY(JSContext* aCx,
}
void
nsGlobalWindow::SetScreenYOuter(int32_t aScreenY, ErrorResult& aError)
nsGlobalWindow::SetScreenYOuter(int32_t aScreenY, ErrorResult& aError, bool aCallerIsChrome)
{
MOZ_RELEASE_ASSERT(IsOuterWindow());
@ -5746,7 +5747,7 @@ nsGlobalWindow::SetScreenYOuter(int32_t aScreenY, ErrorResult& aError)
return;
}
CheckSecurityLeftAndTop(nullptr, &aScreenY);
CheckSecurityLeftAndTop(nullptr, &aScreenY, aCallerIsChrome);
y = CSSToDevIntPixels(aScreenY);
aError = treeOwnerAsWin->SetPosition(x, y);
@ -5755,7 +5756,7 @@ nsGlobalWindow::SetScreenYOuter(int32_t aScreenY, ErrorResult& aError)
void
nsGlobalWindow::SetScreenY(int32_t aScreenY, ErrorResult& aError)
{
FORWARD_TO_OUTER_OR_THROW(SetScreenYOuter, (aScreenY, aError), aError, );
FORWARD_TO_OUTER_OR_THROW(SetScreenYOuter, (aScreenY, aError, nsContentUtils::IsCallerChrome()), aError, );
}
void
@ -5769,14 +5770,14 @@ nsGlobalWindow::SetScreenY(JSContext* aCx, JS::Handle<JS::Value> aValue,
NS_IMETHODIMP
nsGlobalWindow::SetScreenY(int32_t aScreenY)
{
FORWARD_TO_INNER(SetScreenY, (aScreenY), NS_ERROR_UNEXPECTED);
FORWARD_TO_OUTER(SetScreenY, (aScreenY), NS_ERROR_UNEXPECTED);
if (IsFrame()) {
return NS_OK;
}
ErrorResult rv;
SetScreenY(aScreenY, rv);
SetScreenYOuter(aScreenY, rv, /* aCallerIsChrome = */ true);
return rv.StealNSResult();
}
@ -5784,12 +5785,12 @@ nsGlobalWindow::SetScreenY(int32_t aScreenY)
// NOTE: Arguments to this function should have values scaled to
// CSS pixels, not device pixels.
void
nsGlobalWindow::CheckSecurityWidthAndHeight(int32_t* aWidth, int32_t* aHeight)
nsGlobalWindow::CheckSecurityWidthAndHeight(int32_t* aWidth, int32_t* aHeight, bool aCallerIsChrome)
{
MOZ_ASSERT(IsOuterWindow());
#ifdef MOZ_XUL
if (!nsContentUtils::IsCallerChrome()) {
if (!aCallerIsChrome) {
// if attempting to resize the window, hide any open popups
nsContentUtils::HidePopupsInDocument(mDoc);
}
@ -5848,7 +5849,7 @@ nsGlobalWindow::SetCSSViewportWidthAndHeight(nscoord aInnerWidth, nscoord aInner
// NOTE: Arguments to this function should have values scaled to
// CSS pixels, not device pixels.
void
nsGlobalWindow::CheckSecurityLeftAndTop(int32_t* aLeft, int32_t* aTop)
nsGlobalWindow::CheckSecurityLeftAndTop(int32_t* aLeft, int32_t* aTop, bool aCallerIsChrome)
{
MOZ_ASSERT(IsOuterWindow());
@ -5856,7 +5857,7 @@ nsGlobalWindow::CheckSecurityLeftAndTop(int32_t* aLeft, int32_t* aTop)
// Check security state for use in determing window dimensions
if (!nsContentUtils::IsCallerChrome()) {
if (!aCallerIsChrome) {
#ifdef MOZ_XUL
// if attempting to move the window, hide any open popups
nsContentUtils::HidePopupsInDocument(mDoc);
@ -7623,7 +7624,7 @@ nsGlobalWindow::MoveToOuter(int32_t aXPos, int32_t aYPos, ErrorResult& aError, b
// Mild abuse of a "size" object so we don't need more helper functions.
nsIntSize cssPos(aXPos, aYPos);
CheckSecurityLeftAndTop(&cssPos.width, &cssPos.height);
CheckSecurityLeftAndTop(&cssPos.width, &cssPos.height, aCallerIsChrome);
nsIntSize devPos = CSSToDevIntPixels(cssPos);
@ -7683,7 +7684,7 @@ nsGlobalWindow::MoveByOuter(int32_t aXDif, int32_t aYDif, ErrorResult& aError, b
cssPos.width += aXDif;
cssPos.height += aYDif;
CheckSecurityLeftAndTop(&cssPos.width, &cssPos.height);
CheckSecurityLeftAndTop(&cssPos.width, &cssPos.height, aCallerIsChrome);
nsIntSize newDevPos(CSSToDevIntPixels(cssPos));
@ -7741,7 +7742,7 @@ nsGlobalWindow::ResizeToOuter(int32_t aWidth, int32_t aHeight, ErrorResult& aErr
}
nsIntSize cssSize(aWidth, aHeight);
CheckSecurityWidthAndHeight(&cssSize.width, &cssSize.height);
CheckSecurityWidthAndHeight(&cssSize.width, &cssSize.height, aCallerIsChrome);
nsIntSize devSz(CSSToDevIntPixels(cssSize));
@ -7821,7 +7822,7 @@ nsGlobalWindow::ResizeByOuter(int32_t aWidthDif, int32_t aHeightDif,
cssSize.width += aWidthDif;
cssSize.height += aHeightDif;
CheckSecurityWidthAndHeight(&cssSize.width, &cssSize.height);
CheckSecurityWidthAndHeight(&cssSize.width, &cssSize.height, aCallerIsChrome);
nsIntSize newDevSize(CSSToDevIntPixels(cssSize));
@ -7888,7 +7889,7 @@ nsGlobalWindow::SizeToContentOuter(ErrorResult& aError, bool aCallerIsChrome)
}
nsIntSize cssSize(DevToCSSIntPixels(nsIntSize(width, height)));
CheckSecurityWidthAndHeight(&cssSize.width, &cssSize.height);
CheckSecurityWidthAndHeight(&cssSize.width, &cssSize.height, aCallerIsChrome);
nsIntSize newDevSize(CSSToDevIntPixels(cssSize));

View File

@ -1207,27 +1207,27 @@ protected:
// And the implementations of WindowCoordGetter/WindowCoordSetter.
int32_t GetInnerWidthOuter(mozilla::ErrorResult& aError);
int32_t GetInnerWidth(mozilla::ErrorResult& aError);
void SetInnerWidthOuter(int32_t aInnerWidth, mozilla::ErrorResult& aError);
void SetInnerWidthOuter(int32_t aInnerWidth, mozilla::ErrorResult& aError, bool aCallerIsChrome);
void SetInnerWidth(int32_t aInnerWidth, mozilla::ErrorResult& aError);
int32_t GetInnerHeightOuter(mozilla::ErrorResult& aError);
int32_t GetInnerHeight(mozilla::ErrorResult& aError);
void SetInnerHeightOuter(int32_t aInnerHeight, mozilla::ErrorResult& aError);
void SetInnerHeightOuter(int32_t aInnerHeight, mozilla::ErrorResult& aError, bool aCallerIsChrome);
void SetInnerHeight(int32_t aInnerHeight, mozilla::ErrorResult& aError);
int32_t GetScreenXOuter(mozilla::ErrorResult& aError);
int32_t GetScreenX(mozilla::ErrorResult& aError);
void SetScreenXOuter(int32_t aScreenX, mozilla::ErrorResult& aError);
void SetScreenXOuter(int32_t aScreenX, mozilla::ErrorResult& aError, bool aCallerIsChrome);
void SetScreenX(int32_t aScreenX, mozilla::ErrorResult& aError);
int32_t GetScreenYOuter(mozilla::ErrorResult& aError);
int32_t GetScreenY(mozilla::ErrorResult& aError);
void SetScreenYOuter(int32_t aScreenY, mozilla::ErrorResult& aError);
void SetScreenYOuter(int32_t aScreenY, mozilla::ErrorResult& aError, bool aCallerIsChrome);
void SetScreenY(int32_t aScreenY, mozilla::ErrorResult& aError);
int32_t GetOuterWidthOuter(mozilla::ErrorResult& aError);
int32_t GetOuterWidth(mozilla::ErrorResult& aError);
void SetOuterWidthOuter(int32_t aOuterWidth, mozilla::ErrorResult& aError);
void SetOuterWidthOuter(int32_t aOuterWidth, mozilla::ErrorResult& aError, bool aCallerIsChrome);
void SetOuterWidth(int32_t aOuterWidth, mozilla::ErrorResult& aError);
int32_t GetOuterHeightOuter(mozilla::ErrorResult& aError);
int32_t GetOuterHeight(mozilla::ErrorResult& aError);
void SetOuterHeightOuter(int32_t aOuterHeight, mozilla::ErrorResult& aError);
void SetOuterHeightOuter(int32_t aOuterHeight, mozilla::ErrorResult& aError, bool aCallerIsChrome);
void SetOuterHeight(int32_t aOuterHeight, mozilla::ErrorResult& aError);
// Array of idle observers that are notified of idle events.
@ -1457,8 +1457,8 @@ public:
// Outer windows only.
void EnsureReflowFlushAndPaint();
void CheckSecurityWidthAndHeight(int32_t* width, int32_t* height);
void CheckSecurityLeftAndTop(int32_t* left, int32_t* top);
void CheckSecurityWidthAndHeight(int32_t* width, int32_t* height, bool aCallerIsChrome);
void CheckSecurityLeftAndTop(int32_t* left, int32_t* top, bool aCallerIsChrome);
// Outer windows only.
// Arguments to this function should have values in app units
@ -1486,7 +1486,7 @@ public:
nsresult GetInnerSize(mozilla::CSSIntSize& aSize);
nsIntSize GetOuterSize(mozilla::ErrorResult& aError);
void SetOuterSize(int32_t aLengthCSSPixels, bool aIsWidth,
mozilla::ErrorResult& aError);
mozilla::ErrorResult& aError, bool aCallerIsChrome);
nsRect GetInnerScreenRect();
void ScrollTo(const mozilla::CSSIntPoint& aScroll,