Skip to content
This repository was archived by the owner on Jul 9, 2025. It is now read-only.

Commit ab74228

Browse files
committed
Bug 854503 - Rename JS unwrapping functions. r=bholley
1 parent ea0f8cc commit ab74228

44 files changed

Lines changed: 134 additions & 134 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

content/base/src/nsObjectLoadingContent.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2946,7 +2946,7 @@ nsObjectLoadingContent::TeardownProtoChain()
29462946
}
29472947
// Unwrap while checking the jsclass - if the prototype is a wrapper for
29482948
// an NP object, that counts too.
2949-
if (JS_GetClass(js::UnwrapObject(proto)) == &sNPObjectJSWrapperClass) {
2949+
if (JS_GetClass(js::UncheckedUnwrap(proto)) == &sNPObjectJSWrapperClass) {
29502950
// We found an NPObject on the proto chain, get its prototype...
29512951
if (!::JS_GetPrototype(cx, proto, &proto)) {
29522952
return;

content/xbl/src/nsXBLProtoImplField.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -183,7 +183,7 @@ InstallXBLField(JSContext* cx,
183183

184184
// If a separate XBL scope is being used, the callee is not same-compartment
185185
// with the xbl prototype, and the object is a cross-compartment wrapper.
186-
xblProto = js::UnwrapObject(xblProto);
186+
xblProto = js::UncheckedUnwrap(xblProto);
187187
JSAutoCompartment ac2(cx, xblProto);
188188
JS::Value slotVal = ::JS_GetReservedSlot(xblProto, 0);
189189
protoBinding = static_cast<nsXBLPrototypeBinding*>(slotVal.toPrivate());
@@ -230,7 +230,7 @@ FieldGetterImpl(JSContext *cx, JS::CallArgs args)
230230
// wrapper. In this case, we know we want to do an unsafe unwrap, and
231231
// InstallXBLField knows how to handle cross-compartment pointers.
232232
bool installed = false;
233-
JS::Rooted<JSObject*> callee(cx, js::UnwrapObject(&args.calleev().toObject()));
233+
JS::Rooted<JSObject*> callee(cx, js::UncheckedUnwrap(&args.calleev().toObject()));
234234
JS::Rooted<jsid> id(cx);
235235
if (!InstallXBLField(cx, callee, thisObj, &id, &installed)) {
236236
return false;
@@ -299,7 +299,7 @@ FieldSetterImpl(JSContext *cx, JS::CallArgs args)
299299
// wrapper. In this case, we know we want to do an unsafe unwrap, and
300300
// InstallXBLField knows how to handle cross-compartment pointers.
301301
bool installed = false;
302-
JS::Rooted<JSObject*> callee(cx, js::UnwrapObject(&args.calleev().toObject()));
302+
JS::Rooted<JSObject*> callee(cx, js::UncheckedUnwrap(&args.calleev().toObject()));
303303
JS::Rooted<jsid> id(cx);
304304
if (!InstallXBLField(cx, callee, thisObj, &id, &installed)) {
305305
return false;

dom/base/nsDOMClassInfo.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4260,7 +4260,7 @@ nsDOMConstructor::HasInstance(nsIXPConnectWrappedNative *wrapper,
42604260
NS_ASSERTION(dom_obj, "nsDOMConstructor::HasInstance couldn't get object");
42614261

42624262
// This might not be the right object, if there are wrappers. Unwrap if we can.
4263-
JSObject *wrapped_obj = js::UnwrapObjectChecked(dom_obj, /* stopAtOuter = */ false);
4263+
JSObject *wrapped_obj = js::CheckedUnwrap(dom_obj, /* stopAtOuter = */ false);
42644264
if (wrapped_obj)
42654265
dom_obj = wrapped_obj;
42664266

@@ -4775,7 +4775,7 @@ nsWindowSH::GlobalResolve(nsGlobalWindow *aWin, JSContext *cx,
47754775
JSObject* global;
47764776
bool defineOnXray = ObjectIsNativeWrapper(cx, obj);
47774777
if (defineOnXray) {
4778-
global = js::UnwrapObjectChecked(obj, /* stopAtOuter = */ false);
4778+
global = js::CheckedUnwrap(obj, /* stopAtOuter = */ false);
47794779
if (!global) {
47804780
return NS_ERROR_DOM_SECURITY_ERR;
47814781
}
@@ -5023,7 +5023,7 @@ static nsresult
50235023
LocationSetterGuts(JSContext *cx, JSObject *obj, jsval *vp)
50245024
{
50255025
// This function duplicates some of the logic in XPC_WN_HelperSetProperty
5026-
obj = js::UnwrapObjectChecked(obj, /* stopAtOuter = */ false);
5026+
obj = js::CheckedUnwrap(obj, /* stopAtOuter = */ false);
50275027
if (!IS_WN_WRAPPER(obj))
50285028
return NS_ERROR_XPC_BAD_CONVERT_JS;
50295029
XPCWrappedNative *wrapper = XPCWrappedNative::Get(obj);

dom/base/nsGlobalWindow.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6489,7 +6489,7 @@ nsGlobalWindow::CallerInnerWindow()
64896489
bool ok = JS_GetPrototype(cx, scope, &scopeProto);
64906490
NS_ENSURE_TRUE(ok, nullptr);
64916491
if (scopeProto && xpc::IsSandboxPrototypeProxy(scopeProto) &&
6492-
(scopeProto = js::UnwrapObjectChecked(scopeProto, /* stopAtOuter = */ false)))
6492+
(scopeProto = js::CheckedUnwrap(scopeProto, /* stopAtOuter = */ false)))
64936493
{
64946494
scope = scopeProto;
64956495
}

dom/bindings/BindingUtils.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -667,7 +667,7 @@ QueryInterface(JSContext* cx, unsigned argc, JS::Value* vp)
667667
// Get the object. It might be a security wrapper, in which case we do a checked
668668
// unwrap.
669669
JSObject* origObj = JSVAL_TO_OBJECT(thisv);
670-
JSObject* obj = js::UnwrapObjectChecked(origObj);
670+
JSObject* obj = js::CheckedUnwrap(origObj);
671671
if (!obj) {
672672
JS_ReportError(cx, "Permission denied to access object");
673673
return false;
@@ -1245,7 +1245,7 @@ HasPropertyOnPrototype(JSContext* cx, JSObject* proxy, DOMProxyHandler* handler,
12451245
{
12461246
Maybe<JSAutoCompartment> ac;
12471247
if (xpc::WrapperFactory::IsXrayWrapper(proxy)) {
1248-
proxy = js::UnwrapObject(proxy);
1248+
proxy = js::UncheckedUnwrap(proxy);
12491249
ac.construct(cx, proxy);
12501250
}
12511251
MOZ_ASSERT(js::IsProxy(proxy) && js::GetProxyHandler(proxy) == handler);
@@ -1587,7 +1587,7 @@ GetGlobalObject(JSContext* aCx, JSObject* aObject,
15871587
Maybe<JSAutoCompartment>& aAutoCompartment)
15881588
{
15891589
if (js::IsWrapper(aObject)) {
1590-
aObject = js::UnwrapObjectChecked(aObject, /* stopAtOuter = */ false);
1590+
aObject = js::CheckedUnwrap(aObject, /* stopAtOuter = */ false);
15911591
if (!aObject) {
15921592
Throw<mainThread>(aCx, NS_ERROR_XPC_SECURITY_MANAGER_VETO);
15931593
return nullptr;
@@ -1636,7 +1636,7 @@ InterfaceHasInstance(JSContext* cx, JSHandleObject obj, JSObject* instance,
16361636
const DOMIfaceAndProtoJSClass* clasp =
16371637
DOMIfaceAndProtoJSClass::FromJSClass(js::GetObjectClass(obj));
16381638

1639-
const DOMClass* domClass = GetDOMClass(js::UnwrapObject(instance));
1639+
const DOMClass* domClass = GetDOMClass(js::UncheckedUnwrap(instance));
16401640

16411641
MOZ_ASSERT(!domClass || clasp->mPrototypeID != prototypes::id::_ID_Count,
16421642
"Why do we have a hasInstance hook if we don't have a prototype "

dom/bindings/BindingUtils.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,7 @@ UnwrapObject(JSContext* cx, JSObject* obj, U& value)
160160
return NS_ERROR_XPC_BAD_CONVERT_JS;
161161
}
162162

163-
obj = js::UnwrapObjectChecked(obj, /* stopAtOuter = */ false);
163+
obj = js::CheckedUnwrap(obj, /* stopAtOuter = */ false);
164164
if (!obj) {
165165
return NS_ERROR_XPC_SECURITY_MANAGER_VETO;
166166
}
@@ -621,7 +621,7 @@ WrapNewBindingNonWrapperCachedObject(JSContext* cx, JSObject* scope, T* value,
621621
// before we call JS_WrapValue.
622622
Maybe<JSAutoCompartment> ac;
623623
if (js::IsWrapper(scope)) {
624-
scope = js::UnwrapObjectChecked(scope, /* stopAtOuter = */ false);
624+
scope = js::CheckedUnwrap(scope, /* stopAtOuter = */ false);
625625
if (!scope)
626626
return false;
627627
ac.construct(cx, scope);

dom/bindings/CallbackObject.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ CallbackObject::CallSetup::CallSetup(JSObject* const aCallback,
5050
// callable.
5151

5252
// First, find the real underlying callback.
53-
JSObject* realCallback = js::UnwrapObject(aCallback);
53+
JSObject* realCallback = js::UncheckedUnwrap(aCallback);
5454

5555
// Now get the nsIScriptGlobalObject for this callback.
5656
JSContext* cx = nullptr;
@@ -106,7 +106,7 @@ CallbackObject::CallSetup::CallSetup(JSObject* const aCallback,
106106
// Make sure to unwrap aCallback before passing it in, because
107107
// getting principals from wrappers is silly.
108108
nsresult rv = nsContentUtils::GetSecurityManager()->
109-
CheckFunctionAccess(cx, js::UnwrapObject(aCallback), nullptr);
109+
CheckFunctionAccess(cx, js::UncheckedUnwrap(aCallback), nullptr);
110110

111111
// Construct a termination func holder even if we're not planning to
112112
// run any script. We need this because we're going to call

dom/bindings/CallbackObject.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ class CallbackObject : public nsISupports
5454
// If aOwner is not null, enter the compartment of aOwner's
5555
// underlying object.
5656
if (aOwner) {
57-
aOwner = js::UnwrapObject(aOwner);
57+
aOwner = js::UncheckedUnwrap(aOwner);
5858
JSAutoCompartment ac(cx, aOwner);
5959
if (!JS_WrapObject(cx, &aCallback)) {
6060
*aInited = false;
@@ -282,9 +282,9 @@ class CallbackObjectHolder : CallbackObjectHolderBase
282282
}
283283

284284
JSObject* thisObj =
285-
js::UnwrapObject(GetWebIDLCallback()->CallbackPreserveColor());
285+
js::UncheckedUnwrap(GetWebIDLCallback()->CallbackPreserveColor());
286286
JSObject* otherObj =
287-
js::UnwrapObject(aOtherCallback->CallbackPreserveColor());
287+
js::UncheckedUnwrap(aOtherCallback->CallbackPreserveColor());
288288
return thisObj == otherObj;
289289
}
290290

dom/bindings/Codegen.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1111,14 +1111,14 @@ def generate_code(self):
11111111
// FIXME Limit this to chrome by checking xpc::AccessCheck::isChrome(obj).
11121112
nsISupports* native =
11131113
nsContentUtils::XPConnect()->GetNativeOfWrapper(cx,
1114-
js::UnwrapObject(instance));
1114+
js::UncheckedUnwrap(instance));
11151115
nsCOMPtr<nsIDOM%s> qiResult = do_QueryInterface(native);
11161116
*bp = !!qiResult;
11171117
return true;
11181118
""" % self.descriptor.interface.identifier.name
11191119

11201120
hasInstanceCode = """
1121-
const DOMClass* domClass = GetDOMClass(js::UnwrapObject(instance));
1121+
const DOMClass* domClass = GetDOMClass(js::UncheckedUnwrap(instance));
11221122
*bp = false;
11231123
"""
11241124
# Sort interaces implementing self by name so we get stable output.
@@ -6073,7 +6073,7 @@ def definition_body(self):
60736073
return """ MOZ_ASSERT(js::IsProxy(obj));
60746074
if (js::GetProxyHandler(obj) != DOMProxyHandler::getInstance()) {
60756075
MOZ_ASSERT(xpc::WrapperFactory::IsXrayWrapper(obj));
6076-
obj = js::UnwrapObject(obj);
6076+
obj = js::UncheckedUnwrap(obj);
60776077
}
60786078
MOZ_ASSERT(IsProxy(obj));
60796079
return static_cast<%s*>(js::GetProxyPrivate(obj).toPrivate());""" % (self.descriptor.nativeType)

dom/plugins/base/nsJSNPRuntime.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -465,7 +465,7 @@ JSValToNPVariant(NPP npp, JSContext *cx, JS::Value val, NPVariant *variant)
465465
// legitimate cases where a security wrapper ends up here (for example,
466466
// Location objects, which are _always_ behind security wrappers).
467467
JSObject *obj = JSVAL_TO_OBJECT(val);
468-
obj = js::UnwrapObjectChecked(obj);
468+
obj = js::CheckedUnwrap(obj);
469469
if (!obj) {
470470
obj = JSVAL_TO_OBJECT(val);
471471
}
@@ -1127,7 +1127,7 @@ nsJSObjWrapper::GetNewOrUsed(NPP npp, JSContext *cx, JSObject *obj)
11271127
static JSObject *
11281128
GetNPObjectWrapper(JSContext *cx, JSObject *obj, bool wrapResult = true)
11291129
{
1130-
while (obj && (obj = js::UnwrapObjectChecked(obj))) {
1130+
while (obj && (obj = js::CheckedUnwrap(obj))) {
11311131
if (JS_GetClass(obj) == &sNPObjectJSWrapperClass) {
11321132
if (wrapResult && !JS_WrapObject(cx, &obj)) {
11331133
return NULL;

0 commit comments

Comments
 (0)