Bug 1521694 - Make DisplaySystemMenu() handle all nsSizeMode value r=jmathies

DisplaySystemMenu() does not handle nsSizeMode_Invalid that causes warning of
clang.  This patch makes it treat nsSizeMode_Invalid.  When it receives the
value, it will call NS_ASSERTION() to be detectable on debug builds during
automated tests.

Additionally, this adds default case into the switch statement with
MOZ_ASSERT_UNREACHABLE().  Then, when somebody adds new nsSizeMode, they
can detect it with crash in debug build if they forget to change this method.

Differential Revision: https://phabricator.services.mozilla.com/D17217

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Masayuki Nakano 2019-01-25 22:17:26 +00:00
parent e8d2d0ebb7
commit 95b953d536

View File

@ -4699,6 +4699,12 @@ static bool DisplaySystemMenu(HWND hWnd, nsSizeMode sizeMode, bool isRtl,
case nsSizeMode_Normal:
SetMenuItemInfo(hMenu, SC_RESTORE, FALSE, &mii);
break;
case nsSizeMode_Invalid:
NS_ASSERTION(false, "Did the argument come from invalid IPC?");
break;
default:
MOZ_ASSERT_UNREACHABLE("Unhnalded nsSizeMode value detected");
break;
}
LPARAM cmd = TrackPopupMenu(
hMenu,