UpdateIgnoreKeys no longer returns before calling SetIgnoreKeys on item. mIgnoreKeys seems to be changed for item, but keys are still taken as list navigation in Nightly.
draft
UpdateIgnoreKeys no longer returns before calling SetIgnoreKeys on item. mIgnoreKeys seems to be changed for item, but keys are still taken as list navigation in Nightly.
MozReview-Commit-ID: 54ivhyls7eN
--- a/layout/xul/nsXULPopupManager.cpp
+++ b/layout/xul/nsXULPopupManager.cpp
@@ -2606,22 +2606,20 @@ nsXULPopupManager::HandleEvent(nsIDOMEve
if (!trustedEvent) {
return NS_OK;
}
nsAutoString eventType;
aEvent->GetType(eventType);
if(eventType.EqualsLiteral("blur")){
- UpdateIgnoreKeys(false);
- return NS_OK;
+ return UpdateIgnoreKeys();
}
if(eventType.EqualsLiteral("focus")){
- UpdateIgnoreKeys(true);
- return NS_OK;
+ return UpdateIgnoreKeys();
}
nsCOMPtr<nsIDOMKeyEvent> keyEvent = do_QueryInterface(aEvent);
NS_ENSURE_TRUE(keyEvent, NS_ERROR_UNEXPECTED);
if (eventType.EqualsLiteral("keyup")) {
return KeyUp(keyEvent);
}
@@ -2633,63 +2631,59 @@ nsXULPopupManager::HandleEvent(nsIDOMEve
}
NS_ABORT();
return NS_OK;
}
nsresult
-nsXULPopupManager::UpdateIgnoreKeys(bool focus)
+nsXULPopupManager::UpdateIgnoreKeys()
{
/*
- nsMenuFrame* menuFrame = do_QueryFrame(GetTopVisibleMenu()->GetPrimaryFrame());
-
+ nsMenuFrame* menuFrame = do_QueryFrame(mMenu->GetPrimaryFrame());
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){
+
+ /*
+ nsIContent* aPopup = item->Frame()->GetContent();
+
+ nsAutoString ignorekeys;
+ aPopup->GetAttr(kNameSpaceID_None, nsGkAtoms::ignorekeys, ignorekeys);
+
+ if (ignorekeys.EqualsLiteral("true")) {
+ */
+ if (item->IgnoreKeys() == eIgnoreKeys_Handled) {
+ item->SetIgnoreKeys(eIgnoreKeys_True);
+ }
+ if (item->IgnoreKeys() == eIgnoreKeys_True) {
+ item->SetIgnoreKeys(eIgnoreKeys_True);
+ }
+ /*
+ } else if (ignorekeys.EqualsLiteral("handled")) {
+ item->SetIgnoreKeys(eIgnoreKeys_Handled);
+ }
+ else {
+ item->SetIgnoreKeys(eIgnoreKeys_False);
+ }
+ */
}
- 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")) {
-
- 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)
{
// don't do anything if a menu isn't open or a menubar isn't active
if (!mActiveMenuBar) {
--- 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(bool focus);
+ nsresult UpdateIgnoreKeys();
nsresult KeyUp(nsIDOMKeyEvent* aKeyEvent);
nsresult KeyDown(nsIDOMKeyEvent* aKeyEvent);
nsresult KeyPress(nsIDOMKeyEvent* aKeyEvent);
protected:
nsXULPopupManager();
~nsXULPopupManager();