Bug 959209 - Investigate whether Thunderbird still needs the XPFE autocomplete widget. r=standard8 a=[avoid bustage since m-c part landed]
authorMagnus Melin <mkmelin+mozilla@iki.fi>
Sun, 27 Apr 2014 22:54:03 +0300
changeset 16117 62d03039a71812e5246f512a4aa160dde4f19a3d
parent 16116 b940fa424367d7eb34ce2811d29b779b982535ba
child 16118 416056a645fe0ba386be7556030d0b92b1452861
push id10079
push usermkmelin@iki.fi
push dateSun, 27 Apr 2014 19:55:11 +0000
treeherdercomm-central@62d03039a718 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersstandard8
bugs959209
Bug 959209 - Investigate whether Thunderbird still needs the XPFE autocomplete widget. r=standard8 a=[avoid bustage since m-c part landed]
bridge/bridge.mozbuild
mail/components/addrbook/content/abEditListDialog.xul
mail/components/addrbook/content/abMailListDialog.xul
mail/components/compose/content/addressingWidgetOverlay.js
mail/components/compose/content/messengercompose.xul
mailnews/addrbook/src/nsAbLDAPAutoCompleteSearch.js
--- a/bridge/bridge.mozbuild
+++ b/bridge/bridge.mozbuild
@@ -1,18 +1,16 @@
 # vim: set filetype=python:
 # This Source Code Form is subject to the terms of the Mozilla Public
 # License, v. 2.0. If a copy of the MPL was not distributed with this
 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
 
 mailnews_dirs = []
 mailnews_static_dirs = []
 
-mailnews_dirs += ['../mozilla/xpfe/components/autocomplete']
-
 if CONFIG['MOZ_LDAP_XPCOM']:
     mailnews_dirs += ['../ldap']
     mailnews_dirs += ['../ldap/xpcom']
 
 if CONFIG['MOZ_MORK']:
     mailnews_dirs += ['../db']
 
 mailnews_dirs += ['../mailnews']
--- a/mail/components/addrbook/content/abEditListDialog.xul
+++ b/mail/components/addrbook/content/abEditListDialog.xul
@@ -56,17 +56,17 @@
       <listitem class="addressingWidgetItem" allowevents="true">
         <listcell class="addressingWidgetCell">
           <textbox id="addressCol1#1" class="plain textbox-addressingWidget uri-element"
                    type="autocomplete" flex="1"
                    autocompletesearch="addrbook ldap"
                    autocompletesearchparam="{}" timeout="300" maxrows="4"
                    completedefaultindex="true" forcecomplete="true"
                    minresultsforpopup="3"
-                   ontextentered="awRecipientTextCommand(eventParam, this)"
+                   ontextentered="awRecipientTextCommand(param, this)"
                    onkeypress="handleKeyPress(this, event);"
                    onkeydown="awRecipientKeyDown(event, this);"
                    onclick="awNotAnEmptyArea(event);">
             <image onclick="this.parentNode.select();" class="person-icon"/>
           </textbox>
         </listcell>
       </listitem>
     </listbox>
--- a/mail/components/addrbook/content/abMailListDialog.xul
+++ b/mail/components/addrbook/content/abMailListDialog.xul
@@ -66,17 +66,17 @@
       <listitem class="addressingWidgetItem" allowevents="true">
         <listcell class="addressingWidgetCell">
           <textbox id="addressCol1#1" class="plain textbox-addressingWidget uri-element"
                    type="autocomplete" flex="1"
                    autocompletesearch="addrbook ldap"
                    autocompletesearchparam="{}" timeout="300" maxrows="4"
                    completedefaultindex="true" forcecomplete="true"
                    minresultsforpopup="3"
-                   ontextentered="awRecipientTextCommand(eventParam, this)"
+                   ontextentered="awRecipientTextCommand(param, this)"
                    onkeypress="handleKeyPress(this, event);"
                    onkeydown="awRecipientKeyDown(event, this);"
                    onclick="awNotAnEmptyArea(event);">
             <image onclick="this.parentNode.select();" class="person-icon"/>
           </textbox>
         </listcell>            
       </listitem>
     </listbox>
--- a/mail/components/compose/content/addressingWidgetOverlay.js
+++ b/mail/components/compose/content/addressingWidgetOverlay.js
@@ -772,109 +772,45 @@ function _awSetAutoComplete(selectElem, 
 
 function awSetAutoComplete(rowNumber)
 {
     var inputElem = awGetInputElement(rowNumber);
     var selectElem = awGetPopupElement(rowNumber);
     _awSetAutoComplete(selectElem, inputElem)
 }
 
-function awRecipientTextCommand(userAction, element)
-{
-  if (userAction == "typing" || userAction == "scrolling")
-    awReturnHit(element);
-}
-
-// Called when an autocomplete session item is selected and the status of
-// the session it was selected from is nsIAutoCompleteStatus::failureItems.
-//
-// As of this writing, the only way that can happen is when an LDAP
-// autocomplete session returns an error to be displayed to the user.
-//
-// There are hardcoded messages in here, but these are just fallbacks for
-// when string bundles have already failed us.
-//
-function awRecipientErrorCommand(errItem, element)
+function awRecipientTextCommand(enterEvent, element)
 {
-  // remove the angle brackets from the general error message to construct
-  // the title for the alert.  someday we'll pass this info using a real
-  // exception object, and then this code can go away.
-  //
-  var generalErrString;
-  if (errItem.value != "")
-    generalErrString = errItem.value.slice(1, errItem.value.length-1);
-  else
-    generalErrString = "Unknown LDAP server problem encountered";
-
-  // try and get the string of the specific error to contruct the complete
-  // err msg, otherwise fall back to something generic.  This message is
-  // handed to us as an nsISupportsString in the param slot of the
-  // autocomplete error item, by agreement documented in
-  // nsILDAPAutoCompFormatter.idl
-  //
-  var specificErrString = "";
-  try
-  {
-    var specificError = errItem.param.QueryInterface(Components.interfaces.nsISupportsString);
-    specificErrString = specificError.data;
-  } catch (ex)
-  {}
-
-  if (specificErrString == "")
-    specificErrString = "Internal error";
-
-  Services.prompt.alert(window, generalErrString, specificErrString);
+  awReturnHit(element);
 }
 
 function awRecipientKeyPress(event, element)
 {
   switch(event.keyCode) {
-  case KeyEvent.DOM_VK_UP:
-    awArrowHit(element, -1);
-    break;
-  case KeyEvent.DOM_VK_DOWN:
-    awArrowHit(element, 1);
-    break;
   case KeyEvent.DOM_VK_RETURN:
   case KeyEvent.DOM_VK_TAB:
     // if the user text contains a comma or a line return, ignore
     if (element.value.contains(','))
     {
       var addresses = element.value;
       element.value = ""; // clear out the current line so we don't try to autocomplete it..
       parseAndAddAddresses(addresses, awGetPopupElement(awGetRowByInputElement(element)).selectedItem.getAttribute("value"));
     }
     else if (event.keyCode == KeyEvent.DOM_VK_TAB)
       awTabFromRecipient(element, event);
 
     break;
   }
 }
 
-function awArrowHit(inputElement, direction)
-{
-  var row = awGetRowByInputElement(inputElement) + direction;
-  if (row) {
-    var nextInput = awGetInputElement(row);
-
-    if (nextInput)
-      awSetFocus(row, nextInput);
-    else if (inputElement.value)
-      awAppendNewRow(true);
-  }
-}
-
 function awRecipientKeyDown(event, element)
 {
   switch(event.keyCode) {
   case KeyEvent.DOM_VK_DELETE:
   case KeyEvent.DOM_VK_BACK_SPACE:
-    /* do not query directly the value of the text field else the autocomplete widget could potentially
-       alter it value while doing some internal cleanup, instead, query the value through the first child
-    */
     if (!element.value)
       awDeleteHit(element);
 
     // We need to stop the event else the listbox will receive it and the
     // function awKeyDown will be executed!
     event.stopPropagation();
     break;
   }
--- a/mail/components/compose/content/messengercompose.xul
+++ b/mail/components/compose/content/messengercompose.xul
@@ -935,18 +935,17 @@
                 <textbox id="addressCol2#1" class="plain textbox-addressingWidget uri-element"
                          aria-labelledby="addressCol1#1"
                          type="autocomplete" flex="1"
                          autocompletesearch="mydomain addrbook ldap news"
                          autocompletesearchparam="{}"
                          timeout="300" maxrows="4"
                          completedefaultindex="true" forcecomplete="true"
                          minresultsforpopup="2" ignoreblurwhilesearching="true"
-                         ontextentered="awRecipientTextCommand(eventParam, this)"
-                         onerrorcommand="awRecipientErrorCommand(eventParam, this)"
+                         ontextentered="awRecipientTextCommand(param, this)"
                          onchange="onRecipientsChanged();"
                          oninput="onRecipientsChanged();"
                          onkeypress="awRecipientKeyPress(event, this)"
                          onkeydown="awRecipientKeyDown(event, this)"
                          disableonsend="true">
                 </textbox>
               </listcell>
             </listitem>
--- a/mailnews/addrbook/src/nsAbLDAPAutoCompleteSearch.js
+++ b/mailnews/addrbook/src/nsAbLDAPAutoCompleteSearch.js
@@ -158,17 +158,16 @@ nsAbLDAPAutoCompleteSearch.prototype = {
   },
 
   // nsIAutoCompleteSearch
 
   startSearch: function startSearch(aSearchString, aParam,
                                     aPreviousResult, aListener) {
     let params = JSON.parse(aParam);
     let applicable = !params.type || this.applicableHeaders.has(params.type);
-    let idKey = params.idKey;
 
     this._result = new nsAbLDAPAutoCompleteResult(aSearchString);
     aSearchString = aSearchString.toLocaleLowerCase();
 
     // If the search string isn't value, or contains a comma, or the user
     // hasn't enabled autocomplete, then just return no matches / or the
     // result ignored.
     // The comma check is so that we don't autocomplete against the user
@@ -179,19 +178,19 @@ nsAbLDAPAutoCompleteSearch.prototype = {
       return;
     }
 
     // The rules here: If the current identity has a directoryServer set, then
     // use that, otherwise, try the global preference instead.
     var acDirURI = null;
     var identity;
 
-    if (idKey) {
+    if (params.idKey) {
       try {
-        identity = MailServices.accounts.getIdentity(idKey);
+        identity = MailServices.accounts.getIdentity(params.idKey);
       }
       catch(ex) {
         Components.utils.reportError("Couldn't get specified identity, " +
                                      "falling back to global settings");
       }
     }
 
     // Does the current identity override the global preference?