Bug 1521694 - Make DisplaySystemMenu() handle all nsSizeMode value r=jmathies
authorMasayuki Nakano <masayuki@d-toybox.com>
Fri, 25 Jan 2019 22:17:26 +0000
changeset 515531 3883a443b7f893bb8424c8a57ba376bbd1d3d275
parent 515530 bdf350144ce46d0e5ab7974ca365a034bec09457
child 515532 ad292914ca7eb4d20e9315dc50b1b79a1493a994
push id1953
push userffxbld-merge
push dateMon, 11 Mar 2019 12:10:20 +0000
treeherdermozilla-release@9c35dcbaa899 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjmathies
bugs1521694
milestone66.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
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
widget/windows/nsWindow.cpp
--- a/widget/windows/nsWindow.cpp
+++ b/widget/windows/nsWindow.cpp
@@ -4694,16 +4694,22 @@ static bool DisplaySystemMenu(HWND hWnd,
         SetMenuItemInfo(hMenu, SC_MAXIMIZE, FALSE, &mii);
         break;
       case nsSizeMode_Minimized:
         SetMenuItemInfo(hMenu, SC_MINIMIZE, FALSE, &mii);
         break;
       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,
         (TPM_LEFTBUTTON | TPM_RIGHTBUTTON | TPM_RETURNCMD | TPM_TOPALIGN |
          (isRtl ? TPM_RIGHTALIGN : TPM_LEFTALIGN)),
         x, y, 0, hWnd, nullptr);
     if (cmd) {
       PostMessage(hWnd, WM_SYSCOMMAND, cmd, 0);