home *** CD-ROM | disk | FTP | other *** search
/ PC World 2005 March / PCWorld_2005-03_cd.bin / komunikace / kmeleon / kmeleon09.exe / toolkit.jar / content / global / bindings / browser.xml next >
Extensible Markup Language  |  2004-11-03  |  15KB  |  425 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. <bindings id="browserBindings"
  38.           xmlns="http://www.mozilla.org/xbl"
  39.           xmlns:xul="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
  40.  
  41.   <binding id="browser" extends="xul:browser">
  42.     <implementation type="application/x-javascript" implements="nsIAccessibleProvider">
  43.       <property name="accessible">
  44.         <getter>
  45.           <![CDATA[
  46.             var accService = Components.classes["@mozilla.org/accessibilityService;1"].getService(Components.interfaces.nsIAccessibilityService);
  47.             return accService.createOuterDocAccessible(this);
  48.           ]]>
  49.         </getter>
  50.       </property>
  51.  
  52.       <property name="canGoBack"
  53.                 onget="return this.webNavigation.canGoBack;"
  54.                 readonly="true"/>
  55.  
  56.       <property name="canGoForward"
  57.                 onget="return this.webNavigation.canGoForward;"
  58.                 readonly="true"/>
  59.  
  60.       <method name="goBack">
  61.         <body>
  62.           <![CDATA[
  63.             var webNavigation = this.webNavigation;
  64.             if (webNavigation.canGoBack)
  65.               webNavigation.goBack();
  66.           ]]>
  67.         </body>
  68.       </method>
  69.  
  70.       <method name="goForward">
  71.         <body>
  72.           <![CDATA[
  73.             var webNavigation = this.webNavigation;
  74.             if (webNavigation.canGoForward)
  75.               webNavigation.goForward();
  76.           ]]>
  77.         </body>
  78.       </method>
  79.  
  80.       <method name="reload">
  81.         <body>
  82.           <![CDATA[
  83.             const nsIWebNavigation = Components.interfaces.nsIWebNavigation;
  84.             const flags = nsIWebNavigation.LOAD_FLAGS_NONE;
  85.             this.reloadWithFlags(flags);
  86.           ]]>
  87.         </body>
  88.       </method>
  89.  
  90.       <method name="reloadWithFlags">
  91.         <parameter name="aFlags"/>
  92.         <body>
  93.           <![CDATA[
  94.             this.webNavigation.reload(aFlags);
  95.           ]]>
  96.         </body>
  97.       </method>
  98.  
  99.       <method name="stop">
  100.         <body>
  101.           <![CDATA[
  102.             const nsIWebNavigation = Components.interfaces.nsIWebNavigation;
  103.             const flags = nsIWebNavigation.STOP_ALL;
  104.             this.webNavigation.stop(flags);
  105.           ]]>
  106.         </body>
  107.       </method>
  108.  
  109.       <!-- throws exception for unknown schemes -->
  110.       <method name="loadURI">
  111.         <parameter name="aURI"/>
  112.         <parameter name="aReferrerURI"/>
  113.         <parameter name="aCharset"/>
  114.         <body>
  115.           <![CDATA[
  116.             const nsIWebNavigation = Components.interfaces.nsIWebNavigation;
  117.             const flags = nsIWebNavigation.LOAD_FLAGS_NONE;
  118.             this.loadURIWithFlags(aURI, flags, aReferrerURI, aCharset);
  119.           ]]>
  120.         </body>
  121.       </method>
  122.  
  123.       <!-- throws exception for unknown schemes -->
  124.       <method name="loadURIWithFlags">
  125.         <parameter name="aURI"/>
  126.         <parameter name="aFlags"/>
  127.         <parameter name="aReferrerURI"/>
  128.         <parameter name="aCharset"/>
  129.         <body>
  130.           <![CDATA[
  131.             if (!aURI)
  132.               aURI = "about:blank";
  133.  
  134.             if (aCharset) {
  135.               try { 
  136.                 this.documentCharsetInfo.parentCharset = this.mAtomService.getAtom(aCharset);
  137.               }
  138.               catch (e) {
  139.               }
  140.             }
  141.             this.webNavigation.loadURI(aURI, aFlags, aReferrerURI, null, null);
  142.           ]]>
  143.         </body>
  144.       </method>
  145.  
  146.       <method name="goHome">
  147.         <body>
  148.           <![CDATA[
  149.             try {
  150.               this.loadURI(this.homePage);
  151.             }
  152.             catch (e) {
  153.             }
  154.           ]]>
  155.         </body>
  156.       </method>
  157.  
  158.       <property name="homePage">
  159.         <getter>
  160.           <![CDATA[
  161.             var uri;
  162.  
  163.             if (this.hasAttribute("homepage"))
  164.               uri = this.getAttribute("homepage");
  165.             else
  166.               uri = "http://www.mozilla.org/"; // widget pride
  167.  
  168.             return uri;
  169.           ]]>
  170.         </getter>
  171.         <setter>
  172.           <![CDATA[
  173.             this.setAttribute("homepage", val);
  174.             return val;
  175.           ]]>
  176.         </setter>
  177.       </property>
  178.  
  179.       <method name="gotoIndex">
  180.         <parameter name="aIndex"/>
  181.         <body>
  182.           <![CDATA[
  183.             this.webNavigation.gotoIndex(aIndex);
  184.           ]]>
  185.         </body>
  186.       </method>
  187.  
  188.       <property name="currentURI"
  189.                 onget="return this.webNavigation.currentURI;"
  190.                 readonly="true"/>
  191.  
  192.       <property name="preferences"
  193.                 onget="return Components.classes['@mozilla.org/preferences-service;1'].getService(Components.interfaces.nsIPrefService);"
  194.                 readonly="true"/>
  195.  
  196.       <property name="docShell"
  197.                 onget="return this.boxObject.QueryInterface(Components.interfaces.nsIBrowserBoxObject).docShell;"
  198.                 readonly="true"/>
  199.  
  200.       <property name="webNavigation"
  201.                 onget="return this.docShell.QueryInterface(Components.interfaces.nsIWebNavigation);"
  202.                 readonly="true"/>
  203.  
  204.       <field name="_webBrowserFind">null</field>
  205.  
  206.       <property name="webBrowserFind"
  207.                 readonly="true">
  208.         <getter>
  209.         <![CDATA[
  210.           if (!this._webBrowserFind)
  211.             this._webBrowserFind = this.docShell.QueryInterface(Components.interfaces.nsIInterfaceRequestor).getInterface(Components.interfaces.nsIWebBrowserFind);
  212.           return this._webBrowserFind;
  213.         ]]>
  214.         </getter>
  215.       </property>
  216.  
  217.       <property name="webProgress"
  218.                 readonly="true"
  219.                 onget="return this.docShell.QueryInterface(Components.interfaces.nsIInterfaceRequestor).getInterface(Components.interfaces.nsIWebProgress);"/>
  220.  
  221.       <property name="contentWindow"
  222.                 readonly="true"
  223.                 onget="return this.docShell.QueryInterface(Components.interfaces.nsIInterfaceRequestor).getInterface(Components.interfaces.nsIDOMWindow);"/>
  224.  
  225.       <property name="sessionHistory"
  226.                 onget="return this.webNavigation.sessionHistory;"
  227.                 readonly="true"/>
  228.  
  229.       <property name="markupDocumentViewer"
  230.                 onget="return this.docShell.contentViewer.QueryInterface(Components.interfaces.nsIMarkupDocumentViewer);"
  231.                 readonly="true"/>
  232.  
  233.       <property name="contentViewerEdit"
  234.                 onget="return this.docShell.contentViewer.QueryInterface(Components.interfaces.nsIContentViewerEdit);"
  235.                 readonly="true"/>
  236.  
  237.       <property name="contentViewerFile"
  238.                 onget="return this.docShell.contentViewer.QueryInterface(Components.interfaces.nsIContentViewerFile);"
  239.                 readonly="true"/>
  240.  
  241.       <property name="documentCharsetInfo"
  242.                 onget="return this.docShell.documentCharsetInfo;"
  243.                 readonly="true"/>
  244.  
  245.       <property name="contentDocument"
  246.                 onget="return this.webNavigation.document;"
  247.                 readonly="true"/>
  248.  
  249.       <property name="contentTitle"
  250.                 onget="return Components.lookupMethod(this.contentDocument, 'title').call(this.contentDocument);"
  251.                 readonly="true"/>
  252.  
  253.       <field name="mPrefs" readonly="true">
  254.         Components.classes['@mozilla.org/preferences-service;1']
  255.                   .getService(Components.interfaces.nsIPrefService)
  256.                   .getBranch(null);
  257.       </field>
  258.  
  259.       <field name="mAtomService" readonly="true">
  260.         Components.classes['@mozilla.org/atom-service;1']
  261.                   .getService(Components.interfaces.nsIAtomService);
  262.       </field>
  263.  
  264.       <field name="_mStrBundle">null</field>
  265.  
  266.       <property name="mStrBundle">
  267.         <getter>
  268.         <![CDATA[
  269.           if (!this._mStrBundle) {
  270.             // need to create string bundle manually instead of using <xul:stringbundle/>
  271.             // see bug 63370 for details
  272.             var localeService = Components.classes["@mozilla.org/intl/nslocaleservice;1"]
  273.                                   .getService(Components.interfaces.nsILocaleService);
  274.             var stringBundleService = Components.classes["@mozilla.org/intl/stringbundle;1"]
  275.                                   .getService(Components.interfaces.nsIStringBundleService);
  276.             var bundleURL = "chrome://global/locale/tabbrowser.properties";
  277.             this._mStrBundle = stringBundleService.createBundle(bundleURL, localeService.getApplicationLocale());
  278.           }
  279.           return this._mStrBundle;
  280.         ]]></getter>
  281.       </property>
  282.  
  283.       <method name="addProgressListener">
  284.         <parameter name="aListener"/>
  285.         <body>
  286.           <![CDATA[
  287.             this.webProgress.addProgressListener(aListener, Components.interfaces.nsIWebProgress.NOTIFY_ALL);
  288.           ]]>
  289.         </body>
  290.       </method>
  291.  
  292.       <method name="removeProgressListener">
  293.         <parameter name="aListener"/>
  294.         <body>
  295.           <![CDATA[
  296.             this.webProgress.removeProgressListener(aListener);
  297.          ]]>
  298.         </body>
  299.       </method>
  300.  
  301.       <field name="mDragDropHandler">
  302.         null
  303.       </field>
  304.  
  305.       <field name="securityUI">
  306.         null
  307.       </field>
  308.  
  309.       <field name="userTypedClear">
  310.         1
  311.       </field>
  312.  
  313.       <field name="_userTypedValue">
  314.         null
  315.       </field>
  316.  
  317.       <field name="focusedWindow">
  318.         null
  319.       </field>
  320.  
  321.       <field name="focusedElement">
  322.         null
  323.       </field>
  324.  
  325.       <property name="userTypedValue"
  326.                 onget="return this._userTypedValue;"
  327.                 onset="this.userTypedClear = 0; return this._userTypedValue = val;"/>
  328.      
  329.       <constructor>
  330.         <![CDATA[
  331.           try {
  332.             if (!this.hasAttribute("disablehistory")) {
  333.               // wire up session history
  334.               this.webNavigation.sessionHistory = Components.classes["@mozilla.org/browser/shistory;1"].createInstance(Components.interfaces.nsISHistory);
  335.  
  336.               // enable global history
  337.               this.docShell.QueryInterface(Components.interfaces.nsIDocShellHistory).useGlobalHistory = true;
  338.             }
  339.           }
  340.           catch (e) {
  341.           }
  342.           try {
  343.             this.mDragDropHandler = Components.classes["@mozilla.org:/content/content-area-dragdrop;1"].createInstance(Components.interfaces.nsIDragDropHandler);
  344.             this.mDragDropHandler.hookupTo(this, null);
  345.           }
  346.           catch (e) {
  347.           }
  348.           try {
  349.             const SECUREBROWSERUI_CONTRACTID = "@mozilla.org/secure_browser_ui;1";
  350.             if (!this.hasAttribute("disablesecurity") &&
  351.                 SECUREBROWSERUI_CONTRACTID in Components.classes) {
  352.               this.securityUI = Components.classes[SECUREBROWSERUI_CONTRACTID].createInstance(Components.interfaces.nsISecureBrowserUI);
  353.               this.securityUI.init(this.contentWindow);
  354.             }
  355.           }
  356.           catch (e) {
  357.           }
  358.         ]]>
  359.       </constructor>
  360.       
  361.       <destructor>
  362.         <![CDATA[
  363.           if (this.mDragDropHandler)
  364.             this.mDragDropHandler.detach();
  365.  
  366.           this.securityUI = null;
  367.         ]]>
  368.       </destructor>
  369.     </implementation>
  370.  
  371.     <handlers>
  372.       <handler event="keypress" keycode="VK_F7">
  373.         <![CDATA[
  374.           if (!event.isTrusted)
  375.             return;
  376.  
  377.           // Toggle browse with caret mode
  378.           var browseWithCaretOn = false;
  379.           var warn = true;
  380.  
  381.           try {
  382.             warn = this.mPrefs.getBoolPref("accessibility.warn_on_browsewithcaret");
  383.           } catch (ex) {
  384.           }
  385.  
  386.           try {
  387.             browseWithCaretOn = this.mPrefs.getBoolPref("accessibility.browsewithcaret");
  388.           } catch (ex) {
  389.           }
  390.           if (warn && !browseWithCaretOn) {
  391.             var checkValue = {value:false};
  392.             promptService = Components.classes["@mozilla.org/embedcomp/prompt-service;1"].getService(Components.interfaces.nsIPromptService);
  393.  
  394.             var buttonPressed = promptService.confirmEx(window, 
  395.               this.mStrBundle.GetStringFromName('browsewithcaret.checkWindowTitle'), 
  396.               this.mStrBundle.GetStringFromName('browsewithcaret.checkLabel'),
  397.               (promptService.BUTTON_TITLE_OK * promptService.BUTTON_POS_0) +
  398.               (promptService.BUTTON_TITLE_CANCEL * promptService.BUTTON_POS_1),
  399.               null, null, null,
  400.               this.mStrBundle.GetStringFromName('browsewithcaret.checkMsg'), 
  401.               checkValue);
  402.             if (buttonPressed != 0)
  403.               return;
  404.             if (checkValue.value) {
  405.               try {
  406.                 this.mPrefs.setBoolPref("accessibility.warn_on_browsewithcaret", false);
  407.               }
  408.               catch (ex) {
  409.               }
  410.             }
  411.           }
  412.  
  413.           // Toggle the pref
  414.           try {
  415.             this.mPrefs.setBoolPref("accessibility.browsewithcaret",!browseWithCaretOn);
  416.           } catch (ex) {
  417.           }
  418.         ]]>
  419.       </handler>
  420.     </handlers>
  421.  
  422.   </binding>
  423.  
  424. </bindings>
  425.