Bug 1179451 - Part 1: Rewrite some ternary operators as if/else. r=froydnj

This commit is contained in:
Aryeh Gregor 2015-08-13 15:22:48 +03:00
parent b77e18ed9a
commit a0d8e26be1
15 changed files with 71 additions and 18 deletions

View File

@ -396,7 +396,10 @@ SingleAccIterator::Next()
{
nsRefPtr<Accessible> nextAcc;
mAcc.swap(nextAcc);
return (nextAcc && !nextAcc->IsDefunct()) ? nextAcc : nullptr;
if (!nextAcc || nextAcc->IsDefunct()) {
return nullptr;
}
return nextAcc;
}

View File

@ -486,7 +486,10 @@ HTMLTextFieldAccessible::IsWidget() const
Accessible*
HTMLTextFieldAccessible::ContainerWidget() const
{
return mParent && mParent->Role() == roles::AUTOCOMPLETE ? mParent : nullptr;
if (!mParent || mParent->Role() != roles::AUTOCOMPLETE) {
return nullptr;
}
return mParent;
}

View File

@ -4338,7 +4338,10 @@ nsDocShell::GetDocument()
nsPIDOMWindow*
nsDocShell::GetWindow()
{
return NS_SUCCEEDED(EnsureScriptEnvironment()) ? mScriptGlobal : nullptr;
if (NS_FAILED(EnsureScriptEnvironment())) {
return nullptr;
}
return mScriptGlobal;
}
NS_IMETHODIMP

View File

@ -84,7 +84,10 @@ public:
File* IndexedGetter(uint32_t aIndex, bool& aFound)
{
aFound = aIndex < mFiles.Length();
return aFound ? mFiles.ElementAt(aIndex) : nullptr;
if (!aFound) {
return nullptr;
}
return mFiles.ElementAt(aIndex);
}
uint32_t Length()

View File

@ -696,7 +696,10 @@ ShadowRoot *
nsGenericDOMDataNode::GetContainingShadow() const
{
nsDataSlots *slots = GetExistingDataSlots();
return slots ? slots->mContainingShadow : nullptr;
if (!slots) {
return nullptr;
}
return slots->mContainingShadow;
}
void

View File

@ -264,8 +264,10 @@ nsMimeType::GetDescription(nsString& aRetval) const
nsPluginElement*
nsMimeType::GetEnabledPlugin() const
{
return (mPluginElement && mPluginElement->PluginTag()->IsEnabled()) ?
mPluginElement : nullptr;
if (!mPluginElement || !mPluginElement->PluginTag()->IsEnabled()) {
return nullptr;
}
return mPluginElement;
}
void

View File

@ -175,7 +175,11 @@ nsPluginArray::IndexedGetter(uint32_t aIndex, bool &aFound)
aFound = aIndex < mPlugins.Length();
return aFound ? mPlugins[aIndex] : nullptr;
if (!aFound) {
return nullptr;
}
return mPlugins[aIndex];
}
void
@ -391,7 +395,11 @@ nsPluginElement::IndexedGetter(uint32_t aIndex, bool &aFound)
aFound = aIndex < mMimeTypes.Length();
return aFound ? mMimeTypes[aIndex] : nullptr;
if (!aFound) {
return nullptr;
}
return mMimeTypes[aIndex];
}
nsMimeType*

View File

@ -137,7 +137,10 @@ BluetoothManager::DisconnectFromOwner()
BluetoothAdapter*
BluetoothManager::GetDefaultAdapter()
{
return DefaultAdapterExists() ? mAdapters[mDefaultAdapterIndex] : nullptr;
if (!DefaultAdapterExists()) {
return nullptr;
}
return mAdapters[mDefaultAdapterIndex];
}
void

View File

@ -89,7 +89,10 @@ public:
PaintRequest* IndexedGetter(uint32_t aIndex, bool& aFound)
{
aFound = aIndex < mArray.Length();
return aFound ? mArray.ElementAt(aIndex) : nullptr;
if (!aFound) {
return nullptr;
}
return mArray.ElementAt(aIndex);
}
private:

View File

@ -689,7 +689,10 @@ TextComposition*
TextCompositionArray::GetCompositionFor(nsIWidget* aWidget)
{
index_type i = IndexOf(aWidget);
return i != NoIndex ? ElementAt(i) : nullptr;
if (i == NoIndex) {
return nullptr;
}
return ElementAt(i);
}
TextComposition*
@ -697,7 +700,10 @@ TextCompositionArray::GetCompositionFor(nsPresContext* aPresContext,
nsINode* aNode)
{
index_type i = IndexOf(aPresContext, aNode);
return i != NoIndex ? ElementAt(i) : nullptr;
if (i == NoIndex) {
return nullptr;
}
return ElementAt(i);
}
TextComposition*

View File

@ -74,7 +74,10 @@ MediaTrack*
MediaTrackList::IndexedGetter(uint32_t aIndex, bool& aFound)
{
aFound = aIndex < mTracks.Length();
return aFound ? mTracks[aIndex] : nullptr;
if (!aFound) {
return nullptr;
}
return mTracks[aIndex];
}
MediaTrack*

View File

@ -50,7 +50,10 @@ TextTrackCue*
TextTrackCueList::IndexedGetter(uint32_t aIndex, bool& aFound)
{
aFound = aIndex < mList.Length();
return aFound ? mList[aIndex] : nullptr;
if (!aFound) {
return nullptr;
}
return mList[aIndex];
}
TextTrackCue*

View File

@ -69,7 +69,10 @@ TextTrack*
TextTrackList::IndexedGetter(uint32_t aIndex, bool& aFound)
{
aFound = aIndex < mTextTracks.Length();
return aFound ? mTextTracks[aIndex] : nullptr;
if (!aFound) {
return nullptr;
}
return mTextTracks[aIndex];
}
TextTrack*

View File

@ -38,7 +38,11 @@ SourceBufferList::IndexedGetter(uint32_t aIndex, bool& aFound)
{
MOZ_ASSERT(NS_IsMainThread());
aFound = aIndex < mSourceBuffers.Length();
return aFound ? mSourceBuffers[aIndex] : nullptr;
if (!aFound) {
return nullptr;
}
return mSourceBuffers[aIndex];
}
uint32_t

View File

@ -873,7 +873,10 @@ nsRangeFrame::GetAdditionalStyleContext(int32_t aIndex) const
// We only implement this so that SetAdditionalStyleContext will be
// called if style changes that would change the -moz-focus-outer
// pseudo-element have occurred.
return aIndex == 0 ? mOuterFocusStyle : nullptr;
if (aIndex != 0) {
return nullptr;
}
return mOuterFocusStyle;
}
void