diff --git a/mozilla/extensions/xforms/jar.mn b/mozilla/extensions/xforms/jar.mn index 4d1d4fa23bf..e9045b7580e 100755 --- a/mozilla/extensions/xforms/jar.mn +++ b/mozilla/extensions/xforms/jar.mn @@ -18,6 +18,7 @@ xforms.jar: content/xforms/select1.xml (resources/content/select1.xml) content/xforms/range.xml (resources/content/range.xml) content/xforms/select.xml (resources/content/select.xml) + content/xforms/select-xhtml.xml (resources/content/select-xhtml.xml) content/xforms/bindingex.css (resources/content/bindingex.css) content/xforms/bindingex.xul (resources/content/bindingex.xul) content/xforms/calendar.png (resources/content/calendar.png) diff --git a/mozilla/extensions/xforms/resources/content/select.xml b/mozilla/extensions/xforms/resources/content/select.xml index 22085724240..2e6973041f0 100644 --- a/mozilla/extensions/xforms/resources/content/select.xml +++ b/mozilla/extensions/xforms/resources/content/select.xml @@ -22,6 +22,7 @@ - - Contributor(s): - Doron Rosenberg + - Olli Pettay - - Alternatively, the contents of this file may be used under the terms of - either the GNU General Public License Version 2 or later (the "GPL"), or @@ -38,87 +39,56 @@ - ***** END LICENSE BLOCK ***** --> - + xmlns:xbl="http://www.mozilla.org/xbl"> - - + - - - - - - - - - - - - - null - - - if (!this._uiElement) { - this._uiElement = - document.getAnonymousElementByAttribute(this, "anonid", "select"); - } - - return this._uiElement; - - - - - - this.uiElement.selectedIndex = val; - - - - null + - - - - - - - - - - - - - - - - - - - - null - - - + + + + + + if (this.parentControl) { + if (!aIncremental || this.parentControl.incremental) { + this.parentControl._setBoundValue(); + } else { + // we should call _getSelectedValues() method since we probably + // should unselect illegaly selected items. + this.parentControl._getSelectedValues(); + } + this.parentControl._dispatchSelectEvents(); } + + - return this._uiElement; - ]]> + + + + this.parentControl.dispatchDOMUIEvent(aType); + + + + + + + null - - - - - - - - var labelSpan = document.createElementNS("http://www.w3.org/1999/xhtml", - "span"); + - if (aUseLabelValue) { - labelSpan.textContent = aLabel; - } else { - var label = aControl.getElementsByTagName("label")[0]; + - // We either have a bound node and get it's content, or we - // clone the contents of the label element - if (label.accessors.hasBoundNode()) { - labelSpan.textContent = label.accessors.getValue(); - } else { - var childLength = label.childNodes.length; - - // text content only? - if (childLength == 1 && label.firstChild.nodeType == Node.TEXT_NODE) { - labelSpan.textContent = label.textContent; - } else { - // clone all children. We don't simply clone the xforms:label - // because xhtml:select will get confused by it and break - // find-as-you-type. - for (var i = 0; i < childLength; i++) { - labelSpan.appendChild(label.childNodes[i].cloneNode(true)); - } - } - } - } - - var input = document.createElementNS("http://www.w3.org/1999/xhtml", - "input"); - input.setAttribute("type", "checkbox"); - input.setAttribute("value", aValue); - input.setAttribute("optionid", this._controlArraySize); - - div.appendChild(input); - div.appendChild(labelSpan); - - return div; - ]]> - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 0) { - var item = aItemElement.QueryInterface(Components.interfaces.nsIXFormsSelectChild); - for (var j = 0; j < this._selectedElementSize; j++ ) { - var selectedItem = - item.selectItemByNode(this._selectedElementArray[j].element); - if (selectedItem) { - this._selectedElementArray[j].hits++; - item.firstChild.checked = true; - - this._controlArray[this._controlArraySize - 1].wasSelected = true; - // XXX It is possible that two identical elements are under the - // bound node. I guess we shouldn't mark one and not the other - // if there is an item in the select that matches it. So we'll - // go through the whole list. But this is quite an edge case - // and will cause more inefficiency just to prevent an errant - // xforms-out-of-range. - } - } - } else if (!copyItem) { - // if this item contains a value element, then make sure to select - // this item if its value exists under the bound node. - this.preselectItem(itemValue); - } - - return itemValue; - ]]> - - + + diff --git a/mozilla/extensions/xforms/resources/content/xforms-xhtml.xml b/mozilla/extensions/xforms/resources/content/xforms-xhtml.xml index 005d013fcec..bc805824b8c 100644 --- a/mozilla/extensions/xforms/resources/content/xforms-xhtml.xml +++ b/mozilla/extensions/xforms/resources/content/xforms-xhtml.xml @@ -127,6 +127,7 @@ getAnonymousElementByAttribute(this, "anonid", 'implicitcontent'), _explicitContent: this.ownerDocument. getAnonymousElementByAttribute(this, 'anonid', 'explicitcontent'), + __proto__: this, set value(val) { if (val != null) { @@ -136,6 +137,26 @@ this._implicitContent.textContent = ''; this._explicitContent.style.display = 'inline'; } + }, + + get textValue() { + if (this._explicitContent.style.display == 'none') + return this._implicitContent.textContent; + return this.textContent; + }, + get nodeValue() { + var fragment = this.ownerDocument.createDocumentFragment(); + + var container = null; + if (this._explicitContent.style.display == 'none') + container = this._implicitContent; + else + container = this; + + for (var node = container.firstChild; node; node = node.nextSibling) { + fragment.appendChild(node.cloneNode(true)); + } + return fragment; } }; diff --git a/mozilla/extensions/xforms/resources/content/xforms.css b/mozilla/extensions/xforms/resources/content/xforms.css index 7bdb9f84444..26a8da69542 100755 --- a/mozilla/extensions/xforms/resources/content/xforms.css +++ b/mozilla/extensions/xforms/resources/content/xforms.css @@ -468,12 +468,18 @@ case > html|div.-moz-xforms-case-container { } /* select */ -select { - -moz-binding: url('chrome://xforms/content/select.xml#xformswidget-select'); +html|*:root select { + -moz-binding: url('chrome://xforms/content/select-xhtml.xml#xformswidget-select-compact'); +} +html|*:root select html|span[anonid="control"] { + -moz-binding: url('chrome://xforms/content/select-xhtml.xml#widget-select-compact'); } -select[appearance="full"] { - -moz-binding: url('chrome://xforms/content/select.xml#xformswidget-select-full'); +html|*:root select[appearance="full"] { + -moz-binding: url('chrome://xforms/content/select-xhtml.xml#xformswidget-select-full'); +} +html|*:root select[appearance="full"] html|span[anonid="control"] { + -moz-binding: url('chrome://xforms/content/select-xhtml.xml#widget-select-full'); } select html|div.select-choice-label { diff --git a/mozilla/extensions/xforms/resources/content/xforms.xml b/mozilla/extensions/xforms/resources/content/xforms.xml index 15730920424..1afab952f92 100644 --- a/mozilla/extensions/xforms/resources/content/xforms.xml +++ b/mozilla/extensions/xforms/resources/content/xforms.xml @@ -171,6 +171,7 @@ this._delegate = null; this._accessors = null; + this._control = null; @@ -216,6 +217,8 @@ method what returns the object: { set value(); // set "string" value + get textValue() // return text representing label value + get nodeValue() // return document fragment representing label value } --> + + +