Bug 1275698. Get rid of nsScriptSecurityManager::ScriptAllowed and replace it with xpc::Scriptability::Get(obj).Allowed() for better performance and less indirection. r=khuey

This commit is contained in:
Boris Zbarsky
2016-05-27 20:26:56 -04:00
parent 58f09d0377
commit 8386016c45
8 changed files with 15 additions and 39 deletions

View File

@@ -17,7 +17,6 @@
#include "nsIDocShell.h"
#include "nsIDOMDocument.h"
#include "nsIScriptGlobalObject.h"
#include "nsIScriptSecurityManager.h"
#include "nsIWebShellServices.h"
#include "nsContentUtils.h"
#include "mozAutoDocUpdate.h"
@@ -33,6 +32,7 @@
#include "mozilla/Preferences.h"
#include "nsIHTMLDocument.h"
#include "nsIViewSourceChannel.h"
#include "xpcpublic.h"
using namespace mozilla;
@@ -581,6 +581,9 @@ nsHtml5TreeOpExecutor::FlushDocumentWrite()
bool
nsHtml5TreeOpExecutor::IsScriptEnabled()
{
// Note that if we have no document or no docshell or no global or whatnot we
// want to claim script _is_ enabled, so we don't parse the contents of
// <noscript> tags!
if (!mDocument || !mDocShell)
return true;
nsCOMPtr<nsIScriptGlobalObject> globalObject = do_QueryInterface(mDocument->GetInnerWindow());
@@ -588,11 +591,9 @@ nsHtml5TreeOpExecutor::IsScriptEnabled()
// GlobalObject set yet
if (!globalObject) {
globalObject = mDocShell->GetScriptGlobalObject();
NS_ENSURE_TRUE(globalObject, true);
}
NS_ENSURE_TRUE(globalObject && globalObject->GetGlobalJSObject(), true);
return nsContentUtils::GetSecurityManager()->
ScriptAllowed(globalObject->GetGlobalJSObject());
return xpc::Scriptability::Get(globalObject->GetGlobalJSObject()).Allowed();
}
void