[XForms] Reorganize XBL implementations, to expose pure (non-XHTML) widgets in xforms.xml. Bug 323845, patch by surkov@dc.baikal.ru, r=smaug+me

This commit is contained in:
allan%beaufour.dk 2006-02-14 09:33:34 +00:00
parent 494b3a0ab2
commit ba9071ed84
3 changed files with 298 additions and 324 deletions

View File

@ -8,6 +8,7 @@ xforms.jar:
* content/xforms/xforms-prefs-ui.xul (resources/content/xforms-prefs-ui.xul) * content/xforms/xforms-prefs-ui.xul (resources/content/xforms-prefs-ui.xul)
* content/xforms/xforms-prefs.js (resources/content/xforms-prefs.js) * content/xforms/xforms-prefs.js (resources/content/xforms-prefs.js)
content/xforms/xforms.xml (resources/content/xforms.xml) content/xforms/xforms.xml (resources/content/xforms.xml)
content/xforms/xforms-xhtml.xml (resources/content/xforms-xhtml.xml)
content/xforms/select1.xml (resources/content/select1.xml) content/xforms/select1.xml (resources/content/select1.xml)
content/xforms/range.xml (resources/content/range.xml) content/xforms/range.xml (resources/content/range.xml)
content/xforms/select.xml (resources/content/select.xml) content/xforms/select.xml (resources/content/select.xml)

View File

@ -77,7 +77,7 @@ alert {
} }
output { output {
-moz-binding: url('chrome://xforms/content/xforms.xml#xformswidget-output'); -moz-binding: url('chrome://xforms/content/xforms-xhtml.xml#xformswidget-output');
} }
range { range {
@ -85,11 +85,11 @@ range {
} }
input { input {
-moz-binding: url('chrome://xforms/content/xforms.xml#xformswidget-input'); -moz-binding: url('chrome://xforms/content/xforms-xhtml.xml#xformswidget-input');
} }
input[mozType|type="http://www.w3.org/2001/XMLSchema#boolean"] { input[mozType|type="http://www.w3.org/2001/XMLSchema#boolean"] {
-moz-binding: url('chrome://xforms/content/xforms.xml#xformswidget-input-boolean'); -moz-binding: url('chrome://xforms/content/xforms-xhtml.xml#xformswidget-input-boolean');
} }
input[mozType|type="http://www.w3.org/2001/XMLSchema#date"] { input[mozType|type="http://www.w3.org/2001/XMLSchema#date"] {
@ -168,29 +168,25 @@ input[mozType|type="http://www.w3.org/2001/XMLSchema#gYear"] {
} }
secret { secret {
-moz-binding: url('chrome://xforms/content/xforms.xml#xformswidget-secret'); -moz-binding: url('chrome://xforms/content/xforms-xhtml.xml#xformswidget-secret');
} }
textarea { textarea {
-moz-binding: url('chrome://xforms/content/xforms.xml#xformswidget-textarea'); -moz-binding: url('chrome://xforms/content/xforms-xhtml.xml#xformswidget-textarea');
} }
trigger, submit { trigger, submit {
-moz-binding: url('chrome://xforms/content/xforms.xml#xformswidget-trigger'); -moz-binding: url('chrome://xforms/content/xforms-xhtml.xml#xformswidget-trigger');
} }
trigger[appearance="minimal"], submit[appearance="minimal"] { trigger[appearance="minimal"], submit[appearance="minimal"] {
-moz-binding: url('chrome://xforms/content/xforms.xml#xformswidget-trigger-minimal'); -moz-binding: url('chrome://xforms/content/xforms-xhtml.xml#xformswidget-trigger-minimal');
} }
trigger[appearance="minimal"]:hover, submit[appearance="minimal"]:hover { trigger[appearance="minimal"]:hover, submit[appearance="minimal"]:hover {
cursor: pointer; cursor: pointer;
} }
label {
-moz-binding: url('chrome://xforms/content/xforms.xml#xformswidget-label');
}
input > label, input > label,
secret > label, secret > label,
textarea > label, textarea > label,
@ -202,6 +198,10 @@ upload > label {
-moz-binding: url('chrome://xforms/content/xforms.xml#xformswidget-label-accesskey'); -moz-binding: url('chrome://xforms/content/xforms.xml#xformswidget-label-accesskey');
} }
label {
-moz-binding: url('chrome://xforms/content/xforms-xhtml.xml#xformswidget-label');
}
select1 { select1 {
-moz-binding: url('chrome://xforms/content/select1.xml#xformswidget-select1'); -moz-binding: url('chrome://xforms/content/select1.xml#xformswidget-select1');
} }

View File

@ -38,71 +38,40 @@
- -
- ***** END LICENSE BLOCK ***** --> - ***** END LICENSE BLOCK ***** -->
<!--
This file implements the "abstract" UI classes for all XForms controls. They
all have "pure virtual" functions that they expect to be implemented by
concrete application and returned in the getElementControl() call. An example
is the controls for XHTML in xforms-xhtml.xml.
-->
<!DOCTYPE bindings [ <!DOCTYPE bindings [
<!ENTITY % xformsDTD SYSTEM "chrome://xforms/locale/xforms.dtd"> <!ENTITY % xformsDTD SYSTEM "chrome://xforms/locale/xforms.dtd">
%xformsDTD; %xformsDTD;
]> ]>
<bindings id="xformsBindings" <bindings id="xformsBindings"
xmlns="http://www.mozilla.org/xbl" xmlns="http://www.mozilla.org/xbl"
xmlns:html="http://www.w3.org/1999/xhtml" xmlns:html="http://www.w3.org/1999/xhtml"
xmlns:xbl="http://www.mozilla.org/xbl" xmlns:xbl="http://www.mozilla.org/xbl"
xmlns:xforms="http://www.w3.org/2002/xforms" xmlns:xforms="http://www.w3.org/2002/xforms"
xmlns:lazy="http://www.mozilla.org/projects/xforms/2005/lazy"> xmlns:lazy="http://www.mozilla.org/projects/xforms/2005/lazy">
<!-- LAZY INSTANCE MODEL -->
<binding id="xforms-lazy-instance"> <binding id="xforms-lazy-instance">
<content><xforms:instance lazy:lazy="true"/><children/></content> <content><xforms:instance lazy:lazy="true"/><children/></content>
</binding> </binding>
<!-- BASE --> <!-- BASE -->
<binding id="xformswidget-base"> <binding id="xformswidget-base">
<content><children/></content> <content><children/></content>
<implementation implements="nsIXFormsUIWidget"> <implementation implements="nsIXFormsUIWidget">
<constructor>
this.delegate.widgetAttached();
</constructor>
<destructor>
this._delegate = null;
this._accessors = null;
</destructor>
<property name="XFORMS_NS" readonly="true">
<getter>
return "http://www.w3.org/2002/xforms";
</getter>
</property>
<field name="_delegate">null</field>
<property name="delegate" readonly="true">
<getter>
if (!this._delegate)
this._delegate = this.QueryInterface(Components.interfaces.nsIXFormsDelegate);
return this._delegate;
</getter>
</property>
<field name="_accessors">null</field>
<property name="accessors" readonly="true">
<getter>
<![CDATA[
if (!this._accessors && this.delegate)
this._accessors = this.delegate.getXFormsAccessors();
return this._accessors;
]]>
</getter>
</property>
<property name="stringValue" readonly="true">
<getter>
var value = this.accessors.getValue();
return value != null ? value : "";
</getter>
</property>
<!-- nsIXFormsUIWidget interface -->
<method name="refresh"> <method name="refresh">
<body> <body>
return true; return true;
@ -122,6 +91,30 @@
</body> </body>
</method> </method>
<!-- interface -->
<property name="XFORMS_NS" readonly="true">
<getter>
return "http://www.w3.org/2002/xforms";
</getter>
</property>
<property name="accessors" readonly="true">
<getter>
<![CDATA[
if (!this._accessors && this.delegate)
this._accessors = this.delegate.getXFormsAccessors();
return this._accessors;
]]>
</getter>
</property>
<property name="stringValue" readonly="true">
<getter>
var value = this.accessors.getValue();
return value != null ? value : "";
</getter>
</property>
<!-- Dispatch UI Event to the control itself --> <!-- Dispatch UI Event to the control itself -->
<method name="dispatchDOMUIEvent"> <method name="dispatchDOMUIEvent">
<parameter name="aType"/> <parameter name="aType"/>
@ -147,67 +140,103 @@
return true; return true;
</body> </body>
</method> </method>
</implementation>
</binding>
<!-- OUTPUT: <DEFAULT> --> <!--
<binding id="xformswidget-output" Return object to operate with underliying controls. Each xforms widget
extends="chrome://xforms/content/xforms.xml#xformswidget-base"> defines interface what should implement the object.
<content>
<children includes="label"/>
<!-- XXX initialize span with a space until repeat is xbl-ized. Part
of workaround for bug 322975
--> -->
<html:span class="xf-value" anonid="content"> </html:span> <property name="control" readonly="true">
<children/> <getter>
</content> if (!this._control)
this._control = this.getControlElement();
return this._control;
</getter>
</property>
<implementation implements="nsIXFormsUIWidget"> <!--
<method name="refresh"> Each base binding for xforms widget assumes successors bindings will
override the method.
-->
<method name="getControlElement">
<body> <body>
// XXX changing from setting textContent to setting nodeValue of throw Error("getControlElement() method isn't implemented.");
// first child (text node created by space character initializer
// above). Workaround for bug 322975. Probably should be changed
// back after repeat is xbl-ized
document.getAnonymousElementByAttribute(this, "anonid", "content").firstChild.nodeValue =
this.stringValue;
return true;
</body> </body>
</method> </method>
</implementation>
</binding>
<!-- LABEL: <DEFAULT> --> <!-- private -->
<binding id="xformswidget-label" <constructor>
extends="chrome://xforms/content/xforms.xml#xformswidget-base"> this.delegate.widgetAttached();
<content> </constructor>
<html:span anonid="content"></html:span>
<html:span anonid="anoncontent">
<children/>
</html:span>
</content>
<implementation implements="nsIXFormsUIWidget">
<method name="refresh">
<body>
var anoncontent =
document.getAnonymousElementByAttribute(this, "anonid", "anoncontent");
if (this.accessors.hasBoundNode() || this.accessors.getValue() != null) { <destructor>
anoncontent.setAttribute("style", "display:none;"); this._delegate = null;
} else { this._accessors = null;
anoncontent.removeAttribute("style"); </destructor>
<property name="delegate" readonly="true">
<getter>
if (!this._delegate) {
this._delegate =
this.QueryInterface(Components.interfaces.nsIXFormsDelegate);
} }
return this._delegate;
</getter>
</property>
document.getAnonymousElementByAttribute(this, "anonid", "content").textContent = <field name="_delegate">null</field>
this.stringValue; <field name="_accessors">null</field>
<field name="_control">null</field>
</implementation>
</binding>
<!-- OUTPUT: <DEFAULT>
The output widget assumes successors bindings implement getElementControl()
method what returns the object:
{
set value(); // set "string" value
}
-->
<binding id="xformswidget-output-base"
extends="chrome://xforms/content/xforms.xml#xformswidget-base">
<implementation implements="nsIXFormsUIWidget">
<method name="refresh">
<body>
this.control.value = this.stringValue;
return true; return true;
</body> </body>
</method> </method>
</implementation> </implementation>
</binding> </binding>
<!-- LABEL: <ACCESKEY SUPPORT> -->
<!-- LABEL: <DEFAULT>
The label widget assumes successors bindings implement getElementControl()
method what returns the object:
{
set value(); // set "string" value
}
-->
<binding id="xformswidget-label-base"
extends="chrome://xforms/content/xforms.xml#xformswidget-base">
<implementation implements="nsIXFormsUIWidget">
<method name="refresh">
<body>
this.control.value = this.accessors.getValue();
return true;
</body>
</method>
</implementation>
</binding>
<!-- LABEL: <ACCESKEY SUPPORT>
XXX: The widget doesn't support interface based on getElementControl()
method (see a bug https://bugzilla.mozilla.org/show_bug.cgi?id=323845).
-->
<binding id="xformswidget-label-accesskey" <binding id="xformswidget-label-accesskey"
extends="chrome://xforms/content/xforms.xml#xformswidget-base"> extends="chrome://xforms/content/xforms.xml#xformswidget-base">
<content> <content>
@ -257,8 +286,8 @@
// we create a range around the character we want and surround it // we create a range around the character we want and surround it
// with an <html:u> // with an <html:u>
var range = document.createRange(); var range = document.createRange();
range.setStart(content.firstChild, location) range.setStart(content.firstChild, location);
range.setEnd(content.firstChild, location+1) range.setEnd(content.firstChild, location+1);
var u = document.createElementNS("http://www.w3.org/1999/xhtml", "u"); var u = document.createElementNS("http://www.w3.org/1999/xhtml", "u");
range.surroundContents(u); range.surroundContents(u);
@ -275,110 +304,116 @@
</implementation> </implementation>
</binding> </binding>
<!-- INPUT: <DEFAULT> -->
<binding id="xformswidget-input" <!-- INPUT: <DEFAULT>
The input widget assumes successors bindings implement getElementControl()
method what returns the object:
{
set value(); // set "string" value
get value(); // return "string" value
set readonly(); // set readonly state
focus(); // set focus
}
-->
<binding id="xformswidget-input-base"
extends="chrome://xforms/content/xforms.xml#xformswidget-base"> extends="chrome://xforms/content/xforms.xml#xformswidget-base">
<content>
<children includes="label"/>
<html:input anonid="control"
class="xf-value"
onblur="this.parentNode.accessors.setValue(this.value); this.parentNode.dispatchDOMUIEvent('DOMFocusOut')"
onfocus="this.parentNode.dispatchDOMUIEvent('DOMFocusIn')"
onclick="this.parentNode._change();"
onkeyup="if (event.keyCode != event.DOM_VK_TAB) this.parentNode._change();"
onkeypress="if (event.keyCode == event.DOM_VK_RETURN) this.parentNode.dispatchDOMUIEvent('DOMActivate');"
xbl:inherits="accesskey"/>
<children/>
</content>
<implementation implements="nsIXFormsUIWidget"> <implementation implements="nsIXFormsUIWidget">
<field name="_inputField">null</field>
<property name="inputField" readonly="true">
<getter>
if (!this._inputField) {
this._inputField =
document.getAnonymousElementByAttribute(this, "anonid", "control");
}
return this._inputField;
</getter>
</property>
<method name="_change">
<body>
if (this.getAttribute("incremental") == "true") {
this.accessors.setValue(this.inputField.value);
}
return true;
</body>
</method>
<method name="refresh"> <method name="refresh">
<body> <body>
this.inputField.value = this.stringValue; this.control.readonly = this.accessors.isReadonly();
if (this.accessors.isReadonly()) { // If the value has not changed, no need to update the
this.inputField.setAttribute("readonly", "readonly"); // value of the control, because f.x. that makes the textarea widget
} else { // to scroll up.
this.inputField.removeAttribute("readonly"); if (this.control.value != this.stringValue) {
this.control.value = this.stringValue;
} }
return true; return true;
</body> </body>
</method> </method>
<method name="focus"> <method name="focus">
<body> <body>
this.inputField.focus(); this.control.focus();
return true; return true;
</body> </body>
</method> </method>
<method name="updateInstanceData">
<parameter name="incremental"/>
<body>
if (!incremental || this.getAttribute("incremental") == "true")
this.accessors.setValue(this.control.value);
</body>
</method>
</implementation> </implementation>
</binding> </binding>
<!-- INPUT: BOOLEAN -->
<binding id="xformswidget-input-boolean" <!-- INPUT: BOOLEAN
extends="chrome://xforms/content/xforms.xml#xformswidget-input"> The input[type="xsd:boolean"] widget assumes successors bindings implement
getElementControl() method what returns the object:
{
set value(); // set "boolean" value
get value(); // return "boolean" value
set readonly(); // set readonly state
focus(); // set focus
}
-->
<binding id="xformswidget-input-boolean-base"
extends="chrome://xforms/content/xforms.xml#xformswidget-base">
<implementation> <implementation>
<method name="refresh"> <method name="refresh">
<body> <body>
this.inputField.setAttribute("type","checkbox");
var value = this.stringValue; var value = this.stringValue;
if (value == "true" || value == "1") { if (value == "true" || value == "1") {
this.inputField.setAttribute("checked", "checked"); this.control.value = true;
} else { } else {
this.inputField.removeAttribute("checked"); this.control.value = false;
} }
this.inputField.value = value; this.control.readonly = this.accessors.isReadonly();
if (this.accessors.isReadonly()) {
this.inputField.setAttribute("readonly", "readonly");
} else {
this.inputField.removeAttribute("readonly");
}
<!-- Ignore Enter keypress on checkbox -->
this.inputField.removeAttribute("onkeypress");
return true; return true;
</body> </body>
</method> </method>
<method name="_change"> <method name="focus">
<body> <body>
if (this.getAttribute("incremental") != "false") { this.control.focus();
if (this.inputField.checked) { return true;
</body>
</method>
<method name="updateInstanceData">
<parameter name="incremental"/>
<body>
<![CDATA[
if (!incremental || this.getAttribute("incremental") != "false") {
if (this.control.value) {
this.accessors.setValue("true"); this.accessors.setValue("true");
} else { } else {
this.accessors.setValue("false"); this.accessors.setValue("false");
} }
} }
]]>
</body> </body>
</method> </method>
</implementation> </implementation>
</binding> </binding>
<!-- INPUT: DATE -->
<!-- INPUT: DATE
XXX: The widget doesn't support interface based on getElementControl()
method (see a bug https://bugzilla.mozilla.org/show_bug.cgi?id=323845).
-->
<binding id="xformswidget-input-date" <binding id="xformswidget-input-date"
extends="chrome://xforms/content/xforms.xml#xformswidget-input"> extends="chrome://xforms/content/xforms.xml#xformswidget-base">
<content> <content>
<children/> <children/>
<html:input anonid="control" <html:input anonid="control"
@ -428,6 +463,26 @@
</body> </body>
</method> </method>
<method name="_change">
<body>
if (this.getAttribute("incremental") == "true") {
this.accessors.setValue(this.inputField.value);
}
return true;
</body>
</method>
<field name="_inputField">null</field>
<property name="inputField" readonly="true">
<getter>
if (!this._inputField) {
this._inputField =
document.getAnonymousElementByAttribute(this, "anonid", "control");
}
return this._inputField;
</getter>
</property>
<field name="_picker">null</field> <field name="_picker">null</field>
<property name="picker" readonly="true"> <property name="picker" readonly="true">
<getter> <getter>
@ -451,7 +506,6 @@
</property> </property>
<field name="_dateField">null</field> <field name="_dateField">null</field>
<property name="dateField" readonly="true"> <property name="dateField" readonly="true">
<getter> <getter>
if (!this._dateField) { if (!this._dateField) {
@ -480,7 +534,6 @@
</body> </body>
</method> </method>
<method name="_showPicker"> <method name="_showPicker">
<body> <body>
<![CDATA[ <![CDATA[
@ -596,7 +649,7 @@
for (var y = 0; y < 7; y++) { for (var y = 0; y < 7; y++) {
cell = document.createElementNS(xhtmlNS, "td"); cell = document.createElementNS(xhtmlNS, "td");
cell.setAttribute("num", this._cells.length) cell.setAttribute("num", this._cells.length);
this._cells[this._cells.length] = {row:i, col:y, node: cell}; this._cells[this._cells.length] = {row:i, col:y, node: cell};
row.appendChild(cell); row.appendChild(cell);
@ -641,12 +694,12 @@
var maxprev = this._getDaysInMonth(prevmonth, prevyear); var maxprev = this._getDaysInMonth(prevmonth, prevyear);
this._cells[i].node.textContent = maxprev - firstDay + i + 1; this._cells[i].node.textContent = maxprev - firstDay + i + 1;
this._cells[i].node.className = "prevMonth" this._cells[i].node.className = "prevMonth";
showsPrevDays++; showsPrevDays++;
} else { } else {
// next month // next month
this._cells[i].node.textContent = i - (firstDay + totaldays) + 1; this._cells[i].node.textContent = i - (firstDay + totaldays) + 1;
this._cells[i].node.className = "nextMonth" this._cells[i].node.className = "nextMonth";
} }
} else { } else {
// current month // current month
@ -688,7 +741,7 @@
var month, year = aYear; var month, year = aYear;
if (aMonth == 0) { if (aMonth == 0) {
month = 11 month = 11;
year--; year--;
} else { } else {
month = aMonth - 1; month = aMonth - 1;
@ -705,7 +758,7 @@
var month, year = aYear; var month, year = aYear;
if (aMonth == 11) { if (aMonth == 11) {
month = 0 month = 0;
year++; year++;
} else { } else {
month = aMonth + 1; month = aMonth + 1;
@ -885,7 +938,7 @@
// check if something changed // check if something changed
this._change(); this._change();
} }
]]> ]]>
</handler> </handler>
<handler event="mousedown"> <handler event="mousedown">
@ -922,7 +975,10 @@
</handlers> </handlers>
</binding> </binding>
<!-- INPUT: Month --> <!-- INPUT: Month
XXX: The widget doesn't support interface based on getElementControl()
method (see a bug https://bugzilla.mozilla.org/show_bug.cgi?id=323845).
-->
<binding id="xformswidget-input-month" <binding id="xformswidget-input-month"
extends="chrome://xforms/content/xforms.xml#xformswidget-base"> extends="chrome://xforms/content/xforms.xml#xformswidget-base">
<content> <content>
@ -948,7 +1004,7 @@
this.select.readonly = this.accessors.isReadonly(); this.select.readonly = this.accessors.isReadonly();
if (this.accessors.isValid()) if (this.accessors.isValid())
this.select.value = this.stringValue.substr(2,2) this.select.value = this.stringValue.substr(2,2);
else else
this.select.value = ""; this.select.value = "";
@ -960,26 +1016,26 @@
<method name="_build"> <method name="_build">
<body> <body>
<![CDATA[ <![CDATA[
// create the select options // create the select options
var xhtmlNS = "http://www.w3.org/1999/xhtml"; var xhtmlNS = "http://www.w3.org/1999/xhtml";
var date = new Date(); var date = new Date();
var option, monthName; var option, monthName;
for (var i = 0; i < 12; i++) { for (var i = 0; i < 12; i++) {
option = document.createElementNS(xhtmlNS, "option"); option = document.createElementNS(xhtmlNS, "option");
var value = i + 1; var value = i + 1;
if (value < 10) if (value < 10)
value = "0" + value; value = "0" + value;
option.setAttribute("value", value); option.setAttribute("value", value);
date.setMonth(i); date.setMonth(i);
monthName = date.toLocaleFormat("%B"); monthName = date.toLocaleFormat("%B");
var txt = document.createTextNode(monthName); var txt = document.createTextNode(monthName);
option.appendChild(txt); option.appendChild(txt);
this.select.appendChild(option); this.select.appendChild(option);
} }
this.refresh(); this.refresh();
]]> ]]>
@ -1016,7 +1072,10 @@
</implementation> </implementation>
</binding> </binding>
<!-- INPUT: Day --> <!-- INPUT: Day
XXX: The widget doesn't support interface based on getElementControl()
method (see a bug https://bugzilla.mozilla.org/show_bug.cgi?id=323845).
-->
<binding id="xformswidget-input-day" <binding id="xformswidget-input-day"
extends="chrome://xforms/content/xforms.xml#xformswidget-base"> extends="chrome://xforms/content/xforms.xml#xformswidget-base">
<content> <content>
@ -1042,7 +1101,7 @@
this.select.readonly = this.accessors.isReadonly(); this.select.readonly = this.accessors.isReadonly();
if (this.accessors.isValid()) if (this.accessors.isValid())
this.select.value = this.stringValue.substr(3,2) this.select.value = this.stringValue.substr(3,2);
else else
this.select.value = ""; this.select.value = "";
@ -1107,111 +1166,39 @@
</implementation> </implementation>
</binding> </binding>
<!-- SECRET: <DEFAULT> -->
<binding id="xformswidget-secret"
extends="chrome://xforms/content/xforms.xml#xformswidget-input">
<implementation>
<method name="refresh">
<body>
this.inputField.setAttribute("type","password");
this.inputField.value = this.stringValue;
this.inputField.readonly = this.accessors.isReadonly();
return true;
</body>
</method>
</implementation>
</binding>
<!-- TEXTAREA: <DEFAULT> --> <!-- SECRET: <DEFAULT>
<binding id="xformswidget-textarea" We don't need in any special base binding for secret widget. All
successors bindings should be extended from base binding for input widget.
-->
<!-- TEXTAREA: <DEFAULT>
We don't need in any special base binding for textarea widget. All
successors bindings should be extended from base binding for input widget.
-->
<!-- TRIGGER: <DEFAULT>
The trigger widget assumes successors bindings implement getElementControl()
method what returns the object:
{
set disabled(); // set disabled state
focus(); // set focus
}
-->
<binding id="xformswidget-trigger-base"
extends="chrome://xforms/content/xforms.xml#xformswidget-base"> extends="chrome://xforms/content/xforms.xml#xformswidget-base">
<content>
<children includes="label"/>
<html:textarea anonid="control"
class="xf-value"
onblur="this.parentNode.accessors.setValue(this.value); this.parentNode.dispatchDOMUIEvent('DOMFocusOut')"
onfocus="this.parentNode.dispatchDOMUIEvent('DOMFocusIn')"
onkeyup="this.parentNode._change();"
xbl:inherits="accesskey"/>
<children/>
</content>
<implementation implements="nsIXFormsUIWidget">
<field name="_controlField">null</field>
<property name="controlField" readonly="true">
<getter>
if (!this._controlField) {
this._controlField =
document.getAnonymousElementByAttribute(this, "anonid", "control");
}
return this._controlField;
</getter>
</property>
<method name="refresh">
<body>
if (this.accessors.isReadonly()) {
this.controlField.setAttribute("readonly", "readonly");
} else {
this.controlField.removeAttribute("readonly");
}
// If the value has not changed, no need to update the
// value of the control, because that makes the textarea widget
// to scroll up.
if (this.controlField.value != this.stringValue) {
this.controlField.value = this.stringValue;
}
return true;
</body>
</method>
<method name="_change">
<body>
if (this.getAttribute("incremental") == "true") {
this.accessors.setValue(this.controlField.value);
}
return true;
</body>
</method>
<method name="focus">
<body>
this.controlField.focus();
return true;
</body>
</method>
</implementation>
</binding>
<!-- TRIGGER: <DEFAULT> -->
<binding id="xformswidget-trigger"
extends="chrome://xforms/content/xforms.xml#xformswidget-base">
<content>
<html:button anonid="thebutton" xbl:inherits="accesskey"
onblur="this.parentNode.dispatchDOMUIEvent('DOMFocusOut')"
onfocus="this.parentNode.dispatchDOMUIEvent('DOMFocusIn')">
<children/>
</html:button>
</content>
<implementation implements="nsIXFormsUIWidget"> <implementation implements="nsIXFormsUIWidget">
<method name="disable"> <method name="disable">
<parameter name="aDisable"/> <parameter name="aDisable"/>
<body> <body>
var control = this.control.disabled = aDisable;
document.getAnonymousElementByAttribute(this, "anonid", "thebutton");
if (aDisable) {
control.setAttribute("disabled", "disabled");
} else {
control.removeAttribute("disabled");
}
</body> </body>
</method> </method>
<method name="focus"> <method name="focus">
<body> <body>
document.getAnonymousElementByAttribute(this, "anonid", "thebutton").focus(); this.control.focus();
return true; return true;
</body> </body>
</method> </method>
@ -1219,36 +1206,13 @@
</implementation> </implementation>
</binding> </binding>
<!-- TRIGGER: MINIMAL -->
<binding id="xformswidget-trigger-minimal"
extends="chrome://xforms/content/xforms.xml#xformswidget-base">
<content>
<html:span tabindex="0" anonid="thespan" xbl:inherits="accesskey"
onclick="if (!this._disabled) this.parentNode.dispatchDOMUIEvent('DOMActivate');"
onblur="this.parentNode.dispatchDOMUIEvent('DOMFocusOut')"
onfocus="this.parentNode.dispatchDOMUIEvent('DOMFocusIn')">
<children/>
</html:span>
</content>
<implementation implements="nsIXFormsUIWidget"> <!-- TRIGGER: MINIMAL
<field name="_disabled">false</field> We don't need in any special base binding for trigger[appearance="minimal"]
widget. All successors bindings should be extended from base binding for
default trigger widget.
-->
<method name="disable">
<parameter name="aDisable"/>
<body>
this._disabled = aDisable;
</body>
</method>
<method name="focus">
<body>
document.getAnonymousElementByAttribute(this, "anonid", "thespan").focus();
return true;
</body>
</method>
</implementation>
</binding>
<!-- CASE: <DEFAULT> --> <!-- CASE: <DEFAULT> -->
<binding id="xformswidget-case"> <binding id="xformswidget-case">
@ -1260,15 +1224,16 @@
<implementation implements="nsIXFormsCaseUIElement"> <implementation implements="nsIXFormsCaseUIElement">
<constructor> <constructor>
this.QueryInterface(Components.interfaces.nsIXFormsCaseElement).widgetAttached(); this.QueryInterface(Components.interfaces.nsIXFormsCaseElement).
widgetAttached();
</constructor> </constructor>
<field name="_container">null</field> <field name="_container">null</field>
<property name="container" readonly="true"> <property name="container" readonly="true">
<getter> <getter>
if (!this._container) { if (!this._container) {
this._container = this._container = document.
document.getAnonymousElementByAttribute(this, "anonid", "container"); getAnonymousElementByAttribute(this, "anonid", "container");
} }
return this._container; return this._container;
</getter> </getter>
@ -1286,10 +1251,15 @@
return true; return true;
</body> </body>
</method> </method>
</implementation> </implementation>
</binding> </binding>
<!-- UPLOAD: <DEFAULT> -->
<!-- UPLOAD: <DEFAULT>
XXX: The widget doesn't support interface based on getElementControl()
method (see a bug https://bugzilla.mozilla.org/show_bug.cgi?id=323845).
-->
<binding id="xformswidget-upload" <binding id="xformswidget-upload"
extends="chrome://xforms/content/xforms.xml#xformswidget-base"> extends="chrome://xforms/content/xforms.xml#xformswidget-base">
<content> <content>
@ -1378,7 +1348,10 @@
</implementation> </implementation>
</binding> </binding>
<!-- UPLOAD: DISABLED --> <!-- UPLOAD: DISABLED
XXX: The widget doesn't support interface based on getElementControl()
method (see a bug https://bugzilla.mozilla.org/show_bug.cgi?id=323845).
-->
<binding id="xformswidget-upload-disabled" <binding id="xformswidget-upload-disabled"
extends="chrome://xforms/content/xforms.xml#xformswidget-base"> extends="chrome://xforms/content/xforms.xml#xformswidget-base">
<content> <content>