mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 868411 - Handlify js::GetObjectProto; r=bz
This commit is contained in:
parent
45ff1bf9a0
commit
634a0652fb
@ -1062,7 +1062,7 @@ FindObjectClass(JSContext* cx, JSObject* aGlobalObject)
|
||||
JS::Rooted<JSObject*> obj(cx), proto(cx, aGlobalObject);
|
||||
do {
|
||||
obj = proto;
|
||||
js::GetObjectProto(cx, obj, proto.address());
|
||||
js::GetObjectProto(cx, obj, &proto);
|
||||
} while (proto);
|
||||
|
||||
sObjectClass = js::GetObjectJSClass(obj);
|
||||
@ -5171,7 +5171,7 @@ nsWindowSH::NewResolve(nsIXPConnectWrappedNative *wrapper, JSContext *cx,
|
||||
|
||||
if (obj == realObj) {
|
||||
JS::Rooted<JSObject*> proto(cx);
|
||||
if (!js::GetObjectProto(cx, obj, proto.address())) {
|
||||
if (!js::GetObjectProto(cx, obj, &proto)) {
|
||||
*_retval = JS_FALSE;
|
||||
return NS_OK;
|
||||
}
|
||||
@ -6346,16 +6346,18 @@ nsHTMLDocumentSH::DocumentAllGetProperty(JSContext *cx, JSHandleObject obj_,
|
||||
return JS_TRUE;
|
||||
}
|
||||
|
||||
JS::Rooted<JSObject*> proto(cx);
|
||||
while (js::GetObjectJSClass(obj) != &sHTMLDocumentAllClass) {
|
||||
if (!js::GetObjectProto(cx, obj, obj.address())) {
|
||||
if (!js::GetObjectProto(cx, obj, &proto)) {
|
||||
return JS_FALSE;
|
||||
}
|
||||
|
||||
if (!obj) {
|
||||
if (!proto) {
|
||||
NS_ERROR("The JS engine lies!");
|
||||
|
||||
return JS_TRUE;
|
||||
}
|
||||
|
||||
obj = proto;
|
||||
}
|
||||
|
||||
nsHTMLDocument *doc = GetDocument(obj);
|
||||
|
@ -953,12 +953,11 @@ nsChromeOuterWindowProxy
|
||||
nsChromeOuterWindowProxy::singleton;
|
||||
|
||||
static JSObject*
|
||||
NewOuterWindowProxy(JSContext *cx, JSObject *aParent, bool isChrome)
|
||||
NewOuterWindowProxy(JSContext *cx, JS::Handle<JSObject*> parent, bool isChrome)
|
||||
{
|
||||
JS::Rooted<JSObject*> parent(cx, aParent);
|
||||
JSAutoCompartment ac(cx, parent);
|
||||
JS::Rooted<JSObject*> proto(cx);
|
||||
if (!js::GetObjectProto(cx, parent, proto.address()))
|
||||
if (!js::GetObjectProto(cx, parent, &proto))
|
||||
return nullptr;
|
||||
|
||||
JSObject *obj = js::Wrapper::New(cx, parent, proto, parent,
|
||||
@ -2021,8 +2020,8 @@ nsGlobalWindow::CreateOuterObject(nsGlobalWindow* aNewInner)
|
||||
{
|
||||
AutoPushJSContext cx(mContext->GetNativeContext());
|
||||
|
||||
JSObject* outer = NewOuterWindowProxy(cx, aNewInner->FastGetGlobalJSObject(),
|
||||
IsChromeWindow());
|
||||
JS::Rooted<JSObject*> global(cx, aNewInner->FastGetGlobalJSObject());
|
||||
JSObject* outer = NewOuterWindowProxy(cx, global, IsChromeWindow());
|
||||
if (!outer) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
@ -2360,8 +2359,9 @@ nsGlobalWindow::SetNewDocument(nsIDocument* aDocument,
|
||||
mJSObject = mContext->GetNativeGlobal();
|
||||
SetWrapper(mJSObject);
|
||||
} else {
|
||||
JSObject *outerObject = NewOuterWindowProxy(cx, xpc_UnmarkGrayObject(newInnerWindow->mJSObject),
|
||||
thisChrome);
|
||||
JS::Rooted<JSObject*> global(cx,
|
||||
xpc_UnmarkGrayObject(newInnerWindow->mJSObject));
|
||||
JSObject* outerObject = NewOuterWindowProxy(cx, global, thisChrome);
|
||||
if (!outerObject) {
|
||||
NS_ERROR("out of memory");
|
||||
return NS_ERROR_FAILURE;
|
||||
|
@ -1239,7 +1239,7 @@ GetPropertyOnPrototype(JSContext* cx, JS::Handle<JSObject*> proxy,
|
||||
JS::Value* vp)
|
||||
{
|
||||
JS::Rooted<JSObject*> proto(cx);
|
||||
if (!js::GetObjectProto(cx, proxy, proto.address())) {
|
||||
if (!js::GetObjectProto(cx, proxy, &proto)) {
|
||||
return false;
|
||||
}
|
||||
if (!proto) {
|
||||
|
@ -7015,7 +7015,7 @@ if (expando) {
|
||||
|
||||
""" + get + """
|
||||
JS::Rooted<JSObject*> proto(cx);
|
||||
if (!js::GetObjectProto(cx, proxy, proto.address())) {
|
||||
if (!js::GetObjectProto(cx, proxy, &proto)) {
|
||||
return false;
|
||||
}
|
||||
if (proto) {
|
||||
|
@ -111,7 +111,7 @@ DOMProxyHandler::getPropertyDescriptor(JSContext* cx, JS::Handle<JSObject*> prox
|
||||
}
|
||||
|
||||
JS::Rooted<JSObject*> proto(cx);
|
||||
if (!js::GetObjectProto(cx, proxy, proto.address())) {
|
||||
if (!js::GetObjectProto(cx, proxy, &proto)) {
|
||||
return false;
|
||||
}
|
||||
if (!proto) {
|
||||
@ -192,7 +192,7 @@ DOMProxyHandler::has(JSContext* cx, JS::Handle<JSObject*> proxy, JS::Handle<jsid
|
||||
|
||||
// OK, now we have to look at the proto
|
||||
JS::Rooted<JSObject*> proto(cx);
|
||||
if (!js::GetObjectProto(cx, proxy, proto.address())) {
|
||||
if (!js::GetObjectProto(cx, proxy, &proto)) {
|
||||
return false;
|
||||
}
|
||||
if (!proto) {
|
||||
|
@ -16,6 +16,7 @@
|
||||
#include "jsfriendapi.h"
|
||||
|
||||
using namespace mozilla::jsipc;
|
||||
using namespace JS;
|
||||
|
||||
namespace {
|
||||
|
||||
@ -178,11 +179,13 @@ ObjectWrapperParent::GetJSObject(JSContext* cx) const
|
||||
}
|
||||
|
||||
static ObjectWrapperParent*
|
||||
Unwrap(JSContext* cx, JSObject* obj)
|
||||
Unwrap(JSContext* cx, JSObject* objArg)
|
||||
{
|
||||
RootedObject obj(cx, objArg), proto(cx);
|
||||
while (js::GetObjectClass(obj) != &ObjectWrapperParent::sCPOW_JSClass) {
|
||||
if (!js::GetObjectProto(cx, obj, &obj) || !obj)
|
||||
if (!js::GetObjectProto(cx, obj, &proto) || !proto)
|
||||
return NULL;
|
||||
obj = proto;
|
||||
}
|
||||
|
||||
ObjectWrapperParent* self =
|
||||
|
@ -466,17 +466,17 @@ JS_FRIEND_API(void)
|
||||
SetFunctionNativeReserved(JSObject *fun, size_t which, const Value &val);
|
||||
|
||||
inline bool
|
||||
GetObjectProto(JSContext *cx, JSObject *obj, JSObject **proto)
|
||||
GetObjectProto(JSContext *cx, JS::Handle<JSObject*> obj, JS::MutableHandle<JSObject*> proto)
|
||||
{
|
||||
js::Class *clasp = GetObjectClass(obj);
|
||||
if (clasp == &js::ObjectProxyClass ||
|
||||
clasp == &js::OuterWindowProxyClass ||
|
||||
clasp == &js::FunctionProxyClass)
|
||||
{
|
||||
return JS_GetPrototype(cx, obj, proto);
|
||||
return JS_GetPrototype(cx, obj, proto.address());
|
||||
}
|
||||
|
||||
*proto = reinterpret_cast<const shadow::Object*>(obj)->type->proto;
|
||||
proto.set(reinterpret_cast<const shadow::Object*>(obj.get())->type->proto);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -1,6 +1,6 @@
|
||||
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
||||
*
|
||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
||||
/* vim: set ts=8 sts=4 et sw=4 tw=99: */
|
||||
/* 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/. */
|
||||
|
||||
@ -476,13 +476,15 @@ nsJSIID::Enumerate(nsIXPConnectWrappedNative *wrapper,
|
||||
static JSObject *
|
||||
FindObjectForHasInstance(JSContext *cx, HandleObject objArg)
|
||||
{
|
||||
RootedObject obj(cx, objArg);
|
||||
while (obj && !IS_WRAPPER_CLASS(js::GetObjectClass(obj)) && !IsDOMObject(obj))
|
||||
{
|
||||
if (js::IsWrapper(obj))
|
||||
RootedObject obj(cx, objArg), proto(cx);
|
||||
while (obj && !IS_WRAPPER_CLASS(js::GetObjectClass(obj)) && !IsDOMObject(obj)) {
|
||||
if (js::IsWrapper(obj)) {
|
||||
obj = js::CheckedUnwrap(obj, /* stopAtOuter = */ false);
|
||||
else if (!js::GetObjectProto(cx, obj, obj.address()))
|
||||
continue;
|
||||
}
|
||||
if (!js::GetObjectProto(cx, obj, &proto))
|
||||
return nullptr;
|
||||
obj = proto;
|
||||
}
|
||||
return obj;
|
||||
}
|
||||
|
@ -70,7 +70,7 @@ WrapperFactory::CreateXrayWaiver(JSContext *cx, HandleObject obj)
|
||||
|
||||
// Get a waiver for the proto.
|
||||
RootedObject proto(cx);
|
||||
if (!js::GetObjectProto(cx, obj, proto.address()))
|
||||
if (!js::GetObjectProto(cx, obj, &proto))
|
||||
return nullptr;
|
||||
if (proto && !(proto = WaiveXray(cx, proto)))
|
||||
return nullptr;
|
||||
@ -462,7 +462,7 @@ WrapperFactory::Rewrap(JSContext *cx, HandleObject existing, HandleObject obj,
|
||||
{
|
||||
JSAutoCompartment ac(cx, obj);
|
||||
RootedObject unwrappedProto(cx);
|
||||
if (!js::GetObjectProto(cx, obj, unwrappedProto.address()))
|
||||
if (!js::GetObjectProto(cx, obj, &unwrappedProto))
|
||||
return NULL;
|
||||
if (unwrappedProto && IsCrossCompartmentWrapper(unwrappedProto))
|
||||
unwrappedProto = Wrapper::wrappedObject(unwrappedProto);
|
||||
|
Loading…
Reference in New Issue
Block a user