зеркало из https://github.com/mozilla/gecko-dev.git
Bug 902718 - Rip out nsIScriptContext from the lion's share of XBL code. r=bz
This kind of has to be done all at once. The primary correctness concern here is making sure that we continue to operate in the correct compartment. So the basic strategy here is as follows. For most anything that previously took a script context, we remove the parameter entirely and assert that the stack-top cx is in the compartment of the compilation scope. We then bubble this up through all the callers until we hit a caller that finds the scx via some means other than its parameter list. At these points, we push the scx, making it stack-top. This puts us in a good position to switch wholesale to the SafeJSContext in subsequent patches.
This commit is contained in:
Родитель
9f7ed59515
Коммит
0a32efbdf5
|
@ -41,16 +41,17 @@ nsXBLProtoImpl::InstallImplementation(nsXBLPrototypeBinding* aPrototypeBinding,
|
|||
|
||||
nsCOMPtr<nsIScriptContext> context = global->GetContext();
|
||||
if (!context) return NS_OK;
|
||||
JSContext* cx = context->GetNativeContext();
|
||||
AutoCxPusher pusher(cx);
|
||||
|
||||
// InitTarget objects gives us back the JS object that represents the bound element and the
|
||||
// class object in the bound document that represents the concrete version of this implementation.
|
||||
// This function also has the side effect of building up the prototype implementation if it has
|
||||
// not been built already.
|
||||
nsCOMPtr<nsIXPConnectJSObjectHolder> holder;
|
||||
JSAutoRequest ar(context->GetNativeContext());
|
||||
JS::Rooted<JSObject*> targetClassObject(context->GetNativeContext(), nullptr);
|
||||
JS::Rooted<JSObject*> targetClassObject(cx, nullptr);
|
||||
bool targetObjectIsNew = false;
|
||||
nsresult rv = InitTargetObjects(aPrototypeBinding, context,
|
||||
nsresult rv = InitTargetObjects(aPrototypeBinding,
|
||||
aBinding->GetBoundElement(),
|
||||
getter_AddRefs(holder), &targetClassObject,
|
||||
&targetObjectIsNew);
|
||||
|
@ -64,10 +65,8 @@ nsXBLProtoImpl::InstallImplementation(nsXBLPrototypeBinding* aPrototypeBinding,
|
|||
if (!targetObjectIsNew)
|
||||
return NS_OK;
|
||||
|
||||
JS::Rooted<JSObject*> targetScriptObject(context->GetNativeContext(),
|
||||
holder->GetJSObject());
|
||||
JS::Rooted<JSObject*> targetScriptObject(cx, holder->GetJSObject());
|
||||
|
||||
AutoPushJSContext cx(context->GetNativeContext());
|
||||
JSAutoCompartment ac(cx, targetClassObject);
|
||||
|
||||
// Walk our member list and install each one in turn.
|
||||
|
@ -125,7 +124,6 @@ nsXBLProtoImpl::InstallImplementation(nsXBLPrototypeBinding* aPrototypeBinding,
|
|||
|
||||
nsresult
|
||||
nsXBLProtoImpl::InitTargetObjects(nsXBLPrototypeBinding* aBinding,
|
||||
nsIScriptContext* aContext,
|
||||
nsIContent* aBoundElement,
|
||||
nsIXPConnectJSObjectHolder** aScriptObjectHolder,
|
||||
JS::MutableHandle<JSObject*> aTargetClassObject,
|
||||
|
@ -153,7 +151,7 @@ nsXBLProtoImpl::InitTargetObjects(nsXBLPrototypeBinding* aBinding,
|
|||
|
||||
// Because our prototype implementation has a class, we need to build up a corresponding
|
||||
// class for the concrete implementation in the bound document.
|
||||
AutoPushJSContext cx(aContext->GetNativeContext());
|
||||
AutoJSContext cx;
|
||||
JS::Rooted<JSObject*> global(cx, sgo->GetGlobalJSObject());
|
||||
nsCOMPtr<nsIXPConnectJSObjectHolder> wrapper;
|
||||
JS::Rooted<JS::Value> v(cx);
|
||||
|
@ -213,7 +211,7 @@ nsXBLProtoImpl::CompilePrototypeMembers(nsXBLPrototypeBinding* aBinding)
|
|||
for (nsXBLProtoImplMember* curr = mMembers;
|
||||
curr;
|
||||
curr = curr->GetNext()) {
|
||||
nsresult rv = curr->CompileMember(context, mClassName, classObject);
|
||||
nsresult rv = curr->CompileMember(mClassName, classObject);
|
||||
if (NS_FAILED(rv)) {
|
||||
DestroyMembers();
|
||||
return rv;
|
||||
|
@ -321,13 +319,13 @@ nsXBLProtoImpl::DestroyMembers()
|
|||
}
|
||||
|
||||
nsresult
|
||||
nsXBLProtoImpl::Read(nsIScriptContext* aContext,
|
||||
nsIObjectInputStream* aStream,
|
||||
nsXBLProtoImpl::Read(nsIObjectInputStream* aStream,
|
||||
nsXBLPrototypeBinding* aBinding,
|
||||
nsIScriptGlobalObject* aGlobal)
|
||||
{
|
||||
AssertInCompilationScope();
|
||||
AutoJSContext cx;
|
||||
// Set up a class object first so that deserialization is possible
|
||||
AutoPushJSContext cx(aContext->GetNativeContext());
|
||||
JS::Rooted<JSObject*> global(cx, aGlobal->GetGlobalJSObject());
|
||||
|
||||
JS::Rooted<JSObject*> classObject(cx);
|
||||
|
@ -355,7 +353,7 @@ nsXBLProtoImpl::Read(nsIScriptContext* aContext,
|
|||
{
|
||||
nsXBLProtoImplField* field =
|
||||
new nsXBLProtoImplField(type & XBLBinding_Serialize_ReadOnly);
|
||||
rv = field->Read(aContext, aStream);
|
||||
rv = field->Read(aStream);
|
||||
if (NS_FAILED(rv)) {
|
||||
delete field;
|
||||
return rv;
|
||||
|
@ -381,7 +379,7 @@ nsXBLProtoImpl::Read(nsIScriptContext* aContext,
|
|||
|
||||
nsXBLProtoImplProperty* prop =
|
||||
new nsXBLProtoImplProperty(name.get(), type & XBLBinding_Serialize_ReadOnly);
|
||||
rv = prop->Read(aContext, aStream, type & XBLBinding_Serialize_Mask);
|
||||
rv = prop->Read(aStream, type & XBLBinding_Serialize_Mask);
|
||||
if (NS_FAILED(rv)) {
|
||||
delete prop;
|
||||
return rv;
|
||||
|
@ -397,7 +395,7 @@ nsXBLProtoImpl::Read(nsIScriptContext* aContext,
|
|||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
nsXBLProtoImplMethod* method = new nsXBLProtoImplMethod(name.get());
|
||||
rv = method->Read(aContext, aStream);
|
||||
rv = method->Read(aStream);
|
||||
if (NS_FAILED(rv)) {
|
||||
delete method;
|
||||
return rv;
|
||||
|
@ -409,7 +407,7 @@ nsXBLProtoImpl::Read(nsIScriptContext* aContext,
|
|||
case XBLBinding_Serialize_Constructor:
|
||||
{
|
||||
mConstructor = new nsXBLProtoImplAnonymousMethod();
|
||||
rv = mConstructor->Read(aContext, aStream);
|
||||
rv = mConstructor->Read(aStream);
|
||||
if (NS_FAILED(rv)) {
|
||||
delete mConstructor;
|
||||
mConstructor = nullptr;
|
||||
|
@ -422,7 +420,7 @@ nsXBLProtoImpl::Read(nsIScriptContext* aContext,
|
|||
case XBLBinding_Serialize_Destructor:
|
||||
{
|
||||
mDestructor = new nsXBLProtoImplAnonymousMethod();
|
||||
rv = mDestructor->Read(aContext, aStream);
|
||||
rv = mDestructor->Read(aStream);
|
||||
if (NS_FAILED(rv)) {
|
||||
delete mDestructor;
|
||||
mDestructor = nullptr;
|
||||
|
@ -442,8 +440,7 @@ nsXBLProtoImpl::Read(nsIScriptContext* aContext,
|
|||
}
|
||||
|
||||
nsresult
|
||||
nsXBLProtoImpl::Write(nsIScriptContext* aContext,
|
||||
nsIObjectOutputStream* aStream,
|
||||
nsXBLProtoImpl::Write(nsIObjectOutputStream* aStream,
|
||||
nsXBLPrototypeBinding* aBinding)
|
||||
{
|
||||
nsresult rv;
|
||||
|
@ -457,18 +454,18 @@ nsXBLProtoImpl::Write(nsIScriptContext* aContext,
|
|||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
for (nsXBLProtoImplField* curr = mFields; curr; curr = curr->GetNext()) {
|
||||
rv = curr->Write(aContext, aStream);
|
||||
rv = curr->Write(aStream);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
}
|
||||
for (nsXBLProtoImplMember* curr = mMembers; curr; curr = curr->GetNext()) {
|
||||
if (curr == mConstructor) {
|
||||
rv = mConstructor->Write(aContext, aStream, XBLBinding_Serialize_Constructor);
|
||||
rv = mConstructor->Write(aStream, XBLBinding_Serialize_Constructor);
|
||||
}
|
||||
else if (curr == mDestructor) {
|
||||
rv = mDestructor->Write(aContext, aStream, XBLBinding_Serialize_Destructor);
|
||||
rv = mDestructor->Write(aStream, XBLBinding_Serialize_Destructor);
|
||||
}
|
||||
else {
|
||||
rv = curr->Write(aContext, aStream);
|
||||
rv = curr->Write(aStream);
|
||||
}
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
}
|
||||
|
|
|
@ -38,7 +38,7 @@ public:
|
|||
}
|
||||
|
||||
nsresult InstallImplementation(nsXBLPrototypeBinding* aPrototypeBinding, nsXBLBinding* aBinding);
|
||||
nsresult InitTargetObjects(nsXBLPrototypeBinding* aBinding, nsIScriptContext* aContext,
|
||||
nsresult InitTargetObjects(nsXBLPrototypeBinding* aBinding,
|
||||
nsIContent* aBoundElement,
|
||||
nsIXPConnectJSObjectHolder** aScriptObjectHolder,
|
||||
JS::MutableHandle<JSObject*> aTargetClassObject,
|
||||
|
@ -77,12 +77,10 @@ public:
|
|||
return mClassObject != nullptr;
|
||||
}
|
||||
|
||||
nsresult Read(nsIScriptContext* aContext,
|
||||
nsIObjectInputStream* aStream,
|
||||
nsresult Read(nsIObjectInputStream* aStream,
|
||||
nsXBLPrototypeBinding* aBinding,
|
||||
nsIScriptGlobalObject* aGlobal);
|
||||
nsresult Write(nsIScriptContext* aContext,
|
||||
nsIObjectOutputStream* aStream,
|
||||
nsresult Write(nsIObjectOutputStream* aStream,
|
||||
nsXBLPrototypeBinding* aBinding);
|
||||
|
||||
protected:
|
||||
|
|
|
@ -407,9 +407,6 @@ nsXBLProtoImplField::InstallField(nsIScriptContext* aContext,
|
|||
NS_ASSERTION(!::JS_IsExceptionPending(cx),
|
||||
"Shouldn't get here when an exception is pending!");
|
||||
|
||||
// compile the literal string
|
||||
nsCOMPtr<nsIScriptContext> context = aContext;
|
||||
|
||||
// First, enter the xbl scope, wrap the node, and use that as the scope for
|
||||
// the evaluation.
|
||||
JS::Rooted<JSObject*> scopeObject(cx, xpc::GetXBLScope(cx, aBoundNode));
|
||||
|
@ -424,11 +421,11 @@ nsXBLProtoImplField::InstallField(nsIScriptContext* aContext,
|
|||
JS::CompileOptions options(cx);
|
||||
options.setFileAndLine(uriSpec.get(), mLineNumber)
|
||||
.setVersion(JSVERSION_LATEST);
|
||||
rv = context->EvaluateString(nsDependentString(mFieldText,
|
||||
mFieldTextLength),
|
||||
wrappedNode, options,
|
||||
/* aCoerceToString = */ false,
|
||||
result.address());
|
||||
rv = aContext->EvaluateString(nsDependentString(mFieldText,
|
||||
mFieldTextLength),
|
||||
wrappedNode, options,
|
||||
/* aCoerceToString = */ false,
|
||||
result.address());
|
||||
if (NS_FAILED(rv)) {
|
||||
return rv;
|
||||
}
|
||||
|
@ -451,8 +448,7 @@ nsXBLProtoImplField::InstallField(nsIScriptContext* aContext,
|
|||
}
|
||||
|
||||
nsresult
|
||||
nsXBLProtoImplField::Read(nsIScriptContext* aContext,
|
||||
nsIObjectInputStream* aStream)
|
||||
nsXBLProtoImplField::Read(nsIObjectInputStream* aStream)
|
||||
{
|
||||
nsAutoString name;
|
||||
nsresult rv = aStream->ReadString(name);
|
||||
|
@ -473,8 +469,7 @@ nsXBLProtoImplField::Read(nsIScriptContext* aContext,
|
|||
}
|
||||
|
||||
nsresult
|
||||
nsXBLProtoImplField::Write(nsIScriptContext* aContext,
|
||||
nsIObjectOutputStream* aStream)
|
||||
nsXBLProtoImplField::Write(nsIObjectOutputStream* aStream)
|
||||
{
|
||||
XBLBindingSerializeDetails type = XBLBinding_Serialize_Field;
|
||||
|
||||
|
|
|
@ -39,8 +39,8 @@ public:
|
|||
nsresult InstallAccessors(JSContext* aCx,
|
||||
JS::Handle<JSObject*> aTargetClassObject);
|
||||
|
||||
nsresult Read(nsIScriptContext* aContext, nsIObjectInputStream* aStream);
|
||||
nsresult Write(nsIScriptContext* aContext, nsIObjectOutputStream* aStream);
|
||||
nsresult Read(nsIObjectInputStream* aStream);
|
||||
nsresult Write(nsIObjectOutputStream* aStream);
|
||||
|
||||
const PRUnichar* GetName() const { return mName; }
|
||||
|
||||
|
|
|
@ -75,14 +75,12 @@ public:
|
|||
|
||||
virtual nsresult InstallMember(JSContext* aCx,
|
||||
JS::Handle<JSObject*> aTargetClassObject) = 0;
|
||||
virtual nsresult CompileMember(nsIScriptContext* aContext,
|
||||
const nsCString& aClassStr,
|
||||
virtual nsresult CompileMember(const nsCString& aClassStr,
|
||||
JS::Handle<JSObject*> aClassObject) = 0;
|
||||
|
||||
virtual void Trace(const TraceCallbacks& aCallbacks, void *aClosure) = 0;
|
||||
|
||||
virtual nsresult Write(nsIScriptContext* aContext,
|
||||
nsIObjectOutputStream* aStream)
|
||||
virtual nsresult Write(nsIObjectOutputStream* aStream)
|
||||
{
|
||||
return NS_OK;
|
||||
}
|
||||
|
|
|
@ -107,7 +107,6 @@ nsXBLProtoImplMethod::InstallMember(JSContext* aCx,
|
|||
JS::Rooted<JSObject*> scopeObject(aCx, xpc::GetXBLScope(aCx, globalObject));
|
||||
NS_ENSURE_TRUE(scopeObject, NS_ERROR_OUT_OF_MEMORY);
|
||||
|
||||
// now we want to reevaluate our property using aContext and the script object for this window...
|
||||
JS::Rooted<JSObject*> jsMethodObject(aCx, GetCompiledMethod());
|
||||
if (jsMethodObject) {
|
||||
nsDependentString name(mName);
|
||||
|
@ -137,9 +136,10 @@ nsXBLProtoImplMethod::InstallMember(JSContext* aCx,
|
|||
}
|
||||
|
||||
nsresult
|
||||
nsXBLProtoImplMethod::CompileMember(nsIScriptContext* aContext, const nsCString& aClassStr,
|
||||
nsXBLProtoImplMethod::CompileMember(const nsCString& aClassStr,
|
||||
JS::Handle<JSObject*> aClassObject)
|
||||
{
|
||||
AssertInCompilationScope();
|
||||
NS_PRECONDITION(!IsCompiled(),
|
||||
"Trying to compile an already-compiled method");
|
||||
NS_PRECONDITION(aClassObject,
|
||||
|
@ -199,7 +199,7 @@ nsXBLProtoImplMethod::CompileMember(nsIScriptContext* aContext, const nsCString&
|
|||
functionUri.Truncate(hash);
|
||||
}
|
||||
|
||||
AutoPushJSContext cx(aContext->GetNativeContext());
|
||||
AutoJSContext cx;
|
||||
JSAutoCompartment ac(cx, aClassObject);
|
||||
JS::CompileOptions options(cx);
|
||||
options.setFileAndLine(functionUri.get(),
|
||||
|
@ -234,12 +234,12 @@ nsXBLProtoImplMethod::Trace(const TraceCallbacks& aCallbacks, void *aClosure)
|
|||
}
|
||||
|
||||
nsresult
|
||||
nsXBLProtoImplMethod::Read(nsIScriptContext* aContext,
|
||||
nsIObjectInputStream* aStream)
|
||||
nsXBLProtoImplMethod::Read(nsIObjectInputStream* aStream)
|
||||
{
|
||||
AssertInCompilationScope();
|
||||
MOZ_ASSERT(!IsCompiled() && !GetUncompiledMethod());
|
||||
|
||||
AutoPushJSContext cx(aContext->GetNativeContext());
|
||||
AutoJSContext cx;
|
||||
JS::Rooted<JSObject*> methodObject(cx);
|
||||
nsresult rv = XBL_DeserializeFunction(aStream, &methodObject);
|
||||
if (NS_FAILED(rv)) {
|
||||
|
@ -253,12 +253,11 @@ nsXBLProtoImplMethod::Read(nsIScriptContext* aContext,
|
|||
}
|
||||
|
||||
nsresult
|
||||
nsXBLProtoImplMethod::Write(nsIScriptContext* aContext,
|
||||
nsIObjectOutputStream* aStream)
|
||||
nsXBLProtoImplMethod::Write(nsIObjectOutputStream* aStream)
|
||||
{
|
||||
AssertInCompilationScope();
|
||||
MOZ_ASSERT(IsCompiled());
|
||||
if (GetCompiledMethod()) {
|
||||
AutoPushJSContext cx(aContext->GetNativeContext());
|
||||
nsresult rv = aStream->Write8(XBLBinding_Serialize_Method);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
|
@ -364,13 +363,12 @@ nsXBLProtoImplAnonymousMethod::Execute(nsIContent* aBoundElement)
|
|||
}
|
||||
|
||||
nsresult
|
||||
nsXBLProtoImplAnonymousMethod::Write(nsIScriptContext* aContext,
|
||||
nsIObjectOutputStream* aStream,
|
||||
nsXBLProtoImplAnonymousMethod::Write(nsIObjectOutputStream* aStream,
|
||||
XBLBindingSerializeDetails aType)
|
||||
{
|
||||
AssertInCompilationScope();
|
||||
MOZ_ASSERT(IsCompiled());
|
||||
if (GetCompiledMethod()) {
|
||||
AutoPushJSContext cx(aContext->GetNativeContext());
|
||||
nsresult rv = aStream->Write8(aType);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
|
|
|
@ -92,14 +92,13 @@ public:
|
|||
|
||||
virtual nsresult InstallMember(JSContext* aCx,
|
||||
JS::Handle<JSObject*> aTargetClassObject) MOZ_OVERRIDE;
|
||||
virtual nsresult CompileMember(nsIScriptContext* aContext,
|
||||
const nsCString& aClassStr,
|
||||
virtual nsresult CompileMember(const nsCString& aClassStr,
|
||||
JS::Handle<JSObject*> aClassObject) MOZ_OVERRIDE;
|
||||
|
||||
virtual void Trace(const TraceCallbacks& aCallbacks, void *aClosure) MOZ_OVERRIDE;
|
||||
|
||||
nsresult Read(nsIScriptContext* aContext, nsIObjectInputStream* aStream);
|
||||
virtual nsresult Write(nsIScriptContext* aContext, nsIObjectOutputStream* aStream) MOZ_OVERRIDE;
|
||||
nsresult Read(nsIObjectInputStream* aStream);
|
||||
virtual nsresult Write(nsIObjectOutputStream* aStream) MOZ_OVERRIDE;
|
||||
|
||||
bool IsCompiled() const
|
||||
{
|
||||
|
@ -147,8 +146,7 @@ public:
|
|||
}
|
||||
|
||||
using nsXBLProtoImplMethod::Write;
|
||||
nsresult Write(nsIScriptContext* aContext,
|
||||
nsIObjectOutputStream* aStream,
|
||||
nsresult Write(nsIObjectOutputStream* aStream,
|
||||
XBLBindingSerializeDetails aType);
|
||||
};
|
||||
|
||||
|
|
|
@ -135,7 +135,6 @@ nsXBLProtoImplProperty::InstallMember(JSContext *aCx,
|
|||
JS::Rooted<JSObject*> scopeObject(aCx, xpc::GetXBLScope(aCx, globalObject));
|
||||
NS_ENSURE_TRUE(scopeObject, NS_ERROR_OUT_OF_MEMORY);
|
||||
|
||||
// now we want to reevaluate our property using aContext and the script object for this window...
|
||||
if (mGetter.GetJSFunction() || mSetter.GetJSFunction()) {
|
||||
// First, enter the compartment of the scope object and clone the functions.
|
||||
JSAutoCompartment ac(aCx, scopeObject);
|
||||
|
@ -170,9 +169,10 @@ nsXBLProtoImplProperty::InstallMember(JSContext *aCx,
|
|||
}
|
||||
|
||||
nsresult
|
||||
nsXBLProtoImplProperty::CompileMember(nsIScriptContext* aContext, const nsCString& aClassStr,
|
||||
nsXBLProtoImplProperty::CompileMember(const nsCString& aClassStr,
|
||||
JS::Handle<JSObject*> aClassObject)
|
||||
{
|
||||
AssertInCompilationScope();
|
||||
NS_PRECONDITION(!mIsCompiled,
|
||||
"Trying to compile an already-compiled property");
|
||||
NS_PRECONDITION(aClassObject,
|
||||
|
@ -199,7 +199,7 @@ nsXBLProtoImplProperty::CompileMember(nsIScriptContext* aContext, const nsCStrin
|
|||
if (getterText && getterText->GetText()) {
|
||||
nsDependentString getter(getterText->GetText());
|
||||
if (!getter.IsEmpty()) {
|
||||
AutoPushJSContext cx(aContext->GetNativeContext());
|
||||
AutoJSContext cx;
|
||||
JSAutoCompartment ac(cx, aClassObject);
|
||||
JS::CompileOptions options(cx);
|
||||
options.setFileAndLine(functionUri.get(), getterText->GetLineNumber())
|
||||
|
@ -246,7 +246,7 @@ nsXBLProtoImplProperty::CompileMember(nsIScriptContext* aContext, const nsCStrin
|
|||
if (setterText && setterText->GetText()) {
|
||||
nsDependentString setter(setterText->GetText());
|
||||
if (!setter.IsEmpty()) {
|
||||
AutoPushJSContext cx(aContext->GetNativeContext());
|
||||
AutoJSContext cx;
|
||||
JSAutoCompartment ac(cx, aClassObject);
|
||||
JS::CompileOptions options(cx);
|
||||
options.setFileAndLine(functionUri.get(), setterText->GetLineNumber())
|
||||
|
@ -297,15 +297,14 @@ nsXBLProtoImplProperty::Trace(const TraceCallbacks& aCallbacks, void *aClosure)
|
|||
}
|
||||
|
||||
nsresult
|
||||
nsXBLProtoImplProperty::Read(nsIScriptContext* aContext,
|
||||
nsIObjectInputStream* aStream,
|
||||
nsXBLProtoImplProperty::Read(nsIObjectInputStream* aStream,
|
||||
XBLBindingSerializeDetails aType)
|
||||
{
|
||||
AssertInCompilationScope();
|
||||
MOZ_ASSERT(!mIsCompiled);
|
||||
MOZ_ASSERT(!mGetter.GetUncompiled() && !mSetter.GetUncompiled());
|
||||
|
||||
AutoPushJSContext cx(aContext->GetNativeContext());
|
||||
|
||||
AutoJSContext cx;
|
||||
JS::Rooted<JSObject*> getterObject(cx);
|
||||
if (aType == XBLBinding_Serialize_GetterProperty ||
|
||||
aType == XBLBinding_Serialize_GetterSetterProperty) {
|
||||
|
@ -334,11 +333,10 @@ nsXBLProtoImplProperty::Read(nsIScriptContext* aContext,
|
|||
}
|
||||
|
||||
nsresult
|
||||
nsXBLProtoImplProperty::Write(nsIScriptContext* aContext,
|
||||
nsIObjectOutputStream* aStream)
|
||||
nsXBLProtoImplProperty::Write(nsIObjectOutputStream* aStream)
|
||||
{
|
||||
AssertInCompilationScope();
|
||||
XBLBindingSerializeDetails type;
|
||||
AutoPushJSContext cx(aContext->GetNativeContext());
|
||||
|
||||
if (mJSAttributes & JSPROP_GETTER) {
|
||||
type = mJSAttributes & JSPROP_SETTER ?
|
||||
|
|
|
@ -36,17 +36,14 @@ public:
|
|||
|
||||
virtual nsresult InstallMember(JSContext* aCx,
|
||||
JS::Handle<JSObject*> aTargetClassObject) MOZ_OVERRIDE;
|
||||
virtual nsresult CompileMember(nsIScriptContext* aContext,
|
||||
const nsCString& aClassStr,
|
||||
virtual nsresult CompileMember(const nsCString& aClassStr,
|
||||
JS::Handle<JSObject*> aClassObject) MOZ_OVERRIDE;
|
||||
|
||||
virtual void Trace(const TraceCallbacks& aCallback, void *aClosure) MOZ_OVERRIDE;
|
||||
|
||||
nsresult Read(nsIScriptContext* aContext,
|
||||
nsIObjectInputStream* aStream,
|
||||
nsresult Read(nsIObjectInputStream* aStream,
|
||||
XBLBindingSerializeDetails aType);
|
||||
virtual nsresult Write(nsIScriptContext* aContext,
|
||||
nsIObjectOutputStream* aStream) MOZ_OVERRIDE;
|
||||
virtual nsresult Write(nsIObjectOutputStream* aStream) MOZ_OVERRIDE;
|
||||
|
||||
protected:
|
||||
typedef JS::Heap<nsXBLMaybeCompiled<nsXBLTextWithLineNumber> > PropertyOp;
|
||||
|
|
|
@ -951,7 +951,8 @@ nsXBLPrototypeBinding::Read(nsIObjectInputStream* aStream,
|
|||
NS_ENSURE_TRUE(globalObject, NS_ERROR_UNEXPECTED);
|
||||
|
||||
nsIScriptContext *context = globalObject->GetContext();
|
||||
NS_ENSURE_TRUE(context, NS_ERROR_FAILURE);
|
||||
NS_ENSURE_TRUE(context && context->GetNativeContext(), NS_ERROR_FAILURE);
|
||||
AutoCxPusher pusher(context->GetNativeContext());
|
||||
|
||||
bool isFirstBinding = aFlags & XBLBinding_Serialize_IsFirstBinding;
|
||||
rv = Init(id, aDocInfo, nullptr, isFirstBinding);
|
||||
|
@ -976,7 +977,7 @@ nsXBLPrototypeBinding::Read(nsIObjectInputStream* aStream,
|
|||
// retrieve the mapped bindings from within here. However, if an error
|
||||
// occurs, the mapping should be removed again so that we don't keep an
|
||||
// invalid binding around.
|
||||
rv = mImplementation->Read(context, aStream, this, globalObject);
|
||||
rv = mImplementation->Read(aStream, this, globalObject);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
}
|
||||
|
||||
|
@ -995,7 +996,7 @@ nsXBLPrototypeBinding::Read(nsIObjectInputStream* aStream,
|
|||
"invalid handler type");
|
||||
|
||||
nsXBLPrototypeHandler* handler = new nsXBLPrototypeHandler(this);
|
||||
rv = handler->Read(context, aStream);
|
||||
rv = handler->Read(aStream);
|
||||
if (NS_FAILED(rv)) {
|
||||
delete handler;
|
||||
return rv;
|
||||
|
@ -1059,7 +1060,8 @@ nsXBLPrototypeBinding::Write(nsIObjectOutputStream* aStream)
|
|||
NS_ENSURE_TRUE(globalObject, NS_ERROR_UNEXPECTED);
|
||||
|
||||
nsIScriptContext *context = globalObject->GetContext();
|
||||
NS_ENSURE_TRUE(context, NS_ERROR_FAILURE);
|
||||
NS_ENSURE_TRUE(context && context->GetNativeContext(), NS_ERROR_FAILURE);
|
||||
AutoCxPusher pusher(context->GetNativeContext());
|
||||
|
||||
uint8_t flags = mInheritStyle ? XBLBinding_Serialize_InheritStyle : 0;
|
||||
|
||||
|
@ -1118,7 +1120,7 @@ nsXBLPrototypeBinding::Write(nsIObjectOutputStream* aStream)
|
|||
|
||||
// Write out the implementation details.
|
||||
if (mImplementation) {
|
||||
rv = mImplementation->Write(context, aStream, this);
|
||||
rv = mImplementation->Write(aStream, this);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
}
|
||||
else {
|
||||
|
@ -1131,7 +1133,7 @@ nsXBLPrototypeBinding::Write(nsIObjectOutputStream* aStream)
|
|||
// Write out the handlers.
|
||||
nsXBLPrototypeHandler* handler = mPrototypeHandler;
|
||||
while (handler) {
|
||||
rv = handler->Write(context, aStream);
|
||||
rv = handler->Write(aStream);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
handler = handler->GetNextHandler();
|
||||
|
|
|
@ -951,8 +951,9 @@ nsXBLPrototypeHandler::ModifiersMatchMask(nsIDOMUIEvent* aEvent,
|
|||
}
|
||||
|
||||
nsresult
|
||||
nsXBLPrototypeHandler::Read(nsIScriptContext* aContext, nsIObjectInputStream* aStream)
|
||||
nsXBLPrototypeHandler::Read(nsIObjectInputStream* aStream)
|
||||
{
|
||||
AssertInCompilationScope();
|
||||
nsresult rv = aStream->Read8(&mPhase);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
rv = aStream->Read8(&mType);
|
||||
|
@ -985,8 +986,9 @@ nsXBLPrototypeHandler::Read(nsIScriptContext* aContext, nsIObjectInputStream* aS
|
|||
}
|
||||
|
||||
nsresult
|
||||
nsXBLPrototypeHandler::Write(nsIScriptContext* aContext, nsIObjectOutputStream* aStream)
|
||||
nsXBLPrototypeHandler::Write(nsIObjectOutputStream* aStream)
|
||||
{
|
||||
AssertInCompilationScope();
|
||||
// Make sure we don't write out NS_HANDLER_TYPE_XUL types, as they are used
|
||||
// for <keyset> elements.
|
||||
if ((mType & NS_HANDLER_TYPE_XUL) || !mEventName)
|
||||
|
|
|
@ -136,8 +136,8 @@ public:
|
|||
return (mType & NS_HANDLER_ALLOW_UNTRUSTED) != 0;
|
||||
}
|
||||
|
||||
nsresult Read(nsIScriptContext* aContext, nsIObjectInputStream* aStream);
|
||||
nsresult Write(nsIScriptContext* aContext, nsIObjectOutputStream* aStream);
|
||||
nsresult Read(nsIObjectInputStream* aStream);
|
||||
nsresult Write(nsIObjectOutputStream* aStream);
|
||||
|
||||
public:
|
||||
static uint32_t gRefCnt;
|
||||
|
|
Загрузка…
Ссылка в новой задаче