browser/metro/base/content/bindings/bindings.xml

Wed, 31 Dec 2014 06:09:35 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:09:35 +0100
changeset 0
6474c204b198
permissions
-rw-r--r--

Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.

michael@0 1 <?xml version="1.0"?>
michael@0 2 <!-- This Source Code Form is subject to the terms of the Mozilla Public
michael@0 3 - License, v. 2.0. If a copy of the MPL was not distributed with this
michael@0 4 - file, You can obtain one at http://mozilla.org/MPL/2.0/. -->
michael@0 5
michael@0 6
michael@0 7 <!DOCTYPE bindings [
michael@0 8 <!ENTITY % browserDTD SYSTEM "chrome://browser/locale/browser.dtd">
michael@0 9 %browserDTD;
michael@0 10 ]>
michael@0 11
michael@0 12 <bindings
michael@0 13 xmlns="http://www.mozilla.org/xbl"
michael@0 14 xmlns:xbl="http://www.mozilla.org/xbl"
michael@0 15 xmlns:svg="http://www.w3.org/2000/svg"
michael@0 16 xmlns:html="http://www.w3.org/1999/xhtml"
michael@0 17 xmlns:xul="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
michael@0 18
michael@0 19 <binding id="richlistbox-batch" extends="chrome://global/content/bindings/richlistbox.xml#richlistbox">
michael@0 20 <handlers>
michael@0 21 <handler event="scroll">
michael@0 22 <![CDATA[
michael@0 23 // if there no more items to insert, just return early
michael@0 24 if (this._items.length == 0)
michael@0 25 return;
michael@0 26
michael@0 27 if (this._contentScrollHeight == -1) {
michael@0 28 let scrollheight = {};
michael@0 29 this.scrollBoxObject.getScrolledSize({}, scrollheight);
michael@0 30 this._contentScrollHeight = scrollheight.value;
michael@0 31 }
michael@0 32
michael@0 33 let y = {};
michael@0 34 this.scrollBoxObject.getPosition({}, y);
michael@0 35 let scrollRatio = (y.value + this._childrenHeight) / this._contentScrollHeight;
michael@0 36
michael@0 37 // If we're scrolled 80% to the bottom of the list, append the next
michael@0 38 // set of items
michael@0 39 if (scrollRatio > 0.8)
michael@0 40 this._insertItems();
michael@0 41 ]]>
michael@0 42 </handler>
michael@0 43 </handlers>
michael@0 44 <implementation>
michael@0 45 <!-- Number of elements to add to the list initially. If there are more
michael@0 46 than this many elements to display, only add them to the list once
michael@0 47 the user has scrolled towards them. This is a performance
michael@0 48 optimization to avoid locking up while attempting to append hundreds
michael@0 49 of nodes to our richlistbox.
michael@0 50 -->
michael@0 51 <property name="batchSize" readonly="true" onget="return this.getAttribute('batch')"/>
michael@0 52
michael@0 53 <field name="_childrenHeight">this.scrollBoxObject.height;</field>
michael@0 54 <field name="_items">[]</field>
michael@0 55
michael@0 56 <method name="setItems">
michael@0 57 <parameter name="aItems"/>
michael@0 58 <body><![CDATA[
michael@0 59 this._items = aItems;
michael@0 60 this._insertItems();
michael@0 61 ]]></body>
michael@0 62 </method>
michael@0 63
michael@0 64 <method name="_insertItems">
michael@0 65 <body><![CDATA[
michael@0 66 let items = this._items.splice(0, this.batchSize);
michael@0 67 if (!items.length)
michael@0 68 return; // no items to insert
michael@0 69
michael@0 70 let count = items.length;
michael@0 71 for (let i = 0; i<count; i++)
michael@0 72 this.appendChild(items[i]);
michael@0 73
michael@0 74
michael@0 75 // make sure we recalculate the scrollHeight of the content
michael@0 76 this._contentScrollHeight = -1;
michael@0 77 ]]></body>
michael@0 78 </method>
michael@0 79 </implementation>
michael@0 80 </binding>
michael@0 81
michael@0 82 <binding id="richlistbox-contextmenu" extends="chrome://global/content/bindings/richlistbox.xml#richlistbox">
michael@0 83 <handlers>
michael@0 84 <handler event="click" phase="bubble">
michael@0 85 <![CDATA[
michael@0 86 ContextMenuUI.hide();
michael@0 87 ]]>
michael@0 88 </handler>
michael@0 89 </handlers>
michael@0 90 </binding>
michael@0 91
michael@0 92 <binding id="richlistitem" extends="chrome://global/content/bindings/richlistbox.xml#richlistitem">
michael@0 93 <handlers>
michael@0 94 <handler event="mousedown" phase="capturing">
michael@0 95 <![CDATA[
michael@0 96 // We'll get this if the user is interacting via the mouse
michael@0 97 let domUtils = Components.classes["@mozilla.org/inspector/dom-utils;1"].
michael@0 98 getService(Ci.inIDOMUtils);
michael@0 99 domUtils.setContentState(this, 0x00000001);
michael@0 100 ]]>
michael@0 101 </handler>
michael@0 102 <handler event="click" phase="capturing">
michael@0 103 <![CDATA[
michael@0 104 // allow normal mouse event processing
michael@0 105 if (!InputSourceHelper || InputSourceHelper.isPrecise)
michael@0 106 return;
michael@0 107 // trap this here, we'll rely on tap events
michael@0 108 // event.stopPropagation();
michael@0 109 ]]>
michael@0 110 </handler>
michael@0 111 <handler event="touchstart" phase="capturing">
michael@0 112 <![CDATA[
michael@0 113 // touch input event
michael@0 114 let domUtils = Components.classes["@mozilla.org/inspector/dom-utils;1"].
michael@0 115 getService(Ci.inIDOMUtils);
michael@0 116 domUtils.setContentState(this, 0x00000001);
michael@0 117 ]]>
michael@0 118 </handler>
michael@0 119 </handlers>
michael@0 120 </binding>
michael@0 121
michael@0 122 <binding id="menulist" display="xul:box" extends="chrome://global/content/bindings/menulist.xml#menulist">
michael@0 123 <handlers>
michael@0 124 <handler event="mousedown" phase="capturing">
michael@0 125 <![CDATA[
michael@0 126 // Stop the normal menupopup from appearing
michael@0 127 event.stopPropagation();
michael@0 128 ]]>
michael@0 129 </handler>
michael@0 130
michael@0 131 <handler event="click" button="0">
michael@0 132 <![CDATA[
michael@0 133 if (this.disabled || this.itemCount == 0)
michael@0 134 return;
michael@0 135
michael@0 136 this.focus();
michael@0 137 MenuControlUI.show(this);
michael@0 138 ]]>
michael@0 139 </handler>
michael@0 140
michael@0 141 <handler event="command" phase="capturing">
michael@0 142 <![CDATA[
michael@0 143 // The dropmark (button) fires a command event too. Don't forward that.
michael@0 144 // Just forward the menuitem command events, which the toolkit version does.
michael@0 145 if (event.target.parentNode.parentNode != this)
michael@0 146 event.stopPropagation();
michael@0 147 ]]>
michael@0 148 </handler>
michael@0 149 </handlers>
michael@0 150 </binding>
michael@0 151
michael@0 152 <binding id="chrome-select-option">
michael@0 153 <content orient="horizontal" flex="1">
michael@0 154 <xul:image class="chrome-select-option-image" anonid="check"/>
michael@0 155 <xul:label anonid="label" xbl:inherits="value=label"/>
michael@0 156 </content>
michael@0 157
michael@0 158 <implementation>
michael@0 159 <property name="selected">
michael@0 160 <getter>
michael@0 161 <![CDATA[
michael@0 162 return this.hasAttribute("selected");
michael@0 163 ]]>
michael@0 164 </getter>
michael@0 165 <setter>
michael@0 166 <![CDATA[
michael@0 167 if (val)
michael@0 168 this.setAttribute("selected", "true");
michael@0 169 else
michael@0 170 this.removeAttribute("selected");
michael@0 171 return val;
michael@0 172 ]]>
michael@0 173 </setter>
michael@0 174 </property>
michael@0 175 </implementation>
michael@0 176 </binding>
michael@0 177
michael@0 178 <binding id="select-button" extends="xul:box">
michael@0 179 <content>
michael@0 180 <svg:svg width="11px" version="1.1" xmlns="http://www.w3.org/2000/svg" style="position: absolute; top: -moz-calc(50% - 2px); left: 4px;">
michael@0 181 <svg:polyline points="1 1 5 6 9 1" stroke="#414141" stroke-width="2" stroke-linecap="round" fill="transparent" stroke-linejoin="round"/>
michael@0 182 </svg:svg>
michael@0 183 </content>
michael@0 184 </binding>
michael@0 185
michael@0 186 <binding id="textbox" extends="chrome://global/content/bindings/textbox.xml#textbox">
michael@0 187 <handlers>
michael@0 188 <handler event="contextmenu" phase="capturing">
michael@0 189 <![CDATA[
michael@0 190 let box = this.inputField.parentNode;
michael@0 191 box.showContextMenu(this, event, false);
michael@0 192 ]]>
michael@0 193 </handler>
michael@0 194 <handler event="click" phase="capturing">
michael@0 195 <![CDATA[
michael@0 196 if (event.mozInputSource == Ci.nsIDOMMouseEvent.MOZ_SOURCE_TOUCH) {
michael@0 197 if (typeof SelectionHelperUI != 'undefined') {
michael@0 198 SelectionHelperUI.attachEditSession(ChromeSelectionHandler,
michael@0 199 event.clientX, event.clientY, this);
michael@0 200 } else {
michael@0 201 // If we don't have access to SelectionHelperUI then we are using this
michael@0 202 // binding for browser content (e.g. about:config)
michael@0 203 Services.obs.notifyObservers(event, "attach_edit_session_to_content", "");
michael@0 204 }
michael@0 205 }
michael@0 206 ]]>
michael@0 207 </handler>
michael@0 208 </handlers>
michael@0 209 </binding>
michael@0 210
michael@0 211 <binding id="search-textbox" extends="chrome://global/content/bindings/textbox.xml#search-textbox">
michael@0 212 <implementation>
michael@0 213 <field name="_searchClear">
michael@0 214 <![CDATA[
michael@0 215 document.getAnonymousElementByAttribute(this, "class", "textbox-search-clear");
michael@0 216 ]]>
michael@0 217 </field>
michael@0 218 </implementation>
michael@0 219
michael@0 220 <handlers>
michael@0 221 <handler event="contextmenu" phase="capturing">
michael@0 222 <![CDATA[
michael@0 223 let box = this.inputField.parentNode;
michael@0 224 box.showContextMenu(this, event, false);
michael@0 225 ]]>
michael@0 226 </handler>
michael@0 227
michael@0 228 <handler event="text" phase="bubbling"><![CDATA[
michael@0 229 // Listen for composition update, some VKB that does suggestions does not
michael@0 230 // update directly the content of the field but in this case we want to
michael@0 231 // search as soon as something is entered in the field
michael@0 232 let evt = document.createEvent("Event");
michael@0 233 evt.initEvent("input", true, false);
michael@0 234 this.dispatchEvent(evt);
michael@0 235 ]]></handler>
michael@0 236
michael@0 237 <handler event="click" phase="bubbling"><![CDATA[
michael@0 238 // bug 629661. To reset the autosuggestions mechanism of Android, the
michael@0 239 // textfield need to reset the IME state
michael@0 240 if (event.originalTarget == this._searchClear) {
michael@0 241 setTimeout(function(self) {
michael@0 242 try {
michael@0 243 let imeEditor = self.inputField.QueryInterface(Ci.nsIDOMNSEditableElement)
michael@0 244 .editor
michael@0 245 .QueryInterface(Ci.nsIEditorIMESupport);
michael@0 246 if (imeEditor.composing)
michael@0 247 imeEditor.forceCompositionEnd();
michael@0 248 } catch(e) {}
michael@0 249 }, 0, this);
michael@0 250 }
michael@0 251 ]]></handler>
michael@0 252 </handlers>
michael@0 253 </binding>
michael@0 254
michael@0 255 <binding id="input-box" extends="xul:box">
michael@0 256 <implementation>
michael@0 257 <method name="showContextMenu">
michael@0 258 <parameter name="aTextbox"/>
michael@0 259 <parameter name="aEvent"/>
michael@0 260 <parameter name="aIgnoreReadOnly"/>
michael@0 261 <body><![CDATA[
michael@0 262 let selectionStart = aTextbox.selectionStart;
michael@0 263 let selectionEnd = aTextbox.selectionEnd;
michael@0 264
michael@0 265 let json = { types: ["input-text"], string: "" };
michael@0 266 if (selectionStart != selectionEnd) {
michael@0 267 json.types.push("cut");
michael@0 268 json.types.push("copy");
michael@0 269 }
michael@0 270
michael@0 271 if (selectionStart > 0 || selectionEnd < aTextbox.textLength)
michael@0 272 json.types.push("select-all");
michael@0 273
michael@0 274 let clipboard = Components.classes["@mozilla.org/widget/clipboard;1"].
michael@0 275 getService(Ci.nsIClipboard);
michael@0 276 let flavors = ["text/unicode"];
michael@0 277 let hasData = clipboard.hasDataMatchingFlavors(flavors, flavors.length, Ci.nsIClipboard.kGlobalClipboard);
michael@0 278
michael@0 279 if (hasData && (!aTextbox.readOnly || aIgnoreReadOnly)) {
michael@0 280 json.types.push("paste");
michael@0 281 if (aTextbox.type == "url") {
michael@0 282 json.types.push("paste-url");
michael@0 283 }
michael@0 284 }
michael@0 285 json.xPos = aEvent.clientX;
michael@0 286 json.yPos = aEvent.clientY;
michael@0 287 json.source = aEvent.mozInputSource;
michael@0 288 ContextMenuUI.showContextMenu({ target: aTextbox, json: json });
michael@0 289 ]]></body>
michael@0 290 </method>
michael@0 291 </implementation>
michael@0 292 <handlers>
michael@0 293 <handler event="click" phase="capturing">
michael@0 294 <![CDATA[
michael@0 295 if (event.mozInputSource == Ci.nsIDOMMouseEvent.MOZ_SOURCE_TOUCH) {
michael@0 296 if (typeof SelectionHelperUI != 'undefined') {
michael@0 297 SelectionHelperUI.attachEditSession(ChromeSelectionHandler,
michael@0 298 event.clientX, event.clientY, event.target);
michael@0 299 } else {
michael@0 300 // If we don't have access to SelectionHelperUI then we are using this
michael@0 301 // binding for browser content (e.g. about:config)
michael@0 302 Services.obs.notifyObservers(event, "attach_edit_session_to_content", "");
michael@0 303 }
michael@0 304 }
michael@0 305 ]]>
michael@0 306 </handler>
michael@0 307 </handlers>
michael@0 308 </binding>
michael@0 309
michael@0 310 <binding id="line-wrap-label" extends="chrome://global/content/bindings/text.xml#text-label">
michael@0 311 <implementation>
michael@0 312 <constructor>
michael@0 313 <![CDATA[
michael@0 314 if (this.hasAttribute("value")) {
michael@0 315 this.textContent = this.getAttribute("value");
michael@0 316 this.removeAttribute("value");
michael@0 317 }
michael@0 318 ]]>
michael@0 319 </constructor>
michael@0 320 <property name="value">
michael@0 321 <getter>
michael@0 322 <![CDATA[
michael@0 323 return this.textContent;
michael@0 324 ]]>
michael@0 325 </getter>
michael@0 326 <setter>
michael@0 327 <![CDATA[
michael@0 328 return (this.textContent = val);
michael@0 329 ]]>
michael@0 330 </setter>
michael@0 331 </property>
michael@0 332 </implementation>
michael@0 333 </binding>
michael@0 334 <binding id="line-wrap-text-link" extends="chrome://global/content/bindings/text.xml#text-link">
michael@0 335 <implementation>
michael@0 336 <constructor>
michael@0 337 <![CDATA[
michael@0 338 if (this.hasAttribute("value")) {
michael@0 339 this.textContent = this.getAttribute("value");
michael@0 340 this.removeAttribute("value");
michael@0 341 }
michael@0 342 ]]>
michael@0 343 </constructor>
michael@0 344 <property name="value">
michael@0 345 <getter>
michael@0 346 <![CDATA[
michael@0 347 return this.textContent;
michael@0 348 ]]>
michael@0 349 </getter>
michael@0 350 <setter>
michael@0 351 <![CDATA[
michael@0 352 return (this.textContent = val);
michael@0 353 ]]>
michael@0 354 </setter>
michael@0 355 </property>
michael@0 356 </implementation>
michael@0 357 </binding>
michael@0 358
michael@0 359 </bindings>

mercurial