зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1516578 Part 4 - Improve handling when encoding/decoding execution points with no position, r=lsmyth.
--HG-- extra : rebase_source : 7de1af8761422eab9343d4807918aad5f5d615b6 extra : source : 9ddc5bc1e961af52dbd772f66559f3fe4199e572
This commit is contained in:
Родитель
9a98dc9db3
Коммит
e245026227
|
@ -153,16 +153,21 @@ static const char gPositionProperty[] = "position";
|
|||
|
||||
JSObject* ExecutionPoint::Encode(JSContext* aCx) const {
|
||||
RootedObject obj(aCx, JS_NewObject(aCx, nullptr));
|
||||
RootedObject position(aCx, mPosition.Encode(aCx));
|
||||
if (!obj || !position ||
|
||||
if (!obj ||
|
||||
!JS_DefineProperty(aCx, obj, gCheckpointProperty, (double)mCheckpoint,
|
||||
JSPROP_ENUMERATE) ||
|
||||
!JS_DefineProperty(aCx, obj, gProgressProperty, (double)mProgress,
|
||||
JSPROP_ENUMERATE) ||
|
||||
!JS_DefineProperty(aCx, obj, gPositionProperty, position,
|
||||
JSPROP_ENUMERATE)) {
|
||||
return nullptr;
|
||||
}
|
||||
if (HasPosition()) {
|
||||
RootedObject position(aCx, mPosition.Encode(aCx));
|
||||
if (!position ||
|
||||
!JS_DefineProperty(aCx, obj, gPositionProperty, position,
|
||||
JSPROP_ENUMERATE)) {
|
||||
return nullptr;
|
||||
}
|
||||
}
|
||||
return obj;
|
||||
}
|
||||
|
||||
|
@ -172,9 +177,15 @@ bool ExecutionPoint::Decode(JSContext* aCx, HandleObject aObject) {
|
|||
return false;
|
||||
}
|
||||
|
||||
RootedObject positionObject(aCx, NonNullObject(aCx, v));
|
||||
return positionObject && mPosition.Decode(aCx, positionObject) &&
|
||||
GetNumberProperty(aCx, aObject, gCheckpointProperty, &mCheckpoint) &&
|
||||
if (v.isUndefined()) {
|
||||
MOZ_RELEASE_ASSERT(!HasPosition());
|
||||
} else {
|
||||
RootedObject positionObject(aCx, NonNullObject(aCx, v));
|
||||
if (!positionObject || !mPosition.Decode(aCx, positionObject)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return GetNumberProperty(aCx, aObject, gCheckpointProperty, &mCheckpoint) &&
|
||||
GetNumberProperty(aCx, aObject, gProgressProperty, &mProgress);
|
||||
}
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче