Skip to content

Commit

Permalink
Bug 1157898 part 3. Fix the remaining consumers of rv.ErrorCode() in …
Browse files Browse the repository at this point in the history
…NS_ENSURE_* expressions to not do that. r=peterv
  • Loading branch information
bzbarsky committed Apr 27, 2015
1 parent b681abf commit 6a46477
Show file tree
Hide file tree
Showing 6 changed files with 18 additions and 9 deletions.
4 changes: 2 additions & 2 deletions dom/base/nsDocument.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

Expand Down Expand Up @@ -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);
}

Expand Down
2 changes: 1 addition & 1 deletion dom/base/nsRange.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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));
Expand Down
2 changes: 1 addition & 1 deletion dom/events/SpeechRecognitionError.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion dom/workers/RuntimeService.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
2 changes: 1 addition & 1 deletion editor/libeditor/SplitNodeTxn.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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());

Expand Down
15 changes: 12 additions & 3 deletions editor/libeditor/nsHTMLEditor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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()),
Expand Down

0 comments on commit 6a46477

Please sign in to comment.