Bug 865729 - Remove nsIJSContextStack from content/foo. r=gabor

We leave it in nsContentUtils.cpp, which we'll handle in a separate patch.
This commit is contained in:
Bobby Holley 2013-04-29 11:16:17 -07:00
parent bef570a1ac
commit 50cbd97181
19 changed files with 39 additions and 77 deletions

View File

@ -73,7 +73,6 @@
#include "nsLayoutUtils.h"
#include "nsGkAtoms.h"
#include "nsContentUtils.h"
#include "nsIJSContextStack.h"
#include "nsIDOMEventListener.h"
#include "nsIWebNavigation.h"

View File

@ -12,7 +12,6 @@
#include "nsNetUtil.h"
#include "nsMimeTypes.h"
#include "nsDOMMessageEvent.h"
#include "nsIJSContextStack.h"
#include "nsIPromptFactory.h"
#include "nsIWindowWatcher.h"
#include "nsPresContext.h"
@ -201,10 +200,8 @@ EventSource::Init(nsISupports* aOwner,
mWithCredentials = aWithCredentials;
BindToOwner(ownerWindow);
nsCOMPtr<nsIJSContextStack> stack =
do_GetService("@mozilla.org/js/xpc/ContextStack;1");
JSContext* cx = nullptr;
if (stack && NS_SUCCEEDED(stack->Peek(&cx)) && cx) {
// The conditional here is historical and not necessarily sane.
if (JSContext *cx = nsContentUtils::GetCurrentJSContext()) {
const char *filename;
if (nsJSUtils::GetCallingLocation(cx, &filename, &mScriptLine)) {
mScriptFile.AssignASCII(filename);

View File

@ -72,7 +72,6 @@
#include "nsLayoutUtils.h"
#include "nsGkAtoms.h"
#include "nsContentUtils.h"
#include "nsIJSContextStack.h"
#include "nsIDOMEventListener.h"
#include "nsIWebNavigation.h"

View File

@ -32,7 +32,6 @@
#include "nsIDOMCloseEvent.h"
#include "nsICryptoHash.h"
#include "jsdbgapi.h"
#include "nsIJSContextStack.h"
#include "nsJSUtils.h"
#include "nsIScriptError.h"
#include "nsNetUtil.h"

View File

@ -28,7 +28,6 @@
#include "nsStreamUtils.h"
#include "nsXPCOM.h"
#include "nsIDOMEventListener.h"
#include "nsIJSContextStack.h"
#include "nsJSEnvironment.h"
#include "nsIScriptGlobalObject.h"
#include "nsCExternalHandlerService.h"

View File

@ -124,7 +124,6 @@
#include "nsDOMCID.h"
#include "jsapi.h"
#include "nsIJSContextStack.h"
#include "nsIXPConnect.h"
#include "nsCycleCollector.h"
#include "nsCCUncollectableMarker.h"

View File

@ -34,7 +34,6 @@
#include "nsIBaseWindow.h"
#include "nsContentUtils.h"
#include "nsIXPConnect.h"
#include "nsIJSContextStack.h"
#include "nsUnicharUtils.h"
#include "nsIScriptGlobalObject.h"
#include "nsIScriptSecurityManager.h"

View File

@ -19,7 +19,6 @@
#include "nsNetUtil.h"
#include "nsScriptLoader.h"
#include "nsFrameLoader.h"
#include "nsIJSContextStack.h"
#include "nsIXULRuntime.h"
#include "nsIScriptError.h"
#include "nsIConsoleService.h"
@ -630,10 +629,10 @@ nsFrameMessageManager::ReceiveMessage(nsISupports* aTarget,
InfallibleTArray<nsString>* aJSONRetVal,
JSContext* aContext)
{
JSContext* ctx = mContext ? mContext : aContext;
if (!ctx) {
ctx = nsContentUtils::ThreadJSContextStack()->GetSafeJSContext();
}
JSContext *cxToUse = mContext ? mContext
: (aContext ? aContext
: nsContentUtils::GetSafeJSContext());
AutoPushJSContext ctx(cxToUse);
if (mListeners.Length()) {
nsCOMPtr<nsIAtom> name = do_GetAtom(aMessage);
MMListenerRemover lr(this);
@ -976,17 +975,10 @@ void
nsFrameScriptExecutor::Shutdown()
{
if (sCachedScripts) {
JSContext* cx = nsContentUtils::ThreadJSContextStack()->GetSafeJSContext();
if (cx) {
#ifdef DEBUG_smaug
printf("Will clear cached frame manager scripts!\n");
#endif
JSAutoRequest ar(cx);
NS_ASSERTION(sCachedScripts != nullptr, "Need cached scripts");
sCachedScripts->Enumerate(CachedScriptUnrooter, cx);
} else {
NS_WARNING("No context available. Leaking cached scripts!\n");
}
SafeAutoJSContext cx;
JSAutoRequest ar(cx);
NS_ASSERTION(sCachedScripts != nullptr, "Need cached scripts");
sCachedScripts->Enumerate(CachedScriptUnrooter, cx);
delete sCachedScripts;
sCachedScripts = nullptr;

View File

@ -62,7 +62,6 @@
#include "nsIEditor.h"
#include "nsIEditorIMESupport.h"
#include "nsIFrame.h"
#include "nsIJSContextStack.h"
#include "nsILinkHandler.h"
#include "nsINameSpaceManager.h"
#include "nsINodeInfo.h"

View File

@ -15,7 +15,6 @@
#include "nsComponentManagerUtils.h"
#include "nsNetUtil.h"
#include "nsScriptLoader.h"
#include "nsIJSContextStack.h"
#include "nsFrameLoader.h"
#include "xpcpublic.h"
#include "nsIMozBrowserFrame.h"

View File

@ -24,7 +24,6 @@
#include "nsIPermissionManager.h"
#include "nsPluginHost.h"
#include "nsJSNPRuntime.h"
#include "nsIJSContextStack.h"
#include "nsIPresShell.h"
#include "nsIScriptGlobalObject.h"
#include "nsIScriptSecurityManager.h"

View File

@ -26,7 +26,6 @@
#include "nsGUIEvent.h"
#include "prprf.h"
#include "nsIDOMEventListener.h"
#include "nsIJSContextStack.h"
#include "nsIScriptSecurityManager.h"
#include "nsWeakPtr.h"
#include "nsIScriptGlobalObject.h"

View File

@ -9,7 +9,6 @@
#include "prprf.h"
#include "nsIJSContextStack.h"
#include "jsapi.h"
#include "nsIScriptSecurityManager.h"
#include "nsServiceManagerUtils.h"
@ -46,15 +45,12 @@ WebGLContext::GenerateWarning(const char *fmt, va_list ap)
// no need to print to stderr, as JS_ReportWarning takes care of this for us.
nsCOMPtr<nsIJSContextStack> stack = do_GetService("@mozilla.org/js/xpc/ContextStack;1");
JSContext* ccx = nullptr;
if (stack && NS_SUCCEEDED(stack->Peek(&ccx)) && ccx) {
JS_ReportWarning(ccx, "WebGL: %s", buf);
if (!ShouldGenerateWarnings()) {
JS_ReportWarning(ccx,
"WebGL: No further warnings will be reported for this WebGL context "
"(already reported %d warnings)", mAlreadyGeneratedWarnings);
}
AutoJSContext cx;
JS_ReportWarning(cx, "WebGL: %s", buf);
if (!ShouldGenerateWarnings()) {
JS_ReportWarning(cx,
"WebGL: No further warnings will be reported for this WebGL context "
"(already reported %d warnings)", mAlreadyGeneratedWarnings);
}
}

View File

@ -8,7 +8,6 @@
#include "nsEventDispatcher.h"
#include "nsGUIEvent.h"
#include "nsIDocument.h"
#include "nsIJSContextStack.h"
#include "nsDOMJSUtils.h"
#include "prprf.h"
#include "nsGlobalWindow.h"

View File

@ -32,7 +32,6 @@
#include "nsIServiceManager.h"
#include "nsIScriptSecurityManager.h"
#include "nsError.h"
#include "nsIJSContextStack.h"
#include "nsIDocument.h"
#include "nsIPresShell.h"
#include "nsMutationEvent.h"

View File

@ -13,7 +13,6 @@
#include "nsIDOMWindow.h"
#include "nsPIDOMWindow.h"
#include "nsJSUtils.h"
#include "nsIJSContextStack.h"
#include "nsGUIEvent.h"
#include "nsEventDispatcher.h"
#include "nsIJSEventListener.h"

View File

@ -35,7 +35,6 @@
#include "nsRuleData.h"
#include "nsIJSContextStack.h"
#include "nsIDOMHTMLMapElement.h"
#include "nsEventDispatcher.h"

View File

@ -69,7 +69,6 @@
#include "nsIDocumentInlines.h"
#include "nsIDocumentEncoder.h" //for outputting selection
#include "nsICachingChannel.h"
#include "nsIJSContextStack.h"
#include "nsIContentViewer.h"
#include "nsIWyciwygChannel.h"
#include "nsIScriptElement.h"
@ -3323,39 +3322,32 @@ nsHTMLDocument::DoClipboardSecurityCheck(bool aPaste)
{
nsresult rv = NS_ERROR_FAILURE;
nsCOMPtr<nsIJSContextStack> stack =
do_GetService("@mozilla.org/js/xpc/ContextStack;1");
JSContext *cx = nsContentUtils::GetCurrentJSContext();
if (!cx) {
return NS_OK;
}
JSAutoRequest ar(cx);
if (stack) {
JSContext *cx = nullptr;
stack->Peek(&cx);
if (!cx) {
return NS_OK;
NS_NAMED_LITERAL_CSTRING(classNameStr, "Clipboard");
nsIScriptSecurityManager *secMan = nsContentUtils::GetSecurityManager();
if (aPaste) {
if (nsHTMLDocument::sPasteInternal_id == JSID_VOID) {
nsHTMLDocument::sPasteInternal_id =
INTERNED_STRING_TO_JSID(cx, ::JS_InternString(cx, "paste"));
}
JSAutoRequest ar(cx);
NS_NAMED_LITERAL_CSTRING(classNameStr, "Clipboard");
nsIScriptSecurityManager *secMan = nsContentUtils::GetSecurityManager();
if (aPaste) {
if (nsHTMLDocument::sPasteInternal_id == JSID_VOID) {
nsHTMLDocument::sPasteInternal_id =
INTERNED_STRING_TO_JSID(cx, ::JS_InternString(cx, "paste"));
}
rv = secMan->CheckPropertyAccess(cx, nullptr, classNameStr.get(),
nsHTMLDocument::sPasteInternal_id,
nsIXPCSecurityManager::ACCESS_GET_PROPERTY);
} else {
if (nsHTMLDocument::sCutCopyInternal_id == JSID_VOID) {
nsHTMLDocument::sCutCopyInternal_id =
INTERNED_STRING_TO_JSID(cx, ::JS_InternString(cx, "cutcopy"));
}
rv = secMan->CheckPropertyAccess(cx, nullptr, classNameStr.get(),
nsHTMLDocument::sCutCopyInternal_id,
nsIXPCSecurityManager::ACCESS_GET_PROPERTY);
rv = secMan->CheckPropertyAccess(cx, nullptr, classNameStr.get(),
nsHTMLDocument::sPasteInternal_id,
nsIXPCSecurityManager::ACCESS_GET_PROPERTY);
} else {
if (nsHTMLDocument::sCutCopyInternal_id == JSID_VOID) {
nsHTMLDocument::sCutCopyInternal_id =
INTERNED_STRING_TO_JSID(cx, ::JS_InternString(cx, "cutcopy"));
}
rv = secMan->CheckPropertyAccess(cx, nullptr, classNameStr.get(),
nsHTMLDocument::sCutCopyInternal_id,
nsIXPCSecurityManager::ACCESS_GET_PROPERTY);
}
return rv;
}

View File

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