Fix for bug 3700487 - fix accesskey UI behaviour for input, trigger, upload. r=aaronr,Olli.Pettay
git-svn-id: svn://10.0.0.236/trunk@222279 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
@@ -46,7 +46,7 @@
|
||||
* http://developer.mozilla.org/en/docs/XForms:Custom_Controls
|
||||
*
|
||||
*/
|
||||
[scriptable, uuid(f636007c-cc01-4295-b3cb-d525054c4a14)]
|
||||
[scriptable, uuid(0448d5cd-c69c-4279-9dab-eeaee47dbc1a)]
|
||||
interface nsIXFormsUIWidget : nsIDOMElement
|
||||
{
|
||||
/**
|
||||
@@ -59,6 +59,12 @@ interface nsIXFormsUIWidget : nsIDOMElement
|
||||
*/
|
||||
boolean focus();
|
||||
|
||||
/**
|
||||
* The method focuses (or activates) element that accesskey is bound to. It is
|
||||
* called when accesskey is activated.
|
||||
*/
|
||||
void performAccesskey();
|
||||
|
||||
/**
|
||||
* During submission, the \<submit\> should be disabled.
|
||||
*/
|
||||
|
||||
@@ -74,7 +74,7 @@ nsXFormsDelegateStub::PerformAccesskey()
|
||||
nsCOMPtr<nsIXFormsUIWidget> widget(do_QueryInterface(mElement));
|
||||
if (widget) {
|
||||
PRBool isFocused;
|
||||
widget->Focus(&isFocused);
|
||||
widget->PerformAccesskey();
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
|
||||
@@ -196,11 +196,9 @@ nsXFormsLabelElement::PerformAccesskey()
|
||||
nsCOMPtr<nsIDOMNode> parent;
|
||||
node->GetParentNode(getter_AddRefs(parent));
|
||||
if (parent) {
|
||||
nsCOMPtr<nsIXFormsUIWidget> widget(do_QueryInterface(parent));
|
||||
if (widget) {
|
||||
PRBool isFocused;
|
||||
widget->Focus(&isFocused);
|
||||
}
|
||||
nsCOMPtr<nsIXTFElement> parentElm(do_QueryInterface(parent));
|
||||
if (parentElm)
|
||||
parentElm->PerformAccesskey();
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
|
||||
@@ -153,6 +153,15 @@
|
||||
</body>
|
||||
</method>
|
||||
|
||||
<method name="performAccesskey">
|
||||
<body>
|
||||
this.focus();
|
||||
|
||||
this.control.value = !this.control.value;
|
||||
this.updateInstanceData();
|
||||
</body>
|
||||
</method>
|
||||
|
||||
<method name="getCurrentValue">
|
||||
<body>
|
||||
return this.control.value ? "true" : "false";
|
||||
|
||||
@@ -313,6 +313,10 @@
|
||||
} else {
|
||||
this.removeAttribute('disabled');
|
||||
}
|
||||
},
|
||||
activate: function triggerControlElmActivate() {
|
||||
this.focus();
|
||||
this.click();
|
||||
}
|
||||
};
|
||||
</body>
|
||||
@@ -352,10 +356,19 @@
|
||||
return {
|
||||
__proto__: this.ownerDocument.
|
||||
getAnonymousElementByAttribute(this, 'anonid', 'control'),
|
||||
trigger: this,
|
||||
|
||||
set disabled(val) {
|
||||
this.isDisabled = val;
|
||||
},
|
||||
activate: function triggerControlElmActivate(aNoFocus) {
|
||||
if (!this.isDisabled) {
|
||||
if (!aNoFocus)
|
||||
this.trigger.focus();
|
||||
this.trigger.dispatchDOMUIEvent("DOMActivate");
|
||||
}
|
||||
},
|
||||
|
||||
isDisabled: false
|
||||
};
|
||||
</body>
|
||||
@@ -364,10 +377,7 @@
|
||||
</implementation>
|
||||
|
||||
<handlers>
|
||||
<handler event="click">
|
||||
if (!this.control.isDisabled)
|
||||
this.dispatchDOMUIEvent("DOMActivate");
|
||||
</handler>
|
||||
<handler event="click" action="this.control.activate(true);"/>
|
||||
|
||||
<handler event="focus" phase="capturing">
|
||||
if (event.originalTarget == this.control) {
|
||||
@@ -533,6 +543,10 @@
|
||||
focus: function() {
|
||||
this._browseButton.focus();
|
||||
},
|
||||
activate: function uploadControlElmActivate() {
|
||||
this._browseButton.focus();
|
||||
this._upload.uploadElement.pickFile();
|
||||
},
|
||||
|
||||
_browseButton: this.ownerDocument.
|
||||
getAnonymousElementByAttribute(this, 'anonid', 'browse_button'),
|
||||
@@ -540,6 +554,7 @@
|
||||
getAnonymousElementByAttribute(this, 'anonid', 'clear_button'),
|
||||
_textControl: this.ownerDocument.
|
||||
getAnonymousElementByAttribute(this, 'anonid', 'text_control'),
|
||||
_upload: this
|
||||
};
|
||||
</body>
|
||||
</method>
|
||||
|
||||
@@ -331,8 +331,15 @@
|
||||
<implementation>
|
||||
<method name="getControlElement">
|
||||
<body>
|
||||
return this.ownerDocument.
|
||||
getAnonymousElementByAttribute(this, 'anonid', 'control');
|
||||
return {
|
||||
__proto__: this.ownerDocument.
|
||||
getAnonymousElementByAttribute(this, 'anonid', 'control'),
|
||||
|
||||
activate: function triggerControlElmActivate() {
|
||||
this.focus();
|
||||
this.click();
|
||||
}
|
||||
};
|
||||
</body>
|
||||
</method>
|
||||
</implementation>
|
||||
@@ -364,10 +371,19 @@
|
||||
return {
|
||||
__proto__: this.ownerDocument.
|
||||
getAnonymousElementByAttribute(this, 'anonid', 'control'),
|
||||
trigger: this,
|
||||
|
||||
set disabled(val) {
|
||||
this.isDisabled = val;
|
||||
},
|
||||
activate: function triggerControlElmActivate(aNoFocus) {
|
||||
if (!this.isDisabled) {
|
||||
if (!aNoFocus)
|
||||
this.trigger.focus();
|
||||
this.trigger.dispatchDOMUIEvent("DOMActivate");
|
||||
}
|
||||
},
|
||||
|
||||
isDisabled: false
|
||||
}
|
||||
</body>
|
||||
@@ -375,10 +391,7 @@
|
||||
</implementation>
|
||||
|
||||
<handlers>
|
||||
<handler event="click">
|
||||
if (!this.control.isDisabled)
|
||||
this.dispatchDOMUIEvent("DOMActivate");
|
||||
</handler>
|
||||
<handler event="click" action="this.control.activate(true)"/>
|
||||
</handlers>
|
||||
</binding>
|
||||
|
||||
|
||||
@@ -230,6 +230,14 @@
|
||||
</body>
|
||||
</method>
|
||||
|
||||
<!-- Method is called when accesskey associated with the control is
|
||||
activated. -->
|
||||
<method name="performAccesskey">
|
||||
<body>
|
||||
this.focus();
|
||||
</body>
|
||||
</method>
|
||||
|
||||
<!-- Method is called to get current value of xforms element.
|
||||
|
||||
Here the method is implemented for those xforms elements that can't be
|
||||
@@ -436,6 +444,7 @@
|
||||
{
|
||||
set disabled(); // set disabled state
|
||||
focus(); // set focus
|
||||
activate(); // activates trigger
|
||||
}
|
||||
-->
|
||||
<binding id="xformswidget-trigger-base"
|
||||
@@ -462,6 +471,12 @@
|
||||
</body>
|
||||
</method>
|
||||
|
||||
<method name="performAccesskey">
|
||||
<body>
|
||||
this.control.activate();
|
||||
</body>
|
||||
</method>
|
||||
|
||||
<method name="getCurrentValue">
|
||||
<body>
|
||||
return "";
|
||||
@@ -554,6 +569,12 @@
|
||||
</body>
|
||||
</method>
|
||||
|
||||
<method name="performAccesskey">
|
||||
<body>
|
||||
this.control.activate();
|
||||
</body>
|
||||
</method>
|
||||
|
||||
<method name="getCurrentValue">
|
||||
<body>
|
||||
return this.control.value;
|
||||
|
||||
Reference in New Issue
Block a user