Remove js_ReparentTypedArrayToScope as it's unused. No bug, r=jorendorff, rs=bent

This commit is contained in:
Jeff Walden 2011-05-10 14:40:45 -07:00
parent 2b4ea10701
commit 7b12ba4cef
4 changed files with 0 additions and 138 deletions

View File

@ -1698,16 +1698,6 @@ public:
*/
static nsresult CreateStructuredClone(JSContext* cx, jsval val, jsval* rval);
/**
* Reparents the given object and all subobjects to the given scope. Also
* fixes all the prototypes. Assumes obj is properly rooted, that obj has no
* getter functions that can cause side effects, and that the only types of
* objects nested within obj are the types that are cloneable via the
* CreateStructuredClone function above.
*/
static nsresult ReparentClonedObjectToScope(JSContext* cx, JSObject* obj,
JSObject* scope);
/**
* Strip all \n, \r and nulls from the given string
* @param aString the string to remove newlines from [in/out]

View File

@ -6100,89 +6100,6 @@ nsContentUtils::CreateStructuredClone(JSContext* cx,
*rval = output;
return NS_OK;
}
// static
nsresult
nsContentUtils::ReparentClonedObjectToScope(JSContext* cx,
JSObject* obj,
JSObject* scope)
{
JSAutoRequest ar(cx);
scope = JS_GetGlobalForObject(cx, scope);
nsAutoTArray<ReparentObjectData, 20> objectData;
objectData.AppendElement(ReparentObjectData(cx, obj));
while (!objectData.IsEmpty()) {
ReparentObjectData& data = objectData[objectData.Length() - 1];
if (!data.ids) {
NS_ASSERTION(!data.index, "Shouldn't have index here");
// Typed arrays are special and don't need to be enumerated.
if (js_IsTypedArray(data.obj)) {
if (!js_ReparentTypedArrayToScope(cx, data.obj, scope)) {
return NS_ERROR_FAILURE;
}
// No need to enumerate anything here.
objectData.RemoveElementAt(objectData.Length() - 1);
continue;
}
JSProtoKey key = JSCLASS_CACHED_PROTO_KEY(JS_GET_CLASS(cx, data.obj));
if (!key) {
// We should never be reparenting an object that doesn't have a standard
// proto key.
return NS_ERROR_FAILURE;
}
// Fix the prototype and parent first.
JSObject* proto;
if (!js_GetClassPrototype(cx, scope, key, &proto) ||
!JS_SetPrototype(cx, data.obj, proto) ||
!JS_SetParent(cx, data.obj, scope)) {
return NS_ERROR_FAILURE;
}
// Primitive arrays don't need to be enumerated either but the proto and
// parent needed to be fixed above. Now we can just move on.
if (js_IsDensePrimitiveArray(data.obj)) {
objectData.RemoveElementAt(objectData.Length() - 1);
continue;
}
// And now enumerate the object's properties.
if (!(data.ids = JS_Enumerate(cx, data.obj))) {
return NS_ERROR_FAILURE;
}
}
// If we've gone through all the object's properties then we're done with
// this frame.
if (data.index == data.ids->length) {
objectData.RemoveElementAt(objectData.Length() - 1);
continue;
}
// Get the id and increment!
jsid id = data.ids->vector[data.index++];
jsval prop;
if (!JS_GetPropertyById(cx, data.obj, id, &prop)) {
return NS_ERROR_FAILURE;
}
// Push a new frame if this property is an object.
if (!JSVAL_IS_PRIMITIVE(prop)) {
objectData.AppendElement(ReparentObjectData(cx, JSVAL_TO_OBJECT(prop)));
}
}
return NS_OK;
}
struct ClassMatchingInfo {
nsAttrValue::AtomArray mClasses;
nsCaseTreatment mCaseTreatment;

View File

@ -1709,39 +1709,3 @@ js_CreateTypedArrayWithBuffer(JSContext *cx, jsint atype, JSObject *bufArg,
AutoArrayRooter tvr(cx, JS_ARRAY_LENGTH(vals), vals);
return TypedArrayConstruct(cx, atype, argc, &vals[0]);
}
JS_FRIEND_API(JSBool)
js_ReparentTypedArrayToScope(JSContext *cx, JSObject *obj, JSObject *scope)
{
JS_ASSERT(obj);
scope = JS_GetGlobalForObject(cx, scope);
if (!scope)
return JS_FALSE;
if (!js_IsTypedArray(obj))
return JS_FALSE;
TypedArray *typedArray = TypedArray::fromJSObject(obj);
JSObject *buffer = typedArray->bufferJS;
JS_ASSERT(js_IsArrayBuffer(buffer));
JSObject *proto;
JSProtoKey key =
JSCLASS_CACHED_PROTO_KEY(&TypedArray::slowClasses[typedArray->type]);
if (!js_GetClassPrototype(cx, scope, key, &proto))
return JS_FALSE;
obj->setProto(proto);
obj->setParent(scope);
key = JSCLASS_CACHED_PROTO_KEY(&ArrayBuffer::jsclass);
if (!js_GetClassPrototype(cx, scope, key, &proto))
return JS_FALSE;
buffer->setProto(proto);
buffer->setParent(scope);
return JS_TRUE;
}

View File

@ -222,15 +222,6 @@ JS_FRIEND_API(JSObject *)
js_CreateTypedArrayWithBuffer(JSContext *cx, jsint atype, JSObject *bufArg,
jsint byteoffset, jsint length);
/*
* Reparent a typed array to a new scope. This should only be used to reparent
* a typed array that does not share its underlying ArrayBuffer with another
* typed array to avoid having a parent mismatch with the other typed array and
* its ArrayBuffer.
*/
JS_FRIEND_API(JSBool)
js_ReparentTypedArrayToScope(JSContext *cx, JSObject *obj, JSObject *scope);
extern int32 JS_FASTCALL
js_TypedArray_uint8_clamp_double(const double x);