Title: [188969] trunk/Tools
Revision
188969
Author
bfulg...@apple.com
Date
2015-08-26 10:33:49 -0700 (Wed, 26 Aug 2015)

Log Message

[Win] Simplify menu handling code in WinLauncher
https://bugs.webkit.org/show_bug.cgi?id=148461

Reviewed by Zalan Bujtas.

Revise 'ToggleMenuItem' to return a boolean value indicating if
it handled the message. Revise WndProc to use this to decide if it
should pass the message on to the default handler, rather than
duplicating the logic in both places.

* WinLauncher/Common.cpp:
(ToggleMenuItem): Return true if the menu item message was handled.
(WndProc): If 'ToggleMenuItem' did not handle the message, pass
the message tothe default handler.

Modified Paths

Diff

Modified: trunk/Tools/ChangeLog (188968 => 188969)


--- trunk/Tools/ChangeLog	2015-08-26 16:44:43 UTC (rev 188968)
+++ trunk/Tools/ChangeLog	2015-08-26 17:33:49 UTC (rev 188969)
@@ -1,3 +1,20 @@
+2015-08-26  Brent Fulgham  <bfulg...@apple.com>
+
+        [Win] Simplify menu handling code in WinLauncher
+        https://bugs.webkit.org/show_bug.cgi?id=148461
+
+        Reviewed by Zalan Bujtas.
+
+        Revise 'ToggleMenuItem' to return a boolean value indicating if
+        it handled the message. Revise WndProc to use this to decide if it
+        should pass the message on to the default handler, rather than
+        duplicating the logic in both places.
+        
+        * WinLauncher/Common.cpp:
+        (ToggleMenuItem): Return true if the menu item message was handled.
+        (WndProc): If 'ToggleMenuItem' did not handle the message, pass
+        the message tothe default handler.
+
 2015-08-26  Csaba Osztrogonác  <o...@webkit.org>
 
         Remove unused code after r188948

Modified: trunk/Tools/WinLauncher/Common.cpp (188968 => 188969)


--- trunk/Tools/WinLauncher/Common.cpp	2015-08-26 16:44:43 UTC (rev 188968)
+++ trunk/Tools/WinLauncher/Common.cpp	2015-08-26 17:33:49 UTC (rev 188969)
@@ -359,8 +359,11 @@
     }
 }
 
-static void ToggleMenuItem(HWND hWnd, UINT menuID)
+static bool ToggleMenuItem(HWND hWnd, UINT menuID)
 {
+    if (!gWinLauncher)
+        return false;
+
     HMENU menu = ::GetMenu(hWnd);
 
     MENUITEMINFO info;
@@ -369,12 +372,12 @@
     info.fMask = MIIM_STATE;
 
     if (!::GetMenuItemInfo(menu, menuID, FALSE, &info))
-        return;
+        return false;
 
     BOOL newState = !menuItemIsChecked(info);
 
     if (!gWinLauncher->standardPreferences() || !gWinLauncher->privatePreferences())
-        return;
+        return false;
 
     switch (menuID) {
     case IDM_AVFOUNDATION:
@@ -422,11 +425,15 @@
         // The actual user agent string will be set by the custom user agent dialog
         turnOffOtherUserAgents(menu);
         break;
+    default:
+        return false;
     }
 
     info.fState = (newState) ? MFS_CHECKED : MFS_UNCHECKED;
 
     ::SetMenuItemInfo(menu, menuID, FALSE, &info);
+
+    return true;
 }
 
 static const int dragBarHeight = 30;
@@ -487,26 +494,6 @@
             if (gWinLauncher)
                 gWinLauncher->navigateForwardOrBackward(hWnd, wmId);
             break;
-        case IDM_AVFOUNDATION:
-        case IDM_ACC_COMPOSITING:
-        case IDM_WK_FULLSCREEN:
-        case IDM_COMPOSITING_BORDERS:
-        case IDM_INVERT_COLORS:
-        case IDM_DISABLE_IMAGES:
-        case IDM_DISABLE_STYLES:
-        case IDM_DISABLE_JAVASCRIPT:
-        case IDM_DISABLE_LOCAL_FILE_RESTRICTIONS:
-        case IDM_UA_DEFAULT:
-        case IDM_UA_SAFARI_8_0:
-        case IDM_UA_SAFARI_IOS_8_IPHONE:
-        case IDM_UA_SAFARI_IOS_8_IPAD:
-        case IDM_UA_IE_11:
-        case IDM_UA_CHROME_MAC:
-        case IDM_UA_CHROME_WIN:
-        case IDM_UA_FIREFOX_MAC:
-        case IDM_UA_FIREFOX_WIN:
-            ToggleMenuItem(hWnd, wmId);
-            break;
         case IDM_UA_OTHER:
             if (wmEvent)
                 ToggleMenuItem(hWnd, wmId);
@@ -526,7 +513,8 @@
                 gWinLauncher->zoomOut();
             break;
         default:
-            return CallWindowProc(parentProc, hWnd, message, wParam, lParam);
+            if (!ToggleMenuItem(hWnd, wmId))
+                return CallWindowProc(parentProc, hWnd, message, wParam, lParam);
         }
         }
         break;
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to