home *** CD-ROM | disk | FTP | other *** search
/ GameStar 2005 October / Gamestar_77_2005-10_dvd.iso / Programy / nsb-install-8-0.exe / chrome / toolkit.jar / content / global / bindings / autocomplete.xml next >
Extensible Markup Language  |  2005-07-29  |  26KB  |  733 lines

  1. <?xml version="1.0"?>
  2.  
  3.  
  4. <bindings id="autocompleteBindings"
  5.           xmlns="http://www.mozilla.org/xbl"
  6.           xmlns:html="http://www.w3.org/1999/xhtml"
  7.           xmlns:xul="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
  8.           xmlns:xbl="http://www.mozilla.org/xbl">
  9.  
  10.   <binding id="autocomplete"
  11.            extends="chrome://global/content/bindings/textbox.xml#textbox">
  12.     <resources>
  13.       <stylesheet src="chrome://global/skin/autocomplete.css"/>
  14.     </resources>
  15.  
  16.     <content sizetopopup="pref">
  17.       <xul:hbox class="autocomplete-textbox-container" flex="1">
  18.         <children includes="image|deck">
  19.           <xul:image class="autocomplete-icon" allowevents="true"/>
  20.         </children>
  21.  
  22.         <xul:hbox anonid="textbox-input-box" class="textbox-input-box" flex="1" xbl:inherits="tooltiptext=inputtooltiptext">
  23.           <children/>
  24.           <html:input anonid="input" class="autocomplete-textbox textbox-input"
  25.                       flex="1" allowevents="true"
  26.                       xbl:inherits="tooltiptext=inputtooltiptext,onfocus,onblur,value,type,maxlength,disabled,size,readonly,userAction"/>
  27.         </xul:hbox>
  28.         <xul:image class="info-icon" xbl:inherits="src=infoicon,tooltiptext=infotext"/>
  29.       </xul:hbox>
  30.       
  31.       <xul:dropmarker anonid="historydropmarker" class="autocomplete-history-dropmarker"
  32.                       allowevents="true"
  33.                       xbl:inherits="open,enablehistory"/>
  34.  
  35.       <xul:popupset anonid="popupset" class="autocomplete-result-popupset"/>
  36.     </content>
  37.  
  38.     <implementation implements="nsIAccessibleProvider, nsIAutoCompleteInput, nsIDOMXULMenuListElement">
  39.       <field name="mController">null</field>
  40.       <field name="mSearchNames">null</field>
  41.       <field name="mIgnoreInput">false</field>
  42.       <field name="mEnterEvent">null</field>
  43.       
  44.       <field name="mInputElt">
  45.         document.getAnonymousElementByAttribute(this, "anonid", "input");
  46.       </field>
  47.  
  48.       <constructor><![CDATA[
  49.         // set default property values
  50.         this.ifSetAttribute("disablehistory", true);
  51.  
  52.         mController = Components.classes["@mozilla.org/autocomplete/controller;1"].
  53.                         createInstance(Components.interfaces.nsIAutoCompleteController);
  54.       ]]></constructor>
  55.  
  56.       <!-- =================== nsIAccessibleProvider =================== -->
  57.  
  58.       <property name="accessible">
  59.         <getter>
  60.           <![CDATA[
  61.             var accService = Components.classes["@mozilla.org/accessibilityService;1"].
  62.                               getService(Components.interfaces.nsIAccessibilityService);
  63.             return accService.createXULComboboxAccessible(this);
  64.           ]]>
  65.         </getter>
  66.       </property>
  67.  
  68.       <!-- =================== nsIAutoCompleteInput =================== -->
  69.  
  70.       <field name="popup"><![CDATA[
  71.         var popup = null;
  72.         var popupId = this.getAttribute("autocompletepopup");
  73.         if (popupId)
  74.           popup = document.getElementById(popupId);
  75.         if (!popup) {
  76.           popup = document.createElement("popup");
  77.           popup.setAttribute("type", "autocomplete");
  78.           popup.setAttribute("hidden", "true");
  79.           
  80.           var popupset = document.getAnonymousElementByAttribute(this, "anonid", "popupset");
  81.           popupset.appendChild(popup);
  82.         }
  83.         popup.mInput = this;
  84.         popup;
  85.       ]]></field>
  86.       
  87.       <property name="controller" onget="return this.mController;" readonly="true"/>
  88.  
  89.       <property name="popupOpen"
  90.                 onget="return this.popup.popupOpen;"
  91.                 onset="if (val) this.openPopup(); else this.closePopup();"/>
  92.  
  93.       <property name="disableAutoComplete"
  94.                 onset="this.setAttribute('disableautocomplete', val); return val;"
  95.                 onget="return this.getAttribute('disableautocomplete') == 'true';"/>
  96.  
  97.       <property name="completeDefaultIndex"
  98.                 onset="this.setAttribute('completedefaultindex', val); return val;"
  99.                 onget="return this.getAttribute('completedefaultindex') == 'true';"/>
  100.  
  101.       <property name="completeSelectedIndex"
  102.                 onset="this.setAttribute('completeselectedindex', val); return val;"
  103.                 onget="return this.getAttribute('completeselectedindex') == 'true';"/>
  104.  
  105.       <property name="forceComplete"
  106.                 onset="this.setAttribute('forcecomplete', val); return val;"
  107.                 onget="return this.getAttribute('forcecomplete') == 'true';"/>
  108.  
  109.       <property name="minResultsForPopup"
  110.                 onset="this.setAttribute('minresultsforpopup', val); return val;"
  111.                 onget="return parseInt(this.getAttribute('minresultsforpopup')) || 0;"/>
  112.  
  113.       <property name="showCommentColumn"
  114.                 onset="this.setAttribute('showcommentcolumn', val); return val;"
  115.                 onget="return this.getAttribute('showcommentcolumn') == 'true';"/>
  116.  
  117.       <property name="timeout"
  118.                 onset="this.setAttribute('timeout', val); return val;"
  119.                 onget="return parseInt(this.getAttribute('timeout')) || 50;"/>
  120.  
  121.       <property name="searchParam"
  122.                 onget="return this.getAttribute('autocompletesearchparam');"
  123.                 onset="this.setAttribute('autocompletesearchparam', val); return val;"/>
  124.  
  125.       <property name="searchCount" readonly="true"
  126.                 onget="this.initSearchNames(); return this.mSearchNames.length;"/>
  127.     
  128.       <method name="getSearchAt">
  129.         <parameter name="aIndex"/>
  130.         <body><![CDATA[
  131.           this.initSearchNames();
  132.           return this.mSearchNames[aIndex];
  133.         ]]></body>
  134.       </method>
  135.  
  136.       <property name="textValue"
  137.                 onget="return this.value;"
  138.                 onset="return this.value = val;"/>
  139.  
  140.       <property name="selectionStart"
  141.                 onget="return this.mInputElt.selectionStart;"/>
  142.  
  143.       <property name="selectionEnd"
  144.                 onget="return this.mInputElt.selectionEnd;"/>
  145.  
  146.       <method name="selectTextRange">
  147.         <parameter name="aStartIndex"/>
  148.         <parameter name="aEndIndex"/>
  149.         <body><![CDATA[
  150.           this.mInputElt.setSelectionRange(aStartIndex, aEndIndex);
  151.         ]]></body>
  152.       </method>
  153.  
  154.       <method name="onSearchComplete">
  155.         <body><![CDATA[
  156.           if (this.mController.matchCount == 0)
  157.             this.popup.setAttribute("nomatch", "true");
  158.           else
  159.             this.popup.removeAttribute("nomatch");
  160.  
  161.           this.fireEvent("searchcomplete");
  162.         ]]></body>
  163.       </method>
  164.  
  165.       <method name="onTextEntered">
  166.         <body><![CDATA[
  167.           var rv = this.fireEvent("textentered", this.mEnterEvent);
  168.           this.mEnterEvent = null;
  169.           return rv;
  170.         ]]></body>
  171.       </method>
  172.  
  173.       <method name="onTextReverted">
  174.         <body><![CDATA[
  175.           return this.fireEvent("textreverted");
  176.         ]]></body>
  177.       </method>
  178.  
  179.       <!-- =================== nsIDOMXULMenuListElement =================== -->
  180.  
  181.       <property name="editable" readonly="true"
  182.                 onget="return true;" />  
  183.  
  184.       <property name="crop"
  185.                 onset="this.setAttribute('crop',val); return val;"
  186.                 onget="return this.getAttribute('crop');"/>
  187.  
  188.       <property name="label"
  189.                 onset="this.setAttribute('label',val); return val;"
  190.                 onget="return this.getAttribute('label');"/>
  191.  
  192.       <property name="open"
  193.                 onget="return this.getAttribute('open') == 'true';">
  194.         <setter><![CDATA[
  195.             if (val) {
  196.               this.setAttribute("open", "true"); 
  197.               this.showHistoryPopup();
  198.             }
  199.             else {
  200.               this.removeAttribute("open");
  201.               this.closePopup();
  202.             }
  203.         ]]></setter>
  204.       </property>
  205.  
  206.       <!-- =================== PUBLIC MEMBERS =================== -->
  207.  
  208.       <property name="value"
  209.                 onget="return this.mInputElt.value;"
  210.                 onset="this.mIgnoreInput = true; this.mInputElt.value = val; this.mIgnoreInput = false; return val;"/>
  211.  
  212.       <property name="focused" readonly="true"
  213.                 onget="return this.getAttribute('focused') == 'true';"/>
  214.  
  215.       <!-- maximum number of rows to display at a time -->
  216.       <property name="maxRows"
  217.                 onset="this.setAttribute('maxrows', val); return val;"
  218.                 onget="return parseInt(this.getAttribute('maxrows')) || 0;"/>
  219.  
  220.       <!-- option to allow scrolling through the list via the tab key, rather than
  221.            tab moving focus out of the textbox -->
  222.       <property name="tabScrolling"
  223.                 onset="return this.setAttribute('tabscrolling', val); return val;"
  224.                 onget="return this.getAttribute('tabscrolling') == 'true';"/>
  225.  
  226.       <!-- disable key navigation handling in the popup results -->
  227.       <property name="disableKeyNavigation"
  228.                 onset="this.setAttribute('disablekeynavigation', val); return val;"
  229.                 onget="return this.getAttribute('disablekeynavigation') == 'true';"/>
  230.  
  231.       <!-- option to completely ignore any blur events while  
  232.            searches are still going on.  This is useful so that nothing
  233.            gets autopicked if the window is required to lose focus for
  234.            some reason (eg in LDAP autocomplete, another window may be
  235.            brought up so that the user can enter a password to authenticate
  236.            to an LDAP server).  -->
  237.       <property name="ignoreBlurWhileSearching"
  238.                 onset="this.setAttribute('ignoreblurwhilesearching', val); return val;"
  239.                 onget="return this.getAttribute('ignoreblurwhilesearching') == 'true';"/>
  240.       
  241.       <!-- =================== PRIVATE MEMBERS =================== -->
  242.  
  243.       <!-- ::::::::::::: autocomplete controller ::::::::::::: -->
  244.  
  245.       <method name="attachController">
  246.         <body><![CDATA[
  247.           if (this.mController.input != this)
  248.             this.mController.input = this;
  249.         ]]></body>
  250.       </method>
  251.  
  252.       <method name="detachController">
  253.         <body><![CDATA[
  254.           if (this.mController.input == this)
  255.             this.mController.input = null;
  256.         ]]></body>
  257.       </method>
  258.  
  259.       <!-- ::::::::::::: popup opening ::::::::::::: -->
  260.  
  261.       <method name="openPopup">
  262.         <body><![CDATA[
  263.           this.popup.openPopup(this, this.boxObject.screenX, this.boxObject.screenY+this.boxObject.height, this.boxObject.width);
  264.         ]]></body>
  265.       </method>
  266.  
  267.       <method name="closePopup">
  268.         <body><![CDATA[
  269.           this.popup.closePopup();
  270.         ]]></body>
  271.       </method>
  272.  
  273.       <method name="showHistoryPopup">
  274.         <body><![CDATA[
  275.           this.maxRows = 14;
  276.           this.attachController();
  277.           this.mController.startSearch("");
  278.         ]]></body>
  279.       </method>
  280.       
  281.       <!-- ::::::::::::: event dispatching ::::::::::::: -->
  282.  
  283.       <method name="fireEvent">
  284.         <parameter name="aEventType"/>
  285.         <body><![CDATA[
  286.           var cancel = false;
  287.           // handle any xml attribute event handlers
  288.           var handler = this.getAttribute("on"+aEventType);
  289.           if (handler) {
  290.             var fn = new Function("eventType", "param", handler);
  291.             cancel = fn.apply(this, arguments);
  292.           }
  293.           
  294.           return cancel;
  295.         ]]></body>
  296.       </method>
  297.  
  298.       <!-- ::::::::::::: key handling ::::::::::::: -->
  299.  
  300.       <method name="onKeyPress">
  301.         <parameter name="aEvent"/>
  302.         <body><![CDATA[
  303.           //XXXpch this is so bogus...
  304.           if (aEvent.getPreventDefault())
  305.             return false;
  306.  
  307.           var cancel = false;
  308.           const IController = Components.interfaces.nsIAutoCompleteController;
  309.           
  310.           if (!this.disableKeyNavigation) {
  311.             switch (aEvent.keyCode) {
  312.               case KeyEvent.DOM_VK_TAB:
  313.                 if (this.tabScrolling && this.popup.mPopupOpen)
  314.                   cancel = this.mController.handleKeyNavigation(aEvent.shiftKey ? IController.KEY_UP : IController.KEY_DOWN);
  315.                 break;
  316.               case KeyEvent.DOM_VK_UP:
  317.                 cancel = this.mController.handleKeyNavigation(IController.KEY_UP);
  318.                 break;
  319.               case KeyEvent.DOM_VK_DOWN:
  320.                 cancel = this.mController.handleKeyNavigation(IController.KEY_DOWN);
  321.                 break;
  322.               case KeyEvent.DOM_VK_LEFT:
  323.                 cancel = this.mController.handleKeyNavigation(IController.KEY_LEFT);
  324.                 break;
  325.               case KeyEvent.DOM_VK_RIGHT:
  326.                 cancel = this.mController.handleKeyNavigation(IController.KEY_RIGHT);
  327.                 break;
  328.               case KeyEvent.DOM_VK_PAGE_UP:
  329.                 cancel = this.mController.handleKeyNavigation(IController.KEY_PAGE_UP);
  330.                 break;
  331.               case KeyEvent.DOM_VK_PAGE_DOWN:
  332.                 cancel = this.mController.handleKeyNavigation(IController.KEY_PAGE_DOWN);
  333.                 break;
  334.             }
  335.           }
  336.           
  337.           switch (aEvent.keyCode) {
  338.             case KeyEvent.DOM_VK_ESCAPE:
  339.               cancel = this.mController.handleEscape();
  340.               break;
  341.             case KeyEvent.DOM_VK_RETURN:
  342.               this.mEnterEvent = aEvent;
  343.               cancel = this.mController.handleEnter();
  344.               break;
  345.             case KeyEvent.DOM_VK_DELETE:
  346.               if (aEvent.shiftKey)
  347.                 cancel = this.mController.handleDelete();
  348.               break;
  349.           }
  350.  
  351.           if (cancel) {
  352.             aEvent.stopPropagation();
  353.             aEvent.preventDefault();
  354.           }
  355.           
  356.           return true;
  357.         ]]></body>
  358.       </method>
  359.  
  360.       <!-- ::::::::::::: miscellaneous ::::::::::::: -->
  361.  
  362.       <method name="initSearchNames">
  363.         <body><![CDATA[
  364.           if (!this.mSearchNames) {
  365.             var names = this.getAttribute("autocompletesearch");
  366.             if (!names)
  367.               this.mSearchNames = [];
  368.             else
  369.               this.mSearchNames = names.split(" ");
  370.           }
  371.         ]]></body>
  372.       </method>
  373.  
  374.       <method name="ifSetAttribute">
  375.         <parameter name="aAttr"/>
  376.         <parameter name="aVal"/>
  377.         <body><![CDATA[
  378.           if (!this.hasAttribute(aAttr))
  379.             this.setAttribute(aAttr, aVal);
  380.         ]]></body>
  381.       </method>
  382.  
  383.     </implementation>
  384.  
  385.     <handlers>
  386.       <handler event="input"
  387.                action="if (!this.mIgnoreInput) this.mController.handleText(false);"/>
  388.  
  389.       <handler event="keypress" phase="capturing"
  390.                action="return this.onKeyPress(event);"/>
  391.  
  392.       <handler event="focus" phase="capturing"
  393.                action="this.attachController();"/>
  394.  
  395.       <handler event="blur" phase="capturing"
  396.                action="this.detachController();"/>
  397.                
  398.       <handler event="dblclick">
  399.       <![CDATA[
  400.         if (event.originalTarget.className == "info-icon" && event.button == 0)
  401.           return this.fireEvent("infoclick");
  402.         return true;
  403.       ]]>
  404.       </handler>
  405.     </handlers>
  406.   </binding> 
  407.  
  408.   <binding id="autocomplete-result-popup" extends="chrome://global/content/bindings/popup.xml#popup">
  409.     <resources>
  410.       <stylesheet src="chrome://global/skin/tree.css"/>
  411.       <stylesheet src="chrome://global/skin/autocomplete.css"/>
  412.     </resources>
  413.  
  414.     <content>
  415.       <xul:tree anonid="tree" class="autocomplete-tree plain" hidecolumnpicker="true" flex="1">
  416.         <xul:treecols anonid="treecols">
  417.           <xul:treecol id="treecolAutoCompleteValue" class="autocomplete-treecol" flex="1"/>
  418.         </xul:treecols>
  419.         <xul:treechildren class="autocomplete-treebody"/>
  420.       </xul:tree>
  421.     </content>
  422.     
  423.     <implementation implements="nsIAutoCompletePopup">
  424.       <field name="mInput">null</field>
  425.       <field name="mPopupOpen">false</field>
  426.       <field name="mShowCommentCol">false</field>
  427.       
  428.       <constructor><![CDATA[
  429.         this.setAttribute("ignorekeys", "true");
  430.       ]]></constructor>
  431.  
  432.       <!-- =================== nsIAutoCompletePopup =================== -->
  433.  
  434.       <property name="input"
  435.                 onget="return this.mInput"/>
  436.  
  437.       <property name="overrideValue" readonly="true"
  438.                 onget="return null;"/>
  439.  
  440.       <property name="selectedIndex"
  441.                 onget="return this.tree.currentIndex;">
  442.         <setter><![CDATA[
  443.           this.tree.treeBoxObject.selection.select(val);
  444.           if (this.tree.treeBoxObject.height > 0)
  445.             this.tree.treeBoxObject.ensureRowIsVisible(val < 0 ? 0 : val);
  446.           return val;
  447.         ]]></setter>
  448.       </property>
  449.  
  450.       <property name="popupOpen" readonly="true"
  451.                 onget="return this.mPopupOpen;"/>
  452.  
  453.       <method name="openPopup">
  454.         <parameter name="aInput"/>
  455.         <parameter name="aX"/>
  456.         <parameter name="aY"/>
  457.         <parameter name="aWidth"/>
  458.         <body><![CDATA[
  459.           if (!this.mPopupOpen) {
  460.             this.mInput = aInput;
  461.             this.view = aInput.controller.QueryInterface(Components.interfaces.nsITreeView);
  462.             this.invalidate();
  463.             
  464.             this.showCommentColumn = this.mInput.showCommentColumn;
  465.             
  466.             this.removeAttribute("hidden");
  467.             this.setAttribute("width", aWidth < 100 ? 100 : aWidth);
  468.  
  469.             document.popupNode = null;
  470.             this.showPopup(document.documentElement, aX, aY, "popup", null, null);
  471.           }
  472.         ]]></body>
  473.       </method>
  474.  
  475.       <method name="closePopup">
  476.         <body><![CDATA[
  477.           if (this.mPopupOpen) {
  478.             this.hidePopup();
  479.             document.popupNode = null;
  480.  
  481.             this.setAttribute("hidden", "true");
  482.           }
  483.         ]]></body>
  484.       </method>
  485.  
  486.       <method name="invalidate">
  487.         <body><![CDATA[
  488.           this.adjustHeight();
  489.           this.tree.treeBoxObject.invalidate();
  490.         ]]></body>
  491.       </method>
  492.  
  493.       <method name="selectBy">
  494.         <parameter name="aReverse"/>
  495.         <parameter name="aPage"/>
  496.         <body><![CDATA[
  497.           try {
  498.             var amount = aPage ? 5 : 1;
  499.             this.selectedIndex = this.getNextIndex(aReverse, amount, this.selectedIndex, this.tree.view.rowCount-1);
  500.           } catch (ex) {
  501.             // do nothing - occasionally timer-related js errors happen here
  502.             // e.g. "this.selectedIndex has no properties", when you type fast and hit a
  503.             // navigation key before this popup has opened
  504.           }
  505.         ]]></body>
  506.       </method>
  507.  
  508.       <!-- =================== PUBLIC MEMBERS =================== -->
  509.  
  510.       <field name="tree">
  511.         document.getAnonymousElementByAttribute(this, "anonid", "tree");
  512.       </field>
  513.  
  514.       <field name="treecols">
  515.         document.getAnonymousElementByAttribute(this, "anonid", "treecols");
  516.       </field>
  517.  
  518.       <property name="view" 
  519.                 onget="return this.mView;">
  520.         <setter><![CDATA[
  521.           // We must do this by hand because the tree binding may not be ready yet
  522.           this.mView = val;
  523.           var bx = this.tree.boxObject;
  524.           bx = bx.QueryInterface(Components.interfaces.nsITreeBoxObject);
  525.           bx.view = val;
  526.         ]]></setter>
  527.       </property>
  528.  
  529.       <property name="maxRows" readonly="true">
  530.         <getter><![CDATA[
  531.           return (this.mInput && this.mInput.maxRows) || 6;
  532.         ]]></getter>
  533.       </property>
  534.  
  535.       <property name="showCommentColumn"
  536.                 onget="return this.mShowCommentColumn;">
  537.         <setter><![CDATA[
  538.           if (!val && this.mShowCommentColumn) {
  539.             // reset the flex on the value column and add the comment column
  540.             document.getElementById("treecolAutoCompleteValue").setAttribute("flex", 1);
  541.             this.removeColumn("treecolAutoCompleteComment");
  542.           } else if (val && !this.mShowCommentColumn) {
  543.             // reset the flex on the value column and add the comment column
  544.             document.getElementById("treecolAutoCompleteValue").setAttribute("flex", 2);
  545.             this.addColumn({id: "treecolAutoCompleteComment", flex: 1});
  546.           }
  547.           this.mShowCommentColumn = val;
  548.           return val;
  549.         ]]></setter>
  550.       </property>
  551.  
  552.       <method name="addColumn">
  553.         <parameter name="aAttrs"/>
  554.         <body><![CDATA[
  555.           var col = document.createElement("treecol");
  556.           col.setAttribute("class", "autocomplete-treecol");
  557.           for (var name in aAttrs)
  558.             col.setAttribute(name, aAttrs[name]);
  559.           this.treecols.appendChild(col);
  560.           return col;
  561.         ]]></body>
  562.       </method>
  563.  
  564.       <method name="removeColumn">
  565.         <parameter name="aColId"/>
  566.         <body><![CDATA[
  567.           return this.treecols.removeChild(document.getElementById(aColId));
  568.         ]]></body>
  569.       </method>
  570.  
  571.       <method name="adjustHeight">
  572.         <body><![CDATA[
  573.           // detect the desired height of the tree
  574.           var bx = this.tree.treeBoxObject;
  575.           var view = this.tree.view;
  576.           var rows = this.maxRows;
  577.           if (!view.rowCount || (rows && view.rowCount < rows))
  578.             rows = view.rowCount;
  579.           
  580.           var height = rows * bx.rowHeight;
  581.           
  582.           if (height == 0)
  583.             this.tree.setAttribute("collapsed", "true");
  584.           else {
  585.             if (this.tree.hasAttribute("collapsed"))
  586.               this.tree.removeAttribute("collapsed");
  587.  
  588.             this.tree.setAttribute("height", height);
  589.           }
  590.           this.tree.setAttribute("hidescrollbar", view.rowCount <= rows);
  591.         ]]></body>
  592.       </method>
  593.  
  594.       <method name="getNextIndex">
  595.         <parameter name="aReverse"/>
  596.         <parameter name="aAmount"/>
  597.         <parameter name="aIndex"/>
  598.         <parameter name="aMaxRow"/>
  599.         <body><![CDATA[
  600.           if (aMaxRow < 0)
  601.             return -1;
  602.           
  603.           var newIdx = aIndex + (aReverse?-1:1)*aAmount;
  604.           if (aReverse && aIndex == -1 || newIdx > aMaxRow && aIndex != aMaxRow)
  605.             newIdx = aMaxRow;
  606.           else if (!aReverse && aIndex == -1 || newIdx < 0 && aIndex != 0)
  607.             newIdx = 0;
  608.           
  609.           if (newIdx < 0 && aIndex == 0 || newIdx > aMaxRow && aIndex == aMaxRow)
  610.             aIndex = -1;
  611.           else
  612.             aIndex = newIdx;
  613.           
  614.           return aIndex;
  615.         ]]></body>
  616.       </method>
  617.  
  618.       <method name="onPopupClick">
  619.         <parameter name="aEvent"/>
  620.         <body><![CDATA[
  621.           var controller = this.view.QueryInterface(Components.interfaces.nsIAutoCompleteController);
  622.           controller.handleEnter();
  623.         ]]></body>
  624.       </method>
  625.       
  626.       <method name="clearOpenProperty">
  627.         <parameter name="aPopupNode"/>
  628.         <body><![CDATA[
  629.           aPopupNode.mPopupOpen = false;
  630.         ]]></body>
  631.       </method>
  632.  
  633.     </implementation>
  634.  
  635.     <handlers>
  636.       <handler event="popupshowing">
  637.         this.mPopupOpen = true;
  638.       </handler>
  639.  
  640.       <handler event="popuphiding">
  641.         setTimeout(this.clearOpenProperty, 0, this);
  642.         this.mInput.maxRows = 6;
  643.       </handler>
  644.     </handlers>
  645.   </binding>
  646.  
  647.   <binding id="autocomplete-tree" extends="chrome://global/content/bindings/tree.xml#tree">
  648.     <content>
  649.       <children includes="treecols"/>
  650.       <xul:treerows class="autocomplete-treerows tree-rows" xbl:inherits="hidescrollbar" flex="1">
  651.         <children/>
  652.       </xul:treerows>
  653.     </content>
  654.   </binding>
  655.  
  656.   <binding id="autocomplete-treebody">
  657.     <implementation>
  658.       <field name="mLastMoveTime">new Date()</field>
  659.  
  660.       <method name="getHoverCell">
  661.         <parameter name="aEvent"/>
  662.         <body><![CDATA[
  663.            var row = {}; var col = {}; var obj = {};
  664.            var x = aEvent.screenX - this.boxObject.screenX + this.boxObject.x;
  665.            var y = aEvent.screenY - this.boxObject.screenY + this.boxObject.y;
  666.            this.parentNode.treeBoxObject.getCellAt(x, y, row, col, obj);
  667.            if (row.value >= 0)
  668.              return {row: row.value, column: col.value};
  669.            else
  670.             return null;
  671.         ]]></body>
  672.       </method>
  673.     </implementation>
  674.     
  675.     <handlers>
  676.       <handler event="mouseout" action="this.parentNode.currentIndex = -1;"/>
  677.       <handler event="mouseup" action="this.parentNode.parentNode.onPopupClick(event);"/>
  678.  
  679.       <handler event="mousemove"><![CDATA[
  680.         if (new Date() - this.mLastMoveTime > 30) {
  681.          var rc = this.getHoverCell(event);
  682.          if (rc && rc.row != this.parentNode.currentIndex)
  683.             this.parentNode.treeBoxObject.selection.select(rc.row);
  684.          this.mLastMoveTime = new Date();
  685.         }
  686.       ]]></handler>
  687.     </handlers>
  688.   </binding>
  689.  
  690.   <binding id="autocomplete-treerows">
  691.     <content onmousedown="event.preventDefault()">
  692.       <xul:hbox flex="1" class="tree-bodybox">
  693.         <children/>
  694.       </xul:hbox>
  695.       <xul:scrollbar xbl:inherits="collapsed=hidescrollbar" orient="vertical" class="tree-scrollbar"/>
  696.     </content>
  697.   </binding>
  698.  
  699.   <binding id="history-dropmarker" extends="xul:button">
  700.     <content>
  701.       <xul:image class="dropmarker-image"/>
  702.     </content>
  703.       
  704.     <implementation implements="nsIAccessibleProvider">
  705.       <property name="accessible">
  706.         <getter>
  707.           <![CDATA[
  708.             var accService = Components.classes["@mozilla.org/accessibilityService;1"].getService(Components.interfaces.nsIAccessibilityService);
  709.             return accService.createXULDropmarkerAccessible(this);
  710.           ]]>
  711.         </getter>
  712.       </property>
  713.  
  714.       <method name="showPopup">
  715.         <body><![CDATA[
  716.           var textbox = document.getBindingParent(this);
  717.           if (!textbox.popup.mPopupOpen) { 
  718.             textbox.showHistoryPopup();
  719.           }
  720.         ]]></body>
  721.       </method>
  722.     </implementation>
  723.     
  724.     <handlers>
  725.       <handler event="mousedown" button="0"><![CDATA[
  726.         this.showPopup();
  727.       ]]></handler>
  728.     </handlers>
  729.   </binding>
  730.  
  731. </bindings>
  732.  
  733.