1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/browser/metro/base/content/bindings/bindings.xml Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,359 @@ 1.4 +<?xml version="1.0"?> 1.5 +<!-- This Source Code Form is subject to the terms of the Mozilla Public 1.6 + - License, v. 2.0. If a copy of the MPL was not distributed with this 1.7 + - file, You can obtain one at http://mozilla.org/MPL/2.0/. --> 1.8 + 1.9 + 1.10 +<!DOCTYPE bindings [ 1.11 +<!ENTITY % browserDTD SYSTEM "chrome://browser/locale/browser.dtd"> 1.12 +%browserDTD; 1.13 +]> 1.14 + 1.15 +<bindings 1.16 + xmlns="http://www.mozilla.org/xbl" 1.17 + xmlns:xbl="http://www.mozilla.org/xbl" 1.18 + xmlns:svg="http://www.w3.org/2000/svg" 1.19 + xmlns:html="http://www.w3.org/1999/xhtml" 1.20 + xmlns:xul="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"> 1.21 + 1.22 + <binding id="richlistbox-batch" extends="chrome://global/content/bindings/richlistbox.xml#richlistbox"> 1.23 + <handlers> 1.24 + <handler event="scroll"> 1.25 + <![CDATA[ 1.26 + // if there no more items to insert, just return early 1.27 + if (this._items.length == 0) 1.28 + return; 1.29 + 1.30 + if (this._contentScrollHeight == -1) { 1.31 + let scrollheight = {}; 1.32 + this.scrollBoxObject.getScrolledSize({}, scrollheight); 1.33 + this._contentScrollHeight = scrollheight.value; 1.34 + } 1.35 + 1.36 + let y = {}; 1.37 + this.scrollBoxObject.getPosition({}, y); 1.38 + let scrollRatio = (y.value + this._childrenHeight) / this._contentScrollHeight; 1.39 + 1.40 + // If we're scrolled 80% to the bottom of the list, append the next 1.41 + // set of items 1.42 + if (scrollRatio > 0.8) 1.43 + this._insertItems(); 1.44 + ]]> 1.45 + </handler> 1.46 + </handlers> 1.47 + <implementation> 1.48 + <!-- Number of elements to add to the list initially. If there are more 1.49 + than this many elements to display, only add them to the list once 1.50 + the user has scrolled towards them. This is a performance 1.51 + optimization to avoid locking up while attempting to append hundreds 1.52 + of nodes to our richlistbox. 1.53 + --> 1.54 + <property name="batchSize" readonly="true" onget="return this.getAttribute('batch')"/> 1.55 + 1.56 + <field name="_childrenHeight">this.scrollBoxObject.height;</field> 1.57 + <field name="_items">[]</field> 1.58 + 1.59 + <method name="setItems"> 1.60 + <parameter name="aItems"/> 1.61 + <body><![CDATA[ 1.62 + this._items = aItems; 1.63 + this._insertItems(); 1.64 + ]]></body> 1.65 + </method> 1.66 + 1.67 + <method name="_insertItems"> 1.68 + <body><![CDATA[ 1.69 + let items = this._items.splice(0, this.batchSize); 1.70 + if (!items.length) 1.71 + return; // no items to insert 1.72 + 1.73 + let count = items.length; 1.74 + for (let i = 0; i<count; i++) 1.75 + this.appendChild(items[i]); 1.76 + 1.77 + 1.78 + // make sure we recalculate the scrollHeight of the content 1.79 + this._contentScrollHeight = -1; 1.80 + ]]></body> 1.81 + </method> 1.82 + </implementation> 1.83 + </binding> 1.84 + 1.85 + <binding id="richlistbox-contextmenu" extends="chrome://global/content/bindings/richlistbox.xml#richlistbox"> 1.86 + <handlers> 1.87 + <handler event="click" phase="bubble"> 1.88 + <![CDATA[ 1.89 + ContextMenuUI.hide(); 1.90 + ]]> 1.91 + </handler> 1.92 + </handlers> 1.93 + </binding> 1.94 + 1.95 + <binding id="richlistitem" extends="chrome://global/content/bindings/richlistbox.xml#richlistitem"> 1.96 + <handlers> 1.97 + <handler event="mousedown" phase="capturing"> 1.98 + <![CDATA[ 1.99 + // We'll get this if the user is interacting via the mouse 1.100 + let domUtils = Components.classes["@mozilla.org/inspector/dom-utils;1"]. 1.101 + getService(Ci.inIDOMUtils); 1.102 + domUtils.setContentState(this, 0x00000001); 1.103 + ]]> 1.104 + </handler> 1.105 + <handler event="click" phase="capturing"> 1.106 + <![CDATA[ 1.107 + // allow normal mouse event processing 1.108 + if (!InputSourceHelper || InputSourceHelper.isPrecise) 1.109 + return; 1.110 + // trap this here, we'll rely on tap events 1.111 + // event.stopPropagation(); 1.112 + ]]> 1.113 + </handler> 1.114 + <handler event="touchstart" phase="capturing"> 1.115 + <![CDATA[ 1.116 + // touch input event 1.117 + let domUtils = Components.classes["@mozilla.org/inspector/dom-utils;1"]. 1.118 + getService(Ci.inIDOMUtils); 1.119 + domUtils.setContentState(this, 0x00000001); 1.120 + ]]> 1.121 + </handler> 1.122 + </handlers> 1.123 + </binding> 1.124 + 1.125 + <binding id="menulist" display="xul:box" extends="chrome://global/content/bindings/menulist.xml#menulist"> 1.126 + <handlers> 1.127 + <handler event="mousedown" phase="capturing"> 1.128 + <![CDATA[ 1.129 + // Stop the normal menupopup from appearing 1.130 + event.stopPropagation(); 1.131 + ]]> 1.132 + </handler> 1.133 + 1.134 + <handler event="click" button="0"> 1.135 + <![CDATA[ 1.136 + if (this.disabled || this.itemCount == 0) 1.137 + return; 1.138 + 1.139 + this.focus(); 1.140 + MenuControlUI.show(this); 1.141 + ]]> 1.142 + </handler> 1.143 + 1.144 + <handler event="command" phase="capturing"> 1.145 + <![CDATA[ 1.146 + // The dropmark (button) fires a command event too. Don't forward that. 1.147 + // Just forward the menuitem command events, which the toolkit version does. 1.148 + if (event.target.parentNode.parentNode != this) 1.149 + event.stopPropagation(); 1.150 + ]]> 1.151 + </handler> 1.152 + </handlers> 1.153 + </binding> 1.154 + 1.155 + <binding id="chrome-select-option"> 1.156 + <content orient="horizontal" flex="1"> 1.157 + <xul:image class="chrome-select-option-image" anonid="check"/> 1.158 + <xul:label anonid="label" xbl:inherits="value=label"/> 1.159 + </content> 1.160 + 1.161 + <implementation> 1.162 + <property name="selected"> 1.163 + <getter> 1.164 + <![CDATA[ 1.165 + return this.hasAttribute("selected"); 1.166 + ]]> 1.167 + </getter> 1.168 + <setter> 1.169 + <![CDATA[ 1.170 + if (val) 1.171 + this.setAttribute("selected", "true"); 1.172 + else 1.173 + this.removeAttribute("selected"); 1.174 + return val; 1.175 + ]]> 1.176 + </setter> 1.177 + </property> 1.178 + </implementation> 1.179 + </binding> 1.180 + 1.181 + <binding id="select-button" extends="xul:box"> 1.182 + <content> 1.183 + <svg:svg width="11px" version="1.1" xmlns="http://www.w3.org/2000/svg" style="position: absolute; top: -moz-calc(50% - 2px); left: 4px;"> 1.184 + <svg:polyline points="1 1 5 6 9 1" stroke="#414141" stroke-width="2" stroke-linecap="round" fill="transparent" stroke-linejoin="round"/> 1.185 + </svg:svg> 1.186 + </content> 1.187 + </binding> 1.188 + 1.189 + <binding id="textbox" extends="chrome://global/content/bindings/textbox.xml#textbox"> 1.190 + <handlers> 1.191 + <handler event="contextmenu" phase="capturing"> 1.192 + <![CDATA[ 1.193 + let box = this.inputField.parentNode; 1.194 + box.showContextMenu(this, event, false); 1.195 + ]]> 1.196 + </handler> 1.197 + <handler event="click" phase="capturing"> 1.198 + <![CDATA[ 1.199 + if (event.mozInputSource == Ci.nsIDOMMouseEvent.MOZ_SOURCE_TOUCH) { 1.200 + if (typeof SelectionHelperUI != 'undefined') { 1.201 + SelectionHelperUI.attachEditSession(ChromeSelectionHandler, 1.202 + event.clientX, event.clientY, this); 1.203 + } else { 1.204 + // If we don't have access to SelectionHelperUI then we are using this 1.205 + // binding for browser content (e.g. about:config) 1.206 + Services.obs.notifyObservers(event, "attach_edit_session_to_content", ""); 1.207 + } 1.208 + } 1.209 + ]]> 1.210 + </handler> 1.211 + </handlers> 1.212 + </binding> 1.213 + 1.214 + <binding id="search-textbox" extends="chrome://global/content/bindings/textbox.xml#search-textbox"> 1.215 + <implementation> 1.216 + <field name="_searchClear"> 1.217 + <![CDATA[ 1.218 + document.getAnonymousElementByAttribute(this, "class", "textbox-search-clear"); 1.219 + ]]> 1.220 + </field> 1.221 + </implementation> 1.222 + 1.223 + <handlers> 1.224 + <handler event="contextmenu" phase="capturing"> 1.225 + <![CDATA[ 1.226 + let box = this.inputField.parentNode; 1.227 + box.showContextMenu(this, event, false); 1.228 + ]]> 1.229 + </handler> 1.230 + 1.231 + <handler event="text" phase="bubbling"><![CDATA[ 1.232 + // Listen for composition update, some VKB that does suggestions does not 1.233 + // update directly the content of the field but in this case we want to 1.234 + // search as soon as something is entered in the field 1.235 + let evt = document.createEvent("Event"); 1.236 + evt.initEvent("input", true, false); 1.237 + this.dispatchEvent(evt); 1.238 + ]]></handler> 1.239 + 1.240 + <handler event="click" phase="bubbling"><![CDATA[ 1.241 + // bug 629661. To reset the autosuggestions mechanism of Android, the 1.242 + // textfield need to reset the IME state 1.243 + if (event.originalTarget == this._searchClear) { 1.244 + setTimeout(function(self) { 1.245 + try { 1.246 + let imeEditor = self.inputField.QueryInterface(Ci.nsIDOMNSEditableElement) 1.247 + .editor 1.248 + .QueryInterface(Ci.nsIEditorIMESupport); 1.249 + if (imeEditor.composing) 1.250 + imeEditor.forceCompositionEnd(); 1.251 + } catch(e) {} 1.252 + }, 0, this); 1.253 + } 1.254 + ]]></handler> 1.255 + </handlers> 1.256 + </binding> 1.257 + 1.258 + <binding id="input-box" extends="xul:box"> 1.259 + <implementation> 1.260 + <method name="showContextMenu"> 1.261 + <parameter name="aTextbox"/> 1.262 + <parameter name="aEvent"/> 1.263 + <parameter name="aIgnoreReadOnly"/> 1.264 + <body><![CDATA[ 1.265 + let selectionStart = aTextbox.selectionStart; 1.266 + let selectionEnd = aTextbox.selectionEnd; 1.267 + 1.268 + let json = { types: ["input-text"], string: "" }; 1.269 + if (selectionStart != selectionEnd) { 1.270 + json.types.push("cut"); 1.271 + json.types.push("copy"); 1.272 + } 1.273 + 1.274 + if (selectionStart > 0 || selectionEnd < aTextbox.textLength) 1.275 + json.types.push("select-all"); 1.276 + 1.277 + let clipboard = Components.classes["@mozilla.org/widget/clipboard;1"]. 1.278 + getService(Ci.nsIClipboard); 1.279 + let flavors = ["text/unicode"]; 1.280 + let hasData = clipboard.hasDataMatchingFlavors(flavors, flavors.length, Ci.nsIClipboard.kGlobalClipboard); 1.281 + 1.282 + if (hasData && (!aTextbox.readOnly || aIgnoreReadOnly)) { 1.283 + json.types.push("paste"); 1.284 + if (aTextbox.type == "url") { 1.285 + json.types.push("paste-url"); 1.286 + } 1.287 + } 1.288 + json.xPos = aEvent.clientX; 1.289 + json.yPos = aEvent.clientY; 1.290 + json.source = aEvent.mozInputSource; 1.291 + ContextMenuUI.showContextMenu({ target: aTextbox, json: json }); 1.292 + ]]></body> 1.293 + </method> 1.294 + </implementation> 1.295 + <handlers> 1.296 + <handler event="click" phase="capturing"> 1.297 + <![CDATA[ 1.298 + if (event.mozInputSource == Ci.nsIDOMMouseEvent.MOZ_SOURCE_TOUCH) { 1.299 + if (typeof SelectionHelperUI != 'undefined') { 1.300 + SelectionHelperUI.attachEditSession(ChromeSelectionHandler, 1.301 + event.clientX, event.clientY, event.target); 1.302 + } else { 1.303 + // If we don't have access to SelectionHelperUI then we are using this 1.304 + // binding for browser content (e.g. about:config) 1.305 + Services.obs.notifyObservers(event, "attach_edit_session_to_content", ""); 1.306 + } 1.307 + } 1.308 + ]]> 1.309 + </handler> 1.310 + </handlers> 1.311 + </binding> 1.312 + 1.313 + <binding id="line-wrap-label" extends="chrome://global/content/bindings/text.xml#text-label"> 1.314 + <implementation> 1.315 + <constructor> 1.316 + <![CDATA[ 1.317 + if (this.hasAttribute("value")) { 1.318 + this.textContent = this.getAttribute("value"); 1.319 + this.removeAttribute("value"); 1.320 + } 1.321 + ]]> 1.322 + </constructor> 1.323 + <property name="value"> 1.324 + <getter> 1.325 + <![CDATA[ 1.326 + return this.textContent; 1.327 + ]]> 1.328 + </getter> 1.329 + <setter> 1.330 + <![CDATA[ 1.331 + return (this.textContent = val); 1.332 + ]]> 1.333 + </setter> 1.334 + </property> 1.335 + </implementation> 1.336 + </binding> 1.337 + <binding id="line-wrap-text-link" extends="chrome://global/content/bindings/text.xml#text-link"> 1.338 + <implementation> 1.339 + <constructor> 1.340 + <![CDATA[ 1.341 + if (this.hasAttribute("value")) { 1.342 + this.textContent = this.getAttribute("value"); 1.343 + this.removeAttribute("value"); 1.344 + } 1.345 + ]]> 1.346 + </constructor> 1.347 + <property name="value"> 1.348 + <getter> 1.349 + <![CDATA[ 1.350 + return this.textContent; 1.351 + ]]> 1.352 + </getter> 1.353 + <setter> 1.354 + <![CDATA[ 1.355 + return (this.textContent = val); 1.356 + ]]> 1.357 + </setter> 1.358 + </property> 1.359 + </implementation> 1.360 + </binding> 1.361 + 1.362 +</bindings>