Listeners being installed in nsXULPopupManager, UpdateIgnoreKeys being called on focus event. Updated to pass bool for focus state, in order to decide whether ignorekeys should be true or false. item not being set correctly in UpdateIgnoreKeys? draft
authorTylerM <maklebus@msu.edu>
Fri, 07 Oct 2016 12:38:32 -0400
changeset 424926 46e6794eaee52e387327e53841fef7c6bfaab56b
parent 424925 3ce9cd2afc0feec705b0b966b13f1c3796e1532b
child 424927 6b66efa9a0eeac155ff1fcb0c4ce9a641a0d91a8
push id32293
push userbmo:maklebus@msu.edu
push dateThu, 13 Oct 2016 20:34:31 +0000
milestone52.0a1
Listeners being installed in nsXULPopupManager, UpdateIgnoreKeys being called on focus event. Updated to pass bool for focus state, in order to decide whether ignorekeys should be true or false. item not being set correctly in UpdateIgnoreKeys? MozReview-Commit-ID: 2yd5bq4VWaZ
layout/xul/nsXULPopupManager.cpp
layout/xul/nsXULPopupManager.h
--- a/layout/xul/nsXULPopupManager.cpp
+++ b/layout/xul/nsXULPopupManager.cpp
@@ -914,18 +914,16 @@ nsXULPopupManager::ShowPopupCallback(nsI
   nsAutoString ignorekeys;
   aPopup->GetAttr(kNameSpaceID_None, nsGkAtoms::ignorekeys, ignorekeys);
   if (ignorekeys.EqualsLiteral("true")) {
     item->SetIgnoreKeys(eIgnoreKeys_True);
   } else if (ignorekeys.EqualsLiteral("handled")) {
     item->SetIgnoreKeys(eIgnoreKeys_Handled);
   }
 
-  UpdateSearchListeners();
-
   if (ismenu) {
     // if the menu is on a menubar, use the menubar's listener instead
     nsMenuFrame* menuFrame = do_QueryFrame(aPopupFrame->GetParent());
     if (menuFrame) {
       item->SetOnMenuBar(menuFrame->IsOnMenuBar());
     }
   }
 
@@ -957,16 +955,18 @@ nsXULPopupManager::ShowPopupCallback(nsI
   }
 
   if (ismenu)
     UpdateMenuItems(aPopup);
 
   // Caret visibility may have been affected, ensure that
   // the caret isn't now drawn when it shouldn't be.
   CheckCaretDrawingState();
+
+  UpdateSearchListeners();
 }
 
 void
 nsXULPopupManager::HidePopup(nsIContent* aPopup,
                              bool aHideChain,
                              bool aDeselectMenu,
                              bool aAsynchronous,
                              bool aIsCancel,
@@ -2595,86 +2595,99 @@ nsXULPopupManager::IsValidMenuItem(nsICo
   return !(skipNavigatingDisabledMenuItem &&
            aContent->AttrValueIs(kNameSpaceID_None, nsGkAtoms::disabled,
                                  nsGkAtoms::_true, eCaseMatters));
 }
 
 nsresult
 nsXULPopupManager::HandleEvent(nsIDOMEvent* aEvent)
 {
+	//handlers shouldn't be triggered by non-trusted events.
+	bool trustedEvent = false;
+	aEvent->GetIsTrusted(&trustedEvent);
+	if (!trustedEvent) {
+		return NS_OK;
+	}
+
+	nsAutoString eventType;
+	aEvent->GetType(eventType);
+
+	if(eventType.EqualsLiteral("blur")){
+		UpdateIgnoreKeys(false);
+		return NS_OK;
+	}
+	if(eventType.EqualsLiteral("focus")){
+		UpdateIgnoreKeys(true);
+		return NS_OK;
+	}
+
   nsCOMPtr<nsIDOMKeyEvent> keyEvent = do_QueryInterface(aEvent);
   NS_ENSURE_TRUE(keyEvent, NS_ERROR_UNEXPECTED);
 
-  //handlers shouldn't be triggered by non-trusted events.
-  bool trustedEvent = false;
-  aEvent->GetIsTrusted(&trustedEvent);
-  if (!trustedEvent) {
-    return NS_OK;
-  }
-
-  nsAutoString eventType;
-  aEvent->GetType(eventType);
-
-  if (eventType.EqualsLiteral("blur") || eventType.EqualsLiteral("focus")) {
-    return UpdateIgnoreKeys();
-  }
   if (eventType.EqualsLiteral("keyup")) {
     return KeyUp(keyEvent);
   }
   if (eventType.EqualsLiteral("keydown")) {
     return KeyDown(keyEvent);
   }
   if (eventType.EqualsLiteral("keypress")) {
     return KeyPress(keyEvent);
   }
 
   NS_ABORT();
 
   return NS_OK;
 }
 
 nsresult
-nsXULPopupManager::UpdateIgnoreKeys()
+nsXULPopupManager::UpdateIgnoreKeys(bool focus)
 {
-  // TODO update ignore keys here
-
-
   /*
   nsMenuFrame* menuFrame = do_QueryFrame(GetTopVisibleMenu()->GetPrimaryFrame());
 
-  // Find the popup that the menu is inside. Below, this popup will
-  // need to be hidden.
   nsIFrame* frame = menuFrame->GetParent();
   while (frame) {
     nsMenuPopupFrame* popupFrame = do_QueryFrame(frame);
     if (popupFrame) {
       aPopup = popupFrame->GetContent();
       break;
     }
     frame = frame->GetParent();
   }
   */
 
   nsMenuChainItem* item = GetTopVisibleMenu();
-  if (!item)
-    return NS_OK;
+
+  if (!item) {
+	  return NS_OK;
+  }
 
   nsIContent* aPopup = item->Frame()->GetContent();
 
   // install keyboard event listeners for navigating menus. For panels, the
   // escape key may be used to close the panel. However, the ignorekeys
   // attribute may be used to disable adding these event listeners for popups
   // that want to handle their own keyboard events.
-  nsAutoString ignorekeys;
-  aPopup->GetAttr(kNameSpaceID_None, nsGkAtoms::ignorekeys, ignorekeys);
-  if (ignorekeys.EqualsLiteral("true")) {
-    item->SetIgnoreKeys(eIgnoreKeys_True);
+
+  //nsAutoString ignorekeys;
+  //aPopup->GetAttr(kNameSpaceID_None, nsGkAtoms::ignorekeys, ignorekeys);
+
+  //if (ignorekeys.EqualsLiteral("true")) {
+
+  if (focus) {
+	  item->SetIgnoreKeys(eIgnoreKeys_True);
+  } else {
+	  item->SetIgnoreKeys(eIgnoreKeys_False);
+  }
+
+	/*
   } else if (ignorekeys.EqualsLiteral("handled")) {
     item->SetIgnoreKeys(eIgnoreKeys_Handled);
   }
+  */
 
 
   return NS_OK;
 }
 
 nsresult
 nsXULPopupManager::KeyUp(nsIDOMKeyEvent* aKeyEvent)
 {
--- a/layout/xul/nsXULPopupManager.h
+++ b/layout/xul/nsXULPopupManager.h
@@ -655,17 +655,17 @@ public:
 
   /**
    * Handles the keyboard event with keyCode value. Returns true if the event
    * has been handled.
    */
   bool HandleKeyboardEventWithKeyCode(nsIDOMKeyEvent* aKeyEvent,
                                       nsMenuChainItem* aTopVisibleMenuItem);
 
-  nsresult UpdateIgnoreKeys();
+  nsresult UpdateIgnoreKeys(bool focus);
   nsresult KeyUp(nsIDOMKeyEvent* aKeyEvent);
   nsresult KeyDown(nsIDOMKeyEvent* aKeyEvent);
   nsresult KeyPress(nsIDOMKeyEvent* aKeyEvent);
 
 protected:
   nsXULPopupManager();
   ~nsXULPopupManager();