diff --git a/accessible/base/FocusManager.cpp b/accessible/base/FocusManager.cpp index 6d697636e054..5251ff7230e6 100644 --- a/accessible/base/FocusManager.cpp +++ b/accessible/base/FocusManager.cpp @@ -239,7 +239,7 @@ void FocusManager::DispatchFocusEvent(DocAccessible* aDocument, Accessible* aTarget) { - NS_PRECONDITION(aDocument, "No document for focused accessible!"); + MOZ_ASSERT(aDocument, "No document for focused accessible!"); if (aDocument) { RefPtr event = new AccEvent(nsIAccessibleEvent::EVENT_FOCUS, aTarget, @@ -292,8 +292,8 @@ FocusManager::ProcessDOMFocus(nsINode* aTarget) void FocusManager::ProcessFocusEvent(AccEvent* aEvent) { - NS_PRECONDITION(aEvent->GetEventType() == nsIAccessibleEvent::EVENT_FOCUS, - "Focus event is expected!"); + MOZ_ASSERT(aEvent->GetEventType() == nsIAccessibleEvent::EVENT_FOCUS, + "Focus event is expected!"); // Emit focus event if event target is the active item. Otherwise then check // if it's still focused and then update active item and emit focus event. diff --git a/accessible/base/TextAttrs.cpp b/accessible/base/TextAttrs.cpp index 53cca870b9be..2cb6156373e7 100644 --- a/accessible/base/TextAttrs.cpp +++ b/accessible/base/TextAttrs.cpp @@ -37,13 +37,13 @@ TextAttrsMgr::GetAttributes(nsIPersistentProperties* aAttributes, // 3. Offset accessible and result hyper text offsets must not be specified // but include default text attributes flag and attributes list must be // specified in the case of default text attributes. - NS_PRECONDITION(mHyperTextAcc && - ((mOffsetAcc && mOffsetAccIdx != -1 && - aStartOffset && aEndOffset) || - (!mOffsetAcc && mOffsetAccIdx == -1 && - !aStartOffset && !aEndOffset && - mIncludeDefAttrs && aAttributes)), - "Wrong usage of TextAttrsMgr!"); + MOZ_ASSERT(mHyperTextAcc && + ((mOffsetAcc && mOffsetAccIdx != -1 && + aStartOffset && aEndOffset) || + (!mOffsetAcc && mOffsetAccIdx == -1 && + !aStartOffset && !aEndOffset && + mIncludeDefAttrs && aAttributes)), + "Wrong usage of TextAttrsMgr!"); // Embedded objects are combined into own range with empty attributes set. if (mOffsetAcc && !mOffsetAcc->IsText()) { diff --git a/accessible/generic/Accessible.cpp b/accessible/generic/Accessible.cpp index 627aa27db883..1d012ce59ec0 100644 --- a/accessible/generic/Accessible.cpp +++ b/accessible/generic/Accessible.cpp @@ -2356,7 +2356,7 @@ Accessible::IsLink() const uint32_t Accessible::StartOffset() { - NS_PRECONDITION(IsLink(), "StartOffset is called not on hyper link!"); + MOZ_ASSERT(IsLink(), "StartOffset is called not on hyper link!"); HyperTextAccessible* hyperText = mParent ? mParent->AsHyperText() : nullptr; return hyperText ? hyperText->GetChildOffset(this) : 0; @@ -2365,7 +2365,7 @@ Accessible::StartOffset() uint32_t Accessible::EndOffset() { - NS_PRECONDITION(IsLink(), "EndOffset is called on not hyper link!"); + MOZ_ASSERT(IsLink(), "EndOffset is called on not hyper link!"); HyperTextAccessible* hyperText = mParent ? mParent->AsHyperText() : nullptr; return hyperText ? (hyperText->GetChildOffset(this) + 1) : 0; @@ -2374,21 +2374,21 @@ Accessible::EndOffset() uint32_t Accessible::AnchorCount() { - NS_PRECONDITION(IsLink(), "AnchorCount is called on not hyper link!"); + MOZ_ASSERT(IsLink(), "AnchorCount is called on not hyper link!"); return 1; } Accessible* Accessible::AnchorAt(uint32_t aAnchorIndex) { - NS_PRECONDITION(IsLink(), "GetAnchor is called on not hyper link!"); + MOZ_ASSERT(IsLink(), "GetAnchor is called on not hyper link!"); return aAnchorIndex == 0 ? this : nullptr; } already_AddRefed Accessible::AnchorURIAt(uint32_t aAnchorIndex) { - NS_PRECONDITION(IsLink(), "AnchorURIAt is called on not hyper link!"); + MOZ_ASSERT(IsLink(), "AnchorURIAt is called on not hyper link!"); return nullptr; } diff --git a/accessible/generic/Accessible.h b/accessible/generic/Accessible.h index 54b9efed2e34..7da76a3ce3d9 100644 --- a/accessible/generic/Accessible.h +++ b/accessible/generic/Accessible.h @@ -743,7 +743,7 @@ public: */ inline bool IsLinkValid() { - NS_PRECONDITION(IsLink(), "IsLinkValid is called on not hyper link!"); + MOZ_ASSERT(IsLink(), "IsLinkValid is called on not hyper link!"); // XXX In order to implement this we would need to follow every link // Perhaps we can get information about invalid links from the cache diff --git a/accessible/mac/mozTextAccessible.mm b/accessible/mac/mozTextAccessible.mm index 0909cd5129b4..9ea11aa1a3a7 100644 --- a/accessible/mac/mozTextAccessible.mm +++ b/accessible/mac/mozTextAccessible.mm @@ -17,7 +17,7 @@ using namespace mozilla::a11y; inline bool ToNSRange(id aValue, NSRange* aRange) { - NS_PRECONDITION(aRange, "aRange is nil"); + MOZ_ASSERT(aRange, "aRange is nil"); if ([aValue isKindOfClass:[NSValue class]] && strcmp([(NSValue*)aValue objCType], @encode(NSRange)) == 0) { @@ -547,7 +547,7 @@ ToNSString(id aValue) - (NSString*)stringFromRange:(NSRange*)range { - NS_PRECONDITION(range, "no range"); + MOZ_ASSERT(range, "no range"); AccessibleWrap* accWrap = [self getGeckoAccessible]; ProxyAccessible* proxy = [self getProxyAccessible]; diff --git a/accessible/xpcom/xpcAccessibleSelectable.cpp b/accessible/xpcom/xpcAccessibleSelectable.cpp index 9910dc61c126..742311493969 100644 --- a/accessible/xpcom/xpcAccessibleSelectable.cpp +++ b/accessible/xpcom/xpcAccessibleSelectable.cpp @@ -19,7 +19,7 @@ xpcAccessibleSelectable::GetSelectedItems(nsIArray** aSelectedItems) if (!Intl()) return NS_ERROR_FAILURE; - NS_PRECONDITION(Intl()->IsSelect(), "Called on non selectable widget!"); + MOZ_ASSERT(Intl()->IsSelect(), "Called on non selectable widget!"); AutoTArray items; Intl()->SelectedItems(&items); @@ -48,7 +48,7 @@ xpcAccessibleSelectable::GetSelectedItemCount(uint32_t* aSelectionCount) if (!Intl()) return NS_ERROR_FAILURE; - NS_PRECONDITION(Intl()->IsSelect(), "Called on non selectable widget!"); + MOZ_ASSERT(Intl()->IsSelect(), "Called on non selectable widget!"); *aSelectionCount = Intl()->SelectedItemCount(); return NS_OK; @@ -63,7 +63,7 @@ xpcAccessibleSelectable::GetSelectedItemAt(uint32_t aIndex, if (!Intl()) return NS_ERROR_FAILURE; - NS_PRECONDITION(Intl()->IsSelect(), "Called on non selectable widget!"); + MOZ_ASSERT(Intl()->IsSelect(), "Called on non selectable widget!"); *aSelected = ToXPC(Intl()->GetSelectedItem(aIndex)); if (*aSelected) { @@ -82,7 +82,7 @@ xpcAccessibleSelectable::IsItemSelected(uint32_t aIndex, bool* aIsSelected) if (!Intl()) return NS_ERROR_FAILURE; - NS_PRECONDITION(Intl()->IsSelect(), "Called on non selectable widget!"); + MOZ_ASSERT(Intl()->IsSelect(), "Called on non selectable widget!"); *aIsSelected = Intl()->IsItemSelected(aIndex); return NS_OK; @@ -93,7 +93,7 @@ xpcAccessibleSelectable::AddItemToSelection(uint32_t aIndex) { if (!Intl()) return NS_ERROR_FAILURE; - NS_PRECONDITION(Intl()->IsSelect(), "Called on non selectable widget!"); + MOZ_ASSERT(Intl()->IsSelect(), "Called on non selectable widget!"); return Intl()->AddItemToSelection(aIndex) ? NS_OK : NS_ERROR_INVALID_ARG; } @@ -103,7 +103,7 @@ xpcAccessibleSelectable::RemoveItemFromSelection(uint32_t aIndex) { if (!Intl()) return NS_ERROR_FAILURE; - NS_PRECONDITION(Intl()->IsSelect(), "Called on non selectable widget!"); + MOZ_ASSERT(Intl()->IsSelect(), "Called on non selectable widget!"); return Intl()->RemoveItemFromSelection(aIndex) ? NS_OK : NS_ERROR_INVALID_ARG; } @@ -116,7 +116,7 @@ xpcAccessibleSelectable::SelectAll(bool* aIsMultiSelect) if (!Intl()) return NS_ERROR_FAILURE; - NS_PRECONDITION(Intl()->IsSelect(), "Called on non selectable widget!"); + MOZ_ASSERT(Intl()->IsSelect(), "Called on non selectable widget!"); *aIsMultiSelect = Intl()->SelectAll(); return NS_OK; @@ -127,7 +127,7 @@ xpcAccessibleSelectable::UnselectAll() { if (!Intl()) return NS_ERROR_FAILURE; - NS_PRECONDITION(Intl()->IsSelect(), "Called on non selectable widget!"); + MOZ_ASSERT(Intl()->IsSelect(), "Called on non selectable widget!"); Intl()->UnselectAll(); return NS_OK; diff --git a/accessible/xul/XULTreeGridAccessible.cpp b/accessible/xul/XULTreeGridAccessible.cpp index 56cdb21f7fec..1f8d90cc1877 100644 --- a/accessible/xul/XULTreeGridAccessible.cpp +++ b/accessible/xul/XULTreeGridAccessible.cpp @@ -371,7 +371,7 @@ XULTreeGridRowAccessible::ChildCount() const XULTreeGridCellAccessible* XULTreeGridRowAccessible::GetCellAccessible(nsITreeColumn* aColumn) const { - NS_PRECONDITION(aColumn, "No tree column!"); + MOZ_ASSERT(aColumn, "No tree column!"); void* key = static_cast(aColumn); XULTreeGridCellAccessible* cachedCell = mAccessibleCache.GetWeak(key); diff --git a/caps/ContentPrincipal.cpp b/caps/ContentPrincipal.cpp index a1f097e176a0..03ca5fea9963 100644 --- a/caps/ContentPrincipal.cpp +++ b/caps/ContentPrincipal.cpp @@ -330,7 +330,7 @@ ContentPrincipal::MayLoadInternal(nsIURI* aURI) NS_IMETHODIMP ContentPrincipal::GetHashValue(uint32_t* aValue) { - NS_PRECONDITION(mCodebase, "Need a codebase"); + MOZ_ASSERT(mCodebase, "Need a codebase"); *aValue = nsScriptSecurityManager::HashPrincipalByOrigin(this); return NS_OK; diff --git a/caps/nsJSPrincipals.cpp b/caps/nsJSPrincipals.cpp index 50fe96b70950..b042de33b746 100644 --- a/caps/nsJSPrincipals.cpp +++ b/caps/nsJSPrincipals.cpp @@ -28,7 +28,7 @@ NS_IMETHODIMP_(MozExternalRefCountType) nsJSPrincipals::AddRef() { MOZ_ASSERT(NS_IsMainThread()); - NS_PRECONDITION(int32_t(refcount) >= 0, "illegal refcnt"); + MOZ_ASSERT(int32_t(refcount) >= 0, "illegal refcnt"); nsrefcnt count = ++refcount; NS_LOG_ADDREF(this, count, "nsJSPrincipals", sizeof(*this)); return count; @@ -38,7 +38,7 @@ NS_IMETHODIMP_(MozExternalRefCountType) nsJSPrincipals::Release() { MOZ_ASSERT(NS_IsMainThread()); - NS_PRECONDITION(0 != refcount, "dup release"); + MOZ_ASSERT(0 != refcount, "dup release"); nsrefcnt count = --refcount; NS_LOG_RELEASE(this, count, "nsJSPrincipals"); if (count == 0) { diff --git a/caps/nsScriptSecurityManager.cpp b/caps/nsScriptSecurityManager.cpp index 56a0e5a31dce..32b885f07a32 100644 --- a/caps/nsScriptSecurityManager.cpp +++ b/caps/nsScriptSecurityManager.cpp @@ -260,7 +260,8 @@ nsScriptSecurityManager::GetChannelResultPrincipal(nsIChannel* aChannel, nsIPrincipal** aPrincipal, bool aIgnoreSandboxing) { - NS_PRECONDITION(aChannel, "Must have channel!"); + MOZ_ASSERT(aChannel, "Must have channel!"); + // Check whether we have an nsILoadInfo that says what we should do. nsCOMPtr loadInfo = aChannel->GetLoadInfo(); if (loadInfo && loadInfo->GetForceInheritPrincipalOverruleOwner()) { @@ -349,7 +350,7 @@ NS_IMETHODIMP nsScriptSecurityManager::GetChannelURIPrincipal(nsIChannel* aChannel, nsIPrincipal** aPrincipal) { - NS_PRECONDITION(aChannel, "Must have channel!"); + MOZ_ASSERT(aChannel, "Must have channel!"); // Get the principal from the URI. Make sure this does the same thing // as nsDocument::Reset and XULDocument::StartDocumentLoad. @@ -517,7 +518,7 @@ nsScriptSecurityManager::CheckLoadURIFromScript(JSContext *cx, nsIURI *aURI) static nsresult DenyAccessIfURIHasFlags(nsIURI* aURI, uint32_t aURIFlags) { - NS_PRECONDITION(aURI, "Must have URI!"); + MOZ_ASSERT(aURI, "Must have URI!"); bool uriHasFlags; nsresult rv = @@ -565,7 +566,8 @@ nsScriptSecurityManager::CheckLoadURIWithPrincipal(nsIPrincipal* aPrincipal, nsIURI *aTargetURI, uint32_t aFlags) { - NS_PRECONDITION(aPrincipal, "CheckLoadURIWithPrincipal must have a principal"); + MOZ_ASSERT(aPrincipal, "CheckLoadURIWithPrincipal must have a principal"); + // If someone passes a flag that we don't understand, we should // fail, because they may need a security check that we don't // provide. diff --git a/chrome/nsChromeProtocolHandler.cpp b/chrome/nsChromeProtocolHandler.cpp index e42744ae4f75..9dc0e842fb0c 100644 --- a/chrome/nsChromeProtocolHandler.cpp +++ b/chrome/nsChromeProtocolHandler.cpp @@ -113,7 +113,7 @@ nsChromeProtocolHandler::NewChannel2(nsIURI* aURI, NS_ENSURE_ARG_POINTER(aURI); NS_ENSURE_ARG_POINTER(aLoadInfo); - NS_PRECONDITION(aResult, "Null out param"); + MOZ_ASSERT(aResult, "Null out param"); #ifdef DEBUG // Check that the uri we got is already canonified diff --git a/docshell/base/nsDSURIContentListener.cpp b/docshell/base/nsDSURIContentListener.cpp index 0a099ca2c306..9a4df15431c8 100644 --- a/docshell/base/nsDSURIContentListener.cpp +++ b/docshell/base/nsDSURIContentListener.cpp @@ -261,7 +261,7 @@ nsDSURIContentListener::CanHandleContent(const char* aContentType, char** aDesiredContentType, bool* aCanHandleContent) { - NS_PRECONDITION(aCanHandleContent, "Null out param?"); + MOZ_ASSERT(aCanHandleContent, "Null out param?"); NS_ENSURE_ARG_POINTER(aDesiredContentType); *aCanHandleContent = false; diff --git a/docshell/base/nsDocShell.cpp b/docshell/base/nsDocShell.cpp index e58a60cceb2f..8185f00cf179 100644 --- a/docshell/base/nsDocShell.cpp +++ b/docshell/base/nsDocShell.cpp @@ -537,7 +537,7 @@ NS_INTERFACE_MAP_END_INHERITING(nsDocLoader) NS_IMETHODIMP nsDocShell::GetInterface(const nsIID& aIID, void** aSink) { - NS_PRECONDITION(aSink, "null out param"); + MOZ_ASSERT(aSink, "null out param"); *aSink = nullptr; @@ -668,9 +668,9 @@ nsDocShell::LoadURI(nsIURI* aURI, uint32_t aLoadFlags, bool aFirstParty) { - NS_PRECONDITION(aLoadInfo || (aLoadFlags & EXTRA_LOAD_FLAGS) == 0, - "Unexpected flags"); - NS_PRECONDITION((aLoadFlags & 0xf) == 0, "Should not have these flags set"); + MOZ_ASSERT(aLoadInfo || (aLoadFlags & EXTRA_LOAD_FLAGS) == 0, + "Unexpected flags"); + MOZ_ASSERT((aLoadFlags & 0xf) == 0, "Should not have these flags set"); // Note: we allow loads to get through here even if mFiredUnloadEvent is // true; that case will get handled in LoadInternal or LoadHistoryEntry, @@ -3127,7 +3127,7 @@ nsDocShell::CanAccessItem(nsIDocShellTreeItem* aTargetItem, nsIDocShellTreeItem* aAccessingItem, bool aConsiderOpener) { - NS_PRECONDITION(aTargetItem, "Must have target item!"); + MOZ_ASSERT(aTargetItem, "Must have target item!"); if (!gValidateOrigin || !aAccessingItem) { // Good to go @@ -5291,7 +5291,7 @@ nsDocShell::LoadPage(nsISupports* aPageDescriptor, uint32_t aDisplayType) NS_IMETHODIMP nsDocShell::GetCurrentDescriptor(nsISupports** aPageDescriptor) { - NS_PRECONDITION(aPageDescriptor, "Null out param?"); + MOZ_ASSERT(aPageDescriptor, "Null out param?"); *aPageDescriptor = nullptr; @@ -6345,7 +6345,7 @@ nsDocShell::ForceRefreshURIFromTimer(nsIURI* aURI, bool aMetaRefresh, nsITimer* aTimer) { - NS_PRECONDITION(aTimer, "Must have a timer here"); + MOZ_ASSERT(aTimer, "Must have a timer here"); // Remove aTimer from mRefreshURIList if needed if (mRefreshURIList) { @@ -9758,8 +9758,8 @@ nsDocShell::InternalLoad(nsIURI* aURI, if (mFiredUnloadEvent) { if (IsOKToLoadURI(aURI)) { - NS_PRECONDITION(aWindowTarget.IsEmpty(), - "Shouldn't have a window target here!"); + MOZ_ASSERT(aWindowTarget.IsEmpty(), + "Shouldn't have a window target here!"); // If this is a replace load, make whatever load triggered // the unload event also a replace load, so we don't @@ -11340,8 +11340,8 @@ nsDocShell::OnNewURI(nsIURI* aURI, nsIChannel* aChannel, uint32_t aLoadType, bool aFireOnLocationChange, bool aAddToGlobalHistory, bool aCloneSHChildren) { - NS_PRECONDITION(aURI, "uri is null"); - NS_PRECONDITION(!aChannel || !aTriggeringPrincipal, "Shouldn't have both set"); + MOZ_ASSERT(aURI, "uri is null"); + MOZ_ASSERT(!aChannel || !aTriggeringPrincipal, "Shouldn't have both set"); MOZ_ASSERT(!aPrincipalToInherit || (aPrincipalToInherit && aTriggeringPrincipal)); @@ -11992,8 +11992,8 @@ nsDocShell::AddToSessionHistory(nsIURI* aURI, nsIChannel* aChannel, bool aCloneChildren, nsISHEntry** aNewEntry) { - NS_PRECONDITION(aURI, "uri is null"); - NS_PRECONDITION(!aChannel || !aTriggeringPrincipal, "Shouldn't have both set"); + MOZ_ASSERT(aURI, "uri is null"); + MOZ_ASSERT(!aChannel || !aTriggeringPrincipal, "Shouldn't have both set"); #if defined(DEBUG) if (MOZ_LOG_TEST(gDocShellLog, LogLevel::Debug)) { @@ -13153,7 +13153,7 @@ nsDocShell::GetIsContent(bool* aIsContent) bool nsDocShell::IsOKToLoadURI(nsIURI* aURI) { - NS_PRECONDITION(aURI, "Must have a URI!"); + MOZ_ASSERT(aURI, "Must have a URI!"); if (!mFiredUnloadEvent) { return true; diff --git a/docshell/base/nsWebNavigationInfo.cpp b/docshell/base/nsWebNavigationInfo.cpp index b9448a91054d..c7cf4949d87b 100644 --- a/docshell/base/nsWebNavigationInfo.cpp +++ b/docshell/base/nsWebNavigationInfo.cpp @@ -31,7 +31,7 @@ nsWebNavigationInfo::IsTypeSupported(const nsACString& aType, nsIWebNavigation* aWebNav, uint32_t* aIsTypeSupported) { - NS_PRECONDITION(aIsTypeSupported, "null out param?"); + MOZ_ASSERT(aIsTypeSupported, "null out param?"); // Note to self: aWebNav could be an nsWebBrowser or an nsDocShell here (or // an nsSHistory, but not much we can do with that). So if we start using @@ -94,7 +94,7 @@ nsresult nsWebNavigationInfo::IsTypeSupportedInternal(const nsCString& aType, uint32_t* aIsSupported) { - NS_PRECONDITION(aIsSupported, "Null out param?"); + MOZ_ASSERT(aIsSupported, "Null out param?"); nsContentUtils::ContentViewerType vtype = nsContentUtils::TYPE_UNSUPPORTED; diff --git a/docshell/build/nsDocShellModule.cpp b/docshell/build/nsDocShellModule.cpp index 8a17bd814ff1..a98ed6716ecd 100644 --- a/docshell/build/nsDocShellModule.cpp +++ b/docshell/build/nsDocShellModule.cpp @@ -53,7 +53,7 @@ static bool gInitialized = false; static nsresult Initialize() { - NS_PRECONDITION(!gInitialized, "docshell module already initialized"); + MOZ_ASSERT(!gInitialized, "docshell module already initialized"); if (gInitialized) { return NS_OK; } diff --git a/docshell/shistory/nsSHEntryShared.cpp b/docshell/shistory/nsSHEntryShared.cpp index ddb180ca5d13..acf8612510f7 100644 --- a/docshell/shistory/nsSHEntryShared.cpp +++ b/docshell/shistory/nsSHEntryShared.cpp @@ -139,8 +139,8 @@ nsSHEntryShared::DropPresentationState() nsresult nsSHEntryShared::SetContentViewer(nsIContentViewer* aViewer) { - NS_PRECONDITION(!aViewer || !mContentViewer, - "SHEntryShared already contains viewer"); + MOZ_ASSERT(!aViewer || !mContentViewer, + "SHEntryShared already contains viewer"); if (mContentViewer || !aViewer) { DropPresentationState(); diff --git a/docshell/shistory/nsSHistory.cpp b/docshell/shistory/nsSHistory.cpp index 58adbb27fd5b..74f010181d92 100644 --- a/docshell/shistory/nsSHistory.cpp +++ b/docshell/shistory/nsSHistory.cpp @@ -689,7 +689,7 @@ nsSHistory::GetCount(int32_t* aResult) NS_IMETHODIMP nsSHistory::GetIndex(int32_t* aResult) { - NS_PRECONDITION(aResult, "null out param?"); + MOZ_ASSERT(aResult, "null out param?"); *aResult = mIndex; return NS_OK; } @@ -698,7 +698,7 @@ nsSHistory::GetIndex(int32_t* aResult) NS_IMETHODIMP nsSHistory::GetRequestedIndex(int32_t* aResult) { - NS_PRECONDITION(aResult, "null out param?"); + MOZ_ASSERT(aResult, "null out param?"); *aResult = mRequestedIndex; return NS_OK; } diff --git a/dom/base/CharacterData.cpp b/dom/base/CharacterData.cpp index 2f69c789ae1a..c4a5160ff34a 100644 --- a/dom/base/CharacterData.cpp +++ b/dom/base/CharacterData.cpp @@ -66,8 +66,8 @@ CharacterData::CharacterData(already_AddRefed&& aNodeInfo) CharacterData::~CharacterData() { - NS_PRECONDITION(!IsInUncomposedDoc(), - "Please remove this from the document properly"); + MOZ_ASSERT(!IsInUncomposedDoc(), + "Please remove this from the document properly"); if (GetParent()) { NS_RELEASE(mParent); } @@ -246,8 +246,8 @@ CharacterData::SetTextInternal(uint32_t aOffset, uint32_t aCount, uint32_t aLength, bool aNotify, CharacterDataChangeInfo::Details* aDetails) { - NS_PRECONDITION(aBuffer || !aLength, - "Null buffer passed to SetTextInternal!"); + MOZ_ASSERT(aBuffer || !aLength, + "Null buffer passed to SetTextInternal!"); // sanitize arguments uint32_t textLength = mText.GetLength(); @@ -446,28 +446,28 @@ CharacterData::BindToTree(nsIDocument* aDocument, nsIContent* aParent, nsIContent* aBindingParent, bool aCompileEventHandlers) { - NS_PRECONDITION(aParent || aDocument, "Must have document if no parent!"); - NS_PRECONDITION(NODE_FROM(aParent, aDocument)->OwnerDoc() == OwnerDoc(), - "Must have the same owner document"); - NS_PRECONDITION(!aParent || aDocument == aParent->GetUncomposedDoc(), - "aDocument must be current doc of aParent"); - NS_PRECONDITION(!GetUncomposedDoc() && !IsInUncomposedDoc(), - "Already have a document. Unbind first!"); + MOZ_ASSERT(aParent || aDocument, "Must have document if no parent!"); + MOZ_ASSERT(NODE_FROM(aParent, aDocument)->OwnerDoc() == OwnerDoc(), + "Must have the same owner document"); + MOZ_ASSERT(!aParent || aDocument == aParent->GetUncomposedDoc(), + "aDocument must be current doc of aParent"); + MOZ_ASSERT(!GetUncomposedDoc() && !IsInUncomposedDoc(), + "Already have a document. Unbind first!"); // Note that as we recurse into the kids, they'll have a non-null parent. So // only assert if our parent is _changing_ while we have a parent. - NS_PRECONDITION(!GetParent() || aParent == GetParent(), - "Already have a parent. Unbind first!"); - NS_PRECONDITION(!GetBindingParent() || - aBindingParent == GetBindingParent() || - (!aBindingParent && aParent && - aParent->GetBindingParent() == GetBindingParent()), - "Already have a binding parent. Unbind first!"); - NS_PRECONDITION(aBindingParent != this, - "Content must not be its own binding parent"); - NS_PRECONDITION(!IsRootOfNativeAnonymousSubtree() || - aBindingParent == aParent, - "Native anonymous content must have its parent as its " - "own binding parent"); + MOZ_ASSERT(!GetParent() || aParent == GetParent(), + "Already have a parent. Unbind first!"); + MOZ_ASSERT(!GetBindingParent() || + aBindingParent == GetBindingParent() || + (!aBindingParent && aParent && + aParent->GetBindingParent() == GetBindingParent()), + "Already have a binding parent. Unbind first!"); + MOZ_ASSERT(aBindingParent != this, + "Content must not be its own binding parent"); + MOZ_ASSERT(!IsRootOfNativeAnonymousSubtree() || + aBindingParent == aParent, + "Native anonymous content must have its parent as its " + "own binding parent"); if (!aBindingParent && aParent) { aBindingParent = aParent->GetBindingParent(); diff --git a/dom/base/Element.cpp b/dom/base/Element.cpp index 7c1078f92d62..57e5bcc906e7 100644 --- a/dom/base/Element.cpp +++ b/dom/base/Element.cpp @@ -1534,30 +1534,30 @@ Element::BindToTree(nsIDocument* aDocument, nsIContent* aParent, nsIContent* aBindingParent, bool aCompileEventHandlers) { - NS_PRECONDITION(aParent || aDocument, "Must have document if no parent!"); - NS_PRECONDITION((NODE_FROM(aParent, aDocument)->OwnerDoc() == OwnerDoc()), - "Must have the same owner document"); - NS_PRECONDITION(!aParent || aDocument == aParent->GetUncomposedDoc(), - "aDocument must be current doc of aParent"); - NS_PRECONDITION(!GetUncomposedDoc(), "Already have a document. Unbind first!"); + MOZ_ASSERT(aParent || aDocument, "Must have document if no parent!"); + MOZ_ASSERT((NODE_FROM(aParent, aDocument)->OwnerDoc() == OwnerDoc()), + "Must have the same owner document"); + MOZ_ASSERT(!aParent || aDocument == aParent->GetUncomposedDoc(), + "aDocument must be current doc of aParent"); + MOZ_ASSERT(!GetUncomposedDoc(), "Already have a document. Unbind first!"); // Note that as we recurse into the kids, they'll have a non-null parent. So // only assert if our parent is _changing_ while we have a parent. - NS_PRECONDITION(!GetParent() || aParent == GetParent(), - "Already have a parent. Unbind first!"); - NS_PRECONDITION(!GetBindingParent() || - aBindingParent == GetBindingParent() || - (!aBindingParent && aParent && - aParent->GetBindingParent() == GetBindingParent()), - "Already have a binding parent. Unbind first!"); - NS_PRECONDITION(aBindingParent != this, - "Content must not be its own binding parent"); - NS_PRECONDITION(!IsRootOfNativeAnonymousSubtree() || - aBindingParent == aParent, - "Native anonymous content must have its parent as its " - "own binding parent"); - NS_PRECONDITION(aBindingParent || !aParent || - aBindingParent == aParent->GetBindingParent(), - "We should be passed the right binding parent"); + MOZ_ASSERT(!GetParent() || aParent == GetParent(), + "Already have a parent. Unbind first!"); + MOZ_ASSERT(!GetBindingParent() || + aBindingParent == GetBindingParent() || + (!aBindingParent && aParent && + aParent->GetBindingParent() == GetBindingParent()), + "Already have a binding parent. Unbind first!"); + MOZ_ASSERT(aBindingParent != this, + "Content must not be its own binding parent"); + MOZ_ASSERT(!IsRootOfNativeAnonymousSubtree() || + aBindingParent == aParent, + "Native anonymous content must have its parent as its " + "own binding parent"); + MOZ_ASSERT(aBindingParent || !aParent || + aBindingParent == aParent->GetBindingParent(), + "We should be passed the right binding parent"); #ifdef MOZ_XUL // First set the binding parent @@ -1841,7 +1841,7 @@ RemoveFromBindingManagerRunnable::Run() void Element::UnbindFromTree(bool aDeep, bool aNullParent) { - NS_PRECONDITION(aDeep || (!GetUncomposedDoc() && !GetBindingParent()), + MOZ_ASSERT(aDeep || (!GetUncomposedDoc() && !GetBindingParent()), "Shallow unbind won't clear document and binding parent on " "kids!"); @@ -2218,9 +2218,9 @@ Element::DispatchEvent(nsPresContext* aPresContext, bool aFullDispatch, nsEventStatus* aStatus) { - NS_PRECONDITION(aTarget, "Must have target"); - NS_PRECONDITION(aEvent, "Must have source event"); - NS_PRECONDITION(aStatus, "Null out param?"); + MOZ_ASSERT(aTarget, "Must have target"); + MOZ_ASSERT(aEvent, "Must have source event"); + MOZ_ASSERT(aStatus, "Null out param?"); if (!aPresContext) { return NS_OK; @@ -2247,9 +2247,9 @@ Element::DispatchClickEvent(nsPresContext* aPresContext, const EventFlags* aExtraEventFlags, nsEventStatus* aStatus) { - NS_PRECONDITION(aTarget, "Must have target"); - NS_PRECONDITION(aSourceEvent, "Must have source event"); - NS_PRECONDITION(aStatus, "Null out param?"); + MOZ_ASSERT(aTarget, "Must have target"); + MOZ_ASSERT(aSourceEvent, "Must have source event"); + MOZ_ASSERT(aStatus, "Null out param?"); WidgetMouseEvent event(aSourceEvent->IsTrusted(), eMouseClick, aSourceEvent->mWidget, WidgetMouseEvent::eReal); @@ -2322,7 +2322,7 @@ Element::SetEventHandler(nsAtom* aEventName, return NS_OK; } - NS_PRECONDITION(aEventName, "Must have event name!"); + MOZ_ASSERT(aEventName, "Must have event name!"); bool defer = true; EventListenerManager* manager = GetEventListenerManagerForAttr(aEventName, &defer); diff --git a/dom/base/Element.h b/dom/base/Element.h index 8cf632e0f8ab..1a3497a0476d 100644 --- a/dom/base/Element.h +++ b/dom/base/Element.h @@ -603,22 +603,22 @@ protected: // those in EXTERNALLY_MANAGED_STATES. virtual void AddStates(EventStates aStates) { - NS_PRECONDITION(!aStates.HasAtLeastOneOfStates(INTRINSIC_STATES), - "Should only be adding externally-managed states here"); + MOZ_ASSERT(!aStates.HasAtLeastOneOfStates(INTRINSIC_STATES), + "Should only be adding externally-managed states here"); AddStatesSilently(aStates); NotifyStateChange(aStates); } virtual void RemoveStates(EventStates aStates) { - NS_PRECONDITION(!aStates.HasAtLeastOneOfStates(INTRINSIC_STATES), - "Should only be removing externally-managed states here"); + MOZ_ASSERT(!aStates.HasAtLeastOneOfStates(INTRINSIC_STATES), + "Should only be removing externally-managed states here"); RemoveStatesSilently(aStates); NotifyStateChange(aStates); } virtual void ToggleStates(EventStates aStates, bool aNotify) { - NS_PRECONDITION(!aStates.HasAtLeastOneOfStates(INTRINSIC_STATES), - "Should only be removing externally-managed states here"); + MOZ_ASSERT(!aStates.HasAtLeastOneOfStates(INTRINSIC_STATES), + "Should only be removing externally-managed states here"); mState ^= aStates; if (aNotify) { NotifyStateChange(aStates); diff --git a/dom/base/EventSource.cpp b/dom/base/EventSource.cpp index 57a4d4775531..59d0ac1e43bb 100644 --- a/dom/base/EventSource.cpp +++ b/dom/base/EventSource.cpp @@ -835,12 +835,12 @@ EventSourceImpl::AsyncOnChannelRedirect(nsIChannel* aOldChannel, return NS_ERROR_ABORT; } nsCOMPtr aOldRequest = do_QueryInterface(aOldChannel); - NS_PRECONDITION(aOldRequest, "Redirect from a null request?"); + MOZ_ASSERT(aOldRequest, "Redirect from a null request?"); nsresult rv = CheckHealthOfRequestCallback(aOldRequest); NS_ENSURE_SUCCESS(rv, rv); - NS_PRECONDITION(aNewChannel, "Redirect without a channel?"); + MOZ_ASSERT(aNewChannel, "Redirect without a channel?"); nsCOMPtr newURI; rv = NS_GetFinalChannelURI(aNewChannel, getter_AddRefs(newURI)); @@ -1373,8 +1373,7 @@ EventSourceImpl::TimerCallback(nsITimer* aTimer, void* aClosure) return; } - NS_PRECONDITION(!thisObject->mHttpChannel, - "the channel hasn't been cancelled!!"); + MOZ_ASSERT(!thisObject->mHttpChannel, "the channel hasn't been cancelled!!"); if (!thisObject->IsFrozen()) { nsresult rv = thisObject->InitChannelAndRequestEventSource(); diff --git a/dom/base/FragmentOrElement.cpp b/dom/base/FragmentOrElement.cpp index 372788bb41e6..6cf38c7a6eb5 100644 --- a/dom/base/FragmentOrElement.cpp +++ b/dom/base/FragmentOrElement.cpp @@ -814,8 +814,8 @@ FragmentOrElement::FragmentOrElement(already_AddRefed&& FragmentOrElement::~FragmentOrElement() { - NS_PRECONDITION(!IsInUncomposedDoc(), - "Please remove this from the document properly"); + MOZ_ASSERT(!IsInUncomposedDoc(), + "Please remove this from the document properly"); if (GetParent()) { NS_RELEASE(mParent); } @@ -1187,7 +1187,7 @@ FragmentOrElement::InsertChildBefore(nsIContent* aKid, nsIContent* aBeforeThis, bool aNotify) { - NS_PRECONDITION(aKid, "null ptr"); + MOZ_ASSERT(aKid, "null ptr"); int32_t index = aBeforeThis ? ComputeIndexOf(aBeforeThis) : GetChildCount(); MOZ_ASSERT(index >= 0); @@ -1200,7 +1200,7 @@ FragmentOrElement::InsertChildAt_Deprecated(nsIContent* aKid, uint32_t aIndex, bool aNotify) { - NS_PRECONDITION(aKid, "null ptr"); + MOZ_ASSERT(aKid, "null ptr"); return doInsertChildAt(aKid, aIndex, aNotify, mAttrsAndChildren); } diff --git a/dom/base/IDTracker.h b/dom/base/IDTracker.h index c431c9d2686b..4eff1514f5d8 100644 --- a/dom/base/IDTracker.h +++ b/dom/base/IDTracker.h @@ -122,7 +122,7 @@ private: explicit Notification(IDTracker* aTarget) : mTarget(aTarget) { - NS_PRECONDITION(aTarget, "Must have a target"); + MOZ_ASSERT(aTarget, "Must have a target"); } IDTracker* mTarget; }; diff --git a/dom/base/Selection.cpp b/dom/base/Selection.cpp index 7138f7324772..a86454bb5bcd 100644 --- a/dom/base/Selection.cpp +++ b/dom/base/Selection.cpp @@ -2122,7 +2122,7 @@ nsresult Selection::StartAutoScrollTimer(nsIFrame* aFrame, const nsPoint& aPoint, uint32_t aDelay) { - NS_PRECONDITION(aFrame, "Need a frame"); + MOZ_ASSERT(aFrame, "Need a frame"); nsresult result; if (!mFrameSelection) { @@ -2160,7 +2160,7 @@ Selection::StopAutoScrollTimer() nsresult Selection::DoAutoScroll(nsIFrame* aFrame, nsPoint aPoint) { - NS_PRECONDITION(aFrame, "Need a frame"); + MOZ_ASSERT(aFrame, "Need a frame"); if (mAutoScrollTimer) { (void)mAutoScrollTimer->Stop(); diff --git a/dom/base/nsAttrAndChildArray.cpp b/dom/base/nsAttrAndChildArray.cpp index cd3477c59395..6e3cb148cb5a 100644 --- a/dom/base/nsAttrAndChildArray.cpp +++ b/dom/base/nsAttrAndChildArray.cpp @@ -614,7 +614,7 @@ nsAttrAndChildArray::SetAndSwapMappedAttr(nsAtom* aLocalName, nsresult nsAttrAndChildArray::DoSetMappedAttrStyleSheet(nsHTMLStyleSheet* aSheet) { - NS_PRECONDITION(mImpl && mImpl->mMappedAttrs, + MOZ_ASSERT(mImpl && mImpl->mMappedAttrs, "Should have mapped attrs here!"); if (aSheet == mImpl->mMappedAttrs->GetStyleSheet()) { return NS_OK; @@ -800,7 +800,7 @@ nsAttrAndChildArray::GetMapped() const nsresult nsAttrAndChildArray::EnsureCapacityToClone(const nsAttrAndChildArray& aOther, bool aAllocateChildren) { - NS_PRECONDITION(!mImpl, "nsAttrAndChildArray::EnsureCapacityToClone requires the array be empty when called"); + MOZ_ASSERT(!mImpl, "nsAttrAndChildArray::EnsureCapacityToClone requires the array be empty when called"); uint32_t attrCount = aOther.NonMappedAttrCount(); uint32_t childCount = 0; @@ -930,8 +930,8 @@ inline void nsAttrAndChildArray::SetChildAtPos(void** aPos, nsIContent* aChild, uint32_t aIndex, uint32_t aChildCount) { - NS_PRECONDITION(!aChild->GetNextSibling(), "aChild with next sibling?"); - NS_PRECONDITION(!aChild->GetPreviousSibling(), "aChild with prev sibling?"); + MOZ_ASSERT(!aChild->GetNextSibling(), "aChild with next sibling?"); + MOZ_ASSERT(!aChild->GetPreviousSibling(), "aChild with prev sibling?"); *aPos = aChild; NS_ADDREF(aChild); @@ -965,4 +965,3 @@ nsAttrAndChildArray::SizeOfExcludingThis(mozilla::MallocSizeOf aMallocSizeOf) co return n; } - diff --git a/dom/base/nsAttrAndChildArray.h b/dom/base/nsAttrAndChildArray.h index 19c34a9630aa..6447d1969ae6 100644 --- a/dom/base/nsAttrAndChildArray.h +++ b/dom/base/nsAttrAndChildArray.h @@ -184,7 +184,7 @@ private: bool AttrSlotIsTaken(uint32_t aSlot) const { - NS_PRECONDITION(aSlot < AttrSlotCount(), "out-of-bounds"); + MOZ_ASSERT(aSlot < AttrSlotCount(), "out-of-bounds"); return mImpl->mBuffer[aSlot * ATTRSIZE]; } diff --git a/dom/base/nsAttrValue.cpp b/dom/base/nsAttrValue.cpp index 3ac6d763a327..46f174485e7b 100644 --- a/dom/base/nsAttrValue.cpp +++ b/dom/base/nsAttrValue.cpp @@ -737,7 +737,7 @@ nsAttrValue::GetAsAtom() const const nsCheapString nsAttrValue::GetStringValue() const { - NS_PRECONDITION(Type() == eString, "wrong type"); + MOZ_ASSERT(Type() == eString, "wrong type"); return nsCheapString(static_cast(GetPtr())); } @@ -758,7 +758,7 @@ nsAttrValue::GetColorValue(nscolor& aColor) const void nsAttrValue::GetEnumString(nsAString& aResult, bool aRealTag) const { - NS_PRECONDITION(Type() == eEnum, "wrong type"); + MOZ_ASSERT(Type() == eEnum, "wrong type"); uint32_t allEnumBits = (BaseType() == eIntegerBase) ? static_cast(GetIntInternal()) @@ -800,8 +800,8 @@ nsAttrValue::GetAtomCount() const nsAtom* nsAttrValue::AtomAt(int32_t aIndex) const { - NS_PRECONDITION(aIndex >= 0, "Index must not be negative"); - NS_PRECONDITION(GetAtomCount() > uint32_t(aIndex), "aIndex out of range"); + MOZ_ASSERT(aIndex >= 0, "Index must not be negative"); + MOZ_ASSERT(GetAtomCount() > uint32_t(aIndex), "aIndex out of range"); if (BaseType() == eAtomBase) { return GetAtomValue(); @@ -1400,8 +1400,8 @@ nsAttrValue::ParseEnumValue(const nsAString& aValue, } if (aDefaultValue) { - NS_PRECONDITION(aTable <= aDefaultValue && aDefaultValue < tableEntry, - "aDefaultValue not inside aTable?"); + MOZ_ASSERT(aTable <= aDefaultValue && aDefaultValue < tableEntry, + "aDefaultValue not inside aTable?"); SetIntValueAndType(EnumTableEntryToValue(aTable, aDefaultValue), eEnum, &aValue); return true; @@ -1443,7 +1443,7 @@ bool nsAttrValue::ParseIntWithBounds(const nsAString& aString, int32_t aMin, int32_t aMax) { - NS_PRECONDITION(aMin < aMax, "bad boundaries"); + MOZ_ASSERT(aMin < aMax, "bad boundaries"); ResetIfSet(); @@ -1965,4 +1965,3 @@ nsAttrValue::SizeOfExcludingThis(MallocSizeOf aMallocSizeOf) const return n; } - diff --git a/dom/base/nsAttrValueInlines.h b/dom/base/nsAttrValueInlines.h index f11a419024dc..6da96892ed91 100644 --- a/dom/base/nsAttrValueInlines.h +++ b/dom/base/nsAttrValueInlines.h @@ -128,7 +128,7 @@ public: inline int32_t nsAttrValue::GetIntegerValue() const { - NS_PRECONDITION(Type() == eInteger, "wrong type"); + MOZ_ASSERT(Type() == eInteger, "wrong type"); return (BaseType() == eIntegerBase) ? GetIntInternal() : GetMiscContainer()->mValue.mInteger; @@ -137,7 +137,7 @@ nsAttrValue::GetIntegerValue() const inline int16_t nsAttrValue::GetEnumValue() const { - NS_PRECONDITION(Type() == eEnum, "wrong type"); + MOZ_ASSERT(Type() == eEnum, "wrong type"); // We don't need to worry about sign extension here since we're // returning an int16_t which will cut away the top bits. return static_cast(( @@ -150,7 +150,7 @@ nsAttrValue::GetEnumValue() const inline float nsAttrValue::GetPercentValue() const { - NS_PRECONDITION(Type() == ePercent, "wrong type"); + MOZ_ASSERT(Type() == ePercent, "wrong type"); return ((BaseType() == eIntegerBase) ? GetIntInternal() : GetMiscContainer()->mValue.mPercent) @@ -160,35 +160,35 @@ nsAttrValue::GetPercentValue() const inline mozilla::AtomArray* nsAttrValue::GetAtomArrayValue() const { - NS_PRECONDITION(Type() == eAtomArray, "wrong type"); + MOZ_ASSERT(Type() == eAtomArray, "wrong type"); return GetMiscContainer()->mValue.mAtomArray; } inline mozilla::DeclarationBlock* nsAttrValue::GetCSSDeclarationValue() const { - NS_PRECONDITION(Type() == eCSSDeclaration, "wrong type"); + MOZ_ASSERT(Type() == eCSSDeclaration, "wrong type"); return GetMiscContainer()->mValue.mCSSDeclaration; } inline nsIURI* nsAttrValue::GetURLValue() const { - NS_PRECONDITION(Type() == eURL, "wrong type"); + MOZ_ASSERT(Type() == eURL, "wrong type"); return GetMiscContainer()->mValue.mURL; } inline double nsAttrValue::GetDoubleValue() const { - NS_PRECONDITION(Type() == eDoubleValue, "wrong type"); + MOZ_ASSERT(Type() == eDoubleValue, "wrong type"); return GetMiscContainer()->mDoubleValue; } inline bool nsAttrValue::GetIntMarginValue(nsIntMargin& aMargin) const { - NS_PRECONDITION(Type() == eIntMarginValue, "wrong type"); + MOZ_ASSERT(Type() == eIntMarginValue, "wrong type"); nsIntMargin* m = GetMiscContainer()->mValue.mIntMargin; if (!m) return false; @@ -269,7 +269,7 @@ nsAttrValue::Type() const inline nsAtom* nsAttrValue::GetAtomValue() const { - NS_PRECONDITION(Type() == eAtom, "wrong type"); + MOZ_ASSERT(Type() == eAtom, "wrong type"); return reinterpret_cast(GetPtr()); } diff --git a/dom/base/nsContentAreaDragDrop.cpp b/dom/base/nsContentAreaDragDrop.cpp index 88c1f2389ac3..05081b964974 100644 --- a/dom/base/nsContentAreaDragDrop.cpp +++ b/dom/base/nsContentAreaDragDrop.cpp @@ -542,8 +542,8 @@ DragDataProducer::Produce(DataTransfer* aDataTransfer, nsIContent** aDragNode, nsACString& aPrincipalURISpec) { - NS_PRECONDITION(aCanDrag && aSelection && aDataTransfer && aDragNode, - "null pointer passed to Produce"); + MOZ_ASSERT(aCanDrag && aSelection && aDataTransfer && aDragNode, + "null pointer passed to Produce"); NS_ASSERTION(mWindow, "window not set"); NS_ASSERTION(mSelectionTargetNode, "selection target node should have been set"); diff --git a/dom/base/nsContentList.cpp b/dom/base/nsContentList.cpp index 6c662fa1b88f..63c2909695b0 100644 --- a/dom/base/nsContentList.cpp +++ b/dom/base/nsContentList.cpp @@ -628,7 +628,7 @@ nsContentList::AttributeChanged(Element* aElement, int32_t aModType, const nsAttrValue* aOldValue) { - NS_PRECONDITION(aElement, "Must have a content node to work with"); + MOZ_ASSERT(aElement, "Must have a content node to work with"); if (!mFunc || !mFuncMayDependOnAttr || mState == LIST_DIRTY || !MayContainRelevantNodes(aElement->GetParentNode()) || @@ -658,7 +658,7 @@ void nsContentList::ContentAppended(nsIContent* aFirstNewContent) { nsIContent* container = aFirstNewContent->GetParent(); - NS_PRECONDITION(container, "Can't get at the new content if no container!"); + MOZ_ASSERT(container, "Can't get at the new content if no container!"); /* * If the state is LIST_DIRTY then we have no useful information in our list @@ -827,9 +827,9 @@ nsContentList::Match(Element *aElement) bool nsContentList::MatchSelf(nsIContent *aContent) { - NS_PRECONDITION(aContent, "Can't match null stuff, you know"); - NS_PRECONDITION(mDeep || aContent->GetParentNode() == mRootNode, - "MatchSelf called on a node that we can't possibly match"); + MOZ_ASSERT(aContent, "Can't match null stuff, you know"); + MOZ_ASSERT(mDeep || aContent->GetParentNode() == mRootNode, + "MatchSelf called on a node that we can't possibly match"); if (!aContent->IsElement()) { return false; diff --git a/dom/base/nsContentList.h b/dom/base/nsContentList.h index 6e47026cee17..542284532c67 100644 --- a/dom/base/nsContentList.h +++ b/dom/base/nsContentList.h @@ -387,8 +387,8 @@ public: // most common namespace id is kNameSpaceID_Unknown. So check the // string first. Cases in which whether our root's ownerDocument // is HTML changes are extremely rare, so check those last. - NS_PRECONDITION(mXMLMatchAtom, - "How did we get here with a null match atom on our list?"); + MOZ_ASSERT(mXMLMatchAtom, + "How did we get here with a null match atom on our list?"); return mXMLMatchAtom->Equals(aKey.mTagname) && mRootNode == aKey.mRootNode && diff --git a/dom/base/nsContentPolicy.cpp b/dom/base/nsContentPolicy.cpp index 859018a23f24..9c338b0526ad 100644 --- a/dom/base/nsContentPolicy.cpp +++ b/dom/base/nsContentPolicy.cpp @@ -88,7 +88,7 @@ nsContentPolicy::CheckPolicy(CPMethod policyMethod, } //sanity-check passed-through parameters - NS_PRECONDITION(decision, "Null out pointer"); + MOZ_ASSERT(decision, "Null out pointer"); WARN_IF_URI_UNINITIALIZED(contentLocation, "Request URI"); WARN_IF_URI_UNINITIALIZED(requestingLocation, "Requesting URI"); @@ -208,7 +208,7 @@ nsContentPolicy::ShouldLoad(nsIURI *contentLocation, int16_t *decision) { // ShouldProcess does not need a content location, but we do - NS_PRECONDITION(contentLocation, "Must provide request location"); + MOZ_ASSERT(contentLocation, "Must provide request location"); nsresult rv = CheckPolicy(&nsIContentPolicy::ShouldLoad, contentLocation, loadInfo, mimeType, decision); diff --git a/dom/base/nsContentSink.cpp b/dom/base/nsContentSink.cpp index 6e8fa1fa5fae..33d4436ba1e3 100644 --- a/dom/base/nsContentSink.cpp +++ b/dom/base/nsContentSink.cpp @@ -195,8 +195,8 @@ nsContentSink::Init(nsIDocument* aDoc, nsISupports* aContainer, nsIChannel* aChannel) { - NS_PRECONDITION(aDoc, "null ptr"); - NS_PRECONDITION(aURI, "null ptr"); + MOZ_ASSERT(aDoc, "null ptr"); + MOZ_ASSERT(aURI, "null ptr"); if (!aDoc || !aURI) { return NS_ERROR_NULL_POINTER; diff --git a/dom/base/nsContentUtils.cpp b/dom/base/nsContentUtils.cpp index ba8329b6abe2..535195ee3b6a 100644 --- a/dom/base/nsContentUtils.cpp +++ b/dom/base/nsContentUtils.cpp @@ -770,7 +770,7 @@ nsresult nsContentUtils::RemoveWyciwygScheme(nsIURI* aURI, nsIURI** aReturn) #ifdef DEBUG bool isWyciwyg = false; aURI->SchemeIs("wyciwyg", &isWyciwyg); - NS_PRECONDITION(isWyciwyg, "Scheme should be wyciwyg"); + MOZ_ASSERT(isWyciwyg, "Scheme should be wyciwyg"); #endif nsAutoCString path; nsresult rv = aURI->GetPathQueryRef(path); @@ -1061,7 +1061,7 @@ nsContentUtils::Atob(const nsAString& aAsciiBase64String, bool nsContentUtils::IsAutocompleteEnabled(mozilla::dom::HTMLInputElement* aInput) { - NS_PRECONDITION(aInput, "aInput should not be null!"); + MOZ_ASSERT(aInput, "aInput should not be null!"); nsAutoString autocomplete; aInput->GetAutocomplete(autocomplete); @@ -2193,7 +2193,7 @@ nsContentUtils::IsAbsoluteURL(const nsACString& aURL) bool nsContentUtils::InProlog(nsINode *aNode) { - NS_PRECONDITION(aNode, "missing node to nsContentUtils::InProlog"); + MOZ_ASSERT(aNode, "missing node to nsContentUtils::InProlog"); nsINode* parent = aNode->GetParentNode(); if (!parent || !parent->IsDocument()) { @@ -2391,7 +2391,7 @@ nsContentUtils::LookupBindingMember(JSContext* aCx, nsIContent *aContent, nsINode* nsContentUtils::GetCrossDocParentNode(nsINode* aChild) { - NS_PRECONDITION(aChild, "The child is null!"); + MOZ_ASSERT(aChild, "The child is null!"); nsINode* parent = aChild->GetParentNode(); if (parent && parent->IsContent() && aChild->IsContent()) { @@ -2412,8 +2412,8 @@ bool nsContentUtils::ContentIsDescendantOf(const nsINode* aPossibleDescendant, const nsINode* aPossibleAncestor) { - NS_PRECONDITION(aPossibleDescendant, "The possible descendant is null!"); - NS_PRECONDITION(aPossibleAncestor, "The possible ancestor is null!"); + MOZ_ASSERT(aPossibleDescendant, "The possible descendant is null!"); + MOZ_ASSERT(aPossibleAncestor, "The possible ancestor is null!"); do { if (aPossibleDescendant == aPossibleAncestor) @@ -2428,8 +2428,8 @@ bool nsContentUtils::ContentIsHostIncludingDescendantOf( const nsINode* aPossibleDescendant, const nsINode* aPossibleAncestor) { - NS_PRECONDITION(aPossibleDescendant, "The possible descendant is null!"); - NS_PRECONDITION(aPossibleAncestor, "The possible ancestor is null!"); + MOZ_ASSERT(aPossibleDescendant, "The possible descendant is null!"); + MOZ_ASSERT(aPossibleAncestor, "The possible ancestor is null!"); do { if (aPossibleDescendant == aPossibleAncestor) @@ -2478,8 +2478,8 @@ bool nsContentUtils::ContentIsCrossDocDescendantOf(nsINode* aPossibleDescendant, nsINode* aPossibleAncestor) { - NS_PRECONDITION(aPossibleDescendant, "The possible descendant is null!"); - NS_PRECONDITION(aPossibleAncestor, "The possible ancestor is null!"); + MOZ_ASSERT(aPossibleDescendant, "The possible descendant is null!"); + MOZ_ASSERT(aPossibleAncestor, "The possible ancestor is null!"); do { if (aPossibleDescendant == aPossibleAncestor) @@ -2497,8 +2497,8 @@ nsContentUtils::ContentIsFlattenedTreeDescendantOf( const nsINode* aPossibleDescendant, const nsINode* aPossibleAncestor) { - NS_PRECONDITION(aPossibleDescendant, "The possible descendant is null!"); - NS_PRECONDITION(aPossibleAncestor, "The possible ancestor is null!"); + MOZ_ASSERT(aPossibleDescendant, "The possible descendant is null!"); + MOZ_ASSERT(aPossibleAncestor, "The possible ancestor is null!"); do { if (aPossibleDescendant == aPossibleAncestor) { @@ -2516,8 +2516,8 @@ nsContentUtils::ContentIsFlattenedTreeDescendantOfForStyle( const nsINode* aPossibleDescendant, const nsINode* aPossibleAncestor) { - NS_PRECONDITION(aPossibleDescendant, "The possible descendant is null!"); - NS_PRECONDITION(aPossibleAncestor, "The possible ancestor is null!"); + MOZ_ASSERT(aPossibleDescendant, "The possible descendant is null!"); + MOZ_ASSERT(aPossibleAncestor, "The possible ancestor is null!"); do { if (aPossibleDescendant == aPossibleAncestor) { @@ -3451,9 +3451,9 @@ nsContentUtils::CanLoadImage(nsIURI* aURI, nsINode* aNode, int16_t* aImageBlockingStatus, uint32_t aContentType) { - NS_PRECONDITION(aURI, "Must have a URI"); - NS_PRECONDITION(aLoadingDocument, "Must have a document"); - NS_PRECONDITION(aLoadingPrincipal, "Must have a loading principal"); + MOZ_ASSERT(aURI, "Must have a URI"); + MOZ_ASSERT(aLoadingDocument, "Must have a document"); + MOZ_ASSERT(aLoadingPrincipal, "Must have a loading principal"); nsresult rv; @@ -3676,11 +3676,11 @@ nsContentUtils::LoadImage(nsIURI* aURI, nsINode* aContext, uint32_t aContentPolicyType, bool aUseUrgentStartForChannel) { - NS_PRECONDITION(aURI, "Must have a URI"); - NS_PRECONDITION(aContext, "Must have a context"); - NS_PRECONDITION(aLoadingDocument, "Must have a document"); - NS_PRECONDITION(aLoadingPrincipal, "Must have a principal"); - NS_PRECONDITION(aRequest, "Null out param"); + MOZ_ASSERT(aURI, "Must have a URI"); + MOZ_ASSERT(aContext, "Must have a context"); + MOZ_ASSERT(aLoadingDocument, "Must have a document"); + MOZ_ASSERT(aLoadingPrincipal, "Must have a principal"); + MOZ_ASSERT(aRequest, "Null out param"); imgLoader* imgLoader = GetImgLoaderForDocument(aLoadingDocument); if (!imgLoader) { @@ -3788,7 +3788,7 @@ nsContentUtils::ContentIsDraggable(nsIContent* aContent) bool nsContentUtils::IsDraggableImage(nsIContent* aContent) { - NS_PRECONDITION(aContent, "Must have content node to test"); + MOZ_ASSERT(aContent, "Must have content node to test"); nsCOMPtr imageContent(do_QueryInterface(aContent)); if (!imageContent) { @@ -4590,7 +4590,7 @@ nsContentUtils::MatchElementId(nsIContent *aContent, const nsAtom* aId) Element * nsContentUtils::MatchElementId(nsIContent *aContent, const nsAString& aId) { - NS_PRECONDITION(!aId.IsEmpty(), "Will match random elements"); + MOZ_ASSERT(!aId.IsEmpty(), "Will match random elements"); // ID attrs are generally stored as atoms, so just atomize this up front RefPtr id(NS_Atomize(aId)); @@ -4737,9 +4737,9 @@ void nsContentUtils::MaybeFireNodeRemoved(nsINode* aChild, nsINode* aParent, nsIDocument* aOwnerDoc) { - NS_PRECONDITION(aChild, "Missing child"); - NS_PRECONDITION(aChild->GetParentNode() == aParent, "Wrong parent"); - NS_PRECONDITION(aChild->OwnerDoc() == aOwnerDoc, "Wrong owner-doc"); + MOZ_ASSERT(aChild, "Missing child"); + MOZ_ASSERT(aChild->GetParentNode() == aParent, "Wrong parent"); + MOZ_ASSERT(aChild->OwnerDoc() == aOwnerDoc, "Wrong owner-doc"); // Having an explicit check here since it's an easy mistake to fall into, // and there might be existing code with problems. We'd rather be safe @@ -5407,10 +5407,8 @@ bool nsContentUtils::IsInSameAnonymousTree(const nsINode* aNode, const nsIContent* aContent) { - NS_PRECONDITION(aNode, - "Must have a node to work with"); - NS_PRECONDITION(aContent, - "Must have a content to work with"); + MOZ_ASSERT(aNode, "Must have a node to work with"); + MOZ_ASSERT(aContent, "Must have a content to work with"); if (!aNode->IsContent()) { /** @@ -5494,7 +5492,7 @@ nsContentUtils::TriggerLink(nsIContent *aContent, nsPresContext *aPresContext, bool aClick, bool aIsTrusted) { NS_ASSERTION(aPresContext, "Need a nsPresContext"); - NS_PRECONDITION(aLinkURI, "No link URI"); + MOZ_ASSERT(aLinkURI, "No link URI"); if (aContent->IsEditable()) { return; @@ -6279,7 +6277,7 @@ SameOriginCheckerImpl::AsyncOnChannelRedirect(nsIChannel* aOldChannel, uint32_t aFlags, nsIAsyncVerifyRedirectCallback* cb) { - NS_PRECONDITION(aNewChannel, "Redirecting to null channel?"); + MOZ_ASSERT(aNewChannel, "Redirecting to null channel?"); nsresult rv = nsContentUtils::CheckSameOrigin(aOldChannel, aNewChannel); if (NS_SUCCEEDED(rv)) { @@ -6299,7 +6297,7 @@ SameOriginCheckerImpl::GetInterface(const nsIID& aIID, void** aResult) nsresult nsContentUtils::GetASCIIOrigin(nsIPrincipal* aPrincipal, nsACString& aOrigin) { - NS_PRECONDITION(aPrincipal, "missing principal"); + MOZ_ASSERT(aPrincipal, "missing principal"); aOrigin.Truncate(); @@ -6320,7 +6318,7 @@ nsContentUtils::GetASCIIOrigin(nsIPrincipal* aPrincipal, nsACString& aOrigin) nsresult nsContentUtils::GetASCIIOrigin(nsIURI* aURI, nsACString& aOrigin) { - NS_PRECONDITION(aURI, "missing uri"); + MOZ_ASSERT(aURI, "missing uri"); // For Blob URI we have to return the origin of page using its principal. nsCOMPtr uriWithPrincipal = do_QueryInterface(aURI); @@ -6374,7 +6372,7 @@ nsContentUtils::GetASCIIOrigin(nsIURI* aURI, nsACString& aOrigin) nsresult nsContentUtils::GetUTFOrigin(nsIPrincipal* aPrincipal, nsAString& aOrigin) { - NS_PRECONDITION(aPrincipal, "missing principal"); + MOZ_ASSERT(aPrincipal, "missing principal"); aOrigin.Truncate(); @@ -6395,7 +6393,7 @@ nsContentUtils::GetUTFOrigin(nsIPrincipal* aPrincipal, nsAString& aOrigin) nsresult nsContentUtils::GetUTFOrigin(nsIURI* aURI, nsAString& aOrigin) { - NS_PRECONDITION(aURI, "missing uri"); + MOZ_ASSERT(aURI, "missing uri"); bool isBlobURL = false; nsresult rv = aURI->SchemeIs(BLOBURI_SCHEME, &isBlobURL); diff --git a/dom/base/nsContentUtils.h b/dom/base/nsContentUtils.h index 0d9db1a38536..aedc9d615d4f 100644 --- a/dom/base/nsContentUtils.h +++ b/dom/base/nsContentUtils.h @@ -2191,7 +2191,7 @@ public: static already_AddRefed GetElementsByClassName(nsINode* aRootNode, const nsAString& aClasses) { - NS_PRECONDITION(aRootNode, "Must have root node"); + MOZ_ASSERT(aRootNode, "Must have root node"); return GetFuncStringContentList(aRootNode, MatchClassNames, diff --git a/dom/base/nsDocument.cpp b/dom/base/nsDocument.cpp index 1e4917009555..40a846f801b1 100644 --- a/dom/base/nsDocument.cpp +++ b/dom/base/nsDocument.cpp @@ -505,8 +505,8 @@ struct PositionComparator bool nsIdentifierMapEntry::AddIdElement(Element* aElement) { - NS_PRECONDITION(aElement, "Must have element"); - NS_PRECONDITION(!mIdContentList.Contains(nullptr), + MOZ_ASSERT(aElement, "Must have element"); + MOZ_ASSERT(!mIdContentList.Contains(nullptr), "Why is null in our list?"); #ifdef DEBUG @@ -549,7 +549,7 @@ nsIdentifierMapEntry::AddIdElement(Element* aElement) void nsIdentifierMapEntry::RemoveIdElement(Element* aElement) { - NS_PRECONDITION(aElement, "Missing element"); + MOZ_ASSERT(aElement, "Missing element"); // This should only be called while the document is in an update. // Assertions near the call to this method guarantee this. @@ -820,8 +820,8 @@ nsExternalResourceMap::RequestResource(nsIURI* aURI, // If we ever start allowing non-same-origin loads here, we might need to do // something interesting with aRequestingPrincipal even for the hashtable // gets. - NS_PRECONDITION(aURI, "Must have a URI"); - NS_PRECONDITION(aRequestingNode, "Must have a node"); + MOZ_ASSERT(aURI, "Must have a URI"); + MOZ_ASSERT(aRequestingNode, "Must have a node"); *aPendingLoad = nullptr; if (mHaveShutDown) { return nullptr; @@ -958,9 +958,9 @@ nsExternalResourceMap::AddExternalResource(nsIURI* aURI, nsILoadGroup* aLoadGroup, nsIDocument* aDisplayDocument) { - NS_PRECONDITION(aURI, "Unexpected call"); - NS_PRECONDITION((aViewer && aLoadGroup) || (!aViewer && !aLoadGroup), - "Must have both or neither"); + MOZ_ASSERT(aURI, "Unexpected call"); + MOZ_ASSERT((aViewer && aLoadGroup) || (!aViewer && !aLoadGroup), + "Must have both or neither"); RefPtr load; mPendingLoads.Remove(aURI, getter_AddRefs(load)); @@ -1050,7 +1050,7 @@ nsExternalResourceMap::PendingLoad::SetupViewer(nsIRequest* aRequest, nsIContentViewer** aViewer, nsILoadGroup** aLoadGroup) { - NS_PRECONDITION(!mTargetListener, "Unexpected call to OnStartRequest"); + MOZ_ASSERT(!mTargetListener, "Unexpected call to OnStartRequest"); *aViewer = nullptr; *aLoadGroup = nullptr; @@ -1161,8 +1161,8 @@ nsresult nsExternalResourceMap::PendingLoad::StartLoad(nsIURI* aURI, nsINode* aRequestingNode) { - NS_PRECONDITION(aURI, "Must have a URI"); - NS_PRECONDITION(aRequestingNode, "Must have a node"); + MOZ_ASSERT(aURI, "Must have a URI"); + MOZ_ASSERT(aRequestingNode, "Must have a node"); nsCOMPtr loadGroup = aRequestingNode->OwnerDoc()->GetDocumentLoadGroup(); @@ -1754,7 +1754,7 @@ NS_IMPL_CYCLE_COLLECTING_ADDREF(nsDocument) NS_IMETHODIMP_(MozExternalRefCountType) nsDocument::Release() { - NS_PRECONDITION(0 != mRefCnt, "dup release"); + MOZ_ASSERT(0 != mRefCnt, "dup release"); NS_ASSERT_OWNINGTHREAD(nsDocument); nsISupports* base = NS_CYCLE_COLLECTION_CLASSNAME(nsDocument)::Upcast(this); bool shouldDelete = false; @@ -2229,7 +2229,7 @@ nsIDocument::ResetToURI(nsIURI* aURI, nsILoadGroup* aLoadGroup, nsIPrincipal* aPrincipal) { - NS_PRECONDITION(aURI, "Null URI passed to ResetToURI"); + MOZ_ASSERT(aURI, "Null URI passed to ResetToURI"); MOZ_LOG(gDocumentLeakPRLog, LogLevel::Debug, ("DOCUMENT %p ResetToURI %s", this, aURI->GetSpecOrDefault().get())); @@ -2532,9 +2532,9 @@ AppendSheetsToStyleSet(ServoStyleSet* aStyleSet, void nsIDocument::FillStyleSet(ServoStyleSet* aStyleSet) { - NS_PRECONDITION(aStyleSet, "Must have a style set"); - NS_PRECONDITION(aStyleSet->SheetCount(SheetType::Doc) == 0, - "Style set already has document sheets?"); + MOZ_ASSERT(aStyleSet, "Must have a style set"); + MOZ_ASSERT(aStyleSet->SheetCount(SheetType::Doc) == 0, + "Style set already has document sheets?"); MOZ_ASSERT(!mStyleSetFilled); @@ -4381,7 +4381,7 @@ nsIDocument::RemoveStyleSheetFromStyleSets(StyleSheet* aSheet) void nsIDocument::RemoveStyleSheet(StyleSheet* aSheet) { - NS_PRECONDITION(aSheet, "null arg"); + MOZ_ASSERT(aSheet, "null arg"); RefPtr sheet = aSheet; // hold ref so it won't die too soon if (!mStyleSheets.RemoveElement(aSheet)) { @@ -4407,8 +4407,8 @@ nsIDocument::UpdateStyleSheets(nsTArray>& aOldSheets, BeginUpdate(UPDATE_STYLE); // XXX Need to set the sheet on the ownernode, if any - NS_PRECONDITION(aOldSheets.Length() == aNewSheets.Length(), - "The lists must be the same length!"); + MOZ_ASSERT(aOldSheets.Length() == aNewSheets.Length(), + "The lists must be the same length!"); int32_t count = aOldSheets.Length(); RefPtr oldSheet; @@ -4459,7 +4459,7 @@ nsIDocument::InsertStyleSheetAt(StyleSheet* aSheet, size_t aIndex) void nsIDocument::SetStyleSheetApplicableState(StyleSheet* aSheet, bool aApplicable) { - NS_PRECONDITION(aSheet, "null arg"); + MOZ_ASSERT(aSheet, "null arg"); // If we're actually in the document style sheet list if (mStyleSheets.IndexOf(aSheet) != mStyleSheets.NoIndex) { @@ -4543,7 +4543,7 @@ nsresult nsIDocument::LoadAdditionalStyleSheet(additionalSheetType aType, nsIURI* aSheetURI) { - NS_PRECONDITION(aSheetURI, "null arg"); + MOZ_ASSERT(aSheetURI, "null arg"); // Checking if we have loaded this one already. if (FindSheet(mAdditionalSheets[aType], aSheetURI) >= 0) @@ -5478,8 +5478,8 @@ nsIDocument::UnblockDOMContentLoaded() void nsIDocument::ContentStateChanged(nsIContent* aContent, EventStates aStateMask) { - NS_PRECONDITION(!nsContentUtils::IsSafeToRunScript(), - "Someone forgot a scriptblocker"); + MOZ_ASSERT(!nsContentUtils::IsSafeToRunScript(), + "Someone forgot a scriptblocker"); NS_DOCUMENT_NOTIFY_OBSERVERS(ContentStateChanged, (this, aContent, aStateMask)); } @@ -6746,8 +6746,8 @@ nsIDocument::RequestExternalResource(nsIURI* aURI, nsINode* aRequestingNode, ExternalResourceLoad** aPendingLoad) { - NS_PRECONDITION(aURI, "Must have a URI"); - NS_PRECONDITION(aRequestingNode, "Must have a node"); + MOZ_ASSERT(aURI, "Must have a URI"); + MOZ_ASSERT(aRequestingNode, "Must have a node"); if (mDisplayDocument) { return mDisplayDocument->RequestExternalResource(aURI, aRequestingNode, @@ -6921,7 +6921,7 @@ bool nsIDocument::MatchNameAttribute(Element* aElement, int32_t aNamespaceID, nsAtom* aAtom, void* aData) { - NS_PRECONDITION(aElement, "Must have element to work with!"); + MOZ_ASSERT(aElement, "Must have element to work with!"); if (!aElement->HasName()) { return false; @@ -8392,11 +8392,11 @@ nsIDocument::PostUnblockOnloadEvent() void nsIDocument::DoUnblockOnload() { - NS_PRECONDITION(!mDisplayDocument, + MOZ_ASSERT(!mDisplayDocument, "Shouldn't get here for resource document"); - NS_PRECONDITION(mOnloadBlockCount != 0, - "Shouldn't have a count of zero here, since we stabilized in " - "PostUnblockOnloadEvent"); + MOZ_ASSERT(mOnloadBlockCount != 0, + "Shouldn't have a count of zero here, since we stabilized in " + "PostUnblockOnloadEvent"); --mOnloadBlockCount; diff --git a/dom/base/nsDocumentEncoder.cpp b/dom/base/nsDocumentEncoder.cpp index f7a534646ab7..36d744fb2036 100644 --- a/dom/base/nsDocumentEncoder.cpp +++ b/dom/base/nsDocumentEncoder.cpp @@ -99,7 +99,7 @@ protected: bool IsVisibleNode(nsINode* aNode) { - NS_PRECONDITION(aNode, ""); + MOZ_ASSERT(aNode, "null node"); if (mFlags & SkipInvisibleContent) { // Treat the visibility of the ShadowRoot as if it were @@ -1754,7 +1754,7 @@ nsHTMLCopyEncoder::GetChildAt(nsINode *aParent, int32_t aOffset) return resultNode; nsCOMPtr content = do_QueryInterface(aParent); - NS_PRECONDITION(content, "null content in nsHTMLCopyEncoder::GetChildAt"); + MOZ_ASSERT(content, "null content in nsHTMLCopyEncoder::GetChildAt"); resultNode = content->GetChildAt_Deprecated(aOffset); diff --git a/dom/base/nsFocusManager.cpp b/dom/base/nsFocusManager.cpp index 864c76402cb1..0482b45b4f58 100644 --- a/dom/base/nsFocusManager.cpp +++ b/dom/base/nsFocusManager.cpp @@ -1563,8 +1563,8 @@ nsFocusManager::IsWindowVisible(nsPIDOMWindowOuter* aWindow) bool nsFocusManager::IsNonFocusableRoot(nsIContent* aContent) { - NS_PRECONDITION(aContent, "aContent must not be NULL"); - NS_PRECONDITION(aContent->IsInComposedDoc(), "aContent must be in a document"); + MOZ_ASSERT(aContent, "aContent must not be NULL"); + MOZ_ASSERT(aContent->IsInComposedDoc(), "aContent must be in a document"); // If aContent is in designMode, the root element is not focusable. // NOTE: in designMode, most elements are not focusable, just the document is diff --git a/dom/base/nsFrameLoader.cpp b/dom/base/nsFrameLoader.cpp index 5eb11d6cba7c..56a558a5b6a2 100644 --- a/dom/base/nsFrameLoader.cpp +++ b/dom/base/nsFrameLoader.cpp @@ -630,7 +630,7 @@ SetTreeOwnerAndChromeEventHandlerOnDocshellTree(nsIDocShellTreeItem* aItem, nsIDocShellTreeOwner* aOwner, EventTarget* aHandler) { - NS_PRECONDITION(aItem, "Must have item"); + MOZ_ASSERT(aItem, "Must have item"); aItem->SetTreeOwner(aOwner); @@ -662,8 +662,8 @@ nsFrameLoader::AddTreeItemToTreeOwner(nsIDocShellTreeItem* aItem, int32_t aParentType, nsIDocShell* aParentNode) { - NS_PRECONDITION(aItem, "Must have docshell treeitem"); - NS_PRECONDITION(mOwnerContent, "Must have owning content"); + MOZ_ASSERT(aItem, "Must have docshell treeitem"); + MOZ_ASSERT(mOwnerContent, "Must have owning content"); nsAutoString value; bool isContent = mOwnerContent->AttrValueIs( diff --git a/dom/base/nsGenConImageContent.cpp b/dom/base/nsGenConImageContent.cpp index 366abdb1b6cf..324f83ee754a 100644 --- a/dom/base/nsGenConImageContent.cpp +++ b/dom/base/nsGenConImageContent.cpp @@ -91,7 +91,7 @@ namespace dom { already_AddRefed CreateGenConImageContent(nsIDocument* aDocument, imgRequestProxy* aImageRequest) { - NS_PRECONDITION(aImageRequest, "Must have request!"); + MOZ_ASSERT(aImageRequest, "Must have request!"); RefPtr nodeInfo = aDocument->NodeInfoManager()-> GetNodeInfo(nsGkAtoms::mozgeneratedcontentimage, diff --git a/dom/base/nsGlobalWindowInner.cpp b/dom/base/nsGlobalWindowInner.cpp index b469fcdad956..e1887b473911 100644 --- a/dom/base/nsGlobalWindowInner.cpp +++ b/dom/base/nsGlobalWindowInner.cpp @@ -1667,8 +1667,8 @@ nsGlobalWindowInner::SetNewDocument(nsIDocument* aDocument, nsISupports* aState, bool aForceReuseInnerWindow) { - NS_PRECONDITION(mDocumentPrincipal == nullptr, - "mDocumentPrincipal prematurely set!"); + MOZ_ASSERT(mDocumentPrincipal == nullptr, + "mDocumentPrincipal prematurely set!"); MOZ_ASSERT(aDocument); if (!mOuterWindow) { @@ -4780,7 +4780,7 @@ public: NS_IMETHOD Run() override { - NS_PRECONDITION(NS_IsMainThread(), "Should be called on the main thread."); + MOZ_ASSERT(NS_IsMainThread(), "Should be called on the main thread."); return mWindow->FireHashchange(mOldURL, mNewURL); } diff --git a/dom/base/nsGlobalWindowOuter.cpp b/dom/base/nsGlobalWindowOuter.cpp index fdd9c3dc8fc9..e296afd96fcc 100644 --- a/dom/base/nsGlobalWindowOuter.cpp +++ b/dom/base/nsGlobalWindowOuter.cpp @@ -1415,7 +1415,7 @@ WindowStateHolder::WindowStateHolder(nsGlobalWindowInner* aWindow) : mInnerWindow(aWindow), mInnerWindowReflector(RootingCx(), aWindow->GetWrapper()) { - NS_PRECONDITION(aWindow, "null window"); + MOZ_ASSERT(aWindow, "null window"); aWindow->Suspend(); @@ -1640,7 +1640,7 @@ nsGlobalWindowOuter::SetNewDocument(nsIDocument* aDocument, nsISupports* aState, bool aForceReuseInnerWindow) { - NS_PRECONDITION(mDocumentPrincipal == nullptr, + MOZ_ASSERT(mDocumentPrincipal == nullptr, "mDocumentPrincipal prematurely set!"); MOZ_ASSERT(aDocument); @@ -3850,7 +3850,7 @@ nsGlobalWindowOuter::WindowExists(const nsAString& aName, bool aForceNoOpener, bool aLookForCallerOnJSStack) { - NS_PRECONDITION(mDocShell, "Must have docshell"); + MOZ_ASSERT(mDocShell, "Must have docshell"); if (aForceNoOpener) { return aName.LowerCaseEqualsLiteral("_self") || @@ -6901,10 +6901,11 @@ nsGlobalWindowOuter::OpenInternal(const nsAString& aUrl, const nsAString& aName, if (argv) argv->GetLength(&argc); #endif - NS_PRECONDITION(!aExtraArgument || (!argv && argc == 0), - "Can't pass in arguments both ways"); - NS_PRECONDITION(!aCalledNoScript || (!argv && argc == 0), - "Can't pass JS args when called via the noscript methods"); + + MOZ_ASSERT(!aExtraArgument || (!argv && argc == 0), + "Can't pass in arguments both ways"); + MOZ_ASSERT(!aCalledNoScript || (!argv && argc == 0), + "Can't pass JS args when called via the noscript methods"); mozilla::Maybe closeUnblocker; @@ -7731,4 +7732,3 @@ nsAutoPopupStatePusherInternal::~nsAutoPopupStatePusherInternal() { nsContentUtils::PopPopupControlState(mOldState); } - diff --git a/dom/base/nsImageLoadingContent.cpp b/dom/base/nsImageLoadingContent.cpp index c9a484fc92d8..1c15219bf873 100644 --- a/dom/base/nsImageLoadingContent.cpp +++ b/dom/base/nsImageLoadingContent.cpp @@ -148,8 +148,8 @@ nsImageLoadingContent::Notify(imgIRequest* aRequest, // We should definitely have a request here MOZ_ASSERT(aRequest, "no request?"); - NS_PRECONDITION(aRequest == mCurrentRequest || aRequest == mPendingRequest, - "Unknown request"); + MOZ_ASSERT(aRequest == mCurrentRequest || aRequest == mPendingRequest, + "Unknown request"); } { @@ -342,7 +342,7 @@ nsImageLoadingContent::SetLoadingEnabled(bool aLoadingEnabled) NS_IMETHODIMP nsImageLoadingContent::GetImageBlockingStatus(int16_t* aStatus) { - NS_PRECONDITION(aStatus, "Null out param"); + MOZ_ASSERT(aStatus, "Null out param"); *aStatus = ImageBlockingStatus(); return NS_OK; } @@ -719,7 +719,7 @@ NS_IMETHODIMP nsImageLoadingContent::GetRequestType(imgIRequest* aRequest, int32_t* aRequestType) { - NS_PRECONDITION(aRequestType, "Null out param"); + MOZ_ASSERT(aRequestType, "Null out param"); ErrorResult result; *aRequestType = GetRequestType(aRequest, result); @@ -1239,8 +1239,8 @@ nsImageLoadingContent::StringToURI(const nsAString& aSpec, nsIDocument* aDocument, nsIURI** aURI) { - NS_PRECONDITION(aDocument, "Must have a document"); - NS_PRECONDITION(aURI, "Null out param"); + MOZ_ASSERT(aDocument, "Must have a document"); + MOZ_ASSERT(aURI, "Null out param"); // (1) Get the base URI nsIContent* thisContent = AsContent(); @@ -1748,4 +1748,4 @@ mozilla::net::ReferrerPolicy nsImageLoadingContent::GetImageReferrerPolicy() { return mozilla::net::RP_Unset; -}; +} diff --git a/dom/base/nsJSEnvironment.cpp b/dom/base/nsJSEnvironment.cpp index 8e963ea4fc1b..f6f0226316a9 100644 --- a/dom/base/nsJSEnvironment.cpp +++ b/dom/base/nsJSEnvironment.cpp @@ -814,7 +814,7 @@ nsJSContext::ConvertSupportsTojsvals(nsISupports* aArgs, nsresult nsJSContext::AddSupportsPrimitiveTojsvals(nsISupports *aArg, JS::Value *aArgv) { - NS_PRECONDITION(aArg, "Empty arg"); + MOZ_ASSERT(aArg, "Empty arg"); nsCOMPtr argPrimitive(do_QueryInterface(aArg)); if (!argPrimitive) diff --git a/dom/base/nsMappedAttributes.cpp b/dom/base/nsMappedAttributes.cpp index 9a8021f17e2d..825058e517ee 100644 --- a/dom/base/nsMappedAttributes.cpp +++ b/dom/base/nsMappedAttributes.cpp @@ -152,7 +152,7 @@ void nsMappedAttributes::SetAndSwapAttr(nsAtom* aAttrName, nsAttrValue& aValue, bool* aValueWasSet) { - NS_PRECONDITION(aAttrName, "null name"); + MOZ_ASSERT(aAttrName, "null name"); *aValueWasSet = false; uint32_t i; for (i = 0; i < mAttrCount && !Attrs()[i].mName.IsSmaller(aAttrName); ++i) { @@ -178,7 +178,7 @@ nsMappedAttributes::SetAndSwapAttr(nsAtom* aAttrName, nsAttrValue& aValue, const nsAttrValue* nsMappedAttributes::GetAttr(nsAtom* aAttrName) const { - NS_PRECONDITION(aAttrName, "null name"); + MOZ_ASSERT(aAttrName, "null name"); for (uint32_t i = 0; i < mAttrCount; ++i) { if (Attrs()[i].mName.Equals(aAttrName)) { diff --git a/dom/base/nsNameSpaceManager.cpp b/dom/base/nsNameSpaceManager.cpp index 727cdfda7b69..007cab810d3f 100644 --- a/dom/base/nsNameSpaceManager.cpp +++ b/dom/base/nsNameSpaceManager.cpp @@ -126,7 +126,7 @@ nsNameSpaceManager::RegisterNameSpace(already_AddRefed aURI, nsresult nsNameSpaceManager::GetNameSpaceURI(int32_t aNameSpaceID, nsAString& aURI) { - NS_PRECONDITION(aNameSpaceID >= 0, "Bogus namespace ID"); + MOZ_ASSERT(aNameSpaceID >= 0, "Bogus namespace ID"); // We have historically treated GetNameSpaceURI calls for kNameSpaceID_None // as erroneous. diff --git a/dom/base/nsNodeInfoManager.cpp b/dom/base/nsNodeInfoManager.cpp index 2ca31c21784e..5ef019fa97cb 100644 --- a/dom/base/nsNodeInfoManager.cpp +++ b/dom/base/nsNodeInfoManager.cpp @@ -107,7 +107,7 @@ NS_IMPL_CYCLE_COLLECTION_CAN_SKIP_THIS_END nsresult nsNodeInfoManager::Init(nsIDocument *aDocument) { - NS_PRECONDITION(!mPrincipal, + MOZ_ASSERT(!mPrincipal, "Being inited when we already have a principal?"); mPrincipal = NullPrincipal::CreateWithoutOriginAttributes(); @@ -319,7 +319,7 @@ nsNodeInfoManager::SetDocumentPrincipal(nsIPrincipal *aPrincipal) void nsNodeInfoManager::RemoveNodeInfo(NodeInfo *aNodeInfo) { - NS_PRECONDITION(aNodeInfo, "Trying to remove null nodeinfo from manager!"); + MOZ_ASSERT(aNodeInfo, "Trying to remove null nodeinfo from manager!"); if (aNodeInfo == mDocumentNodeInfo) { mDocumentNodeInfo = nullptr; diff --git a/dom/base/nsNodeUtils.cpp b/dom/base/nsNodeUtils.cpp index 2e47452a623e..9625c3a71dee 100644 --- a/dom/base/nsNodeUtils.cpp +++ b/dom/base/nsNodeUtils.cpp @@ -210,8 +210,8 @@ void nsNodeUtils::ContentInserted(nsINode* aContainer, nsIContent* aChild) { - NS_PRECONDITION(aContainer->IsContent() || aContainer->IsDocument(), - "container must be an nsIContent or an nsIDocument"); + MOZ_ASSERT(aContainer->IsContent() || aContainer->IsDocument(), + "container must be an nsIContent or an nsIDocument"); nsIDocument* doc = aContainer->OwnerDoc(); IMPL_MUTATION_NOTIFICATION(ContentInserted, aContainer, (aChild), IsRemoveNotification::No); @@ -222,8 +222,8 @@ nsNodeUtils::ContentRemoved(nsINode* aContainer, nsIContent* aChild, nsIContent* aPreviousSibling) { - NS_PRECONDITION(aContainer->IsContent() || aContainer->IsDocument(), - "container must be an nsIContent or an nsIDocument"); + MOZ_ASSERT(aContainer->IsContent() || aContainer->IsDocument(), + "container must be an nsIContent or an nsIDocument"); nsIDocument* doc = aContainer->OwnerDoc(); MOZ_ASSERT(aChild->GetParentNode() == aContainer, "We expect the parent link to be still around at this point"); @@ -383,11 +383,10 @@ nsNodeUtils::CloneAndAdopt(nsINode *aNode, bool aClone, bool aDeep, nsCOMArray *aNodesWithProperties, nsINode* aParent, ErrorResult& aError) { - NS_PRECONDITION((!aClone && aNewNodeInfoManager) || !aReparentScope, - "If cloning or not getting a new nodeinfo we shouldn't " - "rewrap"); - NS_PRECONDITION(!aParent || aNode->IsContent(), - "Can't insert document or attribute nodes into a parent"); + MOZ_ASSERT((!aClone && aNewNodeInfoManager) || !aReparentScope, + "If cloning or not getting a new nodeinfo we shouldn't rewrap"); + MOZ_ASSERT(!aParent || aNode->IsContent(), + "Can't insert document or attribute nodes into a parent"); // First deal with aNode and walk its attributes (and their children). Then, // if aDeep is true, deal with aNode's children (and recurse into their @@ -713,4 +712,3 @@ nsNodeUtils::GetFirstChildOfTemplateOrNode(nsINode* aNode) return aNode->GetFirstChild(); } - diff --git a/dom/base/nsPropertyTable.cpp b/dom/base/nsPropertyTable.cpp index 487f080afde0..bfef34248c5f 100644 --- a/dom/base/nsPropertyTable.cpp +++ b/dom/base/nsPropertyTable.cpp @@ -140,7 +140,7 @@ nsPropertyTable::GetPropertyInternal(nsPropertyOwner aObject, bool aRemove, nsresult* aResult) { - NS_PRECONDITION(aPropertyName && aObject, "unexpected null param"); + MOZ_ASSERT(aPropertyName && aObject, "unexpected null param"); nsresult rv = NS_PROPTABLE_PROP_NOT_THERE; void *propValue = nullptr; @@ -172,7 +172,7 @@ nsPropertyTable::SetPropertyInternal(nsPropertyOwner aObject, void* aPropDtorData, bool aTransfer) { - NS_PRECONDITION(aPropertyName && aObject, "unexpected null param"); + MOZ_ASSERT(aPropertyName && aObject, "unexpected null param"); PropertyList* propertyList = GetPropertyListFor(aPropertyName); @@ -218,7 +218,7 @@ nsresult nsPropertyTable::DeleteProperty(nsPropertyOwner aObject, nsAtom* aPropertyName) { - NS_PRECONDITION(aPropertyName && aObject, "unexpected null param"); + MOZ_ASSERT(aPropertyName && aObject, "unexpected null param"); PropertyList* propertyList = GetPropertyListFor(aPropertyName); if (propertyList) { diff --git a/dom/base/nsRange.cpp b/dom/base/nsRange.cpp index 0fa7f816b35f..70d3a67493a8 100644 --- a/dom/base/nsRange.cpp +++ b/dom/base/nsRange.cpp @@ -60,7 +60,7 @@ nsRange::GetDocGroup() const static void InvalidateAllFrames(nsINode* aNode) { - NS_PRECONDITION(aNode, "bad arg"); + MOZ_ASSERT(aNode, "bad arg"); nsIFrame* frame = nullptr; switch (aNode->NodeType()) { @@ -199,7 +199,7 @@ struct IsItemInRangeComparator nsRange::IsNodeSelected(nsINode* aNode, uint32_t aStartOffset, uint32_t aEndOffset) { - NS_PRECONDITION(aNode, "bad arg"); + MOZ_ASSERT(aNode, "bad arg"); nsINode* n = GetNextRangeCommonAncestor(aNode); NS_ASSERTION(n || !aNode->IsSelectionDescendant(), @@ -461,7 +461,7 @@ static void UnmarkDescendants(nsINode* aNode) void nsRange::RegisterCommonAncestor(nsINode* aNode) { - NS_PRECONDITION(aNode, "bad arg"); + MOZ_ASSERT(aNode, "bad arg"); MOZ_DIAGNOSTIC_ASSERT(IsInSelection(), "registering range not in selection"); @@ -482,7 +482,7 @@ nsRange::RegisterCommonAncestor(nsINode* aNode) void nsRange::UnregisterCommonAncestor(nsINode* aNode, bool aIsUnlinking) { - NS_PRECONDITION(aNode, "bad arg"); + MOZ_ASSERT(aNode, "bad arg"); NS_ASSERTION(aNode->IsCommonAncestorForRangeInSelection(), "wrong node"); MOZ_DIAGNOSTIC_ASSERT(aNode == mRegisteredCommonAncestor, "wrong node"); LinkedList* ranges = aNode->GetExistingCommonAncestorRanges(); @@ -964,29 +964,32 @@ nsRange::DoSetRange(const RawRangeBoundary& aStart, const RawRangeBoundary& aEnd, nsINode* aRoot, bool aNotInsertedYet) { - NS_PRECONDITION((aStart.IsSet() && aEnd.IsSet() && aRoot) || - (!aStart.IsSet() && !aEnd.IsSet() && !aRoot), - "Set all or none"); - NS_PRECONDITION(!aRoot || aNotInsertedYet || - (nsContentUtils::ContentIsDescendantOf(aStart.Container(), aRoot) && - nsContentUtils::ContentIsDescendantOf(aEnd.Container(), aRoot) && - aRoot == IsValidBoundary(aStart.Container()) && - aRoot == IsValidBoundary(aEnd.Container())), - "Wrong root"); - NS_PRECONDITION(!aRoot || - (aStart.Container()->IsContent() && - aEnd.Container()->IsContent() && - aRoot == - static_cast(aStart.Container())->GetBindingParent() && - aRoot == - static_cast(aEnd.Container())->GetBindingParent()) || - (!aRoot->GetParentNode() && - (aRoot->IsDocument() || - aRoot->IsAttr() || - aRoot->IsDocumentFragment() || - /*For backward compatibility*/ - aRoot->IsContent())), - "Bad root"); + MOZ_ASSERT((aStart.IsSet() && aEnd.IsSet() && aRoot) || + (!aStart.IsSet() && !aEnd.IsSet() && !aRoot), + "Set all or none"); + + MOZ_ASSERT(!aRoot || aNotInsertedYet || + (nsContentUtils::ContentIsDescendantOf(aStart.Container(), aRoot) && + nsContentUtils::ContentIsDescendantOf(aEnd.Container(), aRoot) && + aRoot == IsValidBoundary(aStart.Container()) && + aRoot == IsValidBoundary(aEnd.Container())), + "Wrong root"); + + MOZ_ASSERT(!aRoot || + (aStart.Container()->IsContent() && + aEnd.Container()->IsContent() && + aRoot == + static_cast(aStart.Container())->GetBindingParent() && + aRoot == + static_cast(aEnd.Container())->GetBindingParent()) || + (!aRoot->GetParentNode() && + (aRoot->IsDocument() || + aRoot->IsAttr() || + aRoot->IsDocumentFragment() || + /*For backward compatibility*/ + aRoot->IsContent())), + "Bad root"); + if (mRoot != aRoot) { if (mRoot) { mRoot->RemoveMutationObserver(this); diff --git a/dom/base/nsSyncLoadService.cpp b/dom/base/nsSyncLoadService.cpp index 3eefd9634d04..1b67cf4e831b 100644 --- a/dom/base/nsSyncLoadService.cpp +++ b/dom/base/nsSyncLoadService.cpp @@ -289,7 +289,7 @@ nsSyncLoader::AsyncOnChannelRedirect(nsIChannel *aOldChannel, uint32_t aFlags, nsIAsyncVerifyRedirectCallback *callback) { - NS_PRECONDITION(aNewChannel, "Redirecting to null channel?"); + MOZ_ASSERT(aNewChannel, "Redirecting to null channel?"); mChannel = aNewChannel; diff --git a/dom/base/nsTextNode.cpp b/dom/base/nsTextNode.cpp index eaacc8b1bb71..9344c07bf676 100644 --- a/dom/base/nsTextNode.cpp +++ b/dom/base/nsTextNode.cpp @@ -215,9 +215,9 @@ NS_NewAttributeContent(nsNodeInfoManager *aNodeInfoManager, int32_t aNameSpaceID, nsAtom* aAttrName, nsIContent** aResult) { - NS_PRECONDITION(aNodeInfoManager, "Missing nodeInfoManager"); - NS_PRECONDITION(aAttrName, "Must have an attr name"); - NS_PRECONDITION(aNameSpaceID != kNameSpaceID_Unknown, "Must know namespace"); + MOZ_ASSERT(aNodeInfoManager, "Missing nodeInfoManager"); + MOZ_ASSERT(aAttrName, "Must have an attr name"); + MOZ_ASSERT(aNameSpaceID != kNameSpaceID_Unknown, "Must know namespace"); *aResult = nullptr; @@ -239,8 +239,8 @@ nsAttributeTextNode::BindToTree(nsIDocument* aDocument, nsIContent* aParent, nsIContent* aBindingParent, bool aCompileEventHandlers) { - NS_PRECONDITION(aParent && aParent->GetParent(), - "This node can't be a child of the document or of the document root"); + MOZ_ASSERT(aParent && aParent->GetParent(), + "This node can't be a child of the document or of the document root"); nsresult rv = nsTextNode::BindToTree(aDocument, aParent, aBindingParent, aCompileEventHandlers); @@ -305,4 +305,3 @@ nsAttributeTextNode::UpdateText(bool aNotify) SetText(attrValue, aNotify); } } - diff --git a/dom/base/nsTreeSanitizer.cpp b/dom/base/nsTreeSanitizer.cpp index e49a656829be..0fd5094419b7 100644 --- a/dom/base/nsTreeSanitizer.cpp +++ b/dom/base/nsTreeSanitizer.cpp @@ -1357,7 +1357,7 @@ nsTreeSanitizer::Sanitize(DocumentFragment* aFragment) // If you want to relax these preconditions, be sure to check the code in // here that notifies / does not notify or that fires mutation events if // in tree. - NS_PRECONDITION(!aFragment->IsInUncomposedDoc(), "The fragment is in doc?"); + MOZ_ASSERT(!aFragment->IsInUncomposedDoc(), "The fragment is in doc?"); mFullDocument = false; SanitizeChildren(aFragment); @@ -1370,9 +1370,9 @@ nsTreeSanitizer::Sanitize(nsIDocument* aDocument) // here that notifies / does not notify or that fires mutation events if // in tree. #ifdef DEBUG - NS_PRECONDITION(!aDocument->GetContainer(), "The document is in a shell."); + MOZ_ASSERT(!aDocument->GetContainer(), "The document is in a shell."); RefPtr root = aDocument->GetRootElement(); - NS_PRECONDITION(root->IsHTMLElement(nsGkAtoms::html), "Not HTML root."); + MOZ_ASSERT(root->IsHTMLElement(nsGkAtoms::html), "Not HTML root."); #endif mFullDocument = true; @@ -1542,7 +1542,7 @@ nsTreeSanitizer::LogMessage(const char* aMessage, nsIDocument* aDoc, void nsTreeSanitizer::InitializeStatics() { - NS_PRECONDITION(!sElementsHTML, "Initializing a second time."); + MOZ_ASSERT(!sElementsHTML, "Initializing a second time."); sElementsHTML = new AtomsTable(ArrayLength(kElementsHTML)); for (uint32_t i = 0; kElementsHTML[i]; i++) { diff --git a/dom/canvas/CanvasUtils.cpp b/dom/canvas/CanvasUtils.cpp index 5fffec7a1962..d18f01e92651 100644 --- a/dom/canvas/CanvasUtils.cpp +++ b/dom/canvas/CanvasUtils.cpp @@ -257,7 +257,7 @@ DoDrawImageSecurityCheck(dom::HTMLCanvasElement *aCanvasElement, if (CORSUsed) return; - NS_PRECONDITION(aPrincipal, "Must have a principal here"); + MOZ_ASSERT(aPrincipal, "Must have a principal here"); if (aCanvasElement->NodePrincipal()->Subsumes(aPrincipal)) { // This canvas has access to that image anyway diff --git a/dom/commandhandler/nsControllerCommandTable.cpp b/dom/commandhandler/nsControllerCommandTable.cpp index 91075bba461d..c99464be43d0 100644 --- a/dom/commandhandler/nsControllerCommandTable.cpp +++ b/dom/commandhandler/nsControllerCommandTable.cpp @@ -197,7 +197,7 @@ nsControllerCommandTable::GetSupportedCommands(uint32_t* aCount, nsresult NS_NewControllerCommandTable(nsIControllerCommandTable** aResult) { - NS_PRECONDITION(aResult != nullptr, "null ptr"); + MOZ_ASSERT(aResult != nullptr, "null ptr"); if (!aResult) { return NS_ERROR_NULL_POINTER; } diff --git a/dom/events/ContentEventHandler.cpp b/dom/events/ContentEventHandler.cpp index c2ad7b385094..fdea8bcddd29 100644 --- a/dom/events/ContentEventHandler.cpp +++ b/dom/events/ContentEventHandler.cpp @@ -503,7 +503,7 @@ nsresult ContentEventHandler::QueryContentRect(nsIContent* aContent, WidgetQueryContentEvent* aEvent) { - NS_PRECONDITION(aContent, "aContent must not be null"); + MOZ_ASSERT(aContent, "aContent must not be null"); nsIFrame* frame = aContent->GetPrimaryFrame(); NS_ENSURE_TRUE(frame, NS_ERROR_FAILURE); @@ -2699,7 +2699,7 @@ ContentEventHandler::OnQueryCharacterAtPoint(WidgetQueryContentEvent* aEvent) // The root frame's widget might be different, e.g., the event was fired on // a popup but the rootFrame is the document root. if (rootWidget != aEvent->mWidget) { - NS_PRECONDITION(aEvent->mWidget, "The event must have the widget"); + MOZ_ASSERT(aEvent->mWidget, "The event must have the widget"); nsView* view = nsView::GetViewFor(aEvent->mWidget); NS_ENSURE_TRUE(view, NS_ERROR_FAILURE); rootFrame = view->GetFrame(); diff --git a/dom/events/EventListenerService.cpp b/dom/events/EventListenerService.cpp index 8ab16e6ee58e..ee9c8832ab64 100644 --- a/dom/events/EventListenerService.cpp +++ b/dom/events/EventListenerService.cpp @@ -303,7 +303,7 @@ EventListenerService::AddSystemEventListener(EventTarget *aTarget, bool aUseCapture, JSContext* aCx) { - NS_PRECONDITION(aTarget, "Missing target"); + MOZ_ASSERT(aTarget, "Missing target"); NS_ENSURE_TRUE(aTarget, NS_ERROR_UNEXPECTED); @@ -329,7 +329,7 @@ EventListenerService::RemoveSystemEventListener(EventTarget *aTarget, bool aUseCapture, JSContext* aCx) { - NS_PRECONDITION(aTarget, "Missing target"); + MOZ_ASSERT(aTarget, "Missing target"); NS_ENSURE_TRUE(aTarget, NS_ERROR_UNEXPECTED); diff --git a/dom/events/EventStateManager.cpp b/dom/events/EventStateManager.cpp index a2686b40efd8..c426b378bc01 100644 --- a/dom/events/EventStateManager.cpp +++ b/dom/events/EventStateManager.cpp @@ -5272,11 +5272,11 @@ EventStateManager::SetContentState(nsIContent* aContent, EventStates aState) { // We manage 4 states here: ACTIVE, HOVER, DRAGOVER, URLTARGET // The input must be exactly one of them. - NS_PRECONDITION(aState == NS_EVENT_STATE_ACTIVE || - aState == NS_EVENT_STATE_HOVER || - aState == NS_EVENT_STATE_DRAGOVER || - aState == NS_EVENT_STATE_URLTARGET, - "Unexpected state"); + MOZ_ASSERT(aState == NS_EVENT_STATE_ACTIVE || + aState == NS_EVENT_STATE_HOVER || + aState == NS_EVENT_STATE_DRAGOVER || + aState == NS_EVENT_STATE_URLTARGET, + "Unexpected state"); nsCOMPtr notifyContent1; nsCOMPtr notifyContent2; @@ -5514,7 +5514,7 @@ EventStateManager::EnsureDocument(nsPresContext* aPresContext) void EventStateManager::FlushPendingEvents(nsPresContext* aPresContext) { - NS_PRECONDITION(nullptr != aPresContext, "nullptr ptr"); + MOZ_ASSERT(nullptr != aPresContext, "nullptr ptr"); nsIPresShell *shell = aPresContext->GetPresShell(); if (shell) { shell->FlushPendingNotifications(FlushType::InterruptibleLayout); diff --git a/dom/events/WheelHandlingHelper.cpp b/dom/events/WheelHandlingHelper.cpp index 38589f6ed9e0..e75edb2aa9ec 100644 --- a/dom/events/WheelHandlingHelper.cpp +++ b/dom/events/WheelHandlingHelper.cpp @@ -310,7 +310,7 @@ WheelTransaction::Shutdown() /* static */ void WheelTransaction::OnFailToScrollTarget() { - NS_PRECONDITION(sTargetFrame, "We don't have mouse scrolling transaction"); + MOZ_ASSERT(sTargetFrame, "We don't have mouse scrolling transaction"); if (Prefs::sTestMouseScroll) { // This event is used for automated tests, see bug 442774. diff --git a/dom/html/HTMLFormElement.cpp b/dom/html/HTMLFormElement.cpp index 2874e596874b..67d8b66dd05f 100644 --- a/dom/html/HTMLFormElement.cpp +++ b/dom/html/HTMLFormElement.cpp @@ -1762,9 +1762,9 @@ HTMLFormElement::GetActionURL(nsIURI** aActionURL, NS_IMETHODIMP_(nsIFormControl*) HTMLFormElement::GetDefaultSubmitElement() const { - NS_PRECONDITION(mDefaultSubmitElement == mFirstSubmitInElements || - mDefaultSubmitElement == mFirstSubmitNotInElements, - "What happened here?"); + MOZ_ASSERT(mDefaultSubmitElement == mFirstSubmitInElements || + mDefaultSubmitElement == mFirstSubmitNotInElements, + "What happened here?"); return mDefaultSubmitElement; } @@ -1772,7 +1772,7 @@ HTMLFormElement::GetDefaultSubmitElement() const bool HTMLFormElement::IsDefaultSubmitElement(const nsIFormControl* aControl) const { - NS_PRECONDITION(aControl, "Unexpected call"); + MOZ_ASSERT(aControl, "Unexpected call"); if (aControl == mDefaultSubmitElement) { // Yes, it is @@ -1821,7 +1821,7 @@ HTMLFormElement::ImplicitSubmissionIsDisabled() const bool HTMLFormElement::IsLastActiveElement(const nsIFormControl* aControl) const { - NS_PRECONDITION(aControl, "Unexpected call"); + MOZ_ASSERT(aControl, "Unexpected call"); for (auto* element : Reversed(mControls->mElements)) { if (element->IsSingleLineTextOrNumberControl(false) && diff --git a/dom/html/HTMLFrameSetElement.cpp b/dom/html/HTMLFrameSetElement.cpp index 5b7d675c980e..244525b2b33b 100644 --- a/dom/html/HTMLFrameSetElement.cpp +++ b/dom/html/HTMLFrameSetElement.cpp @@ -74,8 +74,8 @@ nsresult HTMLFrameSetElement::GetRowSpec(int32_t *aNumValues, const nsFramesetSpec** aSpecs) { - NS_PRECONDITION(aNumValues, "Must have a pointer to an integer here!"); - NS_PRECONDITION(aSpecs, "Must have a pointer to an array of nsFramesetSpecs"); + MOZ_ASSERT(aNumValues, "Must have a pointer to an integer here!"); + MOZ_ASSERT(aSpecs, "Must have a pointer to an array of nsFramesetSpecs"); *aNumValues = 0; *aSpecs = nullptr; @@ -104,8 +104,8 @@ nsresult HTMLFrameSetElement::GetColSpec(int32_t *aNumValues, const nsFramesetSpec** aSpecs) { - NS_PRECONDITION(aNumValues, "Must have a pointer to an integer here!"); - NS_PRECONDITION(aSpecs, "Must have a pointer to an array of nsFramesetSpecs"); + MOZ_ASSERT(aNumValues, "Must have a pointer to an integer here!"); + MOZ_ASSERT(aSpecs, "Must have a pointer to an array of nsFramesetSpecs"); *aNumValues = 0; *aSpecs = nullptr; diff --git a/dom/html/HTMLImageElement.cpp b/dom/html/HTMLImageElement.cpp index b21ca276697e..8a14cc175f79 100644 --- a/dom/html/HTMLImageElement.cpp +++ b/dom/html/HTMLImageElement.cpp @@ -865,7 +865,7 @@ HTMLImageElement::GetForm() const void HTMLImageElement::SetForm(HTMLFormElement* aForm) { - NS_PRECONDITION(aForm, "Don't pass null here"); + MOZ_ASSERT(aForm, "Don't pass null here"); NS_ASSERTION(!mForm, "We don't support switching from one non-null form to another."); diff --git a/dom/html/HTMLInputElement.cpp b/dom/html/HTMLInputElement.cpp index 4ba4ef9f9371..ac2d691858f5 100644 --- a/dom/html/HTMLInputElement.cpp +++ b/dom/html/HTMLInputElement.cpp @@ -876,12 +876,12 @@ UploadLastDir::FetchDirectoryAndDisplayPicker(nsIDocument* aDoc, nsIFilePicker* aFilePicker, nsIFilePickerShownCallback* aFpCallback) { - NS_PRECONDITION(aDoc, "aDoc is null"); - NS_PRECONDITION(aFilePicker, "aFilePicker is null"); - NS_PRECONDITION(aFpCallback, "aFpCallback is null"); + MOZ_ASSERT(aDoc, "aDoc is null"); + MOZ_ASSERT(aFilePicker, "aFilePicker is null"); + MOZ_ASSERT(aFpCallback, "aFpCallback is null"); nsIURI* docURI = aDoc->GetDocumentURI(); - NS_PRECONDITION(docURI, "docURI is null"); + MOZ_ASSERT(docURI, "docURI is null"); nsCOMPtr loadContext = aDoc->GetLoadContext(); nsCOMPtr prefCallback = @@ -906,13 +906,13 @@ UploadLastDir::FetchDirectoryAndDisplayPicker(nsIDocument* aDoc, nsresult UploadLastDir::StoreLastUsedDirectory(nsIDocument* aDoc, nsIFile* aDir) { - NS_PRECONDITION(aDoc, "aDoc is null"); + MOZ_ASSERT(aDoc, "aDoc is null"); if (!aDir) { return NS_OK; } nsCOMPtr docURI = aDoc->GetDocumentURI(); - NS_PRECONDITION(docURI, "docURI is null"); + MOZ_ASSERT(docURI, "docURI is null"); // Attempt to get the CPS, if it's not present we'll just return nsCOMPtr contentPrefService = @@ -2794,8 +2794,8 @@ HTMLInputElement::SetValueInternal(const nsAString& aValue, const nsAString* aOldValue, uint32_t aFlags) { - NS_PRECONDITION(GetValueMode() != VALUE_MODE_FILENAME, - "Don't call SetValueInternal for file inputs"); + MOZ_ASSERT(GetValueMode() != VALUE_MODE_FILENAME, + "Don't call SetValueInternal for file inputs"); // We want to remember if the SetValueInternal() call is being made for a XUL // element. We do that by looking at the parent node here, and if that node diff --git a/dom/html/HTMLSharedElement.cpp b/dom/html/HTMLSharedElement.cpp index 8f74f5c9ce84..9f07c0b80e8a 100644 --- a/dom/html/HTMLSharedElement.cpp +++ b/dom/html/HTMLSharedElement.cpp @@ -120,7 +120,7 @@ HTMLSharedElement::IsAttributeMapped(const nsAtom* aAttribute) const static void SetBaseURIUsingFirstBaseWithHref(nsIDocument* aDocument, nsIContent* aMustMatch) { - NS_PRECONDITION(aDocument, "Need a document!"); + MOZ_ASSERT(aDocument, "Need a document!"); for (nsIContent* child = aDocument->GetFirstChild(); child; child = child->GetNextNode()) { @@ -173,7 +173,7 @@ static void SetBaseTargetUsingFirstBaseWithTarget(nsIDocument* aDocument, nsIContent* aMustMatch) { - NS_PRECONDITION(aDocument, "Need a document!"); + MOZ_ASSERT(aDocument, "Need a document!"); for (nsIContent* child = aDocument->GetFirstChild(); child; child = child->GetNextNode()) { diff --git a/dom/html/nsGenericHTMLElement.cpp b/dom/html/nsGenericHTMLElement.cpp index af8a7a0b90e1..d619b599d574 100644 --- a/dom/html/nsGenericHTMLElement.cpp +++ b/dom/html/nsGenericHTMLElement.cpp @@ -544,8 +544,8 @@ bool nsGenericHTMLElement::CheckHandleEventForAnchorsPreconditions( EventChainVisitor& aVisitor) { - NS_PRECONDITION(nsCOMPtr(do_QueryObject(this)), - "should be called only when |this| implements |Link|"); + MOZ_ASSERT(nsCOMPtr(do_QueryObject(this)), + "should be called only when |this| implements |Link|"); if (!aVisitor.mPresContext) { // We need a pres context to do link stuff. Some events (e.g. mutation @@ -589,7 +589,7 @@ nsGenericHTMLElement::PostHandleEventForAnchors(EventChainPostVisitor& aVisitor) bool nsGenericHTMLElement::IsHTMLLink(nsIURI** aURI) const { - NS_PRECONDITION(aURI, "Must provide aURI out param"); + MOZ_ASSERT(aURI, "Must provide aURI out param"); *aURI = GetHrefURIForAnchors().take(); // We promise out param is non-null if we return true, so base rv on it @@ -1683,7 +1683,7 @@ nsGenericHTMLFormElement::SaveSubtreeState() void nsGenericHTMLFormElement::SetForm(HTMLFormElement* aForm) { - NS_PRECONDITION(aForm, "Don't pass null here"); + MOZ_ASSERT(aForm, "Don't pass null here"); NS_ASSERTION(!mForm, "We don't support switching from one non-null form to another."); @@ -2223,8 +2223,8 @@ void nsGenericHTMLFormElement::UpdateFormOwner(bool aBindToTree, Element* aFormIdElement) { - NS_PRECONDITION(!aBindToTree || !aFormIdElement, - "aFormIdElement shouldn't be set if aBindToTree is true!"); + MOZ_ASSERT(!aBindToTree || !aFormIdElement, + "aFormIdElement shouldn't be set if aBindToTree is true!"); bool needStateUpdate = false; if (!aBindToTree) { diff --git a/dom/html/nsGenericHTMLFrameElement.cpp b/dom/html/nsGenericHTMLFrameElement.cpp index b895d83cb01a..db85fae519b3 100644 --- a/dom/html/nsGenericHTMLFrameElement.cpp +++ b/dom/html/nsGenericHTMLFrameElement.cpp @@ -84,7 +84,7 @@ nsGenericHTMLFrameElement::~nsGenericHTMLFrameElement() nsresult nsGenericHTMLFrameElement::GetContentDocument(nsIDOMDocument** aContentDocument) { - NS_PRECONDITION(aContentDocument, "Null out param"); + MOZ_ASSERT(aContentDocument, "Null out param"); nsCOMPtr document = do_QueryInterface(GetContentDocument(*nsContentUtils::SubjectPrincipal())); document.forget(aContentDocument); diff --git a/dom/html/nsHTMLContentSink.cpp b/dom/html/nsHTMLContentSink.cpp index c3200ba8095a..956b5cdaa7f7 100644 --- a/dom/html/nsHTMLContentSink.cpp +++ b/dom/html/nsHTMLContentSink.cpp @@ -785,7 +785,7 @@ HTMLContentSink::DidBuildModel(bool aTerminated) NS_IMETHODIMP HTMLContentSink::SetParser(nsParserBase* aParser) { - NS_PRECONDITION(aParser, "Should have a parser here!"); + MOZ_ASSERT(aParser, "Should have a parser here!"); mParser = aParser; return NS_OK; } @@ -968,7 +968,7 @@ HTMLContentSink::NotifyInsert(nsIContent* aContent, void HTMLContentSink::NotifyRootInsertion() { - NS_PRECONDITION(!mNotifiedRootInsertion, "Double-notifying on root?"); + MOZ_ASSERT(!mNotifiedRootInsertion, "Double-notifying on root?"); NS_ASSERTION(!mLayoutStarted, "How did we start layout without notifying on root?"); // Now make sure to notify that we have now inserted our root. If diff --git a/dom/jsurl/nsJSProtocolHandler.cpp b/dom/jsurl/nsJSProtocolHandler.cpp index 47a4abbb788a..b7ce60d1fcba 100644 --- a/dom/jsurl/nsJSProtocolHandler.cpp +++ b/dom/jsurl/nsJSProtocolHandler.cpp @@ -1415,7 +1415,7 @@ nsJSURI::EqualsInternal(nsIURI* aOther, bool* aResult) { NS_ENSURE_ARG_POINTER(aOther); - NS_PRECONDITION(aResult, "null pointer for outparam"); + MOZ_ASSERT(aResult, "null pointer for outparam"); RefPtr otherJSURI; nsresult rv = aOther->QueryInterface(kJSURICID, diff --git a/dom/script/nsIScriptElement.h b/dom/script/nsIScriptElement.h index a34d9453b2a4..efa8631bf8cd 100644 --- a/dom/script/nsIScriptElement.h +++ b/dom/script/nsIScriptElement.h @@ -64,13 +64,13 @@ public: */ nsIURI* GetScriptURI() { - NS_PRECONDITION(mFrozen, "Not ready for this call yet!"); + MOZ_ASSERT(mFrozen, "Not ready for this call yet!"); return mUri; } nsIPrincipal* GetScriptURITriggeringPrincipal() { - NS_PRECONDITION(mFrozen, "Not ready for this call yet!"); + MOZ_ASSERT(mFrozen, "Not ready for this call yet!"); return mSrcTriggeringPrincipal; } @@ -97,7 +97,7 @@ public: */ bool GetScriptIsModule() { - NS_PRECONDITION(mFrozen, "Not ready for this call yet!"); + MOZ_ASSERT(mFrozen, "Not ready for this call yet!"); return mIsModule; } @@ -106,7 +106,7 @@ public: */ bool GetScriptDeferred() { - NS_PRECONDITION(mFrozen, "Not ready for this call yet!"); + MOZ_ASSERT(mFrozen, "Not ready for this call yet!"); return mDefer; } @@ -115,7 +115,7 @@ public: */ bool GetScriptAsync() { - NS_PRECONDITION(mFrozen, "Not ready for this call yet!"); + MOZ_ASSERT(mFrozen, "Not ready for this call yet!"); return mAsync; } @@ -124,7 +124,7 @@ public: */ bool GetScriptExternal() { - NS_PRECONDITION(mFrozen, "Not ready for this call yet!"); + MOZ_ASSERT(mFrozen, "Not ready for this call yet!"); return mExternal; } diff --git a/dom/security/nsCSPContext.cpp b/dom/security/nsCSPContext.cpp index 14edf298820a..e51f58de0e74 100644 --- a/dom/security/nsCSPContext.cpp +++ b/dom/security/nsCSPContext.cpp @@ -734,8 +734,8 @@ NS_IMETHODIMP nsCSPContext::SetRequestContext(nsIDOMDocument* aDOMDocument, nsIPrincipal* aPrincipal) { - NS_PRECONDITION(aDOMDocument || aPrincipal, - "Can't set context without doc or principal"); + MOZ_ASSERT(aDOMDocument || aPrincipal, + "Can't set context without doc or principal"); NS_ENSURE_ARG(aDOMDocument || aPrincipal); if (aDOMDocument) { diff --git a/dom/smil/SMILBoolType.cpp b/dom/smil/SMILBoolType.cpp index f6ae19b794ba..a821b3852192 100644 --- a/dom/smil/SMILBoolType.cpp +++ b/dom/smil/SMILBoolType.cpp @@ -14,7 +14,7 @@ namespace mozilla { void SMILBoolType::Init(nsSMILValue& aValue) const { - NS_PRECONDITION(aValue.IsNull(), "Unexpected value type"); + MOZ_ASSERT(aValue.IsNull(), "Unexpected value type"); aValue.mU.mBool = false; aValue.mType = this; } @@ -22,7 +22,7 @@ SMILBoolType::Init(nsSMILValue& aValue) const void SMILBoolType::Destroy(nsSMILValue& aValue) const { - NS_PRECONDITION(aValue.mType == this, "Unexpected SMIL value"); + MOZ_ASSERT(aValue.mType == this, "Unexpected SMIL value"); aValue.mU.mBool = false; aValue.mType = nsSMILNullType::Singleton(); } @@ -30,8 +30,8 @@ SMILBoolType::Destroy(nsSMILValue& aValue) const nsresult SMILBoolType::Assign(nsSMILValue& aDest, const nsSMILValue& aSrc) const { - NS_PRECONDITION(aDest.mType == aSrc.mType, "Incompatible SMIL types"); - NS_PRECONDITION(aDest.mType == this, "Unexpected SMIL value"); + MOZ_ASSERT(aDest.mType == aSrc.mType, "Incompatible SMIL types"); + MOZ_ASSERT(aDest.mType == this, "Unexpected SMIL value"); aDest.mU.mBool = aSrc.mU.mBool; return NS_OK; } @@ -40,8 +40,8 @@ bool SMILBoolType::IsEqual(const nsSMILValue& aLeft, const nsSMILValue& aRight) const { - NS_PRECONDITION(aLeft.mType == aRight.mType, "Incompatible SMIL types"); - NS_PRECONDITION(aLeft.mType == this, "Unexpected type for SMIL value"); + MOZ_ASSERT(aLeft.mType == aRight.mType, "Incompatible SMIL types"); + MOZ_ASSERT(aLeft.mType == this, "Unexpected type for SMIL value"); return aLeft.mU.mBool == aRight.mU.mBool; } @@ -50,9 +50,8 @@ nsresult SMILBoolType::Add(nsSMILValue& aDest, const nsSMILValue& aValueToAdd, uint32_t aCount) const { - NS_PRECONDITION(aValueToAdd.mType == aDest.mType, - "Trying to add invalid types"); - NS_PRECONDITION(aValueToAdd.mType == this, "Unexpected source type"); + MOZ_ASSERT(aValueToAdd.mType == aDest.mType, "Trying to add invalid types"); + MOZ_ASSERT(aValueToAdd.mType == this, "Unexpected source type"); return NS_ERROR_FAILURE; // bool values can't be added to each other } @@ -61,8 +60,8 @@ SMILBoolType::ComputeDistance(const nsSMILValue& aFrom, const nsSMILValue& aTo, double& aDistance) const { - NS_PRECONDITION(aFrom.mType == aTo.mType,"Trying to compare different types"); - NS_PRECONDITION(aFrom.mType == this, "Unexpected source type"); + MOZ_ASSERT(aFrom.mType == aTo.mType, "Trying to compare different types"); + MOZ_ASSERT(aFrom.mType == this, "Unexpected source type"); return NS_ERROR_FAILURE; // there is no concept of distance between bool values } @@ -72,11 +71,11 @@ SMILBoolType::Interpolate(const nsSMILValue& aStartVal, double aUnitDistance, nsSMILValue& aResult) const { - NS_PRECONDITION(aStartVal.mType == aEndVal.mType, - "Trying to interpolate different types"); - NS_PRECONDITION(aStartVal.mType == this, + MOZ_ASSERT(aStartVal.mType == aEndVal.mType, + "Trying to interpolate different types"); + MOZ_ASSERT(aStartVal.mType == this, "Unexpected types for interpolation"); - NS_PRECONDITION(aResult.mType == this, "Unexpected result type"); + MOZ_ASSERT(aResult.mType == this, "Unexpected result type"); return NS_ERROR_FAILURE; // bool values do not interpolate } diff --git a/dom/smil/SMILEnumType.cpp b/dom/smil/SMILEnumType.cpp index 2aa7a04c1260..a552045ea0f1 100644 --- a/dom/smil/SMILEnumType.cpp +++ b/dom/smil/SMILEnumType.cpp @@ -14,7 +14,7 @@ namespace mozilla { void SMILEnumType::Init(nsSMILValue& aValue) const { - NS_PRECONDITION(aValue.IsNull(), "Unexpected value type"); + MOZ_ASSERT(aValue.IsNull(), "Unexpected value type"); aValue.mU.mUint = 0; aValue.mType = this; } @@ -22,7 +22,7 @@ SMILEnumType::Init(nsSMILValue& aValue) const void SMILEnumType::Destroy(nsSMILValue& aValue) const { - NS_PRECONDITION(aValue.mType == this, "Unexpected SMIL value"); + MOZ_ASSERT(aValue.mType == this, "Unexpected SMIL value"); aValue.mU.mUint = 0; aValue.mType = nsSMILNullType::Singleton(); } @@ -30,8 +30,8 @@ SMILEnumType::Destroy(nsSMILValue& aValue) const nsresult SMILEnumType::Assign(nsSMILValue& aDest, const nsSMILValue& aSrc) const { - NS_PRECONDITION(aDest.mType == aSrc.mType, "Incompatible SMIL types"); - NS_PRECONDITION(aDest.mType == this, "Unexpected SMIL value"); + MOZ_ASSERT(aDest.mType == aSrc.mType, "Incompatible SMIL types"); + MOZ_ASSERT(aDest.mType == this, "Unexpected SMIL value"); aDest.mU.mUint = aSrc.mU.mUint; return NS_OK; } @@ -40,8 +40,8 @@ bool SMILEnumType::IsEqual(const nsSMILValue& aLeft, const nsSMILValue& aRight) const { - NS_PRECONDITION(aLeft.mType == aRight.mType, "Incompatible SMIL types"); - NS_PRECONDITION(aLeft.mType == this, "Unexpected type for SMIL value"); + MOZ_ASSERT(aLeft.mType == aRight.mType, "Incompatible SMIL types"); + MOZ_ASSERT(aLeft.mType == this, "Unexpected type for SMIL value"); return aLeft.mU.mUint == aRight.mU.mUint; } @@ -50,9 +50,9 @@ nsresult SMILEnumType::Add(nsSMILValue& aDest, const nsSMILValue& aValueToAdd, uint32_t aCount) const { - NS_PRECONDITION(aValueToAdd.mType == aDest.mType, + MOZ_ASSERT(aValueToAdd.mType == aDest.mType, "Trying to add invalid types"); - NS_PRECONDITION(aValueToAdd.mType == this, "Unexpected source type"); + MOZ_ASSERT(aValueToAdd.mType == this, "Unexpected source type"); return NS_ERROR_FAILURE; // enum values can't be added to each other } @@ -61,8 +61,8 @@ SMILEnumType::ComputeDistance(const nsSMILValue& aFrom, const nsSMILValue& aTo, double& aDistance) const { - NS_PRECONDITION(aFrom.mType == aTo.mType,"Trying to compare different types"); - NS_PRECONDITION(aFrom.mType == this, "Unexpected source type"); + MOZ_ASSERT(aFrom.mType == aTo.mType,"Trying to compare different types"); + MOZ_ASSERT(aFrom.mType == this, "Unexpected source type"); return NS_ERROR_FAILURE; // there is no concept of distance between enum values } @@ -72,11 +72,11 @@ SMILEnumType::Interpolate(const nsSMILValue& aStartVal, double aUnitDistance, nsSMILValue& aResult) const { - NS_PRECONDITION(aStartVal.mType == aEndVal.mType, + MOZ_ASSERT(aStartVal.mType == aEndVal.mType, "Trying to interpolate different types"); - NS_PRECONDITION(aStartVal.mType == this, + MOZ_ASSERT(aStartVal.mType == this, "Unexpected types for interpolation"); - NS_PRECONDITION(aResult.mType == this, "Unexpected result type"); + MOZ_ASSERT(aResult.mType == this, "Unexpected result type"); return NS_ERROR_FAILURE; // enum values do not interpolate } diff --git a/dom/smil/SMILIntegerType.cpp b/dom/smil/SMILIntegerType.cpp index 194653e1b3a7..058d30c19665 100644 --- a/dom/smil/SMILIntegerType.cpp +++ b/dom/smil/SMILIntegerType.cpp @@ -22,7 +22,7 @@ SMILIntegerType::Init(nsSMILValue& aValue) const void SMILIntegerType::Destroy(nsSMILValue& aValue) const { - NS_PRECONDITION(aValue.mType == this, "Unexpected SMIL value"); + MOZ_ASSERT(aValue.mType == this, "Unexpected SMIL value"); aValue.mU.mInt = 0; aValue.mType = nsSMILNullType::Singleton(); } @@ -30,8 +30,8 @@ SMILIntegerType::Destroy(nsSMILValue& aValue) const nsresult SMILIntegerType::Assign(nsSMILValue& aDest, const nsSMILValue& aSrc) const { - NS_PRECONDITION(aDest.mType == aSrc.mType, "Incompatible SMIL types"); - NS_PRECONDITION(aDest.mType == this, "Unexpected SMIL value"); + MOZ_ASSERT(aDest.mType == aSrc.mType, "Incompatible SMIL types"); + MOZ_ASSERT(aDest.mType == this, "Unexpected SMIL value"); aDest.mU.mInt = aSrc.mU.mInt; return NS_OK; } @@ -40,8 +40,8 @@ bool SMILIntegerType::IsEqual(const nsSMILValue& aLeft, const nsSMILValue& aRight) const { - NS_PRECONDITION(aLeft.mType == aRight.mType, "Incompatible SMIL types"); - NS_PRECONDITION(aLeft.mType == this, "Unexpected type for SMIL value"); + MOZ_ASSERT(aLeft.mType == aRight.mType, "Incompatible SMIL types"); + MOZ_ASSERT(aLeft.mType == this, "Unexpected type for SMIL value"); return aLeft.mU.mInt == aRight.mU.mInt; } @@ -50,9 +50,9 @@ nsresult SMILIntegerType::Add(nsSMILValue& aDest, const nsSMILValue& aValueToAdd, uint32_t aCount) const { - NS_PRECONDITION(aValueToAdd.mType == aDest.mType, + MOZ_ASSERT(aValueToAdd.mType == aDest.mType, "Trying to add invalid types"); - NS_PRECONDITION(aValueToAdd.mType == this, "Unexpected source type"); + MOZ_ASSERT(aValueToAdd.mType == this, "Unexpected source type"); aDest.mU.mInt += aValueToAdd.mU.mInt * aCount; return NS_OK; } @@ -62,8 +62,8 @@ SMILIntegerType::ComputeDistance(const nsSMILValue& aFrom, const nsSMILValue& aTo, double& aDistance) const { - NS_PRECONDITION(aFrom.mType == aTo.mType,"Trying to compare different types"); - NS_PRECONDITION(aFrom.mType == this, "Unexpected source type"); + MOZ_ASSERT(aFrom.mType == aTo.mType, "Trying to compare different types"); + MOZ_ASSERT(aFrom.mType == this, "Unexpected source type"); aDistance = fabs(double(aTo.mU.mInt - aFrom.mU.mInt)); return NS_OK; } @@ -74,11 +74,10 @@ SMILIntegerType::Interpolate(const nsSMILValue& aStartVal, double aUnitDistance, nsSMILValue& aResult) const { - NS_PRECONDITION(aStartVal.mType == aEndVal.mType, - "Trying to interpolate different types"); - NS_PRECONDITION(aStartVal.mType == this, - "Unexpected types for interpolation"); - NS_PRECONDITION(aResult.mType == this, "Unexpected result type"); + MOZ_ASSERT(aStartVal.mType == aEndVal.mType, + "Trying to interpolate different types"); + MOZ_ASSERT(aStartVal.mType == this, "Unexpected types for interpolation"); + MOZ_ASSERT(aResult.mType == this, "Unexpected result type"); const double startVal = double(aStartVal.mU.mInt); const double endVal = double(aEndVal.mU.mInt); diff --git a/dom/smil/SMILStringType.cpp b/dom/smil/SMILStringType.cpp index d67323b7e3dd..6510f6cf666c 100644 --- a/dom/smil/SMILStringType.cpp +++ b/dom/smil/SMILStringType.cpp @@ -14,7 +14,7 @@ namespace mozilla { void SMILStringType::Init(nsSMILValue& aValue) const { - NS_PRECONDITION(aValue.IsNull(), "Unexpected value type"); + MOZ_ASSERT(aValue.IsNull(), "Unexpected value type"); aValue.mU.mPtr = new nsString(); aValue.mType = this; } @@ -22,7 +22,7 @@ SMILStringType::Init(nsSMILValue& aValue) const void SMILStringType::Destroy(nsSMILValue& aValue) const { - NS_PRECONDITION(aValue.mType == this, "Unexpected SMIL value"); + MOZ_ASSERT(aValue.mType == this, "Unexpected SMIL value"); delete static_cast(aValue.mU.mPtr); aValue.mU.mPtr = nullptr; aValue.mType = nsSMILNullType::Singleton(); @@ -31,8 +31,8 @@ SMILStringType::Destroy(nsSMILValue& aValue) const nsresult SMILStringType::Assign(nsSMILValue& aDest, const nsSMILValue& aSrc) const { - NS_PRECONDITION(aDest.mType == aSrc.mType, "Incompatible SMIL types"); - NS_PRECONDITION(aDest.mType == this, "Unexpected SMIL value"); + MOZ_ASSERT(aDest.mType == aSrc.mType, "Incompatible SMIL types"); + MOZ_ASSERT(aDest.mType == this, "Unexpected SMIL value"); const nsAString* src = static_cast(aSrc.mU.mPtr); nsAString* dst = static_cast(aDest.mU.mPtr); @@ -44,8 +44,8 @@ bool SMILStringType::IsEqual(const nsSMILValue& aLeft, const nsSMILValue& aRight) const { - NS_PRECONDITION(aLeft.mType == aRight.mType, "Incompatible SMIL types"); - NS_PRECONDITION(aLeft.mType == this, "Unexpected type for SMIL value"); + MOZ_ASSERT(aLeft.mType == aRight.mType, "Incompatible SMIL types"); + MOZ_ASSERT(aLeft.mType == this, "Unexpected type for SMIL value"); const nsAString* leftString = static_cast(aLeft.mU.mPtr); @@ -58,9 +58,9 @@ nsresult SMILStringType::Add(nsSMILValue& aDest, const nsSMILValue& aValueToAdd, uint32_t aCount) const { - NS_PRECONDITION(aValueToAdd.mType == aDest.mType, + MOZ_ASSERT(aValueToAdd.mType == aDest.mType, "Trying to add invalid types"); - NS_PRECONDITION(aValueToAdd.mType == this, "Unexpected source type"); + MOZ_ASSERT(aValueToAdd.mType == this, "Unexpected source type"); return NS_ERROR_FAILURE; // string values can't be added to each other } @@ -69,8 +69,8 @@ SMILStringType::ComputeDistance(const nsSMILValue& aFrom, const nsSMILValue& aTo, double& aDistance) const { - NS_PRECONDITION(aFrom.mType == aTo.mType,"Trying to compare different types"); - NS_PRECONDITION(aFrom.mType == this, "Unexpected source type"); + MOZ_ASSERT(aFrom.mType == aTo.mType, "Trying to compare different types"); + MOZ_ASSERT(aFrom.mType == this, "Unexpected source type"); return NS_ERROR_FAILURE; // there is no concept of distance between string values } @@ -80,11 +80,10 @@ SMILStringType::Interpolate(const nsSMILValue& aStartVal, double aUnitDistance, nsSMILValue& aResult) const { - NS_PRECONDITION(aStartVal.mType == aEndVal.mType, - "Trying to interpolate different types"); - NS_PRECONDITION(aStartVal.mType == this, - "Unexpected types for interpolation"); - NS_PRECONDITION(aResult.mType == this, "Unexpected result type"); + MOZ_ASSERT(aStartVal.mType == aEndVal.mType, + "Trying to interpolate different types"); + MOZ_ASSERT(aStartVal.mType == this, "Unexpected types for interpolation"); + MOZ_ASSERT(aResult.mType == this, "Unexpected result type"); return NS_ERROR_FAILURE; // string values do not interpolate } diff --git a/dom/smil/nsSMILFloatType.cpp b/dom/smil/nsSMILFloatType.cpp index d3e2980430ed..da9fd298c9a0 100644 --- a/dom/smil/nsSMILFloatType.cpp +++ b/dom/smil/nsSMILFloatType.cpp @@ -12,7 +12,7 @@ void nsSMILFloatType::Init(nsSMILValue& aValue) const { - NS_PRECONDITION(aValue.IsNull(), "Unexpected value type"); + MOZ_ASSERT(aValue.IsNull(), "Unexpected value type"); aValue.mU.mDouble = 0.0; aValue.mType = this; } @@ -20,7 +20,7 @@ nsSMILFloatType::Init(nsSMILValue& aValue) const void nsSMILFloatType::Destroy(nsSMILValue& aValue) const { - NS_PRECONDITION(aValue.mType == this, "Unexpected SMIL value"); + MOZ_ASSERT(aValue.mType == this, "Unexpected SMIL value"); aValue.mU.mDouble = 0.0; aValue.mType = nsSMILNullType::Singleton(); } @@ -28,8 +28,8 @@ nsSMILFloatType::Destroy(nsSMILValue& aValue) const nsresult nsSMILFloatType::Assign(nsSMILValue& aDest, const nsSMILValue& aSrc) const { - NS_PRECONDITION(aDest.mType == aSrc.mType, "Incompatible SMIL types"); - NS_PRECONDITION(aDest.mType == this, "Unexpected SMIL value"); + MOZ_ASSERT(aDest.mType == aSrc.mType, "Incompatible SMIL types"); + MOZ_ASSERT(aDest.mType == this, "Unexpected SMIL value"); aDest.mU.mDouble = aSrc.mU.mDouble; return NS_OK; } @@ -38,8 +38,8 @@ bool nsSMILFloatType::IsEqual(const nsSMILValue& aLeft, const nsSMILValue& aRight) const { - NS_PRECONDITION(aLeft.mType == aRight.mType, "Incompatible SMIL types"); - NS_PRECONDITION(aLeft.mType == this, "Unexpected type for SMIL value"); + MOZ_ASSERT(aLeft.mType == aRight.mType, "Incompatible SMIL types"); + MOZ_ASSERT(aLeft.mType == this, "Unexpected type for SMIL value"); return aLeft.mU.mDouble == aRight.mU.mDouble; } @@ -48,9 +48,9 @@ nsresult nsSMILFloatType::Add(nsSMILValue& aDest, const nsSMILValue& aValueToAdd, uint32_t aCount) const { - NS_PRECONDITION(aValueToAdd.mType == aDest.mType, + MOZ_ASSERT(aValueToAdd.mType == aDest.mType, "Trying to add invalid types"); - NS_PRECONDITION(aValueToAdd.mType == this, "Unexpected source type"); + MOZ_ASSERT(aValueToAdd.mType == this, "Unexpected source type"); aDest.mU.mDouble += aValueToAdd.mU.mDouble * aCount; return NS_OK; } @@ -60,8 +60,8 @@ nsSMILFloatType::ComputeDistance(const nsSMILValue& aFrom, const nsSMILValue& aTo, double& aDistance) const { - NS_PRECONDITION(aFrom.mType == aTo.mType,"Trying to compare different types"); - NS_PRECONDITION(aFrom.mType == this, "Unexpected source type"); + MOZ_ASSERT(aFrom.mType == aTo.mType, "Trying to compare different types"); + MOZ_ASSERT(aFrom.mType == this, "Unexpected source type"); const double &from = aFrom.mU.mDouble; const double &to = aTo.mU.mDouble; @@ -77,11 +77,11 @@ nsSMILFloatType::Interpolate(const nsSMILValue& aStartVal, double aUnitDistance, nsSMILValue& aResult) const { - NS_PRECONDITION(aStartVal.mType == aEndVal.mType, - "Trying to interpolate different types"); - NS_PRECONDITION(aStartVal.mType == this, + MOZ_ASSERT(aStartVal.mType == aEndVal.mType, + "Trying to interpolate different types"); + MOZ_ASSERT(aStartVal.mType == this, "Unexpected types for interpolation"); - NS_PRECONDITION(aResult.mType == this, "Unexpected result type"); + MOZ_ASSERT(aResult.mType == this, "Unexpected result type"); const double &startVal = aStartVal.mU.mDouble; const double &endVal = aEndVal.mU.mDouble; diff --git a/dom/smil/nsSMILNullType.cpp b/dom/smil/nsSMILNullType.cpp index 795a93df4b88..2d387c18b46f 100644 --- a/dom/smil/nsSMILNullType.cpp +++ b/dom/smil/nsSMILNullType.cpp @@ -18,8 +18,8 @@ nsSMILNullType::Singleton() nsresult nsSMILNullType::Assign(nsSMILValue& aDest, const nsSMILValue& aSrc) const { - NS_PRECONDITION(aDest.mType == aSrc.mType, "Incompatible SMIL types"); - NS_PRECONDITION(aSrc.mType == this, "Unexpected source type"); + MOZ_ASSERT(aDest.mType == aSrc.mType, "Incompatible SMIL types"); + MOZ_ASSERT(aSrc.mType == this, "Unexpected source type"); aDest.mU = aSrc.mU; aDest.mType = Singleton(); return NS_OK; @@ -29,8 +29,8 @@ bool nsSMILNullType::IsEqual(const nsSMILValue& aLeft, const nsSMILValue& aRight) const { - NS_PRECONDITION(aLeft.mType == aRight.mType, "Incompatible SMIL types"); - NS_PRECONDITION(aLeft.mType == this, "Unexpected type for SMIL value"); + MOZ_ASSERT(aLeft.mType == aRight.mType, "Incompatible SMIL types"); + MOZ_ASSERT(aLeft.mType == this, "Unexpected type for SMIL value"); return true; // All null-typed values are equivalent. } diff --git a/dom/svg/SVGIntegerPairSMILType.cpp b/dom/svg/SVGIntegerPairSMILType.cpp index e13fae3f58fe..ceb2990c208b 100644 --- a/dom/svg/SVGIntegerPairSMILType.cpp +++ b/dom/svg/SVGIntegerPairSMILType.cpp @@ -24,7 +24,7 @@ SVGIntegerPairSMILType::Init(nsSMILValue& aValue) const void SVGIntegerPairSMILType::Destroy(nsSMILValue& aValue) const { - NS_PRECONDITION(aValue.mType == this, "Unexpected SMIL value"); + MOZ_ASSERT(aValue.mType == this, "Unexpected SMIL value"); aValue.mU.mIntPair[0] = 0; aValue.mU.mIntPair[1] = 0; aValue.mType = nsSMILNullType::Singleton(); @@ -33,8 +33,8 @@ SVGIntegerPairSMILType::Destroy(nsSMILValue& aValue) const nsresult SVGIntegerPairSMILType::Assign(nsSMILValue& aDest, const nsSMILValue& aSrc) const { - NS_PRECONDITION(aDest.mType == aSrc.mType, "Incompatible SMIL types"); - NS_PRECONDITION(aDest.mType == this, "Unexpected SMIL value"); + MOZ_ASSERT(aDest.mType == aSrc.mType, "Incompatible SMIL types"); + MOZ_ASSERT(aDest.mType == this, "Unexpected SMIL value"); aDest.mU.mIntPair[0] = aSrc.mU.mIntPair[0]; aDest.mU.mIntPair[1] = aSrc.mU.mIntPair[1]; @@ -45,8 +45,8 @@ bool SVGIntegerPairSMILType::IsEqual(const nsSMILValue& aLeft, const nsSMILValue& aRight) const { - NS_PRECONDITION(aLeft.mType == aRight.mType, "Incompatible SMIL types"); - NS_PRECONDITION(aLeft.mType == this, "Unexpected type for SMIL value"); + MOZ_ASSERT(aLeft.mType == aRight.mType, "Incompatible SMIL types"); + MOZ_ASSERT(aLeft.mType == this, "Unexpected type for SMIL value"); return aLeft.mU.mIntPair[0] == aRight.mU.mIntPair[0] && aLeft.mU.mIntPair[1] == aRight.mU.mIntPair[1]; @@ -56,9 +56,9 @@ nsresult SVGIntegerPairSMILType::Add(nsSMILValue& aDest, const nsSMILValue& aValueToAdd, uint32_t aCount) const { - NS_PRECONDITION(aValueToAdd.mType == aDest.mType, + MOZ_ASSERT(aValueToAdd.mType == aDest.mType, "Trying to add invalid types"); - NS_PRECONDITION(aValueToAdd.mType == this, "Unexpected source type"); + MOZ_ASSERT(aValueToAdd.mType == this, "Unexpected source type"); aDest.mU.mIntPair[0] += aValueToAdd.mU.mIntPair[0] * aCount; aDest.mU.mIntPair[1] += aValueToAdd.mU.mIntPair[1] * aCount; @@ -71,8 +71,8 @@ SVGIntegerPairSMILType::ComputeDistance(const nsSMILValue& aFrom, const nsSMILValue& aTo, double& aDistance) const { - NS_PRECONDITION(aFrom.mType == aTo.mType,"Trying to compare different types"); - NS_PRECONDITION(aFrom.mType == this, "Unexpected source type"); + MOZ_ASSERT(aFrom.mType == aTo.mType,"Trying to compare different types"); + MOZ_ASSERT(aFrom.mType == this, "Unexpected source type"); double delta[2]; delta[0] = aTo.mU.mIntPair[0] - aFrom.mU.mIntPair[0]; @@ -88,11 +88,10 @@ SVGIntegerPairSMILType::Interpolate(const nsSMILValue& aStartVal, double aUnitDistance, nsSMILValue& aResult) const { - NS_PRECONDITION(aStartVal.mType == aEndVal.mType, - "Trying to interpolate different types"); - NS_PRECONDITION(aStartVal.mType == this, - "Unexpected types for interpolation"); - NS_PRECONDITION(aResult.mType == this, "Unexpected result type"); + MOZ_ASSERT(aStartVal.mType == aEndVal.mType, + "Trying to interpolate different types"); + MOZ_ASSERT(aStartVal.mType == this, "Unexpected types for interpolation"); + MOZ_ASSERT(aResult.mType == this, "Unexpected result type"); double currentVal[2]; currentVal[0] = aStartVal.mU.mIntPair[0] + diff --git a/dom/svg/SVGLengthListSMILType.cpp b/dom/svg/SVGLengthListSMILType.cpp index 8664965a2516..0ea3a89799f8 100644 --- a/dom/svg/SVGLengthListSMILType.cpp +++ b/dom/svg/SVGLengthListSMILType.cpp @@ -36,7 +36,7 @@ SVGLengthListSMILType::Init(nsSMILValue &aValue) const void SVGLengthListSMILType::Destroy(nsSMILValue& aValue) const { - NS_PRECONDITION(aValue.mType == this, "Unexpected SMIL value type"); + MOZ_ASSERT(aValue.mType == this, "Unexpected SMIL value type"); delete static_cast(aValue.mU.mPtr); aValue.mU.mPtr = nullptr; aValue.mType = nsSMILNullType::Singleton(); @@ -46,8 +46,8 @@ nsresult SVGLengthListSMILType::Assign(nsSMILValue& aDest, const nsSMILValue& aSrc) const { - NS_PRECONDITION(aDest.mType == aSrc.mType, "Incompatible SMIL types"); - NS_PRECONDITION(aDest.mType == this, "Unexpected SMIL value"); + MOZ_ASSERT(aDest.mType == aSrc.mType, "Incompatible SMIL types"); + MOZ_ASSERT(aDest.mType == this, "Unexpected SMIL value"); const SVGLengthListAndInfo* src = static_cast(aSrc.mU.mPtr); @@ -61,8 +61,8 @@ bool SVGLengthListSMILType::IsEqual(const nsSMILValue& aLeft, const nsSMILValue& aRight) const { - NS_PRECONDITION(aLeft.mType == aRight.mType, "Incompatible SMIL types"); - NS_PRECONDITION(aLeft.mType == this, "Unexpected type for SMIL value"); + MOZ_ASSERT(aLeft.mType == aRight.mType, "Incompatible SMIL types"); + MOZ_ASSERT(aLeft.mType == this, "Unexpected type for SMIL value"); return *static_cast(aLeft.mU.mPtr) == *static_cast(aRight.mU.mPtr); @@ -73,8 +73,8 @@ SVGLengthListSMILType::Add(nsSMILValue& aDest, const nsSMILValue& aValueToAdd, uint32_t aCount) const { - NS_PRECONDITION(aDest.mType == this, "Unexpected SMIL type"); - NS_PRECONDITION(aValueToAdd.mType == this, "Incompatible SMIL type"); + MOZ_ASSERT(aDest.mType == this, "Unexpected SMIL type"); + MOZ_ASSERT(aValueToAdd.mType == this, "Incompatible SMIL type"); SVGLengthListAndInfo& dest = *static_cast(aDest.mU.mPtr); @@ -161,8 +161,8 @@ SVGLengthListSMILType::ComputeDistance(const nsSMILValue& aFrom, const nsSMILValue& aTo, double& aDistance) const { - NS_PRECONDITION(aFrom.mType == this, "Unexpected SMIL type"); - NS_PRECONDITION(aTo.mType == this, "Incompatible SMIL type"); + MOZ_ASSERT(aFrom.mType == this, "Unexpected SMIL type"); + MOZ_ASSERT(aTo.mType == this, "Incompatible SMIL type"); const SVGLengthListAndInfo& from = *static_cast(aFrom.mU.mPtr); @@ -231,11 +231,10 @@ SVGLengthListSMILType::Interpolate(const nsSMILValue& aStartVal, double aUnitDistance, nsSMILValue& aResult) const { - NS_PRECONDITION(aStartVal.mType == aEndVal.mType, - "Trying to interpolate different types"); - NS_PRECONDITION(aStartVal.mType == this, - "Unexpected types for interpolation"); - NS_PRECONDITION(aResult.mType == this, "Unexpected result type"); + MOZ_ASSERT(aStartVal.mType == aEndVal.mType, + "Trying to interpolate different types"); + MOZ_ASSERT(aStartVal.mType == this, "Unexpected types for interpolation"); + MOZ_ASSERT(aResult.mType == this, "Unexpected result type"); const SVGLengthListAndInfo& start = *static_cast(aStartVal.mU.mPtr); diff --git a/dom/svg/SVGNumberListSMILType.cpp b/dom/svg/SVGNumberListSMILType.cpp index 51bc27a688ea..0d7b8b28cc70 100644 --- a/dom/svg/SVGNumberListSMILType.cpp +++ b/dom/svg/SVGNumberListSMILType.cpp @@ -49,7 +49,7 @@ SVGNumberListSMILType::Init(nsSMILValue &aValue) const void SVGNumberListSMILType::Destroy(nsSMILValue& aValue) const { - NS_PRECONDITION(aValue.mType == this, "Unexpected SMIL value type"); + MOZ_ASSERT(aValue.mType == this, "Unexpected SMIL value type"); delete static_cast(aValue.mU.mPtr); aValue.mU.mPtr = nullptr; aValue.mType = nsSMILNullType::Singleton(); @@ -59,8 +59,8 @@ nsresult SVGNumberListSMILType::Assign(nsSMILValue& aDest, const nsSMILValue& aSrc) const { - NS_PRECONDITION(aDest.mType == aSrc.mType, "Incompatible SMIL types"); - NS_PRECONDITION(aDest.mType == this, "Unexpected SMIL value"); + MOZ_ASSERT(aDest.mType == aSrc.mType, "Incompatible SMIL types"); + MOZ_ASSERT(aDest.mType == this, "Unexpected SMIL value"); const SVGNumberListAndInfo* src = static_cast(aSrc.mU.mPtr); @@ -74,8 +74,8 @@ bool SVGNumberListSMILType::IsEqual(const nsSMILValue& aLeft, const nsSMILValue& aRight) const { - NS_PRECONDITION(aLeft.mType == aRight.mType, "Incompatible SMIL types"); - NS_PRECONDITION(aLeft.mType == this, "Unexpected type for SMIL value"); + MOZ_ASSERT(aLeft.mType == aRight.mType, "Incompatible SMIL types"); + MOZ_ASSERT(aLeft.mType == this, "Unexpected type for SMIL value"); return *static_cast(aLeft.mU.mPtr) == *static_cast(aRight.mU.mPtr); @@ -86,8 +86,8 @@ SVGNumberListSMILType::Add(nsSMILValue& aDest, const nsSMILValue& aValueToAdd, uint32_t aCount) const { - NS_PRECONDITION(aDest.mType == this, "Unexpected SMIL type"); - NS_PRECONDITION(aValueToAdd.mType == this, "Incompatible SMIL type"); + MOZ_ASSERT(aDest.mType == this, "Unexpected SMIL type"); + MOZ_ASSERT(aValueToAdd.mType == this, "Incompatible SMIL type"); SVGNumberListAndInfo& dest = *static_cast(aDest.mU.mPtr); @@ -133,8 +133,8 @@ SVGNumberListSMILType::ComputeDistance(const nsSMILValue& aFrom, const nsSMILValue& aTo, double& aDistance) const { - NS_PRECONDITION(aFrom.mType == this, "Unexpected SMIL type"); - NS_PRECONDITION(aTo.mType == this, "Incompatible SMIL type"); + MOZ_ASSERT(aFrom.mType == this, "Unexpected SMIL type"); + MOZ_ASSERT(aTo.mType == this, "Incompatible SMIL type"); const SVGNumberListAndInfo& from = *static_cast(aFrom.mU.mPtr); @@ -171,11 +171,10 @@ SVGNumberListSMILType::Interpolate(const nsSMILValue& aStartVal, double aUnitDistance, nsSMILValue& aResult) const { - NS_PRECONDITION(aStartVal.mType == aEndVal.mType, - "Trying to interpolate different types"); - NS_PRECONDITION(aStartVal.mType == this, - "Unexpected types for interpolation"); - NS_PRECONDITION(aResult.mType == this, "Unexpected result type"); + MOZ_ASSERT(aStartVal.mType == aEndVal.mType, + "Trying to interpolate different types"); + MOZ_ASSERT(aStartVal.mType == this, "Unexpected types for interpolation"); + MOZ_ASSERT(aResult.mType == this, "Unexpected result type"); const SVGNumberListAndInfo& start = *static_cast(aStartVal.mU.mPtr); diff --git a/dom/svg/SVGNumberPairSMILType.cpp b/dom/svg/SVGNumberPairSMILType.cpp index e314dfcf1d12..e5f03e9d2c87 100644 --- a/dom/svg/SVGNumberPairSMILType.cpp +++ b/dom/svg/SVGNumberPairSMILType.cpp @@ -26,7 +26,7 @@ SVGNumberPairSMILType::Init(nsSMILValue& aValue) const void SVGNumberPairSMILType::Destroy(nsSMILValue& aValue) const { - NS_PRECONDITION(aValue.mType == this, "Unexpected SMIL value"); + MOZ_ASSERT(aValue.mType == this, "Unexpected SMIL value"); aValue.mU.mNumberPair[0] = 0; aValue.mU.mNumberPair[1] = 0; aValue.mType = nsSMILNullType::Singleton(); @@ -35,8 +35,8 @@ SVGNumberPairSMILType::Destroy(nsSMILValue& aValue) const nsresult SVGNumberPairSMILType::Assign(nsSMILValue& aDest, const nsSMILValue& aSrc) const { - NS_PRECONDITION(aDest.mType == aSrc.mType, "Incompatible SMIL types"); - NS_PRECONDITION(aDest.mType == this, "Unexpected SMIL value"); + MOZ_ASSERT(aDest.mType == aSrc.mType, "Incompatible SMIL types"); + MOZ_ASSERT(aDest.mType == this, "Unexpected SMIL value"); aDest.mU.mNumberPair[0] = aSrc.mU.mNumberPair[0]; aDest.mU.mNumberPair[1] = aSrc.mU.mNumberPair[1]; @@ -47,8 +47,8 @@ bool SVGNumberPairSMILType::IsEqual(const nsSMILValue& aLeft, const nsSMILValue& aRight) const { - NS_PRECONDITION(aLeft.mType == aRight.mType, "Incompatible SMIL types"); - NS_PRECONDITION(aLeft.mType == this, "Unexpected type for SMIL value"); + MOZ_ASSERT(aLeft.mType == aRight.mType, "Incompatible SMIL types"); + MOZ_ASSERT(aLeft.mType == this, "Unexpected type for SMIL value"); return aLeft.mU.mNumberPair[0] == aRight.mU.mNumberPair[0] && aLeft.mU.mNumberPair[1] == aRight.mU.mNumberPair[1]; @@ -58,9 +58,9 @@ nsresult SVGNumberPairSMILType::Add(nsSMILValue& aDest, const nsSMILValue& aValueToAdd, uint32_t aCount) const { - NS_PRECONDITION(aValueToAdd.mType == aDest.mType, + MOZ_ASSERT(aValueToAdd.mType == aDest.mType, "Trying to add invalid types"); - NS_PRECONDITION(aValueToAdd.mType == this, "Unexpected source type"); + MOZ_ASSERT(aValueToAdd.mType == this, "Unexpected source type"); aDest.mU.mNumberPair[0] += aValueToAdd.mU.mNumberPair[0] * aCount; aDest.mU.mNumberPair[1] += aValueToAdd.mU.mNumberPair[1] * aCount; @@ -73,8 +73,8 @@ SVGNumberPairSMILType::ComputeDistance(const nsSMILValue& aFrom, const nsSMILValue& aTo, double& aDistance) const { - NS_PRECONDITION(aFrom.mType == aTo.mType,"Trying to compare different types"); - NS_PRECONDITION(aFrom.mType == this, "Unexpected source type"); + MOZ_ASSERT(aFrom.mType == aTo.mType,"Trying to compare different types"); + MOZ_ASSERT(aFrom.mType == this, "Unexpected source type"); double delta[2]; delta[0] = aTo.mU.mNumberPair[0] - aFrom.mU.mNumberPair[0]; @@ -90,11 +90,10 @@ SVGNumberPairSMILType::Interpolate(const nsSMILValue& aStartVal, double aUnitDistance, nsSMILValue& aResult) const { - NS_PRECONDITION(aStartVal.mType == aEndVal.mType, - "Trying to interpolate different types"); - NS_PRECONDITION(aStartVal.mType == this, - "Unexpected types for interpolation"); - NS_PRECONDITION(aResult.mType == this, "Unexpected result type"); + MOZ_ASSERT(aStartVal.mType == aEndVal.mType, + "Trying to interpolate different types"); + MOZ_ASSERT(aStartVal.mType == this, "Unexpected types for interpolation"); + MOZ_ASSERT(aResult.mType == this, "Unexpected result type"); aResult.mU.mNumberPair[0] = float(aStartVal.mU.mNumberPair[0] + diff --git a/dom/svg/SVGOrientSMILType.cpp b/dom/svg/SVGOrientSMILType.cpp index e129c084eb47..408e1c63b3f9 100644 --- a/dom/svg/SVGOrientSMILType.cpp +++ b/dom/svg/SVGOrientSMILType.cpp @@ -32,7 +32,7 @@ SVGOrientSMILType::Init(nsSMILValue& aValue) const void SVGOrientSMILType::Destroy(nsSMILValue& aValue) const { - NS_PRECONDITION(aValue.mType == this, "Unexpected SMIL value."); + MOZ_ASSERT(aValue.mType == this, "Unexpected SMIL value."); aValue.mU.mPtr = nullptr; aValue.mType = nsSMILNullType::Singleton(); } @@ -40,8 +40,8 @@ SVGOrientSMILType::Destroy(nsSMILValue& aValue) const nsresult SVGOrientSMILType::Assign(nsSMILValue& aDest, const nsSMILValue& aSrc) const { - NS_PRECONDITION(aDest.mType == aSrc.mType, "Incompatible SMIL types."); - NS_PRECONDITION(aDest.mType == this, "Unexpected SMIL value."); + MOZ_ASSERT(aDest.mType == aSrc.mType, "Incompatible SMIL types."); + MOZ_ASSERT(aDest.mType == this, "Unexpected SMIL value."); aDest.mU.mOrient.mAngle = aSrc.mU.mOrient.mAngle; aDest.mU.mOrient.mUnit = aSrc.mU.mOrient.mUnit; @@ -53,8 +53,8 @@ bool SVGOrientSMILType::IsEqual(const nsSMILValue& aLeft, const nsSMILValue& aRight) const { - NS_PRECONDITION(aLeft.mType == aRight.mType, "Incompatible SMIL types"); - NS_PRECONDITION(aLeft.mType == this, "Unexpected type for SMIL value"); + MOZ_ASSERT(aLeft.mType == aRight.mType, "Incompatible SMIL types"); + MOZ_ASSERT(aLeft.mType == this, "Unexpected type for SMIL value"); return aLeft.mU.mOrient.mAngle == aRight.mU.mOrient.mAngle && @@ -66,9 +66,9 @@ nsresult SVGOrientSMILType::Add(nsSMILValue& aDest, const nsSMILValue& aValueToAdd, uint32_t aCount) const { - NS_PRECONDITION(aValueToAdd.mType == aDest.mType, + MOZ_ASSERT(aValueToAdd.mType == aDest.mType, "Trying to add invalid types"); - NS_PRECONDITION(aValueToAdd.mType == this, "Unexpected source type"); + MOZ_ASSERT(aValueToAdd.mType == this, "Unexpected source type"); if (aDest.mU.mOrient.mOrientType != SVG_MARKER_ORIENT_ANGLE || aValueToAdd.mU.mOrient.mOrientType != SVG_MARKER_ORIENT_ANGLE) { @@ -98,8 +98,8 @@ SVGOrientSMILType::ComputeDistance(const nsSMILValue& aFrom, const nsSMILValue& aTo, double& aDistance) const { - NS_PRECONDITION(aFrom.mType == aTo.mType,"Trying to compare different types"); - NS_PRECONDITION(aFrom.mType == this, "Unexpected source type"); + MOZ_ASSERT(aFrom.mType == aTo.mType,"Trying to compare different types"); + MOZ_ASSERT(aFrom.mType == this, "Unexpected source type"); if (aFrom.mU.mOrient.mOrientType != SVG_MARKER_ORIENT_ANGLE || aTo.mU.mOrient.mOrientType != SVG_MARKER_ORIENT_ANGLE) { @@ -124,11 +124,10 @@ SVGOrientSMILType::Interpolate(const nsSMILValue& aStartVal, double aUnitDistance, nsSMILValue& aResult) const { - NS_PRECONDITION(aStartVal.mType == aEndVal.mType, - "Trying to interpolate different types"); - NS_PRECONDITION(aStartVal.mType == this, - "Unexpected types for interpolation."); - NS_PRECONDITION(aResult.mType == this, "Unexpected result type."); + MOZ_ASSERT(aStartVal.mType == aEndVal.mType, + "Trying to interpolate different types"); + MOZ_ASSERT(aStartVal.mType == this, "Unexpected types for interpolation."); + MOZ_ASSERT(aResult.mType == this, "Unexpected result type."); if (aStartVal.mU.mOrient.mOrientType != SVG_MARKER_ORIENT_ANGLE || aEndVal.mU.mOrient.mOrientType != SVG_MARKER_ORIENT_ANGLE) { diff --git a/dom/svg/SVGPathSegListSMILType.cpp b/dom/svg/SVGPathSegListSMILType.cpp index 0ddd7783c925..92469a5108fb 100644 --- a/dom/svg/SVGPathSegListSMILType.cpp +++ b/dom/svg/SVGPathSegListSMILType.cpp @@ -32,7 +32,7 @@ SVGPathSegListSMILType::Init(nsSMILValue &aValue) const void SVGPathSegListSMILType::Destroy(nsSMILValue& aValue) const { - NS_PRECONDITION(aValue.mType == this, "Unexpected SMIL value type"); + MOZ_ASSERT(aValue.mType == this, "Unexpected SMIL value type"); delete static_cast(aValue.mU.mPtr); aValue.mU.mPtr = nullptr; aValue.mType = nsSMILNullType::Singleton(); @@ -42,8 +42,8 @@ nsresult SVGPathSegListSMILType::Assign(nsSMILValue& aDest, const nsSMILValue& aSrc) const { - NS_PRECONDITION(aDest.mType == aSrc.mType, "Incompatible SMIL types"); - NS_PRECONDITION(aDest.mType == this, "Unexpected SMIL value"); + MOZ_ASSERT(aDest.mType == aSrc.mType, "Incompatible SMIL types"); + MOZ_ASSERT(aDest.mType == this, "Unexpected SMIL value"); const SVGPathDataAndInfo* src = static_cast(aSrc.mU.mPtr); @@ -57,8 +57,8 @@ bool SVGPathSegListSMILType::IsEqual(const nsSMILValue& aLeft, const nsSMILValue& aRight) const { - NS_PRECONDITION(aLeft.mType == aRight.mType, "Incompatible SMIL types"); - NS_PRECONDITION(aLeft.mType == this, "Unexpected type for SMIL value"); + MOZ_ASSERT(aLeft.mType == aRight.mType, "Incompatible SMIL types"); + MOZ_ASSERT(aLeft.mType == this, "Unexpected type for SMIL value"); return *static_cast(aLeft.mU.mPtr) == *static_cast(aRight.mU.mPtr); @@ -400,8 +400,8 @@ SVGPathSegListSMILType::Add(nsSMILValue& aDest, const nsSMILValue& aValueToAdd, uint32_t aCount) const { - NS_PRECONDITION(aDest.mType == this, "Unexpected SMIL type"); - NS_PRECONDITION(aValueToAdd.mType == this, "Incompatible SMIL type"); + MOZ_ASSERT(aDest.mType == this, "Unexpected SMIL type"); + MOZ_ASSERT(aValueToAdd.mType == this, "Incompatible SMIL type"); SVGPathDataAndInfo& dest = *static_cast(aDest.mU.mPtr); @@ -440,8 +440,8 @@ SVGPathSegListSMILType::ComputeDistance(const nsSMILValue& aFrom, const nsSMILValue& aTo, double& aDistance) const { - NS_PRECONDITION(aFrom.mType == this, "Unexpected SMIL type"); - NS_PRECONDITION(aTo.mType == this, "Incompatible SMIL type"); + MOZ_ASSERT(aFrom.mType == this, "Unexpected SMIL type"); + MOZ_ASSERT(aTo.mType == this, "Incompatible SMIL type"); // See https://bugzilla.mozilla.org/show_bug.cgi?id=522306#c18 @@ -455,11 +455,10 @@ SVGPathSegListSMILType::Interpolate(const nsSMILValue& aStartVal, double aUnitDistance, nsSMILValue& aResult) const { - NS_PRECONDITION(aStartVal.mType == aEndVal.mType, - "Trying to interpolate different types"); - NS_PRECONDITION(aStartVal.mType == this, - "Unexpected types for interpolation"); - NS_PRECONDITION(aResult.mType == this, "Unexpected result type"); + MOZ_ASSERT(aStartVal.mType == aEndVal.mType, + "Trying to interpolate different types"); + MOZ_ASSERT(aStartVal.mType == this, "Unexpected types for interpolation"); + MOZ_ASSERT(aResult.mType == this, "Unexpected result type"); const SVGPathDataAndInfo& start = *static_cast(aStartVal.mU.mPtr); diff --git a/dom/svg/SVGPointListSMILType.cpp b/dom/svg/SVGPointListSMILType.cpp index 4b8c6abe71c4..9bcd2cc786cc 100644 --- a/dom/svg/SVGPointListSMILType.cpp +++ b/dom/svg/SVGPointListSMILType.cpp @@ -32,7 +32,7 @@ SVGPointListSMILType::Init(nsSMILValue &aValue) const void SVGPointListSMILType::Destroy(nsSMILValue& aValue) const { - NS_PRECONDITION(aValue.mType == this, "Unexpected SMIL value type"); + MOZ_ASSERT(aValue.mType == this, "Unexpected SMIL value type"); delete static_cast(aValue.mU.mPtr); aValue.mU.mPtr = nullptr; aValue.mType = nsSMILNullType::Singleton(); @@ -42,8 +42,8 @@ nsresult SVGPointListSMILType::Assign(nsSMILValue& aDest, const nsSMILValue& aSrc) const { - NS_PRECONDITION(aDest.mType == aSrc.mType, "Incompatible SMIL types"); - NS_PRECONDITION(aDest.mType == this, "Unexpected SMIL value"); + MOZ_ASSERT(aDest.mType == aSrc.mType, "Incompatible SMIL types"); + MOZ_ASSERT(aDest.mType == this, "Unexpected SMIL value"); const SVGPointListAndInfo* src = static_cast(aSrc.mU.mPtr); @@ -57,8 +57,8 @@ bool SVGPointListSMILType::IsEqual(const nsSMILValue& aLeft, const nsSMILValue& aRight) const { - NS_PRECONDITION(aLeft.mType == aRight.mType, "Incompatible SMIL types"); - NS_PRECONDITION(aLeft.mType == this, "Unexpected type for SMIL value"); + MOZ_ASSERT(aLeft.mType == aRight.mType, "Incompatible SMIL types"); + MOZ_ASSERT(aLeft.mType == this, "Unexpected type for SMIL value"); return *static_cast(aLeft.mU.mPtr) == *static_cast(aRight.mU.mPtr); @@ -69,8 +69,8 @@ SVGPointListSMILType::Add(nsSMILValue& aDest, const nsSMILValue& aValueToAdd, uint32_t aCount) const { - NS_PRECONDITION(aDest.mType == this, "Unexpected SMIL type"); - NS_PRECONDITION(aValueToAdd.mType == this, "Incompatible SMIL type"); + MOZ_ASSERT(aDest.mType == this, "Unexpected SMIL type"); + MOZ_ASSERT(aValueToAdd.mType == this, "Incompatible SMIL type"); SVGPointListAndInfo& dest = *static_cast(aDest.mU.mPtr); @@ -112,8 +112,8 @@ SVGPointListSMILType::ComputeDistance(const nsSMILValue& aFrom, const nsSMILValue& aTo, double& aDistance) const { - NS_PRECONDITION(aFrom.mType == this, "Unexpected SMIL type"); - NS_PRECONDITION(aTo.mType == this, "Incompatible SMIL type"); + MOZ_ASSERT(aFrom.mType == this, "Unexpected SMIL type"); + MOZ_ASSERT(aTo.mType == this, "Incompatible SMIL type"); const SVGPointListAndInfo& from = *static_cast(aFrom.mU.mPtr); @@ -151,11 +151,10 @@ SVGPointListSMILType::Interpolate(const nsSMILValue& aStartVal, double aUnitDistance, nsSMILValue& aResult) const { - NS_PRECONDITION(aStartVal.mType == aEndVal.mType, - "Trying to interpolate different types"); - NS_PRECONDITION(aStartVal.mType == this, - "Unexpected types for interpolation"); - NS_PRECONDITION(aResult.mType == this, "Unexpected result type"); + MOZ_ASSERT(aStartVal.mType == aEndVal.mType, + "Trying to interpolate different types"); + MOZ_ASSERT(aStartVal.mType == this, "Unexpected types for interpolation"); + MOZ_ASSERT(aResult.mType == this, "Unexpected result type"); const SVGPointListAndInfo& start = *static_cast(aStartVal.mU.mPtr); diff --git a/dom/svg/SVGTransformListSMILType.cpp b/dom/svg/SVGTransformListSMILType.cpp index dd617a65e03c..16bbe87344e1 100644 --- a/dom/svg/SVGTransformListSMILType.cpp +++ b/dom/svg/SVGTransformListSMILType.cpp @@ -22,7 +22,7 @@ typedef FallibleTArray TransformArray; void SVGTransformListSMILType::Init(nsSMILValue &aValue) const { - NS_PRECONDITION(aValue.IsNull(), "Unexpected value type"); + MOZ_ASSERT(aValue.IsNull(), "Unexpected value type"); TransformArray* transforms = new TransformArray(1); aValue.mU.mPtr = transforms; @@ -32,7 +32,7 @@ SVGTransformListSMILType::Init(nsSMILValue &aValue) const void SVGTransformListSMILType::Destroy(nsSMILValue& aValue) const { - NS_PRECONDITION(aValue.mType == this, "Unexpected SMIL value type"); + MOZ_ASSERT(aValue.mType == this, "Unexpected SMIL value type"); TransformArray* params = static_cast(aValue.mU.mPtr); delete params; aValue.mU.mPtr = nullptr; @@ -43,8 +43,8 @@ nsresult SVGTransformListSMILType::Assign(nsSMILValue& aDest, const nsSMILValue& aSrc) const { - NS_PRECONDITION(aDest.mType == aSrc.mType, "Incompatible SMIL types"); - NS_PRECONDITION(aDest.mType == this, "Unexpected SMIL value"); + MOZ_ASSERT(aDest.mType == aSrc.mType, "Incompatible SMIL types"); + MOZ_ASSERT(aDest.mType == this, "Unexpected SMIL value"); const TransformArray* srcTransforms = static_cast(aSrc.mU.mPtr); @@ -60,8 +60,8 @@ bool SVGTransformListSMILType::IsEqual(const nsSMILValue& aLeft, const nsSMILValue& aRight) const { - NS_PRECONDITION(aLeft.mType == aRight.mType, "Incompatible SMIL types"); - NS_PRECONDITION(aLeft.mType == this, "Unexpected SMIL type"); + MOZ_ASSERT(aLeft.mType == aRight.mType, "Incompatible SMIL types"); + MOZ_ASSERT(aLeft.mType == this, "Unexpected SMIL type"); const TransformArray& leftArr (*static_cast(aLeft.mU.mPtr)); @@ -90,8 +90,8 @@ SVGTransformListSMILType::Add(nsSMILValue& aDest, const nsSMILValue& aValueToAdd, uint32_t aCount) const { - NS_PRECONDITION(aDest.mType == this, "Unexpected SMIL type"); - NS_PRECONDITION(aDest.mType == aValueToAdd.mType, "Incompatible SMIL types"); + MOZ_ASSERT(aDest.mType == this, "Unexpected SMIL type"); + MOZ_ASSERT(aDest.mType == aValueToAdd.mType, "Incompatible SMIL types"); TransformArray& dstTransforms(*static_cast(aDest.mU.mPtr)); const TransformArray& srcTransforms @@ -142,8 +142,8 @@ nsresult SVGTransformListSMILType::SandwichAdd(nsSMILValue& aDest, const nsSMILValue& aValueToAdd) const { - NS_PRECONDITION(aDest.mType == this, "Unexpected SMIL type"); - NS_PRECONDITION(aDest.mType == aValueToAdd.mType, "Incompatible SMIL types"); + MOZ_ASSERT(aDest.mType == this, "Unexpected SMIL type"); + MOZ_ASSERT(aDest.mType == aValueToAdd.mType, "Incompatible SMIL types"); // For a sandwich add means a matrix post-multiplication // which just means to put the additional transform on the end of the array @@ -180,9 +180,9 @@ SVGTransformListSMILType::ComputeDistance(const nsSMILValue& aFrom, const nsSMILValue& aTo, double& aDistance) const { - NS_PRECONDITION(aFrom.mType == aTo.mType, + MOZ_ASSERT(aFrom.mType == aTo.mType, "Can't compute difference between different SMIL types"); - NS_PRECONDITION(aFrom.mType == this, "Unexpected SMIL type"); + MOZ_ASSERT(aFrom.mType == this, "Unexpected SMIL type"); const TransformArray* fromTransforms = static_cast(aFrom.mU.mPtr); @@ -245,11 +245,10 @@ SVGTransformListSMILType::Interpolate(const nsSMILValue& aStartVal, double aUnitDistance, nsSMILValue& aResult) const { - NS_PRECONDITION(aStartVal.mType == aEndVal.mType, - "Can't interpolate between different SMIL types"); - NS_PRECONDITION(aStartVal.mType == this, - "Unexpected type for interpolation"); - NS_PRECONDITION(aResult.mType == this, "Unexpected result type"); + MOZ_ASSERT(aStartVal.mType == aEndVal.mType, + "Can't interpolate between different SMIL types"); + MOZ_ASSERT(aStartVal.mType == this, "Unexpected type for interpolation"); + MOZ_ASSERT(aResult.mType == this, "Unexpected result type"); const TransformArray& startTransforms = (*static_cast(aStartVal.mU.mPtr)); @@ -319,7 +318,7 @@ SVGTransformListSMILType::AppendTransform( const SVGTransformSMILData& aTransform, nsSMILValue& aValue) { - NS_PRECONDITION(aValue.mType == Singleton(), "Unexpected SMIL value type"); + MOZ_ASSERT(aValue.mType == Singleton(), "Unexpected SMIL value type"); TransformArray& transforms = *static_cast(aValue.mU.mPtr); return transforms.AppendElement(aTransform, fallible) ? @@ -331,7 +330,7 @@ bool SVGTransformListSMILType::AppendTransforms(const SVGTransformList& aList, nsSMILValue& aValue) { - NS_PRECONDITION(aValue.mType == Singleton(), "Unexpected SMIL value type"); + MOZ_ASSERT(aValue.mType == Singleton(), "Unexpected SMIL value type"); TransformArray& transforms = *static_cast(aValue.mU.mPtr); @@ -352,7 +351,7 @@ bool SVGTransformListSMILType::GetTransforms(const nsSMILValue& aValue, FallibleTArray& aTransforms) { - NS_PRECONDITION(aValue.mType == Singleton(), "Unexpected SMIL value type"); + MOZ_ASSERT(aValue.mType == Singleton(), "Unexpected SMIL value type"); const TransformArray& smilTransforms = *static_cast(aValue.mU.mPtr); diff --git a/dom/svg/SVGViewBoxSMILType.cpp b/dom/svg/SVGViewBoxSMILType.cpp index af85ed9410a7..deb3f7aa6fc2 100644 --- a/dom/svg/SVGViewBoxSMILType.cpp +++ b/dom/svg/SVGViewBoxSMILType.cpp @@ -26,7 +26,7 @@ SVGViewBoxSMILType::Init(nsSMILValue& aValue) const void SVGViewBoxSMILType::Destroy(nsSMILValue& aValue) const { - NS_PRECONDITION(aValue.mType == this, "Unexpected SMIL value"); + MOZ_ASSERT(aValue.mType == this, "Unexpected SMIL value"); delete static_cast(aValue.mU.mPtr); aValue.mU.mPtr = nullptr; aValue.mType = nsSMILNullType::Singleton(); @@ -35,8 +35,8 @@ SVGViewBoxSMILType::Destroy(nsSMILValue& aValue) const nsresult SVGViewBoxSMILType::Assign(nsSMILValue& aDest, const nsSMILValue& aSrc) const { - NS_PRECONDITION(aDest.mType == aSrc.mType, "Incompatible SMIL types"); - NS_PRECONDITION(aDest.mType == this, "Unexpected SMIL value"); + MOZ_ASSERT(aDest.mType == aSrc.mType, "Incompatible SMIL types"); + MOZ_ASSERT(aDest.mType == this, "Unexpected SMIL value"); const nsSVGViewBoxRect* src = static_cast(aSrc.mU.mPtr); nsSVGViewBoxRect* dst = static_cast(aDest.mU.mPtr); @@ -48,8 +48,8 @@ bool SVGViewBoxSMILType::IsEqual(const nsSMILValue& aLeft, const nsSMILValue& aRight) const { - NS_PRECONDITION(aLeft.mType == aRight.mType, "Incompatible SMIL types"); - NS_PRECONDITION(aLeft.mType == this, "Unexpected type for SMIL value"); + MOZ_ASSERT(aLeft.mType == aRight.mType, "Incompatible SMIL types"); + MOZ_ASSERT(aLeft.mType == this, "Unexpected type for SMIL value"); const nsSVGViewBoxRect* leftBox = static_cast(aLeft.mU.mPtr); @@ -62,9 +62,9 @@ nsresult SVGViewBoxSMILType::Add(nsSMILValue& aDest, const nsSMILValue& aValueToAdd, uint32_t aCount) const { - NS_PRECONDITION(aValueToAdd.mType == aDest.mType, + MOZ_ASSERT(aValueToAdd.mType == aDest.mType, "Trying to add invalid types"); - NS_PRECONDITION(aValueToAdd.mType == this, "Unexpected source type"); + MOZ_ASSERT(aValueToAdd.mType == this, "Unexpected source type"); // See https://bugzilla.mozilla.org/show_bug.cgi?id=541884#c3 and the two // comments that follow that one for arguments for and against allowing @@ -78,8 +78,8 @@ SVGViewBoxSMILType::ComputeDistance(const nsSMILValue& aFrom, const nsSMILValue& aTo, double& aDistance) const { - NS_PRECONDITION(aFrom.mType == aTo.mType,"Trying to compare different types"); - NS_PRECONDITION(aFrom.mType == this, "Unexpected source type"); + MOZ_ASSERT(aFrom.mType == aTo.mType,"Trying to compare different types"); + MOZ_ASSERT(aFrom.mType == this, "Unexpected source type"); const nsSVGViewBoxRect* from = static_cast(aFrom.mU.mPtr); const nsSVGViewBoxRect* to = static_cast(aTo.mU.mPtr); @@ -110,11 +110,10 @@ SVGViewBoxSMILType::Interpolate(const nsSMILValue& aStartVal, double aUnitDistance, nsSMILValue& aResult) const { - NS_PRECONDITION(aStartVal.mType == aEndVal.mType, - "Trying to interpolate different types"); - NS_PRECONDITION(aStartVal.mType == this, - "Unexpected types for interpolation"); - NS_PRECONDITION(aResult.mType == this, "Unexpected result type"); + MOZ_ASSERT(aStartVal.mType == aEndVal.mType, + "Trying to interpolate different types"); + MOZ_ASSERT(aStartVal.mType == this, "Unexpected types for interpolation"); + MOZ_ASSERT(aResult.mType == this, "Unexpected result type"); const nsSVGViewBoxRect* start = static_cast(aStartVal.mU.mPtr); const nsSVGViewBoxRect* end = static_cast(aEndVal.mU.mPtr); diff --git a/dom/xbl/nsBindingManager.cpp b/dom/xbl/nsBindingManager.cpp index 4a0de1b540ed..44513a690ac2 100644 --- a/dom/xbl/nsBindingManager.cpp +++ b/dom/xbl/nsBindingManager.cpp @@ -202,7 +202,7 @@ nsBindingManager::RemovedFromDocumentInternal(nsIContent* aContent, nsIDocument* aOldDocument, DestructorHandling aDestructorHandling) { - NS_PRECONDITION(aOldDocument != nullptr, "no old document"); + MOZ_ASSERT(aOldDocument != nullptr, "no old document"); RefPtr binding = aContent->GetXBLBinding(); if (binding) { @@ -298,7 +298,7 @@ nsBindingManager::LoadBindingDocument(nsIDocument* aBoundDoc, nsIURI* aURL, nsIPrincipal* aOriginPrincipal) { - NS_PRECONDITION(aURL, "Must have a URI to load!"); + MOZ_ASSERT(aURL, "Must have a URI to load!"); // First we need to load our binding. nsXBLService* xblService = nsXBLService::GetInstance(); @@ -471,7 +471,7 @@ nsBindingManager::ExecuteDetachedHandlers() nsresult nsBindingManager::PutXBLDocumentInfo(nsXBLDocumentInfo* aDocumentInfo) { - NS_PRECONDITION(aDocumentInfo, "Must have a non-null documentinfo!"); + MOZ_ASSERT(aDocumentInfo, "Must have a non-null documentinfo!"); if (!mDocumentTable) { mDocumentTable = new nsRefPtrHashtable(); @@ -502,7 +502,7 @@ nsBindingManager::GetXBLDocumentInfo(nsIURI* aURL) nsresult nsBindingManager::PutLoadingDocListener(nsIURI* aURL, nsIStreamListener* aListener) { - NS_PRECONDITION(aListener, "Must have a non-null listener!"); + MOZ_ASSERT(aListener, "Must have a non-null listener!"); if (!mLoadingDocTable) { mLoadingDocTable = diff --git a/dom/xbl/nsXBLContentSink.cpp b/dom/xbl/nsXBLContentSink.cpp index a7640d260faf..ebf9c4826c35 100644 --- a/dom/xbl/nsXBLContentSink.cpp +++ b/dom/xbl/nsXBLContentSink.cpp @@ -170,7 +170,7 @@ nsXBLContentSink::ReportError(const char16_t* aErrorText, nsIScriptError *aError, bool *_retval) { - NS_PRECONDITION(aError && aSourceText && aErrorText, "Check arguments!!!"); + MOZ_ASSERT(aError && aSourceText && aErrorText, "Check arguments!!!"); // XXX FIXME This function overrides and calls on // nsXMLContentSink::ReportError, and probably should die. See bug 347826. diff --git a/dom/xbl/nsXBLProtoImplField.cpp b/dom/xbl/nsXBLProtoImplField.cpp index db5380c62bed..595e9309678b 100644 --- a/dom/xbl/nsXBLProtoImplField.cpp +++ b/dom/xbl/nsXBLProtoImplField.cpp @@ -375,9 +375,8 @@ nsXBLProtoImplField::InstallField(JS::Handle aBoundNode, const nsXBLPrototypeBinding& aProtoBinding, bool* aDidInstall) const { - NS_PRECONDITION(aBoundNode, - "uh-oh, bound node should NOT be null or bad things will " - "happen"); + MOZ_ASSERT(aBoundNode, + "uh-oh, bound node should NOT be null or bad things will happen"); *aDidInstall = false; diff --git a/dom/xbl/nsXBLProtoImplMethod.cpp b/dom/xbl/nsXBLProtoImplMethod.cpp index f0c58713c8de..0c52d0db6ac9 100644 --- a/dom/xbl/nsXBLProtoImplMethod.cpp +++ b/dom/xbl/nsXBLProtoImplMethod.cpp @@ -44,8 +44,8 @@ nsXBLProtoImplMethod::~nsXBLProtoImplMethod() void nsXBLProtoImplMethod::AppendBodyText(const nsAString& aText) { - NS_PRECONDITION(!IsCompiled(), - "Must not be compiled when accessing uncompiled method"); + MOZ_ASSERT(!IsCompiled(), + "Must not be compiled when accessing uncompiled method"); nsXBLUncompiledMethod* uncompiledMethod = GetUncompiledMethod(); if (!uncompiledMethod) { @@ -59,8 +59,8 @@ nsXBLProtoImplMethod::AppendBodyText(const nsAString& aText) void nsXBLProtoImplMethod::AddParameter(const nsAString& aText) { - NS_PRECONDITION(!IsCompiled(), - "Must not be compiled when accessing uncompiled method"); + MOZ_ASSERT(!IsCompiled(), + "Must not be compiled when accessing uncompiled method"); if (aText.IsEmpty()) { NS_WARNING("Empty name attribute in xbl:parameter!"); @@ -79,8 +79,8 @@ nsXBLProtoImplMethod::AddParameter(const nsAString& aText) void nsXBLProtoImplMethod::SetLineNumber(uint32_t aLineNumber) { - NS_PRECONDITION(!IsCompiled(), - "Must not be compiled when accessing uncompiled method"); + MOZ_ASSERT(!IsCompiled(), + "Must not be compiled when accessing uncompiled method"); nsXBLUncompiledMethod* uncompiledMethod = GetUncompiledMethod(); if (!uncompiledMethod) { @@ -95,7 +95,7 @@ nsresult nsXBLProtoImplMethod::InstallMember(JSContext* aCx, JS::Handle aTargetClassObject) { - NS_PRECONDITION(IsCompiled(), + MOZ_ASSERT(IsCompiled(), "Should not be installing an uncompiled method"); MOZ_ASSERT(js::IsObjectInContextCompartment(aTargetClassObject, aCx)); @@ -130,9 +130,9 @@ nsXBLProtoImplMethod::CompileMember(AutoJSAPI& jsapi, const nsString& aClassStr, JS::Handle aClassObject) { AssertInCompilationScope(); - NS_PRECONDITION(!IsCompiled(), + MOZ_ASSERT(!IsCompiled(), "Trying to compile an already-compiled method"); - NS_PRECONDITION(aClassObject, + MOZ_ASSERT(aClassObject, "Must have class object to compile"); nsXBLUncompiledMethod* uncompiledMethod = GetUncompiledMethod(); @@ -263,7 +263,7 @@ nsXBLProtoImplAnonymousMethod::Execute(nsIContent* aBoundElement, const nsXBLPrototypeBinding& aProtoBinding) { MOZ_ASSERT(aBoundElement->IsElement()); - NS_PRECONDITION(IsCompiled(), "Can't execute uncompiled method"); + MOZ_ASSERT(IsCompiled(), "Can't execute uncompiled method"); if (!GetCompiledMethod()) { // Nothing to do here diff --git a/dom/xbl/nsXBLProtoImplProperty.cpp b/dom/xbl/nsXBLProtoImplProperty.cpp index a953f67cf9c6..b05aa361bbc4 100644 --- a/dom/xbl/nsXBLProtoImplProperty.cpp +++ b/dom/xbl/nsXBLProtoImplProperty.cpp @@ -86,8 +86,7 @@ void nsXBLProtoImplProperty::EnsureUncompiledText(PropertyOp& aPropertyOp) void nsXBLProtoImplProperty::AppendGetterText(const nsAString& aText) { - NS_PRECONDITION(!mIsCompiled, - "Must not be compiled when accessing getter text"); + MOZ_ASSERT(!mIsCompiled, "Must not be compiled when accessing getter text"); EnsureUncompiledText(mGetter); mGetter.GetUncompiled()->AppendText(aText); } @@ -95,8 +94,7 @@ nsXBLProtoImplProperty::AppendGetterText(const nsAString& aText) void nsXBLProtoImplProperty::AppendSetterText(const nsAString& aText) { - NS_PRECONDITION(!mIsCompiled, - "Must not be compiled when accessing setter text"); + MOZ_ASSERT(!mIsCompiled, "Must not be compiled when accessing setter text"); EnsureUncompiledText(mSetter); mSetter.GetUncompiled()->AppendText(aText); } @@ -104,8 +102,7 @@ nsXBLProtoImplProperty::AppendSetterText(const nsAString& aText) void nsXBLProtoImplProperty::SetGetterLineNumber(uint32_t aLineNumber) { - NS_PRECONDITION(!mIsCompiled, - "Must not be compiled when accessing getter text"); + MOZ_ASSERT(!mIsCompiled, "Must not be compiled when accessing getter text"); EnsureUncompiledText(mGetter); mGetter.GetUncompiled()->SetLineNumber(aLineNumber); } @@ -113,8 +110,7 @@ nsXBLProtoImplProperty::SetGetterLineNumber(uint32_t aLineNumber) void nsXBLProtoImplProperty::SetSetterLineNumber(uint32_t aLineNumber) { - NS_PRECONDITION(!mIsCompiled, - "Must not be compiled when accessing setter text"); + MOZ_ASSERT(!mIsCompiled, "Must not be compiled when accessing setter text"); EnsureUncompiledText(mSetter); mSetter.GetUncompiled()->SetLineNumber(aLineNumber); } @@ -125,8 +121,7 @@ nsresult nsXBLProtoImplProperty::InstallMember(JSContext *aCx, JS::Handle aTargetClassObject) { - NS_PRECONDITION(mIsCompiled, - "Should not be installing an uncompiled property"); + MOZ_ASSERT(mIsCompiled, "Should not be installing an uncompiled property"); MOZ_ASSERT(mGetter.IsCompiled() && mSetter.IsCompiled()); MOZ_ASSERT(js::IsObjectInContextCompartment(aTargetClassObject, aCx)); @@ -169,10 +164,8 @@ nsXBLProtoImplProperty::CompileMember(AutoJSAPI& jsapi, const nsString& aClassSt JS::Handle aClassObject) { AssertInCompilationScope(); - NS_PRECONDITION(!mIsCompiled, - "Trying to compile an already-compiled property"); - NS_PRECONDITION(aClassObject, - "Must have class object to compile"); + MOZ_ASSERT(!mIsCompiled, "Trying to compile an already-compiled property"); + MOZ_ASSERT(aClassObject, "Must have class object to compile"); MOZ_ASSERT(!mGetter.IsCompiled() && !mSetter.IsCompiled()); JSContext *cx = jsapi.cx(); diff --git a/dom/xbl/nsXBLService.cpp b/dom/xbl/nsXBLService.cpp index 174abc0e1930..8886eeb73da2 100644 --- a/dom/xbl/nsXBLService.cpp +++ b/dom/xbl/nsXBLService.cpp @@ -480,7 +480,7 @@ nsXBLService::LoadBindings(Element* aElement, nsIURI* aURL, nsIPrincipal* aOriginPrincipal, nsXBLBinding** aBinding, bool* aResolveStyle) { - NS_PRECONDITION(aOriginPrincipal, "Must have an origin principal"); + MOZ_ASSERT(aOriginPrincipal, "Must have an origin principal"); *aBinding = nullptr; *aResolveStyle = false; @@ -900,9 +900,9 @@ nsXBLService::LoadBindingDocumentInfo(nsIContent* aBoundElement, bool aForceSyncLoad, nsXBLDocumentInfo** aResult) { - NS_PRECONDITION(aBindingURI, "Must have a binding URI"); - NS_PRECONDITION(!aOriginPrincipal || aBoundDocument, - "If we're doing a security check, we better have a document!"); + MOZ_ASSERT(aBindingURI, "Must have a binding URI"); + MOZ_ASSERT(!aOriginPrincipal || aBoundDocument, + "If we're doing a security check, we better have a document!"); *aResult = nullptr; // Allow XBL in unprivileged documents if it's specified in a privileged or diff --git a/dom/xhr/XMLHttpRequestMainThread.cpp b/dom/xhr/XMLHttpRequestMainThread.cpp index 520430779704..dac7fe21230e 100644 --- a/dom/xhr/XMLHttpRequestMainThread.cpp +++ b/dom/xhr/XMLHttpRequestMainThread.cpp @@ -3217,7 +3217,7 @@ XMLHttpRequestMainThread::AsyncOnChannelRedirect(nsIChannel *aOldChannel, uint32_t aFlags, nsIAsyncVerifyRedirectCallback *callback) { - NS_PRECONDITION(aNewChannel, "Redirect without a channel?"); + MOZ_ASSERT(aNewChannel, "Redirect without a channel?"); // Prepare to receive callback mRedirectCallback = callback; diff --git a/dom/xml/ProcessingInstruction.cpp b/dom/xml/ProcessingInstruction.cpp index e351cca11a13..b0c40f4a46c9 100644 --- a/dom/xml/ProcessingInstruction.cpp +++ b/dom/xml/ProcessingInstruction.cpp @@ -20,7 +20,7 @@ NS_NewXMLProcessingInstruction(nsNodeInfoManager *aNodeInfoManager, using mozilla::dom::ProcessingInstruction; using mozilla::dom::XMLStylesheetProcessingInstruction; - NS_PRECONDITION(aNodeInfoManager, "Missing nodeinfo manager"); + MOZ_ASSERT(aNodeInfoManager, "Missing nodeinfo manager"); RefPtr target = NS_Atomize(aTarget); MOZ_ASSERT(target); diff --git a/dom/xml/nsXMLContentSink.cpp b/dom/xml/nsXMLContentSink.cpp index 85ef66fc3a79..94ef995a0e20 100644 --- a/dom/xml/nsXMLContentSink.cpp +++ b/dom/xml/nsXMLContentSink.cpp @@ -79,7 +79,7 @@ NS_NewXMLContentSink(nsIXMLContentSink** aResult, nsISupports* aContainer, nsIChannel* aChannel) { - NS_PRECONDITION(nullptr != aResult, "null ptr"); + MOZ_ASSERT(nullptr != aResult, "null ptr"); if (nullptr == aResult) { return NS_ERROR_NULL_POINTER; } @@ -456,7 +456,7 @@ nsXMLContentSink::WillResume(void) NS_IMETHODIMP nsXMLContentSink::SetParser(nsParserBase* aParser) { - NS_PRECONDITION(aParser, "Should have a parser here!"); + MOZ_ASSERT(aParser, "Should have a parser here!"); mParser = aParser; return NS_OK; } @@ -844,7 +844,7 @@ nsXMLContentSink::GetCurrentStackNode() nsresult nsXMLContentSink::PushContent(nsIContent *aContent) { - NS_PRECONDITION(aContent, "Null content being pushed!"); + MOZ_ASSERT(aContent, "Null content being pushed!"); StackNode *sn = mContentStack.AppendElement(); NS_ENSURE_TRUE(sn, NS_ERROR_OUT_OF_MEMORY); @@ -973,7 +973,7 @@ nsXMLContentSink::HandleStartElement(const char16_t *aName, uint32_t aLineNumber, bool aInterruptable) { - NS_PRECONDITION(aAttsCount % 2 == 0, "incorrect aAttsCount"); + MOZ_ASSERT(aAttsCount % 2 == 0, "incorrect aAttsCount"); // Adjust aAttsCount so it's the actual number of attributes aAttsCount /= 2; @@ -1358,7 +1358,7 @@ nsXMLContentSink::ReportError(const char16_t* aErrorText, nsIScriptError *aError, bool *_retval) { - NS_PRECONDITION(aError && aSourceText && aErrorText, "Check arguments!!!"); + MOZ_ASSERT(aError && aSourceText && aErrorText, "Check arguments!!!"); nsresult rv = NS_OK; // The expat driver should report the error. We're just cleaning up the mess. diff --git a/dom/xml/nsXMLFragmentContentSink.cpp b/dom/xml/nsXMLFragmentContentSink.cpp index 1296e2fbc8aa..b3222be49869 100644 --- a/dom/xml/nsXMLFragmentContentSink.cpp +++ b/dom/xml/nsXMLFragmentContentSink.cpp @@ -296,7 +296,7 @@ nsXMLFragmentContentSink::ReportError(const char16_t* aErrorText, nsIScriptError *aError, bool *_retval) { - NS_PRECONDITION(aError && aSourceText && aErrorText, "Check arguments!!!"); + MOZ_ASSERT(aError && aSourceText && aErrorText, "Check arguments!!!"); // The expat driver should report the error. *_retval = true; diff --git a/dom/xslt/xpath/txXPathTreeWalker.h b/dom/xslt/xpath/txXPathTreeWalker.h index 5196a6df821a..8644c2f435a8 100644 --- a/dom/xslt/xpath/txXPathTreeWalker.h +++ b/dom/xslt/xpath/txXPathTreeWalker.h @@ -177,8 +177,7 @@ txXPathTreeWalker::isOnNode(const txXPathNode& aNode) const inline int32_t txXPathNodeUtils::getUniqueIdentifier(const txXPathNode& aNode) { - NS_PRECONDITION(!aNode.isAttribute(), - "Not implemented for attributes."); + MOZ_ASSERT(!aNode.isAttribute(), "Not implemented for attributes."); return NS_PTR_TO_INT32(aNode.mNode); } diff --git a/dom/xslt/xslt/txExecutionState.cpp b/dom/xslt/xslt/txExecutionState.cpp index 208494b6b52b..de06fe5fee58 100644 --- a/dom/xslt/xslt/txExecutionState.cpp +++ b/dom/xslt/xslt/txExecutionState.cpp @@ -395,7 +395,7 @@ txExecutionState::pushTemplateRule(txStylesheet::ImportFrame* aFrame, void txExecutionState::popTemplateRule() { - NS_PRECONDITION(!mTemplateRules.IsEmpty(), "No rules to pop"); + MOZ_ASSERT(!mTemplateRules.IsEmpty(), "No rules to pop"); mTemplateRules.RemoveLastElement(); } @@ -457,7 +457,7 @@ txExecutionState::getKeyNodes(const txExpandedName& aKeyName, txExecutionState::TemplateRule* txExecutionState::getCurrentTemplateRule() { - NS_PRECONDITION(!mTemplateRules.IsEmpty(), "No current rule!"); + MOZ_ASSERT(!mTemplateRules.IsEmpty(), "No current rule!"); return &mTemplateRules[mTemplateRules.Length() - 1]; } diff --git a/dom/xslt/xslt/txMozillaStylesheetCompiler.cpp b/dom/xslt/xslt/txMozillaStylesheetCompiler.cpp index 37c3703b399c..4a4095454ba3 100644 --- a/dom/xslt/xslt/txMozillaStylesheetCompiler.cpp +++ b/dom/xslt/xslt/txMozillaStylesheetCompiler.cpp @@ -125,7 +125,7 @@ txStylesheetSink::HandleStartElement(const char16_t *aName, uint32_t aAttsCount, uint32_t aLineNumber) { - NS_PRECONDITION(aAttsCount % 2 == 0, "incorrect aAttsCount"); + MOZ_ASSERT(aAttsCount % 2 == 0, "incorrect aAttsCount"); nsresult rv = mCompiler->startElement(aName, aAtts, aAttsCount / 2); @@ -208,7 +208,7 @@ txStylesheetSink::ReportError(const char16_t *aErrorText, nsIScriptError *aError, bool *_retval) { - NS_PRECONDITION(aError && aSourceText && aErrorText, "Check arguments!!!"); + MOZ_ASSERT(aError && aSourceText && aErrorText, "Check arguments!!!"); // The expat driver should report the error. *_retval = true; diff --git a/dom/xslt/xslt/txMozillaXMLOutput.cpp b/dom/xslt/xslt/txMozillaXMLOutput.cpp index 2dd66aa27c6c..d5e3fae811d6 100644 --- a/dom/xslt/xslt/txMozillaXMLOutput.cpp +++ b/dom/xslt/xslt/txMozillaXMLOutput.cpp @@ -432,8 +432,8 @@ txMozillaXMLOutput::startElement(nsAtom* aPrefix, nsAtom* aLocalName, nsAtom* aLowercaseLocalName, const int32_t aNsID) { - NS_PRECONDITION(aNsID != kNameSpaceID_None || !aPrefix, - "Can't have prefix without namespace"); + MOZ_ASSERT(aNsID != kNameSpaceID_None || !aPrefix, + "Can't have prefix without namespace"); if (mOutputFormat.mMethod == eHTMLOutput && aNsID == kNameSpaceID_None) { RefPtr owner; diff --git a/dom/xslt/xslt/txStylesheetCompiler.cpp b/dom/xslt/xslt/txStylesheetCompiler.cpp index 23ab8d32e78a..478ce60064ef 100644 --- a/dom/xslt/xslt/txStylesheetCompiler.cpp +++ b/dom/xslt/xslt/txStylesheetCompiler.cpp @@ -703,7 +703,7 @@ txStylesheetCompilerState::addToplevelItem(txToplevelItem* aItem) nsresult txStylesheetCompilerState::openInstructionContainer(txInstructionContainer* aContainer) { - NS_PRECONDITION(!mNextInstrPtr, "can't nest instruction-containers"); + MOZ_ASSERT(!mNextInstrPtr, "can't nest instruction-containers"); mNextInstrPtr = aContainer->mFirstInstruction.StartAssignment(); return NS_OK; @@ -720,7 +720,7 @@ txStylesheetCompilerState::closeInstructionContainer() nsresult txStylesheetCompilerState::addInstruction(nsAutoPtr&& aInstruction) { - NS_PRECONDITION(mNextInstrPtr, "adding instruction outside container"); + MOZ_ASSERT(mNextInstrPtr, "adding instruction outside container"); txInstruction* newInstr = aInstruction; diff --git a/dom/xul/XULDocument.cpp b/dom/xul/XULDocument.cpp index 874ef9baeb13..aa8cc175e4f6 100644 --- a/dom/xul/XULDocument.cpp +++ b/dom/xul/XULDocument.cpp @@ -219,7 +219,7 @@ XULDocument::~XULDocument() nsresult NS_NewXULDocument(nsIDocument** result) { - NS_PRECONDITION(result != nullptr, "null ptr"); + MOZ_ASSERT(result != nullptr, "null ptr"); if (! result) return NS_ERROR_NULL_POINTER; @@ -1622,7 +1622,7 @@ XULDocument::MatchAttribute(Element* aElement, nsAtom* aAttrName, void* aData) { - NS_PRECONDITION(aElement, "Must have content node to work with!"); + MOZ_ASSERT(aElement, "Must have content node to work with!"); nsString* attrValue = static_cast(aData); if (aNamespaceID != kNameSpaceID_Unknown && aNamespaceID != kNameSpaceID_Wildcard) { @@ -2048,8 +2048,8 @@ nsresult XULDocument::CreateAndInsertPI(const nsXULPrototypePI* aProtoPI, nsINode* aParent, nsINode* aBeforeThis) { - NS_PRECONDITION(aProtoPI, "null ptr"); - NS_PRECONDITION(aParent, "null ptr"); + MOZ_ASSERT(aProtoPI, "null ptr"); + MOZ_ASSERT(aParent, "null ptr"); RefPtr node = NS_NewXMLProcessingInstruction(mNodeInfoManager, aProtoPI->mTarget, @@ -2739,8 +2739,8 @@ XULDocument::GetXULWindowIfToplevelChrome() const nsresult XULDocument::DoneWalking() { - NS_PRECONDITION(mPendingSheets == 0, "there are sheets to be loaded"); - NS_PRECONDITION(!mStillWalking, "walk not done"); + MOZ_ASSERT(mPendingSheets == 0, "there are sheets to be loaded"); + MOZ_ASSERT(!mStillWalking, "walk not done"); // XXXldb This is where we should really be setting the chromehidden // attribute. @@ -2959,7 +2959,7 @@ XULDocument::EndUpdate(nsUpdateType aUpdateType) void XULDocument::ReportMissingOverlay(nsIURI* aURI) { - NS_PRECONDITION(aURI, "Must have a URI"); + MOZ_ASSERT(aURI, "Must have a URI"); NS_ConvertUTF8toUTF16 utfSpec(aURI->GetSpecOrDefault()); const char16_t* params[] = { utfSpec.get() }; @@ -3265,7 +3265,7 @@ XULDocument::OnScriptCompileComplete(JSScript* aScript, nsresult aStatus) nsresult XULDocument::ExecuteScript(nsXULPrototypeScript *aScript) { - NS_PRECONDITION(aScript != nullptr, "null ptr"); + MOZ_ASSERT(aScript != nullptr, "null ptr"); NS_ENSURE_TRUE(aScript, NS_ERROR_NULL_POINTER); NS_ENSURE_TRUE(mScriptGlobalObject, NS_ERROR_NOT_INITIALIZED); @@ -3306,7 +3306,7 @@ XULDocument::CreateElementFromPrototype(nsXULPrototypeElement* aPrototype, bool aIsRoot) { // Create a content model element from a prototype element. - NS_PRECONDITION(aPrototype != nullptr, "null ptr"); + MOZ_ASSERT(aPrototype != nullptr, "null ptr"); if (! aPrototype) return NS_ERROR_NULL_POINTER; diff --git a/dom/xul/nsXULCommandDispatcher.cpp b/dom/xul/nsXULCommandDispatcher.cpp index f2ae9a9a4fe0..ccdf818c1ce1 100644 --- a/dom/xul/nsXULCommandDispatcher.cpp +++ b/dom/xul/nsXULCommandDispatcher.cpp @@ -242,7 +242,7 @@ nsXULCommandDispatcher::AddCommandUpdater(Element* aElement, const nsAString& aEvents, const nsAString& aTargets) { - NS_PRECONDITION(aElement != nullptr, "null ptr"); + MOZ_ASSERT(aElement != nullptr, "null ptr"); if (! aElement) return NS_ERROR_NULL_POINTER; @@ -310,7 +310,7 @@ nsXULCommandDispatcher::AddCommandUpdater(Element* aElement, NS_IMETHODIMP nsXULCommandDispatcher::RemoveCommandUpdater(Element* aElement) { - NS_PRECONDITION(aElement != nullptr, "null ptr"); + MOZ_ASSERT(aElement != nullptr, "null ptr"); if (! aElement) return NS_ERROR_NULL_POINTER; diff --git a/dom/xul/nsXULContentSink.cpp b/dom/xul/nsXULContentSink.cpp index d4354fd44fe2..155cc3c48a90 100644 --- a/dom/xul/nsXULContentSink.cpp +++ b/dom/xul/nsXULContentSink.cpp @@ -274,7 +274,7 @@ nsresult XULContentSinkImpl::Init(nsIDocument* aDocument, nsXULPrototypeDocument* aPrototype) { - NS_PRECONDITION(aDocument != nullptr, "null ptr"); + MOZ_ASSERT(aDocument != nullptr, "null ptr"); if (! aDocument) return NS_ERROR_NULL_POINTER; @@ -406,7 +406,6 @@ XULContentSinkImpl::CreateElement(mozilla::dom::NodeInfo *aNodeInfo, /**** BEGIN NEW APIs ****/ - NS_IMETHODIMP XULContentSinkImpl::HandleStartElement(const char16_t *aName, const char16_t **aAtts, @@ -415,8 +414,9 @@ XULContentSinkImpl::HandleStartElement(const char16_t *aName, { // XXX Hopefully the parser will flag this before we get here. If // we're in the epilog, there should be no new elements - NS_PRECONDITION(mState != eInEpilog, "tag in XUL doc epilog"); - NS_PRECONDITION(aAttsCount % 2 == 0, "incorrect aAttsCount"); + MOZ_ASSERT(mState != eInEpilog, "tag in XUL doc epilog"); + MOZ_ASSERT(aAttsCount % 2 == 0, "incorrect aAttsCount"); + // Adjust aAttsCount so it's the actual number of attributes aAttsCount /= 2; @@ -629,7 +629,7 @@ XULContentSinkImpl::ReportError(const char16_t* aErrorText, nsIScriptError *aError, bool *_retval) { - NS_PRECONDITION(aError && aSourceText && aErrorText, "Check arguments!!!"); + MOZ_ASSERT(aError && aSourceText && aErrorText, "Check arguments!!!"); // The expat driver should report the error. *_retval = true; diff --git a/dom/xul/nsXULContentUtils.cpp b/dom/xul/nsXULContentUtils.cpp index 3f18d500c9f4..bb97f37cca7e 100644 --- a/dom/xul/nsXULContentUtils.cpp +++ b/dom/xul/nsXULContentUtils.cpp @@ -93,11 +93,11 @@ nsXULContentUtils::SetCommandUpdater(nsIDocument* aDocument, Element* aElement) // Deal with setting up a 'commandupdater'. Pulls the 'events' and // 'targets' attributes off of aElement, and adds it to the // document's command dispatcher. - NS_PRECONDITION(aDocument != nullptr, "null ptr"); + MOZ_ASSERT(aDocument != nullptr, "null ptr"); if (! aDocument) return NS_ERROR_NULL_POINTER; - NS_PRECONDITION(aElement != nullptr, "null ptr"); + MOZ_ASSERT(aElement != nullptr, "null ptr"); if (! aElement) return NS_ERROR_NULL_POINTER; diff --git a/dom/xul/nsXULControllers.cpp b/dom/xul/nsXULControllers.cpp index 9f4547572148..1880075c6587 100644 --- a/dom/xul/nsXULControllers.cpp +++ b/dom/xul/nsXULControllers.cpp @@ -45,7 +45,7 @@ nsXULControllers::DeleteControllers() nsresult NS_NewXULControllers(nsISupports* aOuter, REFNSIID aIID, void** aResult) { - NS_PRECONDITION(aOuter == nullptr, "no aggregation"); + MOZ_ASSERT(aOuter == nullptr, "no aggregation"); if (aOuter) return NS_ERROR_NO_AGGREGATION; diff --git a/dom/xul/nsXULElement.cpp b/dom/xul/nsXULElement.cpp index 57cfbc6ae47d..54359958d720 100644 --- a/dom/xul/nsXULElement.cpp +++ b/dom/xul/nsXULElement.cpp @@ -239,11 +239,11 @@ nsXULElement::CreateFromPrototype(nsXULPrototypeElement* aPrototype, Element** aResult) { // Create an nsXULElement from a prototype - NS_PRECONDITION(aPrototype != nullptr, "null ptr"); + MOZ_ASSERT(aPrototype != nullptr, "null ptr"); if (! aPrototype) return NS_ERROR_NULL_POINTER; - NS_PRECONDITION(aResult != nullptr, "null ptr"); + MOZ_ASSERT(aResult != nullptr, "null ptr"); if (! aResult) return NS_ERROR_NULL_POINTER; @@ -270,7 +270,7 @@ NS_NewXULElement(Element** aResult, already_AddRefed&& a { RefPtr nodeInfo = aNodeInfo; - NS_PRECONDITION(nodeInfo, "need nodeinfo for non-proto Create"); + MOZ_ASSERT(nodeInfo, "need nodeinfo for non-proto Create"); NS_ASSERTION(nodeInfo->NamespaceEquals(kNameSpaceID_XUL), "Trying to create XUL elements that don't have the XUL namespace"); @@ -288,7 +288,7 @@ NS_TrustedNewXULElement(Element** aResult, already_AddRefed&& aNodeInfo) { RefPtr ni = aNodeInfo; - NS_PRECONDITION(ni, "need nodeinfo for non-proto Create"); + MOZ_ASSERT(ni, "need nodeinfo for non-proto Create"); // Create an nsXULElement with the specified namespace and tag. NS_ADDREF(*aResult = nsXULElement::Construct(ni.forget())); @@ -2145,7 +2145,7 @@ nsXULPrototypeElement::Deserialize(nsIObjectInputStream* aStream, nsIURI* aDocumentURI, const nsTArray> *aNodeInfos) { - NS_PRECONDITION(aNodeInfos, "missing nodeinfo array"); + MOZ_ASSERT(aNodeInfos, "missing nodeinfo array"); // Read Node Info uint32_t number = 0; @@ -2272,7 +2272,7 @@ nsresult nsXULPrototypeElement::SetAttrAt(uint32_t aPos, const nsAString& aValue, nsIURI* aDocumentURI) { - NS_PRECONDITION(aPos < mNumAttributes, "out-of-bounds"); + MOZ_ASSERT(aPos < mNumAttributes, "out-of-bounds"); // WARNING!! // This code is largely duplicated in nsXULElement::SetAttr. diff --git a/dom/xul/nsXULPrototypeDocument.cpp b/dom/xul/nsXULPrototypeDocument.cpp index 345e2a0aede7..1a7e26ef1340 100644 --- a/dom/xul/nsXULPrototypeDocument.cpp +++ b/dom/xul/nsXULPrototypeDocument.cpp @@ -409,7 +409,7 @@ nsXULPrototypeDocument::SetRootElement(nsXULPrototypeElement* aElement) nsresult nsXULPrototypeDocument::AddProcessingInstruction(nsXULPrototypePI* aPI) { - NS_PRECONDITION(aPI, "null ptr"); + MOZ_ASSERT(aPI, "null ptr"); if (!mProcessingInstructions.AppendElement(aPI)) { return NS_ERROR_OUT_OF_MEMORY; } @@ -425,7 +425,7 @@ nsXULPrototypeDocument::GetProcessingInstructions() const void nsXULPrototypeDocument::AddStyleSheetReference(nsIURI* aURI) { - NS_PRECONDITION(aURI, "null ptr"); + MOZ_ASSERT(aURI, "null ptr"); if (!mStyleSheetReferences.AppendObject(aURI)) { NS_WARNING("mStyleSheetReferences->AppendElement() failed." "Stylesheet overlay dropped."); @@ -441,7 +441,7 @@ nsXULPrototypeDocument::GetStyleSheetReferences() const nsIPrincipal* nsXULPrototypeDocument::DocumentPrincipal() { - NS_PRECONDITION(mNodeInfoManager, "missing nodeInfoManager"); + MOZ_ASSERT(mNodeInfoManager, "missing nodeInfoManager"); return mNodeInfoManager->DocumentPrincipal(); } diff --git a/editor/libeditor/EditorBase.cpp b/editor/libeditor/EditorBase.cpp index 17e7f24cf9d0..290461309988 100644 --- a/editor/libeditor/EditorBase.cpp +++ b/editor/libeditor/EditorBase.cpp @@ -3549,9 +3549,9 @@ EditorBase::FindNextLeafNode(nsINode* aCurrentNode, bool bNoBlockCrossing) { // called only by GetPriorNode so we don't need to check params. - NS_PRECONDITION(IsDescendantOfEditorRoot(aCurrentNode) && - !IsEditorRoot(aCurrentNode), - "Bogus arguments"); + MOZ_ASSERT(IsDescendantOfEditorRoot(aCurrentNode) && + !IsEditorRoot(aCurrentNode), + "Bogus arguments"); nsINode* cur = aCurrentNode; for (;;) { @@ -4146,7 +4146,7 @@ EditorBase::JoinNodesDeepWithTransaction(nsIContent& aLeftNode, void EditorBase::BeginUpdateViewBatch() { - NS_PRECONDITION(mUpdateCount >= 0, "bad state"); + MOZ_ASSERT(mUpdateCount >= 0, "bad state"); if (!mUpdateCount) { // Turn off selection updates and notifications. @@ -4162,7 +4162,7 @@ EditorBase::BeginUpdateViewBatch() nsresult EditorBase::EndUpdateViewBatch() { - NS_PRECONDITION(mUpdateCount > 0, "bad state"); + MOZ_ASSERT(mUpdateCount > 0, "bad state"); if (mUpdateCount <= 0) { mUpdateCount = 0; diff --git a/editor/libeditor/EditorEventListener.cpp b/editor/libeditor/EditorEventListener.cpp index 1295fa4c0953..c5cdf0894c46 100644 --- a/editor/libeditor/EditorEventListener.cpp +++ b/editor/libeditor/EditorEventListener.cpp @@ -138,7 +138,7 @@ EditorEventListener::Connect(EditorBase* aEditorBase) nsresult EditorEventListener::InstallToEditor() { - NS_PRECONDITION(mEditorBase, "The caller must set mEditorBase"); + MOZ_ASSERT(mEditorBase, "The caller must set mEditorBase"); EventTarget* piTarget = mEditorBase->GetDOMEventTarget(); NS_ENSURE_TRUE(piTarget, NS_ERROR_FAILURE); diff --git a/editor/libeditor/HTMLEditor.cpp b/editor/libeditor/HTMLEditor.cpp index 7e56588d850d..70a9c23c7af2 100644 --- a/editor/libeditor/HTMLEditor.cpp +++ b/editor/libeditor/HTMLEditor.cpp @@ -391,8 +391,8 @@ HTMLEditor::FindSelectionRoot(nsINode* aNode) return nullptr; } - NS_PRECONDITION(aNode->IsDocument() || aNode->IsContent(), - "aNode must be content or document node"); + MOZ_ASSERT(aNode->IsDocument() || aNode->IsContent(), + "aNode must be content or document node"); nsCOMPtr doc = aNode->GetComposedDoc(); if (!doc) { @@ -3649,7 +3649,7 @@ HTMLEditor::GetEnclosingTable(nsINode* aNode) nsIDOMNode* HTMLEditor::GetEnclosingTable(nsIDOMNode* aNode) { - NS_PRECONDITION(aNode, "null node passed to HTMLEditor::GetEnclosingTable"); + MOZ_ASSERT(aNode, "null node passed to HTMLEditor::GetEnclosingTable"); nsCOMPtr node = do_QueryInterface(aNode); NS_ENSURE_TRUE(node, nullptr); nsCOMPtr table = GetEnclosingTable(node); diff --git a/editor/libeditor/TextEditRules.cpp b/editor/libeditor/TextEditRules.cpp index 288359208459..e1f2cdcd5f3b 100644 --- a/editor/libeditor/TextEditRules.cpp +++ b/editor/libeditor/TextEditRules.cpp @@ -230,7 +230,7 @@ TextEditRules::AfterEdit(EditAction aAction, AutoLockRulesSniffing lockIt(this); - NS_PRECONDITION(mActionNesting>0, "bad action nesting!"); + MOZ_ASSERT(mActionNesting>0, "bad action nesting!"); if (!--mActionNesting) { NS_ENSURE_STATE(mTextEditor); RefPtr selection = mTextEditor->GetSelection(); diff --git a/editor/libeditor/TextEditor.cpp b/editor/libeditor/TextEditor.cpp index eef5ceba236e..94e2119dd725 100644 --- a/editor/libeditor/TextEditor.cpp +++ b/editor/libeditor/TextEditor.cpp @@ -207,7 +207,7 @@ TextEditor::BeginEditorInit() nsresult TextEditor::EndEditorInit() { - NS_PRECONDITION(mInitTriggerCounter > 0, "ended editor init before we began?"); + MOZ_ASSERT(mInitTriggerCounter > 0, "ended editor init before we began?"); mInitTriggerCounter--; if (mInitTriggerCounter) { return NS_OK; diff --git a/extensions/spellcheck/src/mozInlineSpellChecker.cpp b/extensions/spellcheck/src/mozInlineSpellChecker.cpp index 69ad3ed99837..dc052c528ad8 100644 --- a/extensions/spellcheck/src/mozInlineSpellChecker.cpp +++ b/extensions/spellcheck/src/mozInlineSpellChecker.cpp @@ -1758,8 +1758,8 @@ bool // static ContentIsDescendantOf(nsINode* aPossibleDescendant, nsINode* aPossibleAncestor) { - NS_PRECONDITION(aPossibleDescendant, "The possible descendant is null!"); - NS_PRECONDITION(aPossibleAncestor, "The possible ancestor is null!"); + MOZ_ASSERT(aPossibleDescendant, "The possible descendant is null!"); + MOZ_ASSERT(aPossibleAncestor, "The possible ancestor is null!"); do { if (aPossibleDescendant == aPossibleAncestor) diff --git a/extensions/spellcheck/src/mozInlineSpellWordUtil.cpp b/extensions/spellcheck/src/mozInlineSpellWordUtil.cpp index bac63bb493d5..a6f7f2f12536 100644 --- a/extensions/spellcheck/src/mozInlineSpellWordUtil.cpp +++ b/extensions/spellcheck/src/mozInlineSpellWordUtil.cpp @@ -87,7 +87,7 @@ static nsINode* FindNextNode(nsINode* aNode, nsINode* aRoot, OnLeaveNodeFunPtr aOnLeaveNode, void* aClosure) { - NS_PRECONDITION(aNode, "Null starting node?"); + MOZ_ASSERT(aNode, "Null starting node?"); nsINode* next = aNode->GetFirstChild(); if (next) @@ -123,7 +123,7 @@ FindNextNode(nsINode* aNode, nsINode* aRoot, static nsINode* FindNextTextNode(nsINode* aNode, int32_t aOffset, nsINode* aRoot) { - NS_PRECONDITION(aNode, "Null starting node?"); + MOZ_ASSERT(aNode, "Null starting node?"); NS_ASSERTION(!IsSpellCheckingTextNode(aNode), "FindNextTextNode should start with a non-text node"); nsINode* checkNode; @@ -165,7 +165,7 @@ FindNextTextNode(nsINode* aNode, int32_t aOffset, nsINode* aRoot) nsresult mozInlineSpellWordUtil::SetEnd(nsINode* aEndNode, int32_t aEndOffset) { - NS_PRECONDITION(aEndNode, "Null end node?"); + MOZ_ASSERT(aEndNode, "Null end node?"); NS_ASSERTION(mRootNode, "Not initialized"); diff --git a/gfx/thebes/gfxDWriteCommon.cpp b/gfx/thebes/gfxDWriteCommon.cpp index d5fd4157060f..ef047e2e6be1 100644 --- a/gfx/thebes/gfxDWriteCommon.cpp +++ b/gfx/thebes/gfxDWriteCommon.cpp @@ -51,14 +51,14 @@ public: IFACEMETHOD_(ULONG, AddRef)() { - NS_PRECONDITION(int32_t(mRefCnt) >= 0, "illegal refcnt"); + MOZ_ASSERT(int32_t(mRefCnt) >= 0, "illegal refcnt"); ++mRefCnt; return mRefCnt; } IFACEMETHOD_(ULONG, Release)() { - NS_PRECONDITION(0 != mRefCnt, "dup release"); + MOZ_ASSERT(0 != mRefCnt, "dup release"); --mRefCnt; if (mRefCnt == 0) { delete this; diff --git a/gfx/thebes/gfxFT2FontBase.cpp b/gfx/thebes/gfxFT2FontBase.cpp index f3d61412d4bd..ffbc24dd20ed 100644 --- a/gfx/thebes/gfxFT2FontBase.cpp +++ b/gfx/thebes/gfxFT2FontBase.cpp @@ -107,7 +107,7 @@ gfxFT2FontBase::GetGlyph(uint32_t aCharCode) void gfxFT2FontBase::GetGlyphExtents(uint32_t aGlyph, cairo_text_extents_t* aExtents) { - NS_PRECONDITION(aExtents != nullptr, "aExtents must not be NULL"); + MOZ_ASSERT(aExtents != nullptr, "aExtents must not be NULL"); cairo_glyph_t glyphs[1]; glyphs[0].index = aGlyph; diff --git a/gfx/thebes/gfxFT2Utils.cpp b/gfx/thebes/gfxFT2Utils.cpp index 85f6a26c3490..cfc4b1723bc0 100644 --- a/gfx/thebes/gfxFT2Utils.cpp +++ b/gfx/thebes/gfxFT2Utils.cpp @@ -47,7 +47,7 @@ typedef FT_UInt (*GetCharVariantFunction)(FT_Face face, uint32_t gfxFT2LockedFace::GetUVSGlyph(uint32_t aCharCode, uint32_t aVariantSelector) { - NS_PRECONDITION(aVariantSelector, "aVariantSelector should not be NULL"); + MOZ_ASSERT(aVariantSelector, "aVariantSelector should not be NULL"); if (MOZ_UNLIKELY(!mFace)) return 0; diff --git a/gfx/thebes/gfxFont.cpp b/gfx/thebes/gfxFont.cpp index e16dacb453b4..8540c0295bf8 100644 --- a/gfx/thebes/gfxFont.cpp +++ b/gfx/thebes/gfxFont.cpp @@ -4191,9 +4191,9 @@ gfxFontStyle::Hash() const void gfxFontStyle::AdjustForSubSuperscript(int32_t aAppUnitsPerDevPixel) { - NS_PRECONDITION(variantSubSuper != NS_FONT_VARIANT_POSITION_NORMAL && - baselineOffset == 0, - "can't adjust this style for sub/superscript"); + MOZ_ASSERT(variantSubSuper != NS_FONT_VARIANT_POSITION_NORMAL && + baselineOffset == 0, + "can't adjust this style for sub/superscript"); // calculate the baseline offset (before changing the size) if (variantSubSuper == NS_FONT_VARIANT_POSITION_SUPER) { diff --git a/gfx/thebes/gfxFont.h b/gfx/thebes/gfxFont.h index cec23e25c9fe..cc40cc23ff1a 100644 --- a/gfx/thebes/gfxFont.h +++ b/gfx/thebes/gfxFont.h @@ -1465,7 +1465,7 @@ public: typedef mozilla::FontSlantStyle FontSlantStyle; nsrefcnt AddRef(void) { - NS_PRECONDITION(int32_t(mRefCnt) >= 0, "illegal refcnt"); + MOZ_ASSERT(int32_t(mRefCnt) >= 0, "illegal refcnt"); if (mExpirationState.IsTracked()) { gfxFontCache::GetCache()->RemoveObject(this); } @@ -1474,7 +1474,7 @@ public: return mRefCnt; } nsrefcnt Release(void) { - NS_PRECONDITION(0 != mRefCnt, "dup release"); + MOZ_ASSERT(0 != mRefCnt, "dup release"); --mRefCnt; NS_LOG_RELEASE(this, mRefCnt, "gfxFont"); if (mRefCnt == 0) { diff --git a/gfx/thebes/gfxFontEntry.h b/gfx/thebes/gfxFontEntry.h index 9fb21da1c90d..9c930c59d31c 100644 --- a/gfx/thebes/gfxFontEntry.h +++ b/gfx/thebes/gfxFontEntry.h @@ -50,14 +50,14 @@ class SVGContextPaint; class gfxCharacterMap : public gfxSparseBitSet { public: nsrefcnt AddRef() { - NS_PRECONDITION(int32_t(mRefCnt) >= 0, "illegal refcnt"); + MOZ_ASSERT(int32_t(mRefCnt) >= 0, "illegal refcnt"); ++mRefCnt; NS_LOG_ADDREF(this, mRefCnt, "gfxCharacterMap", sizeof(*this)); return mRefCnt; } nsrefcnt Release() { - NS_PRECONDITION(0 != mRefCnt, "dup release"); + MOZ_ASSERT(0 != mRefCnt, "dup release"); --mRefCnt; NS_LOG_RELEASE(this, mRefCnt, "gfxCharacterMap"); if (mRefCnt == 0) { diff --git a/gfx/thebes/gfxTextRun.cpp b/gfx/thebes/gfxTextRun.cpp index 4d373e7363a0..91a362f1617a 100644 --- a/gfx/thebes/gfxTextRun.cpp +++ b/gfx/thebes/gfxTextRun.cpp @@ -853,8 +853,8 @@ gfxTextRun::ClassifyAutoHyphenations(uint32_t aStart, Range aRange, nsTArray& aHyphenBuffer, HyphenationState* aWordState) { - NS_PRECONDITION(aRange.end - aStart <= aHyphenBuffer.Length() && - aRange.start >= aStart, "Range out of bounds"); + MOZ_ASSERT(aRange.end - aStart <= aHyphenBuffer.Length() && + aRange.start >= aStart, "Range out of bounds"); MOZ_ASSERT(aWordState->mostRecentBoundary >= aStart, "Unexpected aMostRecentWordBoundary!!"); diff --git a/gfx/thebes/gfxXlibSurface.cpp b/gfx/thebes/gfxXlibSurface.cpp index bf330d7cd81c..cefcedc76b90 100644 --- a/gfx/thebes/gfxXlibSurface.cpp +++ b/gfx/thebes/gfxXlibSurface.cpp @@ -71,8 +71,8 @@ gfxXlibSurface::gfxXlibSurface(cairo_surface_t *csurf) , mGLXPixmap(X11None) #endif { - NS_PRECONDITION(cairo_surface_status(csurf) == 0, - "Not expecting an error surface"); + MOZ_ASSERT(cairo_surface_status(csurf) == 0, + "Not expecting an error surface"); mDrawable = cairo_xlib_surface_get_drawable(csurf); mDisplay = cairo_xlib_surface_get_display(csurf); diff --git a/image/ImageURL.h b/image/ImageURL.h index 0beba6efa850..bced1fb00581 100644 --- a/image/ImageURL.h +++ b/image/ImageURL.h @@ -84,8 +84,8 @@ public: nsresult SchemeIs(const char* scheme, bool* result) { - NS_PRECONDITION(scheme, "scheme is null"); - NS_PRECONDITION(result, "result is null"); + MOZ_ASSERT(scheme, "scheme is null"); + MOZ_ASSERT(result, "result is null"); *result = mScheme.Equals(scheme); return NS_OK; diff --git a/image/decoders/icon/nsIconURI.cpp b/image/decoders/icon/nsIconURI.cpp index 83acfd3a34bf..3c9e07f67f09 100644 --- a/image/decoders/icon/nsIconURI.cpp +++ b/image/decoders/icon/nsIconURI.cpp @@ -471,7 +471,7 @@ nsMozIconURI::Equals(nsIURI* other, bool* result) { *result = false; NS_ENSURE_ARG_POINTER(other); - NS_PRECONDITION(result, "null pointer"); + MOZ_ASSERT(result, "null pointer"); nsAutoCString spec1; nsAutoCString spec2; diff --git a/image/imgLoader.h b/image/imgLoader.h index cce83d1dac92..ebd7f390638a 100644 --- a/image/imgLoader.h +++ b/image/imgLoader.h @@ -49,7 +49,7 @@ public: nsrefcnt AddRef() { - NS_PRECONDITION(int32_t(mRefCnt) >= 0, "illegal refcnt"); + MOZ_ASSERT(int32_t(mRefCnt) >= 0, "illegal refcnt"); NS_ASSERT_OWNINGTHREAD(imgCacheEntry); ++mRefCnt; NS_LOG_ADDREF(this, mRefCnt, "imgCacheEntry", sizeof(*this)); @@ -58,7 +58,7 @@ public: nsrefcnt Release() { - NS_PRECONDITION(0 != mRefCnt, "dup release"); + MOZ_ASSERT(0 != mRefCnt, "dup release"); NS_ASSERT_OWNINGTHREAD(imgCacheEntry); --mRefCnt; NS_LOG_RELEASE(this, mRefCnt, "imgCacheEntry"); diff --git a/image/imgRequest.cpp b/image/imgRequest.cpp index a915403b8539..a12e0c561078 100644 --- a/image/imgRequest.cpp +++ b/image/imgRequest.cpp @@ -214,7 +214,7 @@ imgRequest::ResetCacheEntry() void imgRequest::AddProxy(imgRequestProxy* proxy) { - NS_PRECONDITION(proxy, "null imgRequestProxy passed in"); + MOZ_ASSERT(proxy, "null imgRequestProxy passed in"); LOG_SCOPE_WITH_PARAM(gImgLog, "imgRequest::AddProxy", "proxy", proxy); if (!mFirstProxy) { diff --git a/image/imgRequestProxy.cpp b/image/imgRequestProxy.cpp index 12c7e1f69ea8..282ec11585d7 100644 --- a/image/imgRequestProxy.cpp +++ b/image/imgRequestProxy.cpp @@ -133,7 +133,7 @@ imgRequestProxy::imgRequestProxy() : imgRequestProxy::~imgRequestProxy() { /* destructor code */ - NS_PRECONDITION(!mListener, + MOZ_ASSERT(!mListener, "Someone forgot to properly cancel this request!"); // If we had a listener, that means we would have issued notifications. With @@ -184,8 +184,8 @@ imgRequestProxy::Init(imgRequest* aOwner, ImageURL* aURI, imgINotificationObserver* aObserver) { - NS_PRECONDITION(!GetOwner() && !mListener, - "imgRequestProxy is already initialized"); + MOZ_ASSERT(!GetOwner() && !mListener, + "imgRequestProxy is already initialized"); LOG_SCOPE_WITH_PARAM(gImgLog, "imgRequestProxy::Init", "request", aOwner); @@ -214,7 +214,7 @@ imgRequestProxy::Init(imgRequest* aOwner, nsresult imgRequestProxy::ChangeOwner(imgRequest* aNewOwner) { - NS_PRECONDITION(GetOwner(), + MOZ_ASSERT(GetOwner(), "Cannot ChangeOwner on a proxy without an owner!"); if (mCanceled) { @@ -863,7 +863,7 @@ imgRequestProxy::PerformClone(imgINotificationObserver* aObserver, bool aSyncNotify, imgRequestProxy** aClone) { - NS_PRECONDITION(aClone, "Null out param"); + MOZ_ASSERT(aClone, "Null out param"); LOG_SCOPE(gImgLog, "imgRequestProxy::Clone"); @@ -1137,7 +1137,7 @@ imgRequestProxy::OnLoadComplete(bool aLastPart) } if (mListenerIsStrongRef && aLastPart) { - NS_PRECONDITION(mListener, "How did that happen?"); + MOZ_ASSERT(mListener, "How did that happen?"); // Drop our strong ref to the listener now that we're done with // everything. Note that this can cancel us and other fun things // like that. Don't add anything in this method after this point. diff --git a/intl/lwbrk/WordBreaker.cpp b/intl/lwbrk/WordBreaker.cpp index 1704cfa68768..b22a341fa68a 100644 --- a/intl/lwbrk/WordBreaker.cpp +++ b/intl/lwbrk/WordBreaker.cpp @@ -17,13 +17,12 @@ WordBreaker::Create() return RefPtr(new WordBreaker()).forget(); } - bool WordBreaker::BreakInBetween( const char16_t* aText1 , uint32_t aTextLen1, const char16_t* aText2 , uint32_t aTextLen2) { - NS_PRECONDITION( nullptr != aText1, "null ptr"); - NS_PRECONDITION( nullptr != aText2, "null ptr"); + MOZ_ASSERT(nullptr != aText1, "null ptr"); + MOZ_ASSERT(nullptr != aText2, "null ptr"); if(!aText1 || !aText2 || (0 == aTextLen1) || (0 == aTextLen2)) return false; @@ -31,7 +30,6 @@ bool WordBreaker::BreakInBetween( return GetClass(aText1[aTextLen1-1]) != GetClass(aText2[0]); } - #define IS_ASCII(c) (0 == ( 0xFF80 & (c))) #define ASCII_IS_ALPHA(c) ((( 'a' <= (c)) && ((c) <= 'z')) || (( 'A' <= (c)) && ((c) <= 'Z'))) #define ASCII_IS_DIGIT(c) (( '0' <= (c)) && ((c) <= '9')) @@ -92,9 +90,9 @@ WordRange WordBreaker::FindWord( uint32_t aOffset) { WordRange range; - NS_PRECONDITION( nullptr != aText, "null ptr"); - NS_PRECONDITION( 0 != aTextLen, "len = 0"); - NS_PRECONDITION( aOffset <= aTextLen, "aOffset > aTextLen"); + MOZ_ASSERT(nullptr != aText, "null ptr"); + MOZ_ASSERT(0 != aTextLen, "len = 0"); + MOZ_ASSERT(aOffset <= aTextLen, "aOffset > aTextLen"); range.mBegin = aTextLen + 1; range.mEnd = aTextLen + 1; diff --git a/intl/uconv/nsConverterOutputStream.cpp b/intl/uconv/nsConverterOutputStream.cpp index 3fcd49837788..73d213715066 100644 --- a/intl/uconv/nsConverterOutputStream.cpp +++ b/intl/uconv/nsConverterOutputStream.cpp @@ -27,7 +27,7 @@ NS_IMETHODIMP nsConverterOutputStream::Init(nsIOutputStream* aOutStream, const char* aCharset) { - NS_PRECONDITION(aOutStream, "Null output stream!"); + MOZ_ASSERT(aOutStream, "Null output stream!"); const Encoding* encoding; if (!aCharset) { @@ -132,4 +132,3 @@ nsConverterOutputStream::Close() mConverter = nullptr; return NS_FAILED(rv1) ? rv1 : rv2; } - diff --git a/ipc/glue/MessageChannel.cpp b/ipc/glue/MessageChannel.cpp index 45e5aa172eb9..f10663baa176 100644 --- a/ipc/glue/MessageChannel.cpp +++ b/ipc/glue/MessageChannel.cpp @@ -776,7 +776,7 @@ MessageChannel::Clear() bool MessageChannel::Open(Transport* aTransport, MessageLoop* aIOLoop, Side aSide) { - NS_PRECONDITION(!mLink, "Open() called > once"); + MOZ_ASSERT(!mLink, "Open() called > once"); mMonitor = new RefCountedMonitor(); mWorkerLoop = MessageLoop::current(); @@ -808,8 +808,8 @@ MessageChannel::Open(MessageChannel *aTargetChan, nsIEventTarget *aEventTarget, // - meanwhile, on PB's worker loop, the work item is removed and: // - invokes PB->SlaveOpen(PA, ...): // - sets its state and that of PA to Connected - NS_PRECONDITION(aTargetChan, "Need a target channel"); - NS_PRECONDITION(ChannelClosed == mChannelState, "Not currently closed"); + MOZ_ASSERT(aTargetChan, "Need a target channel"); + MOZ_ASSERT(ChannelClosed == mChannelState, "Not currently closed"); CommonThreadOpenInit(aTargetChan, aSide); @@ -841,10 +841,9 @@ void MessageChannel::OnOpenAsSlave(MessageChannel *aTargetChan, Side aSide) { // Invoked when the other side has begun the open. - NS_PRECONDITION(ChannelClosed == mChannelState, - "Not currently closed"); - NS_PRECONDITION(ChannelOpening == aTargetChan->mChannelState, - "Target channel not in the process of opening"); + MOZ_ASSERT(ChannelClosed == mChannelState, "Not currently closed"); + MOZ_ASSERT(ChannelOpening == aTargetChan->mChannelState, + "Target channel not in the process of opening"); CommonThreadOpenInit(aTargetChan, aSide); mMonitor = aTargetChan->mMonitor; diff --git a/ipc/glue/MessageLink.cpp b/ipc/glue/MessageLink.cpp index b19673072a50..6aba7f06eafb 100644 --- a/ipc/glue/MessageLink.cpp +++ b/ipc/glue/MessageLink.cpp @@ -72,7 +72,7 @@ ProcessLink::Open(mozilla::ipc::Transport* aTransport, MessageLoop *aIOLoop, Sid { mChan->AssertWorkerThread(); - NS_PRECONDITION(aTransport, "need transport layer"); + MOZ_ASSERT(aTransport, "need transport layer"); // FIXME need to check for valid channel @@ -87,7 +87,7 @@ ProcessLink::Open(mozilla::ipc::Transport* aTransport, MessageLoop *aIOLoop, Sid needOpen = true; mChan->mSide = (aSide == UnknownSide) ? ChildSide : aSide; } else { - NS_PRECONDITION(aSide == UnknownSide, "expected default side arg"); + MOZ_ASSERT(aSide == UnknownSide, "expected default side arg"); // parent mChan->mSide = ParentSide; diff --git a/js/xpconnect/src/XPCConvert.cpp b/js/xpconnect/src/XPCConvert.cpp index fb5c43b359d3..0d1eae9e8b5a 100644 --- a/js/xpconnect/src/XPCConvert.cpp +++ b/js/xpconnect/src/XPCConvert.cpp @@ -101,7 +101,7 @@ bool XPCConvert::NativeData2JS(MutableHandleValue d, const void* s, const nsXPTType& type, const nsID* iid, nsresult* pErr) { - NS_PRECONDITION(s, "bad param"); + MOZ_ASSERT(s, "bad param"); AutoJSContext cx; if (pErr) @@ -404,7 +404,7 @@ XPCConvert::JSData2Native(void* d, HandleValue s, const nsID* iid, nsresult* pErr) { - NS_PRECONDITION(d, "bad param"); + MOZ_ASSERT(d, "bad param"); AutoJSContext cx; if (pErr) @@ -1242,7 +1242,7 @@ XPCConvert::NativeArray2JS(MutableHandleValue d, const void** s, const nsXPTType& type, const nsID* iid, uint32_t count, nsresult* pErr) { - NS_PRECONDITION(s, "bad param"); + MOZ_ASSERT(s, "bad param"); AutoJSContext cx; @@ -1639,7 +1639,7 @@ XPCConvert::NativeStringWithSize2JS(MutableHandleValue d, const void* s, uint32_t count, nsresult* pErr) { - NS_PRECONDITION(s, "bad param"); + MOZ_ASSERT(s, "bad param"); AutoJSContext cx; if (pErr) @@ -1681,8 +1681,8 @@ XPCConvert::JSStringWithSize2Native(void* d, HandleValue s, uint32_t count, const nsXPTType& type, nsresult* pErr) { - NS_PRECONDITION(!s.isNull(), "bad param"); - NS_PRECONDITION(d, "bad param"); + MOZ_ASSERT(!s.isNull(), "bad param"); + MOZ_ASSERT(d, "bad param"); AutoJSContext cx; uint32_t len; diff --git a/js/xpconnect/src/XPCMaps.h b/js/xpconnect/src/XPCMaps.h index 8919021ae4dd..4ec6290b7cb7 100644 --- a/js/xpconnect/src/XPCMaps.h +++ b/js/xpconnect/src/XPCMaps.h @@ -45,7 +45,7 @@ public: } inline nsXPCWrappedJS* Find(JSObject* Obj) { - NS_PRECONDITION(Obj,"bad param"); + MOZ_ASSERT(Obj,"bad param"); Map::Ptr p = mTable.lookup(Obj); return p ? p->value() : nullptr; } @@ -61,7 +61,7 @@ public: #endif inline nsXPCWrappedJS* Add(JSContext* cx, nsXPCWrappedJS* wrapper) { - NS_PRECONDITION(wrapper,"bad param"); + MOZ_ASSERT(wrapper,"bad param"); JSObject* obj = wrapper->GetJSObjectPreserveColor(); Map::AddPtr p = mTable.lookupForAdd(obj); if (p) @@ -72,7 +72,7 @@ public: } inline void Remove(nsXPCWrappedJS* wrapper) { - NS_PRECONDITION(wrapper,"bad param"); + MOZ_ASSERT(wrapper,"bad param"); mTable.remove(wrapper->GetJSObjectPreserveColor()); } @@ -114,14 +114,14 @@ public: inline XPCWrappedNative* Find(nsISupports* Obj) { - NS_PRECONDITION(Obj,"bad param"); + MOZ_ASSERT(Obj,"bad param"); auto entry = static_cast(mTable.Search(Obj)); return entry ? entry->value : nullptr; } inline XPCWrappedNative* Add(XPCWrappedNative* wrapper) { - NS_PRECONDITION(wrapper,"bad param"); + MOZ_ASSERT(wrapper,"bad param"); nsISupports* obj = wrapper->GetIdentityObject(); MOZ_ASSERT(!Find(obj), "wrapper already in new scope!"); auto entry = static_cast(mTable.Add(obj, mozilla::fallible)); @@ -136,7 +136,7 @@ public: inline void Remove(XPCWrappedNative* wrapper) { - NS_PRECONDITION(wrapper,"bad param"); + MOZ_ASSERT(wrapper,"bad param"); #ifdef DEBUG XPCWrappedNative* wrapperInMap = Find(wrapper->GetIdentityObject()); MOZ_ASSERT(!wrapperInMap || wrapperInMap == wrapper, @@ -186,7 +186,7 @@ public: inline nsXPCWrappedJSClass* Add(nsXPCWrappedJSClass* clazz) { - NS_PRECONDITION(clazz,"bad param"); + MOZ_ASSERT(clazz,"bad param"); const nsIID* iid = &clazz->GetIID(); auto entry = static_cast(mTable.Add(iid, mozilla::fallible)); if (!entry) @@ -200,7 +200,7 @@ public: inline void Remove(nsXPCWrappedJSClass* clazz) { - NS_PRECONDITION(clazz,"bad param"); + MOZ_ASSERT(clazz,"bad param"); mTable.Remove(&clazz->GetIID()); } @@ -240,7 +240,7 @@ public: inline XPCNativeInterface* Add(XPCNativeInterface* iface) { - NS_PRECONDITION(iface,"bad param"); + MOZ_ASSERT(iface,"bad param"); const nsIID* iid = iface->GetIID(); auto entry = static_cast(mTable.Add(iid, mozilla::fallible)); if (!entry) @@ -254,7 +254,7 @@ public: inline void Remove(XPCNativeInterface* iface) { - NS_PRECONDITION(iface,"bad param"); + MOZ_ASSERT(iface,"bad param"); mTable.Remove(iface->GetIID()); } @@ -298,7 +298,7 @@ public: inline XPCNativeSet* Add(nsIClassInfo* info, XPCNativeSet* set) { - NS_PRECONDITION(info,"bad param"); + MOZ_ASSERT(info,"bad param"); auto entry = static_cast(mTable.Add(info, mozilla::fallible)); if (!entry) return nullptr; @@ -311,7 +311,7 @@ public: inline void Remove(nsIClassInfo* info) { - NS_PRECONDITION(info,"bad param"); + MOZ_ASSERT(info,"bad param"); mTable.Remove(info); } @@ -351,7 +351,7 @@ public: inline XPCWrappedNativeProto* Add(nsIClassInfo* info, XPCWrappedNativeProto* proto) { - NS_PRECONDITION(info,"bad param"); + MOZ_ASSERT(info,"bad param"); auto entry = static_cast(mTable.Add(info, mozilla::fallible)); if (!entry) return nullptr; @@ -364,7 +364,7 @@ public: inline void Remove(nsIClassInfo* info) { - NS_PRECONDITION(info,"bad param"); + MOZ_ASSERT(info,"bad param"); mTable.Remove(info); } @@ -467,7 +467,7 @@ public: inline XPCWrappedNativeProto* Add(XPCWrappedNativeProto* proto) { - NS_PRECONDITION(proto,"bad param"); + MOZ_ASSERT(proto,"bad param"); auto entry = static_cast (mTable.Add(proto, mozilla::fallible)); if (!entry) @@ -480,7 +480,7 @@ public: inline void Remove(XPCWrappedNativeProto* proto) { - NS_PRECONDITION(proto,"bad param"); + MOZ_ASSERT(proto,"bad param"); mTable.Remove(proto); } @@ -517,7 +517,7 @@ public: } inline JSObject* Find(JSObject* key) { - NS_PRECONDITION(key, "bad param"); + MOZ_ASSERT(key, "bad param"); if (Map::Ptr p = mTable.lookup(key)) return p->value(); return nullptr; @@ -525,7 +525,7 @@ public: /* Note: If the entry already exists, return the old value. */ inline JSObject* Add(JSContext* cx, JSObject* key, JSObject* value) { - NS_PRECONDITION(key,"bad param"); + MOZ_ASSERT(key,"bad param"); Map::AddPtr p = mTable.lookupForAdd(key); if (p) return p->value(); @@ -536,7 +536,7 @@ public: } inline void Remove(JSObject* key) { - NS_PRECONDITION(key,"bad param"); + MOZ_ASSERT(key,"bad param"); mTable.remove(key); } diff --git a/js/xpconnect/src/XPCWrappedJS.cpp b/js/xpconnect/src/XPCWrappedJS.cpp index 70d3a79b194d..c4593eb7fd79 100644 --- a/js/xpconnect/src/XPCWrappedJS.cpp +++ b/js/xpconnect/src/XPCWrappedJS.cpp @@ -183,7 +183,7 @@ NS_IMETHODIMP nsXPCWrappedJS::QueryInterface(REFNSIID aIID, void** aInstancePtr) { if (nullptr == aInstancePtr) { - NS_PRECONDITION(false, "null pointer"); + MOZ_ASSERT(false, "null pointer"); return NS_ERROR_NULL_POINTER; } @@ -614,7 +614,7 @@ nsXPCWrappedJS::CallMethod(uint16_t methodIndex, NS_IMETHODIMP nsXPCWrappedJS::GetInterfaceIID(nsIID** iid) { - NS_PRECONDITION(iid, "bad param"); + MOZ_ASSERT(iid, "bad param"); *iid = GetIID().Clone(); return NS_OK; diff --git a/js/xpconnect/src/XPCWrappedJSClass.cpp b/js/xpconnect/src/XPCWrappedJSClass.cpp index 90a0ba878e33..b0eca70366f6 100644 --- a/js/xpconnect/src/XPCWrappedJSClass.cpp +++ b/js/xpconnect/src/XPCWrappedJSClass.cpp @@ -38,7 +38,7 @@ static uint32_t zero_methods_descriptor; bool AutoScriptEvaluate::StartEvaluating(HandleObject scope) { - NS_PRECONDITION(!mEvaluated, "AutoScriptEvaluate::Evaluate should only be called once"); + MOZ_ASSERT(!mEvaluated, "AutoScriptEvaluate::Evaluate should only be called once"); if (!mJSContext) return true; diff --git a/js/xpconnect/src/nsXPConnect.cpp b/js/xpconnect/src/nsXPConnect.cpp index 09ba0c437953..d53ba8e9e70a 100644 --- a/js/xpconnect/src/nsXPConnect.cpp +++ b/js/xpconnect/src/nsXPConnect.cpp @@ -667,7 +667,7 @@ nsXPConnect::JSValToVariant(JSContext* cx, HandleValue aJSVal, nsIVariant** aResult) { - NS_PRECONDITION(aResult, "bad param"); + MOZ_ASSERT(aResult, "bad param"); RefPtr variant = XPCVariant::newVariant(cx, aJSVal); variant.forget(aResult); @@ -879,9 +879,9 @@ NS_IMETHODIMP nsXPConnect::VariantToJS(JSContext* ctx, JSObject* scopeArg, nsIVariant* value, MutableHandleValue _retval) { - NS_PRECONDITION(ctx, "bad param"); - NS_PRECONDITION(scopeArg, "bad param"); - NS_PRECONDITION(value, "bad param"); + MOZ_ASSERT(ctx, "bad param"); + MOZ_ASSERT(scopeArg, "bad param"); + MOZ_ASSERT(value, "bad param"); RootedObject scope(ctx, scopeArg); MOZ_ASSERT(js::IsObjectInContextCompartment(scope, ctx)); @@ -899,8 +899,8 @@ nsXPConnect::VariantToJS(JSContext* ctx, JSObject* scopeArg, nsIVariant* value, NS_IMETHODIMP nsXPConnect::JSToVariant(JSContext* ctx, HandleValue value, nsIVariant** _retval) { - NS_PRECONDITION(ctx, "bad param"); - NS_PRECONDITION(_retval, "bad param"); + MOZ_ASSERT(ctx, "bad param"); + MOZ_ASSERT(_retval, "bad param"); RefPtr variant = XPCVariant::newVariant(ctx, value); variant.forget(_retval); diff --git a/layout/base/PresShell.cpp b/layout/base/PresShell.cpp index de668b60b38f..92fc9d97985f 100644 --- a/layout/base/PresShell.cpp +++ b/layout/base/PresShell.cpp @@ -911,10 +911,10 @@ PresShell::Init(nsIDocument* aDocument, nsViewManager* aViewManager, UniquePtr aStyleSet) { - NS_PRECONDITION(aDocument, "null ptr"); - NS_PRECONDITION(aPresContext, "null ptr"); - NS_PRECONDITION(aViewManager, "null ptr"); - NS_PRECONDITION(!mDocument, "already initialized"); + MOZ_ASSERT(aDocument, "null ptr"); + MOZ_ASSERT(aPresContext, "null ptr"); + MOZ_ASSERT(aViewManager, "null ptr"); + MOZ_ASSERT(!mDocument, "already initialized"); if (!aDocument || !aPresContext || !aViewManager || mDocument) { return; @@ -1932,7 +1932,7 @@ PresShell::ResizeReflowIgnoreOverride(nscoord aWidth, nscoord aHeight, nscoord aOldWidth, nscoord aOldHeight, ResizeReflowOptions aOptions) { - NS_PRECONDITION(!mIsReflowing, "Shouldn't be in reflow here!"); + MOZ_ASSERT(!mIsReflowing, "Shouldn't be in reflow here!"); nsIFrame* rootFrame = mFrameConstructor->GetRootFrame(); if (!rootFrame) { @@ -2544,7 +2544,7 @@ void PresShell::EndUpdate(nsIDocument *aDocument, nsUpdateType aUpdateType) { #ifdef DEBUG - NS_PRECONDITION(0 != mUpdateCount, "too many EndUpdate's"); + MOZ_ASSERT(0 != mUpdateCount, "too many EndUpdate's"); --mUpdateCount; #endif @@ -2604,7 +2604,7 @@ PresShell::BeginLoad(nsIDocument *aDocument) void PresShell::EndLoad(nsIDocument *aDocument) { - NS_PRECONDITION(aDocument == mDocument, "Wrong document"); + MOZ_ASSERT(aDocument == mDocument, "Wrong document"); RestoreRootScrollPosition(); @@ -2677,10 +2677,10 @@ PresShell::FrameNeedsReflow(nsIFrame *aFrame, IntrinsicDirty aIntrinsicDirty, nsFrameState aBitToAdd, ReflowRootHandling aRootHandling) { - NS_PRECONDITION(aBitToAdd == NS_FRAME_IS_DIRTY || - aBitToAdd == NS_FRAME_HAS_DIRTY_CHILDREN || - !aBitToAdd, - "Unexpected bits being added"); + MOZ_ASSERT(aBitToAdd == NS_FRAME_IS_DIRTY || + aBitToAdd == NS_FRAME_HAS_DIRTY_CHILDREN || + !aBitToAdd, + "Unexpected bits being added"); // FIXME bug 478135 NS_ASSERTION(!(aIntrinsicDirty == eStyleChange && @@ -2838,7 +2838,7 @@ void PresShell::FrameNeedsToContinueReflow(nsIFrame *aFrame) { NS_ASSERTION(mIsReflowing, "Must be in reflow when marking path dirty."); - NS_PRECONDITION(mCurrentReflowRoot, "Must have a current reflow root here"); + MOZ_ASSERT(mCurrentReflowRoot, "Must have a current reflow root here"); NS_ASSERTION(aFrame == mCurrentReflowRoot || nsLayoutUtils::IsProperAncestorFrame(mCurrentReflowRoot, aFrame), "Frame passed in is not the descendant of mCurrentReflowRoot"); @@ -3930,7 +3930,7 @@ nsIPresShell::ClearMouseCapture(nsIFrame* aFrame) nsresult PresShell::CaptureHistoryState(nsILayoutHistoryState** aState) { - NS_PRECONDITION(nullptr != aState, "null state pointer"); + MOZ_ASSERT(nullptr != aState, "null state pointer"); // We actually have to mess with the docshell here, since we want to // store the state back in it. @@ -4404,8 +4404,8 @@ void PresShell::CharacterDataChanged(nsIContent* aContent, const CharacterDataChangeInfo& aInfo) { - NS_PRECONDITION(!mIsDocumentGone, "Unexpected CharacterDataChanged"); - NS_PRECONDITION(aContent->OwnerDoc() == mDocument, "Unexpected document"); + MOZ_ASSERT(!mIsDocumentGone, "Unexpected CharacterDataChanged"); + MOZ_ASSERT(aContent->OwnerDoc() == mDocument, "Unexpected document"); nsAutoCauseReflowNotifier crNotifier(this); @@ -4418,8 +4418,8 @@ PresShell::ContentStateChanged(nsIDocument* aDocument, nsIContent* aContent, EventStates aStateMask) { - NS_PRECONDITION(!mIsDocumentGone, "Unexpected ContentStateChanged"); - NS_PRECONDITION(aDocument == mDocument, "Unexpected aDocument"); + MOZ_ASSERT(!mIsDocumentGone, "Unexpected ContentStateChanged"); + MOZ_ASSERT(aDocument == mDocument, "Unexpected aDocument"); if (mDidInitialize) { nsAutoCauseReflowNotifier crNotifier(this); @@ -4430,8 +4430,8 @@ PresShell::ContentStateChanged(nsIDocument* aDocument, void PresShell::DocumentStatesChanged(nsIDocument* aDocument, EventStates aStateMask) { - NS_PRECONDITION(!mIsDocumentGone, "Unexpected DocumentStatesChanged"); - NS_PRECONDITION(aDocument == mDocument, "Unexpected aDocument"); + MOZ_ASSERT(!mIsDocumentGone, "Unexpected DocumentStatesChanged"); + MOZ_ASSERT(aDocument == mDocument, "Unexpected aDocument"); MOZ_ASSERT(!aStateMask.IsEmpty()); if (mDidInitialize) { @@ -4452,8 +4452,8 @@ PresShell::AttributeWillChange(Element* aElement, int32_t aModType, const nsAttrValue* aNewValue) { - NS_PRECONDITION(!mIsDocumentGone, "Unexpected AttributeWillChange"); - NS_PRECONDITION(aElement->OwnerDoc() == mDocument, "Unexpected document"); + MOZ_ASSERT(!mIsDocumentGone, "Unexpected AttributeWillChange"); + MOZ_ASSERT(aElement->OwnerDoc() == mDocument, "Unexpected document"); // XXXwaterson it might be more elegant to wait until after the // initial reflow to begin observing the document. That would @@ -4473,8 +4473,8 @@ PresShell::AttributeChanged(Element* aElement, int32_t aModType, const nsAttrValue* aOldValue) { - NS_PRECONDITION(!mIsDocumentGone, "Unexpected AttributeChanged"); - NS_PRECONDITION(aElement->OwnerDoc() == mDocument, "Unexpected document"); + MOZ_ASSERT(!mIsDocumentGone, "Unexpected AttributeChanged"); + MOZ_ASSERT(aElement->OwnerDoc() == mDocument, "Unexpected document"); // XXXwaterson it might be more elegant to wait until after the // initial reflow to begin observing the document. That would @@ -4490,8 +4490,8 @@ PresShell::AttributeChanged(Element* aElement, void PresShell::ContentAppended(nsIContent* aFirstNewContent) { - NS_PRECONDITION(!mIsDocumentGone, "Unexpected ContentAppended"); - NS_PRECONDITION(aFirstNewContent->OwnerDoc() == mDocument, + MOZ_ASSERT(!mIsDocumentGone, "Unexpected ContentAppended"); + MOZ_ASSERT(aFirstNewContent->OwnerDoc() == mDocument, "Unexpected document"); // We never call ContentAppended with a document as the container, so we can @@ -4519,8 +4519,8 @@ PresShell::ContentAppended(nsIContent* aFirstNewContent) void PresShell::ContentInserted(nsIContent* aChild) { - NS_PRECONDITION(!mIsDocumentGone, "Unexpected ContentInserted"); - NS_PRECONDITION(aChild->OwnerDoc() == mDocument, "Unexpected document"); + MOZ_ASSERT(!mIsDocumentGone, "Unexpected ContentInserted"); + MOZ_ASSERT(aChild->OwnerDoc() == mDocument, "Unexpected document"); if (!mDidInitialize) { return; @@ -4542,8 +4542,8 @@ PresShell::ContentInserted(nsIContent* aChild) void PresShell::ContentRemoved(nsIContent* aChild, nsIContent* aPreviousSibling) { - NS_PRECONDITION(!mIsDocumentGone, "Unexpected ContentRemoved"); - NS_PRECONDITION(aChild->OwnerDoc() == mDocument, "Unexpected document"); + MOZ_ASSERT(!mIsDocumentGone, "Unexpected ContentRemoved"); + MOZ_ASSERT(aChild->OwnerDoc() == mDocument, "Unexpected document"); nsINode* container = aChild->GetParentNode(); // Notify the ESM that the content has been removed, so that @@ -4593,8 +4593,8 @@ PresShell::NotifyCounterStylesAreDirty() void PresShell::ReconstructFrames() { - NS_PRECONDITION(!mFrameConstructor->GetRootFrame() || mDidInitialize, - "Must not have root frame before initial reflow"); + MOZ_ASSERT(!mFrameConstructor->GetRootFrame() || mDidInitialize, + "Must not have root frame before initial reflow"); if (!mDidInitialize || mIsDestroying) { // Nothing to do here return; @@ -8848,7 +8848,7 @@ PresShell::sReflowContinueCallback(nsITimer* aTimer, void* aPresShell) { RefPtr self = static_cast(aPresShell); - NS_PRECONDITION(aTimer == self->mReflowContinueTimer, "Unexpected timer"); + MOZ_ASSERT(aTimer == self->mReflowContinueTimer, "Unexpected timer"); self->mReflowContinueTimer = nullptr; self->ScheduleReflow(); } @@ -8856,7 +8856,7 @@ PresShell::sReflowContinueCallback(nsITimer* aTimer, void* aPresShell) bool PresShell::ScheduleReflowOffTimer() { - NS_PRECONDITION(!mObservingLayoutFlushes, "Shouldn't get here"); + MOZ_ASSERT(!mObservingLayoutFlushes, "Shouldn't get here"); ASSERT_REFLOW_SCHEDULED_STATE(); if (!mReflowContinueTimer) { @@ -10442,7 +10442,7 @@ SetPluginIsActive(nsISupports* aSupports, void* aClosure) nsresult PresShell::SetIsActive(bool aIsActive) { - NS_PRECONDITION(mDocument, "should only be called with a document"); + MOZ_ASSERT(mDocument, "should only be called with a document"); mIsActive = aIsActive; diff --git a/layout/base/RestyleManager.cpp b/layout/base/RestyleManager.cpp index 680127878f5f..803b6b581ce2 100644 --- a/layout/base/RestyleManager.cpp +++ b/layout/base/RestyleManager.cpp @@ -991,8 +991,8 @@ static void DoApplyRenderingChangeToTree(nsIFrame* aFrame, nsChangeHint aChange) { - NS_PRECONDITION(gInApplyRenderingChangeToTree, - "should only be called within ApplyRenderingChangeToTree"); + MOZ_ASSERT(gInApplyRenderingChangeToTree, + "should only be called within ApplyRenderingChangeToTree"); for ( ; aFrame; aFrame = nsLayoutUtils::GetNextContinuationOrIBSplitSibling(aFrame)) { // Invalidate and sync views on all descendant frames, following placeholders. @@ -1091,8 +1091,9 @@ DoApplyRenderingChangeToTree(nsIFrame* aFrame, static void SyncViewsAndInvalidateDescendants(nsIFrame* aFrame, nsChangeHint aChange) { - NS_PRECONDITION(gInApplyRenderingChangeToTree, - "should only be called within ApplyRenderingChangeToTree"); + MOZ_ASSERT(gInApplyRenderingChangeToTree, + "should only be called within ApplyRenderingChangeToTree"); + NS_ASSERTION(nsChangeHint_size_t(aChange) == (aChange & (nsChangeHint_RepaintFrame | nsChangeHint_SyncFrameView | diff --git a/layout/base/nsBidiPresUtils.cpp b/layout/base/nsBidiPresUtils.cpp index f76b90b50a85..5443517d2f7d 100644 --- a/layout/base/nsBidiPresUtils.cpp +++ b/layout/base/nsBidiPresUtils.cpp @@ -627,8 +627,8 @@ CreateContinuation(nsIFrame* aFrame, nsIFrame** aNewFrame, bool aIsFluid) { - NS_PRECONDITION(aNewFrame, "null OUT ptr"); - NS_PRECONDITION(aFrame, "null ptr"); + MOZ_ASSERT(aNewFrame, "null OUT ptr"); + MOZ_ASSERT(aFrame, "null ptr"); *aNewFrame = nullptr; @@ -1867,8 +1867,8 @@ nsBidiPresUtils::EnsureBidiContinuation(nsIFrame* aFrame, int32_t aStart, int32_t aEnd) { - NS_PRECONDITION(aNewFrame, "null OUT ptr"); - NS_PRECONDITION(aFrame, "aFrame is null"); + MOZ_ASSERT(aNewFrame, "null OUT ptr"); + MOZ_ASSERT(aFrame, "aFrame is null"); aFrame->AdjustOffsetsForBidi(aStart, aEnd); return CreateContinuation(aFrame, aNewFrame, false); diff --git a/layout/base/nsCSSFrameConstructor.cpp b/layout/base/nsCSSFrameConstructor.cpp index 6fa511a65547..40e501ad25f3 100644 --- a/layout/base/nsCSSFrameConstructor.cpp +++ b/layout/base/nsCSSFrameConstructor.cpp @@ -545,7 +545,7 @@ IsFramePartOfIBSplit(nsIFrame* aFrame) static nsContainerFrame* GetIBSplitSibling(nsIFrame* aFrame) { - NS_PRECONDITION(IsFramePartOfIBSplit(aFrame), "Shouldn't call this"); + MOZ_ASSERT(IsFramePartOfIBSplit(aFrame), "Shouldn't call this"); // We only store the "ib-split sibling" annotation with the first // frame in the continuation chain. Walk back to find that frame now. @@ -555,7 +555,7 @@ static nsContainerFrame* GetIBSplitSibling(nsIFrame* aFrame) static nsContainerFrame* GetIBSplitPrevSibling(nsIFrame* aFrame) { - NS_PRECONDITION(IsFramePartOfIBSplit(aFrame), "Shouldn't call this"); + MOZ_ASSERT(IsFramePartOfIBSplit(aFrame), "Shouldn't call this"); // We only store the ib-split sibling annotation with the first // frame in the continuation chain. Walk back to find that frame now. @@ -579,7 +579,7 @@ GetLastIBSplitSibling(nsIFrame* aFrame) static void SetFrameIsIBSplit(nsContainerFrame* aFrame, nsContainerFrame* aIBSplitSibling) { - NS_PRECONDITION(aFrame, "bad args!"); + MOZ_ASSERT(aFrame, "bad args!"); // We should be the only continuation NS_ASSERTION(!aFrame->GetPrevContinuation(), @@ -606,8 +606,8 @@ SetFrameIsIBSplit(nsContainerFrame* aFrame, nsContainerFrame* aIBSplitSibling) static nsIFrame* GetIBContainingBlockFor(nsIFrame* aFrame) { - NS_PRECONDITION(IsFramePartOfIBSplit(aFrame), - "GetIBContainingBlockFor() should only be called on known IB frames"); + MOZ_ASSERT(IsFramePartOfIBSplit(aFrame), + "GetIBContainingBlockFor() should only be called on known IB frames"); // Get the first "normal" ancestor of the target frame. nsIFrame* parentFrame; @@ -691,7 +691,7 @@ FindFirstNonBlock(const nsFrameList& aList) inline void SetInitialSingleChild(nsContainerFrame* aParent, nsIFrame* aFrame) { - NS_PRECONDITION(!aFrame->GetNextSibling(), "Should be using a frame list"); + MOZ_ASSERT(!aFrame->GetNextSibling(), "Should be using a frame list"); nsFrameList temp(aFrame, aFrame); aParent->SetInitialChildList(kPrincipalList, temp); } @@ -708,7 +708,7 @@ struct nsFrameItems : public nsFrameList void nsFrameItems::AddChild(nsIFrame* aChild) { - NS_PRECONDITION(aChild, "nsFrameItems::AddChild"); + MOZ_ASSERT(aChild, "nsFrameItems::AddChild"); // It'd be really nice if we could just AppendFrames(kPrincipalList, aChild) here, // but some of our callers put frames that have different @@ -1148,9 +1148,9 @@ void nsFrameConstructorState::PushFloatContainingBlock(nsContainerFrame* aNewFloatContainingBlock, nsFrameConstructorSaveState& aSaveState) { - NS_PRECONDITION(!aNewFloatContainingBlock || - aNewFloatContainingBlock->IsFloatContainingBlock(), - "Please push a real float containing block!"); + MOZ_ASSERT(!aNewFloatContainingBlock || + aNewFloatContainingBlock->IsFloatContainingBlock(), + "Please push a real float containing block!"); NS_ASSERTION(!aNewFloatContainingBlock || !ShouldSuppressFloatingOfDescendants(aNewFloatContainingBlock), "We should not push a frame that is supposed to _suppress_ " @@ -1166,7 +1166,7 @@ nsContainerFrame* nsFrameConstructorState::GetGeometricParent(const nsStyleDisplay* aStyleDisplay, nsContainerFrame* aContentParentFrame) const { - NS_PRECONDITION(aStyleDisplay, "Must have display struct!"); + MOZ_ASSERT(aStyleDisplay, "Must have display struct!"); // If there is no container for a fixed, absolute, or floating root // frame, we will ignore the positioning. This hack is originally @@ -1313,7 +1313,7 @@ nsFrameConstructorState::AddChild(nsIFrame* aNewFrame, bool aInsertAfter, nsIFrame* aInsertAfterFrame) { - NS_PRECONDITION(!aNewFrame->GetNextSibling(), "Shouldn't happen"); + MOZ_ASSERT(!aNewFrame->GetNextSibling(), "Shouldn't happen"); nsFrameState placeholderType; nsAbsoluteItems* outOfFlowFrameItems = @@ -1379,13 +1379,13 @@ nsFrameConstructorState::ProcessFrameInsertions(nsAbsoluteItems& aFrameItems, &aFrameItems == &mTopLayerFixedItems) && \ aChildListID == nsIFrame::kFixedList) #ifdef MOZ_XUL - NS_PRECONDITION(NS_NONXUL_LIST_TEST || - (&aFrameItems == &mPopupItems && - aChildListID == nsIFrame::kPopupList), - "Unexpected aFrameItems/aChildListID combination"); + MOZ_ASSERT(NS_NONXUL_LIST_TEST || + (&aFrameItems == &mPopupItems && + aChildListID == nsIFrame::kPopupList), + "Unexpected aFrameItems/aChildListID combination"); #else - NS_PRECONDITION(NS_NONXUL_LIST_TEST, - "Unexpected aFrameItems/aChildListID combination"); + MOZ_ASSERT(NS_NONXUL_LIST_TEST, + "Unexpected aFrameItems/aChildListID combination"); #endif if (aFrameItems.IsEmpty()) { @@ -2045,8 +2045,8 @@ nsCSSFrameConstructor::AdjustParentFrame(nsContainerFrame** aParentFra const FrameConstructionData* aFCData, ComputedStyle* aComputedStyle) { - NS_PRECONDITION(aComputedStyle, "Must have child's style"); - NS_PRECONDITION(aFCData, "Must have frame construction data"); + MOZ_ASSERT(aComputedStyle, "Must have child's style"); + MOZ_ASSERT(aFCData, "Must have frame construction data"); bool tablePart = ((aFCData->mBits & FCDATA_IS_TABLE_PART) != 0); @@ -2083,9 +2083,9 @@ nsCSSFrameConstructor::ConstructTable(nsFrameConstructorState& aState, const nsStyleDisplay* aDisplay, nsFrameItems& aFrameItems) { - NS_PRECONDITION(aDisplay->mDisplay == StyleDisplay::Table || - aDisplay->mDisplay == StyleDisplay::InlineTable, - "Unexpected call"); + MOZ_ASSERT(aDisplay->mDisplay == StyleDisplay::Table || + aDisplay->mDisplay == StyleDisplay::InlineTable, + "Unexpected call"); nsIContent* const content = aItem.mContent; ComputedStyle* const computedStyle = aItem.mComputedStyle; @@ -2376,10 +2376,10 @@ NeedFrameFor(const nsFrameConstructorState& aState, { // XXX the GetContent() != aChildContent check is needed due to bug 135040. // Remove it once that's fixed. - NS_PRECONDITION(!aChildContent->GetPrimaryFrame() || - aState.mCreatingExtraFrames || - aChildContent->GetPrimaryFrame()->GetContent() != aChildContent, - "Why did we get called?"); + MOZ_ASSERT(!aChildContent->GetPrimaryFrame() || + aState.mCreatingExtraFrames || + aChildContent->GetPrimaryFrame()->GetContent() != aChildContent, + "Why did we get called?"); // don't create a whitespace frame if aParentFrame doesn't want it. // always create frames for children in generated content. counter(), @@ -2729,10 +2729,10 @@ nsCSSFrameConstructor::ConstructRootFrame() void nsCSSFrameConstructor::SetUpDocElementContainingBlock(nsIContent* aDocElement) { - NS_PRECONDITION(aDocElement, "No element?"); - NS_PRECONDITION(!aDocElement->GetParent(), "Not root content?"); - NS_PRECONDITION(aDocElement->GetUncomposedDoc(), "Not in a document?"); - NS_PRECONDITION(aDocElement->GetUncomposedDoc()->GetRootElement() == + MOZ_ASSERT(aDocElement, "No element?"); + MOZ_ASSERT(!aDocElement->GetParent(), "Not root content?"); + MOZ_ASSERT(aDocElement->GetUncomposedDoc(), "Not in a document?"); + MOZ_ASSERT(aDocElement->GetUncomposedDoc()->GetRootElement() == aDocElement, "Not the root of the document?"); /* @@ -3057,8 +3057,9 @@ nsCSSFrameConstructor::CreatePlaceholderFrameFor(nsIPresShell* aPresShell, static inline void ClearLazyBits(nsIContent* aStartContent, nsIContent* aEndContent) { - NS_PRECONDITION(aStartContent || !aEndContent, - "Must have start child if we have an end child"); + MOZ_ASSERT(aStartContent || !aEndContent, + "Must have start child if we have an end child"); + for (nsIContent* cur = aStartContent; cur != aEndContent; cur = cur->GetNextSibling()) { cur->UnsetFlags(NODE_DESCENDANTS_NEED_FRAMES | NODE_NEEDS_FRAME); @@ -3473,7 +3474,7 @@ nsCSSFrameConstructor::ConstructTextFrame(const FrameConstructionData* aData, ComputedStyle* aComputedStyle, nsFrameItems& aFrameItems) { - NS_PRECONDITION(aData, "Must have frame construction data"); + MOZ_ASSERT(aData, "Must have frame construction data"); nsIFrame* newFrame = (*aData->mFunc.mCreationFunc)(mPresShell, aComputedStyle); @@ -5652,8 +5653,8 @@ nsCSSFrameConstructor::AddFrameConstructionItemsInternal(nsFrameConstructorState nsTArray* aAnonChildren, FrameConstructionItemList& aItems) { - NS_PRECONDITION(aContent->IsText() || aContent->IsElement(), - "Shouldn't get anything else here!"); + MOZ_ASSERT(aContent->IsText() || aContent->IsElement(), + "Shouldn't get anything else here!"); MOZ_ASSERT(aContent->IsInComposedDoc()); MOZ_ASSERT(!aContent->GetPrimaryFrame() || aState.mCreatingExtraFrames || aContent->NodeInfo()->NameAtom() == nsGkAtoms::area); @@ -6276,12 +6277,12 @@ nsCSSFrameConstructor::AppendFramesToParent(nsFrameConstructorState& aStat nsIFrame* aPrevSibling, bool aIsRecursiveCall) { - NS_PRECONDITION(!IsFramePartOfIBSplit(aParentFrame) || - !GetIBSplitSibling(aParentFrame) || - !GetIBSplitSibling(aParentFrame)->PrincipalChildList().FirstChild(), - "aParentFrame has a ib-split sibling with kids?"); - NS_PRECONDITION(!aPrevSibling || aPrevSibling->GetParent() == aParentFrame, - "Parent and prevsibling don't match"); + MOZ_ASSERT(!IsFramePartOfIBSplit(aParentFrame) || + !GetIBSplitSibling(aParentFrame) || + !GetIBSplitSibling(aParentFrame)->PrincipalChildList().FirstChild(), + "aParentFrame has a ib-split sibling with kids?"); + MOZ_ASSERT(!aPrevSibling || aPrevSibling->GetParent() == aParentFrame, + "Parent and prevsibling don't match"); nsIFrame* nextSibling = ::GetInsertNextSibling(aParentFrame, aPrevSibling); @@ -6604,8 +6605,7 @@ static nsContainerFrame* GetAdjustedParentFrame(nsContainerFrame* aParentFrame, nsIContent* aChildContent) { - NS_PRECONDITION(!aParentFrame->IsTableWrapperFrame(), - "Shouldn't be happening!"); + MOZ_ASSERT(!aParentFrame->IsTableWrapperFrame(), "Shouldn't be happening!"); nsContainerFrame* newParent = nullptr; @@ -6627,7 +6627,7 @@ nsCSSFrameConstructor::GetInsertionPrevSibling(InsertionPoint* aInsertion, nsIContent* aStartSkipChild, nsIContent* aEndSkipChild) { - NS_PRECONDITION(aInsertion->mParentFrame, "Must have parent frame to start with"); + MOZ_ASSERT(aInsertion->mParentFrame, "Must have parent frame to start with"); *aIsAppend = false; @@ -6738,7 +6738,7 @@ nsCSSFrameConstructor::AddTextItemIfNeeded(nsFrameConstructorState& aState, nsIContent* aPossibleTextContent, FrameConstructionItemList& aItems) { - NS_PRECONDITION(aPossibleTextContent, "Must have node"); + MOZ_ASSERT(aPossibleTextContent, "Must have node"); if (!aPossibleTextContent->IsText() || !aPossibleTextContent->HasFlag(NS_CREATE_FRAME_IF_NON_WHITESPACE) || aPossibleTextContent->HasFlag(NODE_NEEDS_FRAME)) { @@ -7416,7 +7416,7 @@ nsCSSFrameConstructor::ContentRangeInserted(nsIContent* aStartChild, AUTO_LAYOUT_PHASE_ENTRY_POINT(mPresShell->GetPresContext(), FrameC); - NS_PRECONDITION(aStartChild, "must always pass a child"); + MOZ_ASSERT(aStartChild, "must always pass a child"); #ifdef DEBUG if (gNoisyContentUpdates) { @@ -8211,8 +8211,8 @@ nsCSSFrameConstructor::ContentRemoved(nsIContent* aChild, static void InvalidateCanvasIfNeeded(nsIPresShell* presShell, nsIContent* node) { - NS_PRECONDITION(presShell->GetRootFrame(), "What happened here?"); - NS_PRECONDITION(presShell->GetPresContext(), "Say what?"); + MOZ_ASSERT(presShell->GetRootFrame(), "What happened here?"); + MOZ_ASSERT(presShell->GetPresContext(), "Say what?"); // Note that both in ContentRemoved and ContentInserted the content node // will still have the right parent pointer, so looking at that is ok. @@ -8856,10 +8856,10 @@ FindPreviousNonWhitespaceSibling(nsIFrame* aFrame) bool nsCSSFrameConstructor::MaybeRecreateContainerForFrameRemoval(nsIFrame* aFrame) { - NS_PRECONDITION(aFrame, "Must have a frame"); - NS_PRECONDITION(aFrame->GetParent(), "Frame shouldn't be root"); - NS_PRECONDITION(aFrame == aFrame->FirstContinuation(), - "aFrame not the result of GetPrimaryFrame()?"); + MOZ_ASSERT(aFrame, "Must have a frame"); + MOZ_ASSERT(aFrame->GetParent(), "Frame shouldn't be root"); + MOZ_ASSERT(aFrame == aFrame->FirstContinuation(), + "aFrame not the result of GetPrimaryFrame()?"); if (IsFramePartOfIBSplit(aFrame)) { // The removal functions can't handle removal of an {ib} split directly; we @@ -9281,7 +9281,7 @@ nsCSSFrameConstructor::ShouldHaveFirstLetterStyle(nsIContent* aContent, bool nsCSSFrameConstructor::HasFirstLetterStyle(nsIFrame* aBlockFrame) { - NS_PRECONDITION(aBlockFrame, "Need a frame"); + MOZ_ASSERT(aBlockFrame, "Need a frame"); NS_ASSERTION(nsLayoutUtils::GetAsBlock(aBlockFrame), "Not a block frame?"); @@ -10206,10 +10206,11 @@ nsCSSFrameConstructor::ProcessChildren(nsFrameConstructorState& aState, PendingBinding* aPendingBinding, nsIFrame* aPossiblyLeafFrame) { - NS_PRECONDITION(aFrame, "Must have parent frame here"); - NS_PRECONDITION(aFrame->GetContentInsertionFrame() == aFrame, - "Parent frame in ProcessChildren should be its own " - "content insertion frame"); + MOZ_ASSERT(aFrame, "Must have parent frame here"); + MOZ_ASSERT(aFrame->GetContentInsertionFrame() == aFrame, + "Parent frame in ProcessChildren should be its own " + "content insertion frame"); + const uint32_t kMaxDepth = 2 * MAX_REFLOW_DEPTH; static_assert(kMaxDepth <= UINT16_MAX, "mCurrentDepth type is too narrow"); AutoRestore savedDepth(mCurrentDepth); @@ -10599,7 +10600,7 @@ FirstLetterCount(const nsTextFragment* aFragment) static bool NeedFirstLetterContinuation(nsIContent* aContent) { - NS_PRECONDITION(aContent, "null ptr"); + MOZ_ASSERT(aContent, "null ptr"); bool result = false; if (aContent) { @@ -10702,7 +10703,7 @@ nsCSSFrameConstructor::CreateLetterFrame(nsContainerFrame* aBlockFrame, nsContainerFrame* aParentFrame, nsFrameItems& aResult) { - NS_PRECONDITION(aTextContent->IsText(), "aTextContent isn't text"); + MOZ_ASSERT(aTextContent->IsText(), "aTextContent isn't text"); NS_ASSERTION(nsLayoutUtils::GetAsBlock(aBlockFrame), "Not a block frame?"); @@ -11427,9 +11428,9 @@ nsCSSFrameConstructor::CreateIBSiblings(nsFrameConstructorState& aState, do { // On entry to this loop aChildItems is not empty and the first frame in it // is block-level. - NS_PRECONDITION(aChildItems.NotEmpty(), "Should have child items"); - NS_PRECONDITION(!aChildItems.FirstChild()->IsInlineOutside(), - "Must have list starting with block"); + MOZ_ASSERT(aChildItems.NotEmpty(), "Should have child items"); + MOZ_ASSERT(!aChildItems.FirstChild()->IsInlineOutside(), + "Must have list starting with block"); // The initial run of blocks belongs to an anonymous block that we create // right now. The anonymous block will be the parent of these block @@ -11547,8 +11548,8 @@ nsCSSFrameConstructor::BuildInlineChildItems(nsFrameConstructorState& aState, static bool IsSafeToAppendToIBSplitInline(nsIFrame* aParentFrame, nsIFrame* aNextSibling) { - NS_PRECONDITION(IsInlineFrame(aParentFrame), - "Must have an inline parent here"); + MOZ_ASSERT(IsInlineFrame(aParentFrame), "Must have an inline parent here"); + do { NS_ASSERTION(IsFramePartOfIBSplit(aParentFrame), "How is this not part of an ib-split?"); @@ -12012,8 +12013,8 @@ bool nsCSSFrameConstructor:: FrameConstructionItem::IsWhitespace(nsFrameConstructorState& aState) const { - NS_PRECONDITION(aState.mCreatingExtraFrames || - !mContent->GetPrimaryFrame(), "How did that happen?"); + MOZ_ASSERT(aState.mCreatingExtraFrames || + !mContent->GetPrimaryFrame(), "How did that happen?"); if (!mIsText) { return false; } @@ -12029,7 +12030,7 @@ void nsCSSFrameConstructor::FrameConstructionItemList:: AdjustCountsForItem(FrameConstructionItem* aItem, int32_t aDelta) { - NS_PRECONDITION(aDelta == 1 || aDelta == -1, "Unexpected delta"); + MOZ_ASSERT(aDelta == 1 || aDelta == -1, "Unexpected delta"); mItemCount += aDelta; if (aItem->mIsAllInline) { mInlineCount += aDelta; @@ -12050,7 +12051,7 @@ inline bool nsCSSFrameConstructor::FrameConstructionItemList:: Iterator::SkipItemsWantingParentType(ParentType aParentType) { - NS_PRECONDITION(!IsDone(), "Shouldn't be done yet"); + MOZ_ASSERT(!IsDone(), "Shouldn't be done yet"); while (item().DesiredParentType() == aParentType) { Next(); if (IsDone()) { @@ -12064,7 +12065,7 @@ inline bool nsCSSFrameConstructor::FrameConstructionItemList:: Iterator::SkipItemsNotWantingParentType(ParentType aParentType) { - NS_PRECONDITION(!IsDone(), "Shouldn't be done yet"); + MOZ_ASSERT(!IsDone(), "Shouldn't be done yet"); while (item().DesiredParentType() != aParentType) { Next(); if (IsDone()) { @@ -12115,7 +12116,7 @@ Iterator::SkipItemsThatNeedAnonFlexOrGridItem( const nsFrameConstructorState& aState, bool aIsLegacyBox) { - NS_PRECONDITION(!IsDone(), "Shouldn't be done yet"); + MOZ_ASSERT(!IsDone(), "Shouldn't be done yet"); while (item().NeedsAnonFlexOrGridItem(aState, aIsLegacyBox)) { Next(); if (IsDone()) { @@ -12131,7 +12132,7 @@ Iterator::SkipItemsThatDontNeedAnonFlexOrGridItem( const nsFrameConstructorState& aState, bool aIsLegacyBox) { - NS_PRECONDITION(!IsDone(), "Shouldn't be done yet"); + MOZ_ASSERT(!IsDone(), "Shouldn't be done yet"); while (!(item().NeedsAnonFlexOrGridItem(aState, aIsLegacyBox))) { Next(); if (IsDone()) { @@ -12145,7 +12146,7 @@ inline bool nsCSSFrameConstructor::FrameConstructionItemList:: Iterator::SkipItemsNotWantingRubyParent() { - NS_PRECONDITION(!IsDone(), "Shouldn't be done yet"); + MOZ_ASSERT(!IsDone(), "Shouldn't be done yet"); while (!IsRubyParentType(item().DesiredParentType())) { Next(); if (IsDone()) { @@ -12159,8 +12160,8 @@ inline bool nsCSSFrameConstructor::FrameConstructionItemList:: Iterator::SkipWhitespace(nsFrameConstructorState& aState) { - NS_PRECONDITION(!IsDone(), "Shouldn't be done yet"); - NS_PRECONDITION(item().IsWhitespace(aState), "Not pointing to whitespace?"); + MOZ_ASSERT(!IsDone(), "Shouldn't be done yet"); + MOZ_ASSERT(item().IsWhitespace(aState), "Not pointing to whitespace?"); do { Next(); if (IsDone()) { @@ -12176,7 +12177,7 @@ nsCSSFrameConstructor::FrameConstructionItemList:: Iterator::AppendItemToList(FrameConstructionItemList& aTargetList) { NS_ASSERTION(&aTargetList != &mList, "Unexpected call"); - NS_PRECONDITION(!IsDone(), "should not be done"); + MOZ_ASSERT(!IsDone(), "should not be done"); FrameConstructionItem* item = mCurrent; Next(); @@ -12193,7 +12194,7 @@ Iterator::AppendItemsToList(nsCSSFrameConstructor* aFCtor, const Iterator& aEnd, FrameConstructionItemList& aTargetList) { NS_ASSERTION(&aTargetList != &mList, "Unexpected call"); - NS_PRECONDITION(&mList == &aEnd.mList, "End iterator for some other list?"); + MOZ_ASSERT(&mList == &aEnd.mList, "End iterator for some other list?"); // We can't just move our guts to the other list if it already has // some information or if we're not moving our entire list. @@ -12242,8 +12243,8 @@ void nsCSSFrameConstructor::FrameConstructionItemList:: Iterator::DeleteItemsTo(nsCSSFrameConstructor* aFCtor, const Iterator& aEnd) { - NS_PRECONDITION(&mList == &aEnd.mList, "End iterator for some other list?"); - NS_PRECONDITION(*this != aEnd, "Shouldn't be at aEnd yet"); + MOZ_ASSERT(&mList == &aEnd.mList, "End iterator for some other list?"); + MOZ_ASSERT(*this != aEnd, "Shouldn't be at aEnd yet"); do { NS_ASSERTION(!IsDone(), "Ran off end of list?"); diff --git a/layout/base/nsDocumentViewer.cpp b/layout/base/nsDocumentViewer.cpp index f53aa837bbda..c95a0fe8b2dc 100644 --- a/layout/base/nsDocumentViewer.cpp +++ b/layout/base/nsDocumentViewer.cpp @@ -2586,9 +2586,9 @@ nsDocumentViewer::FindContainerView() nsresult nsDocumentViewer::CreateDeviceContext(nsView* aContainerView) { - NS_PRECONDITION(!mPresShell && !mWindow, - "This will screw up our existing presentation"); - NS_PRECONDITION(mDocument, "Gotta have a document here"); + MOZ_ASSERT(!mPresShell && !mWindow, + "This will screw up our existing presentation"); + MOZ_ASSERT(mDocument, "Gotta have a document here"); nsIDocument* doc = mDocument->GetDisplayDocument(); if (doc) { diff --git a/layout/base/nsFrameManager.cpp b/layout/base/nsFrameManager.cpp index e43114197488..566ec96fa905 100644 --- a/layout/base/nsFrameManager.cpp +++ b/layout/base/nsFrameManager.cpp @@ -84,10 +84,10 @@ nsFrameManager::InsertFrames(nsContainerFrame* aParentFrame, nsIFrame* aPrevFrame, nsFrameList& aFrameList) { - NS_PRECONDITION(!aPrevFrame || (!aPrevFrame->GetNextContinuation() - || (((aPrevFrame->GetNextContinuation()->GetStateBits() & NS_FRAME_IS_OVERFLOW_CONTAINER)) - && !(aPrevFrame->GetStateBits() & NS_FRAME_IS_OVERFLOW_CONTAINER))), - "aPrevFrame must be the last continuation in its chain!"); + MOZ_ASSERT(!aPrevFrame || (!aPrevFrame->GetNextContinuation() + || (((aPrevFrame->GetNextContinuation()->GetStateBits() & NS_FRAME_IS_OVERFLOW_CONTAINER)) + && !(aPrevFrame->GetStateBits() & NS_FRAME_IS_OVERFLOW_CONTAINER))), + "aPrevFrame must be the last continuation in its chain!"); if (aParentFrame->IsAbsoluteContainer() && aListID == aParentFrame->GetAbsoluteListID()) { @@ -170,7 +170,7 @@ void nsFrameManager::CaptureFrameState(nsIFrame* aFrame, nsILayoutHistoryState* aState) { - NS_PRECONDITION(nullptr != aFrame && nullptr != aState, "null parameters passed in"); + MOZ_ASSERT(nullptr != aFrame && nullptr != aState, "null parameters passed in"); CaptureFrameStateFor(aFrame, aState); @@ -245,7 +245,7 @@ void nsFrameManager::RestoreFrameState(nsIFrame* aFrame, nsILayoutHistoryState* aState) { - NS_PRECONDITION(nullptr != aFrame && nullptr != aState, "null parameters passed in"); + MOZ_ASSERT(nullptr != aFrame && nullptr != aState, "null parameters passed in"); RestoreFrameStateFor(aFrame, aState); diff --git a/layout/base/nsLayoutDebugger.cpp b/layout/base/nsLayoutDebugger.cpp index 6488280371b3..fd2019b8c662 100644 --- a/layout/base/nsLayoutDebugger.cpp +++ b/layout/base/nsLayoutDebugger.cpp @@ -44,7 +44,7 @@ protected: nsresult NS_NewLayoutDebugger(nsILayoutDebugger** aResult) { - NS_PRECONDITION(aResult, "null OUT ptr"); + MOZ_ASSERT(aResult, "null OUT ptr"); if (!aResult) { return NS_ERROR_NULL_POINTER; } diff --git a/layout/base/nsLayoutUtils.cpp b/layout/base/nsLayoutUtils.cpp index 968265a1a117..6267a799d860 100644 --- a/layout/base/nsLayoutUtils.cpp +++ b/layout/base/nsLayoutUtils.cpp @@ -1380,7 +1380,7 @@ nsLayoutUtils::RemoveDisplayPort(nsIContent* aContent) nsContainerFrame* nsLayoutUtils::LastContinuationWithChild(nsContainerFrame* aFrame) { - NS_PRECONDITION(aFrame, "NULL frame pointer"); + MOZ_ASSERT(aFrame, "NULL frame pointer"); nsIFrame* f = aFrame->LastContinuation(); while (!f->PrincipalChildList().FirstChild() && f->GetPrevContinuation()) { f = f->GetPrevContinuation(); @@ -1623,8 +1623,8 @@ nsLayoutUtils::DoCompareTreePosition(nsIContent* aContent1, int32_t aIf2Ancestor, const nsIContent* aCommonAncestor) { - NS_PRECONDITION(aContent1, "aContent1 must not be null"); - NS_PRECONDITION(aContent2, "aContent2 must not be null"); + MOZ_ASSERT(aContent1, "aContent1 must not be null"); + MOZ_ASSERT(aContent2, "aContent2 must not be null"); AutoTArray content1Ancestors; nsINode* c1; @@ -1728,8 +1728,8 @@ nsLayoutUtils::DoCompareTreePosition(nsIFrame* aFrame1, int32_t aIf2Ancestor, nsIFrame* aCommonAncestor) { - NS_PRECONDITION(aFrame1, "aFrame1 must not be null"); - NS_PRECONDITION(aFrame2, "aFrame2 must not be null"); + MOZ_ASSERT(aFrame1, "aFrame1 must not be null"); + MOZ_ASSERT(aFrame2, "aFrame2 must not be null"); AutoTArray frame2Ancestors; nsIFrame* nonCommonAncestor = @@ -1749,8 +1749,8 @@ nsLayoutUtils::DoCompareTreePosition(nsIFrame* aFrame1, int32_t aIf2Ancestor, nsIFrame* aCommonAncestor) { - NS_PRECONDITION(aFrame1, "aFrame1 must not be null"); - NS_PRECONDITION(aFrame2, "aFrame2 must not be null"); + MOZ_ASSERT(aFrame1, "aFrame1 must not be null"); + MOZ_ASSERT(aFrame2, "aFrame2 must not be null"); nsPresContext* presContext = aFrame1->PresContext(); if (presContext != aFrame2->PresContext()) { @@ -2082,7 +2082,7 @@ nsLayoutUtils::HasPseudoStyle(nsIContent* aContent, CSSPseudoElementType aPseudoElement, nsPresContext* aPresContext) { - NS_PRECONDITION(aPresContext, "Must have a prescontext"); + MOZ_ASSERT(aPresContext, "Must have a prescontext"); RefPtr pseudoContext; if (aContent) { @@ -4990,8 +4990,9 @@ GetIntrinsicCoord(const nsStyleCoord& aStyle, eWidthProperty aProperty, nscoord& aResult) { - NS_PRECONDITION(aProperty == PROP_WIDTH || aProperty == PROP_MAX_WIDTH || - aProperty == PROP_MIN_WIDTH, "unexpected property"); + MOZ_ASSERT(aProperty == PROP_WIDTH || aProperty == PROP_MAX_WIDTH || + aProperty == PROP_MIN_WIDTH, "unexpected property"); + if (aStyle.GetUnit() != eStyleUnit_Enumerated) return false; int32_t val = aStyle.GetIntValue(); @@ -5212,10 +5213,10 @@ nsLayoutUtils::IntrinsicForAxis(PhysicalAxis aAxis, uint32_t aFlags, nscoord aMarginBoxMinSizeClamp) { - NS_PRECONDITION(aFrame, "null frame"); - NS_PRECONDITION(aFrame->GetParent(), - "IntrinsicForAxis called on frame not in tree"); - NS_PRECONDITION(aType == MIN_ISIZE || aType == PREF_ISIZE, "bad type"); + MOZ_ASSERT(aFrame, "null frame"); + MOZ_ASSERT(aFrame->GetParent(), + "IntrinsicForAxis called on frame not in tree"); + MOZ_ASSERT(aType == MIN_ISIZE || aType == PREF_ISIZE, "bad type"); MOZ_ASSERT(aFrame->GetParent()->Type() != LayoutFrameType::GridContainer || aPercentageBasis.isSome(), "grid layout should always pass a percentage basis"); @@ -5595,9 +5596,9 @@ nsLayoutUtils::ComputeBSizeDependentValue( // the unit conditions. // XXXldb Many callers pass a non-'auto' containing block height when // according to CSS2.1 they should be passing 'auto'. - NS_PRECONDITION(NS_AUTOHEIGHT != aContainingBlockBSize || - !aCoord.HasPercent(), - "unexpected containing block block-size"); + MOZ_ASSERT(NS_AUTOHEIGHT != aContainingBlockBSize || + !aCoord.HasPercent(), + "unexpected containing block block-size"); if (aCoord.IsCoordPercentCalcUnit()) { return aCoord.ComputeCoordPercentCalc(aContainingBlockBSize); @@ -6304,7 +6305,7 @@ nsLayoutUtils::GetLastLineBaseline(WritingMode aWM, static nscoord CalculateBlockContentBEnd(WritingMode aWM, nsBlockFrame* aFrame) { - NS_PRECONDITION(aFrame, "null ptr"); + MOZ_ASSERT(aFrame, "null ptr"); nscoord contentBEnd = 0; @@ -6330,7 +6331,7 @@ CalculateBlockContentBEnd(WritingMode aWM, nsBlockFrame* aFrame) /* static */ nscoord nsLayoutUtils::CalculateContentBEnd(WritingMode aWM, nsIFrame* aFrame) { - NS_PRECONDITION(aFrame, "null ptr"); + MOZ_ASSERT(aFrame, "null ptr"); nscoord contentBEnd = aFrame->BSize(aWM); @@ -7836,7 +7837,7 @@ GetFontFacesForFramesInner(nsIFrame* aFrame, nsLayoutUtils::UsedFontFaceTable& aFontFaces, uint32_t aMaxRanges) { - NS_PRECONDITION(aFrame, "NULL frame pointer"); + MOZ_ASSERT(aFrame, "NULL frame pointer"); if (aFrame->IsTextFrame()) { if (!aFrame->GetPrevContinuation()) { @@ -7863,7 +7864,7 @@ nsLayoutUtils::GetFontFacesForFrames(nsIFrame* aFrame, UsedFontFaceTable& aFontFaces, uint32_t aMaxRanges) { - NS_PRECONDITION(aFrame, "NULL frame pointer"); + MOZ_ASSERT(aFrame, "NULL frame pointer"); while (aFrame) { GetFontFacesForFramesInner(aFrame, aFontFaces, aMaxRanges); @@ -7939,7 +7940,7 @@ nsLayoutUtils::GetFontFacesForText(nsIFrame* aFrame, UsedFontFaceTable& aFontFaces, uint32_t aMaxRanges) { - NS_PRECONDITION(aFrame, "NULL frame pointer"); + MOZ_ASSERT(aFrame, "NULL frame pointer"); if (!aFrame->IsTextFrame()) { return; @@ -7991,7 +7992,7 @@ nsLayoutUtils::SizeOfTextRunsForFrames(nsIFrame* aFrame, MallocSizeOf aMallocSizeOf, bool clear) { - NS_PRECONDITION(aFrame, "NULL frame pointer"); + MOZ_ASSERT(aFrame, "NULL frame pointer"); size_t total = 0; diff --git a/layout/base/nsPresContext.cpp b/layout/base/nsPresContext.cpp index 54a19a629c2f..305ae885a640 100644 --- a/layout/base/nsPresContext.cpp +++ b/layout/base/nsPresContext.cpp @@ -357,7 +357,7 @@ nsPresContext::Destroy() nsPresContext::~nsPresContext() { - NS_PRECONDITION(!mShell, "Presshell forgot to clear our mShell pointer"); + MOZ_ASSERT(!mShell, "Presshell forgot to clear our mShell pointer"); DetachShell(); Destroy(); @@ -2854,7 +2854,7 @@ nsPresContext::CheckForInterrupt(nsIFrame* aFrame) nsIFrame* nsPresContext::GetPrimaryFrameFor(nsIContent* aContent) { - NS_PRECONDITION(aContent, "Don't do that"); + MOZ_ASSERT(aContent, "Don't do that"); if (GetPresShell() && GetPresShell()->GetDocument() == aContent->GetComposedDoc()) { return aContent->GetPrimaryFrame(); diff --git a/layout/base/nsRefreshDriver.cpp b/layout/base/nsRefreshDriver.cpp index 1769e94f4f04..24024e015e2c 100644 --- a/layout/base/nsRefreshDriver.cpp +++ b/layout/base/nsRefreshDriver.cpp @@ -1511,10 +1511,10 @@ nsRefreshDriver::ArrayFor(FlushType aFlushType) void nsRefreshDriver::DoTick() { - NS_PRECONDITION(!IsFrozen(), "Why are we notified while frozen?"); - NS_PRECONDITION(mPresContext, "Why are we notified after disconnection?"); - NS_PRECONDITION(!nsContentUtils::GetCurrentJSContext(), - "Shouldn't have a JSContext on the stack"); + MOZ_ASSERT(!IsFrozen(), "Why are we notified while frozen?"); + MOZ_ASSERT(mPresContext, "Why are we notified after disconnection?"); + MOZ_ASSERT(!nsContentUtils::GetCurrentJSContext(), + "Shouldn't have a JSContext on the stack"); if (mTestControllingRefreshes) { Tick(mMostRecentRefreshEpochTime, mMostRecentRefresh); @@ -1782,8 +1782,8 @@ nsRefreshDriver::CancelIdleRunnable(nsIRunnable* aRunnable) void nsRefreshDriver::Tick(int64_t aNowEpoch, TimeStamp aNowTime) { - NS_PRECONDITION(!nsContentUtils::GetCurrentJSContext(), - "Shouldn't have a JSContext on the stack"); + MOZ_ASSERT(!nsContentUtils::GetCurrentJSContext(), + "Shouldn't have a JSContext on the stack"); if (nsNPAPIPluginInstance::InPluginCallUnsafeForReentry()) { NS_ERROR("Refresh driver should not run during plugin call!"); diff --git a/layout/base/nsStyleSheetService.cpp b/layout/base/nsStyleSheetService.cpp index 2debac212d5d..0e379477584a 100644 --- a/layout/base/nsStyleSheetService.cpp +++ b/layout/base/nsStyleSheetService.cpp @@ -246,7 +246,7 @@ nsStyleSheetService::SheetRegistered(nsIURI *sheetURI, aSheetType == USER_SHEET || aSheetType == AUTHOR_SHEET); NS_ENSURE_ARG_POINTER(sheetURI); - NS_PRECONDITION(_retval, "Null out param"); + MOZ_ASSERT(_retval, "Null out param"); // Check to see if we have the sheet. *_retval = (FindSheetByURI(aSheetType, sheetURI) >= 0); @@ -280,7 +280,7 @@ NS_IMETHODIMP nsStyleSheetService::PreloadSheet(nsIURI* aSheetURI, uint32_t aSheetType, nsIPreloadedStyleSheet** aSheet) { - NS_PRECONDITION(aSheet, "Null out param"); + MOZ_ASSERT(aSheet, "Null out param"); NS_ENSURE_ARG_POINTER(aSheetURI); css::SheetParsingMode parsingMode; diff --git a/layout/build/nsContentDLF.cpp b/layout/build/nsContentDLF.cpp index e879dab5dc3b..b0ed9ebb10dc 100644 --- a/layout/build/nsContentDLF.cpp +++ b/layout/build/nsContentDLF.cpp @@ -94,7 +94,7 @@ IsTypeInList(const nsACString& aType, const char* const aList[]) nsresult NS_NewContentDocumentLoaderFactory(nsIDocumentLoaderFactory** aResult) { - NS_PRECONDITION(aResult, "null OUT ptr"); + MOZ_ASSERT(aResult, "null OUT ptr"); if (!aResult) { return NS_ERROR_NULL_POINTER; } diff --git a/layout/build/nsLayoutModule.cpp b/layout/build/nsLayoutModule.cpp index 76f2e647aa8b..416cda00e9e6 100644 --- a/layout/build/nsLayoutModule.cpp +++ b/layout/build/nsLayoutModule.cpp @@ -285,7 +285,7 @@ Initialize() void Shutdown() { - NS_PRECONDITION(gInitialized, "module not initialized"); + MOZ_ASSERT(gInitialized, "module not initialized"); if (!gInitialized) return; diff --git a/layout/forms/nsComboboxControlFrame.cpp b/layout/forms/nsComboboxControlFrame.cpp index 9489749acfa7..8a55cc35f5f5 100644 --- a/layout/forms/nsComboboxControlFrame.cpp +++ b/layout/forms/nsComboboxControlFrame.cpp @@ -1061,7 +1061,7 @@ nsComboboxControlFrame::HandleRedisplayTextEvent() // Redirect frame insertions during this method (see GetContentInsertionFrame()) // so that any reframing that the frame constructor forces upon us is inserted // into the correct parent (mDisplayFrame). See bug 282607. - NS_PRECONDITION(!mInRedisplayText, "Nested RedisplayText"); + MOZ_ASSERT(!mInRedisplayText, "Nested RedisplayText"); mInRedisplayText = true; mRedisplayTextEvent.Forget(); diff --git a/layout/forms/nsFieldSetFrame.cpp b/layout/forms/nsFieldSetFrame.cpp index 9260c81c2d6a..b88319604534 100644 --- a/layout/forms/nsFieldSetFrame.cpp +++ b/layout/forms/nsFieldSetFrame.cpp @@ -365,8 +365,8 @@ nsFieldSetFrame::Reflow(nsPresContext* aPresContext, DO_GLOBAL_REFLOW_COUNT("nsFieldSetFrame"); DISPLAY_REFLOW(aPresContext, this, aReflowInput, aDesiredSize, aStatus); MOZ_ASSERT(aStatus.IsEmpty(), "Caller should pass a fresh reflow status!"); - NS_PRECONDITION(aReflowInput.ComputedISize() != NS_INTRINSICSIZE, - "Should have a precomputed inline-size!"); + MOZ_ASSERT(aReflowInput.ComputedISize() != NS_INTRINSICSIZE, + "Should have a precomputed inline-size!"); nsOverflowAreas ocBounds; nsReflowStatus ocStatus; @@ -706,4 +706,3 @@ nsFieldSetFrame::AppendDirectlyOwnedAnonBoxes(nsTArray& aResult) aResult.AppendElement(OwnedAnonBox(kid)); } } - diff --git a/layout/forms/nsListControlFrame.cpp b/layout/forms/nsListControlFrame.cpp index 79edd0a4e9d4..3e3410a1fce3 100644 --- a/layout/forms/nsListControlFrame.cpp +++ b/layout/forms/nsListControlFrame.cpp @@ -368,8 +368,8 @@ nsListControlFrame::Reflow(nsPresContext* aPresContext, nsReflowStatus& aStatus) { MOZ_ASSERT(aStatus.IsEmpty(), "Caller should pass a fresh reflow status!"); - NS_PRECONDITION(aReflowInput.ComputedISize() != NS_UNCONSTRAINEDSIZE, - "Must have a computed inline size"); + MOZ_ASSERT(aReflowInput.ComputedISize() != NS_UNCONSTRAINEDSIZE, + "Must have a computed inline size"); SchedulePaint(); @@ -503,8 +503,8 @@ nsListControlFrame::ReflowAsDropdown(nsPresContext* aPresContext, const ReflowInput& aReflowInput, nsReflowStatus& aStatus) { - NS_PRECONDITION(aReflowInput.ComputedBSize() == NS_UNCONSTRAINEDSIZE, - "We should not have a computed block size here!"); + MOZ_ASSERT(aReflowInput.ComputedBSize() == NS_UNCONSTRAINEDSIZE, + "We should not have a computed block size here!"); mMightNeedSecondPass = NS_SUBTREE_DIRTY(this) || aReflowInput.ShouldReflowAllKids(); @@ -1243,7 +1243,7 @@ DecrementAndClamp(int32_t aSelectionIndex, int32_t aLength) NS_IMETHODIMP nsListControlFrame::RemoveOption(int32_t aIndex) { - NS_PRECONDITION(aIndex >= 0, "negative