toolkit/content/widgets/browser.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
michael@0 3 <!-- This Source Code Form is subject to the terms of the Mozilla Public
michael@0 4 - License, v. 2.0. If a copy of the MPL was not distributed with this
michael@0 5 - file, You can obtain one at http://mozilla.org/MPL/2.0/. -->
michael@0 6
michael@0 7 <!DOCTYPE bindings [
michael@0 8 <!ENTITY % findBarDTD SYSTEM "chrome://global/locale/findbar.dtd" >
michael@0 9 %findBarDTD;
michael@0 10 ]>
michael@0 11
michael@0 12 <bindings id="browserBindings"
michael@0 13 xmlns="http://www.mozilla.org/xbl"
michael@0 14 xmlns:xul="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
michael@0 15
michael@0 16 <binding id="browser" extends="xul:browser" role="outerdoc">
michael@0 17 <content clickthrough="never">
michael@0 18 <children/>
michael@0 19 </content>
michael@0 20 <implementation type="application/javascript" implements="nsIObserver, nsIDOMEventListener, nsIFrameRequestCallback, nsIMessageListener">
michael@0 21 <property name="autoscrollEnabled">
michael@0 22 <getter>
michael@0 23 <![CDATA[
michael@0 24 if (this.getAttribute("autoscroll") == "false")
michael@0 25 return false;
michael@0 26
michael@0 27 var enabled = true;
michael@0 28 try {
michael@0 29 enabled = this.mPrefs.getBoolPref("general.autoScroll");
michael@0 30 }
michael@0 31 catch(ex) {
michael@0 32 }
michael@0 33
michael@0 34 return enabled;
michael@0 35 ]]>
michael@0 36 </getter>
michael@0 37 </property>
michael@0 38
michael@0 39 <property name="canGoBack"
michael@0 40 onget="return this.webNavigation.canGoBack;"
michael@0 41 readonly="true"/>
michael@0 42
michael@0 43 <property name="canGoForward"
michael@0 44 onget="return this.webNavigation.canGoForward;"
michael@0 45 readonly="true"/>
michael@0 46
michael@0 47 <method name="goBack">
michael@0 48 <body>
michael@0 49 <![CDATA[
michael@0 50 var webNavigation = this.webNavigation;
michael@0 51 if (webNavigation.canGoBack) {
michael@0 52 try {
michael@0 53 this.userTypedClear++;
michael@0 54 webNavigation.goBack();
michael@0 55 } finally {
michael@0 56 if (this.userTypedClear)
michael@0 57 this.userTypedClear--;
michael@0 58 }
michael@0 59 }
michael@0 60 ]]>
michael@0 61 </body>
michael@0 62 </method>
michael@0 63
michael@0 64 <method name="goForward">
michael@0 65 <body>
michael@0 66 <![CDATA[
michael@0 67 var webNavigation = this.webNavigation;
michael@0 68 if (webNavigation.canGoForward) {
michael@0 69 try {
michael@0 70 this.userTypedClear++;
michael@0 71 webNavigation.goForward();
michael@0 72 } finally {
michael@0 73 if (this.userTypedClear)
michael@0 74 this.userTypedClear--;
michael@0 75 }
michael@0 76 }
michael@0 77 ]]>
michael@0 78 </body>
michael@0 79 </method>
michael@0 80
michael@0 81 <method name="reload">
michael@0 82 <body>
michael@0 83 <![CDATA[
michael@0 84 const nsIWebNavigation = Components.interfaces.nsIWebNavigation;
michael@0 85 const flags = nsIWebNavigation.LOAD_FLAGS_NONE;
michael@0 86 this.reloadWithFlags(flags);
michael@0 87 ]]>
michael@0 88 </body>
michael@0 89 </method>
michael@0 90
michael@0 91 <method name="reloadWithFlags">
michael@0 92 <parameter name="aFlags"/>
michael@0 93 <body>
michael@0 94 <![CDATA[
michael@0 95 this.webNavigation.reload(aFlags);
michael@0 96 ]]>
michael@0 97 </body>
michael@0 98 </method>
michael@0 99
michael@0 100 <method name="stop">
michael@0 101 <body>
michael@0 102 <![CDATA[
michael@0 103 const nsIWebNavigation = Components.interfaces.nsIWebNavigation;
michael@0 104 const flags = nsIWebNavigation.STOP_ALL;
michael@0 105 this.webNavigation.stop(flags);
michael@0 106 ]]>
michael@0 107 </body>
michael@0 108 </method>
michael@0 109
michael@0 110 <!-- throws exception for unknown schemes -->
michael@0 111 <method name="loadURI">
michael@0 112 <parameter name="aURI"/>
michael@0 113 <parameter name="aReferrerURI"/>
michael@0 114 <parameter name="aCharset"/>
michael@0 115 <body>
michael@0 116 <![CDATA[
michael@0 117 const nsIWebNavigation = Components.interfaces.nsIWebNavigation;
michael@0 118 const flags = nsIWebNavigation.LOAD_FLAGS_NONE;
michael@0 119 this.loadURIWithFlags(aURI, flags, aReferrerURI, aCharset);
michael@0 120 ]]>
michael@0 121 </body>
michael@0 122 </method>
michael@0 123
michael@0 124 <!-- throws exception for unknown schemes -->
michael@0 125 <method name="loadURIWithFlags">
michael@0 126 <parameter name="aURI"/>
michael@0 127 <parameter name="aFlags"/>
michael@0 128 <parameter name="aReferrerURI"/>
michael@0 129 <parameter name="aCharset"/>
michael@0 130 <parameter name="aPostData"/>
michael@0 131 <body>
michael@0 132 <![CDATA[
michael@0 133 if (!aURI)
michael@0 134 aURI = "about:blank";
michael@0 135
michael@0 136 if (aCharset) {
michael@0 137 try {
michael@0 138 this.docShell.parentCharset = aCharset;
michael@0 139 }
michael@0 140 catch (e) {
michael@0 141 }
michael@0 142 }
michael@0 143
michael@0 144 if (!(aFlags & this.webNavigation.LOAD_FLAGS_FROM_EXTERNAL))
michael@0 145 this.userTypedClear++;
michael@0 146
michael@0 147 try {
michael@0 148 this.webNavigation.loadURI(aURI, aFlags, aReferrerURI, aPostData, null);
michael@0 149 } finally {
michael@0 150 if (this.userTypedClear)
michael@0 151 this.userTypedClear--;
michael@0 152 }
michael@0 153 ]]>
michael@0 154 </body>
michael@0 155 </method>
michael@0 156
michael@0 157 <method name="goHome">
michael@0 158 <body>
michael@0 159 <![CDATA[
michael@0 160 try {
michael@0 161 this.loadURI(this.homePage);
michael@0 162 }
michael@0 163 catch (e) {
michael@0 164 }
michael@0 165 ]]>
michael@0 166 </body>
michael@0 167 </method>
michael@0 168
michael@0 169 <property name="homePage">
michael@0 170 <getter>
michael@0 171 <![CDATA[
michael@0 172 var uri;
michael@0 173
michael@0 174 if (this.hasAttribute("homepage"))
michael@0 175 uri = this.getAttribute("homepage");
michael@0 176 else
michael@0 177 uri = "http://www.mozilla.org/"; // widget pride
michael@0 178
michael@0 179 return uri;
michael@0 180 ]]>
michael@0 181 </getter>
michael@0 182 <setter>
michael@0 183 <![CDATA[
michael@0 184 this.setAttribute("homepage", val);
michael@0 185 return val;
michael@0 186 ]]>
michael@0 187 </setter>
michael@0 188 </property>
michael@0 189
michael@0 190 <method name="gotoIndex">
michael@0 191 <parameter name="aIndex"/>
michael@0 192 <body>
michael@0 193 <![CDATA[
michael@0 194 try {
michael@0 195 this.userTypedClear++;
michael@0 196 this.webNavigation.gotoIndex(aIndex);
michael@0 197 } finally {
michael@0 198 if (this.userTypedClear)
michael@0 199 this.userTypedClear--;
michael@0 200 }
michael@0 201 ]]>
michael@0 202 </body>
michael@0 203 </method>
michael@0 204
michael@0 205 <property name="currentURI"
michael@0 206 onget="return this.webNavigation.currentURI;"
michael@0 207 readonly="true"/>
michael@0 208
michael@0 209 <!--
michael@0 210 Used by session restore to ensure that currentURI is set so
michael@0 211 that switch-to-tab works before the tab is fully
michael@0 212 restored. This function also invokes onLocationChanged
michael@0 213 listeners in tabbrowser.xml.
michael@0 214 -->
michael@0 215 <method name="_setCurrentURI">
michael@0 216 <parameter name="aURI"/>
michael@0 217 <body><![CDATA[
michael@0 218 this.docShell.setCurrentURI(aURI);
michael@0 219 ]]></body>
michael@0 220 </method>
michael@0 221
michael@0 222 <property name="documentURI"
michael@0 223 onget="return this.contentDocument.documentURIObject;"
michael@0 224 readonly="true"/>
michael@0 225
michael@0 226 <property name="documentContentType"
michael@0 227 onget="return this.contentDocument ? this.contentDocument.contentType : null;"
michael@0 228 readonly="true"/>
michael@0 229
michael@0 230 <property name="preferences"
michael@0 231 onget="return this.mPrefs.QueryInterface(Components.interfaces.nsIPrefService);"
michael@0 232 readonly="true"/>
michael@0 233
michael@0 234 <field name="_docShell">null</field>
michael@0 235
michael@0 236 <property name="docShell" readonly="true">
michael@0 237 <getter><![CDATA[
michael@0 238 if (this._docShell)
michael@0 239 return this._docShell;
michael@0 240
michael@0 241 let frameLoader = this.QueryInterface(Components.interfaces.nsIFrameLoaderOwner).frameLoader;
michael@0 242 if (!frameLoader)
michael@0 243 return null;
michael@0 244 this._docShell = frameLoader.docShell;
michael@0 245 return this._docShell;
michael@0 246 ]]></getter>
michael@0 247 </property>
michael@0 248
michael@0 249 <field name="_loadContext">null</field>
michael@0 250
michael@0 251 <property name="loadContext" readonly="true">
michael@0 252 <getter><![CDATA[
michael@0 253 if (this._loadContext)
michael@0 254 return this._loadContext;
michael@0 255
michael@0 256 let frameLoader = this.QueryInterface(Components.interfaces.nsIFrameLoaderOwner).frameLoader;
michael@0 257 if (!frameLoader)
michael@0 258 return null;
michael@0 259 this._loadContext = frameLoader.loadContext;
michael@0 260 return this._loadContext;
michael@0 261 ]]></getter>
michael@0 262 </property>
michael@0 263
michael@0 264 <property name="docShellIsActive">
michael@0 265 <getter>
michael@0 266 <![CDATA[
michael@0 267 return this.docShell && this.docShell.isActive;
michael@0 268 ]]>
michael@0 269 </getter>
michael@0 270 <setter>
michael@0 271 <![CDATA[
michael@0 272 if (this.docShell)
michael@0 273 return this.docShell.isActive = val;
michael@0 274 return false;
michael@0 275 ]]>
michael@0 276 </setter>
michael@0 277 </property>
michael@0 278
michael@0 279 <property name="imageDocument"
michael@0 280 readonly="true">
michael@0 281 <getter>
michael@0 282 <![CDATA[
michael@0 283 var document = this.contentDocument;
michael@0 284 if (!document || !(document instanceof Ci.nsIImageDocument))
michael@0 285 return null;
michael@0 286
michael@0 287 try {
michael@0 288 return {width: document.imageRequest.image.width, height: document.imageRequest.image.height };
michael@0 289 } catch (e) {}
michael@0 290 return null;
michael@0 291 ]]>
michael@0 292 </getter>
michael@0 293 </property>
michael@0 294
michael@0 295 <property name="isRemoteBrowser"
michael@0 296 onget="return (this.getAttribute('remote') == 'true');"
michael@0 297 readonly="true"/>
michael@0 298
michael@0 299 <property name="messageManager"
michael@0 300 onget="return this.QueryInterface(Components.interfaces.nsIFrameLoaderOwner).frameLoader.messageManager;"
michael@0 301 readonly="true"/>
michael@0 302
michael@0 303 <field name="_webNavigation">null</field>
michael@0 304
michael@0 305 <property name="webNavigation"
michael@0 306 readonly="true">
michael@0 307 <getter>
michael@0 308 <![CDATA[
michael@0 309 if (!this._webNavigation)
michael@0 310 this._webNavigation = this.docShell.QueryInterface(Components.interfaces.nsIWebNavigation);
michael@0 311 return this._webNavigation;
michael@0 312 ]]>
michael@0 313 </getter>
michael@0 314 </property>
michael@0 315
michael@0 316 <field name="_webBrowserFind">null</field>
michael@0 317
michael@0 318 <property name="webBrowserFind"
michael@0 319 readonly="true">
michael@0 320 <getter>
michael@0 321 <![CDATA[
michael@0 322 if (!this._webBrowserFind)
michael@0 323 this._webBrowserFind = this.docShell.QueryInterface(Components.interfaces.nsIInterfaceRequestor).getInterface(Components.interfaces.nsIWebBrowserFind);
michael@0 324 return this._webBrowserFind;
michael@0 325 ]]>
michael@0 326 </getter>
michael@0 327 </property>
michael@0 328
michael@0 329 <method name="getTabBrowser">
michael@0 330 <body>
michael@0 331 <![CDATA[
michael@0 332 var tabBrowser = this.parentNode;
michael@0 333 while (tabBrowser && tabBrowser.localName != "tabbrowser")
michael@0 334 tabBrowser = tabBrowser.parentNode;
michael@0 335 return tabBrowser;
michael@0 336 ]]>
michael@0 337 </body>
michael@0 338 </method>
michael@0 339
michael@0 340 <field name="_finder">null</field>
michael@0 341
michael@0 342 <property name="finder" readonly="true">
michael@0 343 <getter><![CDATA[
michael@0 344 if (!this._finder) {
michael@0 345 if (!this.docShell)
michael@0 346 return null;
michael@0 347
michael@0 348 let Finder = Components.utils.import("resource://gre/modules/Finder.jsm", {}).Finder;
michael@0 349 this._finder = new Finder(this.docShell);
michael@0 350 }
michael@0 351 return this._finder;
michael@0 352 ]]></getter>
michael@0 353 </property>
michael@0 354
michael@0 355 <field name="_fastFind">null</field>
michael@0 356 <property name="fastFind" readonly="true">
michael@0 357 <getter><![CDATA[
michael@0 358 if (!this._fastFind) {
michael@0 359 if (!("@mozilla.org/typeaheadfind;1" in Components.classes))
michael@0 360 return null;
michael@0 361
michael@0 362 var tabBrowser = this.getTabBrowser();
michael@0 363 if (tabBrowser && "fastFind" in tabBrowser)
michael@0 364 return this._fastFind = tabBrowser.fastFind;
michael@0 365
michael@0 366 if (!this.docShell)
michael@0 367 return null;
michael@0 368
michael@0 369 this._fastFind = Components.classes["@mozilla.org/typeaheadfind;1"]
michael@0 370 .createInstance(Components.interfaces.nsITypeAheadFind);
michael@0 371 this._fastFind.init(this.docShell);
michael@0 372 }
michael@0 373 return this._fastFind;
michael@0 374 ]]></getter>
michael@0 375 </property>
michael@0 376
michael@0 377 <field name="_permanentKey">({})</field>
michael@0 378
michael@0 379 <property name="permanentKey" readonly="true"
michael@0 380 onget="return this._permanentKey;"/>
michael@0 381
michael@0 382 <field name="_lastSearchString">null</field>
michael@0 383 <field name="_lastSearchHighlight">false</field>
michael@0 384
michael@0 385 <property name="webProgress"
michael@0 386 readonly="true"
michael@0 387 onget="return this.docShell.QueryInterface(Components.interfaces.nsIInterfaceRequestor).getInterface(Components.interfaces.nsIWebProgress);"/>
michael@0 388
michael@0 389 <field name="_contentWindow">null</field>
michael@0 390
michael@0 391 <property name="contentWindow"
michael@0 392 readonly="true"
michael@0 393 onget="return this._contentWindow || (this._contentWindow = this.docShell.QueryInterface(Components.interfaces.nsIInterfaceRequestor).getInterface(Components.interfaces.nsIDOMWindow));"/>
michael@0 394
michael@0 395 <property name="sessionHistory"
michael@0 396 onget="return this.webNavigation.sessionHistory;"
michael@0 397 readonly="true"/>
michael@0 398
michael@0 399 <property name="markupDocumentViewer"
michael@0 400 onget="return this.docShell.contentViewer.QueryInterface(Components.interfaces.nsIMarkupDocumentViewer);"
michael@0 401 readonly="true"/>
michael@0 402
michael@0 403 <property name="contentViewerEdit"
michael@0 404 onget="return this.docShell.contentViewer.QueryInterface(Components.interfaces.nsIContentViewerEdit);"
michael@0 405 readonly="true"/>
michael@0 406
michael@0 407 <property name="contentViewerFile"
michael@0 408 onget="return this.docShell.contentViewer.QueryInterface(Components.interfaces.nsIContentViewerFile);"
michael@0 409 readonly="true"/>
michael@0 410
michael@0 411 <property name="contentDocument"
michael@0 412 onget="return this.webNavigation.document;"
michael@0 413 readonly="true"/>
michael@0 414
michael@0 415 <property name="contentTitle"
michael@0 416 onget="return this.contentDocument.title;"
michael@0 417 readonly="true"/>
michael@0 418
michael@0 419 <property name="characterSet"
michael@0 420 onget="return this.contentDocument.characterSet;"
michael@0 421 readonly="true"/>
michael@0 422
michael@0 423 <property name="contentPrincipal"
michael@0 424 onget="return this.contentDocument.nodePrincipal;"
michael@0 425 readonly="true"/>
michael@0 426
michael@0 427 <property name="showWindowResizer"
michael@0 428 onset="if (val) this.setAttribute('showresizer', 'true');
michael@0 429 else this.removeAttribute('showresizer');
michael@0 430 return val;"
michael@0 431 onget="return this.getAttribute('showresizer') == 'true';"/>
michael@0 432
michael@0 433
michael@0 434 <property name="fullZoom">
michael@0 435 <getter><![CDATA[
michael@0 436 return this.markupDocumentViewer.fullZoom;
michael@0 437 ]]></getter>
michael@0 438 <setter><![CDATA[
michael@0 439 this.markupDocumentViewer.fullZoom = val;
michael@0 440 ]]></setter>
michael@0 441 </property>
michael@0 442
michael@0 443 <property name="textZoom">
michael@0 444 <getter><![CDATA[
michael@0 445 return this.markupDocumentViewer.textZoom;
michael@0 446 ]]></getter>
michael@0 447 <setter><![CDATA[
michael@0 448 this.markupDocumentViewer.textZoom = val;
michael@0 449 ]]></setter>
michael@0 450 </property>
michael@0 451
michael@0 452 <property name="isSyntheticDocument">
michael@0 453 <getter><![CDATA[
michael@0 454 return this.contentDocument.mozSyntheticDocument;
michael@0 455 ]]></getter>
michael@0 456 </property>
michael@0 457
michael@0 458 <field name="mPrefs" readonly="true">
michael@0 459 Components.classes['@mozilla.org/preferences-service;1']
michael@0 460 .getService(Components.interfaces.nsIPrefBranch);
michael@0 461 </field>
michael@0 462
michael@0 463 <field name="mAtomService" readonly="true">
michael@0 464 Components.classes['@mozilla.org/atom-service;1']
michael@0 465 .getService(Components.interfaces.nsIAtomService);
michael@0 466 </field>
michael@0 467
michael@0 468 <field name="_mStrBundle">null</field>
michael@0 469
michael@0 470 <property name="mStrBundle">
michael@0 471 <getter>
michael@0 472 <![CDATA[
michael@0 473 if (!this._mStrBundle) {
michael@0 474 // need to create string bundle manually instead of using <xul:stringbundle/>
michael@0 475 // see bug 63370 for details
michael@0 476 this._mStrBundle = Components.classes["@mozilla.org/intl/stringbundle;1"]
michael@0 477 .getService(Components.interfaces.nsIStringBundleService)
michael@0 478 .createBundle("chrome://global/locale/browser.properties");
michael@0 479 }
michael@0 480 return this._mStrBundle;
michael@0 481 ]]></getter>
michael@0 482 </property>
michael@0 483
michael@0 484 <method name="addProgressListener">
michael@0 485 <parameter name="aListener"/>
michael@0 486 <parameter name="aNotifyMask"/>
michael@0 487 <body>
michael@0 488 <![CDATA[
michael@0 489 if (!aNotifyMask) {
michael@0 490 aNotifyMask = Components.interfaces.nsIWebProgress.NOTIFY_ALL;
michael@0 491 }
michael@0 492 this.webProgress.addProgressListener(aListener, aNotifyMask);
michael@0 493 ]]>
michael@0 494 </body>
michael@0 495 </method>
michael@0 496
michael@0 497 <method name="removeProgressListener">
michael@0 498 <parameter name="aListener"/>
michael@0 499 <body>
michael@0 500 <![CDATA[
michael@0 501 this.webProgress.removeProgressListener(aListener);
michael@0 502 ]]>
michael@0 503 </body>
michael@0 504 </method>
michael@0 505
michael@0 506 <method name="attachFormFill">
michael@0 507 <body>
michael@0 508 <![CDATA[
michael@0 509 if (!this.mFormFillAttached && this.hasAttribute("autocompletepopup")) {
michael@0 510 // hoop up the form fill autocomplete controller
michael@0 511 var controller = Components.classes["@mozilla.org/satchel/form-fill-controller;1"].
michael@0 512 getService(Components.interfaces.nsIFormFillController);
michael@0 513
michael@0 514 var popup = document.getElementById(this.getAttribute("autocompletepopup"));
michael@0 515 if (popup) {
michael@0 516 controller.attachToBrowser(this.docShell, popup.QueryInterface(Components.interfaces.nsIAutoCompletePopup));
michael@0 517 this.mFormFillAttached = true;
michael@0 518 }
michael@0 519 }
michael@0 520 ]]>
michael@0 521 </body>
michael@0 522 </method>
michael@0 523
michael@0 524 <method name="detachFormFill">
michael@0 525 <body>
michael@0 526 <![CDATA[
michael@0 527 if (this.mFormFillAttached) {
michael@0 528 // hoop up the form fill autocomplete controller
michael@0 529 var controller = Components.classes["@mozilla.org/satchel/form-fill-controller;1"].
michael@0 530 getService(Components.interfaces.nsIFormFillController);
michael@0 531 controller.detachFromBrowser(this.docShell);
michael@0 532
michael@0 533 this.mFormFillAttached = false;
michael@0 534 }
michael@0 535 ]]>
michael@0 536 </body>
michael@0 537 </method>
michael@0 538
michael@0 539 <method name="findChildShell">
michael@0 540 <parameter name="aDocShell"/>
michael@0 541 <parameter name="aSoughtURI"/>
michael@0 542 <body>
michael@0 543 <![CDATA[
michael@0 544 if (aDocShell.QueryInterface(Components.interfaces.nsIWebNavigation)
michael@0 545 .currentURI.spec == aSoughtURI.spec)
michael@0 546 return aDocShell;
michael@0 547 var node = aDocShell.QueryInterface(
michael@0 548 Components.interfaces.nsIDocShellTreeItem);
michael@0 549 for (var i = 0; i < node.childCount; ++i) {
michael@0 550 var docShell = node.getChildAt(i);
michael@0 551 docShell = this.findChildShell(docShell, aSoughtURI);
michael@0 552 if (docShell)
michael@0 553 return docShell;
michael@0 554 }
michael@0 555 return null;
michael@0 556 ]]>
michael@0 557 </body>
michael@0 558 </method>
michael@0 559
michael@0 560 <method name="onPageShow">
michael@0 561 <parameter name="aEvent"/>
michael@0 562 <body>
michael@0 563 <![CDATA[
michael@0 564 this.attachFormFill();
michael@0 565 ]]>
michael@0 566 </body>
michael@0 567 </method>
michael@0 568
michael@0 569 <method name="onPageHide">
michael@0 570 <parameter name="aEvent"/>
michael@0 571 <body>
michael@0 572 <![CDATA[
michael@0 573 // Delete the feeds cache if we're hiding the topmost page
michael@0 574 // (as opposed to one of its iframes).
michael@0 575 if (this.feeds && aEvent.target == this.contentDocument)
michael@0 576 this.feeds = null;
michael@0 577 if (!this.docShell || !this.fastFind)
michael@0 578 return;
michael@0 579 var tabBrowser = this.getTabBrowser();
michael@0 580 if (!tabBrowser || !("fastFind" in tabBrowser) ||
michael@0 581 tabBrowser.selectedBrowser == this)
michael@0 582 this.fastFind.setDocShell(this.docShell);
michael@0 583 ]]>
michael@0 584 </body>
michael@0 585 </method>
michael@0 586
michael@0 587 <method name="updateBlockedPopups">
michael@0 588 <parameter name="aBlockedPopups"/>
michael@0 589 <parameter name="aFreshPopup"/>
michael@0 590 <body>
michael@0 591 <![CDATA[
michael@0 592 this.blockedPopups = aBlockedPopups;
michael@0 593 if (aFreshPopup) {
michael@0 594 this.blockedPopups.reported = false;
michael@0 595 }
michael@0 596
michael@0 597 var event = document.createEvent("Events");
michael@0 598 event.initEvent("DOMUpdatePageReport", true, true);
michael@0 599 this.dispatchEvent(event);
michael@0 600 ]]>
michael@0 601 </body>
michael@0 602 </method>
michael@0 603
michael@0 604 <method name="unblockPopup">
michael@0 605 <parameter name="aPopupIndex"/>
michael@0 606 <body><![CDATA[
michael@0 607 this.messageManager.sendAsyncMessage("PopupBlocking:UnblockPopup",
michael@0 608 {index: aPopupIndex});
michael@0 609 ]]></body>
michael@0 610 </method>
michael@0 611
michael@0 612 <field name="blockedPopups">null</field>
michael@0 613
michael@0 614 <!-- Obsolete name for blockedPopups. Used by metro and android. -->
michael@0 615 <property name="pageReport"
michael@0 616 onget="return this.blockedPopups;"
michael@0 617 readonly="true"/>
michael@0 618
michael@0 619 <property name="securityUI">
michael@0 620 <getter>
michael@0 621 <![CDATA[
michael@0 622 // Bug 666809 - SecurityUI support for e10s
michael@0 623 if (!this.docShell)
michael@0 624 return null;
michael@0 625
michael@0 626 if (!this.docShell.securityUI) {
michael@0 627 const SECUREBROWSERUI_CONTRACTID = "@mozilla.org/secure_browser_ui;1";
michael@0 628 if (!this.hasAttribute("disablesecurity") &&
michael@0 629 SECUREBROWSERUI_CONTRACTID in Components.classes) {
michael@0 630 var securityUI = Components.classes[SECUREBROWSERUI_CONTRACTID]
michael@0 631 .createInstance(Components.interfaces.nsISecureBrowserUI);
michael@0 632 securityUI.init(this.contentWindow);
michael@0 633 }
michael@0 634 }
michael@0 635
michael@0 636 return this.docShell.securityUI;
michael@0 637 ]]>
michael@0 638 </getter>
michael@0 639 <setter>
michael@0 640 <![CDATA[
michael@0 641 this.docShell.securityUI = val;
michael@0 642 ]]>
michael@0 643 </setter>
michael@0 644 </property>
michael@0 645
michael@0 646 <method name="adjustPriority">
michael@0 647 <parameter name="adjustment"/>
michael@0 648 <body><![CDATA[
michael@0 649 let loadGroup = this.webNavigation.QueryInterface(Ci.nsIDocumentLoader)
michael@0 650 .loadGroup.QueryInterface(Ci.nsISupportsPriority);
michael@0 651 loadGroup.adjustPriority(adjustment);
michael@0 652 ]]></body>
michael@0 653 </method>
michael@0 654
michael@0 655 <!--
michael@0 656 This field tracks the location bar state. The value that the user typed
michael@0 657 in to the location bar may not be changed while this field is zero.
michael@0 658 However invoking a load will temporarily increase this field to allow
michael@0 659 the location bar to be updated to the new URL.
michael@0 660
michael@0 661 Case 1: Anchor scroll
michael@0 662 The user appends the anchor to the URL. This sets the location bar
michael@0 663 into typed state, and disables changes to the location bar. The user
michael@0 664 then requests the scroll. loadURIWithFlags temporarily increases the
michael@0 665 flag by 1 so that the anchor scroll's location change resets the
michael@0 666 location bar state.
michael@0 667
michael@0 668 Case 2: Interrupted load
michael@0 669 The user types in and submits the URL. This triggers an asynchronous
michael@0 670 network load which increases the flag by 2. (The temporary increase
michael@0 671 from loadURIWithFlags is not noticeable in this case.) When the load
michael@0 672 is interrupted the flag returns to zero, and the location bar stays
michael@0 673 in typed state.
michael@0 674
michael@0 675 Case 3: New load
michael@0 676 This works like case 2, but as the load is not interrupted the
michael@0 677 location changes while the flag is still 2 thus resetting the
michael@0 678 location bar state.
michael@0 679
michael@0 680 Case 4: Corrected load
michael@0 681 This is a combination of case 2 and case 3, except that the original
michael@0 682 load is interrupted by the new load. Normally cancelling and starting
michael@0 683 a new load would reset the flag to 0 and then increase it to 2 again.
michael@0 684 However both actions occur as a consequence of the loadURIWithFlags
michael@0 685 invocation, which adds its temporary increase in to the mix. Since
michael@0 686 the new URL would have been typed in the flag would have been reset
michael@0 687 before loadURIWithFlags incremented it. The interruption resets the
michael@0 688 flag to 0 and increases it to 2. Although loadURIWithFlags will
michael@0 689 decrement the flag it remains at 1 thus allowing the location bar
michael@0 690 state to be reset when the new load changes the location.
michael@0 691 This case also applies when loading into a new browser, as this
michael@0 692 interrupts the default load of about:blank.
michael@0 693 -->
michael@0 694 <field name="userTypedClear">
michael@0 695 1
michael@0 696 </field>
michael@0 697
michael@0 698 <field name="_userTypedValue">
michael@0 699 null
michael@0 700 </field>
michael@0 701
michael@0 702 <property name="userTypedValue"
michael@0 703 onget="return this._userTypedValue;">
michael@0 704 <setter><![CDATA[
michael@0 705 this.userTypedClear = 0;
michael@0 706 this._userTypedValue = val;
michael@0 707 return val;
michael@0 708 ]]></setter>
michael@0 709 </property>
michael@0 710
michael@0 711 <field name="mFormFillAttached">
michael@0 712 false
michael@0 713 </field>
michael@0 714
michael@0 715 <field name="isShowingMessage">
michael@0 716 false
michael@0 717 </field>
michael@0 718
michael@0 719 <field name="droppedLinkHandler">
michael@0 720 null
michael@0 721 </field>
michael@0 722
michael@0 723 <field name="mIconURL">null</field>
michael@0 724
michael@0 725 <!-- This is managed by the tabbrowser -->
michael@0 726 <field name="lastURI">null</field>
michael@0 727
michael@0 728 <field name="mDestroyed">false</field>
michael@0 729
michael@0 730 <constructor>
michael@0 731 <![CDATA[
michael@0 732 try {
michael@0 733 // |webNavigation.sessionHistory| will have been set by the frame
michael@0 734 // loader when creating the docShell as long as this xul:browser
michael@0 735 // doesn't have the 'disablehistory' attribute set.
michael@0 736 if (this.docShell && this.webNavigation.sessionHistory) {
michael@0 737 var os = Components.classes["@mozilla.org/observer-service;1"]
michael@0 738 .getService(Components.interfaces.nsIObserverService);
michael@0 739 os.addObserver(this, "browser:purge-session-history", false);
michael@0 740
michael@0 741 // enable global history if we weren't told otherwise
michael@0 742 if (!this.hasAttribute("disableglobalhistory") && !this.isRemoteBrowser) {
michael@0 743 try {
michael@0 744 this.docShell.useGlobalHistory = true;
michael@0 745 } catch(ex) {
michael@0 746 // This can occur if the Places database is locked
michael@0 747 Components.utils.reportError("Error enabling browser global history: " + ex);
michael@0 748 }
michael@0 749 }
michael@0 750 }
michael@0 751 }
michael@0 752 catch (e) {
michael@0 753 Components.utils.reportError(e);
michael@0 754 }
michael@0 755 try {
michael@0 756 var securityUI = this.securityUI;
michael@0 757 }
michael@0 758 catch (e) {
michael@0 759 }
michael@0 760
michael@0 761 // Listen for first load for lazy attachment to form fill controller
michael@0 762 // (But we don't want to do this for remote browsers - the test infra
michael@0 763 // might fire these events when they normally wouldn't.)
michael@0 764 if (!this.isRemoteBrowser) {
michael@0 765 this.addEventListener("pageshow", this.onPageShow, true);
michael@0 766 this.addEventListener("pagehide", this.onPageHide, true);
michael@0 767 }
michael@0 768
michael@0 769 if (this.messageManager) {
michael@0 770 this.messageManager.addMessageListener("PopupBlocking:UpdateBlockedPopups", this);
michael@0 771 this.messageManager.addMessageListener("Autoscroll:Start", this);
michael@0 772 this.messageManager.addMessageListener("Autoscroll:Cancel", this);
michael@0 773 this.messageManager.loadFrameScript("chrome://global/content/browser-content.js", true);
michael@0 774 }
michael@0 775 ]]>
michael@0 776 </constructor>
michael@0 777
michael@0 778 <destructor>
michael@0 779 <![CDATA[
michael@0 780 this.destroy();
michael@0 781 ]]>
michael@0 782 </destructor>
michael@0 783
michael@0 784 <!-- This is necessary because the destructor doesn't always get called when
michael@0 785 we are removed from a tabbrowser. This will be explicitly called by tabbrowser -->
michael@0 786 <method name="destroy">
michael@0 787 <body>
michael@0 788 <![CDATA[
michael@0 789 if (this.mDestroyed)
michael@0 790 return;
michael@0 791 this.mDestroyed = true;
michael@0 792
michael@0 793 if (this.docShell && this.webNavigation.sessionHistory) {
michael@0 794 var os = Components.classes["@mozilla.org/observer-service;1"]
michael@0 795 .getService(Components.interfaces.nsIObserverService);
michael@0 796 try {
michael@0 797 os.removeObserver(this, "browser:purge-session-history");
michael@0 798 } catch (ex) {
michael@0 799 // It's not clear why this sometimes throws an exception.
michael@0 800 }
michael@0 801 }
michael@0 802
michael@0 803 this.detachFormFill();
michael@0 804
michael@0 805 this._fastFind = null;
michael@0 806 this._webBrowserFind = null;
michael@0 807
michael@0 808 // The feeds cache can keep the document inside this browser alive.
michael@0 809 this.feeds = null;
michael@0 810
michael@0 811 this.lastURI = null;
michael@0 812
michael@0 813 if (!this.isRemoteBrowser) {
michael@0 814 this.removeEventListener("pageshow", this.onPageShow, true);
michael@0 815 this.removeEventListener("pagehide", this.onPageHide, true);
michael@0 816 }
michael@0 817
michael@0 818 if (this._autoScrollNeedsCleanup) {
michael@0 819 // we polluted the global scope, so clean it up
michael@0 820 this._autoScrollPopup.parentNode.removeChild(this._autoScrollPopup);
michael@0 821 }
michael@0 822 ]]>
michael@0 823 </body>
michael@0 824 </method>
michael@0 825
michael@0 826 <!--
michael@0 827 We call this _receiveMessage (and alias receiveMessage to it) so that
michael@0 828 bindings that inherit from this one can delegate to it.
michael@0 829 -->
michael@0 830 <method name="_receiveMessage">
michael@0 831 <parameter name="aMessage"/>
michael@0 832 <body><![CDATA[
michael@0 833 let data = aMessage.data;
michael@0 834 switch (aMessage.name) {
michael@0 835 case "PopupBlocking:UpdateBlockedPopups":
michael@0 836 this.updateBlockedPopups(data.blockedPopups, data.freshPopup);
michael@0 837 break;
michael@0 838 case "Autoscroll:Start": {
michael@0 839 if (!this.autoscrollEnabled) {
michael@0 840 return false;
michael@0 841 }
michael@0 842 let pos = this.mapScreenCoordinatesFromContent(data.screenX, data.screenY);
michael@0 843 this.startScroll(data.scrolldir, pos.x, pos.y);
michael@0 844 return true;
michael@0 845 }
michael@0 846 case "Autoscroll:Cancel":
michael@0 847 this._autoScrollPopup.hidePopup();
michael@0 848 break;
michael@0 849 }
michael@0 850 ]]></body>
michael@0 851 </method>
michael@0 852
michael@0 853 <method name="receiveMessage">
michael@0 854 <parameter name="aMessage"/>
michael@0 855 <body><![CDATA[
michael@0 856 return this._receiveMessage(aMessage);
michael@0 857 ]]></body>
michael@0 858 </method>
michael@0 859
michael@0 860 <method name="observe">
michael@0 861 <parameter name="aSubject"/>
michael@0 862 <parameter name="aTopic"/>
michael@0 863 <parameter name="aState"/>
michael@0 864 <body>
michael@0 865 <![CDATA[
michael@0 866 if (aTopic != "browser:purge-session-history" || !this.sessionHistory)
michael@0 867 return;
michael@0 868
michael@0 869 // place the entry at current index at the end of the history list, so it won't get removed
michael@0 870 if (this.sessionHistory.index < this.sessionHistory.count - 1) {
michael@0 871 var indexEntry = this.sessionHistory.getEntryAtIndex(this.sessionHistory.index, false);
michael@0 872 this.sessionHistory.QueryInterface(Components.interfaces.nsISHistoryInternal);
michael@0 873 indexEntry.QueryInterface(Components.interfaces.nsISHEntry);
michael@0 874 this.sessionHistory.addEntry(indexEntry, true);
michael@0 875 }
michael@0 876
michael@0 877 var purge = this.sessionHistory.count;
michael@0 878 if (this.currentURI != "about:blank")
michael@0 879 --purge; // Don't remove the page the user's staring at from shistory
michael@0 880
michael@0 881 if (purge > 0)
michael@0 882 this.sessionHistory.PurgeHistory(purge);
michael@0 883 ]]>
michael@0 884 </body>
michael@0 885 </method>
michael@0 886
michael@0 887 <field name="_AUTOSCROLL_SNAP">10</field>
michael@0 888 <field name="_scrolling">false</field>
michael@0 889 <field name="_startX">null</field>
michael@0 890 <field name="_startY">null</field>
michael@0 891 <field name="_autoScrollPopup">null</field>
michael@0 892 <field name="_autoScrollNeedsCleanup">false</field>
michael@0 893
michael@0 894 <method name="stopScroll">
michael@0 895 <body>
michael@0 896 <![CDATA[
michael@0 897 if (this._scrolling) {
michael@0 898 this._scrolling = false;
michael@0 899 window.removeEventListener("mousemove", this, true);
michael@0 900 window.removeEventListener("mousedown", this, true);
michael@0 901 window.removeEventListener("mouseup", this, true);
michael@0 902 window.removeEventListener("contextmenu", this, true);
michael@0 903 window.removeEventListener("keydown", this, true);
michael@0 904 window.removeEventListener("keypress", this, true);
michael@0 905 window.removeEventListener("keyup", this, true);
michael@0 906 this.messageManager.sendAsyncMessage("Autoscroll:Stop");
michael@0 907 }
michael@0 908 ]]>
michael@0 909 </body>
michael@0 910 </method>
michael@0 911
michael@0 912 <method name="_createAutoScrollPopup">
michael@0 913 <body>
michael@0 914 <![CDATA[
michael@0 915 const XUL_NS = "http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul";
michael@0 916 var popup = document.createElementNS(XUL_NS, "panel");
michael@0 917 popup.className = "autoscroller";
michael@0 918 // We set this attribute on the element so that mousemove
michael@0 919 // events can be handled by browser-content.js.
michael@0 920 popup.setAttribute("mousethrough", "always");
michael@0 921 return popup;
michael@0 922 ]]>
michael@0 923 </body>
michael@0 924 </method>
michael@0 925
michael@0 926 <method name="startScroll">
michael@0 927 <parameter name="scrolldir"/>
michael@0 928 <parameter name="screenX"/>
michael@0 929 <parameter name="screenY"/>
michael@0 930 <body><![CDATA[
michael@0 931 if (!this._autoScrollPopup) {
michael@0 932 if (this.hasAttribute("autoscrollpopup")) {
michael@0 933 // our creator provided a popup to share
michael@0 934 this._autoScrollPopup = document.getElementById(this.getAttribute("autoscrollpopup"));
michael@0 935 }
michael@0 936 else {
michael@0 937 // we weren't provided a popup; we have to use the global scope
michael@0 938 this._autoScrollPopup = this._createAutoScrollPopup();
michael@0 939 document.documentElement.appendChild(this._autoScrollPopup);
michael@0 940 this._autoScrollNeedsCleanup = true;
michael@0 941 }
michael@0 942 }
michael@0 943
michael@0 944 // we need these attributes so themers don't need to create per-platform packages
michael@0 945 if (screen.colorDepth > 8) { // need high color for transparency
michael@0 946 // Exclude second-rate platforms
michael@0 947 this._autoScrollPopup.setAttribute("transparent", !/BeOS|OS\/2/.test(navigator.appVersion));
michael@0 948 // Enable translucency on Windows and Mac
michael@0 949 this._autoScrollPopup.setAttribute("translucent", /Win|Mac/.test(navigator.platform));
michael@0 950 }
michael@0 951
michael@0 952 this._autoScrollPopup.setAttribute("scrolldir", scrolldir);
michael@0 953 this._autoScrollPopup.addEventListener("popuphidden", this, true);
michael@0 954 this._autoScrollPopup.showPopup(document.documentElement,
michael@0 955 screenX,
michael@0 956 screenY,
michael@0 957 "popup", null, null);
michael@0 958 this._ignoreMouseEvents = true;
michael@0 959 this._scrolling = true;
michael@0 960 this._startX = screenX;
michael@0 961 this._startY = screenY;
michael@0 962
michael@0 963 window.addEventListener("mousemove", this, true);
michael@0 964 window.addEventListener("mousedown", this, true);
michael@0 965 window.addEventListener("mouseup", this, true);
michael@0 966 window.addEventListener("contextmenu", this, true);
michael@0 967 window.addEventListener("keydown", this, true);
michael@0 968 window.addEventListener("keypress", this, true);
michael@0 969 window.addEventListener("keyup", this, true);
michael@0 970 ]]>
michael@0 971 </body>
michael@0 972 </method>
michael@0 973
michael@0 974 <method name="handleEvent">
michael@0 975 <parameter name="aEvent"/>
michael@0 976 <body>
michael@0 977 <![CDATA[
michael@0 978 if (this._scrolling) {
michael@0 979 switch(aEvent.type) {
michael@0 980 case "mousemove": {
michael@0 981 var x = aEvent.screenX - this._startX;
michael@0 982 var y = aEvent.screenY - this._startY;
michael@0 983
michael@0 984 if ((x > this._AUTOSCROLL_SNAP || x < -this._AUTOSCROLL_SNAP) ||
michael@0 985 (y > this._AUTOSCROLL_SNAP || y < -this._AUTOSCROLL_SNAP))
michael@0 986 this._ignoreMouseEvents = false;
michael@0 987 break;
michael@0 988 }
michael@0 989 case "mouseup":
michael@0 990 case "mousedown":
michael@0 991 case "contextmenu": {
michael@0 992 if (!this._ignoreMouseEvents)
michael@0 993 this._autoScrollPopup.hidePopup();
michael@0 994 this._ignoreMouseEvents = false;
michael@0 995 break;
michael@0 996 }
michael@0 997 case "popuphidden": {
michael@0 998 this._autoScrollPopup.removeEventListener("popuphidden", this, true);
michael@0 999 this.stopScroll();
michael@0 1000 break;
michael@0 1001 }
michael@0 1002 case "keydown": {
michael@0 1003 if (aEvent.keyCode == aEvent.DOM_VK_ESCAPE) {
michael@0 1004 // the escape key will be processed by
michael@0 1005 // nsXULPopupManager::KeyDown and the panel will be closed.
michael@0 1006 // So, don't consume the key event here.
michael@0 1007 break;
michael@0 1008 }
michael@0 1009 // don't break here. we need to eat keydown events.
michael@0 1010 }
michael@0 1011 case "keypress":
michael@0 1012 case "keyup": {
michael@0 1013 // All keyevents should be eaten here during autoscrolling.
michael@0 1014 aEvent.stopPropagation();
michael@0 1015 aEvent.preventDefault();
michael@0 1016 break;
michael@0 1017 }
michael@0 1018 }
michael@0 1019 }
michael@0 1020 ]]>
michael@0 1021 </body>
michael@0 1022 </method>
michael@0 1023
michael@0 1024 <!--
michael@0 1025 For out-of-process code, event.screen[XY] is relative to the
michael@0 1026 left/top of the content view. For in-process code,
michael@0 1027 event.screen[XY] is relative to the left/top of the screen. We
michael@0 1028 use this method to map screen coordinates received from a
michael@0 1029 (possibly out-of-process) <browser> element to coordinates
michael@0 1030 that are relative to the screen. This code handles the
michael@0 1031 in-process case, where we return the coordinates unchanged.
michael@0 1032 -->
michael@0 1033 <method name="mapScreenCoordinatesFromContent">
michael@0 1034 <parameter name="aScreenX"/>
michael@0 1035 <parameter name="aScreenY"/>
michael@0 1036 <body>
michael@0 1037 <![CDATA[
michael@0 1038 return { x: aScreenX, y: aScreenY };
michael@0 1039 ]]>
michael@0 1040 </body>
michael@0 1041 </method>
michael@0 1042
michael@0 1043 <method name="swapDocShells">
michael@0 1044 <parameter name="aOtherBrowser"/>
michael@0 1045 <body>
michael@0 1046 <![CDATA[
michael@0 1047 // We need to swap fields that are tied to our docshell or related to
michael@0 1048 // the loaded page
michael@0 1049 // Fields which are built as a result of notifactions (pageshow/hide,
michael@0 1050 // DOMLinkAdded/Removed, onStateChange) should not be swapped here,
michael@0 1051 // because these notifications are dispatched again once the docshells
michael@0 1052 // are swapped.
michael@0 1053 var fieldsToSwap = [
michael@0 1054 "_docShell",
michael@0 1055 "_webBrowserFind",
michael@0 1056 "_contentWindow",
michael@0 1057 "_webNavigation",
michael@0 1058 "_permanentKey"
michael@0 1059 ];
michael@0 1060
michael@0 1061 var ourFieldValues = {};
michael@0 1062 var otherFieldValues = {};
michael@0 1063 for each (var field in fieldsToSwap) {
michael@0 1064 ourFieldValues[field] = this[field];
michael@0 1065 otherFieldValues[field] = aOtherBrowser[field];
michael@0 1066 }
michael@0 1067
michael@0 1068 if (window.PopupNotifications)
michael@0 1069 PopupNotifications._swapBrowserNotifications(aOtherBrowser, this);
michael@0 1070
michael@0 1071 this.QueryInterface(Components.interfaces.nsIFrameLoaderOwner)
michael@0 1072 .swapFrameLoaders(aOtherBrowser);
michael@0 1073
michael@0 1074 // Before we swap the actual docShell property we need to detach the
michael@0 1075 // form fill controller from those docShells.
michael@0 1076 this.detachFormFill();
michael@0 1077 aOtherBrowser.detachFormFill();
michael@0 1078
michael@0 1079 for each (var field in fieldsToSwap) {
michael@0 1080 this[field] = otherFieldValues[field];
michael@0 1081 aOtherBrowser[field] = ourFieldValues[field];
michael@0 1082 }
michael@0 1083
michael@0 1084 // Re-attach the docShells to the form fill controller.
michael@0 1085 this.attachFormFill();
michael@0 1086 aOtherBrowser.attachFormFill();
michael@0 1087
michael@0 1088 // Null the current nsITypeAheadFind instances so that they're
michael@0 1089 // lazily re-created on access. We need to do this because they
michael@0 1090 // might have attached the wrong docShell.
michael@0 1091 this._fastFind = aOtherBrowser._fastFind = null;
michael@0 1092 ]]>
michael@0 1093 </body>
michael@0 1094 </method>
michael@0 1095 </implementation>
michael@0 1096
michael@0 1097 <handlers>
michael@0 1098 <handler event="keypress" keycode="VK_F7" group="system">
michael@0 1099 <![CDATA[
michael@0 1100 if (event.defaultPrevented || !event.isTrusted)
michael@0 1101 return;
michael@0 1102
michael@0 1103 var isEnabled = this.mPrefs.getBoolPref("accessibility.browsewithcaret_shortcut.enabled");
michael@0 1104 if (!isEnabled)
michael@0 1105 return;
michael@0 1106
michael@0 1107 // Toggle browse with caret mode
michael@0 1108 var browseWithCaretOn = false;
michael@0 1109 var warn = true;
michael@0 1110
michael@0 1111 try {
michael@0 1112 warn = this.mPrefs.getBoolPref("accessibility.warn_on_browsewithcaret");
michael@0 1113 } catch (ex) {
michael@0 1114 }
michael@0 1115
michael@0 1116 try {
michael@0 1117 browseWithCaretOn = this.mPrefs.getBoolPref("accessibility.browsewithcaret");
michael@0 1118 } catch (ex) {
michael@0 1119 }
michael@0 1120 if (warn && !browseWithCaretOn) {
michael@0 1121 var checkValue = {value:false};
michael@0 1122 var promptService = Components.classes["@mozilla.org/embedcomp/prompt-service;1"]
michael@0 1123 .getService(Components.interfaces.nsIPromptService);
michael@0 1124
michael@0 1125 var buttonPressed = promptService.confirmEx(window,
michael@0 1126 this.mStrBundle.GetStringFromName('browsewithcaret.checkWindowTitle'),
michael@0 1127 this.mStrBundle.GetStringFromName('browsewithcaret.checkLabel'),
michael@0 1128 promptService.STD_YES_NO_BUTTONS,
michael@0 1129 null, null, null, this.mStrBundle.GetStringFromName('browsewithcaret.checkMsg'),
michael@0 1130 checkValue);
michael@0 1131 if (buttonPressed != 0)
michael@0 1132 return;
michael@0 1133 if (checkValue.value) {
michael@0 1134 try {
michael@0 1135 this.mPrefs.setBoolPref("accessibility.warn_on_browsewithcaret", false);
michael@0 1136 }
michael@0 1137 catch (ex) {
michael@0 1138 }
michael@0 1139 }
michael@0 1140 }
michael@0 1141
michael@0 1142 // Toggle the pref
michael@0 1143 try {
michael@0 1144 this.mPrefs.setBoolPref("accessibility.browsewithcaret",!browseWithCaretOn);
michael@0 1145 } catch (ex) {
michael@0 1146 }
michael@0 1147 ]]>
michael@0 1148 </handler>
michael@0 1149 <handler event="dragover" group="system">
michael@0 1150 <![CDATA[
michael@0 1151 if (!this.droppedLinkHandler || event.defaultPrevented)
michael@0 1152 return;
michael@0 1153
michael@0 1154 // For drags that appear to be internal text (for example, tab drags),
michael@0 1155 // set the dropEffect to 'none'. This prevents the drop even if some
michael@0 1156 // other listener cancelled the event.
michael@0 1157 var types = event.dataTransfer.types;
michael@0 1158 if (types.contains("text/x-moz-text-internal") && !types.contains("text/plain")) {
michael@0 1159 event.dataTransfer.dropEffect = "none";
michael@0 1160 event.stopPropagation();
michael@0 1161 event.preventDefault();
michael@0 1162 }
michael@0 1163
michael@0 1164 let linkHandler = Components.classes["@mozilla.org/content/dropped-link-handler;1"].
michael@0 1165 getService(Components.interfaces.nsIDroppedLinkHandler);
michael@0 1166 if (linkHandler.canDropLink(event, false))
michael@0 1167 event.preventDefault();
michael@0 1168 ]]>
michael@0 1169 </handler>
michael@0 1170 <handler event="drop" group="system">
michael@0 1171 <![CDATA[
michael@0 1172 if (!this.droppedLinkHandler || event.defaultPrevented)
michael@0 1173 return;
michael@0 1174
michael@0 1175 let name = { };
michael@0 1176 let linkHandler = Components.classes["@mozilla.org/content/dropped-link-handler;1"].
michael@0 1177 getService(Components.interfaces.nsIDroppedLinkHandler);
michael@0 1178 try {
michael@0 1179 // Pass true to prevent the dropping of javascript:/data: URIs
michael@0 1180 var uri = linkHandler.dropLink(event, name, true);
michael@0 1181 } catch (ex) {
michael@0 1182 return;
michael@0 1183 }
michael@0 1184
michael@0 1185 if (uri) {
michael@0 1186 this.droppedLinkHandler(event, uri, name.value);
michael@0 1187 }
michael@0 1188 ]]>
michael@0 1189 </handler>
michael@0 1190 </handlers>
michael@0 1191
michael@0 1192 </binding>
michael@0 1193
michael@0 1194 </bindings>

mercurial