зеркало из https://github.com/mozilla/gecko-dev.git
Bug 937317 - Root around GC call GetIncumbentGlobal. r=bz
This commit is contained in:
Родитель
3140797fe1
Коммит
80aa980365
|
@ -272,7 +272,7 @@ nsDOMEventTargetHelper::SetEventHandler(nsIAtom* aType,
|
|||
const JS::Value& aValue)
|
||||
{
|
||||
nsRefPtr<EventHandlerNonNull> handler;
|
||||
JSObject* callable;
|
||||
JS::Rooted<JSObject*> callable(aCx);
|
||||
if (aValue.isObject() &&
|
||||
JS_ObjectIsCallable(aCx, callable = &aValue.toObject())) {
|
||||
handler = new EventHandlerNonNull(callable, mozilla::dom::GetIncumbentGlobal());
|
||||
|
|
|
@ -4946,8 +4946,9 @@ nsGlobalWindow::RequestAnimationFrame(const JS::Value& aCallback,
|
|||
return NS_ERROR_INVALID_ARG;
|
||||
}
|
||||
|
||||
JS::Rooted<JSObject*> callbackObj(cx, &aCallback.toObject());
|
||||
nsRefPtr<FrameRequestCallback> callback =
|
||||
new FrameRequestCallback(&aCallback.toObject(), GetIncumbentGlobal());
|
||||
new FrameRequestCallback(callbackObj, GetIncumbentGlobal());
|
||||
|
||||
ErrorResult rv;
|
||||
*aHandle = RequestAnimationFrame(*callback, rv);
|
||||
|
@ -13231,7 +13232,7 @@ nsGlobalWindow::DisableNetworkEvent(uint32_t aType)
|
|||
NS_IMETHODIMP nsGlobalWindow::SetOn##name_(JSContext *cx, \
|
||||
const JS::Value &v) { \
|
||||
nsRefPtr<EventHandlerNonNull> handler; \
|
||||
JSObject *callable; \
|
||||
JS::Rooted<JSObject*> callable(cx); \
|
||||
if (v.isObject() && \
|
||||
JS_ObjectIsCallable(cx, callable = &v.toObject())) { \
|
||||
handler = new EventHandlerNonNull(callable, GetIncumbentGlobal()); \
|
||||
|
@ -13261,7 +13262,7 @@ nsGlobalWindow::DisableNetworkEvent(uint32_t aType)
|
|||
} \
|
||||
\
|
||||
nsRefPtr<OnErrorEventHandlerNonNull> handler; \
|
||||
JSObject *callable; \
|
||||
JS::Rooted<JSObject*> callable(cx); \
|
||||
if (v.isObject() && \
|
||||
JS_ObjectIsCallable(cx, callable = &v.toObject())) { \
|
||||
handler = new OnErrorEventHandlerNonNull(callable, GetIncumbentGlobal()); \
|
||||
|
@ -13292,7 +13293,7 @@ nsGlobalWindow::DisableNetworkEvent(uint32_t aType)
|
|||
} \
|
||||
\
|
||||
nsRefPtr<OnBeforeUnloadEventHandlerNonNull> handler; \
|
||||
JSObject *callable; \
|
||||
JS::Rooted<JSObject*> callable(cx); \
|
||||
if (v.isObject() && \
|
||||
JS_ObjectIsCallable(cx, callable = &v.toObject())) { \
|
||||
handler = new OnBeforeUnloadEventHandlerNonNull(callable, GetIncumbentGlobal()); \
|
||||
|
|
|
@ -25,7 +25,7 @@ namespace dom {
|
|||
class CallbackFunction : public CallbackObject
|
||||
{
|
||||
public:
|
||||
explicit CallbackFunction(JSObject* aCallable,
|
||||
explicit CallbackFunction(JS::Handle<JSObject*> aCallable,
|
||||
nsIGlobalObject* aIncumbentGlobal)
|
||||
: CallbackObject(aCallable, aIncumbentGlobal)
|
||||
{
|
||||
|
|
|
@ -24,7 +24,7 @@ namespace dom {
|
|||
class CallbackInterface : public CallbackObject
|
||||
{
|
||||
public:
|
||||
explicit CallbackInterface(JSObject* aCallback,
|
||||
explicit CallbackInterface(JS::Handle<JSObject*> aCallback,
|
||||
nsIGlobalObject *aIncumbentGlobal)
|
||||
: CallbackObject(aCallback, aIncumbentGlobal)
|
||||
{
|
||||
|
|
|
@ -49,7 +49,7 @@ public:
|
|||
// incumbent script settings object when the callback is invoked (overriding
|
||||
// the entry point computed from aCallback). If no override is required, the
|
||||
// caller should pass null.
|
||||
explicit CallbackObject(JSObject* aCallback, nsIGlobalObject *aIncumbentGlobal)
|
||||
explicit CallbackObject(JS::Handle<JSObject*> aCallback, nsIGlobalObject *aIncumbentGlobal)
|
||||
{
|
||||
Init(aCallback, aIncumbentGlobal);
|
||||
}
|
||||
|
|
|
@ -3396,7 +3396,10 @@ for (uint32_t i = 0; i < length; ++i) {
|
|||
else:
|
||||
declType = CGGeneric("OwningNonNull<%s>" % name)
|
||||
conversion = (
|
||||
"${declName} = new %s(&${val}.toObject(), mozilla::dom::GetIncumbentGlobal());\n" % name)
|
||||
"{ // Scope for tempRoot\n"
|
||||
" JS::Rooted<JSObject*> tempRoot(cx, &${val}.toObject());\n"
|
||||
" ${declName} = new %s(tempRoot, mozilla::dom::GetIncumbentGlobal());\n"
|
||||
"}" % name)
|
||||
|
||||
template = wrapObjectTemplate(conversion, type,
|
||||
"${declName} = nullptr",
|
||||
|
@ -3729,7 +3732,10 @@ for (uint32_t i = 0; i < length; ++i) {
|
|||
else:
|
||||
declType = CGGeneric("OwningNonNull<%s>" % name)
|
||||
conversion = (
|
||||
" ${declName} = new %s(&${val}.toObject(), mozilla::dom::GetIncumbentGlobal());\n" % name)
|
||||
"{ // Scope for tempRoot\n"
|
||||
" JS::Rooted<JSObject*> tempRoot(cx, &${val}.toObject());\n"
|
||||
" ${declName} = new %s(tempRoot, mozilla::dom::GetIncumbentGlobal());\n"
|
||||
"}\n" % name)
|
||||
|
||||
if allowTreatNonCallableAsNull and type.treatNonCallableAsNull():
|
||||
haveCallable = "JS_ObjectIsCallable(cx, &${val}.toObject())"
|
||||
|
@ -10676,7 +10682,7 @@ class CGCallback(CGClass):
|
|||
|
||||
def getConstructors(self):
|
||||
return [ClassConstructor(
|
||||
[Argument("JSObject*", "aCallback"), Argument("nsIGlobalObject*", "aIncumbentGlobal")],
|
||||
[Argument("JS::Handle<JSObject*>", "aCallback"), Argument("nsIGlobalObject*", "aIncumbentGlobal")],
|
||||
bodyInHeader=True,
|
||||
visibility="public",
|
||||
explicit=True,
|
||||
|
|
Загрузка…
Ссылка в новой задаче