home *** CD-ROM | disk | FTP | other *** search
/ PC World 2003 May / PCWorld_2003-05_cd.bin / Komunik / phoenix / chrome / toolkit.jar / content / global / widgets / autocomplete.xml next >
Extensible Markup Language  |  2002-10-11  |  25KB  |  696 lines

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