mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-24 21:31:04 +00:00
Bug 677079 - Part b: Use existing JSAPI functions where those are available; r=bholley
This commit is contained in:
parent
f085e09f42
commit
adcd5d59fc
@ -50,7 +50,6 @@
|
||||
#include "mozilla/Util.h"
|
||||
|
||||
#include "jsapi.h"
|
||||
#include "jscntxt.h"
|
||||
#include "jsdbgapi.h"
|
||||
#include "jsfriendapi.h"
|
||||
#include "jsprf.h"
|
||||
@ -554,7 +553,7 @@ GC(JSContext *cx, uintN argc, jsval *vp)
|
||||
{
|
||||
JS_GC(cx);
|
||||
#ifdef JS_GCMETER
|
||||
js_DumpGCStats(cx->runtime, stdout);
|
||||
js_DumpGCStats(JS_GetRuntime(cx), stdout);
|
||||
#endif
|
||||
JS_SET_RVAL(cx, vp, JSVAL_VOID);
|
||||
return true;
|
||||
|
@ -685,9 +685,8 @@ JSBool XPCJSRuntime::GCCallback(JSContext *cx, JSGCStatus status)
|
||||
|
||||
// We seem to sometime lose the unrooted global flag. Restore it
|
||||
// here. FIXME: bug 584495.
|
||||
JSContext *iter = nsnull, *acx;
|
||||
|
||||
while ((acx = JS_ContextIterator(cx->runtime, &iter))) {
|
||||
JSContext *iter = nsnull;
|
||||
while (JSContext *acx = JS_ContextIterator(JS_GetRuntime(cx), &iter)) {
|
||||
if (!acx->hasRunOption(JSOPTION_UNROOTED_GLOBAL))
|
||||
JS_ToggleOptions(acx, JSOPTION_UNROOTED_GLOBAL);
|
||||
}
|
||||
|
@ -55,8 +55,6 @@
|
||||
#include "xpcprivate.h"
|
||||
#include "nsStringBuffer.h"
|
||||
|
||||
#include "jscntxt.h" // emptyAtom
|
||||
|
||||
static int sDOMStringFinalizerIndex = -1;
|
||||
|
||||
static void
|
||||
@ -89,10 +87,8 @@ XPCStringConvert::ReadableToJSVal(JSContext *cx,
|
||||
|
||||
PRUint32 length = readable.Length();
|
||||
|
||||
JSAtom *atom;
|
||||
if (length == 0 && (atom = cx->runtime->atomState.emptyAtom)) {
|
||||
return STRING_TO_JSVAL(atom);
|
||||
}
|
||||
if (length == 0)
|
||||
return JS_GetEmptyStringValue(cx);
|
||||
|
||||
nsStringBuffer *buf = nsStringBuffer::FromString(readable);
|
||||
if (buf) {
|
||||
|
@ -52,7 +52,6 @@
|
||||
#include "WrapperFactory.h"
|
||||
|
||||
#include "jsfriendapi.h"
|
||||
#include "jscntxt.h" // JSID_IS_ATOM, JSFlatString* -> JSString*
|
||||
|
||||
using namespace mozilla;
|
||||
using namespace js;
|
||||
@ -136,7 +135,8 @@ static bool
|
||||
IsPermitted(const char *name, JSFlatString *prop, bool set)
|
||||
{
|
||||
size_t propLength;
|
||||
const jschar *propChars = JS_GetInternedStringCharsAndLength(prop, &propLength);
|
||||
const jschar *propChars =
|
||||
JS_GetInternedStringCharsAndLength(JS_FORGET_STRING_FLATNESS(prop), &propLength);
|
||||
if (!propLength)
|
||||
return false;
|
||||
switch (name[0]) {
|
||||
@ -196,7 +196,7 @@ IsFrameId(JSContext *cx, JSObject *obj, jsid id)
|
||||
|
||||
if (JSID_IS_INT(id)) {
|
||||
col->Item(JSID_TO_INT(id), getter_AddRefs(domwin));
|
||||
} else if (JSID_IS_ATOM(id)) {
|
||||
} else if (JSID_IS_STRING(id)) {
|
||||
nsAutoString str(JS_GetInternedStringChars(JSID_TO_STRING(id)));
|
||||
col->NamedItem(str, getter_AddRefs(domwin));
|
||||
} else {
|
||||
@ -303,7 +303,7 @@ AccessCheck::isCrossOriginAccessPermitted(JSContext *cx, JSObject *wrapper, jsid
|
||||
else
|
||||
name = clasp->name;
|
||||
|
||||
if (JSID_IS_ATOM(id)) {
|
||||
if (JSID_IS_STRING(id)) {
|
||||
if (IsPermitted(name, JSID_TO_FLAT_STRING(id), act == Wrapper::SET))
|
||||
return true;
|
||||
}
|
||||
@ -496,7 +496,7 @@ ExposedPropertiesOnly::check(JSContext *cx, JSObject *wrapper, jsid id, Wrapper:
|
||||
// Always permit access to "length" and indexed properties of arrays.
|
||||
if (JS_IsArrayObject(cx, wrappedObject) &&
|
||||
((JSID_IS_INT(id) && JSID_TO_INT(id) >= 0) ||
|
||||
(JSID_IS_ATOM(id) && JS_FlatStringEqualsAscii(JSID_TO_FLAT_STRING(id), "length")))) {
|
||||
(JSID_IS_STRING(id) && JS_FlatStringEqualsAscii(JSID_TO_FLAT_STRING(id), "length")))) {
|
||||
perm = PermitPropertyAccess;
|
||||
return true; // Allow
|
||||
}
|
||||
|
@ -49,7 +49,7 @@
|
||||
#include "XPCWrapper.h"
|
||||
#include "xpcprivate.h"
|
||||
|
||||
#include "jscntxt.h" // JSID_IS_ATOM, js::AutoIdVector
|
||||
#include "jscntxt.h" // js::AutoIdVector
|
||||
|
||||
namespace xpc {
|
||||
|
||||
@ -261,7 +261,7 @@ ResolveNativeProperty(JSContext *cx, JSObject *wrapper, JSObject *holder, jsid i
|
||||
|
||||
// There are no native numeric properties, so we can shortcut here. We will not
|
||||
// find the property.
|
||||
if (!JSID_IS_ATOM(id)) {
|
||||
if (!JSID_IS_STRING(id)) {
|
||||
/* Not found */
|
||||
return true;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user