Bug 750808, move children element in label control binding, so that it doesn't get deleted when setting accesskey, r=neil
authorNeil Deakin <neil@mozilla.com>
Wed, 16 May 2012 19:55:09 -0400
changeset 94155 d3733e739f16c31b47e7d353b9ecdad1dd5a7850
parent 94154 f1b1411cb13e6a72285a9a890b3c4c932c92e4f7
child 94156 722e163ecc1e5440f1e74842fc3f28b67762705b
push id9498
push userneil@mozilla.com
push dateWed, 16 May 2012 23:56:14 +0000
treeherdermozilla-inbound@722e163ecc1e [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersneil
bugs750808
milestone15.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 750808, move children element in label control binding, so that it doesn't get deleted when setting accesskey, r=neil
layout/reftests/xul/accesskey-ref.xul
layout/reftests/xul/accesskey.xul
layout/reftests/xul/reftest.list
toolkit/content/widgets/text.xml
new file mode 100644
--- /dev/null
+++ b/layout/reftests/xul/accesskey-ref.xul
@@ -0,0 +1,23 @@
+<?xml version="1.0"?>
+<?xml-stylesheet href="chrome://global/skin" type="text/css"?>
+<?xml-stylesheet href="data:text/css,u { display: inline; text-decoration: underline; }" type="text/css"?>
+
+<window xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
+
+<hbox align="start">
+  <label control="b1"><u>L</u>abel1</label><textbox id="b1" size="2"/>
+  <label control="b2">Labe<u>l</u>2</label><textbox id="b2" size="2"/>
+  <label control="b3">La<u>b</u>el3</label><textbox id="b3" size="2"/>
+  <label control="b4">Label4 (<u>X</u>)</label><textbox id="b4" size="2"/>
+  <label control="b5" maxwidth="50">Quite a <u>l</u>ong label. Hopefully it will wrap</label><textbox id="b5" label="Button5" size="2"/>
+</hbox>
+
+<hbox id="d" align="start">
+  <label control="d1"><u>L</u>abel1</label><textbox id="d1" size="2"/>
+  <label control="d2">Labe<u>l</u>2</label><textbox id="d2" size="2"/>
+  <label control="d3">La<u>b</u>el3</label><textbox id="d3" size="2"/>
+  <label control="d4">Label4 (<u>X</u>)</label><textbox id="d4" size="2"/>
+  <label control="d5" maxwidth="50">Quite a <u>l</u>ong label. Hopefully it will wrap</label><textbox id="d5" size="2"/>
+</hbox>
+
+</window>
new file mode 100644
--- /dev/null
+++ b/layout/reftests/xul/accesskey.xul
@@ -0,0 +1,43 @@
+<?xml version="1.0"?>
+<?xml-stylesheet href="chrome://global/skin" type="text/css"?>
+
+<!-- This test checks that access keys are rendered properly, both when set with the
+     accesskey attribute in the markup and updated via script later.
+  -->
+<window class="reftest-wait" onload="changeKeys()"
+        xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
+
+<script>
+<![CDATA[
+
+var keys = ['L', 'l', 'b', 'x', 'l'];
+
+function changeKeys()
+{
+  var box = document.getElementById('d');
+  for (var b = 0; b < 5; b++)
+    box.childNodes[b * 2].accessKey = keys[b];
+
+  document.documentElement.className='';
+}
+
+]]>
+</script>
+
+<hbox align="start">
+  <label control="b1">Label1</label><textbox id="b1" accesskey="L" size="2"/>
+  <label control="b2">Label2</label><textbox id="b2" accesskey="l" size="2"/>
+  <label control="b3">Label3</label><textbox id="b3" accesskey="b" size="2"/>
+  <label control="b4">Label4</label><textbox id="b4" accesskey="x" size="2"/>
+  <label control="b5" maxwidth="50">Quite a long label. Hopefully it will wrap</label><textbox id="b5" accesskey="l" size="2"/>
+</hbox>
+
+<hbox id="d" align="start">
+  <label control="d1">Label1</label><textbox id="d1" accesskey="z" size="2"/>
+  <label control="d2">Label2</label><textbox id="d2" size="2"/>
+  <label control="d3">Label3</label><textbox id="d3" accesskey="t" size="2"/>
+  <label control="d4">Label4</label><textbox id="d4" accesskey="b" size="2"/>
+  <label control="d5" maxwidth="50">Quite a long label. Hopefully it will wrap</label><textbox id="d5" accesskey="l" size="2"/>
+</hbox>
+
+</window>
--- a/layout/reftests/xul/reftest.list
+++ b/layout/reftests/xul/reftest.list
@@ -1,5 +1,7 @@
 == menuitem-key.xul menuitem-key-ref.xul
 # these random-if(Android) are due to differences between Android Native & Xul, see bug 732569
 random-if(Android) == menulist-shrinkwrap-1.xul menulist-shrinkwrap-1-ref.xul
 random-if(Android) fails-if(winWidget) == menulist-shrinkwrap-2.xul menulist-shrinkwrap-2-ref.xul
 == textbox-overflow-1.xul textbox-overflow-1-ref.xul # for bug 749658
+# accesskeys are not normally displayed on Mac, so skip this test
+skip-if(cocoaWidget) == accesskey.xul accesskey-ref.xul
--- a/toolkit/content/widgets/text.xml
+++ b/toolkit/content/widgets/text.xml
@@ -52,17 +52,17 @@
           ]]>
         </setter>
       </property>
     </implementation>
   </binding>
 
   <binding id="label-control" extends="chrome://global/content/bindings/text.xml#text-label">
     <content>
-      <html:span anonid="accessKeyParens"><children/></html:span>
+      <children/><html:span anonid="accessKeyParens"></html:span>
     </content>
     <implementation implements="nsIDOMXULLabelElement">
       <constructor>
         <![CDATA[
           try {
             var prefs = Components.classes["@mozilla.org/preferences-service;1"].
                                    getService(Components.interfaces.nsIPrefBranch);
             this.mUnderlineAccesskey = (prefs.getIntPref("ui.key.menuAccessKey") != 0);
@@ -101,17 +101,17 @@
                 control = bindingParent; // For controls that make the <label> an anon child
               }
             }
             if (control) {
               control.labelElement = this;
             }
 
             var afterLabel = document.getAnonymousElementByAttribute(this, "anonid", "accessKeyParens");
-            afterLabel.textContent = ""; // This does not clear real nodes!
+            afterLabel.textContent = "";
 
             var oldAccessKey = this.getElementsByAttribute('class', 'accesskey').item(0);
             if (oldAccessKey) { // Clear old accesskey
               this.mergeElement(oldAccessKey);
             }
 
             var oldHiddenSpan =
               this.getElementsByAttribute('class', 'hiddenColon').item(0);