Bug 1179334 - check for chrome callers in nsDOMWindowUtils interface methods; r=mccr8

This commit is contained in:
Nathan Froyd 2015-07-02 11:23:34 -04:00
Родитель 40eb8ff95b
Коммит b4d14a98a8
1 изменённых файлов: 34 добавлений и 0 удалений

Просмотреть файл

@ -285,6 +285,8 @@ nsDOMWindowUtils::Redraw(uint32_t aCount, uint32_t *aDurationOut)
NS_IMETHODIMP
nsDOMWindowUtils::UpdateLayerTree()
{
MOZ_RELEASE_ASSERT(nsContentUtils::IsCallerChrome());
if (nsIPresShell* presShell = GetPresShell()) {
presShell->FlushPendingNotifications(Flush_Display);
nsRefPtr<nsViewManager> vm = presShell->GetViewManager();
@ -1652,6 +1654,8 @@ getScrollXYAppUnits(nsWeakPtr aWindow, bool aFlushLayout, nsPoint& aScrollPos) {
NS_IMETHODIMP
nsDOMWindowUtils::GetScrollXY(bool aFlushLayout, int32_t* aScrollX, int32_t* aScrollY)
{
MOZ_RELEASE_ASSERT(nsContentUtils::IsCallerChrome());
nsPoint scrollPos(0,0);
nsresult rv = getScrollXYAppUnits(mWindow, aFlushLayout, scrollPos);
NS_ENSURE_SUCCESS(rv, rv);
@ -1664,6 +1668,8 @@ nsDOMWindowUtils::GetScrollXY(bool aFlushLayout, int32_t* aScrollX, int32_t* aSc
NS_IMETHODIMP
nsDOMWindowUtils::GetScrollXYFloat(bool aFlushLayout, float* aScrollX, float* aScrollY)
{
MOZ_RELEASE_ASSERT(nsContentUtils::IsCallerChrome());
nsPoint scrollPos(0,0);
nsresult rv = getScrollXYAppUnits(mWindow, aFlushLayout, scrollPos);
NS_ENSURE_SUCCESS(rv, rv);
@ -1830,6 +1836,8 @@ nsDOMWindowUtils::FindElementWithViewId(nsViewID aID,
NS_IMETHODIMP
nsDOMWindowUtils::GetViewId(nsIDOMElement* aElement, nsViewID* aResult)
{
MOZ_RELEASE_ASSERT(nsContentUtils::IsCallerChrome());
nsCOMPtr<nsIContent> content = do_QueryInterface(aElement);
if (content && nsLayoutUtils::FindIDFor(content, aResult)) {
return NS_OK;
@ -1840,6 +1848,8 @@ nsDOMWindowUtils::GetViewId(nsIDOMElement* aElement, nsViewID* aResult)
NS_IMETHODIMP
nsDOMWindowUtils::GetScreenPixelsPerCSSPixel(float* aScreenPixels)
{
MOZ_RELEASE_ASSERT(nsContentUtils::IsCallerChrome());
nsCOMPtr<nsPIDOMWindow> window = do_QueryReferent(mWindow);
NS_ENSURE_TRUE(window, NS_ERROR_FAILURE);
return window->GetDevicePixelRatio(aScreenPixels);
@ -2455,6 +2465,8 @@ NS_IMETHODIMP
nsDOMWindowUtils::SetAsyncScrollOffset(nsIDOMNode* aNode,
int32_t aX, int32_t aY)
{
MOZ_RELEASE_ASSERT(nsContentUtils::IsCallerChrome());
nsCOMPtr<Element> element = do_QueryInterface(aNode);
if (!element) {
return NS_ERROR_INVALID_ARG;
@ -2482,6 +2494,8 @@ nsDOMWindowUtils::SetAsyncScrollOffset(nsIDOMNode* aNode,
NS_IMETHODIMP
nsDOMWindowUtils::SetAsyncZoom(nsIDOMNode* aRootElement, float aValue)
{
MOZ_RELEASE_ASSERT(nsContentUtils::IsCallerChrome());
nsCOMPtr<Element> element = do_QueryInterface(aRootElement);
if (!element) {
return NS_ERROR_INVALID_ARG;
@ -2509,6 +2523,8 @@ nsDOMWindowUtils::SetAsyncZoom(nsIDOMNode* aRootElement, float aValue)
NS_IMETHODIMP
nsDOMWindowUtils::FlushApzRepaints(bool* aOutResult)
{
MOZ_RELEASE_ASSERT(nsContentUtils::IsCallerChrome());
nsIWidget* widget = GetWidget();
if (!widget) {
*aOutResult = false;
@ -3469,6 +3485,8 @@ nsDOMWindowUtils::IsNodeDisabledForEvents(nsIDOMNode* aNode, bool* aRetVal)
NS_IMETHODIMP
nsDOMWindowUtils::SetPaintFlashing(bool aPaintFlashing)
{
MOZ_RELEASE_ASSERT(nsContentUtils::IsCallerChrome());
nsPresContext* presContext = GetPresContext();
if (presContext) {
presContext->SetPaintFlashing(aPaintFlashing);
@ -3487,6 +3505,8 @@ nsDOMWindowUtils::SetPaintFlashing(bool aPaintFlashing)
NS_IMETHODIMP
nsDOMWindowUtils::GetPaintFlashing(bool* aRetVal)
{
MOZ_RELEASE_ASSERT(nsContentUtils::IsCallerChrome());
*aRetVal = false;
nsPresContext* presContext = GetPresContext();
if (presContext) {
@ -3660,6 +3680,8 @@ HandlingUserInputHelper::~HandlingUserInputHelper()
NS_IMETHODIMP
HandlingUserInputHelper::Destruct()
{
MOZ_RELEASE_ASSERT(nsContentUtils::IsCallerChrome());
if (NS_WARN_IF(mDestructCalled)) {
return NS_ERROR_FAILURE;
}
@ -3731,6 +3753,8 @@ nsDOMWindowUtils::GetCompositorAPZTestData(JSContext* aContext,
NS_IMETHODIMP
nsDOMWindowUtils::PostRestyleSelfEvent(nsIDOMElement* aElement)
{
MOZ_RELEASE_ASSERT(nsContentUtils::IsCallerChrome());
nsCOMPtr<Element> element = do_QueryInterface(aElement);
if (!element) {
return NS_ERROR_INVALID_ARG;
@ -3789,6 +3813,8 @@ nsDOMWindowUtils::SetChromeMargin(int32_t aTop,
int32_t aBottom,
int32_t aLeft)
{
MOZ_RELEASE_ASSERT(nsContentUtils::IsCallerChrome());
nsCOMPtr<nsPIDOMWindow> window = do_QueryReferent(mWindow);
if (window) {
nsCOMPtr<nsIBaseWindow> baseWindow = do_QueryInterface(window->GetDocShell());
@ -3829,6 +3855,8 @@ nsDOMWindowUtils::GetFrameUniformityTestData(JSContext* aContext,
NS_IMETHODIMP
nsDOMWindowUtils::XpconnectArgument(nsIDOMWindowUtils* aThis)
{
MOZ_RELEASE_ASSERT(nsContentUtils::IsCallerChrome());
// Do nothing.
return NS_OK;
}
@ -3836,6 +3864,8 @@ nsDOMWindowUtils::XpconnectArgument(nsIDOMWindowUtils* aThis)
NS_IMETHODIMP
nsDOMWindowUtils::AskPermission(nsIContentPermissionRequest* aRequest)
{
MOZ_RELEASE_ASSERT(nsContentUtils::IsCallerChrome());
nsCOMPtr<nsPIDOMWindow> window = do_QueryReferent(mWindow);
return nsContentPermissionUtils::AskPermission(aRequest, window->GetCurrentInnerWindow());
}
@ -3843,6 +3873,8 @@ nsDOMWindowUtils::AskPermission(nsIContentPermissionRequest* aRequest)
NS_IMETHODIMP
nsDOMWindowUtils::GetFramesConstructed(uint64_t* aResult)
{
MOZ_RELEASE_ASSERT(nsContentUtils::IsCallerChrome());
nsPresContext* presContext = GetPresContext();
if (!presContext) {
return NS_ERROR_NOT_AVAILABLE;
@ -3855,6 +3887,8 @@ nsDOMWindowUtils::GetFramesConstructed(uint64_t* aResult)
NS_IMETHODIMP
nsDOMWindowUtils::GetFramesReflowed(uint64_t* aResult)
{
MOZ_RELEASE_ASSERT(nsContentUtils::IsCallerChrome());
nsPresContext* presContext = GetPresContext();
if (!presContext) {
return NS_ERROR_NOT_AVAILABLE;