Skip to content

Commit

Permalink
Bug 1127201 (attempt 2, part 1) - Replace most NS_ABORT_IF_FALSE call…
Browse files Browse the repository at this point in the history
…s with MOZ_ASSERT. r=Waldo.
  • Loading branch information
nnethercote committed Feb 9, 2015
1 parent 9e95b0e commit 00355c6
Show file tree
Hide file tree
Showing 347 changed files with 2,974 additions and 3,007 deletions.
4 changes: 2 additions & 2 deletions chrome/nsChromeRegistryContent.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ nsChromeRegistryContent::RegisterRemoteChrome(
const nsACString& aLocale,
bool aReset)
{
NS_ABORT_IF_FALSE(aReset || mLocale.IsEmpty(),
"RegisterChrome twice?");
MOZ_ASSERT(aReset || mLocale.IsEmpty(),
"RegisterChrome twice?");

if (aReset) {
mPackagesHash.Clear();
Expand Down
4 changes: 2 additions & 2 deletions dom/animation/Animation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ ComputedTimingFunction::Init(const nsTimingFunction &aFunction)
static inline double
StepEnd(uint32_t aSteps, double aPortion)
{
NS_ABORT_IF_FALSE(0.0 <= aPortion && aPortion <= 1.0, "out of range");
MOZ_ASSERT(0.0 <= aPortion && aPortion <= 1.0, "out of range");
uint32_t step = uint32_t(aPortion * aSteps); // floor
return double(step) / double(aSteps);
}
Expand All @@ -47,7 +47,7 @@ ComputedTimingFunction::GetValue(double aPortion) const
// really meant it.
return 1.0 - StepEnd(mSteps, 1.0 - aPortion);
default:
NS_ABORT_IF_FALSE(false, "bad type");
MOZ_ASSERT(false, "bad type");
// fall through
case nsTimingFunction::StepEnd:
return StepEnd(mSteps, aPortion);
Expand Down
2 changes: 1 addition & 1 deletion dom/archivereader/ArchiveRequest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ class ArchiveRequestEvent : public nsRunnable
NS_IMETHODIMP
ArchiveRequestEvent::Run()
{
NS_ABORT_IF_FALSE(mRequest, "the request is not longer valid");
MOZ_ASSERT(mRequest, "the request is not longer valid");
mRequest->Run();
return NS_OK;
}
Expand Down
6 changes: 3 additions & 3 deletions dom/base/Attr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,9 @@ Attr::Attr(nsDOMAttributeMap *aAttrMap,
const nsAString &aValue, bool aNsAware)
: nsIAttribute(aAttrMap, aNodeInfo, aNsAware), mValue(aValue)
{
NS_ABORT_IF_FALSE(mNodeInfo, "We must get a nodeinfo here!");
NS_ABORT_IF_FALSE(mNodeInfo->NodeType() == nsIDOMNode::ATTRIBUTE_NODE,
"Wrong nodeType");
MOZ_ASSERT(mNodeInfo, "We must get a nodeinfo here!");
MOZ_ASSERT(mNodeInfo->NodeType() == nsIDOMNode::ATTRIBUTE_NODE,
"Wrong nodeType");

// We don't add a reference to our content. It will tell us
// to drop our reference when it goes away.
Expand Down
4 changes: 2 additions & 2 deletions dom/base/Comment.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ class Comment MOZ_FINAL : public nsGenericDOMDataNode,
private:
void Init()
{
NS_ABORT_IF_FALSE(mNodeInfo->NodeType() == nsIDOMNode::COMMENT_NODE,
"Bad NodeType in aNodeInfo");
MOZ_ASSERT(mNodeInfo->NodeType() == nsIDOMNode::COMMENT_NODE,
"Bad NodeType in aNodeInfo");
}

virtual ~Comment();
Expand Down
2 changes: 1 addition & 1 deletion dom/base/Crypto.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ Crypto::GetRandomValues(JSContext* aCx, const ArrayBufferView& aArray,
JS::MutableHandle<JSObject*> aRetval,
ErrorResult& aRv)
{
NS_ABORT_IF_FALSE(NS_IsMainThread(), "Called on the wrong thread");
MOZ_ASSERT(NS_IsMainThread(), "Called on the wrong thread");

JS::Rooted<JSObject*> view(aCx, aArray.Obj());

Expand Down
9 changes: 4 additions & 5 deletions dom/base/DocumentFragment.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,10 @@ class DocumentFragment : public FragmentOrElement,
private:
void Init()
{
NS_ABORT_IF_FALSE(mNodeInfo->NodeType() ==
nsIDOMNode::DOCUMENT_FRAGMENT_NODE &&
mNodeInfo->Equals(nsGkAtoms::documentFragmentNodeName,
kNameSpaceID_None),
"Bad NodeType in aNodeInfo");
MOZ_ASSERT(mNodeInfo->NodeType() == nsIDOMNode::DOCUMENT_FRAGMENT_NODE &&
mNodeInfo->Equals(nsGkAtoms::documentFragmentNodeName,
kNameSpaceID_None),
"Bad NodeType in aNodeInfo");
}

public:
Expand Down
4 changes: 2 additions & 2 deletions dom/base/DocumentType.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,8 @@ DocumentType::DocumentType(already_AddRefed<mozilla::dom::NodeInfo>& aNodeInfo,
mSystemId(aSystemId),
mInternalSubset(aInternalSubset)
{
NS_ABORT_IF_FALSE(mNodeInfo->NodeType() == nsIDOMNode::DOCUMENT_TYPE_NODE,
"Bad NodeType in aNodeInfo");
MOZ_ASSERT(mNodeInfo->NodeType() == nsIDOMNode::DOCUMENT_TYPE_NODE,
"Bad NodeType in aNodeInfo");
}

DocumentType::~DocumentType()
Expand Down
6 changes: 3 additions & 3 deletions dom/base/Element.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -204,9 +204,9 @@ Element::NotifyStateChange(EventStates aStates)
void
Element::UpdateLinkState(EventStates aState)
{
NS_ABORT_IF_FALSE(!aState.HasAtLeastOneOfStates(~(NS_EVENT_STATE_VISITED |
NS_EVENT_STATE_UNVISITED)),
"Unexpected link state bits");
MOZ_ASSERT(!aState.HasAtLeastOneOfStates(~(NS_EVENT_STATE_VISITED |
NS_EVENT_STATE_UNVISITED)),
"Unexpected link state bits");
mState =
(mState & ~(NS_EVENT_STATE_VISITED | NS_EVENT_STATE_UNVISITED)) |
aState;
Expand Down
4 changes: 2 additions & 2 deletions dom/base/Element.h
Original file line number Diff line number Diff line change
Expand Up @@ -152,8 +152,8 @@ class Element : public FragmentOrElement
FragmentOrElement(aNodeInfo),
mState(NS_EVENT_STATE_MOZ_READONLY)
{
NS_ABORT_IF_FALSE(mNodeInfo->NodeType() == nsIDOMNode::ELEMENT_NODE,
"Bad NodeType in aNodeInfo");
MOZ_ASSERT(mNodeInfo->NodeType() == nsIDOMNode::ELEMENT_NODE,
"Bad NodeType in aNodeInfo");
SetIsElement();
}
#endif // MOZILLA_INTERNAL_API
Expand Down
6 changes: 3 additions & 3 deletions dom/base/EventSource.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -580,9 +580,9 @@ EventSource::AsyncOnChannelRedirect(nsIChannel *aOldChannel,
nsresult
EventSource::OnRedirectVerifyCallback(nsresult aResult)
{
NS_ABORT_IF_FALSE(mRedirectCallback, "mRedirectCallback not set in callback");
NS_ABORT_IF_FALSE(mNewRedirectChannel,
"mNewRedirectChannel not set in callback");
MOZ_ASSERT(mRedirectCallback, "mRedirectCallback not set in callback");
MOZ_ASSERT(mNewRedirectChannel,
"mNewRedirectChannel not set in callback");

NS_ENSURE_SUCCESS(aResult, aResult);

Expand Down
8 changes: 4 additions & 4 deletions dom/base/Link.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ Link::Link(Element *aElement)
, mNeedsRegistration(false)
, mRegistered(false)
{
NS_ABORT_IF_FALSE(mElement, "Must have an element");
MOZ_ASSERT(mElement, "Must have an element");
}

Link::~Link()
Expand Down Expand Up @@ -58,9 +58,9 @@ Link::SetLinkState(nsLinkState aState)
// Per IHistory interface documentation, we are no longer registered.
mRegistered = false;

NS_ABORT_IF_FALSE(LinkState() == NS_EVENT_STATE_VISITED ||
LinkState() == NS_EVENT_STATE_UNVISITED,
"Unexpected state obtained from LinkState()!");
MOZ_ASSERT(LinkState() == NS_EVENT_STATE_VISITED ||
LinkState() == NS_EVENT_STATE_UNVISITED,
"Unexpected state obtained from LinkState()!");

// Tell the element to update its visited state
mElement->UpdateState(true);
Expand Down
5 changes: 2 additions & 3 deletions dom/base/NodeInfo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ NodeInfo::NodeInfo(nsIAtom *aName, nsIAtom *aPrefix, int32_t aNamespaceID,
nsNodeInfoManager *aOwnerManager)
{
CheckValidNodeInfo(aNodeType, aName, aNamespaceID, aExtraName);
NS_ABORT_IF_FALSE(aOwnerManager, "Invalid aOwnerManager");
MOZ_ASSERT(aOwnerManager, "Invalid aOwnerManager");

// Initialize mInner
NS_ADDREF(mInner.mName = aName);
Expand Down Expand Up @@ -104,8 +104,7 @@ NodeInfo::NodeInfo(nsIAtom *aName, nsIAtom *aPrefix, int32_t aNamespaceID,
SetDOMStringToNull(mLocalName);
break;
default:
NS_ABORT_IF_FALSE(aNodeType == UINT16_MAX,
"Unknown node type");
MOZ_ASSERT(aNodeType == UINT16_MAX, "Unknown node type");
}
}

Expand Down
74 changes: 37 additions & 37 deletions dom/base/NodeInfoInlines.h
Original file line number Diff line number Diff line change
Expand Up @@ -75,42 +75,42 @@ inline void
CheckValidNodeInfo(uint16_t aNodeType, nsIAtom *aName, int32_t aNamespaceID,
nsIAtom* aExtraName)
{
NS_ABORT_IF_FALSE(aNodeType == nsIDOMNode::ELEMENT_NODE ||
aNodeType == nsIDOMNode::ATTRIBUTE_NODE ||
aNodeType == nsIDOMNode::TEXT_NODE ||
aNodeType == nsIDOMNode::CDATA_SECTION_NODE ||
aNodeType == nsIDOMNode::PROCESSING_INSTRUCTION_NODE ||
aNodeType == nsIDOMNode::COMMENT_NODE ||
aNodeType == nsIDOMNode::DOCUMENT_NODE ||
aNodeType == nsIDOMNode::DOCUMENT_TYPE_NODE ||
aNodeType == nsIDOMNode::DOCUMENT_FRAGMENT_NODE ||
aNodeType == UINT16_MAX,
"Invalid nodeType");
NS_ABORT_IF_FALSE((aNodeType == nsIDOMNode::PROCESSING_INSTRUCTION_NODE ||
aNodeType == nsIDOMNode::DOCUMENT_TYPE_NODE) ==
!!aExtraName,
"Supply aExtraName for and only for PIs and doctypes");
NS_ABORT_IF_FALSE(aNodeType == nsIDOMNode::ELEMENT_NODE ||
aNodeType == nsIDOMNode::ATTRIBUTE_NODE ||
aNodeType == UINT16_MAX ||
aNamespaceID == kNameSpaceID_None,
"Only attributes and elements can be in a namespace");
NS_ABORT_IF_FALSE(aName && aName != nsGkAtoms::_empty, "Invalid localName");
NS_ABORT_IF_FALSE(((aNodeType == nsIDOMNode::TEXT_NODE) ==
(aName == nsGkAtoms::textTagName)) &&
((aNodeType == nsIDOMNode::CDATA_SECTION_NODE) ==
(aName == nsGkAtoms::cdataTagName)) &&
((aNodeType == nsIDOMNode::COMMENT_NODE) ==
(aName == nsGkAtoms::commentTagName)) &&
((aNodeType == nsIDOMNode::DOCUMENT_NODE) ==
(aName == nsGkAtoms::documentNodeName)) &&
((aNodeType == nsIDOMNode::DOCUMENT_FRAGMENT_NODE) ==
(aName == nsGkAtoms::documentFragmentNodeName)) &&
((aNodeType == nsIDOMNode::DOCUMENT_TYPE_NODE) ==
(aName == nsGkAtoms::documentTypeNodeName)) &&
((aNodeType == nsIDOMNode::PROCESSING_INSTRUCTION_NODE) ==
(aName == nsGkAtoms::processingInstructionTagName)),
"Wrong localName for nodeType");
MOZ_ASSERT(aNodeType == nsIDOMNode::ELEMENT_NODE ||
aNodeType == nsIDOMNode::ATTRIBUTE_NODE ||
aNodeType == nsIDOMNode::TEXT_NODE ||
aNodeType == nsIDOMNode::CDATA_SECTION_NODE ||
aNodeType == nsIDOMNode::PROCESSING_INSTRUCTION_NODE ||
aNodeType == nsIDOMNode::COMMENT_NODE ||
aNodeType == nsIDOMNode::DOCUMENT_NODE ||
aNodeType == nsIDOMNode::DOCUMENT_TYPE_NODE ||
aNodeType == nsIDOMNode::DOCUMENT_FRAGMENT_NODE ||
aNodeType == UINT16_MAX,
"Invalid nodeType");
MOZ_ASSERT((aNodeType == nsIDOMNode::PROCESSING_INSTRUCTION_NODE ||
aNodeType == nsIDOMNode::DOCUMENT_TYPE_NODE) ==
!!aExtraName,
"Supply aExtraName for and only for PIs and doctypes");
MOZ_ASSERT(aNodeType == nsIDOMNode::ELEMENT_NODE ||
aNodeType == nsIDOMNode::ATTRIBUTE_NODE ||
aNodeType == UINT16_MAX ||
aNamespaceID == kNameSpaceID_None,
"Only attributes and elements can be in a namespace");
MOZ_ASSERT(aName && aName != nsGkAtoms::_empty, "Invalid localName");
MOZ_ASSERT(((aNodeType == nsIDOMNode::TEXT_NODE) ==
(aName == nsGkAtoms::textTagName)) &&
((aNodeType == nsIDOMNode::CDATA_SECTION_NODE) ==
(aName == nsGkAtoms::cdataTagName)) &&
((aNodeType == nsIDOMNode::COMMENT_NODE) ==
(aName == nsGkAtoms::commentTagName)) &&
((aNodeType == nsIDOMNode::DOCUMENT_NODE) ==
(aName == nsGkAtoms::documentNodeName)) &&
((aNodeType == nsIDOMNode::DOCUMENT_FRAGMENT_NODE) ==
(aName == nsGkAtoms::documentFragmentNodeName)) &&
((aNodeType == nsIDOMNode::DOCUMENT_TYPE_NODE) ==
(aName == nsGkAtoms::documentTypeNodeName)) &&
((aNodeType == nsIDOMNode::PROCESSING_INSTRUCTION_NODE) ==
(aName == nsGkAtoms::processingInstructionTagName)),
"Wrong localName for nodeType");
}

#endif /* mozilla_dom_NodeInfoInlines_h___ */
#endif /* mozilla_dom_NodeInfoInlines_h___ */
4 changes: 2 additions & 2 deletions dom/base/WebSocket.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1482,7 +1482,7 @@ WebSocketImpl::Init(JSContext* aCx,
void
WebSocketImpl::AsyncOpen(ErrorResult& aRv)
{
NS_ABORT_IF_FALSE(NS_IsMainThread(), "Not running on main thread");
MOZ_ASSERT(NS_IsMainThread(), "Not running on main thread");

nsCString asciiOrigin;
aRv = nsContentUtils::GetASCIIOrigin(mPrincipal, asciiOrigin);
Expand Down Expand Up @@ -1527,7 +1527,7 @@ nsresult
WebSocketImpl::InitializeConnection()
{
AssertIsOnMainThread();
NS_ABORT_IF_FALSE(!mChannel, "mChannel should be null");
MOZ_ASSERT(!mChannel, "mChannel should be null");

nsCOMPtr<nsIWebSocketChannel> wsChannel;
nsAutoCloseWS autoClose(this);
Expand Down
5 changes: 2 additions & 3 deletions dom/base/nsAttrValue.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1032,8 +1032,7 @@ nsAttrValue::Equals(const nsAttrValue& aOther) const
// If that changes then we probably want to add methods to the
// corresponding SVG types to compare their base values.
// As a shortcut, however, we can begin by comparing the pointers.
NS_ABORT_IF_FALSE(false, "Comparing nsAttrValues that point to SVG "
"data");
MOZ_ASSERT(false, "Comparing nsAttrValues that point to SVG data");
return false;
}
NS_NOTREACHED("unknown type stored in MiscContainer");
Expand Down Expand Up @@ -1754,7 +1753,7 @@ nsAttrValue::ResetMiscAtomOrString()
void
nsAttrValue::SetSVGType(ValueType aType, const void* aValue,
const nsAString* aSerialized) {
NS_ABORT_IF_FALSE(IsSVGType(aType), "Not an SVG type");
MOZ_ASSERT(IsSVGType(aType), "Not an SVG type");

MiscContainer* cont = EnsureEmptyMiscContainer();
// All SVG types are just pointers to classes so just setting any of them
Expand Down
2 changes: 1 addition & 1 deletion dom/base/nsContentUtils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4277,7 +4277,7 @@ nsContentUtils::ParseFragmentXML(const nsAString& aSourceBuffer,
// sXMLFragmentSink now owns the sink
}
nsCOMPtr<nsIContentSink> contentsink = do_QueryInterface(sXMLFragmentSink);
NS_ABORT_IF_FALSE(contentsink, "Sink doesn't QI to nsIContentSink!");
MOZ_ASSERT(contentsink, "Sink doesn't QI to nsIContentSink!");
sXMLFragmentParser->SetContentSink(contentsink);

sXMLFragmentSink->SetTargetDocument(aDocument);
Expand Down
2 changes: 1 addition & 1 deletion dom/base/nsDOMClassInfo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1765,7 +1765,7 @@ GetXPCProto(nsIXPConnect *aXPConnect, JSContext *cx, nsGlobalWindow *aWin,
nsCOMPtr<nsIClassInfo> ci;
if (aNameStruct->mType == nsGlobalNameStruct::eTypeClassConstructor) {
int32_t id = aNameStruct->mDOMClassInfoID;
NS_ABORT_IF_FALSE(id >= 0, "Negative DOM classinfo?!?");
MOZ_ASSERT(id >= 0, "Negative DOM classinfo?!?");

nsDOMClassInfoID ci_id = (nsDOMClassInfoID)id;

Expand Down
6 changes: 3 additions & 3 deletions dom/base/nsDOMDataChannel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -269,7 +269,7 @@ nsDOMDataChannel::Send(const nsAString& aData, ErrorResult& aRv)
void
nsDOMDataChannel::Send(File& aData, ErrorResult& aRv)
{
NS_ABORT_IF_FALSE(NS_IsMainThread(), "Not running on main thread");
MOZ_ASSERT(NS_IsMainThread(), "Not running on main thread");

nsCOMPtr<nsIInputStream> msgStream;
nsresult rv = aData.GetInternalStream(getter_AddRefs(msgStream));
Expand All @@ -296,7 +296,7 @@ nsDOMDataChannel::Send(File& aData, ErrorResult& aRv)
void
nsDOMDataChannel::Send(const ArrayBuffer& aData, ErrorResult& aRv)
{
NS_ABORT_IF_FALSE(NS_IsMainThread(), "Not running on main thread");
MOZ_ASSERT(NS_IsMainThread(), "Not running on main thread");

aData.ComputeLengthAndData();

Expand All @@ -312,7 +312,7 @@ nsDOMDataChannel::Send(const ArrayBuffer& aData, ErrorResult& aRv)
void
nsDOMDataChannel::Send(const ArrayBufferView& aData, ErrorResult& aRv)
{
NS_ABORT_IF_FALSE(NS_IsMainThread(), "Not running on main thread");
MOZ_ASSERT(NS_IsMainThread(), "Not running on main thread");

aData.ComputeLengthAndData();

Expand Down
8 changes: 4 additions & 4 deletions dom/base/nsDOMTokenList.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ void
nsDOMTokenList::RemoveInternal(const nsAttrValue* aAttr,
const nsTArray<nsString>& aTokens)
{
NS_ABORT_IF_FALSE(aAttr, "Need an attribute");
MOZ_ASSERT(aAttr, "Need an attribute");

nsAutoString input;
aAttr->ToString(input);
Expand All @@ -204,7 +204,7 @@ nsDOMTokenList::RemoveInternal(const nsAttrValue* aAttr,
if (iter == end) {
// At this point we're sure the last seen token (if any) wasn't to be
// removed. So the trailing spaces will need to be kept.
NS_ABORT_IF_FALSE(!lastTokenRemoved, "How did this happen?");
MOZ_ASSERT(!lastTokenRemoved, "How did this happen?");

output.Append(Substring(copyStart, end));
break;
Expand All @@ -227,8 +227,8 @@ nsDOMTokenList::RemoveInternal(const nsAttrValue* aAttr,
} else {

if (lastTokenRemoved && !output.IsEmpty()) {
NS_ABORT_IF_FALSE(!nsContentUtils::IsHTMLWhitespace(
output.Last()), "Invalid last output token");
MOZ_ASSERT(!nsContentUtils::IsHTMLWhitespace(output.Last()),
"Invalid last output token");
output.Append(char16_t(' '));
}
lastTokenRemoved = false;
Expand Down
Loading

0 comments on commit 00355c6

Please sign in to comment.