Bug 419059 - contentAccess accesskeys for elements hidden with CSS don't work, r=neil, sr=roc, a=jst

This commit is contained in:
Olli Pettay 2008-12-30 16:09:14 +02:00
parent 594c36bac2
commit 7c4810ebbf
2 changed files with 16 additions and 8 deletions

View File

@ -143,7 +143,7 @@
#include "nsServiceManagerUtils.h" #include "nsServiceManagerUtils.h"
#include "nsITimer.h" #include "nsITimer.h"
#include "nsIFontMetrics.h" #include "nsIFontMetrics.h"
#include "nsIDOMXULDocument.h"
#include "nsIDragService.h" #include "nsIDragService.h"
#include "nsIDragSession.h" #include "nsIDragSession.h"
#include "nsDOMDataTransfer.h" #include "nsDOMDataTransfer.h"
@ -1545,10 +1545,17 @@ GetAccessModifierMask(nsISupports* aDocShell)
static PRBool static PRBool
IsAccessKeyTarget(nsIContent* aContent, nsIFrame* aFrame, nsAString& aKey) IsAccessKeyTarget(nsIContent* aContent, nsIFrame* aFrame, nsAString& aKey)
{ {
if (!aFrame) if (!aContent->AttrValueIs(kNameSpaceID_None, nsGkAtoms::accesskey, aKey,
eIgnoreCase))
return PR_FALSE; return PR_FALSE;
if (!aContent->AttrValueIs(kNameSpaceID_None, nsGkAtoms::accesskey, aKey, eIgnoreCase)) nsCOMPtr<nsIDOMXULDocument> 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; return PR_FALSE;
if (aFrame->IsFocusable()) if (aFrame->IsFocusable())
@ -1560,6 +1567,7 @@ IsAccessKeyTarget(nsIContent* aContent, nsIFrame* aFrame, nsAString& aKey)
if (!aFrame->AreAncestorViewsVisible()) if (!aFrame->AreAncestorViewsVisible())
return PR_FALSE; return PR_FALSE;
// XUL controls can be activated.
nsCOMPtr<nsIDOMXULControlElement> control(do_QueryInterface(aContent)); nsCOMPtr<nsIDOMXULControlElement> control(do_QueryInterface(aContent));
if (control) if (control)
return PR_TRUE; return PR_TRUE;

View File

@ -22,7 +22,7 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=409604
var modifier = Components.interfaces.nsIDOMNSEvent.ALT_MASK | var modifier = Components.interfaces.nsIDOMNSEvent.ALT_MASK |
Components.interfaces.nsIDOMNSEvent.SHIFT_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 // XXX the "map" test is causing trouble, see bug 433089
// var expectedClick = "a,b,c,e,f,i,j"; // var expectedClick = "a,b,c,e,f,i,j";
var expectedClick = "a,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) { function handleFocus(e) {
ok("accessKey" in e, "(focus) accesskey property not found on element"); ok("accessKey" in e, "(focus) accesskey property not found on element");
var expected = focusArray.shift(); var expected = focusArray.shift();
// "k" is a special case because the element receiving the focus is not // "k" and "n" are a special cases because the element receiving the focus
// the element which has the accesskey. // is not the element which has the accesskey.
if (expected == "k") { if (expected == "k" || expected == "n") {
ok(e.value == "test for label", "(focus) unexpected element: " + e.value + ok(e.value == "test for label", "(focus) unexpected element: " + e.value +
" expected: " + "test for label"); " expected: " + "test for label");
// "l" is a special case because the element receiving the focus is not // "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
</tr> </tr>
<tr> <tr>
<td>label (label invisible)</td><td><label for="txt1" accesskey="n" style="display:none">test label</label> <td>label (label invisible)</td><td><label for="txt1" accesskey="n" style="display:none">test label</label>
<input type="text" id="txt1" value="test for label" onfocus="handleInvalid(event.target);"></td> <input type="text" id="txt1" value="test for label" onfocus="handleFocus(event.target);"></td>
</tr> </tr>
<tr> <tr>
<td>label (control invisible)</td><td><label for="txt2" accesskey="o">test label</label> <td>label (control invisible)</td><td><label for="txt2" accesskey="o">test label</label>