From d95a1b785d45f51ffca8eaf26530211f75106082 Mon Sep 17 00:00:00 2001 From: Jeff Walden Date: Thu, 4 Aug 2011 19:39:13 -0700 Subject: [PATCH] Bug 676738 - Change the index argument to JS_HasElement from jsint to uint32. r=dmandelin --HG-- extra : rebase_source : 20e35753ef5af787d1755ab8c1b68d5b7a43cce1 --- dom/base/nsDOMClassInfo.cpp | 14 ++------------ js/src/jsapi.cpp | 8 ++++++-- js/src/jsapi.h | 2 +- 3 files changed, 9 insertions(+), 15 deletions(-) diff --git a/dom/base/nsDOMClassInfo.cpp b/dom/base/nsDOMClassInfo.cpp index a17522cec51..b95942868a1 100644 --- a/dom/base/nsDOMClassInfo.cpp +++ b/dom/base/nsDOMClassInfo.cpp @@ -9824,12 +9824,7 @@ nsHTMLPluginObjElementSH::GetProperty(nsIXPConnectWrappedNative *wrapper, JSBool found = PR_FALSE; if (!ObjectIsNativeWrapper(cx, obj)) { - if (JSID_IS_STRING(id)) { - *_retval = ::JS_HasPropertyById(cx, pi_obj, id, &found); - } else { - *_retval = ::JS_HasElement(cx, pi_obj, JSID_TO_INT(id), &found); - } - + *_retval = ::JS_HasPropertyById(cx, pi_obj, id, &found); if (!*_retval) { return NS_ERROR_UNEXPECTED; } @@ -9863,12 +9858,7 @@ nsHTMLPluginObjElementSH::SetProperty(nsIXPConnectWrappedNative *wrapper, JSBool found = PR_FALSE; if (!ObjectIsNativeWrapper(cx, obj)) { - if (JSID_IS_STRING(id)) { - *_retval = ::JS_HasPropertyById(cx, pi_obj, id, &found); - } else { - *_retval = ::JS_HasElement(cx, pi_obj, JSID_TO_INT(id), &found); - } - + *_retval = ::JS_HasPropertyById(cx, pi_obj, id, &found); if (!*_retval) { return NS_ERROR_UNEXPECTED; } diff --git a/js/src/jsapi.cpp b/js/src/jsapi.cpp index 699bbd134bd..5ca4f2b6c49 100644 --- a/js/src/jsapi.cpp +++ b/js/src/jsapi.cpp @@ -3294,9 +3294,13 @@ JS_HasPropertyById(JSContext *cx, JSObject *obj, jsid id, JSBool *foundp) } JS_PUBLIC_API(JSBool) -JS_HasElement(JSContext *cx, JSObject *obj, jsint index, JSBool *foundp) +JS_HasElement(JSContext *cx, JSObject *obj, uint32 index, JSBool *foundp) { - return JS_HasPropertyById(cx, obj, INT_TO_JSID(index), foundp); + CHECK_REQUEST(cx); + jsid id; + if (!IndexToId(cx, index, &id)) + return false; + return JS_HasPropertyById(cx, obj, id, foundp); } JS_PUBLIC_API(JSBool) diff --git a/js/src/jsapi.h b/js/src/jsapi.h index c16137debdc..1371b9968de 100644 --- a/js/src/jsapi.h +++ b/js/src/jsapi.h @@ -2493,7 +2493,7 @@ extern JS_PUBLIC_API(JSBool) JS_AlreadyHasOwnElement(JSContext *cx, JSObject *obj, uint32 index, JSBool *foundp); extern JS_PUBLIC_API(JSBool) -JS_HasElement(JSContext *cx, JSObject *obj, jsint index, JSBool *foundp); +JS_HasElement(JSContext *cx, JSObject *obj, uint32 index, JSBool *foundp); extern JS_PUBLIC_API(JSBool) JS_LookupElement(JSContext *cx, JSObject *obj, jsint index, jsval *vp);