home *** CD-ROM | disk | FTP | other *** search
/ Maximum CD 2005 October / maximum-cd-2005-10.iso / Software / Apps / FirefoxSetup1.0.6.exe / browser.xpi / bin / chrome / toolkit.jar / content / global / bindings / browser.xml < prev    next >
Encoding:
Extensible Markup Language  |  2004-10-22  |  34.2 KB  |  1,009 lines

  1. <?xml version="1.0"?>
  2.  
  3. <!--
  4.    - The contents of this file are subject to the Mozilla Public
  5.    - License Version 1.1 (the "License"); you may not use this file
  6.    - except in compliance with the License. You may obtain a copy of
  7.    - the License at http://www.mozilla.org/MPL/
  8.    -
  9.    - Software distributed under the License is distributed on an "AS
  10.    - IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
  11.    - implied. See the License for the specific language governing
  12.    - rights and limitations under the License.
  13.    -
  14.    - The Original Code is this file as it was released on
  15.    - March 28, 2001.
  16.    -
  17.    - The Initial Developer of the Original Code is Peter Annema.
  18.    - Portions created by Peter Annema are Copyright (C) 2001
  19.    - Peter Annema.  All Rights Reserved.
  20.    -
  21.    - Contributor(s):
  22.    -   Peter Annema <disttsc@bart.nl> (Original Author of <browser>)
  23.    -
  24.    - Alternatively, the contents of this file may be used under the
  25.    - terms of the GNU General Public License Version 2 or later (the
  26.    - "GPL"), in which case the provisions of the GPL are applicable
  27.    - instead of those above.  If you wish to allow use of your
  28.    - version of this file only under the terms of the GPL and not to
  29.    - allow others to use your version of this file under the MPL,
  30.    - indicate your decision by deleting the provisions above and
  31.    - replace them with the notice and other provisions required by
  32.    - the GPL.  If you do not delete the provisions above, a recipient
  33.    - may use your version of this file under either the MPL or the
  34.    - GPL.
  35.   -->
  36.  
  37. <!DOCTYPE window [
  38.   <!ENTITY % findBarDTD SYSTEM "chrome://global/locale/findBar.dtd" >
  39.   %findBarDTD;
  40. ]>
  41.  
  42. <bindings id="browserBindings"
  43.           xmlns="http://www.mozilla.org/xbl"
  44.           xmlns:xul="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
  45.  
  46.   <binding id="browser" extends="xul:browser">
  47.     <implementation type="application/x-javascript" implements="nsIAccessibleProvider, nsIObserver">
  48.       <property name="accessible">
  49.         <getter>
  50.           <![CDATA[
  51.             var accService = Components.classes["@mozilla.org/accessibilityService;1"].getService(Components.interfaces.nsIAccessibilityService);
  52.             return accService.createOuterDocAccessible(this);
  53.           ]]>
  54.         </getter>
  55.       </property>
  56.  
  57.       <property name="autoscrollEnabled">
  58.         <getter>
  59.           <![CDATA[
  60.             if (this.getAttribute("autoscroll") == "false")
  61.               return false;
  62.             
  63.             var enabled = true;
  64.             try {
  65.               enabled = this.mPrefs.getBoolPref("general.autoScroll");
  66.             }
  67.             catch(ex) {
  68.             }
  69.             
  70.             return enabled;
  71.           ]]>
  72.         </getter>
  73.       </property>
  74.  
  75.       <property name="canGoBack"
  76.                 onget="return this.webNavigation.canGoBack;"
  77.                 readonly="true"/>
  78.  
  79.       <property name="canGoForward"
  80.                 onget="return this.webNavigation.canGoForward;"
  81.                 readonly="true"/>
  82.  
  83.       <method name="goBack">
  84.         <body>
  85.           <![CDATA[
  86.             var webNavigation = this.webNavigation;
  87.             if (webNavigation.canGoBack)
  88.               webNavigation.goBack();
  89.           ]]>
  90.         </body>
  91.       </method>
  92.  
  93.       <method name="goForward">
  94.         <body>
  95.           <![CDATA[
  96.             var webNavigation = this.webNavigation;
  97.             if (webNavigation.canGoForward)
  98.               webNavigation.goForward();
  99.           ]]>
  100.         </body>
  101.       </method>
  102.  
  103.       <method name="reload">
  104.         <body>
  105.           <![CDATA[
  106.             const nsIWebNavigation = Components.interfaces.nsIWebNavigation;
  107.             const flags = nsIWebNavigation.LOAD_FLAGS_NONE;
  108.             this.reloadWithFlags(flags);
  109.           ]]>
  110.         </body>
  111.       </method>
  112.  
  113.       <method name="reloadWithFlags">
  114.         <parameter name="aFlags"/>
  115.         <body>
  116.           <![CDATA[
  117.             this.webNavigation.reload(aFlags);
  118.           ]]>
  119.         </body>
  120.       </method>
  121.  
  122.       <method name="stop">
  123.         <body>
  124.           <![CDATA[
  125.             const nsIWebNavigation = Components.interfaces.nsIWebNavigation;
  126.             const flags = nsIWebNavigation.STOP_ALL;
  127.             this.webNavigation.stop(flags);
  128.           ]]>
  129.         </body>
  130.       </method>
  131.  
  132.       <!-- throws exception for unknown schemes -->
  133.       <method name="loadURI">
  134.         <parameter name="aURI"/>
  135.         <parameter name="aReferrerURI"/>
  136.         <parameter name="aCharset"/>
  137.         <body>
  138.           <![CDATA[
  139.             const nsIWebNavigation = Components.interfaces.nsIWebNavigation;
  140.             const flags = nsIWebNavigation.LOAD_FLAGS_NONE;
  141.             this.loadURIWithFlags(aURI, flags, aReferrerURI, aCharset);
  142.           ]]>
  143.         </body>
  144.       </method>
  145.  
  146.       <!-- throws exception for unknown schemes -->
  147.       <method name="loadURIWithFlags">
  148.         <parameter name="aURI"/>
  149.         <parameter name="aFlags"/>
  150.         <parameter name="aReferrerURI"/>
  151.         <parameter name="aCharset"/>
  152.         <parameter name="aPostData"/>
  153.         <body>
  154.           <![CDATA[
  155.             if (!aURI)
  156.               aURI = "about:blank";
  157.  
  158.             if (aCharset) {
  159.               try { 
  160.                 this.documentCharsetInfo.parentCharset = this.mAtomService.getAtom(aCharset);
  161.               }
  162.               catch (e) {
  163.               }
  164.             }
  165.             this.mFavIconURL = null;
  166.             this.webNavigation.loadURI(aURI, aFlags, aReferrerURI, aPostData, null);
  167.           ]]>
  168.         </body>
  169.       </method>
  170.  
  171.       <method name="goHome">
  172.         <body>
  173.           <![CDATA[
  174.             try {
  175.               this.loadURI(this.homePage);
  176.             }
  177.             catch (e) {
  178.             }
  179.           ]]>
  180.         </body>
  181.       </method>
  182.  
  183.       <property name="homePage">
  184.         <getter>
  185.           <![CDATA[
  186.             var uri;
  187.  
  188.             if (this.hasAttribute("homepage"))
  189.               uri = this.getAttribute("homepage");
  190.             else
  191.               uri = "http://www.mozilla.org/"; // widget pride
  192.  
  193.             return uri;
  194.           ]]>
  195.         </getter>
  196.         <setter>
  197.           <![CDATA[
  198.             this.setAttribute("homepage", val);
  199.             return val;
  200.           ]]>
  201.         </setter>
  202.       </property>
  203.  
  204.       <method name="gotoIndex">
  205.         <parameter name="aIndex"/>
  206.         <body>
  207.           <![CDATA[
  208.             this.webNavigation.gotoIndex(aIndex);
  209.           ]]>
  210.         </body>
  211.       </method>
  212.  
  213.       <property name="currentURI"
  214.                 onget="return this.webNavigation.currentURI;"
  215.                 readonly="true"/>
  216.  
  217.       <property name="preferences"
  218.                 onget="return Components.classes['@mozilla.org/preferences-service;1'].getService(Components.interfaces.nsIPrefService);"
  219.                 readonly="true"/>
  220.  
  221.       <property name="docShell"
  222.                 onget="return this.boxObject.QueryInterface(Components.interfaces.nsIBrowserBoxObject).docShell;"
  223.                 readonly="true"/>
  224.  
  225.       <property name="webNavigation"
  226.                 onget="return this.docShell.QueryInterface(Components.interfaces.nsIWebNavigation);"
  227.                 readonly="true"/>
  228.  
  229.       <field name="_webBrowserFind">null</field>
  230.  
  231.       <property name="webBrowserFind"
  232.                 readonly="true">
  233.         <getter>
  234.         <![CDATA[
  235.           if (!this._webBrowserFind)
  236.             this._webBrowserFind = this.docShell.QueryInterface(Components.interfaces.nsIInterfaceRequestor).getInterface(Components.interfaces.nsIWebBrowserFind);
  237.           return this._webBrowserFind;
  238.         ]]>
  239.         </getter>
  240.       </property>
  241.  
  242.       <field name="_fastFind">null</field>
  243.       <property name="fastFind"
  244.                 readonly="true">
  245.         <getter>
  246.         <![CDATA[
  247.           if (!this._fastFind) {
  248.             var n = this.parentNode;
  249.             while (n && n.localName != "tabbrowser")
  250.               n = n.parentNode;
  251.  
  252.             if (n && n.mCurrentBrowser == this)
  253.               return this._fastFind = n.fastFind
  254.  
  255.             this._fastFind = Components.classes["@mozilla.org/typeaheadfind;1"]
  256.                                        .createInstance(Components.interfaces.nsITypeAheadFind);                                
  257.             this._fastFind.init(this.docShell);
  258.           }
  259.           return this._fastFind;
  260.         ]]>
  261.         </getter>
  262.       </property>
  263.       
  264.       <property name="findString" readonly="true">
  265.         <getter>
  266.         <![CDATA[
  267.           return this.fastFind.searchString;
  268.         ]]>
  269.         </getter>
  270.       </property>
  271.       
  272.       <property name="webProgress"
  273.                 readonly="true"
  274.                 onget="return this.docShell.QueryInterface(Components.interfaces.nsIInterfaceRequestor).getInterface(Components.interfaces.nsIWebProgress);"/>
  275.  
  276.       <property name="contentWindow"
  277.                 readonly="true"
  278.                 onget="return this.docShell.QueryInterface(Components.interfaces.nsIInterfaceRequestor).getInterface(Components.interfaces.nsIDOMWindow);"/>
  279.  
  280.       <property name="sessionHistory"
  281.                 onget="return this.webNavigation.sessionHistory;"
  282.                 readonly="true"/>
  283.  
  284.       <property name="markupDocumentViewer"
  285.                 onget="return this.docShell.contentViewer.QueryInterface(Components.interfaces.nsIMarkupDocumentViewer);"
  286.                 readonly="true"/>
  287.  
  288.       <property name="contentViewerEdit"
  289.                 onget="return this.docShell.contentViewer.QueryInterface(Components.interfaces.nsIContentViewerEdit);"
  290.                 readonly="true"/>
  291.  
  292.       <property name="contentViewerFile"
  293.                 onget="return this.docShell.contentViewer.QueryInterface(Components.interfaces.nsIContentViewerFile);"
  294.                 readonly="true"/>
  295.  
  296.       <property name="documentCharsetInfo"
  297.                 onget="return this.docShell.documentCharsetInfo;"
  298.                 readonly="true"/>
  299.  
  300.       <property name="contentDocument"
  301.                 onget="return this.webNavigation.document;"
  302.                 readonly="true"/>
  303.  
  304.       <property name="contentTitle"
  305.                 onget="return Components.lookupMethod(this.contentDocument, 'title').call(this.contentDocument);"
  306.                 readonly="true"/>
  307.  
  308.       <field name="mPrefs" readonly="true">
  309.         Components.classes['@mozilla.org/preferences-service;1']
  310.                   .getService(Components.interfaces.nsIPrefService)
  311.                   .getBranch(null);
  312.       </field>
  313.  
  314.       <field name="mAtomService" readonly="true">
  315.         Components.classes['@mozilla.org/atom-service;1']
  316.                   .getService(Components.interfaces.nsIAtomService);
  317.       </field>
  318.  
  319.       <field name="_mStrBundle">null</field>
  320.  
  321.       <property name="mStrBundle">
  322.         <getter>
  323.         <![CDATA[
  324.           if (!this._mStrBundle) {
  325.             // need to create string bundle manually instead of using <xul:stringbundle/>
  326.             // see bug 63370 for details
  327.             var localeService = Components.classes["@mozilla.org/intl/nslocaleservice;1"]
  328.                                   .getService(Components.interfaces.nsILocaleService);
  329.             var stringBundleService = Components.classes["@mozilla.org/intl/stringbundle;1"]
  330.                                   .getService(Components.interfaces.nsIStringBundleService);
  331.             var bundleURL = "chrome://global/locale/tabbrowser.properties";
  332.             this._mStrBundle = stringBundleService.createBundle(bundleURL, localeService.getApplicationLocale());
  333.           }
  334.           return this._mStrBundle;
  335.         ]]></getter>
  336.       </property>
  337.  
  338.       <method name="addProgressListener">
  339.         <parameter name="aListener"/>
  340.         <body>
  341.           <![CDATA[
  342.             this.webProgress.addProgressListener(aListener, Components.interfaces.nsIWebProgress.NOTIFY_ALL);
  343.           ]]>
  344.         </body>
  345.       </method>
  346.  
  347.       <method name="removeProgressListener">
  348.         <parameter name="aListener"/>
  349.         <body>
  350.           <![CDATA[
  351.             this.webProgress.removeProgressListener(aListener);
  352.          ]]>
  353.         </body>
  354.       </method>
  355.  
  356.       <method name="attachFormFill">
  357.         <body>
  358.           <![CDATA[
  359.           if (!this.mFormFillAttached && this.hasAttribute("autocompletepopup")) {
  360.             // hoop up the form fill autocomplete controller
  361.             var controller = Components.classes["@mozilla.org/satchel/form-fill-controller;1"].
  362.                                getService(Components.interfaces.nsIFormFillController);
  363.  
  364.             var popup = document.getElementById(this.getAttribute("autocompletepopup"));
  365.             if (popup)
  366.               controller.attachToBrowser(this.docShell, popup.QueryInterface(Components.interfaces.nsIAutoCompletePopup));
  367.             
  368.             this.mFormFillAttached = true;
  369.           }
  370.           ]]>
  371.         </body>
  372.       </method>
  373.  
  374.       <method name="detachFormFill">
  375.         <body>
  376.           <![CDATA[
  377.           if (this.mFormFillAttached) {
  378.             // hoop up the form fill autocomplete controller
  379.             var controller = Components.classes["@mozilla.org/satchel/form-fill-controller;1"].
  380.                                getService(Components.interfaces.nsIFormFillController);
  381.             controller.detachFromBrowser(this.docShell);
  382.             
  383.             this.mFormFillAttached = false;
  384.           }
  385.           ]]>
  386.         </body>
  387.       </method>
  388.       
  389.       <method name="findChildShell">
  390.         <parameter name="aDocShell"/>
  391.         <parameter name="aSoughtURI"/>
  392.         <body>
  393.           <![CDATA[
  394.             if (aDocShell.QueryInterface(Components.interfaces.nsIWebNavigation)
  395.                          .currentURI.spec == aSoughtURI.spec)
  396.               return aDocShell;
  397.             var node = aDocShell.QueryInterface(
  398.                                    Components.interfaces.nsIDocShellTreeNode);
  399.             for (var i = 0; i < node.childCount; ++i) {
  400.               var docShell = node.getChildAt(i);
  401.               docShell = this.findChildShell(docShell, aSoughtURI);
  402.               if (docShell)
  403.                 return docShell;
  404.             }
  405.             return null;
  406.           ]]>
  407.         </body>
  408.       </method>
  409.  
  410.       <method name="onLoad">
  411.         <parameter name="aEvent"/>
  412.         <body>
  413.           <![CDATA[
  414.             this.attachFormFill();
  415.             if (this.pageReport) {
  416.               var i = 0;
  417.               while (i < this.pageReport.length) {
  418.                 if (this.findChildShell(this.docShell,
  419.                                         this.pageReport[i].requestingWindowURI))
  420.                   i++;
  421.                 else
  422.                   this.pageReport.splice(i, 1);
  423.               }
  424.               if (this.pageReport.length == 0) {
  425.                 this.pageReport = null;
  426.                 this.updatePageReport();
  427.               }
  428.             }
  429.          ]]>
  430.         </body>
  431.       </method>
  432.  
  433.       <method name="onUnload">
  434.         <parameter name="aEvent"/>
  435.         <body>
  436.           <![CDATA[
  437.             if (this.pageReport) {
  438.               this.pageReport = null;
  439.               this.updatePageReport();
  440.             }
  441.          ]]>
  442.         </body>
  443.       </method>
  444.  
  445.       <method name="updatePageReport">
  446.         <body>
  447.           <![CDATA[
  448.             var n = this.parentNode;
  449.             while (n && n.localName != "tabbrowser")
  450.               n = n.parentNode;
  451.  
  452.             if (!n || n.mCurrentBrowser != this) return;
  453.            
  454.             var event = document.createEvent("Events");
  455.             event.initEvent("DOMUpdatePageReport", true, true);
  456.             n.dispatchEvent(event);
  457.           ]]>
  458.         </body>
  459.       </method>
  460.  
  461.       <method name="onPopupBlocked">
  462.         <parameter name="evt"/>
  463.         <body>
  464.           <![CDATA[
  465.             if (!this.pageReport) {
  466.               this.pageReport = new Array();
  467.               this.updatePageReport(); 
  468.             }
  469.  
  470.             var obj = { requestingWindowURI: evt.requestingWindowURI,
  471.                         popupWindowURI: evt.popupWindowURI,
  472.                         popupWindowFeatures: evt.popupWindowFeatures };
  473.             this.pageReport.push(obj);
  474.           ]]> 
  475.         </body>
  476.       </method>
  477.  
  478.       <field name="pageReport">null</field>
  479.  
  480.       <field name="mDragDropHandler">
  481.         null
  482.       </field>
  483.  
  484.       <field name="securityUI">
  485.         null
  486.       </field>
  487.       
  488.       <field name="userTypedClear">
  489.         true
  490.       </field>
  491.  
  492.       <field name="_userTypedValue">
  493.         null
  494.       </field>
  495.  
  496.       <property name="userTypedValue"
  497.                 onget="return this._userTypedValue;"
  498.                 onset="this.userTypedClear = false; return this._userTypedValue = val;"/>
  499.  
  500.       <field name="mFormFillAttached">
  501.         false
  502.       </field>
  503.       
  504.       <field name="focusedWindow">
  505.         null
  506.       </field>
  507.  
  508.       <field name="focusedElement">
  509.         null
  510.       </field>     
  511.       
  512.       <field name="isShowingMessage">
  513.         false
  514.       </field>
  515.  
  516.       <field name="mFavIconURL">null</field>
  517.  
  518.       <constructor>
  519.         <![CDATA[
  520.           try {
  521.             if (!this.hasAttribute("disablehistory")) {
  522.               // wire up session history
  523.               this.webNavigation.sessionHistory = Components.classes["@mozilla.org/browser/shistory;1"].createInstance(Components.interfaces.nsISHistory);
  524.               var os = Components.classes["@mozilla.org/observer-service;1"].getService(Components.interfaces.nsIObserverService);
  525.               os.addObserver(this, "browser:purge-session-history", false);
  526.               // enable global history
  527.               this.docShell.QueryInterface(Components.interfaces.nsIDocShellHistory).useGlobalHistory = true;
  528.             }
  529.           }
  530.           catch (e) {
  531.           }
  532.           try {
  533.             this.mDragDropHandler = Components.classes["@mozilla.org:/content/content-area-dragdrop;1"].createInstance(Components.interfaces.nsIDragDropHandler);
  534.             this.mDragDropHandler.hookupTo(this, null);
  535.           }
  536.           catch (e) {
  537.           }
  538.           try {
  539.             const SECUREBROWSERUI_CONTRACTID = "@mozilla.org/secure_browser_ui;1";
  540.             if (!this.hasAttribute("disablesecurity") &&
  541.                 SECUREBROWSERUI_CONTRACTID in Components.classes) {
  542.               this.securityUI = Components.classes[SECUREBROWSERUI_CONTRACTID].createInstance(Components.interfaces.nsISecureBrowserUI);
  543.               this.securityUI.init(this.contentWindow);
  544.             }
  545.           }
  546.           catch (e) {
  547.           }
  548.  
  549.           // Listen for first load for lazy attachment to form fill controller
  550.           this.addEventListener("load", this.onLoad, true);
  551.           this.addEventListener("unload", this.onUnload, true);
  552.           this.addEventListener("DOMPopupBlocked", this.onPopupBlocked, false);
  553.         ]]>
  554.       </constructor>
  555.       
  556.       <destructor>
  557.         <![CDATA[
  558.           this.destroy();
  559.         ]]>
  560.       </destructor>
  561.  
  562.       <!-- This is necessary because the destructor doesn't always get called when
  563.            we are removed from a tabbrowser. This will be explicitly called by tabbrowser -->
  564.       <method name="destroy">
  565.         <body>
  566.           <![CDATA[
  567.           if (!this.hasAttribute("disablehistory")) {
  568.             var os = Components.classes["@mozilla.org/observer-service;1"].getService(Components.interfaces.nsIObserverService);
  569.             os.removeObserver(this, "browser:purge-session-history", false);
  570.           }
  571.  
  572.           if (this.mDragDropHandler)
  573.             this.mDragDropHandler.detach();
  574.           this.mDragDropHandler = null;
  575.  
  576.           this.detachFormFill();
  577.           
  578.           this.securityUI = null;
  579.           this._fastFind = null;
  580.  
  581.           this.removeEventListener("load", this.onLoad, true);
  582.           this.removeEventListener("unload", this.onUnload, true);
  583.           this.removeEventListener("DOMPopupBlocked", this.onPopupBlocked, true);
  584.           ]]>
  585.         </body>
  586.       </method>
  587.       
  588.       <method name="observe">
  589.         <parameter name="aSubject"/>
  590.         <parameter name="aTopic"/>
  591.         <parameter name="aState"/>
  592.         <body>
  593.           <![CDATA[
  594.             if (aTopic != "browser:purge-session-history")
  595.               return;
  596.               
  597.             var purge = this.sessionHistory.count;
  598.             if (this.currentURI != "about:blank")
  599.               --purge; // Don't remove the page the user's staring at from shistory
  600.               
  601.             this.sessionHistory.PurgeHistory(purge);
  602.           ]]>
  603.         </body>
  604.       </method>
  605.           
  606.       <field name="_AUTOSCROLL_SPEED">3</field>
  607.       <field name="_AUTOSCROLL_SNAP">10</field>
  608.       <field name="_clientFrameDoc">null</field>
  609.       <field name="_isScrolling">false</field>
  610.       <field name="_autoScrollMarkerImage">null</field>
  611.       <field name="_snapOn">false</field>
  612.       <field name="_scrollCount">0</field>
  613.       <field name="_startX">null</field>
  614.       <field name="_startY">null</field>
  615.       <field name="_clientX">null</field>
  616.       <field name="_clientY">null</field>
  617.  
  618.       <method name="stopScroll">
  619.         <body>
  620.           <![CDATA[
  621.             this._isScrolling = false;
  622.             if (this._autoScrollMarkerImage) {
  623.               this._autoScrollMarkerImage.style.display = 'none';  // seems to avoid blocking when autoscroll is initited during pageload
  624.               this._autoScrollMarkerImage.parentNode.removeChild(this._autoScrollMarkerImage);
  625.             }
  626.             this._autoScrollMarkerImage = null;
  627.          ]]>
  628.        </body>
  629.      </method>
  630.      
  631.      <method name="autoScrollLoop">
  632.        <body>
  633.          <![CDATA[
  634.            if (this._isScrolling) {
  635.              var x = (this._clientX - this._startX) / this._AUTOSCROLL_SPEED;
  636.              var y = (this._clientY - this._startY) / this._AUTOSCROLL_SPEED;
  637.          
  638.              if(Math.abs(x) > 0 && Math.abs(y) > 0)
  639.              {
  640.                if (this._scrollCount++ % 2)
  641.                  y = 0;
  642.                else
  643.                  x = 0;
  644.              }
  645.          
  646.              this._clientFrameDoc.defaultView.scrollBy(x, y);
  647.              setTimeout(function foo(a) { a.autoScrollLoop() }, 5, this);
  648.            }
  649.          ]]>
  650.        </body>
  651.      </method>
  652.      <method name="isAutoscrollBlocker">
  653.        <parameter name="node"/>
  654.        <body>
  655.          <![CDATA[
  656.            var mmPaste = false;
  657.            var mmScrollbarPosition = false;
  658.  
  659.            try {
  660.              mmPaste = this.mPrefs.getBoolPref("middlemouse.paste");
  661.            }
  662.            catch (ex) {
  663.            }
  664.  
  665.            try {
  666.              mmScrollbarPosition = this.mPrefs.getBoolPref("middlemouse.scrollbarPosition");
  667.            }
  668.            catch (ex) {
  669.            }
  670.  
  671.            while (node) {
  672.              if ((node instanceof HTMLAnchorElement || node instanceof HTMLAreaElement) && node.hasAttribute("href"))
  673.                return true;
  674.  
  675.              if (mmPaste && (node instanceof HTMLInputElement || node instanceof HTMLTextAreaElement))
  676.                return true;
  677.  
  678.              if (node instanceof XULElement && mmScrollbarPosition
  679.                  && (node.localName == "scrollbar" || node.localName == "scrollcorner"))
  680.                return true;
  681.  
  682.              node = node.parentNode;
  683.            }
  684.            return false;
  685.          ]]>
  686.        </body>
  687.      </method>
  688.      <method name="showAutoscrollMarker">
  689.        <parameter name="evt"/>
  690.        <body>
  691.          <![CDATA[
  692.            var scrollCursor  = new Array("move", "n-resize", "e-resize");
  693.            var docBox = this._clientFrameDoc.getBoxObjectFor(this._clientFrameDoc.documentElement);
  694.            var left = evt.screenX - docBox.screenX;
  695.            var top = evt.screenY - docBox.screenY;
  696.            
  697.            
  698.            var documentWidth = docBox.width;
  699.            var documentHeight = docBox.height;
  700.            var windowWidth = window.innerWidth;
  701.            var windowHeight = window.innerHeight;
  702.            var scrollType = 0;
  703.            if (windowHeight < documentHeight && windowWidth >= documentWidth)
  704.              scrollType = 1;
  705.            else if (windowHeight >= documentHeight && windowWidth < documentWidth)
  706.              scrollType = 2;
  707.      
  708.            var imageWidth = 28;
  709.            var imageHeight = 28;
  710.            
  711.            // marker
  712.            var el = this._clientFrameDoc.createElementNS("http://www.w3.org/1999/xhtml", "img");
  713.            
  714.            var scrollImages  = new Array("chrome://global/content/bindings/autoscroll_all.png",
  715.                                          "chrome://global/content/bindings/autoscroll_v.png",
  716.                                          "chrome://global/content/bindings/autoscroll_h.png");
  717.            
  718.            el.src = scrollImages[scrollType];         
  719.            el.style.position = "fixed";
  720.            el.style.left = left - imageWidth / 2 + "px";
  721.            el.style.top = top - imageHeight / 2 + "px";
  722.            el.style.width = imageWidth + "px";
  723.            el.style.height = imageHeight + "px";
  724.            el.style.cursor = scrollCursor[scrollType];
  725.            el.style.zIndex = 2147483647; //Max Int
  726.            el.style.borderStyle = "none";
  727.            el.style.padding = "0";
  728.            el.style.margin = "0";
  729.  
  730.            this._clientFrameDoc.documentElement.appendChild(el);
  731.            
  732.            this._autoScrollMarkerImage = el;
  733.          ]]>
  734.        </body>
  735.      </method>
  736.  
  737.      <field name="_findInstData">null</field>
  738.      <property name="findInstData" readonly="true">
  739.         <getter>
  740.           <![CDATA[
  741.             if (!this._findInstData) {
  742.               this._findInstData = new nsFindInstData();
  743.               this._findInstData.browser = this;
  744.               // defaults for rootSearchWindow and currentSearchWindow are fine here
  745.             }
  746.             return this._findInstData;
  747.           ]]>
  748.         </getter>
  749.      </property>
  750.  
  751.      <property name="canFindAgain" readonly="true" onget="return canFindAgainInPage();"/>
  752.  
  753.      <method name="find">
  754.        <body>
  755.          <![CDATA[
  756.            findInPage(this.findInstData)
  757.          ]]>
  758.        </body>
  759.      </method>
  760.  
  761.      <method name="findAgain">
  762.        <body>
  763.          <![CDATA[
  764.            findAgainInPage(this.findInstData, false)
  765.          ]]>
  766.        </body>
  767.      </method>
  768.  
  769.      <method name="findPrevious">
  770.        <body>
  771.          <![CDATA[
  772.            findAgainInPage(this.findInstData, true)
  773.          ]]>
  774.        </body>
  775.      </method>
  776.  
  777.     </implementation>
  778.  
  779.     <handlers>
  780.       <handler event="keypress" keycode="VK_F7">
  781.         <![CDATA[
  782.           if (!event.isTrusted)
  783.             return;
  784.  
  785.           // Toggle browse with caret mode
  786.           var browseWithCaretOn = false;
  787.           var warn = true;
  788.  
  789.           try {
  790.             warn = this.mPrefs.getBoolPref("accessibility.warn_on_browsewithcaret");
  791.           } catch (ex) {
  792.           }
  793.  
  794.           try {
  795.             browseWithCaretOn = this.mPrefs.getBoolPref("accessibility.browsewithcaret");
  796.           } catch (ex) {
  797.           }
  798.           if (warn && !browseWithCaretOn) {
  799.             var checkValue = {value:false};
  800.             promptService = Components.classes["@mozilla.org/embedcomp/prompt-service;1"].getService(Components.interfaces.nsIPromptService);
  801.  
  802.             var buttonPressed = promptService.confirmEx(window, 
  803.               this.mStrBundle.GetStringFromName('browsewithcaret.checkWindowTitle'), 
  804.               this.mStrBundle.GetStringFromName('browsewithcaret.checkLabel'),
  805.               (promptService.BUTTON_TITLE_YES * promptService.BUTTON_POS_0) +
  806.               (promptService.BUTTON_TITLE_NO * promptService.BUTTON_POS_1),
  807.               null, null, null, this.mStrBundle.GetStringFromName('browsewithcaret.checkMsg'),
  808.               checkValue);
  809.             if (buttonPressed != 0)
  810.               return;
  811.             if (checkValue.value) {
  812.               try {
  813.                 this.mPrefs.setBoolPref("accessibility.warn_on_browsewithcaret", false);
  814.               }
  815.               catch (ex) {
  816.               }
  817.             }
  818.           }
  819.  
  820.           // Toggle the pref
  821.           try {
  822.             this.mPrefs.setBoolPref("accessibility.browsewithcaret",!browseWithCaretOn);
  823.           } catch (ex) {
  824.           }
  825.         ]]>
  826.       </handler>
  827.       <handler event="mouseup">
  828.         <![CDATA[
  829.           if (!this.autoscrollEnabled)
  830.             return;
  831.           if (!this._snapOn)
  832.             this.stopScroll();
  833.         ]]>        
  834.       </handler>
  835.       <handler event="mousedown">
  836.         <![CDATA[
  837.           if (this._isScrolling) {
  838.             stopScroll();
  839.           } else if (event.button == 1) {
  840.           if (!this.autoscrollEnabled || this.isAutoscrollBlocker(event.originalTarget))
  841.             return;
  842.  
  843.               this._startX = event.clientX;
  844.               this._startY = event.clientY;
  845.               this._clientFrameDoc = event.originalTarget.ownerDocument;
  846.               this._isScrolling = true;
  847.               this._snapOn = true; 
  848.               this.showAutoscrollMarker(event);
  849.               window.setTimeout(function foo(a) { a.autoScrollLoop() }, 5, this);
  850.             }
  851.         ]]>
  852.       </handler>
  853.       <handler event="mousemove">
  854.         <![CDATA[          
  855.           this._clientX = event.clientX;
  856.           this._clientY = event.clientY;
  857.         
  858.           if (this._isScrolling) {
  859.             var x = this._clientX - this._startX;
  860.             var y = this._clientY - this._startY;
  861.         
  862.             if ((x > this._AUTOSCROLL_SNAP || x < -this._AUTOSCROLL_SNAP) || (y > this._AUTOSCROLL_SNAP || y < -this._AUTOSCROLL_SNAP))
  863.               this._snapOn = false;            
  864.           }
  865.         ]]>
  866.       </handler>
  867.     </handlers>
  868.  
  869.   </binding>
  870.   
  871.   <binding id="browsermessage" extends="xul:hbox">
  872.     <content align="center">
  873.       <xul:hbox anonid="messagePopupContainer" align="center" flex="1">
  874.         <xul:image       anonid="messageImage"   class="messageImage"/>
  875.         <xul:description anonid="messageText"    class="messageText" flex="1"/>
  876.       </xul:hbox>
  877.       <xul:button       anonid="messageButton"  class="messageButton"/>
  878.       <xul:spacer class="tabs-right"/>
  879.       <xul:hbox hidden="true" anonid="messageClose" class="tabs-closebutton-box" 
  880.                 align="center" pack="end">
  881.         <xul:toolbarbutton ondblclick="event.preventBubble();" 
  882.                            class="tabs-closebutton close-button" 
  883.                            oncommand="this.parentNode.parentNode.hide();"/>
  884.       </xul:hbox>
  885.     </content>
  886.     <implementation>
  887.       <property name="type" onget="return this.getAttribute('type');"
  888.                             onset="this.setAttribute('type', val); return val;"/>
  889.  
  890.       <field name="_imageElement">
  891.         document.getAnonymousElementByAttribute(this, "anonid", "messageImage");
  892.       </field>
  893.       <property name="image">
  894.         <getter>
  895.           <![CDATA[
  896.             return this._imageElement.getAttribute("src");
  897.           ]]>
  898.         </getter>
  899.         <setter>
  900.           <![CDATA[
  901.             this._imageElement.setAttribute("src", val);
  902.             return val;
  903.           ]]>        
  904.         </setter>
  905.       </property>
  906.       
  907.       <field name="docShell">
  908.         null;
  909.       </field>
  910.       <field name="source">
  911.         "";
  912.       </field>
  913.       <property name="popup">
  914.         <setter>
  915.           <![CDATA[
  916.             if (val)
  917.               document.getAnonymousElementByAttribute(this, "anonid", "messagePopupContainer").setAttribute("popup", val);
  918.             else
  919.               document.getAnonymousElementByAttribute(this, "anonid", "messagePopupContainer").removeAttribute("popup");
  920.             return val;
  921.           ]]>
  922.         </setter>
  923.         <getter>
  924.           <![CDATA[
  925.             return document.getAnonymousElementByAttribute(this, "anonid", "messagePopupContainer").getAttribute("popup");
  926.           ]]>
  927.         </getter>
  928.       </property>
  929.  
  930.       <field name="_textElement">
  931.         document.getAnonymousElementByAttribute(this, "anonid", "messageText");
  932.       </field>
  933.       <field name="_text">
  934.         "";
  935.       </field>
  936.       <property name="text">
  937.         <getter>
  938.           <![CDATA[
  939.             return this._text;
  940.           ]]>
  941.         </getter>
  942.         <setter>
  943.           <![CDATA[
  944.             this._text = val;
  945.             while (this._textElement.hasChildNodes())
  946.               this._textElement.removeChild(this._textElement.firstChild);
  947.             this._textElement.appendChild(document.createTextNode(val));
  948.             return val;
  949.           ]]>        
  950.         </setter>
  951.       </property>
  952.       
  953.       <field name="_buttonElement">
  954.         document.getAnonymousElementByAttribute(this, "anonid", "messageButton");
  955.       </field>
  956.       <property name="buttonText">
  957.         <getter>
  958.           <![CDATA[
  959.             return this._buttonElement.getAttribute("label");
  960.           ]]>
  961.         </getter>
  962.         <setter>
  963.           <![CDATA[
  964.             if (val != "") {
  965.               this._buttonElement.removeAttribute("style");
  966.               this._buttonElement.setAttribute("label", val);
  967.             }
  968.             else
  969.               this._buttonElement.setAttribute("style", "max-width: 1px; visibility: hidden;");
  970.             return val;
  971.           ]]>        
  972.         </setter>
  973.       </property>
  974.       <property name="closeButton">
  975.         <getter>
  976.           <![CDATA[
  977.             return document.getAnonymousElementByAttribute(this, "anonid", "messageClose");
  978.           ]]>
  979.         </getter>
  980.         <setter>
  981.           <![CDATA[
  982.             var elm = document.getAnonymousElementByAttribute(this, "anonid", "messageClose");
  983.             elm.hidden = !val;
  984.             return val;
  985.           ]]>        
  986.         </setter>
  987.       </property>
  988.       <method name="hide">
  989.         <body>
  990.           <![CDATA[
  991.             this.hidden = true;
  992.           ]]>
  993.         </body>
  994.       </method>
  995.     </implementation>
  996.     <handlers>
  997.       <handler event="click">
  998.         if (event.originalTarget.getAttribute("anonid") == "messageButton") {
  999.           var os = Components.classes["@mozilla.org/observer-service;1"]
  1000.                              .getService(Components.interfaces.nsIObserverService);
  1001.           var subject = this.docShell ? this.docShell : null;
  1002.           os.notifyObservers(subject, this.source, "");
  1003.         }
  1004.       </handler>
  1005.     </handlers>
  1006.   </binding>
  1007.  
  1008. </bindings>
  1009.