Skip to content

Commit 71422dc

Browse files
committed
Bug 1457813 - Part 2: Replace non-asserting NS_PRECONDITIONs with MOZ_ASSERTs. r=froydnj
s/NS_PRECONDITION/MOZ_ASSERT/ and reindent MozReview-Commit-ID: KuUsnVe2h8L --HG-- extra : source : c14655ab3df2c9b1465dd8102b9d25683359a37b
1 parent d4cad70 commit 71422dc

File tree

292 files changed

+1627
-1642
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

292 files changed

+1627
-1642
lines changed

accessible/base/FocusManager.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -239,7 +239,7 @@ void
239239
FocusManager::DispatchFocusEvent(DocAccessible* aDocument,
240240
Accessible* aTarget)
241241
{
242-
NS_PRECONDITION(aDocument, "No document for focused accessible!");
242+
MOZ_ASSERT(aDocument, "No document for focused accessible!");
243243
if (aDocument) {
244244
RefPtr<AccEvent> event =
245245
new AccEvent(nsIAccessibleEvent::EVENT_FOCUS, aTarget,
@@ -292,8 +292,8 @@ FocusManager::ProcessDOMFocus(nsINode* aTarget)
292292
void
293293
FocusManager::ProcessFocusEvent(AccEvent* aEvent)
294294
{
295-
NS_PRECONDITION(aEvent->GetEventType() == nsIAccessibleEvent::EVENT_FOCUS,
296-
"Focus event is expected!");
295+
MOZ_ASSERT(aEvent->GetEventType() == nsIAccessibleEvent::EVENT_FOCUS,
296+
"Focus event is expected!");
297297

298298
// Emit focus event if event target is the active item. Otherwise then check
299299
// if it's still focused and then update active item and emit focus event.

accessible/base/TextAttrs.cpp

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -37,13 +37,13 @@ TextAttrsMgr::GetAttributes(nsIPersistentProperties* aAttributes,
3737
// 3. Offset accessible and result hyper text offsets must not be specified
3838
// but include default text attributes flag and attributes list must be
3939
// specified in the case of default text attributes.
40-
NS_PRECONDITION(mHyperTextAcc &&
41-
((mOffsetAcc && mOffsetAccIdx != -1 &&
42-
aStartOffset && aEndOffset) ||
43-
(!mOffsetAcc && mOffsetAccIdx == -1 &&
44-
!aStartOffset && !aEndOffset &&
45-
mIncludeDefAttrs && aAttributes)),
46-
"Wrong usage of TextAttrsMgr!");
40+
MOZ_ASSERT(mHyperTextAcc &&
41+
((mOffsetAcc && mOffsetAccIdx != -1 &&
42+
aStartOffset && aEndOffset) ||
43+
(!mOffsetAcc && mOffsetAccIdx == -1 &&
44+
!aStartOffset && !aEndOffset &&
45+
mIncludeDefAttrs && aAttributes)),
46+
"Wrong usage of TextAttrsMgr!");
4747

4848
// Embedded objects are combined into own range with empty attributes set.
4949
if (mOffsetAcc && !mOffsetAcc->IsText()) {

accessible/generic/Accessible.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2356,7 +2356,7 @@ Accessible::IsLink() const
23562356
uint32_t
23572357
Accessible::StartOffset()
23582358
{
2359-
NS_PRECONDITION(IsLink(), "StartOffset is called not on hyper link!");
2359+
MOZ_ASSERT(IsLink(), "StartOffset is called not on hyper link!");
23602360

23612361
HyperTextAccessible* hyperText = mParent ? mParent->AsHyperText() : nullptr;
23622362
return hyperText ? hyperText->GetChildOffset(this) : 0;
@@ -2365,7 +2365,7 @@ Accessible::StartOffset()
23652365
uint32_t
23662366
Accessible::EndOffset()
23672367
{
2368-
NS_PRECONDITION(IsLink(), "EndOffset is called on not hyper link!");
2368+
MOZ_ASSERT(IsLink(), "EndOffset is called on not hyper link!");
23692369

23702370
HyperTextAccessible* hyperText = mParent ? mParent->AsHyperText() : nullptr;
23712371
return hyperText ? (hyperText->GetChildOffset(this) + 1) : 0;
@@ -2374,21 +2374,21 @@ Accessible::EndOffset()
23742374
uint32_t
23752375
Accessible::AnchorCount()
23762376
{
2377-
NS_PRECONDITION(IsLink(), "AnchorCount is called on not hyper link!");
2377+
MOZ_ASSERT(IsLink(), "AnchorCount is called on not hyper link!");
23782378
return 1;
23792379
}
23802380

23812381
Accessible*
23822382
Accessible::AnchorAt(uint32_t aAnchorIndex)
23832383
{
2384-
NS_PRECONDITION(IsLink(), "GetAnchor is called on not hyper link!");
2384+
MOZ_ASSERT(IsLink(), "GetAnchor is called on not hyper link!");
23852385
return aAnchorIndex == 0 ? this : nullptr;
23862386
}
23872387

23882388
already_AddRefed<nsIURI>
23892389
Accessible::AnchorURIAt(uint32_t aAnchorIndex)
23902390
{
2391-
NS_PRECONDITION(IsLink(), "AnchorURIAt is called on not hyper link!");
2391+
MOZ_ASSERT(IsLink(), "AnchorURIAt is called on not hyper link!");
23922392
return nullptr;
23932393
}
23942394

accessible/generic/Accessible.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -743,7 +743,7 @@ class Accessible : public nsISupports
743743
*/
744744
inline bool IsLinkValid()
745745
{
746-
NS_PRECONDITION(IsLink(), "IsLinkValid is called on not hyper link!");
746+
MOZ_ASSERT(IsLink(), "IsLinkValid is called on not hyper link!");
747747

748748
// XXX In order to implement this we would need to follow every link
749749
// Perhaps we can get information about invalid links from the cache

accessible/mac/mozTextAccessible.mm

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
inline bool
1818
ToNSRange(id aValue, NSRange* aRange)
1919
{
20-
NS_PRECONDITION(aRange, "aRange is nil");
20+
MOZ_ASSERT(aRange, "aRange is nil");
2121

2222
if ([aValue isKindOfClass:[NSValue class]] &&
2323
strcmp([(NSValue*)aValue objCType], @encode(NSRange)) == 0) {
@@ -547,7 +547,7 @@ - (void)selectedTextDidChange
547547

548548
- (NSString*)stringFromRange:(NSRange*)range
549549
{
550-
NS_PRECONDITION(range, "no range");
550+
MOZ_ASSERT(range, "no range");
551551

552552
AccessibleWrap* accWrap = [self getGeckoAccessible];
553553
ProxyAccessible* proxy = [self getProxyAccessible];

accessible/xpcom/xpcAccessibleSelectable.cpp

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ xpcAccessibleSelectable::GetSelectedItems(nsIArray** aSelectedItems)
1919

2020
if (!Intl())
2121
return NS_ERROR_FAILURE;
22-
NS_PRECONDITION(Intl()->IsSelect(), "Called on non selectable widget!");
22+
MOZ_ASSERT(Intl()->IsSelect(), "Called on non selectable widget!");
2323

2424
AutoTArray<Accessible*, 10> items;
2525
Intl()->SelectedItems(&items);
@@ -48,7 +48,7 @@ xpcAccessibleSelectable::GetSelectedItemCount(uint32_t* aSelectionCount)
4848

4949
if (!Intl())
5050
return NS_ERROR_FAILURE;
51-
NS_PRECONDITION(Intl()->IsSelect(), "Called on non selectable widget!");
51+
MOZ_ASSERT(Intl()->IsSelect(), "Called on non selectable widget!");
5252

5353
*aSelectionCount = Intl()->SelectedItemCount();
5454
return NS_OK;
@@ -63,7 +63,7 @@ xpcAccessibleSelectable::GetSelectedItemAt(uint32_t aIndex,
6363

6464
if (!Intl())
6565
return NS_ERROR_FAILURE;
66-
NS_PRECONDITION(Intl()->IsSelect(), "Called on non selectable widget!");
66+
MOZ_ASSERT(Intl()->IsSelect(), "Called on non selectable widget!");
6767

6868
*aSelected = ToXPC(Intl()->GetSelectedItem(aIndex));
6969
if (*aSelected) {
@@ -82,7 +82,7 @@ xpcAccessibleSelectable::IsItemSelected(uint32_t aIndex, bool* aIsSelected)
8282

8383
if (!Intl())
8484
return NS_ERROR_FAILURE;
85-
NS_PRECONDITION(Intl()->IsSelect(), "Called on non selectable widget!");
85+
MOZ_ASSERT(Intl()->IsSelect(), "Called on non selectable widget!");
8686

8787
*aIsSelected = Intl()->IsItemSelected(aIndex);
8888
return NS_OK;
@@ -93,7 +93,7 @@ xpcAccessibleSelectable::AddItemToSelection(uint32_t aIndex)
9393
{
9494
if (!Intl())
9595
return NS_ERROR_FAILURE;
96-
NS_PRECONDITION(Intl()->IsSelect(), "Called on non selectable widget!");
96+
MOZ_ASSERT(Intl()->IsSelect(), "Called on non selectable widget!");
9797

9898
return Intl()->AddItemToSelection(aIndex) ? NS_OK : NS_ERROR_INVALID_ARG;
9999
}
@@ -103,7 +103,7 @@ xpcAccessibleSelectable::RemoveItemFromSelection(uint32_t aIndex)
103103
{
104104
if (!Intl())
105105
return NS_ERROR_FAILURE;
106-
NS_PRECONDITION(Intl()->IsSelect(), "Called on non selectable widget!");
106+
MOZ_ASSERT(Intl()->IsSelect(), "Called on non selectable widget!");
107107

108108
return Intl()->RemoveItemFromSelection(aIndex) ? NS_OK : NS_ERROR_INVALID_ARG;
109109
}
@@ -116,7 +116,7 @@ xpcAccessibleSelectable::SelectAll(bool* aIsMultiSelect)
116116

117117
if (!Intl())
118118
return NS_ERROR_FAILURE;
119-
NS_PRECONDITION(Intl()->IsSelect(), "Called on non selectable widget!");
119+
MOZ_ASSERT(Intl()->IsSelect(), "Called on non selectable widget!");
120120

121121
*aIsMultiSelect = Intl()->SelectAll();
122122
return NS_OK;
@@ -127,7 +127,7 @@ xpcAccessibleSelectable::UnselectAll()
127127
{
128128
if (!Intl())
129129
return NS_ERROR_FAILURE;
130-
NS_PRECONDITION(Intl()->IsSelect(), "Called on non selectable widget!");
130+
MOZ_ASSERT(Intl()->IsSelect(), "Called on non selectable widget!");
131131

132132
Intl()->UnselectAll();
133133
return NS_OK;

accessible/xul/XULTreeGridAccessible.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -371,7 +371,7 @@ XULTreeGridRowAccessible::ChildCount() const
371371
XULTreeGridCellAccessible*
372372
XULTreeGridRowAccessible::GetCellAccessible(nsITreeColumn* aColumn) const
373373
{
374-
NS_PRECONDITION(aColumn, "No tree column!");
374+
MOZ_ASSERT(aColumn, "No tree column!");
375375

376376
void* key = static_cast<void*>(aColumn);
377377
XULTreeGridCellAccessible* cachedCell = mAccessibleCache.GetWeak(key);

caps/ContentPrincipal.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -330,7 +330,7 @@ ContentPrincipal::MayLoadInternal(nsIURI* aURI)
330330
NS_IMETHODIMP
331331
ContentPrincipal::GetHashValue(uint32_t* aValue)
332332
{
333-
NS_PRECONDITION(mCodebase, "Need a codebase");
333+
MOZ_ASSERT(mCodebase, "Need a codebase");
334334

335335
*aValue = nsScriptSecurityManager::HashPrincipalByOrigin(this);
336336
return NS_OK;

caps/nsJSPrincipals.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ NS_IMETHODIMP_(MozExternalRefCountType)
2828
nsJSPrincipals::AddRef()
2929
{
3030
MOZ_ASSERT(NS_IsMainThread());
31-
NS_PRECONDITION(int32_t(refcount) >= 0, "illegal refcnt");
31+
MOZ_ASSERT(int32_t(refcount) >= 0, "illegal refcnt");
3232
nsrefcnt count = ++refcount;
3333
NS_LOG_ADDREF(this, count, "nsJSPrincipals", sizeof(*this));
3434
return count;
@@ -38,7 +38,7 @@ NS_IMETHODIMP_(MozExternalRefCountType)
3838
nsJSPrincipals::Release()
3939
{
4040
MOZ_ASSERT(NS_IsMainThread());
41-
NS_PRECONDITION(0 != refcount, "dup release");
41+
MOZ_ASSERT(0 != refcount, "dup release");
4242
nsrefcnt count = --refcount;
4343
NS_LOG_RELEASE(this, count, "nsJSPrincipals");
4444
if (count == 0) {

caps/nsScriptSecurityManager.cpp

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -260,7 +260,8 @@ nsScriptSecurityManager::GetChannelResultPrincipal(nsIChannel* aChannel,
260260
nsIPrincipal** aPrincipal,
261261
bool aIgnoreSandboxing)
262262
{
263-
NS_PRECONDITION(aChannel, "Must have channel!");
263+
MOZ_ASSERT(aChannel, "Must have channel!");
264+
264265
// Check whether we have an nsILoadInfo that says what we should do.
265266
nsCOMPtr<nsILoadInfo> loadInfo = aChannel->GetLoadInfo();
266267
if (loadInfo && loadInfo->GetForceInheritPrincipalOverruleOwner()) {
@@ -349,7 +350,7 @@ NS_IMETHODIMP
349350
nsScriptSecurityManager::GetChannelURIPrincipal(nsIChannel* aChannel,
350351
nsIPrincipal** aPrincipal)
351352
{
352-
NS_PRECONDITION(aChannel, "Must have channel!");
353+
MOZ_ASSERT(aChannel, "Must have channel!");
353354

354355
// Get the principal from the URI. Make sure this does the same thing
355356
// as nsDocument::Reset and XULDocument::StartDocumentLoad.
@@ -517,7 +518,7 @@ nsScriptSecurityManager::CheckLoadURIFromScript(JSContext *cx, nsIURI *aURI)
517518
static nsresult
518519
DenyAccessIfURIHasFlags(nsIURI* aURI, uint32_t aURIFlags)
519520
{
520-
NS_PRECONDITION(aURI, "Must have URI!");
521+
MOZ_ASSERT(aURI, "Must have URI!");
521522

522523
bool uriHasFlags;
523524
nsresult rv =
@@ -565,7 +566,8 @@ nsScriptSecurityManager::CheckLoadURIWithPrincipal(nsIPrincipal* aPrincipal,
565566
nsIURI *aTargetURI,
566567
uint32_t aFlags)
567568
{
568-
NS_PRECONDITION(aPrincipal, "CheckLoadURIWithPrincipal must have a principal");
569+
MOZ_ASSERT(aPrincipal, "CheckLoadURIWithPrincipal must have a principal");
570+
569571
// If someone passes a flag that we don't understand, we should
570572
// fail, because they may need a security check that we don't
571573
// provide.

0 commit comments

Comments
 (0)