mirror of
https://github.com/mozilla/gecko-dev.git
synced 2025-04-13 19:41:41 +00:00
bug 935325 - merge nsIScriptGlobalObjectOwner into nsIDocShell r=smaug
This commit is contained in:
parent
7d09aa8e5c
commit
092eeac701
@ -60,7 +60,6 @@
|
|||||||
#include "nsIPrincipal.h"
|
#include "nsIPrincipal.h"
|
||||||
#include "nsTextFragment.h"
|
#include "nsTextFragment.h"
|
||||||
#include "nsIScriptGlobalObject.h"
|
#include "nsIScriptGlobalObject.h"
|
||||||
#include "nsIScriptGlobalObjectOwner.h"
|
|
||||||
|
|
||||||
#include "nsIParserService.h"
|
#include "nsIParserService.h"
|
||||||
|
|
||||||
@ -712,10 +711,7 @@ IsScriptEnabled(nsIDocument *aDoc, nsIDocShell *aContainer)
|
|||||||
// Getting context is tricky if the document hasn't had its
|
// Getting context is tricky if the document hasn't had its
|
||||||
// GlobalObject set yet
|
// GlobalObject set yet
|
||||||
if (!globalObject) {
|
if (!globalObject) {
|
||||||
nsCOMPtr<nsIScriptGlobalObjectOwner> owner = do_GetInterface(aContainer);
|
globalObject = aContainer->GetScriptGlobalObject();
|
||||||
NS_ENSURE_TRUE(owner, true);
|
|
||||||
|
|
||||||
globalObject = owner->GetScriptGlobalObject();
|
|
||||||
NS_ENSURE_TRUE(globalObject, true);
|
NS_ENSURE_TRUE(globalObject, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -40,7 +40,6 @@
|
|||||||
#include "nsJSUtils.h"
|
#include "nsJSUtils.h"
|
||||||
#include "nsCRT.h"
|
#include "nsCRT.h"
|
||||||
#include "nsIAuthPrompt.h"
|
#include "nsIAuthPrompt.h"
|
||||||
#include "nsIScriptGlobalObjectOwner.h"
|
|
||||||
#include "nsContentCreatorFunctions.h"
|
#include "nsContentCreatorFunctions.h"
|
||||||
#include "nsContentPolicyUtils.h"
|
#include "nsContentPolicyUtils.h"
|
||||||
#include "nsIDOMUserDataHandler.h"
|
#include "nsIDOMUserDataHandler.h"
|
||||||
|
@ -897,7 +897,6 @@ NS_INTERFACE_MAP_BEGIN(nsDocShell)
|
|||||||
NS_INTERFACE_MAP_ENTRY(nsIScrollable)
|
NS_INTERFACE_MAP_ENTRY(nsIScrollable)
|
||||||
NS_INTERFACE_MAP_ENTRY(nsITextScroll)
|
NS_INTERFACE_MAP_ENTRY(nsITextScroll)
|
||||||
NS_INTERFACE_MAP_ENTRY(nsIDocCharset)
|
NS_INTERFACE_MAP_ENTRY(nsIDocCharset)
|
||||||
NS_INTERFACE_MAP_ENTRY(nsIScriptGlobalObjectOwner)
|
|
||||||
NS_INTERFACE_MAP_ENTRY(nsIRefreshURI)
|
NS_INTERFACE_MAP_ENTRY(nsIRefreshURI)
|
||||||
NS_INTERFACE_MAP_ENTRY(nsIWebProgressListener)
|
NS_INTERFACE_MAP_ENTRY(nsIWebProgressListener)
|
||||||
NS_INTERFACE_MAP_ENTRY(nsISupportsWeakReference)
|
NS_INTERFACE_MAP_ENTRY(nsISupportsWeakReference)
|
||||||
@ -3920,6 +3919,13 @@ nsDocShell::GetCurrentSHEntry(nsISHEntry** aEntry, bool* aOSHE)
|
|||||||
return NS_OK;
|
return NS_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
nsIScriptGlobalObject*
|
||||||
|
nsDocShell::GetScriptGlobalObject()
|
||||||
|
{
|
||||||
|
NS_ENSURE_SUCCESS(EnsureScriptEnvironment(), nullptr);
|
||||||
|
return mScriptGlobal;
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
nsDocShell::ClearFrameHistory(nsISHEntry* aEntry)
|
nsDocShell::ClearFrameHistory(nsISHEntry* aEntry)
|
||||||
{
|
{
|
||||||
@ -5818,17 +5824,6 @@ nsDocShell::ScrollByPages(int32_t numPages)
|
|||||||
return NS_OK;
|
return NS_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
//*****************************************************************************
|
|
||||||
// nsDocShell::nsIScriptGlobalObjectOwner
|
|
||||||
//*****************************************************************************
|
|
||||||
|
|
||||||
nsIScriptGlobalObject*
|
|
||||||
nsDocShell::GetScriptGlobalObject()
|
|
||||||
{
|
|
||||||
NS_ENSURE_SUCCESS(EnsureScriptEnvironment(), nullptr);
|
|
||||||
return mScriptGlobal;
|
|
||||||
}
|
|
||||||
|
|
||||||
//*****************************************************************************
|
//*****************************************************************************
|
||||||
// nsDocShell::nsIRefreshURI
|
// nsDocShell::nsIRefreshURI
|
||||||
//*****************************************************************************
|
//*****************************************************************************
|
||||||
|
@ -33,7 +33,6 @@
|
|||||||
#include "nsIDocCharset.h"
|
#include "nsIDocCharset.h"
|
||||||
#include "nsIInterfaceRequestor.h"
|
#include "nsIInterfaceRequestor.h"
|
||||||
#include "nsIRefreshURI.h"
|
#include "nsIRefreshURI.h"
|
||||||
#include "nsIScriptGlobalObjectOwner.h"
|
|
||||||
#include "nsIWebNavigation.h"
|
#include "nsIWebNavigation.h"
|
||||||
#include "nsIWebPageDescriptor.h"
|
#include "nsIWebPageDescriptor.h"
|
||||||
#include "nsIWebProgressListener.h"
|
#include "nsIWebProgressListener.h"
|
||||||
@ -130,7 +129,6 @@ class nsDocShell : public nsDocLoader,
|
|||||||
public nsITextScroll,
|
public nsITextScroll,
|
||||||
public nsIDocCharset,
|
public nsIDocCharset,
|
||||||
public nsIContentViewerContainer,
|
public nsIContentViewerContainer,
|
||||||
public nsIScriptGlobalObjectOwner,
|
|
||||||
public nsIRefreshURI,
|
public nsIRefreshURI,
|
||||||
public nsIWebProgressListener,
|
public nsIWebProgressListener,
|
||||||
public nsIWebPageDescriptor,
|
public nsIWebPageDescriptor,
|
||||||
@ -205,9 +203,6 @@ public:
|
|||||||
nsDocShellInfoLoadType ConvertLoadTypeToDocShellLoadInfo(uint32_t aLoadType);
|
nsDocShellInfoLoadType ConvertLoadTypeToDocShellLoadInfo(uint32_t aLoadType);
|
||||||
uint32_t ConvertDocShellLoadInfoToLoadType(nsDocShellInfoLoadType aDocShellLoadType);
|
uint32_t ConvertDocShellLoadInfoToLoadType(nsDocShellInfoLoadType aDocShellLoadType);
|
||||||
|
|
||||||
// nsIScriptGlobalObjectOwner methods
|
|
||||||
virtual nsIScriptGlobalObject* GetScriptGlobalObject();
|
|
||||||
|
|
||||||
// Don't use NS_DECL_NSILOADCONTEXT because some of nsILoadContext's methods
|
// Don't use NS_DECL_NSILOADCONTEXT because some of nsILoadContext's methods
|
||||||
// are shared with nsIDocShell (appID, etc.) and can't be declared twice.
|
// are shared with nsIDocShell (appID, etc.) and can't be declared twice.
|
||||||
NS_IMETHOD GetAssociatedWindow(nsIDOMWindow**);
|
NS_IMETHOD GetAssociatedWindow(nsIDOMWindow**);
|
||||||
|
@ -34,6 +34,7 @@ interface nsIRequest;
|
|||||||
interface nsISHEntry;
|
interface nsISHEntry;
|
||||||
interface nsILayoutHistoryState;
|
interface nsILayoutHistoryState;
|
||||||
interface nsISecureBrowserUI;
|
interface nsISecureBrowserUI;
|
||||||
|
interface nsIScriptGlobalObject;
|
||||||
interface nsIDOMStorage;
|
interface nsIDOMStorage;
|
||||||
interface nsIPrincipal;
|
interface nsIPrincipal;
|
||||||
interface nsIWebBrowserPrint;
|
interface nsIWebBrowserPrint;
|
||||||
@ -43,7 +44,7 @@ interface nsIReflowObserver;
|
|||||||
|
|
||||||
typedef unsigned long nsLoadFlags;
|
typedef unsigned long nsLoadFlags;
|
||||||
|
|
||||||
[scriptable, builtinclass, uuid(1470A132-99B2-44C3-B37D-D8093B2E29BF)]
|
[scriptable, builtinclass, uuid(5c9adf31-8e4a-4d8d-8daf-9999e6002697)]
|
||||||
interface nsIDocShell : nsIDocShellTreeItem
|
interface nsIDocShell : nsIDocShellTreeItem
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
@ -907,4 +908,9 @@ interface nsIDocShell : nsIDocShellTreeItem
|
|||||||
*/
|
*/
|
||||||
[noscript, notxpcom] bool IsInvisible();
|
[noscript, notxpcom] bool IsInvisible();
|
||||||
[noscript, notxpcom] void SetInvisible(in bool aIsInvisibleDochsell);
|
[noscript, notxpcom] void SetInvisible(in bool aIsInvisibleDochsell);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the script global for the document in this docshell.
|
||||||
|
*/
|
||||||
|
[noscript,notxpcom,nostdcall] nsIScriptGlobalObject GetScriptGlobalObject();
|
||||||
};
|
};
|
||||||
|
@ -34,7 +34,6 @@ EXPORTS += [
|
|||||||
'nsIScriptContext.h',
|
'nsIScriptContext.h',
|
||||||
'nsIScriptExternalNameSet.h',
|
'nsIScriptExternalNameSet.h',
|
||||||
'nsIScriptGlobalObject.h',
|
'nsIScriptGlobalObject.h',
|
||||||
'nsIScriptGlobalObjectOwner.h',
|
|
||||||
'nsIScriptNameSpaceManager.h',
|
'nsIScriptNameSpaceManager.h',
|
||||||
'nsIScriptObjectPrincipal.h',
|
'nsIScriptObjectPrincipal.h',
|
||||||
'nsIScriptTimeoutHandler.h',
|
'nsIScriptTimeoutHandler.h',
|
||||||
|
@ -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__ */
|
|
@ -21,7 +21,6 @@
|
|||||||
#include "nsIURI.h"
|
#include "nsIURI.h"
|
||||||
#include "nsIScriptContext.h"
|
#include "nsIScriptContext.h"
|
||||||
#include "nsIScriptGlobalObject.h"
|
#include "nsIScriptGlobalObject.h"
|
||||||
#include "nsIScriptGlobalObjectOwner.h"
|
|
||||||
#include "nsIPrincipal.h"
|
#include "nsIPrincipal.h"
|
||||||
#include "nsIScriptSecurityManager.h"
|
#include "nsIScriptSecurityManager.h"
|
||||||
#include "nsIInterfaceRequestor.h"
|
#include "nsIInterfaceRequestor.h"
|
||||||
@ -119,22 +118,19 @@ static
|
|||||||
nsIScriptGlobalObject* GetGlobalObject(nsIChannel* aChannel)
|
nsIScriptGlobalObject* GetGlobalObject(nsIChannel* aChannel)
|
||||||
{
|
{
|
||||||
// Get the global object owner from the channel
|
// Get the global object owner from the channel
|
||||||
nsCOMPtr<nsIScriptGlobalObjectOwner> globalOwner;
|
nsCOMPtr<nsIDocShell> docShell;
|
||||||
NS_QueryNotificationCallbacks(aChannel, globalOwner);
|
NS_QueryNotificationCallbacks(aChannel, docShell);
|
||||||
if (!globalOwner) {
|
if (!docShell) {
|
||||||
NS_WARNING("Unable to get an nsIScriptGlobalObjectOwner from the "
|
NS_WARNING("Unable to get a docShell from the channel!");
|
||||||
"channel!");
|
|
||||||
}
|
|
||||||
if (!globalOwner) {
|
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
// So far so good: get the script context from its owner.
|
// So far so good: get the script global from its docshell
|
||||||
nsIScriptGlobalObject* global = globalOwner->GetScriptGlobalObject();
|
nsIScriptGlobalObject* global = docShell->GetScriptGlobalObject();
|
||||||
|
|
||||||
NS_ASSERTION(global,
|
NS_ASSERTION(global,
|
||||||
"Unable to get an nsIScriptGlobalObject from the "
|
"Unable to get an nsIScriptGlobalObject from the "
|
||||||
"ScriptGlobalObjectOwner!");
|
"docShell!");
|
||||||
return global;
|
return global;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -17,7 +17,6 @@
|
|||||||
#include "nsStyleLinkElement.h"
|
#include "nsStyleLinkElement.h"
|
||||||
#include "nsIDocShell.h"
|
#include "nsIDocShell.h"
|
||||||
#include "nsIScriptGlobalObject.h"
|
#include "nsIScriptGlobalObject.h"
|
||||||
#include "nsIScriptGlobalObjectOwner.h"
|
|
||||||
#include "nsIScriptSecurityManager.h"
|
#include "nsIScriptSecurityManager.h"
|
||||||
#include "nsIWebShellServices.h"
|
#include "nsIWebShellServices.h"
|
||||||
#include "nsContentUtils.h"
|
#include "nsContentUtils.h"
|
||||||
@ -653,9 +652,7 @@ nsHtml5TreeOpExecutor::IsScriptEnabled()
|
|||||||
// Getting context is tricky if the document hasn't had its
|
// Getting context is tricky if the document hasn't had its
|
||||||
// GlobalObject set yet
|
// GlobalObject set yet
|
||||||
if (!globalObject) {
|
if (!globalObject) {
|
||||||
nsCOMPtr<nsIScriptGlobalObjectOwner> owner = do_GetInterface(mDocShell);
|
globalObject = mDocShell->GetScriptGlobalObject();
|
||||||
NS_ENSURE_TRUE(owner, true);
|
|
||||||
globalObject = do_QueryInterface(mDocument->GetWindow());
|
|
||||||
NS_ENSURE_TRUE(globalObject, true);
|
NS_ENSURE_TRUE(globalObject, true);
|
||||||
}
|
}
|
||||||
nsIScriptContext *scriptContext = globalObject->GetContext();
|
nsIScriptContext *scriptContext = globalObject->GetContext();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user