Bug 1157898 part 3. Fix the remaining consumers of rv.ErrorCode() in NS_ENSURE_* expressions to not do that. r=peterv

This commit is contained in:
Boris Zbarsky 2015-04-27 09:18:52 -04:00
parent b61068714a
commit b29b29a61d
6 changed files with 18 additions and 9 deletions

View File

@ -5513,7 +5513,7 @@ nsDocument::CreateElement(const nsAString& aTagName,
*aReturn = nullptr;
ErrorResult rv;
nsCOMPtr<Element> element = nsIDocument::CreateElement(aTagName, rv);
NS_ENSURE_FALSE(rv.Failed(), rv.ErrorCode());
NS_ENSURE_FALSE(rv.Failed(), rv.StealNSResult());
return CallQueryInterface(element, aReturn);
}
@ -5620,7 +5620,7 @@ nsDocument::CreateElementNS(const nsAString& aNamespaceURI,
ErrorResult rv;
nsCOMPtr<Element> element =
nsIDocument::CreateElementNS(aNamespaceURI, aQualifiedName, rv);
NS_ENSURE_FALSE(rv.Failed(), rv.ErrorCode());
NS_ENSURE_FALSE(rv.Failed(), rv.StealNSResult());
return CallQueryInterface(element, aReturn);
}

View File

@ -1995,7 +1995,7 @@ nsRange::CutContents(DocumentFragment** aFragment)
if (parent) {
mozilla::ErrorResult error;
parent->RemoveChild(*node, error);
NS_ENSURE_FALSE(error.Failed(), error.ErrorCode());
NS_ENSURE_FALSE(error.Failed(), error.StealNSResult());
}
NS_ENSURE_STATE(!guard.Mutated(1) ||
ValidateCurrentNode(this, iter));

View File

@ -42,7 +42,7 @@ SpeechRecognitionError::InitSpeechRecognitionError(const nsAString& aType,
ErrorResult& aRv)
{
aRv = Event::InitEvent(aType, aCanBubble, aCancelable);
NS_ENSURE_SUCCESS_VOID(aRv.ErrorCode());
NS_ENSURE_TRUE_VOID(!aRv.Failed());
mError = aError;
mMessage = aMessage;

View File

@ -2430,7 +2430,7 @@ RuntimeService::CreateSharedWorkerFromLoadInfo(JSContext* aCx,
workerPrivate =
WorkerPrivate::Constructor(aCx, aScriptURL, false,
aType, aName, aLoadInfo, rv);
NS_ENSURE_TRUE(workerPrivate, rv.ErrorCode());
NS_ENSURE_TRUE(workerPrivate, rv.StealNSResult());
created = true;
} else {

View File

@ -48,7 +48,7 @@ SplitNodeTxn::DoTransaction()
// Don't use .downcast directly because AsContent has an assertion we want
nsCOMPtr<nsINode> clone = mExistingRightNode->CloneNode(false, rv);
NS_ASSERTION(!rv.Failed() && clone, "Could not create clone");
NS_ENSURE_TRUE(!rv.Failed() && clone, rv.ErrorCode());
NS_ENSURE_TRUE(!rv.Failed() && clone, rv.StealNSResult());
mNewLeftNode = dont_AddRef(clone.forget().take()->AsContent());
mEditor.MarkNodeDirty(mExistingRightNode->AsDOMNode());

View File

@ -2538,13 +2538,22 @@ nsHTMLEditor::CreateElementWithDefaults(const nsAString& aTagName)
if (tagName.EqualsLiteral("table")) {
newElement->SetAttribute(NS_LITERAL_STRING("cellpadding"),
NS_LITERAL_STRING("2"), rv);
NS_ENSURE_SUCCESS(rv.ErrorCode(), nullptr);
if (NS_WARN_IF(rv.Failed())) {
rv.SuppressException();
return nullptr;
}
newElement->SetAttribute(NS_LITERAL_STRING("cellspacing"),
NS_LITERAL_STRING("2"), rv);
NS_ENSURE_SUCCESS(rv.ErrorCode(), nullptr);
if (NS_WARN_IF(rv.Failed())) {
rv.SuppressException();
return nullptr;
}
newElement->SetAttribute(NS_LITERAL_STRING("border"),
NS_LITERAL_STRING("1"), rv);
NS_ENSURE_SUCCESS(rv.ErrorCode(), nullptr);
if (NS_WARN_IF(rv.Failed())) {
rv.SuppressException();
return nullptr;
}
} else if (tagName.EqualsLiteral("td")) {
nsresult res = SetAttributeOrEquivalent(
static_cast<nsIDOMElement*>(newElement->AsDOMNode()),