зеркало из https://github.com/mozilla/gecko-dev.git
Bug 868312 - Some more rooting fixes for dom r=bz
This commit is contained in:
Родитель
91c6289f4f
Коммит
e35c65d6d0
|
@ -3644,8 +3644,8 @@ IDBConstantGetter(JSContext *cx, JSHandleObject obj, JSHandleId id, JSMutableHan
|
|||
|
||||
// Redefine property to remove getter
|
||||
NS_ConvertASCIItoUTF16 valStr(c.value);
|
||||
jsval value;
|
||||
if (!xpc::StringToJsval(cx, valStr, &value)) {
|
||||
JS::Rooted<JS::Value> value(cx);
|
||||
if (!xpc::StringToJsval(cx, valStr, value.address())) {
|
||||
return JS_FALSE;
|
||||
}
|
||||
if (!::JS_DefineProperty(cx, obj, c.name, value,
|
||||
|
@ -3660,7 +3660,7 @@ IDBConstantGetter(JSContext *cx, JSHandleObject obj, JSHandleId id, JSMutableHan
|
|||
}
|
||||
|
||||
static nsresult
|
||||
DefineIDBInterfaceConstants(JSContext *cx, JSObject *obj, const nsIID *aIID)
|
||||
DefineIDBInterfaceConstants(JSContext *cx, JS::Handle<JSObject*> obj, const nsIID *aIID)
|
||||
{
|
||||
const char* interface;
|
||||
if (aIID->Equals(NS_GET_IID(nsIIDBCursor))) {
|
||||
|
@ -5545,10 +5545,11 @@ nsNodeSH::AddProperty(nsIXPConnectWrappedNative *wrapper, JSContext *cx,
|
|||
|
||||
NS_IMETHODIMP
|
||||
nsNodeSH::NewResolve(nsIXPConnectWrappedNative *wrapper, JSContext *cx,
|
||||
JSObject *aObj, jsid id, uint32_t flags,
|
||||
JSObject *aObj, jsid aId, uint32_t flags,
|
||||
JSObject **objp, bool *_retval)
|
||||
{
|
||||
JS::Rooted<JSObject*> obj(cx, aObj);
|
||||
JS::Rooted<jsid> id(cx, aId);
|
||||
if (id == sOnload_id || id == sOnerror_id) {
|
||||
// Make sure that this node can't go away while waiting for a
|
||||
// network load that could fire an event handler.
|
||||
|
@ -6770,10 +6771,11 @@ nsHTMLDocumentSH::NewResolve(nsIXPConnectWrappedNative *wrapper, JSContext *cx,
|
|||
|
||||
NS_IMETHODIMP
|
||||
nsHTMLDocumentSH::GetProperty(nsIXPConnectWrappedNative *wrapper,
|
||||
JSContext *cx, JSObject *aObj, jsid id,
|
||||
JSContext *cx, JSObject *aObj, jsid aId,
|
||||
jsval *vp, bool *_retval)
|
||||
{
|
||||
JS::Rooted<JSObject*> obj(cx, aObj);
|
||||
JS::Rooted<jsid> id(cx, aId);
|
||||
nsCOMPtr<nsISupports> result;
|
||||
|
||||
JSAutoRequest ar(cx);
|
||||
|
@ -7166,9 +7168,10 @@ nsCSSRuleListSH::GetItemAt(nsISupports *aNative, uint32_t aIndex,
|
|||
|
||||
NS_IMETHODIMP
|
||||
nsStorage2SH::NewResolve(nsIXPConnectWrappedNative *wrapper, JSContext *cx,
|
||||
JSObject *obj, jsid id, uint32_t flags,
|
||||
JSObject *obj, jsid aId, uint32_t flags,
|
||||
JSObject **objp, bool *_retval)
|
||||
{
|
||||
JS::Rooted<jsid> id(cx, aId);
|
||||
if (ObjectIsNativeWrapper(cx, obj)) {
|
||||
return NS_OK;
|
||||
}
|
||||
|
|
|
@ -2029,7 +2029,7 @@ nsGlobalWindow::CreateOuterObject(nsGlobalWindow* aNewInner)
|
|||
AutoPushJSContext cx(mContext->GetNativeContext());
|
||||
|
||||
JS::Rooted<JSObject*> global(cx, aNewInner->FastGetGlobalJSObject());
|
||||
JSObject* outer = NewOuterWindowProxy(cx, global, IsChromeWindow());
|
||||
JS::Rooted<JSObject*> outer(cx, NewOuterWindowProxy(cx, global, IsChromeWindow()));
|
||||
if (!outer) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
@ -2040,7 +2040,7 @@ nsGlobalWindow::CreateOuterObject(nsGlobalWindow* aNewInner)
|
|||
}
|
||||
|
||||
nsresult
|
||||
nsGlobalWindow::SetOuterObject(JSContext* aCx, JSObject* aOuterObject)
|
||||
nsGlobalWindow::SetOuterObject(JSContext* aCx, JS::Handle<JSObject*> aOuterObject)
|
||||
{
|
||||
// Force our context's global object to be the outer.
|
||||
// NB: JS_SetGlobalObject sets aCx->compartment.
|
||||
|
@ -2393,7 +2393,8 @@ nsGlobalWindow::SetNewDocument(nsIDocument* aDocument,
|
|||
|
||||
JS_SetParent(cx, mJSObject, newInnerWindow->mJSObject);
|
||||
|
||||
rv = SetOuterObject(cx, mJSObject);
|
||||
JS::Rooted<JSObject*> obj(cx, mJSObject);
|
||||
rv = SetOuterObject(cx, obj);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
NS_ASSERTION(!JS_IsExceptionPending(cx),
|
||||
|
|
|
@ -1010,7 +1010,7 @@ protected:
|
|||
inline int32_t DOMMinTimeoutValue() const;
|
||||
|
||||
nsresult CreateOuterObject(nsGlobalWindow* aNewInner);
|
||||
nsresult SetOuterObject(JSContext* aCx, JSObject* aOuterObject);
|
||||
nsresult SetOuterObject(JSContext* aCx, JS::Handle<JSObject*> aOuterObject);
|
||||
nsresult CloneStorageEvent(const nsAString& aType,
|
||||
nsCOMPtr<nsIDOMStorageEvent>& aEvent);
|
||||
|
||||
|
|
|
@ -154,7 +154,7 @@ CameraControlImpl::Get(JSContext* aCx, uint32_t aKey, JS::Value* aValue)
|
|||
CameraRegion* r = ®ionArray[i];
|
||||
JS::Rooted<JS::Value> v(aCx);
|
||||
|
||||
JSObject* o = JS_NewObject(aCx, nullptr, nullptr, nullptr);
|
||||
JS::Rooted<JSObject*> o(aCx, JS_NewObject(aCx, nullptr, nullptr, nullptr));
|
||||
if (!o) {
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
|
|
|
@ -2503,7 +2503,7 @@ ExtractDateFromOptions(JSContext* aCx, const JS::Value& aOptions)
|
|||
if (!JSVAL_IS_VOID(aOptions) && !aOptions.isNull()) {
|
||||
nsresult rv = params.Init(aCx, &aOptions);
|
||||
if (NS_SUCCEEDED(rv) && !JSVAL_IS_VOID(params.since) && !params.since.isNull() && params.since.isObject()) {
|
||||
JSObject* obj = JSVAL_TO_OBJECT(params.since);
|
||||
JS::Rooted<JSObject*> obj(aCx, JSVAL_TO_OBJECT(params.since));
|
||||
if (JS_ObjectIsDate(aCx, obj) && js_DateIsValid(obj)) {
|
||||
result = js_DateGetMsecSinceEpoch(obj);
|
||||
}
|
||||
|
|
|
@ -130,7 +130,6 @@ ArchiveRequest::ReaderReady(nsTArray<nsCOMPtr<nsIDOMFile> >& aFileList,
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
JS::Value result;
|
||||
nsresult rv;
|
||||
|
||||
nsIScriptContext* sc = GetContextForEventHandlers(&rv);
|
||||
|
@ -145,17 +144,18 @@ ArchiveRequest::ReaderReady(nsTArray<nsCOMPtr<nsIDOMFile> >& aFileList,
|
|||
JSAutoRequest ar(cx);
|
||||
JSAutoCompartment ac(cx, global);
|
||||
|
||||
JS::Rooted<JS::Value> result(cx);
|
||||
switch (mOperation) {
|
||||
case GetFilenames:
|
||||
rv = GetFilenamesResult(cx, &result, aFileList);
|
||||
rv = GetFilenamesResult(cx, result.address(), aFileList);
|
||||
break;
|
||||
|
||||
case GetFile:
|
||||
rv = GetFileResult(cx, &result, aFileList);
|
||||
rv = GetFileResult(cx, result.address(), aFileList);
|
||||
break;
|
||||
|
||||
case GetFiles:
|
||||
rv = GetFilesResult(cx, &result, aFileList);
|
||||
rv = GetFilesResult(cx, result.address(), aFileList);
|
||||
break;
|
||||
}
|
||||
|
||||
|
|
|
@ -157,7 +157,7 @@ IDBFactory::Create(nsPIDOMWindow* aWindow,
|
|||
// static
|
||||
nsresult
|
||||
IDBFactory::Create(JSContext* aCx,
|
||||
JSObject* aOwningObject,
|
||||
JS::Handle<JSObject*> aOwningObject,
|
||||
ContentParent* aContentParent,
|
||||
IDBFactory** aFactory)
|
||||
{
|
||||
|
@ -534,7 +534,7 @@ IDBFactory::OpenInternal(const nsAString& aName,
|
|||
NS_ASSERTION(mWindow || mOwningObject, "Must have one of these!");
|
||||
|
||||
nsCOMPtr<nsPIDOMWindow> window;
|
||||
JSObject* scriptOwner = nullptr;
|
||||
JS::Rooted<JSObject*> scriptOwner(aCallingCx);
|
||||
StoragePrivilege privilege;
|
||||
|
||||
if (mWindow) {
|
||||
|
@ -622,8 +622,8 @@ IDBFactory::WrapObject(JSContext* aCx, JS::Handle<JSObject*> aScope)
|
|||
}
|
||||
|
||||
int16_t
|
||||
IDBFactory::Cmp(JSContext* aCx, JS::Value aFirst, JS::Value aSecond,
|
||||
ErrorResult& aRv)
|
||||
IDBFactory::Cmp(JSContext* aCx, JS::Handle<JS::Value> aFirst,
|
||||
JS::Handle<JS::Value> aSecond, ErrorResult& aRv)
|
||||
{
|
||||
Key first, second;
|
||||
nsresult rv = first.SetFromJSVal(aCx, aFirst);
|
||||
|
|
|
@ -64,7 +64,7 @@ public:
|
|||
// Called when using IndexedDB from a JS component or a JSM in the current
|
||||
// process.
|
||||
static nsresult Create(JSContext* aCx,
|
||||
JSObject* aOwningObject,
|
||||
JS::Handle<JSObject*> aOwningObject,
|
||||
ContentParent* aContentParent,
|
||||
IDBFactory** aFactory);
|
||||
|
||||
|
@ -158,7 +158,8 @@ public:
|
|||
}
|
||||
|
||||
int16_t
|
||||
Cmp(JSContext* aCx, JS::Value aFirst, JS::Value aSecond, ErrorResult& aRv);
|
||||
Cmp(JSContext* aCx, JS::Handle<JS::Value> aFirst,
|
||||
JS::Handle<JS::Value> aSecond, ErrorResult& aRv);
|
||||
|
||||
already_AddRefed<nsIIDBOpenDBRequest>
|
||||
OpenForPrincipal(JSContext* aCx, nsIPrincipal* aPrincipal,
|
||||
|
|
|
@ -584,11 +584,11 @@ GenerateRequest(IDBObjectStore* aObjectStore, JSContext* aCx)
|
|||
aObjectStore->Transaction(), aCx);
|
||||
}
|
||||
|
||||
struct GetAddInfoClosure
|
||||
struct MOZ_STACK_CLASS GetAddInfoClosure
|
||||
{
|
||||
IDBObjectStore* mThis;
|
||||
StructuredCloneWriteInfo& mCloneWriteInfo;
|
||||
jsval mValue;
|
||||
JS::Handle<JS::Value> mValue;
|
||||
};
|
||||
|
||||
nsresult
|
||||
|
@ -599,8 +599,7 @@ GetAddInfoCallback(JSContext* aCx, void* aClosure)
|
|||
data->mCloneWriteInfo.mOffsetToKeyProp = 0;
|
||||
data->mCloneWriteInfo.mTransaction = data->mThis->Transaction();
|
||||
|
||||
if (!IDBObjectStore::SerializeValue(aCx, data->mCloneWriteInfo,
|
||||
data->mValue)) {
|
||||
if (!IDBObjectStore::SerializeValue(aCx, data->mCloneWriteInfo, data->mValue)) {
|
||||
return NS_ERROR_DOM_DATA_CLONE_ERR;
|
||||
}
|
||||
|
||||
|
@ -1241,7 +1240,7 @@ IDBObjectStore::DeserializeValue(JSContext* aCx,
|
|||
bool
|
||||
IDBObjectStore::SerializeValue(JSContext* aCx,
|
||||
StructuredCloneWriteInfo& aCloneWriteInfo,
|
||||
jsval aValue)
|
||||
JS::Handle<JS::Value> aValue)
|
||||
{
|
||||
NS_ASSERTION(NS_IsMainThread(),
|
||||
"Should only be serializing on the main thread!");
|
||||
|
@ -1739,8 +1738,8 @@ IDBObjectStore::~IDBObjectStore()
|
|||
|
||||
nsresult
|
||||
IDBObjectStore::GetAddInfo(JSContext* aCx,
|
||||
jsval aValue,
|
||||
jsval aKeyVal,
|
||||
JS::Handle<JS::Value> aValue,
|
||||
JS::Handle<JS::Value> aKeyVal,
|
||||
StructuredCloneWriteInfo& aCloneWriteInfo,
|
||||
Key& aKey,
|
||||
nsTArray<IndexUpdateInfo>& aUpdateInfoArray)
|
||||
|
@ -1827,7 +1826,8 @@ IDBObjectStore::AddOrPut(const jsval& aValue,
|
|||
Key key;
|
||||
nsTArray<IndexUpdateInfo> updateInfo;
|
||||
|
||||
nsresult rv = GetAddInfo(aCx, aValue, keyval, cloneWriteInfo, key,
|
||||
JS::Rooted<JS::Value> value(aCx, aValue);
|
||||
nsresult rv = GetAddInfo(aCx, value, keyval, cloneWriteInfo, key,
|
||||
updateInfo);
|
||||
if (NS_FAILED(rv)) {
|
||||
return rv;
|
||||
|
|
|
@ -99,7 +99,7 @@ public:
|
|||
static bool
|
||||
SerializeValue(JSContext* aCx,
|
||||
StructuredCloneWriteInfo& aCloneWriteInfo,
|
||||
jsval aValue);
|
||||
JS::Handle<JS::Value> aValue);
|
||||
|
||||
template <class DeserializationTraits>
|
||||
static JSObject*
|
||||
|
@ -257,8 +257,8 @@ protected:
|
|||
~IDBObjectStore();
|
||||
|
||||
nsresult GetAddInfo(JSContext* aCx,
|
||||
jsval aValue,
|
||||
jsval aKeyVal,
|
||||
JS::Handle<JS::Value> aValue,
|
||||
JS::Handle<JS::Value> aKeyVal,
|
||||
StructuredCloneWriteInfo& aCloneWriteInfo,
|
||||
Key& aKey,
|
||||
nsTArray<IndexUpdateInfo>& aUpdateInfoArray);
|
||||
|
|
|
@ -342,7 +342,7 @@ IDBOpenDBRequest::~IDBOpenDBRequest()
|
|||
already_AddRefed<IDBOpenDBRequest>
|
||||
IDBOpenDBRequest::Create(IDBFactory* aFactory,
|
||||
nsPIDOMWindow* aOwner,
|
||||
JSObject* aScriptOwner,
|
||||
JS::Handle<JSObject*> aScriptOwner,
|
||||
JSContext* aCallingCx)
|
||||
{
|
||||
NS_ASSERTION(NS_IsMainThread(), "Wrong thread!");
|
||||
|
|
|
@ -130,7 +130,7 @@ public:
|
|||
already_AddRefed<IDBOpenDBRequest>
|
||||
Create(IDBFactory* aFactory,
|
||||
nsPIDOMWindow* aOwner,
|
||||
JSObject* aScriptOwner,
|
||||
JS::Handle<JSObject*> aScriptOwner,
|
||||
JSContext* aCallingCx);
|
||||
|
||||
void SetTransaction(IDBTransaction* aTransaction);
|
||||
|
|
|
@ -158,7 +158,7 @@ GetJSValFromKeyPathString(JSContext* aCx,
|
|||
if (tokenizer.hasMoreTokens()) {
|
||||
// If we're not at the end, we need to add a dummy object to the
|
||||
// chain.
|
||||
JSObject* dummy = JS_NewObject(aCx, nullptr, nullptr, nullptr);
|
||||
JS::Rooted<JSObject*> dummy(aCx, JS_NewObject(aCx, nullptr, nullptr, nullptr));
|
||||
if (!dummy) {
|
||||
rv = NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR;
|
||||
break;
|
||||
|
@ -175,8 +175,8 @@ GetJSValFromKeyPathString(JSContext* aCx,
|
|||
obj = dummy;
|
||||
}
|
||||
else {
|
||||
JSObject* dummy = JS_NewObject(aCx, &IDBObjectStore::sDummyPropJSClass,
|
||||
nullptr, nullptr);
|
||||
JS::Rooted<JSObject*> dummy(aCx, JS_NewObject(aCx, &IDBObjectStore::sDummyPropJSClass,
|
||||
nullptr, nullptr));
|
||||
if (!dummy) {
|
||||
rv = NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR;
|
||||
break;
|
||||
|
|
|
@ -141,7 +141,7 @@ SmsManager::GetSegmentInfoForText(const nsAString& aText,
|
|||
}
|
||||
|
||||
nsresult
|
||||
SmsManager::Send(JSContext* aCx, JSObject* aGlobal, JS::Handle<JSString*> aNumber,
|
||||
SmsManager::Send(JSContext* aCx, JS::Handle<JSObject*> aGlobal, JS::Handle<JSString*> aNumber,
|
||||
const nsAString& aMessage, JS::Value* aRequest)
|
||||
{
|
||||
nsCOMPtr<nsISmsService> smsService = do_GetService(SMS_SERVICE_CONTRACTID);
|
||||
|
|
|
@ -36,7 +36,7 @@ private:
|
|||
/**
|
||||
* Internal Send() method used to send one message.
|
||||
*/
|
||||
nsresult Send(JSContext* aCx, JSObject* aGlobal, JS::Handle<JSString*> aNumber,
|
||||
nsresult Send(JSContext* aCx, JS::Handle<JSObject*> aGlobal, JS::Handle<JSString*> aNumber,
|
||||
const nsAString& aMessage, JS::Value* aRequest);
|
||||
|
||||
nsresult DispatchTrustedSmsEventToSelf(const nsAString& aEventName,
|
||||
|
|
|
@ -55,13 +55,13 @@ MmsAttachmentDataToJSObject(JSContext* aContext,
|
|||
}
|
||||
|
||||
nsCOMPtr<nsIDOMBlob> blob = static_cast<BlobParent*>(aAttachment.contentParent())->GetBlob();
|
||||
JS::Value content;
|
||||
JS::Rooted<JSObject*> global (aContext, JS_GetGlobalForScopeChain(aContext));
|
||||
JS::Rooted<JS::Value> content(aContext);
|
||||
JS::Rooted<JSObject*> global(aContext, JS_GetGlobalForScopeChain(aContext));
|
||||
nsresult rv = nsContentUtils::WrapNative(aContext,
|
||||
global,
|
||||
blob,
|
||||
&NS_GET_IID(nsIDOMBlob),
|
||||
&content);
|
||||
content.address());
|
||||
NS_ENSURE_SUCCESS(rv, nullptr);
|
||||
if (!JS_DefineProperty(aContext, obj, "content", content,
|
||||
nullptr, nullptr, 0)) {
|
||||
|
|
|
@ -18,9 +18,9 @@ using mozilla::net::gNeckoChild;
|
|||
namespace IPC {
|
||||
|
||||
bool
|
||||
DeserializeArrayBuffer(JSObject* aObj,
|
||||
DeserializeArrayBuffer(JS::Handle<JSObject*> aObj,
|
||||
const InfallibleTArray<uint8_t>& aBuffer,
|
||||
JS::Value* aVal)
|
||||
JS::MutableHandle<JS::Value> aVal)
|
||||
{
|
||||
JSContext* cx = nsContentUtils::GetSafeJSContext();
|
||||
JSAutoRequest ar(cx);
|
||||
|
@ -33,7 +33,7 @@ DeserializeArrayBuffer(JSObject* aObj,
|
|||
if (!data)
|
||||
return false;
|
||||
memcpy(data, aBuffer.Elements(), aBuffer.Length());
|
||||
*aVal = OBJECT_TO_JSVAL(obj);
|
||||
aVal.set(OBJECT_TO_JSVAL(obj));
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -135,8 +135,10 @@ TCPSocketChild::RecvCallback(const nsString& aType,
|
|||
const SendableData& data = aData.get_SendableData();
|
||||
|
||||
if (data.type() == SendableData::TArrayOfuint8_t) {
|
||||
JS::Value val;
|
||||
bool ok = IPC::DeserializeArrayBuffer(mSocketObj, data.get_ArrayOfuint8_t(), &val);
|
||||
JSContext* cx = nsContentUtils::GetSafeJSContext();
|
||||
JS::Rooted<JS::Value> val(cx);
|
||||
JS::Rooted<JSObject*> socket(cx, mSocketObj);
|
||||
bool ok = IPC::DeserializeArrayBuffer(socket, data.get_ArrayOfuint8_t(), &val);
|
||||
NS_ENSURE_TRUE(ok, true);
|
||||
rv = mSocket->CallListenerArrayBuffer(aType, val);
|
||||
|
||||
|
|
|
@ -7,6 +7,7 @@
|
|||
#include "jsfriendapi.h"
|
||||
#include "nsJSUtils.h"
|
||||
#include "nsIDOMTCPSocket.h"
|
||||
#include "nsContentUtils.h"
|
||||
#include "mozilla/unused.h"
|
||||
#include "mozilla/AppProcessChecker.h"
|
||||
|
||||
|
@ -14,9 +15,9 @@ namespace IPC {
|
|||
|
||||
//Defined in TCPSocketChild.cpp
|
||||
extern bool
|
||||
DeserializeArrayBuffer(JSObject* aObj,
|
||||
DeserializeArrayBuffer(JS::Handle<JSObject*> aObj,
|
||||
const InfallibleTArray<uint8_t>& aBuffer,
|
||||
JS::Value* aVal);
|
||||
JS::MutableHandle<JS::Value> aVal);
|
||||
|
||||
}
|
||||
|
||||
|
@ -95,8 +96,10 @@ TCPSocketParent::RecvData(const SendableData& aData)
|
|||
nsresult rv;
|
||||
switch (aData.type()) {
|
||||
case SendableData::TArrayOfuint8_t: {
|
||||
JS::Value val;
|
||||
IPC::DeserializeArrayBuffer(mIntermediaryObj, aData.get_ArrayOfuint8_t(), &val);
|
||||
AutoSafeJSContext cx;
|
||||
JS::Rooted<JS::Value> val(cx);
|
||||
JS::Rooted<JSObject*> obj(cx, mIntermediaryObj);
|
||||
IPC::DeserializeArrayBuffer(obj, aData.get_ArrayOfuint8_t(), &val);
|
||||
rv = mIntermediary->SendArrayBuffer(val);
|
||||
NS_ENSURE_SUCCESS(rv, true);
|
||||
break;
|
||||
|
@ -167,8 +170,8 @@ TCPSocketParent::SendCallback(const nsAString& aType, const JS::Value& aDataVal,
|
|||
} else {
|
||||
nsDependentJSString name;
|
||||
|
||||
JS::Value val;
|
||||
if (!JS_GetProperty(aCx, obj, "name", &val)) {
|
||||
JS::Rooted<JS::Value> val(aCx);
|
||||
if (!JS_GetProperty(aCx, obj, "name", val.address())) {
|
||||
NS_ERROR("No name property on supposed error object");
|
||||
} else if (JSVAL_IS_STRING(val)) {
|
||||
if (!name.init(aCx, JSVAL_TO_STRING(val))) {
|
||||
|
|
|
@ -601,7 +601,7 @@ static dom::ConstantSpec gWinProperties[] =
|
|||
* If the field does not exist, create it. If it exists but is not an
|
||||
* object, throw a JS error.
|
||||
*/
|
||||
JSObject *GetOrCreateObjectProperty(JSContext *cx, JSObject *aObject,
|
||||
JSObject *GetOrCreateObjectProperty(JSContext *cx, JS::Handle<JSObject*> aObject,
|
||||
const char *aProperty)
|
||||
{
|
||||
JS::Rooted<JS::Value> val(cx);
|
||||
|
@ -625,7 +625,7 @@ JSObject *GetOrCreateObjectProperty(JSContext *cx, JSObject *aObject,
|
|||
*
|
||||
* If the nsString is void (i.e. IsVoid is true), do nothing.
|
||||
*/
|
||||
bool SetStringProperty(JSContext *cx, JSObject *aObject, const char *aProperty,
|
||||
bool SetStringProperty(JSContext *cx, JS::Handle<JSObject*> aObject, const char *aProperty,
|
||||
const nsString aValue)
|
||||
{
|
||||
if (aValue.IsVoid()) {
|
||||
|
@ -643,7 +643,7 @@ bool SetStringProperty(JSContext *cx, JSObject *aObject, const char *aProperty,
|
|||
* This function creates or uses JS object |OS.Constants| to store
|
||||
* all its constants.
|
||||
*/
|
||||
bool DefineOSFileConstants(JSContext *cx, JSObject *global)
|
||||
bool DefineOSFileConstants(JSContext *cx, JS::Handle<JSObject*> global)
|
||||
{
|
||||
MOZ_ASSERT(gInitialized);
|
||||
|
||||
|
|
|
@ -39,7 +39,7 @@ void CleanupOSFileConstants();
|
|||
* This function creates or uses JS object |OS.Constants| to store
|
||||
* all its constants.
|
||||
*/
|
||||
bool DefineOSFileConstants(JSContext *cx, JSObject *global);
|
||||
bool DefineOSFileConstants(JSContext *cx, JS::Handle<JSObject*> global);
|
||||
|
||||
/**
|
||||
* XPConnect initializer, for use in the main thread.
|
||||
|
|
|
@ -53,9 +53,9 @@ DefineChromeWorkerFunctions(JSContext* aCx, JS::Handle<JSObject*> aGlobal)
|
|||
// Currently ctypes is the only special property given to ChromeWorkers.
|
||||
#ifdef BUILD_CTYPES
|
||||
{
|
||||
jsval ctypes;
|
||||
JS::Rooted<JS::Value> ctypes(aCx);
|
||||
if (!JS_InitCTypesClass(aCx, aGlobal) ||
|
||||
!JS_GetProperty(aCx, aGlobal, "ctypes", &ctypes)) {
|
||||
!JS_GetProperty(aCx, aGlobal, "ctypes", ctypes.address())) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
|
@ -39,10 +39,11 @@ EventTarget::GetEventListener(const nsAString& aType, ErrorResult& aRv) const
|
|||
}
|
||||
|
||||
void
|
||||
EventTarget::SetEventListener(const nsAString& aType, JSObject* aListener,
|
||||
EventTarget::SetEventListener(const nsAString& aType, JSObject* aListener_,
|
||||
ErrorResult& aRv)
|
||||
{
|
||||
JSContext* cx = GetJSContext();
|
||||
JS::Rooted<JSObject*> aListener(cx, aListener_);
|
||||
|
||||
JSString* type =
|
||||
JS_NewUCStringCopyN(cx, aType.BeginReading(), aType.Length());
|
||||
|
@ -56,15 +57,16 @@ EventTarget::SetEventListener(const nsAString& aType, JSObject* aListener,
|
|||
}
|
||||
|
||||
void
|
||||
EventTarget::AddEventListener(const nsAString& aType, JSObject* aListener,
|
||||
EventTarget::AddEventListener(const nsAString& aType, JSObject* aListener_,
|
||||
bool aCapturing, Nullable<bool> aWantsUntrusted,
|
||||
ErrorResult& aRv)
|
||||
{
|
||||
if (!aListener) {
|
||||
if (!aListener_) {
|
||||
return;
|
||||
}
|
||||
|
||||
JSContext* cx = GetJSContext();
|
||||
JS::Rooted<JSObject*> aListener(cx, aListener_);
|
||||
|
||||
JSString* type =
|
||||
JS_NewUCStringCopyN(cx, aType.BeginReading(), aType.Length());
|
||||
|
@ -80,14 +82,15 @@ EventTarget::AddEventListener(const nsAString& aType, JSObject* aListener,
|
|||
}
|
||||
|
||||
void
|
||||
EventTarget::RemoveEventListener(const nsAString& aType, JSObject* aListener,
|
||||
EventTarget::RemoveEventListener(const nsAString& aType, JSObject* aListener_,
|
||||
bool aCapturing, ErrorResult& aRv)
|
||||
{
|
||||
if (!aListener) {
|
||||
if (!aListener_) {
|
||||
return;
|
||||
}
|
||||
|
||||
JSContext* cx = GetJSContext();
|
||||
JS::Rooted<JSObject*> aListener(cx, aListener_);
|
||||
|
||||
JSString* type =
|
||||
JS_NewUCStringCopyN(cx, aType.BeginReading(), aType.Length());
|
||||
|
|
|
@ -230,12 +230,12 @@ DOMException::Create(JSContext* aCx, nsresult aNSResult)
|
|||
return NULL;
|
||||
}
|
||||
|
||||
JSString* jsname = JS_NewStringCopyZ(aCx, name);
|
||||
JS::Rooted<JSString*> jsname(aCx, JS_NewStringCopyZ(aCx, name));
|
||||
if (!jsname) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
JSString* jsmessage = JS_NewStringCopyZ(aCx, message);
|
||||
JS::Rooted<JSString*> jsmessage(aCx, JS_NewStringCopyZ(aCx, message));
|
||||
if (!jsmessage) {
|
||||
return NULL;
|
||||
}
|
||||
|
|
|
@ -65,7 +65,7 @@ public:
|
|||
|
||||
private:
|
||||
static nsIDOMBlob*
|
||||
GetInstancePrivate(JSContext* aCx, JSObject* aObj, const char* aFunctionName)
|
||||
GetInstancePrivate(JSContext* aCx, JS::Handle<JSObject*> aObj, const char* aFunctionName)
|
||||
{
|
||||
nsIDOMBlob* blob = GetPrivate(aObj);
|
||||
if (blob) {
|
||||
|
@ -158,7 +158,7 @@ private:
|
|||
static JSBool
|
||||
Slice(JSContext* aCx, unsigned aArgc, jsval* aVp)
|
||||
{
|
||||
JSObject* obj = JS_THIS_OBJECT(aCx, aVp);
|
||||
JS::Rooted<JSObject*> obj(aCx, JS_THIS_OBJECT(aCx, aVp));
|
||||
if (!obj) {
|
||||
return false;
|
||||
}
|
||||
|
@ -271,7 +271,7 @@ public:
|
|||
|
||||
private:
|
||||
static nsIDOMFile*
|
||||
GetInstancePrivate(JSContext* aCx, JSObject* aObj, const char* aFunctionName)
|
||||
GetInstancePrivate(JSContext* aCx, JS::Handle<JSObject*> aObj, const char* aFunctionName)
|
||||
{
|
||||
nsIDOMFile* file = GetPrivate(aObj);
|
||||
if (file) {
|
||||
|
@ -412,7 +412,7 @@ CreateBlob(JSContext* aCx, nsIDOMBlob* aBlob)
|
|||
}
|
||||
|
||||
bool
|
||||
InitClasses(JSContext* aCx, JSObject* aGlobal)
|
||||
InitClasses(JSContext* aCx, JS::Handle<JSObject*> aGlobal)
|
||||
{
|
||||
JSObject* blobProto = Blob::InitClass(aCx, aGlobal);
|
||||
return blobProto && File::InitClass(aCx, aGlobal, blobProto);
|
||||
|
|
|
@ -19,7 +19,7 @@ BEGIN_WORKERS_NAMESPACE
|
|||
namespace file {
|
||||
|
||||
bool
|
||||
InitClasses(JSContext* aCx, JSObject* aGlobal);
|
||||
InitClasses(JSContext* aCx, JS::Handle<JSObject*> aGlobal);
|
||||
|
||||
JSObject*
|
||||
CreateBlob(JSContext* aCx, nsIDOMBlob* aBlob);
|
||||
|
|
|
@ -37,7 +37,8 @@ public:
|
|||
}
|
||||
|
||||
static JSObject*
|
||||
Create(JSContext* aCx, uint32_t aWidth, uint32_t aHeight, JSObject *aData)
|
||||
Create(JSContext* aCx, uint32_t aWidth,
|
||||
uint32_t aHeight, JS::Handle<JSObject*> aData)
|
||||
{
|
||||
MOZ_ASSERT(aData);
|
||||
MOZ_ASSERT(JS_IsTypedArrayObject(aData));
|
||||
|
@ -167,7 +168,8 @@ InitClass(JSContext* aCx, JSObject* aGlobal)
|
|||
}
|
||||
|
||||
JSObject*
|
||||
Create(JSContext* aCx, uint32_t aWidth, uint32_t aHeight, JSObject* aData)
|
||||
Create(JSContext* aCx, uint32_t aWidth,
|
||||
uint32_t aHeight, JS::Handle<JSObject*> aData)
|
||||
{
|
||||
return ImageData::Create(aCx, aWidth, aHeight, aData);
|
||||
}
|
||||
|
|
|
@ -15,7 +15,8 @@ bool
|
|||
InitClass(JSContext* aCx, JSObject* aGlobal);
|
||||
|
||||
JSObject*
|
||||
Create(JSContext* aCx, uint32_t aWidth, uint32_t aHeight, JSObject* aData);
|
||||
Create(JSContext* aCx, uint32_t aWidth,
|
||||
uint32_t aHeight, JS::Handle<JSObject*> aData);
|
||||
|
||||
/*
|
||||
* All data members live in private slots on the JS Object. Callers must
|
||||
|
|
|
@ -74,10 +74,10 @@ public:
|
|||
InitClass(JSContext* aCx, JSObject* aObj, JSObject* aParentProto,
|
||||
bool aMainRuntime)
|
||||
{
|
||||
JSObject* proto =
|
||||
JS::Rooted<JSObject*> proto(aCx,
|
||||
js::InitClassWithReserved(aCx, aObj, aParentProto, ProtoClass(),
|
||||
Construct, 0, sProperties, sFunctions,
|
||||
NULL, NULL);
|
||||
NULL, NULL));
|
||||
if (!proto) {
|
||||
return NULL;
|
||||
}
|
||||
|
@ -188,7 +188,7 @@ private:
|
|||
|
||||
NS_ConvertASCIItoUTF16 nameStr(name + 2);
|
||||
ErrorResult rv;
|
||||
JSObject* listener = worker->GetEventListener(nameStr, rv);
|
||||
JS::Rooted<JSObject*> listener(aCx, worker->GetEventListener(nameStr, rv));
|
||||
|
||||
if (rv.Failed()) {
|
||||
JS_ReportError(aCx, "Failed to get listener!");
|
||||
|
@ -211,8 +211,8 @@ private:
|
|||
return !JS_IsExceptionPending(aCx);
|
||||
}
|
||||
|
||||
JSObject* listener;
|
||||
if (!JS_ValueToObject(aCx, aVp, &listener)) {
|
||||
JS::Rooted<JSObject*> listener(aCx);
|
||||
if (!JS_ValueToObject(aCx, aVp, listener.address())) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -389,9 +389,9 @@ public:
|
|||
InitClass(JSContext* aCx, JSObject* aObj, JSObject* aParentProto,
|
||||
bool aMainRuntime)
|
||||
{
|
||||
JSObject* proto =
|
||||
JS::Rooted<JSObject*> proto(aCx,
|
||||
js::InitClassWithReserved(aCx, aObj, aParentProto, ProtoClass(),
|
||||
Construct, 0, NULL, NULL, NULL, NULL);
|
||||
Construct, 0, NULL, NULL, NULL, NULL));
|
||||
if (!proto) {
|
||||
return NULL;
|
||||
}
|
||||
|
|
|
@ -204,8 +204,8 @@ struct WorkerStructuredCloneCallbacks
|
|||
MOZ_ASSERT(dataArray.isObject());
|
||||
|
||||
// Construct the ImageData.
|
||||
JSObject* obj = imagedata::Create(aCx, width, height,
|
||||
&dataArray.toObject());
|
||||
JS::Rooted<JSObject*> dataObj(aCx, &dataArray.toObject());
|
||||
JSObject* obj = imagedata::Create(aCx, width, height, dataObj);
|
||||
return obj;
|
||||
}
|
||||
|
||||
|
|
|
@ -292,15 +292,15 @@ private:
|
|||
return false;
|
||||
}
|
||||
|
||||
jsval rval = JSVAL_VOID;
|
||||
JS::Rooted<JS::Value> rval(aCx, JS::UndefinedValue());
|
||||
if (!JS_CallFunctionValue(aCx, JSVAL_TO_OBJECT(scope), listener,
|
||||
ArrayLength(argv), argv, &rval)) {
|
||||
ArrayLength(argv), argv, rval.address())) {
|
||||
JS_ReportPendingException(aCx);
|
||||
return false;
|
||||
}
|
||||
|
||||
if (JSVAL_IS_BOOLEAN(rval) && JSVAL_TO_BOOLEAN(rval) &&
|
||||
!JS_CallFunctionName(aCx, event, "preventDefault", 0, NULL, &rval)) {
|
||||
!JS_CallFunctionName(aCx, event, "preventDefault", 0, NULL, rval.address())) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче