mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 1046647 - Part 2: Replace AutoCxPusher in nsXBLProtoImpl::InstallImplementation. r=bholley
This commit is contained in:
parent
85496333c0
commit
d09519ac3f
@ -10,8 +10,6 @@
|
||||
#include "nsIDocument.h"
|
||||
#include "nsContentUtils.h"
|
||||
#include "nsCxPusher.h"
|
||||
#include "nsIScriptGlobalObject.h"
|
||||
#include "nsIScriptContext.h"
|
||||
#include "nsIXPConnect.h"
|
||||
#include "nsIServiceManager.h"
|
||||
#include "nsIDOMNode.h"
|
||||
@ -19,6 +17,7 @@
|
||||
#include "nsXBLProtoImplProperty.h"
|
||||
#include "nsIURI.h"
|
||||
#include "mozilla/AddonPathService.h"
|
||||
#include "mozilla/dom/ScriptSettings.h"
|
||||
#include "mozilla/dom/XULElementBinding.h"
|
||||
#include "xpcpublic.h"
|
||||
#include "js/CharacterEncoding.h"
|
||||
@ -42,13 +41,20 @@ nsXBLProtoImpl::InstallImplementation(nsXBLPrototypeBinding* aPrototypeBinding,
|
||||
// nsXBLProtoImplAnonymousMethod::Execute
|
||||
nsIDocument* document = aBinding->GetBoundElement()->OwnerDoc();
|
||||
|
||||
nsCOMPtr<nsIScriptGlobalObject> global = do_QueryInterface(document->GetScopeObject());
|
||||
if (!global) return NS_OK;
|
||||
// This sometimes gets called when we have no outer window and if we don't
|
||||
// catch this, we get leaks during crashtests and reftests.
|
||||
if (NS_WARN_IF(!document->GetWindow())) {
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIScriptContext> context = global->GetContext();
|
||||
if (!context) return NS_OK;
|
||||
JSContext* cx = context->GetNativeContext();
|
||||
AutoCxPusher pusher(cx);
|
||||
// |propertyHolder| (below) can be an existing object, so in theory we might
|
||||
// hit something that could end up running script. We never want that to
|
||||
// happen here, so we use an AutoJSAPI instead of an AutoEntryScript.
|
||||
dom::AutoJSAPI jsapi;
|
||||
if (NS_WARN_IF(!jsapi.Init(document->GetScopeObject()))) {
|
||||
return NS_OK;
|
||||
}
|
||||
JSContext* cx = jsapi.cx();
|
||||
|
||||
// InitTarget objects gives us back the JS object that represents the bound element and the
|
||||
// class object in the bound document that represents the concrete version of this implementation.
|
||||
|
Loading…
Reference in New Issue
Block a user