Bug 898136 - Remove nsIDOMGlobalObjectConstructor. r=mrbkap

This commit is contained in:
Masatoshi Kimura 2013-07-31 09:25:31 -04:00
Родитель 479716c930
Коммит 42290cd659
3 изменённых файлов: 4 добавлений и 79 удалений

Просмотреть файл

@ -256,7 +256,6 @@ using mozilla::dom::workers::ResolveWorkerClasses;
#include "DOMCameraCapabilities.h"
#include "nsIOpenWindowEventDetail.h"
#include "nsIAsyncScrollEventDetail.h"
#include "nsIDOMGlobalObjectConstructor.h"
#include "nsIDOMCanvasRenderingContext2D.h"
#include "LockedFile.h"
#include "nsDebug.h"
@ -2729,8 +2728,7 @@ BaseStubConstructor(nsIWeakReference* aWeakOwner,
}
nsCOMPtr<nsIJSNativeInitializer> initializer(do_QueryInterface(native));
nsCOMPtr<nsIDOMGlobalObjectConstructor> constructor(do_QueryInterface(native));
if (initializer || constructor) {
if (initializer) {
// Initialize object using the current inner window, but only if
// the caller can access it.
nsCOMPtr<nsPIDOMWindow> owner = do_QueryReferent(aWeakOwner);
@ -2743,62 +2741,9 @@ BaseStubConstructor(nsIWeakReference* aWeakOwner,
return NS_ERROR_DOM_SECURITY_ERR;
}
if (initializer) {
rv = initializer->Initialize(currentInner, cx, obj, args);
if (NS_FAILED(rv)) {
return rv;
}
} else {
nsCOMPtr<nsIXPConnectWrappedJS> wrappedJS = do_QueryInterface(native);
JS::Rooted<JSObject*> thisObject(cx, wrappedJS->GetJSObject());
if (!thisObject) {
return NS_ERROR_UNEXPECTED;
}
nsCxPusher pusher;
pusher.Push(cx);
JSAutoCompartment ac(cx, thisObject);
JS::Rooted<JS::Value> funval(cx);
if (!JS_GetProperty(cx, thisObject, "constructor", &funval) ||
!funval.isObject()) {
return NS_ERROR_UNEXPECTED;
}
// Check if the object is even callable.
NS_ENSURE_STATE(JS_ObjectIsCallable(cx, &funval.toObject()));
{
// wrap parameters in the target compartment
// we also pass in the calling window as the first argument
unsigned argc = args.length() + 1;
nsAutoArrayPtr<JS::Value> argv(new JS::Value[argc]);
JS::AutoArrayRooter rooter(cx, 0, argv);
nsCOMPtr<nsIXPConnectJSObjectHolder> holder;
nsCOMPtr<nsIDOMWindow> currentWin(do_GetInterface(currentInner));
rv = WrapNative(cx, obj, currentWin, &NS_GET_IID(nsIDOMWindow),
true, &argv[0], getter_AddRefs(holder));
if (!JS_WrapValue(cx, &argv[0]))
return NS_ERROR_FAILURE;
rooter.changeLength(1);
for (size_t i = 1; i < argc; ++i) {
argv[i] = args[i - 1];
if (!JS_WrapValue(cx, &argv[i]))
return NS_ERROR_FAILURE;
rooter.changeLength(i + 1);
}
JS::Rooted<JS::Value> frval(cx);
bool ret = JS_CallFunctionValue(cx, thisObject, funval, argc, argv,
frval.address());
if (!ret) {
return NS_ERROR_FAILURE;
}
}
rv = initializer->Initialize(currentInner, cx, obj, args);
if (NS_FAILED(rv)) {
return rv;
}
}

Просмотреть файл

@ -16,7 +16,6 @@ XPIDL_SOURCES += [
'nsIDOMClientRect.idl',
'nsIDOMClientRectList.idl',
'nsIDOMConstructor.idl',
'nsIDOMGlobalObjectConstructor.idl',
'nsIDOMGlobalPropertyInitializer.idl',
'nsIDOMHistory.idl',
'nsIDOMJSWindow.idl',

Просмотреть файл

@ -1,19 +0,0 @@
/* -*- Mode: IDL; 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/. */
#include "domstubs.idl"
[scriptable, uuid(cb439c73-0129-4289-a349-c5216e6b912a)]
interface nsIDOMGlobalObjectConstructor : nsISupports
{
/*
* JS use only
*
* The constructor() method will be called with any parameters passed
* to the object constructor.
* If the JS implementation returns a value, it will be ignored.
*/
void constructor();
};