diff --git a/content/events/src/nsEventStateManager.cpp b/content/events/src/nsEventStateManager.cpp index 63d469210f63..be59679cc355 100644 --- a/content/events/src/nsEventStateManager.cpp +++ b/content/events/src/nsEventStateManager.cpp @@ -143,7 +143,7 @@ #include "nsServiceManagerUtils.h" #include "nsITimer.h" #include "nsIFontMetrics.h" - +#include "nsIDOMXULDocument.h" #include "nsIDragService.h" #include "nsIDragSession.h" #include "nsDOMDataTransfer.h" @@ -1545,10 +1545,17 @@ GetAccessModifierMask(nsISupports* aDocShell) static PRBool IsAccessKeyTarget(nsIContent* aContent, nsIFrame* aFrame, nsAString& aKey) { - if (!aFrame) + if (!aContent->AttrValueIs(kNameSpaceID_None, nsGkAtoms::accesskey, aKey, + eIgnoreCase)) return PR_FALSE; - if (!aContent->AttrValueIs(kNameSpaceID_None, nsGkAtoms::accesskey, aKey, eIgnoreCase)) + nsCOMPtr xulDoc = + do_QueryInterface(aContent->GetOwnerDoc()); + if (!xulDoc && !aContent->IsNodeOfType(nsINode::eXUL)) + return PR_TRUE; + + // For XUL we do visibility checks. + if (!aFrame) return PR_FALSE; if (aFrame->IsFocusable()) @@ -1560,6 +1567,7 @@ IsAccessKeyTarget(nsIContent* aContent, nsIFrame* aFrame, nsAString& aKey) if (!aFrame->AreAncestorViewsVisible()) return PR_FALSE; + // XUL controls can be activated. nsCOMPtr control(do_QueryInterface(aContent)); if (control) return PR_TRUE; diff --git a/content/events/test/test_bug409604.html b/content/events/test/test_bug409604.html index 8c365f4a0e54..3a94830919d2 100644 --- a/content/events/test/test_bug409604.html +++ b/content/events/test/test_bug409604.html @@ -22,7 +22,7 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=409604 var modifier = Components.interfaces.nsIDOMNSEvent.ALT_MASK | Components.interfaces.nsIDOMNSEvent.SHIFT_MASK; - var expectedFocus = "d,g,h,k,l,m"; + var expectedFocus = "d,g,h,k,l,m,n"; // XXX the "map" test is causing trouble, see bug 433089 // var expectedClick = "a,b,c,e,f,i,j"; var expectedClick = "a,c,e,f,i,j"; @@ -115,9 +115,9 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=409604 function handleFocus(e) { ok("accessKey" in e, "(focus) accesskey property not found on element"); var expected = focusArray.shift(); - // "k" is a special case because the element receiving the focus is not - // the element which has the accesskey. - if (expected == "k") { + // "k" and "n" are a special cases because the element receiving the focus + // is not the element which has the accesskey. + if (expected == "k" || expected == "n") { ok(e.value == "test for label", "(focus) unexpected element: " + e.value + " expected: " + "test for label"); // "l" is a special case because the element receiving the focus is not @@ -312,7 +312,7 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=409604 label (label invisible) - + label (control invisible)