зеркало из https://github.com/mozilla/pjs.git
Bug 497562, accesskeys on radio don't focus properly, r+sr=neil
This commit is contained in:
Родитель
478eb586e1
Коммит
513d5a0e6b
|
@ -656,9 +656,27 @@ nsXULElement::PerformAccesskey(PRBool aKeyCausesActivation,
|
|||
nsIAtom *tag = content->Tag();
|
||||
if (tag != nsGkAtoms::toolbarbutton) {
|
||||
nsIFocusManager* fm = nsFocusManager::GetFocusManager();
|
||||
nsCOMPtr<nsIDOMElement> element = do_QueryInterface(content);
|
||||
if (fm)
|
||||
fm->SetFocus(element, nsIFocusManager::FLAG_BYKEY);
|
||||
if (fm) {
|
||||
nsCOMPtr<nsIDOMElement> element;
|
||||
// for radio buttons, focus the radiogroup instead
|
||||
if (tag == nsGkAtoms::radio) {
|
||||
nsCOMPtr<nsIDOMXULSelectControlItemElement> controlItem(do_QueryInterface(elm));
|
||||
if (controlItem) {
|
||||
PRBool disabled;
|
||||
controlItem->GetDisabled(&disabled);
|
||||
if (!disabled) {
|
||||
nsCOMPtr<nsIDOMXULSelectControlElement> selectControl;
|
||||
controlItem->GetControl(getter_AddRefs(selectControl));
|
||||
element = do_QueryInterface(selectControl);
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
element = do_QueryInterface(content);
|
||||
}
|
||||
if (element)
|
||||
fm->SetFocus(element, nsIFocusManager::FLAG_BYKEY);
|
||||
}
|
||||
}
|
||||
if (aKeyCausesActivation && tag != nsGkAtoms::textbox && tag != nsGkAtoms::menulist)
|
||||
elm->Click();
|
||||
|
|
|
@ -20,8 +20,8 @@
|
|||
<radio label="Three" value="three"/>
|
||||
</radiogroup>
|
||||
<radiogroup id="radiogroup-initwithselected" value="two">
|
||||
<radio label="One" value="one"/>
|
||||
<radio label="Two" value="two"/>
|
||||
<radio id="one" label="One" value="one" accesskey="o"/>
|
||||
<radio id="two" label="Two" value="two" accesskey="t"/>
|
||||
<radio label="Three" value="three" selected="true"/>
|
||||
</radiogroup>
|
||||
|
||||
|
@ -38,6 +38,25 @@ function test_radio()
|
|||
var element = document.getElementById("radiogroup");
|
||||
test_nsIDOMXULSelectControlElement(element, "radio", null);
|
||||
test_nsIDOMXULSelectControlElement_UI(element, null);
|
||||
|
||||
window.blur();
|
||||
|
||||
var accessKeyDetails = (navigator.platform.indexOf("Mac") >= 0) ?
|
||||
{ ctrlKey : true } : { altKey : true, shiftKey: true };
|
||||
synthesizeKey("t", accessKeyDetails);
|
||||
|
||||
var radiogroup = $("radiogroup-initwithselected");
|
||||
is(document.activeElement, radiogroup, "accesskey focuses radiogroup");
|
||||
is(radiogroup.selectedItem, $("two"), "accesskey selects radio");
|
||||
|
||||
$("radiogroup-initwithvalue").focus();
|
||||
|
||||
$("one").disabled = true;
|
||||
synthesizeKey("o", accessKeyDetails);
|
||||
|
||||
is(document.activeElement, $("radiogroup-initwithvalue"), "accesskey on disabled radio doesn't focus");
|
||||
is(radiogroup.selectedItem, $("two"), "accesskey on disabled radio doesn't change selection");
|
||||
|
||||
SimpleTest.finish();
|
||||
}
|
||||
|
||||
|
|
|
@ -522,14 +522,6 @@
|
|||
this.control.focusedItem = this;
|
||||
]]>
|
||||
</handler>
|
||||
<handler event="focus">
|
||||
<![CDATA[
|
||||
if (!this.disabled) {
|
||||
this.control.focusedItem = this;
|
||||
this.control.focus();
|
||||
}
|
||||
]]>
|
||||
</handler>
|
||||
</handlers>
|
||||
</binding>
|
||||
</bindings>
|
||||
|
|
Загрузка…
Ссылка в новой задаче