<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[188969] trunk/Tools</title>
</head>
<body>

<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt;  }
#msg dl a { font-weight: bold}
#msg dl a:link    { color:#fc3; }
#msg dl a:active  { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg ul { text-indent: -1em; padding-left: 1em; }#logmsg ol { text-indent: -1.5em; padding-left: 1.5em; }
#logmsg > ul, #logmsg > ol { margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff  {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<dl class="meta">
<dt>Revision</dt> <dd><a href="http://trac.webkit.org/projects/webkit/changeset/188969">188969</a></dd>
<dt>Author</dt> <dd>bfulgham@apple.com</dd>
<dt>Date</dt> <dd>2015-08-26 10:33:49 -0700 (Wed, 26 Aug 2015)</dd>
</dl>

<h3>Log Message</h3>
<pre>[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.</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkToolsChangeLog">trunk/Tools/ChangeLog</a></li>
<li><a href="#trunkToolsWinLauncherCommoncpp">trunk/Tools/WinLauncher/Common.cpp</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkToolsChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Tools/ChangeLog (188968 => 188969)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Tools/ChangeLog        2015-08-26 16:44:43 UTC (rev 188968)
+++ trunk/Tools/ChangeLog        2015-08-26 17:33:49 UTC (rev 188969)
</span><span class="lines">@@ -1,3 +1,20 @@
</span><ins>+2015-08-26  Brent Fulgham  &lt;bfulgham@apple.com&gt;
+
+        [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.
+
</ins><span class="cx"> 2015-08-26  Csaba Osztrogonác  &lt;ossy@webkit.org&gt;
</span><span class="cx"> 
</span><span class="cx">         Remove unused code after r188948
</span></span></pre></div>
<a id="trunkToolsWinLauncherCommoncpp"></a>
<div class="modfile"><h4>Modified: trunk/Tools/WinLauncher/Common.cpp (188968 => 188969)</h4>
<pre class="diff"><span>
<span class="info">--- 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)
</span><span class="lines">@@ -359,8 +359,11 @@
</span><span class="cx">     }
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-static void ToggleMenuItem(HWND hWnd, UINT menuID)
</del><ins>+static bool ToggleMenuItem(HWND hWnd, UINT menuID)
</ins><span class="cx"> {
</span><ins>+    if (!gWinLauncher)
+        return false;
+
</ins><span class="cx">     HMENU menu = ::GetMenu(hWnd);
</span><span class="cx"> 
</span><span class="cx">     MENUITEMINFO info;
</span><span class="lines">@@ -369,12 +372,12 @@
</span><span class="cx">     info.fMask = MIIM_STATE;
</span><span class="cx"> 
</span><span class="cx">     if (!::GetMenuItemInfo(menu, menuID, FALSE, &amp;info))
</span><del>-        return;
</del><ins>+        return false;
</ins><span class="cx"> 
</span><span class="cx">     BOOL newState = !menuItemIsChecked(info);
</span><span class="cx"> 
</span><span class="cx">     if (!gWinLauncher-&gt;standardPreferences() || !gWinLauncher-&gt;privatePreferences())
</span><del>-        return;
</del><ins>+        return false;
</ins><span class="cx"> 
</span><span class="cx">     switch (menuID) {
</span><span class="cx">     case IDM_AVFOUNDATION:
</span><span class="lines">@@ -422,11 +425,15 @@
</span><span class="cx">         // The actual user agent string will be set by the custom user agent dialog
</span><span class="cx">         turnOffOtherUserAgents(menu);
</span><span class="cx">         break;
</span><ins>+    default:
+        return false;
</ins><span class="cx">     }
</span><span class="cx"> 
</span><span class="cx">     info.fState = (newState) ? MFS_CHECKED : MFS_UNCHECKED;
</span><span class="cx"> 
</span><span class="cx">     ::SetMenuItemInfo(menu, menuID, FALSE, &amp;info);
</span><ins>+
+    return true;
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> static const int dragBarHeight = 30;
</span><span class="lines">@@ -487,26 +494,6 @@
</span><span class="cx">             if (gWinLauncher)
</span><span class="cx">                 gWinLauncher-&gt;navigateForwardOrBackward(hWnd, wmId);
</span><span class="cx">             break;
</span><del>-        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;
</del><span class="cx">         case IDM_UA_OTHER:
</span><span class="cx">             if (wmEvent)
</span><span class="cx">                 ToggleMenuItem(hWnd, wmId);
</span><span class="lines">@@ -526,7 +513,8 @@
</span><span class="cx">                 gWinLauncher-&gt;zoomOut();
</span><span class="cx">             break;
</span><span class="cx">         default:
</span><del>-            return CallWindowProc(parentProc, hWnd, message, wParam, lParam);
</del><ins>+            if (!ToggleMenuItem(hWnd, wmId))
+                return CallWindowProc(parentProc, hWnd, message, wParam, lParam);
</ins><span class="cx">         }
</span><span class="cx">         }
</span><span class="cx">         break;
</span></span></pre>
</div>
</div>

</body>
</html>