Bug 1154183 part.3 Clean up some variable names in nsXBLWindowKeyHandler::WalkHandlersAndExecute() r=smaug
authorMasayuki Nakano <masayuki@d-toybox.com>
Fri, 18 Mar 2016 11:25:08 +0900
changeset 290008 024017da65648b6393ddf01126139bd7cb1b172d
parent 290007 b6bf385a7c2a84e72ce0caab657c082625381045
child 290009 6c650c359c8e65904805108b1996a56f08c2a372
push id19656
push usergwagner@mozilla.com
push dateMon, 04 Apr 2016 13:43:23 +0000
treeherderb2g-inbound@e99061fde28a [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerssmaug
bugs1154183
milestone48.0a1
Bug 1154183 part.3 Clean up some variable names in nsXBLWindowKeyHandler::WalkHandlersAndExecute() r=smaug MozReview-Commit-ID: 17fCUBwFf92
dom/xbl/nsXBLWindowKeyHandler.cpp
--- a/dom/xbl/nsXBLWindowKeyHandler.cpp
+++ b/dom/xbl/nsXBLWindowKeyHandler.cpp
@@ -568,120 +568,121 @@ nsXBLWindowKeyHandler::WalkHandlersInter
   }
   return false;
 }
 
 bool
 nsXBLWindowKeyHandler::WalkHandlersAndExecute(
                          nsIDOMKeyEvent* aKeyEvent,
                          nsIAtom* aEventType,
-                         nsXBLPrototypeHandler* aHandler,
+                         nsXBLPrototypeHandler* aFirstHandler,
                          uint32_t aCharCode,
                          const IgnoreModifierState& aIgnoreModifierState,
                          bool aExecute,
                          bool* aOutReservedForChrome)
 {
-  nsresult rv;
-
   // Try all of the handlers until we find one that matches the event.
-  for (nsXBLPrototypeHandler *currHandler = aHandler; currHandler;
-       currHandler = currHandler->GetNextHandler()) {
+  for (nsXBLPrototypeHandler* handler = aFirstHandler;
+       handler;
+       handler = handler->GetNextHandler()) {
     bool stopped = aKeyEvent->AsEvent()->IsDispatchStopped();
     if (stopped) {
       // The event is finished, don't execute any more handlers
       return false;
     }
 
-    if (!EventMatched(currHandler, aEventType, aKeyEvent,
+    if (!EventMatched(handler, aEventType, aKeyEvent,
                       aCharCode, aIgnoreModifierState)) {
       continue;  // try the next one
     }
 
     // Before executing this handler, check that it's not disabled,
     // and that it has something to do (oncommand of the <key> or its
     // <command> is non-empty).
-    nsCOMPtr<nsIContent> elt = currHandler->GetHandlerElement();
-    nsCOMPtr<Element> commandElt;
+    nsCOMPtr<nsIContent> keyContent = handler->GetHandlerElement();
+    nsCOMPtr<Element> commandElement;
 
     // See if we're in a XUL doc.
-    nsCOMPtr<Element> el = GetElement();
-    if (el && elt) {
+    nsCOMPtr<Element> chromeHandlerElement = GetElement();
+    if (chromeHandlerElement && keyContent) {
       // We are.  Obtain our command attribute.
       nsAutoString command;
-      elt->GetAttr(kNameSpaceID_None, nsGkAtoms::command, command);
+      keyContent->GetAttr(kNameSpaceID_None, nsGkAtoms::command, command);
       if (!command.IsEmpty()) {
         // Locate the command element in question.  Note that we
-        // know "elt" is in a doc if we're dealing with it here.
-        NS_ASSERTION(elt->IsInDoc(), "elt must be in document");
-        nsIDocument *doc = elt->GetCurrentDoc();
-        if (doc)
-          commandElt = do_QueryInterface(doc->GetElementById(command));
+        // know "keyContent" is in a doc if we're dealing with it here.
+        NS_ASSERTION(keyContent->IsInDoc(),
+                     "the key element must be in document");
+        nsIDocument* doc = keyContent->GetCurrentDoc();
+        if (doc) {
+          commandElement = do_QueryInterface(doc->GetElementById(command));
+        }
 
-        if (!commandElt) {
-          NS_ERROR("A XUL <key> is observing a command that doesn't exist. Unable to execute key binding!");
+        if (!commandElement) {
+          NS_ERROR("A XUL <key> is observing a command that doesn't exist. "
+                   "Unable to execute key binding!");
           continue;
         }
       }
     }
 
-    if (!commandElt) {
-      commandElt = do_QueryInterface(elt);
+    if (!commandElement) {
+      commandElement = do_QueryInterface(keyContent);
     }
 
-    if (commandElt) {
+    if (commandElement) {
       nsAutoString value;
-      commandElt->GetAttribute(NS_LITERAL_STRING("disabled"), value);
+      commandElement->GetAttribute(NS_LITERAL_STRING("disabled"), value);
       if (value.EqualsLiteral("true")) {
         continue;  // this handler is disabled, try the next one
       }
 
       // Check that there is an oncommand handler
-      commandElt->GetAttribute(NS_LITERAL_STRING("oncommand"), value);
+      commandElement->GetAttribute(NS_LITERAL_STRING("oncommand"), value);
       if (value.IsEmpty()) {
         continue;  // nothing to do
       }
 
       if (aOutReservedForChrome) {
         // The caller wants to know if this is a reserved command
-        commandElt->GetAttribute(NS_LITERAL_STRING("reserved"), value);
+        commandElement->GetAttribute(NS_LITERAL_STRING("reserved"), value);
         *aOutReservedForChrome = value.EqualsLiteral("true");
       }
     }
 
-    nsCOMPtr<EventTarget> piTarget;
-    nsCOMPtr<Element> element = GetElement();
-    if (element) {
-      piTarget = commandElt;
-    } else {
-      piTarget = mTarget;
-    }
-
     if (!aExecute) {
       return true;
     }
 
-    rv = currHandler->ExecuteHandler(piTarget, aKeyEvent->AsEvent());
+    nsCOMPtr<EventTarget> target;
+    if (chromeHandlerElement) {
+      target = commandElement;
+    } else {
+      target = mTarget;
+    }
+
+    nsresult rv = handler->ExecuteHandler(target, aKeyEvent->AsEvent());
     if (NS_SUCCEEDED(rv)) {
       return true;
     }
   }
 
 #ifdef XP_WIN
   // Windows native applications ignore Windows-Logo key state when checking
   // shortcut keys even if the key is pressed.  Therefore, if there is no
   // shortcut key which exactly matches current modifier state, we should
   // retry to look for a shortcut key without the Windows-Logo key press.
   if (!aIgnoreModifierState.mOS) {
     WidgetKeyboardEvent* keyEvent =
       aKeyEvent->AsEvent()->WidgetEventPtr()->AsKeyboardEvent();
     if (keyEvent && keyEvent->IsOS()) {
       IgnoreModifierState ignoreModifierState(aIgnoreModifierState);
       ignoreModifierState.mOS = true;
-      return WalkHandlersAndExecute(aKeyEvent, aEventType, aHandler, aCharCode,
-                                    ignoreModifierState, aExecute);
+      return WalkHandlersAndExecute(aKeyEvent, aEventType, aFirstHandler,
+                                    aCharCode, ignoreModifierState, aExecute);
     }
   }
 #endif
 
   return false;
 }
 
 bool