Bug 1225219 Implement ErrorResult::CloneTo(). r=bz

This commit is contained in:
Ben Kelly 2015-11-18 08:50:28 -08:00
Родитель 830e8bb659
Коммит 442a013f24
2 изменённых файлов: 35 добавлений и 0 удалений

Просмотреть файл

@ -466,6 +466,36 @@ ErrorResult::operator=(ErrorResult&& aRHS)
return *this;
}
void
ErrorResult::CloneTo(ErrorResult& aRv) const
{
aRv.ClearUnionData();
aRv.mResult = mResult;
aRv.mMightHaveUnreportedJSException = mMightHaveUnreportedJSException;
if (IsErrorWithMessage()) {
#ifdef DEBUG
aRv.mUnionState = HasMessage;
#endif
aRv.mMessage = new Message();
aRv.mMessage->mArgs = mMessage->mArgs;
aRv.mMessage->mErrorNumber = mMessage->mErrorNumber;
} else if (IsDOMException()) {
#ifdef DEBUG
aRv.mUnionState = HasDOMExceptionInfo;
#endif
aRv.mDOMExceptionInfo = new DOMExceptionInfo(mDOMExceptionInfo->mRv,
mDOMExceptionInfo->mMessage);
} else if (IsJSException()) {
#ifdef DEBUG
aRv.mUnionState = HasJSException;
#endif
JSContext* cx = nsContentUtils::RootingCxForThread();
JS::Rooted<JS::Value> exception(cx, mJSException);
aRv.ThrowJSException(cx, exception);
}
}
void
ErrorResult::SuppressException()
{

Просмотреть файл

@ -115,6 +115,11 @@ public:
AssignErrorCode(rv);
}
// Duplicate our current state on the given ErrorResult object. Any existing
// errors or messages on the target will be suppressed before cloning. Our
// own error state remains unchanged.
void CloneTo(ErrorResult& aRv) const;
// Use SuppressException when you want to suppress any exception that might be
// on the ErrorResult. After this call, the ErrorResult will be back a "no
// exception thrown" state.