bug 935325 - merge nsIScriptGlobalObjectOwner into nsIDocShell r=smaug

This commit is contained in:
Trevor Saunders 2013-05-27 06:07:01 -04:00
parent cd02aea365
commit 012fdba09b
9 changed files with 23 additions and 76 deletions

View File

@ -60,7 +60,6 @@
#include "nsIPrincipal.h"
#include "nsTextFragment.h"
#include "nsIScriptGlobalObject.h"
#include "nsIScriptGlobalObjectOwner.h"
#include "nsIParserService.h"
@ -712,10 +711,7 @@ IsScriptEnabled(nsIDocument *aDoc, nsIDocShell *aContainer)
// Getting context is tricky if the document hasn't had its
// GlobalObject set yet
if (!globalObject) {
nsCOMPtr<nsIScriptGlobalObjectOwner> owner = do_GetInterface(aContainer);
NS_ENSURE_TRUE(owner, true);
globalObject = owner->GetScriptGlobalObject();
globalObject = aContainer->GetScriptGlobalObject();
NS_ENSURE_TRUE(globalObject, true);
}

View File

@ -40,7 +40,6 @@
#include "nsJSUtils.h"
#include "nsCRT.h"
#include "nsIAuthPrompt.h"
#include "nsIScriptGlobalObjectOwner.h"
#include "nsContentCreatorFunctions.h"
#include "nsContentPolicyUtils.h"
#include "nsIDOMUserDataHandler.h"

View File

@ -897,7 +897,6 @@ NS_INTERFACE_MAP_BEGIN(nsDocShell)
NS_INTERFACE_MAP_ENTRY(nsIScrollable)
NS_INTERFACE_MAP_ENTRY(nsITextScroll)
NS_INTERFACE_MAP_ENTRY(nsIDocCharset)
NS_INTERFACE_MAP_ENTRY(nsIScriptGlobalObjectOwner)
NS_INTERFACE_MAP_ENTRY(nsIRefreshURI)
NS_INTERFACE_MAP_ENTRY(nsIWebProgressListener)
NS_INTERFACE_MAP_ENTRY(nsISupportsWeakReference)
@ -3920,6 +3919,13 @@ nsDocShell::GetCurrentSHEntry(nsISHEntry** aEntry, bool* aOSHE)
return NS_OK;
}
nsIScriptGlobalObject*
nsDocShell::GetScriptGlobalObject()
{
NS_ENSURE_SUCCESS(EnsureScriptEnvironment(), nullptr);
return mScriptGlobal;
}
void
nsDocShell::ClearFrameHistory(nsISHEntry* aEntry)
{
@ -5818,17 +5824,6 @@ nsDocShell::ScrollByPages(int32_t numPages)
return NS_OK;
}
//*****************************************************************************
// nsDocShell::nsIScriptGlobalObjectOwner
//*****************************************************************************
nsIScriptGlobalObject*
nsDocShell::GetScriptGlobalObject()
{
NS_ENSURE_SUCCESS(EnsureScriptEnvironment(), nullptr);
return mScriptGlobal;
}
//*****************************************************************************
// nsDocShell::nsIRefreshURI
//*****************************************************************************

View File

@ -33,7 +33,6 @@
#include "nsIDocCharset.h"
#include "nsIInterfaceRequestor.h"
#include "nsIRefreshURI.h"
#include "nsIScriptGlobalObjectOwner.h"
#include "nsIWebNavigation.h"
#include "nsIWebPageDescriptor.h"
#include "nsIWebProgressListener.h"
@ -130,7 +129,6 @@ class nsDocShell : public nsDocLoader,
public nsITextScroll,
public nsIDocCharset,
public nsIContentViewerContainer,
public nsIScriptGlobalObjectOwner,
public nsIRefreshURI,
public nsIWebProgressListener,
public nsIWebPageDescriptor,
@ -205,9 +203,6 @@ public:
nsDocShellInfoLoadType ConvertLoadTypeToDocShellLoadInfo(uint32_t aLoadType);
uint32_t ConvertDocShellLoadInfoToLoadType(nsDocShellInfoLoadType aDocShellLoadType);
// nsIScriptGlobalObjectOwner methods
virtual nsIScriptGlobalObject* GetScriptGlobalObject();
// Don't use NS_DECL_NSILOADCONTEXT because some of nsILoadContext's methods
// are shared with nsIDocShell (appID, etc.) and can't be declared twice.
NS_IMETHOD GetAssociatedWindow(nsIDOMWindow**);

View File

@ -34,6 +34,7 @@ interface nsIRequest;
interface nsISHEntry;
interface nsILayoutHistoryState;
interface nsISecureBrowserUI;
interface nsIScriptGlobalObject;
interface nsIDOMStorage;
interface nsIPrincipal;
interface nsIWebBrowserPrint;
@ -43,7 +44,7 @@ interface nsIReflowObserver;
typedef unsigned long nsLoadFlags;
[scriptable, builtinclass, uuid(1470A132-99B2-44C3-B37D-D8093B2E29BF)]
[scriptable, builtinclass, uuid(5c9adf31-8e4a-4d8d-8daf-9999e6002697)]
interface nsIDocShell : nsIDocShellTreeItem
{
/**
@ -907,4 +908,9 @@ interface nsIDocShell : nsIDocShellTreeItem
*/
[noscript, notxpcom] bool IsInvisible();
[noscript, notxpcom] void SetInvisible(in bool aIsInvisibleDochsell);
/**
* Get the script global for the document in this docshell.
*/
[noscript,notxpcom,nostdcall] nsIScriptGlobalObject GetScriptGlobalObject();
};

View File

@ -34,7 +34,6 @@ EXPORTS += [
'nsIScriptContext.h',
'nsIScriptExternalNameSet.h',
'nsIScriptGlobalObject.h',
'nsIScriptGlobalObjectOwner.h',
'nsIScriptNameSpaceManager.h',
'nsIScriptObjectPrincipal.h',
'nsIScriptTimeoutHandler.h',

View File

@ -1,36 +0,0 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#ifndef nsIScriptGlobalObjectOwner_h__
#define nsIScriptGlobalObjectOwner_h__
#include "nsISupports.h"
class nsIScriptGlobalObject;
#define NS_ISCRIPTGLOBALOBJECTOWNER_IID \
{0xfd25ca8e, 0x6b63, 0x435f, \
{ 0xb8, 0xc6, 0xb8, 0x07, 0x68, 0xa4, 0x0a, 0xdc }}
/**
* Implemented by any object capable of supplying a nsIScriptGlobalObject.
* The implentor may create the script global object on demand.
*/
class nsIScriptGlobalObjectOwner : public nsISupports
{
public:
NS_DECLARE_STATIC_IID_ACCESSOR(NS_ISCRIPTGLOBALOBJECTOWNER_IID)
/**
* Returns the script global object
*/
virtual nsIScriptGlobalObject* GetScriptGlobalObject() = 0;
};
NS_DEFINE_STATIC_IID_ACCESSOR(nsIScriptGlobalObjectOwner,
NS_ISCRIPTGLOBALOBJECTOWNER_IID)
#endif /* nsIScriptGlobalObjectOwner_h__ */

View File

@ -21,7 +21,6 @@
#include "nsIURI.h"
#include "nsIScriptContext.h"
#include "nsIScriptGlobalObject.h"
#include "nsIScriptGlobalObjectOwner.h"
#include "nsIPrincipal.h"
#include "nsIScriptSecurityManager.h"
#include "nsIInterfaceRequestor.h"
@ -119,22 +118,19 @@ static
nsIScriptGlobalObject* GetGlobalObject(nsIChannel* aChannel)
{
// Get the global object owner from the channel
nsCOMPtr<nsIScriptGlobalObjectOwner> globalOwner;
NS_QueryNotificationCallbacks(aChannel, globalOwner);
if (!globalOwner) {
NS_WARNING("Unable to get an nsIScriptGlobalObjectOwner from the "
"channel!");
}
if (!globalOwner) {
nsCOMPtr<nsIDocShell> docShell;
NS_QueryNotificationCallbacks(aChannel, docShell);
if (!docShell) {
NS_WARNING("Unable to get a docShell from the channel!");
return nullptr;
}
// So far so good: get the script context from its owner.
nsIScriptGlobalObject* global = globalOwner->GetScriptGlobalObject();
// So far so good: get the script global from its docshell
nsIScriptGlobalObject* global = docShell->GetScriptGlobalObject();
NS_ASSERTION(global,
"Unable to get an nsIScriptGlobalObject from the "
"ScriptGlobalObjectOwner!");
"docShell!");
return global;
}

View File

@ -17,7 +17,6 @@
#include "nsStyleLinkElement.h"
#include "nsIDocShell.h"
#include "nsIScriptGlobalObject.h"
#include "nsIScriptGlobalObjectOwner.h"
#include "nsIScriptSecurityManager.h"
#include "nsIWebShellServices.h"
#include "nsContentUtils.h"
@ -653,9 +652,7 @@ nsHtml5TreeOpExecutor::IsScriptEnabled()
// Getting context is tricky if the document hasn't had its
// GlobalObject set yet
if (!globalObject) {
nsCOMPtr<nsIScriptGlobalObjectOwner> owner = do_GetInterface(mDocShell);
NS_ENSURE_TRUE(owner, true);
globalObject = do_QueryInterface(mDocument->GetWindow());
globalObject = mDocShell->GetScriptGlobalObject();
NS_ENSURE_TRUE(globalObject, true);
}
nsIScriptContext *scriptContext = globalObject->GetContext();