зеркало из https://github.com/mozilla/gecko-dev.git
XForms bug 299766 - implement accesskey underlining
This commit is contained in:
Родитель
e202b0696d
Коммит
7dc77c33ce
|
@ -61,7 +61,6 @@ nsIAtom *nsXFormsAtoms::incremental;
|
|||
nsIAtom *nsXFormsAtoms::clazz;
|
||||
nsIAtom *nsXFormsAtoms::deferredBindListProperty;
|
||||
nsIAtom *nsXFormsAtoms::readyForBindProperty;
|
||||
nsIAtom *nsXFormsAtoms::accesskey;
|
||||
nsIAtom *nsXFormsAtoms::fatalError;
|
||||
nsIAtom *nsXFormsAtoms::isInstanceDocument;
|
||||
nsIAtom *nsXFormsAtoms::instanceDocumentOwner;
|
||||
|
@ -89,7 +88,6 @@ const nsStaticAtom nsXFormsAtoms::Atoms_info[] = {
|
|||
{ "class", &nsXFormsAtoms::clazz },
|
||||
{ "DeferredBindListProperty", &nsXFormsAtoms::deferredBindListProperty },
|
||||
{ "ReadyForBindProperty", &nsXFormsAtoms::readyForBindProperty },
|
||||
{ "accesskey", &nsXFormsAtoms::accesskey },
|
||||
{ "fatalError", &nsXFormsAtoms::fatalError },
|
||||
{ "isInstanceDocument", &nsXFormsAtoms::isInstanceDocument },
|
||||
{ "instanceDocumentOwner", &nsXFormsAtoms::instanceDocumentOwner }
|
||||
|
|
|
@ -69,7 +69,6 @@ class nsXFormsAtoms
|
|||
static NS_HIDDEN_(nsIAtom *) clazz;
|
||||
static NS_HIDDEN_(nsIAtom *) deferredBindListProperty;
|
||||
static NS_HIDDEN_(nsIAtom *) readyForBindProperty;
|
||||
static NS_HIDDEN_(nsIAtom *) accesskey;
|
||||
static NS_HIDDEN_(nsIAtom *) fatalError;
|
||||
static NS_HIDDEN_(nsIAtom *) isInstanceDocument;
|
||||
static NS_HIDDEN_(nsIAtom *) instanceDocumentOwner;
|
||||
|
|
|
@ -82,7 +82,7 @@
|
|||
<html:span>
|
||||
<children includes="label"/>
|
||||
</html:span>
|
||||
<html:select xbl:inherits="style"
|
||||
<html:select xbl:inherits="style, accesskey"
|
||||
class="xf-value"
|
||||
onchange="this.parentNode.parentNode.selectionChanged();"
|
||||
onfocus="this.parentNode.parentNode.dispatchDOMUIEvent('DOMFocusIn');"
|
||||
|
|
|
@ -62,6 +62,7 @@
|
|||
anonid="container"><html:input
|
||||
class="-moz-xforms-select1-input"
|
||||
anonid="control"
|
||||
xbl:inherits="accesskey"
|
||||
onfocus="this.parentNode.parentNode.dispatchDOMUIEvent('DOMFocusIn')"
|
||||
onblur="this.parentNode.parentNode.handleBlur(); this.parentNode.parentNode.dispatchDOMUIEvent('DOMFocusOut');"
|
||||
onclick="this.parentNode.parentNode.handleControlClick();"
|
||||
|
|
|
@ -191,6 +191,17 @@ label {
|
|||
-moz-binding: url('chrome://xforms/content/xforms.xml#xformswidget-label');
|
||||
}
|
||||
|
||||
input > label,
|
||||
secret > label,
|
||||
textarea > label,
|
||||
trigger > label,
|
||||
submit > label,
|
||||
select > label,
|
||||
select1 > label,
|
||||
upload > label {
|
||||
-moz-binding: url('chrome://xforms/content/xforms.xml#xformswidget-label-accesskey');
|
||||
}
|
||||
|
||||
select1 {
|
||||
-moz-binding: url('chrome://xforms/content/select1.xml#xformswidget-select1');
|
||||
}
|
||||
|
|
|
@ -198,7 +198,75 @@
|
|||
</method>
|
||||
</implementation>
|
||||
</binding>
|
||||
|
||||
|
||||
<!-- LABEL: <ACCESKEY SUPPORT> -->
|
||||
<binding id="xformswidget-label-accesskey"
|
||||
extends="chrome://xforms/content/xforms.xml#xformswidget-base">
|
||||
<content>
|
||||
<html:span anonid="content"></html:span>
|
||||
<html:span anonid="anoncontent" style="display:none;">
|
||||
<children/>
|
||||
</html:span>
|
||||
</content>
|
||||
<implementation implements="nsIXFormsUIWidget">
|
||||
<method name="refresh">
|
||||
<body>
|
||||
<![CDATA[
|
||||
// we cannot access the <children/> content in XBL1, so we switch to
|
||||
// always cloning the content into the content span.
|
||||
var content =
|
||||
document.getAnonymousElementByAttribute(this, "anonid", "content");
|
||||
|
||||
var hasElementChildren = false;
|
||||
var hasBoundValue = false;
|
||||
|
||||
if (this.accessors.hasBoundNode() || this.accessors.getValue() != null) {
|
||||
content.textContent = this.stringValue;
|
||||
hasBoundValue = true;
|
||||
} else {
|
||||
// clone the contents child by child
|
||||
var node;
|
||||
for (var i = 0; i < this.childNodes.length; i++) {
|
||||
if (!hasElementChildren && this.childNodes[i].nodeType == Node.ELEMENT_NODE)
|
||||
hasElementChildren = true;
|
||||
|
||||
content.appendChild(this.childNodes[i].cloneNode(true));
|
||||
}
|
||||
}
|
||||
|
||||
// XXX: if label has element node children, we skip accesskey underlining
|
||||
if (!hasElementChildren && this.parentNode.hasAttribute("accesskey")) {
|
||||
var accesskey = this.parentNode.getAttribute("accesskey");
|
||||
|
||||
// bail if no accesskey or accesskey is longer than 1 character
|
||||
if (!accesskey || accesskey.length != 1)
|
||||
return true;
|
||||
|
||||
var str = content.textContent;
|
||||
var location = str.indexOf(accesskey);
|
||||
|
||||
if (location > -1) {
|
||||
// we create a range around the character we want and surround it
|
||||
// with an <html:u>
|
||||
var range = document.createRange();
|
||||
range.setStart(content.firstChild, location)
|
||||
range.setEnd(content.firstChild, location+1)
|
||||
|
||||
var u = document.createElementNS("http://www.w3.org/1999/xhtml", "u");
|
||||
range.surroundContents(u);
|
||||
} else {
|
||||
// if we didn't find the accesskey, append it to the end
|
||||
content.textContent += "(" + accesskey + ")";
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
]]>
|
||||
</body>
|
||||
</method>
|
||||
</implementation>
|
||||
</binding>
|
||||
|
||||
<!-- INPUT: <DEFAULT> -->
|
||||
<binding id="xformswidget-input"
|
||||
extends="chrome://xforms/content/xforms.xml#xformswidget-base">
|
||||
|
@ -1178,8 +1246,7 @@
|
|||
<children includes="label"/>
|
||||
<html:input anonid="upload_text_control"
|
||||
class="xf-value"
|
||||
readonly="true"
|
||||
xbl:inherits="accesskey"/>
|
||||
readonly="true"/>
|
||||
<html:button anonid="upload_browse_button"
|
||||
type="button"
|
||||
onclick="this.parentNode.uploadElem.pickFile();"
|
||||
|
@ -1189,7 +1256,7 @@
|
|||
type="button"
|
||||
onclick="this.parentNode.uploadElem.clearFile();"
|
||||
onkeypress="if (event.keyCode == event.DOM_VK_RETURN) this.parentNode.dispatchDOMUIEvent('DOMActivate');"
|
||||
xbl:inherits="accesskey"> &xforms.upload.cleartext; </html:button>
|
||||
> &xforms.upload.cleartext; </html:button>
|
||||
<children/>
|
||||
</content>
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче