Bug 676738 - Change the index argument to JS_DefineElement from jsint to uint32. r=jst, r=dmandelin

--HG--
extra : rebase_source : d0e3be27e3f0cf022eea21805923c2f4736a36ca
This commit is contained in:
Jeff Walden 2011-08-04 19:39:12 -07:00
Родитель d88c5bdf23
Коммит 79d6d0b16a
5 изменённых файлов: 24 добавлений и 29 удалений

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

@ -5189,7 +5189,7 @@ nsWindowSH::InstallGlobalScopePolluter(JSContext *cx, JSObject *obj,
static
already_AddRefed<nsIDOMWindow>
GetChildFrame(nsGlobalWindow *win, jsid id)
GetChildFrame(nsGlobalWindow *win, PRUint32 index)
{
nsCOMPtr<nsIDOMWindowCollection> frames;
win->GetFrames(getter_AddRefs(frames));
@ -5197,7 +5197,7 @@ GetChildFrame(nsGlobalWindow *win, jsid id)
nsIDOMWindow *frame = nsnull;
if (frames) {
frames->Item(JSID_TO_INT(id), &frame);
frames->Item(index, &frame);
}
return frame;
@ -5234,16 +5234,14 @@ nsWindowSH::GetProperty(nsIXPConnectWrappedNative *wrapper, JSContext *cx,
// whacky, that's because this method is *extremely* performace
// critical. Don't touch this unless you know what you're doing.
if (JSID_IS_INT(id)) {
if (JSID_IS_INT(id) && JSID_TO_INT(id) >= 0) {
// If we're accessing a numeric property we'll treat that as if
// window.frames[n] is accessed (since window.frames === window),
// if window.frames[n] is a child frame, wrap the frame and return
// it without doing a security check.
nsCOMPtr<nsIDOMWindow> frame = GetChildFrame(win, id);
PRUint32 index = PRUint32(JSID_TO_INT(id));
nsresult rv = NS_OK;
if (frame) {
if (nsCOMPtr<nsIDOMWindow> frame = GetChildFrame(win, index)) {
// A numeric property accessed and the numeric property is a
// child frame, wrap the child frame without doing a security
// check and return.
@ -6504,19 +6502,17 @@ nsWindowSH::NewResolve(nsIXPConnectWrappedNative *wrapper, JSContext *cx,
nsGlobalWindow *win = nsGlobalWindow::FromWrapper(wrapper);
if (!JSID_IS_STRING(id)) {
if (JSID_IS_INT(id) && !(flags & JSRESOLVE_ASSIGNING)) {
if (JSID_IS_INT(id) && JSID_TO_INT(id) >= 0 && !(flags & JSRESOLVE_ASSIGNING)) {
// If we're resolving a numeric property, treat that as if
// window.frames[n] is resolved (since window.frames ===
// window), if window.frames[n] is a child frame, define a
// property for this index.
nsCOMPtr<nsIDOMWindow> frame = GetChildFrame(win, id);
if (frame) {
PRUint32 index = PRUint32(JSID_TO_INT(id));
if (nsCOMPtr<nsIDOMWindow> frame = GetChildFrame(win, index)) {
// A numeric property accessed and the numeric property is a
// child frame. Define a property for this index.
*_retval = ::JS_DefineElement(cx, obj, JSID_TO_INT(id), JSVAL_VOID,
*_retval = ::JS_DefineElement(cx, obj, index, JSVAL_VOID,
nsnull, nsnull, JSPROP_SHARED);
if (*_retval) {
@ -7907,8 +7903,9 @@ nsGenericArraySH::NewResolve(nsIXPConnectWrappedNative *wrapper, JSContext *cx,
nsresult rv = GetLength(wrapper, cx, obj, &length);
NS_ENSURE_SUCCESS(rv, rv);
if ((PRUint32)n < length) {
*_retval = ::JS_DefineElement(cx, obj, n, JSVAL_VOID, nsnull, nsnull,
PRUint32 index = PRUint32(n);
if (index < length) {
*_retval = ::JS_DefineElement(cx, obj, index, JSVAL_VOID, nsnull, nsnull,
JSPROP_ENUMERATE | JSPROP_SHARED);
*objp = obj;
}
@ -8934,12 +8931,7 @@ nsHTMLDocumentSH::DocumentAllNewResolve(JSContext *cx, JSObject *obj, jsid id,
JSBool ok = JS_TRUE;
if (v != JSVAL_VOID) {
if (JSID_IS_STRING(id)) {
ok = ::JS_DefinePropertyById(cx, obj, id, v, nsnull, nsnull, 0);
} else {
ok = ::JS_DefineElement(cx, obj, JSID_TO_INT(id), v, nsnull, nsnull, 0);
}
ok = ::JS_DefinePropertyById(cx, obj, id, v, nsnull, nsnull, 0);
*objp = obj;
}
@ -9482,7 +9474,7 @@ nsHTMLSelectElementSH::NewResolve(nsIXPConnectWrappedNative *wrapper, JSContext
nsISupports *node = options->GetNodeAt(n);
if (node) {
*objp = obj;
*_retval = JS_DefineElement(cx, obj, n, JSVAL_VOID, nsnull, nsnull,
*_retval = JS_DefineElement(cx, obj, PRUint32(n), JSVAL_VOID, nsnull, nsnull,
JSPROP_ENUMERATE | JSPROP_SHARED);
return NS_OK;

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

@ -184,7 +184,7 @@ NS_IMETHODIMP nsScriptableRegion::GetRects() {
*retvalPtr = OBJECT_TO_JSVAL(destArray);
ncc->SetReturnValueWasSet(PR_TRUE);
int n = 0;
uint32 n = 0;
nsIntRegionRectIterator iter(mRegion);
const nsIntRect *rect;

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

@ -3387,10 +3387,14 @@ JS_DefinePropertyById(JSContext *cx, JSObject *obj, jsid id, jsval value,
}
JS_PUBLIC_API(JSBool)
JS_DefineElement(JSContext *cx, JSObject *obj, jsint index, jsval value,
JS_DefineElement(JSContext *cx, JSObject *obj, uint32 index, jsval value,
JSPropertyOp getter, JSStrictPropertyOp setter, uintN attrs)
{
return DefinePropertyById(cx, obj, INT_TO_JSID(index), Valueify(value),
CHECK_REQUEST(cx);
jsid id;
if (!IndexToId(cx, index, &id))
return false;
return DefinePropertyById(cx, obj, id, Valueify(value),
Valueify(getter), Valueify(setter), attrs, 0, 0);
}

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

@ -2486,7 +2486,7 @@ extern JS_PUBLIC_API(JSBool)
JS_SetArrayLength(JSContext *cx, JSObject *obj, jsuint length);
extern JS_PUBLIC_API(JSBool)
JS_DefineElement(JSContext *cx, JSObject *obj, jsint index, jsval value,
JS_DefineElement(JSContext *cx, JSObject *obj, uint32 index, jsval value,
JSPropertyOp getter, JSStrictPropertyOp setter, uintN attrs);
extern JS_PUBLIC_API(JSBool)

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

@ -1152,7 +1152,7 @@ ProcessArgs(JSContext *cx, JSObject *obj, char **argv, int argc)
{
const char rcfilename[] = "xpcshell.js";
FILE *rcfile;
int i, j, length;
int i;
JSObject *argsObj;
char *filename = NULL;
JSBool isInteractive = JS_TRUE;
@ -1198,8 +1198,7 @@ ProcessArgs(JSContext *cx, JSObject *obj, char **argv, int argc)
return 1;
}
length = argc - i;
for (j = 0; j < length; j++) {
for (size_t j = 0, length = argc - i; j < length; j++) {
JSString *str = JS_NewStringCopyZ(cx, argv[i++]);
if (!str)
return 1;