Bug 662946 - Remove various headers from INSTALLED_HEADERS that shouldn't be there. r=jimb

--HG--
extra : rebase_source : a6028a859cac4625ef2f3227ce0fa3159b5e8556
This commit is contained in:
Jeff Walden 2011-06-09 01:12:21 -07:00
parent 2872d0dfd3
commit c4d955c11a
17 changed files with 14 additions and 539 deletions

View File

@ -1594,17 +1594,6 @@ public:
static void StripNullChars(const nsAString& aInStr, nsAString& aOutStr);
/**
* Creates a structured clone of the given jsval according to the algorithm
* at:
* http://www.whatwg.org/specs/web-apps/current-work/multipage/
* urls.html#safe-passing-of-structured-data
*
* If the function returns a success code then rval is set to point at the
* cloned jsval. rval is not set if the function returns a failure code.
*/
static nsresult CreateStructuredClone(JSContext* cx, jsval val, jsval* rval);
/**
* Strip all \n, \r and nulls from the given string
* @param aString the string to remove newlines from [in/out]

View File

@ -42,7 +42,8 @@
/* A namespace class for static layout utilities. */
#include "jscntxt.h"
#include "jsapi.h"
#include "jsdbgapi.h"
#include "nsJSUtils.h"
#include "nsCOMPtr.h"
@ -192,11 +193,6 @@ static NS_DEFINE_CID(kXTFServiceCID, NS_XTFSERVICE_CID);
#include "mozAutoDocUpdate.h"
#include "imgICache.h"
#include "jsinterp.h"
#include "jsarray.h"
#include "jsdate.h"
#include "jsregexp.h"
#include "jstypedarray.h"
#include "xpcprivate.h"
#include "nsScriptSecurityManager.h"
#include "nsIChannelPolicy.h"
@ -5286,395 +5282,6 @@ nsContentUtils::StripNullChars(const nsAString& aInStr, nsAString& aOutStr)
}
}
namespace {
const unsigned int kCloneStackFrameStackSize = 20;
class CloneStackFrame
{
friend class CloneStack;
public:
// These three jsvals must all stick together as they're treated as a jsval
// array!
jsval source;
jsval clone;
jsval temp;
js::AutoIdArray ids;
jsuint index;
private:
// Only let CloneStack access these.
CloneStackFrame(JSContext* aCx, jsval aSource, jsval aClone, JSIdArray* aIds)
: source(aSource), clone(aClone), temp(JSVAL_NULL), ids(aCx, aIds), index(0),
prevFrame(nsnull), tvrVals(aCx, 3, &source)
{
MOZ_COUNT_CTOR(CloneStackFrame);
}
~CloneStackFrame()
{
MOZ_COUNT_DTOR(CloneStackFrame);
}
CloneStackFrame* prevFrame;
js::AutoArrayRooter tvrVals;
};
class CloneStack
{
public:
CloneStack(JSContext* cx)
: mCx(cx), mLastFrame(nsnull) {
mObjectSet.Init();
}
~CloneStack() {
while (!IsEmpty()) {
Pop();
}
}
PRBool
Push(jsval source, jsval clone, JSIdArray* ids) {
NS_ASSERTION(!JSVAL_IS_PRIMITIVE(source) && !JSVAL_IS_PRIMITIVE(clone),
"Must be an object!");
if (!ids) {
return PR_FALSE;
}
CloneStackFrame* newFrame;
if (mObjectSet.Count() < kCloneStackFrameStackSize) {
// If the object can fit in our stack space then use that.
CloneStackFrame* buf = reinterpret_cast<CloneStackFrame*>(mStackFrames);
newFrame = new (buf + mObjectSet.Count())
CloneStackFrame(mCx, source, clone, ids);
}
else {
// Use the heap.
newFrame = new CloneStackFrame(mCx, source, clone, ids);
}
mObjectSet.PutEntry(JSVAL_TO_OBJECT(source));
newFrame->prevFrame = mLastFrame;
mLastFrame = newFrame;
return PR_TRUE;
}
CloneStackFrame*
Peek() {
return mLastFrame;
}
void
Pop() {
if (IsEmpty()) {
NS_ERROR("Empty stack!");
return;
}
CloneStackFrame* lastFrame = mLastFrame;
mObjectSet.RemoveEntry(JSVAL_TO_OBJECT(lastFrame->source));
mLastFrame = lastFrame->prevFrame;
if (mObjectSet.Count() >= kCloneStackFrameStackSize) {
// Only delete if this was a heap object.
delete lastFrame;
}
else {
// Otherwise just run the destructor.
lastFrame->~CloneStackFrame();
}
}
PRBool
IsEmpty() {
NS_ASSERTION((!mLastFrame && !mObjectSet.Count()) ||
(mLastFrame && mObjectSet.Count()),
"Hashset is out of sync!");
return mObjectSet.Count() == 0;
}
PRBool
Search(JSObject* obj) {
return !!mObjectSet.GetEntry(obj);
}
private:
JSContext* mCx;
CloneStackFrame* mLastFrame;
nsTHashtable<nsVoidPtrHashKey> mObjectSet;
// Use a char array instead of CloneStackFrame array to prevent the JSAuto*
// helpers from running until we're ready for them.
char mStackFrames[kCloneStackFrameStackSize * sizeof(CloneStackFrame)];
};
struct ReparentObjectData {
ReparentObjectData(JSContext* cx, JSObject* obj)
: cx(cx), obj(obj), ids(nsnull), index(0) { }
~ReparentObjectData() {
if (ids) {
JS_DestroyIdArray(cx, ids);
}
}
JSContext* cx;
JSObject* obj;
JSIdArray* ids;
jsint index;
};
inline nsresult
SetPropertyOnValueOrObject(JSContext* cx,
jsval val,
jsval* rval,
JSObject* obj,
jsid id)
{
NS_ASSERTION((rval && !obj) || (!rval && obj), "Can only clone to one dest!");
if (rval) {
*rval = val;
return NS_OK;
}
if (!JS_DefinePropertyById(cx, obj, id, val, nsnull, nsnull,
JSPROP_ENUMERATE)) {
return NS_ERROR_FAILURE;
}
return NS_OK;
}
inline JSObject*
CreateEmptyObjectOrArray(JSContext* cx,
JSObject* obj)
{
if (JS_IsArrayObject(cx, obj)) {
jsuint length;
if (!JS_GetArrayLength(cx, obj, &length)) {
NS_ERROR("Failed to get array length?!");
return nsnull;
}
return JS_NewArrayObject(cx, length, NULL);
}
return JS_NewObject(cx, NULL, NULL, NULL);
}
nsresult
CloneSimpleValues(JSContext* cx,
jsval val,
jsval* rval,
PRBool* wasCloned,
JSObject* robj = nsnull,
jsid rid = INT_TO_JSID(0))
{
*wasCloned = PR_TRUE;
// No cloning necessary for these non-GC'd jsvals.
if (!JSVAL_IS_GCTHING(val) || JSVAL_IS_NULL(val)) {
return SetPropertyOnValueOrObject(cx, val, rval, robj, rid);
}
// We'll use immutable strings to prevent copying if we can.
if (JSVAL_IS_STRING(val)) {
if (!JS_MakeStringImmutable(cx, JSVAL_TO_STRING(val))) {
return NS_ERROR_FAILURE;
}
return SetPropertyOnValueOrObject(cx, val, rval, robj, rid);
}
NS_ASSERTION(!JSVAL_IS_PRIMITIVE(val), "Not an object!");
JSObject* obj = JSVAL_TO_OBJECT(val);
// Dense arrays of primitives can be cloned quickly.
JSObject* newArray;
if (!js_CloneDensePrimitiveArray(cx, obj, &newArray)) {
return NS_ERROR_FAILURE;
}
if (newArray) {
return SetPropertyOnValueOrObject(cx, OBJECT_TO_JSVAL(newArray), rval, robj,
rid);
}
// Date objects.
if (js_DateIsValid(cx, obj)) {
jsdouble msec = js_DateGetMsecSinceEpoch(cx, obj);
JSObject* newDate;
if (!(msec && (newDate = js_NewDateObjectMsec(cx, msec)))) {
return NS_ERROR_OUT_OF_MEMORY;
}
return SetPropertyOnValueOrObject(cx, OBJECT_TO_JSVAL(newDate), rval, robj,
rid);
}
// RegExp objects.
if (js_ObjectIsRegExp(obj)) {
JSObject* proto;
if (!js_GetClassPrototype(cx, JS_GetScopeChain(cx), JSProto_RegExp,
&proto)) {
return NS_ERROR_FAILURE;
}
JSObject* newRegExp = js_CloneRegExpObject(cx, obj, proto);
if (!newRegExp) {
return NS_ERROR_FAILURE;
}
return SetPropertyOnValueOrObject(cx, OBJECT_TO_JSVAL(newRegExp), rval,
robj, rid);
}
// Typed array objects.
if (js_IsTypedArray(obj)) {
js::TypedArray* src = js::TypedArray::fromJSObject(obj);
JSObject* newTypedArray = js_CreateTypedArrayWithArray(cx, src->type, obj);
if (!newTypedArray) {
return NS_ERROR_FAILURE;
}
return SetPropertyOnValueOrObject(cx, OBJECT_TO_JSVAL(newTypedArray), rval,
robj, rid);
}
// ArrayBuffer objects.
if (js_IsArrayBuffer(obj)) {
JSObject* src = js::ArrayBuffer::getArrayBuffer(src);
if (!src) {
return NS_ERROR_FAILURE;
}
JSObject* newBuffer = js_CreateArrayBuffer(cx, js::ArrayBuffer::getByteLength(src));
if (!newBuffer) {
return NS_ERROR_FAILURE;
}
memcpy(js::ArrayBuffer::getDataOffset(newBuffer), js::ArrayBuffer::getDataOffset(src),
js::ArrayBuffer::getByteLength(src));
return SetPropertyOnValueOrObject(cx, OBJECT_TO_JSVAL(newBuffer), rval,
robj, rid);
}
// Do we support File?
// Do we support Blob?
// Do we support FileList?
// Function objects don't get cloned.
if (JS_ObjectIsFunction(cx, obj)) {
return NS_ERROR_DOM_NOT_SUPPORTED_ERR;
}
// Security wrapped objects are not allowed either.
if (obj->isWrapper() && !obj->getClass()->ext.innerObject)
return NS_ERROR_DOM_NOT_SUPPORTED_ERR;
// See if this JSObject is backed by some C++ object. If it is then we assume
// that it is inappropriate to clone.
nsCOMPtr<nsIXPConnectWrappedNative> wrapper;
nsContentUtils::XPConnect()->
GetWrappedNativeOfJSObject(cx, obj, getter_AddRefs(wrapper));
if (wrapper) {
return NS_ERROR_DOM_NOT_SUPPORTED_ERR;
}
*wasCloned = PR_FALSE;
return NS_OK;
}
} // anonymous namespace
// static
nsresult
nsContentUtils::CreateStructuredClone(JSContext* cx,
jsval val,
jsval* rval)
{
JSAutoRequest ar(cx);
nsCOMPtr<nsIXPConnect> xpconnect(sXPConnect);
NS_ENSURE_STATE(xpconnect);
PRBool wasCloned;
nsresult rv = CloneSimpleValues(cx, val, rval, &wasCloned);
if (NS_FAILED(rv)) {
return rv;
}
if (wasCloned) {
return NS_OK;
}
NS_ASSERTION(JSVAL_IS_OBJECT(val), "Not an object?!");
JSObject* obj = CreateEmptyObjectOrArray(cx, JSVAL_TO_OBJECT(val));
if (!obj) {
return NS_ERROR_OUT_OF_MEMORY;
}
jsval output = OBJECT_TO_JSVAL(obj);
js::AutoValueRooter tvr(cx, output);
CloneStack stack(cx);
if (!stack.Push(val, OBJECT_TO_JSVAL(obj),
JS_Enumerate(cx, JSVAL_TO_OBJECT(val)))) {
return NS_ERROR_OUT_OF_MEMORY;
}
while (!stack.IsEmpty()) {
CloneStackFrame* frame = stack.Peek();
NS_ASSERTION(!!frame->ids &&
frame->ids.length() >= frame->index &&
!JSVAL_IS_PRIMITIVE(frame->source) &&
!JSVAL_IS_PRIMITIVE(frame->clone),
"Bad frame state!");
if (frame->index == frame->ids.length()) {
// Done cloning this object, pop the frame.
stack.Pop();
continue;
}
// Get the current id and increment the index.
jsid id = frame->ids[frame->index++];
if (!JS_GetPropertyById(cx, JSVAL_TO_OBJECT(frame->source), id,
&frame->temp)) {
return NS_ERROR_FAILURE;
}
if (!JSVAL_IS_PRIMITIVE(frame->temp) &&
stack.Search(JSVAL_TO_OBJECT(frame->temp))) {
// Spec says to throw this particular exception for cyclical references.
return NS_ERROR_DOM_NOT_SUPPORTED_ERR;
}
JSObject* clone = JSVAL_TO_OBJECT(frame->clone);
PRBool wasCloned;
nsresult rv = CloneSimpleValues(cx, frame->temp, nsnull, &wasCloned, clone,
id);
if (NS_FAILED(rv)) {
return rv;
}
if (!wasCloned) {
NS_ASSERTION(JSVAL_IS_OBJECT(frame->temp), "Not an object?!");
obj = CreateEmptyObjectOrArray(cx, JSVAL_TO_OBJECT(frame->temp));
if (!obj ||
!stack.Push(frame->temp, OBJECT_TO_JSVAL(obj),
JS_Enumerate(cx, JSVAL_TO_OBJECT(frame->temp)))) {
return NS_ERROR_OUT_OF_MEMORY;
}
// Set the new object as a property of the clone. We'll fill it on the
// next iteration.
if (!JS_DefinePropertyById(cx, clone, id, OBJECT_TO_JSVAL(obj), nsnull,
nsnull, JSPROP_ENUMERATE)) {
return NS_ERROR_FAILURE;
}
}
}
*rval = output;
return NS_OK;
}
struct ClassMatchingInfo {
nsAttrValue::AtomArray mClasses;
nsCaseTreatment mCaseTreatment;

View File

@ -42,7 +42,6 @@
#include "nsContentUtils.h"
#include "nsIXPConnect.h"
#include "jsapi.h"
#include "jsarray.h"
#include "jsinterp.h"
#include "nsJSUtils.h"
#include "nsNetUtil.h"

View File

@ -59,7 +59,6 @@
#include "nsIPrivateDOMEvent.h"
#include "nsFrameLoader.h"
#include "nsNetUtil.h"
#include "jsarray.h"
#include "nsContentUtils.h"
#include "nsContentPermissionHelper.h"
#include "nsIDOMNSHTMLFrameElement.h"

View File

@ -39,14 +39,7 @@
* ***** END LICENSE BLOCK ***** */
#include "jsapi.h"
#include "jsdtoa.h"
#include "jsprvtd.h"
#include "jsbool.h"
#include "jsarena.h"
#include "jscntxt.h"
#include "jsinterp.h"
#include "jsiter.h"
#include "jstypes.h"
#include "jsdbgapi.h"
#include "nsIServiceManager.h"
#include "nsJSON.h"
#include "nsIXPConnect.h"

View File

@ -44,8 +44,6 @@
#include "mozilla/jetpack/Handle.h"
#include "mozilla/IntentionalCrash.h"
#include "jsarray.h"
#include <stdio.h>
namespace mozilla {

View File

@ -196,9 +196,7 @@ INSTALLED_HEADERS = \
$(CURDIR)/jsautokw.h \
js.msg \
jsalloc.h \
jsanalyze.h \
jsapi.h \
jsarray.h \
jsarena.h \
jsatom.h \
jsbit.h \
@ -210,12 +208,10 @@ INSTALLED_HEADERS = \
jsdate.h \
jsdbgapi.h \
jsdhash.h \
jsdtoa.h \
jsemit.h \
jsfun.h \
jsfriendapi.h \
jsgc.h \
jsgcmark.h \
jscell.h \
jsgcchunk.h \
jsgcstats.h \
@ -226,36 +222,28 @@ INSTALLED_HEADERS = \
jsiter.h \
jslock.h \
jslong.h \
jsmath.h \
jsobj.h \
jsobjinlines.h \
json.h \
jsonparser.h \
jsopcode.tbl \
jsopcode.h \
jsopcodeinlines.h \
jsotypes.h \
jsparse.h \
jsproxy.h \
jsprf.h \
jsprobes.h \
jspropertycache.h \
jspropertycacheinlines.h \
jspropertytree.h \
jsproto.tbl \
jsprvtd.h \
jspubtd.h \
jsreflect.h \
jsregexp.h \
jsscan.h \
jsscope.h \
jsscript.h \
jsscriptinlines.h \
jsstaticcheck.h \
jsstdint.h \
jsstr.h \
jstracer.h \
jshotloop.h \
jstypedarray.h \
jstypes.h \
jsutil.h \
@ -263,10 +251,8 @@ INSTALLED_HEADERS = \
jstl.h \
jshashtable.h \
jsversion.h \
jsweakmap.h \
jswrapper.h \
jsxdrapi.h \
jsxml.h \
jsval.h \
jsvalue.h \
prmjtime.h \

View File

@ -3204,73 +3204,3 @@ js_ArrayInfo(JSContext *cx, uintN argc, jsval *vp)
return true;
}
#endif
JS_FRIEND_API(JSBool)
js_IsDensePrimitiveArray(JSObject *obj)
{
if (!obj || !obj->isDenseArray())
return JS_FALSE;
jsuint capacity = obj->getDenseArrayCapacity();
for (jsuint i = 0; i < capacity; i++) {
if (obj->getDenseArrayElement(i).isObject())
return JS_FALSE;
}
return JS_TRUE;
}
JS_FRIEND_API(JSBool)
js_CloneDensePrimitiveArray(JSContext *cx, JSObject *obj, JSObject **clone)
{
JS_ASSERT(obj);
if (!obj->isDenseArray()) {
/*
* This wasn't a dense array. Return JS_TRUE but a NULL clone to signal
* that no exception was encountered.
*/
*clone = NULL;
return JS_TRUE;
}
jsuint length = obj->getArrayLength();
/*
* Must use the minimum of original array's length and capacity, to handle
* |a = [1,2,3]; a.length = 10000| "dense" cases efficiently. In the normal
* case where length is <= capacity, the clone and original array will have
* the same capacity.
*/
jsuint jsvalCount = JS_MIN(obj->getDenseArrayCapacity(), length);
AutoValueVector vector(cx);
if (!vector.reserve(jsvalCount))
return JS_FALSE;
for (jsuint i = 0; i < jsvalCount; i++) {
const Value &val = obj->getDenseArrayElement(i);
if (val.isString()) {
// Strings must be made immutable before being copied to a clone.
if (!val.toString()->ensureFixed(cx))
return JS_FALSE;
} else if (val.isObject()) {
/*
* This wasn't an array of primitives. Return JS_TRUE but a null
* clone to signal that no exception was encountered.
*/
*clone = NULL;
return JS_TRUE;
}
vector.infallibleAppend(val);
}
*clone = NewDenseCopiedArray(cx, jsvalCount, vector.begin());
if (!*clone)
return JS_FALSE;
/* The length will be set to the JS_MIN, above, but length might be larger. */
(*clone)->setArrayLength(length);
return JS_TRUE;
}

View File

@ -271,26 +271,6 @@ js_GetDenseArrayElementValue(JSContext *cx, JSObject *obj, jsid id,
JSBool
js_Array(JSContext *cx, uintN argc, js::Value *vp);
/*
* Makes a fast clone of a dense array as long as the array only contains
* primitive values.
*
* If the return value is JS_FALSE then clone will not be set.
*
* If the return value is JS_TRUE then clone will either be set to the address
* of a new JSObject or to NULL if the array was not dense or contained values
* that were not primitives.
*/
JS_FRIEND_API(JSBool)
js_CloneDensePrimitiveArray(JSContext *cx, JSObject *obj, JSObject **clone);
/*
* Returns JS_TRUE if the given object is a dense array that contains only
* primitive values.
*/
JS_FRIEND_API(JSBool)
js_IsDensePrimitiveArray(JSObject *obj);
extern JSBool JS_FASTCALL
js_EnsureDenseArrayCapacity(JSContext *cx, JSObject *obj, jsint i);

View File

@ -62,6 +62,7 @@
#include "jscntxt.h"
#include "jsversion.h"
#include "jsdbgapi.h"
#include "jsdtoa.h"
#include "jsexn.h"
#include "jsfun.h"
#include "jsgc.h"

View File

@ -51,19 +51,16 @@
#include "jslong.h"
#include "jsatom.h"
#include "jsdhash.h"
#include "jsdtoa.h"
#include "jsfun.h"
#include "jsgc.h"
#include "jsgcchunk.h"
#include "jshashtable.h"
#include "jsinterp.h"
#include "jsmath.h"
#include "jsobj.h"
#include "jspropertycache.h"
#include "jspropertytree.h"
#include "jsstaticcheck.h"
#include "jsutil.h"
#include "jsarray.h"
#include "jsvector.h"
#include "prmjtime.h"
@ -88,6 +85,10 @@ template<typename T> class Seq;
} /* namespace nanojit */
JS_BEGIN_EXTERN_C
struct DtoaState;
JS_END_EXTERN_C
namespace js {
/* Tracer constants. */
@ -209,7 +210,7 @@ struct ThreadData {
/* Property cache for faster call/get/set invocation. */
PropertyCache propertyCache;
/* State used by dtoa.c. */
/* State used by jsdtoa.cpp. */
DtoaState *dtoaState;
/* Base address of the native stack for the current thread. */

View File

@ -43,6 +43,7 @@
#include "jsgc.h"
#include "jsgcmark.h"
#include "jsiter.h"
#include "jsmath.h"
#include "jsproxy.h"
#include "jsscope.h"
#include "jstracer.h"

View File

@ -42,12 +42,10 @@
#include "jscntxt.h"
#include "jsgc.h"
#include "jsmath.h"
#include "jsobj.h"
#include "jsfun.h"
#include "jsgcstats.h"
#include "jsclist.h"
#include "jsxml.h"
#ifdef _MSC_VER
#pragma warning(push)
@ -347,6 +345,8 @@ class NativeIterCache {
}
};
class MathCache;
/*
* A single-entry cache for some base-10 double-to-string conversions. This
* helps date-format-xparb.js. It also avoids skewing the results for

View File

@ -41,6 +41,7 @@
#define jsscopeinlines_h___
#include <new>
#include "jsarray.h"
#include "jsbool.h"
#include "jscntxt.h"
#include "jsdbgapi.h"

View File

@ -462,11 +462,6 @@ static JS_ALWAYS_INLINE jsval_layout
BOOLEAN_TO_JSVAL_IMPL(JSBool b)
{
jsval_layout l;
/*
* Happens if XPConnect hands out an illegal value (constructed from C++ through a PRBool, for
* instance).
*/
JS_ASSERT(b == JS_TRUE || b == JS_FALSE);
l.s.tag = JSVAL_TAG_BOOLEAN;
l.s.payload.boo = b;
@ -660,11 +655,6 @@ static JS_ALWAYS_INLINE jsval_layout
BOOLEAN_TO_JSVAL_IMPL(JSBool b)
{
jsval_layout l;
/*
* Happens if XPConnect hands out an illegal value (constructed from C++ through a PRBool, for
* instance).
*/
JS_ASSERT(b == JS_TRUE || b == JS_FALSE);
l.asBits = ((uint64)(uint32)b) | JSVAL_SHIFTED_TAG_BOOLEAN;
return l;

View File

@ -42,6 +42,7 @@
#include "jscntxt.h"
#include "jsexn.h"
#include "jsmath.h"
#include "json.h"
#include "jsobjinlines.h"

View File

@ -45,7 +45,6 @@
#include "mozStorageStatement.h"
#include "jsapi.h"
#include "jsdate.h"
namespace mozilla {
namespace storage {