Bug 409604: Accesskeys on HTML label, area and legend elements don't work, patch by Ehsan Akhgari <ehsan.akhgari@gmail.com>, r+sr=roc, a=schrep
authorgavin@gavinsharp.com
Thu, 08 May 2008 13:00:24 -0700
changeset 15065 d109091bcb3e03f1407ea88e3c87173f2f0ac0b8
parent 15064 fea673f8d51dc5fe67213e8a29ba7e728e2f23ae
child 15066 fefe9f963eb49e8e35745c794fa0818ce1148149
push idunknown
push userunknown
push dateunknown
reviewersschrep
bugs409604
milestone1.9pre
Bug 409604: Accesskeys on HTML label, area and legend elements don't work, patch by Ehsan Akhgari <ehsan.akhgari@gmail.com>, r+sr=roc, a=schrep
content/events/src/nsEventStateManager.cpp
content/events/test/Makefile.in
--- a/content/events/src/nsEventStateManager.cpp
+++ b/content/events/src/nsEventStateManager.cpp
@@ -22,16 +22,17 @@
  *
  * Contributor(s):
  *   Makoto Kato  <m_kato@ga2.so-net.ne.jp>
  *   Dean Tessman <dean_tessman@hotmail.com>
  *   Mats Palmgren <mats.palmgren@bredband.net>
  *   Masayuki Nakano <masayuki@d-toybox.com>
  *   Ginn Chen <ginn.chen@sun.com>
  *   Simon B├╝nzli <zeniko@gmail.com>
+ *   Ehsan Akhgari <ehsan.akhgari@gmail.com>
  *
  * Alternatively, the contents of this file may be used under the terms of
  * either of the GNU General Public License Version 2 or later (the "GPL"),
  * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
  * in which case the provisions of the GPL or the LGPL are applicable instead
  * of those above. If you wish to allow use of your version of this file only
  * under the terms of either the GPL or the LGPL, and not to allow others to
  * use your version of this file under the terms of the MPL, indicate your
@@ -1458,16 +1459,27 @@ IsAccessKeyTarget(nsIContent* aContent, 
 
   if (!aFrame->AreAncestorViewsVisible())
     return PR_FALSE;
 
   nsCOMPtr<nsIDOMXULControlElement> control(do_QueryInterface(aContent));
   if (control)
     return PR_TRUE;
 
+  if (aContent->IsNodeOfType(nsINode::eHTML)) {
+    nsIAtom* tag = aContent->Tag();
+
+    // HTML area, label and legend elements are never focusable, so
+    // we need to check for them explicitly before giving up.
+    if (tag == nsGkAtoms::area ||
+        tag == nsGkAtoms::label ||
+        tag == nsGkAtoms::legend)
+      return PR_TRUE;
+  }
+
   return PR_FALSE;
 }
 
 PRBool
 nsEventStateManager::ExecuteAccessKey(nsTArray<PRUint32>& aAccessCharCodes,
                                       PRBool aIsTrustedEvent)
 {
   PRInt32 count, start = -1;
--- a/content/events/test/Makefile.in
+++ b/content/events/test/Makefile.in
@@ -52,16 +52,17 @@ include $(topsrcdir)/config/rules.mk
 		test_bug336682_2.xul \
 		test_bug336682.js \
 		test_bug367781.html \
 		test_bug368835.html \
 		test_bug379120.html \
 		test_bug391568.xhtml \
 		test_bug402089.html \
 		test_bug405632.html \
+		test_bug409604.html \
 		$(NULL)
 
 _CHROME_FILES = \
 		test_bug415498.xul \
 		bug415498-doc1.html \
 		bug415498-doc2.html \
 		$(NULL)