зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1157898 part 5. Eliminate the remaining non-ErrorResult consumers of ErrorResult::ErrorCode and make it protected. r=peterv
This commit is contained in:
Родитель
1e816696de
Коммит
d36060dc11
|
@ -3525,7 +3525,7 @@ NS_IMETHODIMP
|
|||
nsGlobalWindow::GetWindow(nsIDOMWindow** aWindow)
|
||||
{
|
||||
ErrorResult rv;
|
||||
FORWARD_TO_OUTER_OR_THROW(GetWindow, (aWindow), rv, rv.ErrorCode());
|
||||
FORWARD_TO_OUTER_OR_THROW(GetWindow, (aWindow), rv, rv.StealNSResult());
|
||||
|
||||
nsCOMPtr<nsIDOMWindow> window = Window();
|
||||
window.forget(aWindow);
|
||||
|
|
|
@ -339,6 +339,14 @@ ErrorResult::ReportNotEnoughArgsError(JSContext* cx,
|
|||
ThrowErrorMessage(cx, dom::MSG_MISSING_ARGUMENTS, errorMessage.get());
|
||||
}
|
||||
|
||||
void
|
||||
ErrorResult::ReportGenericError(JSContext* cx)
|
||||
{
|
||||
MOZ_ASSERT(!IsErrorWithMessage());
|
||||
MOZ_ASSERT(!IsJSException());
|
||||
dom::Throw(cx, ErrorCode());
|
||||
}
|
||||
|
||||
ErrorResult&
|
||||
ErrorResult::operator=(ErrorResult&& aRHS)
|
||||
{
|
||||
|
|
|
@ -127,7 +127,8 @@ ThrowMethodFailedWithDetails(JSContext* cx, ErrorResult& rv,
|
|||
rv.ReportNotEnoughArgsError(cx, ifaceName, memberName);
|
||||
return false;
|
||||
}
|
||||
return Throw(cx, rv.ErrorCode());
|
||||
rv.ReportGenericError(cx);
|
||||
return false;
|
||||
}
|
||||
|
||||
// Returns true if the JSClass is used for DOM objects.
|
||||
|
|
|
@ -119,6 +119,10 @@ public:
|
|||
const char* memberName);
|
||||
bool IsNotEnoughArgsError() const { return ErrorCode() == NS_ERROR_XPC_NOT_ENOUGH_ARGS; }
|
||||
|
||||
// Report a generic error. This should only be used if we're not
|
||||
// some more specific exception type.
|
||||
void ReportGenericError(JSContext* cx);
|
||||
|
||||
// Support for uncatchable exceptions.
|
||||
void ThrowUncatchableException() {
|
||||
Throw(NS_ERROR_UNCATCHABLE_EXCEPTION);
|
||||
|
@ -160,14 +164,20 @@ public:
|
|||
return NS_FAILED(mResult);
|
||||
}
|
||||
|
||||
nsresult ErrorCode() const {
|
||||
return mResult;
|
||||
}
|
||||
|
||||
bool ErrorCodeIs(nsresult rv) const {
|
||||
return mResult == rv;
|
||||
}
|
||||
|
||||
// For use in logging ONLY.
|
||||
uint32_t ErrorCodeAsInt() const {
|
||||
return static_cast<uint32_t>(ErrorCode());
|
||||
}
|
||||
|
||||
protected:
|
||||
nsresult ErrorCode() const {
|
||||
return mResult;
|
||||
}
|
||||
|
||||
private:
|
||||
friend struct IPC::ParamTraits<ErrorResult>;
|
||||
void SerializeMessage(IPC::Message* aMsg) const;
|
||||
|
@ -225,7 +235,7 @@ private:
|
|||
if (res.Failed()) { \
|
||||
nsCString msg; \
|
||||
msg.AppendPrintf("ENSURE_SUCCESS(%s, %s) failed with " \
|
||||
"result 0x%X", #res, #ret, res.ErrorCode()); \
|
||||
"result 0x%X", #res, #ret, res.ErrorCodeAsInt()); \
|
||||
NS_WARNING(msg.get()); \
|
||||
return ret; \
|
||||
} \
|
||||
|
@ -236,7 +246,7 @@ private:
|
|||
if (res.Failed()) { \
|
||||
nsCString msg; \
|
||||
msg.AppendPrintf("ENSURE_SUCCESS_VOID(%s) failed with " \
|
||||
"result 0x%X", #res, res.ErrorCode()); \
|
||||
"result 0x%X", #res, res.ErrorCodeAsInt()); \
|
||||
NS_WARNING(msg.get()); \
|
||||
return; \
|
||||
} \
|
||||
|
|
|
@ -960,7 +960,7 @@ EventListenerManager::HandleEventSubType(Listener* aListener,
|
|||
ErrorResult rv;
|
||||
listenerHolder.GetWebIDLCallback()->
|
||||
HandleEvent(aCurrentTarget, *(aDOMEvent->InternalDOMEvent()), rv);
|
||||
result = rv.ErrorCode();
|
||||
result = rv.StealNSResult();
|
||||
} else {
|
||||
result = listenerHolder.GetXPCOMCallback()->HandleEvent(aDOMEvent);
|
||||
}
|
||||
|
|
|
@ -286,7 +286,7 @@ HTMLCanvasElement::CopyInnerTo(Element* aDest)
|
|||
ErrorResult err;
|
||||
context2d->DrawImage(element,
|
||||
0.0, 0.0, err);
|
||||
rv = err.ErrorCode();
|
||||
rv = err.StealNSResult();
|
||||
}
|
||||
}
|
||||
return rv;
|
||||
|
|
|
@ -176,7 +176,7 @@ HTMLOptionsCollection::SetOption(uint32_t aIndex,
|
|||
nsCOMPtr<nsINode> node = do_QueryInterface(aOption);
|
||||
ErrorResult res;
|
||||
parent->ReplaceChild(*node, *refChild, res);
|
||||
rv = res.ErrorCode();
|
||||
rv = res.StealNSResult();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -109,7 +109,7 @@ public:
|
|||
{
|
||||
RemoveItem(aKey, aRv);
|
||||
|
||||
aFound = (aRv.ErrorCode() != NS_SUCCESS_DOM_NO_OPERATION);
|
||||
aFound = !aRv.ErrorCodeIs(NS_SUCCESS_DOM_NO_OPERATION);
|
||||
}
|
||||
|
||||
void Clear(ErrorResult& aRv);
|
||||
|
|
|
@ -815,8 +815,9 @@ private:
|
|||
nsRefPtr<Promise> cachePromise =
|
||||
mCacheCreator->Cache_()->Put(request, *response, error);
|
||||
if (NS_WARN_IF(error.Failed())) {
|
||||
channel->Cancel(error.ErrorCode());
|
||||
return error.StealNSResult();
|
||||
nsresult rv = error.StealNSResult();
|
||||
channel->Cancel(rv);
|
||||
return rv;
|
||||
}
|
||||
|
||||
nsRefPtr<CachePromiseHandler> promiseHandler =
|
||||
|
@ -1322,7 +1323,7 @@ CacheScriptLoader::Load(Cache* aCache)
|
|||
ErrorResult error;
|
||||
nsRefPtr<Promise> promise = aCache->Match(request, params, error);
|
||||
if (NS_WARN_IF(error.Failed())) {
|
||||
Fail(error.ErrorCode());
|
||||
Fail(error.StealNSResult());
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
@ -528,7 +528,7 @@ CompareCache::ManageCacheResult(JSContext* aCx, JS::Handle<JS::Value> aValue)
|
|||
CacheQueryOptions params;
|
||||
nsRefPtr<Promise> promise = cache->Match(request, params, error);
|
||||
if (NS_WARN_IF(error.Failed())) {
|
||||
mManager->CacheFinished(error.ErrorCode(), false);
|
||||
mManager->CacheFinished(error.StealNSResult(), false);
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
@ -145,7 +145,7 @@ ServiceWorkerWindowClient::Focus(ErrorResult& aRv) const
|
|||
promiseProxy);
|
||||
aRv = NS_DispatchToMainThread(r);
|
||||
if (NS_WARN_IF(aRv.Failed())) {
|
||||
promise->MaybeReject(aRv.ErrorCode());
|
||||
promise->MaybeReject(aRv);
|
||||
}
|
||||
|
||||
return promise.forget();
|
||||
|
|
|
@ -1495,8 +1495,7 @@ nsXULElement::GetControllers(ErrorResult& rv)
|
|||
rv = NS_NewXULControllers(nullptr, NS_GET_IID(nsIControllers),
|
||||
reinterpret_cast<void**>(&slots->mControllers));
|
||||
|
||||
NS_ASSERTION(NS_SUCCEEDED(rv.ErrorCode()),
|
||||
"unable to create a controllers");
|
||||
NS_ASSERTION(!rv.Failed(), "unable to create a controllers");
|
||||
if (rv.Failed()) {
|
||||
return nullptr;
|
||||
}
|
||||
|
|
|
@ -1445,10 +1445,14 @@ nsEditor::SplitNode(nsIContent& aNode, int32_t aOffset, ErrorResult& aResult)
|
|||
|
||||
mRangeUpdater.SelAdjSplitNode(aNode, aOffset, newNode);
|
||||
|
||||
nsresult result = aResult.StealNSResult();
|
||||
for (auto& listener : mActionListeners) {
|
||||
listener->DidSplitNode(aNode.AsDOMNode(), aOffset, GetAsDOMNode(newNode),
|
||||
aResult.ErrorCode());
|
||||
result);
|
||||
}
|
||||
// Note: result might be a success code, so we can't use Throw() to
|
||||
// set it on aResult.
|
||||
aResult = result;
|
||||
|
||||
return newNode;
|
||||
}
|
||||
|
|
|
@ -1209,7 +1209,7 @@ nsHTMLEditor::ReplaceHeadContentsWithHTML(const nsAString& aSourceToInsert)
|
|||
if (err.Failed()) {
|
||||
#ifdef DEBUG
|
||||
printf("Couldn't create contextual fragment: error was %X\n",
|
||||
static_cast<uint32_t>(err.ErrorCode()));
|
||||
err.ErrorCodeAsInt());
|
||||
#endif
|
||||
return err.StealNSResult();
|
||||
}
|
||||
|
|
|
@ -1512,7 +1512,7 @@ nsresult mozInlineSpellChecker::DoSpellCheck(mozInlineSpellWordUtil& aWordUtil,
|
|||
aSpellCheckSelection->GetRangesForInterval(*beginNode, beginOffset,
|
||||
*endNode, endOffset,
|
||||
true, ranges, erv);
|
||||
ENSURE_SUCCESS(erv, erv.ErrorCode());
|
||||
ENSURE_SUCCESS(erv, erv.StealNSResult());
|
||||
for (uint32_t i = 0; i < ranges.Length(); i++)
|
||||
RemoveRange(aSpellCheckSelection, ranges[i]);
|
||||
}
|
||||
|
|
|
@ -136,13 +136,7 @@ public:
|
|||
~JSErrorResult()
|
||||
{
|
||||
#if !defined(MOZILLA_EXTERNAL_LINKAGE)
|
||||
WouldReportJSException();
|
||||
if (IsJSException()) {
|
||||
MOZ_ASSERT(NS_IsMainThread());
|
||||
AutoJSContext cx;
|
||||
Optional<JS::Handle<JS::Value> > value(cx);
|
||||
StealJSException(cx, &value.Value());
|
||||
}
|
||||
SuppressException();
|
||||
#endif
|
||||
}
|
||||
};
|
||||
|
@ -237,7 +231,7 @@ public:
|
|||
if (jrv.Failed()) {
|
||||
CSFLogError(logTag, ": OnAddTrack(%u) failed! Error: %u",
|
||||
static_cast<unsigned>(i),
|
||||
static_cast<unsigned>(jrv.ErrorCode()));
|
||||
jrv.ErrorCodeAsInt());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -252,7 +246,7 @@ public:
|
|||
mObserver->OnAddStream(*aStream, rv);
|
||||
if (rv.Failed()) {
|
||||
CSFLogError(logTag, ": OnAddStream() failed! Error: %u",
|
||||
static_cast<unsigned>(rv.ErrorCode()));
|
||||
rv.ErrorCodeAsInt());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче