Bug 312867: expose input's editor (toolkit version), patch by Alex Vincent <ajvincent@gmail.com>, r=mconnor, also address an xpfe nit (comment 16) and fix some trailing whitespace

This commit is contained in:
gavin%gavinsharp.com 2006-01-25 01:14:00 +00:00
parent 60ba096f4c
commit 0646d40ceb
3 changed files with 58 additions and 46 deletions

View File

@ -49,7 +49,7 @@
<constructor>
this.setInitialSelection()
</constructor>
<method name="setInitialSelection">
<body>
<![CDATA[
@ -390,6 +390,13 @@
else this.removeAttribute('disableautoselect'); return val;"
onget="return this.hasAttribute('disableautoselect');"/>
<property name="editor" readonly="true">
<getter><![CDATA[
const nsIDOMNSEditableElement = Components.interfaces.nsIDOMNSEditableElement;
return this.inputField.QueryInterface(nsIDOMNSEditableElement).editor;
]]></getter>
</property>
<method name="select">
<body>
this.inputField.select();
@ -446,7 +453,7 @@
</handlers>
</binding>
<binding id="menulist-compact" display="xul:menu"
<binding id="menulist-compact" display="xul:menu"
extends="chrome://global/content/bindings/menulist.xml#menulist">
<content sizetopopup="false">
<xul:dropmarker class="menulist-dropmarker" type="menu"/>

View File

@ -15,14 +15,14 @@
<resources>
<stylesheet src="chrome://global/skin/textbox.css"/>
</resources>
<content>
<xul:hbox class="textbox-input-box" flex="1" xbl:inherits="context">
<html:input class="textbox-input" flex="1" anonid="input"
xbl:inherits="onfocus,onblur,value,type,maxlength,disabled,size,readonly,tabindex,accesskey"/>
</xul:hbox>
</content>
<implementation implements="nsIAccessibleProvider, nsIDOMXULTextBoxElement">
<property name="accessible">
<getter>
@ -36,15 +36,15 @@
<field name="mInputField">null</field>
<field name="mIgnoreClick">false</field>
<field name="mIgnoreFocus">false</field>
<property name="inputField" readonly="true">
<getter><![CDATA[
if (!this.mInputField)
if (!this.mInputField)
this.mInputField = document.getAnonymousElementByAttribute(this, "anonid", "input");
return this.mInputField;
]]></getter>
</property>
<property name="value" onset="this.inputField.value = val; return val;"
onget="return this.inputField.value;"/>
<property name="type" onset="this.inputField.type = val; return val;"
@ -70,6 +70,13 @@
onset="if (val) this.setAttribute('clickSelectsAll', 'true');
else this.removeAttribute('clickSelectsAll'); return val;" />
<property name="editor" readonly="true">
<getter><![CDATA[
const nsIDOMNSEditableElement = Components.interfaces.nsIDOMNSEditableElement;
return this.inputField.QueryInterface(nsIDOMNSEditableElement).editor;
]]></getter>
</property>
<method name="select">
<body>
this.inputField.select();
@ -118,12 +125,10 @@
str = this.getAttribute("newlines");
if (str) {
const nsIPlaintextEditor = Components.interfaces.nsIPlaintextEditor;
const nsIDOMNSEditableElement = Components.interfaces.nsIDOMNSEditableElement;
for (var x in nsIPlaintextEditor) {
if (/^eNewlines/.test(x)) {
if (str == RegExp.rightContext.toLowerCase()) {
this.inputField.QueryInterface(nsIDOMNSEditableElement)
.editor.QueryInterface(nsIPlaintextEditor)
this.editor.QueryInterface(nsIPlaintextEditor)
.newlineHandling = nsIPlaintextEditor[x];
break;
}
@ -160,7 +165,7 @@
</method>
</implementation>
<handlers>
<handler event="focus" phase="capturing">
<![CDATA[
@ -201,7 +206,7 @@
this.inputField.select();
]]>
</handler>
</handlers>
</handlers>
</binding>
<binding id="timed-textbox" extends="chrome://global/content/bindings/textbox.xml#textbox">
@ -232,7 +237,7 @@
]]>
</body>
</method>
</implementation>
</implementation>
<handlers>
<handler event="input">
<![CDATA[
@ -294,7 +299,7 @@
<implementation>
<method name="_doPopupItemEnabling">
<parameter name="popupNode"/>
<parameter name="popupNode"/>
<body>
<![CDATA[
var children = popupNode.childNodes;
@ -306,7 +311,7 @@
if (enabled)
children[i].removeAttribute("disabled");
else
children[i].setAttribute("disabled", "true");
children[i].setAttribute("disabled", "true");
}
}
@ -395,5 +400,5 @@
</method>
</implementation>
</binding>
</bindings>

View File

@ -12,7 +12,7 @@
</resources>
</binding>
<binding id="menulist" display="xul:menu"
<binding id="menulist" display="xul:menu"
extends="chrome://global/content/bindings/menulist.xml#menulist-base">
<content sizetopopup="pref">
<xul:hbox class="menulist-label-box" flex="1">
@ -26,7 +26,7 @@
<handlers>
<handler event="command" phase="capturing"
action="if (event.target.parentNode.parentNode == this) this.selectedItem = event.target;"/>
<handler event="popupshowing">
<![CDATA[
if (event.target.parentNode == this && this.selectedItem)
@ -49,7 +49,7 @@
<constructor>
this.setInitialSelection()
</constructor>
<method name="setInitialSelection">
<body>
<![CDATA[
@ -59,7 +59,7 @@
if (!arr.item(0) && this.value)
arr = popup.getElementsByAttribute('value', this.value);
if (arr.item(0))
this.selectedItem = arr[0];
else
@ -143,7 +143,7 @@
this.selectedItem = popup.childNodes[val];
else
this.selectedItem = null;
return val;
return val;
]]>
</setter>
</property>
@ -158,7 +158,7 @@
<![CDATA[
if (this.selectedInternal == val)
return val;
if (this.selectedInternal)
this.selectedInternal.removeAttribute('selected');
@ -170,7 +170,7 @@
this.removeAttribute('description');
return val;
}
val.setAttribute('selected', 'true');
this.setAttribute('value', val.getAttribute('value'));
@ -181,12 +181,12 @@
var event = document.createEvent("Events");
event.initEvent("ValueChange", true, true);
this.dispatchEvent(event);
return val;
]]>
</setter>
</property>
<method name="appendItem">
<parameter name="label"/>
<parameter name="value"/>
@ -207,7 +207,7 @@
]]>
</body>
</method>
<method name="insertItemAt">
<parameter name="index"/>
<parameter name="label"/>
@ -267,7 +267,7 @@
]]>
</getter>
</property>
</implementation>
</implementation>
</binding>
<binding id="menulist-editable" extends="chrome://global/content/bindings/menulist.xml#menulist">
@ -279,19 +279,12 @@
<xul:dropmarker class="menulist-dropmarker" type="menu"/>
<children includes="menupopup"/>
</content>
<implementation>
<constructor><![CDATA[
this.setInitialSelection();
]]></constructor>
<property name="editor" readonly="true">
<getter><![CDATA[
const nsIDOMNSEditableElement = Components.interfaces.nsIDOMNSEditableElement;
return this.inputField.QueryInterface(nsIDOMNSEditableElement).editor;
]]></getter>
</property>
<method name="_selectInputFieldValueInList">
<body>
<![CDATA[
@ -319,7 +312,7 @@
// when using selectedItem's setter
if (this.selectedInternal == val)
return val;
if (this.selectedInternal)
this.selectedInternal.removeAttribute('selected');
@ -335,10 +328,10 @@
</method>
<field name="mInputField">null</field>
<property name="inputField" readonly="true">
<getter><![CDATA[
if (!this.mInputField)
if (!this.mInputField)
this.mInputField = document.getAnonymousElementByAttribute(this, "anonid", "input");
return this.mInputField;
]]></getter>
@ -392,11 +385,18 @@
]]>
</setter>
</property>
<property name="disableautoselect"
<property name="disableautoselect"
onset="if (val) this.setAttribute('disableautoselect','true');
else this.removeAttribute('disableautoselect'); return val;"
onget="return this.hasAttribute('disableautoselect');"/>
<property name="editor" readonly="true">
<getter><![CDATA[
const nsIDOMNSEditableElement = Components.interfaces.nsIDOMNSEditableElement;
return this.inputField.QueryInterface(nsIDOMNSEditableElement).editor;
]]></getter>
</property>
<method name="select">
<body>
this.inputField.select();
@ -408,13 +408,13 @@
<handler event="focus" phase="capturing">
<![CDATA[
if (!this.hasAttribute('focused')) {
if (document.commandDispatcher.focusedElement != this.inputField)
if (document.commandDispatcher.focusedElement != this.inputField)
this.inputField.focus();
this.setAttribute('focused','true');
}
]]>
</handler>
<handler event="blur" phase="capturing">
<![CDATA[
this.removeAttribute('focused');
@ -426,7 +426,7 @@
// editable menulists elements aren't in the focus order,
// so when the popup opens we need to force the focus to the inputField
if (event.target.parentNode == this) {
if (document.commandDispatcher.focusedElement != this.inputField)
if (document.commandDispatcher.focusedElement != this.inputField)
this.inputField.focus();
if (this.selectedItem)
@ -450,10 +450,10 @@
}
]]>
</handler>
</handlers>
</handlers>
</binding>
<binding id="menulist-compact" display="xul:menu"
<binding id="menulist-compact" display="xul:menu"
extends="chrome://global/content/bindings/menulist.xml#menulist">
<content sizetopopup="false">
<xul:dropmarker class="menulist-dropmarker" type="menu"/>
@ -463,7 +463,7 @@
</content>
</binding>
<binding id="menulist-description" display="xul:menu"
<binding id="menulist-description" display="xul:menu"
extends="chrome://global/content/bindings/menulist.xml#menulist">
<content sizetopopup="pref">
<xul:hbox class="menulist-label-box" flex="1">