Bug 1400243 - 2. Small fixes to ActionBarHandler and FormAssistant; r?esawin draft
authorJim Chen <nchen@mozilla.com>
Tue, 19 Sep 2017 15:57:19 -0400
changeset 667171 716c2fad00667e28bba3502c162be76f59716e75
parent 667170 8abd345a56058afb663f7eef54dca568992b0a2f
child 732314 9f7e47bce9307b17c26c71fe61e42b916bb1f8e2
push id80633
push userbmo:nchen@mozilla.com
push dateTue, 19 Sep 2017 19:57:50 +0000
reviewersesawin
bugs1400243
milestone57.0a1
Bug 1400243 - 2. Small fixes to ActionBarHandler and FormAssistant; r?esawin Small fixes to ride-along in this bug: * Use localized ellipsis in ActionBarHandler if available. * Fix one situation where the FormAssistPopup fails to hide. * Handle an error case in FormAssistant. MozReview-Commit-ID: 9EZhPnS5h3E
mobile/android/modules/ActionBarHandler.jsm
mobile/android/modules/FormAssistant.jsm
--- a/mobile/android/modules/ActionBarHandler.jsm
+++ b/mobile/android/modules/ActionBarHandler.jsm
@@ -657,17 +657,23 @@ var ActionBarHandler = {
           // Allow if selected text exists.
           return (ActionBarHandler._getSelectedText().length > 0);
         },
       },
 
       action: function(element, win) {
         let title = win.document.title;
         if (title && title.length > 200) {
-          title = title.slice(0, 200) + "\u2026"; // Add ellipsis.
+          let ellipsis = "\u2026";
+          try {
+            ellipsis = Services.prefs.getComplexValue(
+                "intl.ellipsis", Ci.nsIPrefLocalizedString).data;
+          } catch (e) {
+          }
+          title = title.slice(0, 200) + ellipsis; // Add ellipsis.
         } else if (!title) {
           title = win.location.href;
         }
         EventDispatcher.instance.sendRequest({
           type: "Share:Text",
           text: ActionBarHandler._getSelectedText(),
           title: title,
         });
--- a/mobile/android/modules/FormAssistant.jsm
+++ b/mobile/android/modules/FormAssistant.jsm
@@ -111,16 +111,20 @@ var FormAssistant = {
         if (this._showValidationMessage(currentElement) ||
             this._isAutoComplete(currentElement)) {
           this._currentFocusedElement = Cu.getWeakReference(currentElement);
         }
         break;
       }
 
       case "blur": {
+        let focused = this._currentFocusedElement && this._currentFocusedElement.get();
+        if (focused) {
+          this._hideFormAssistPopup(focused);
+        }
         this._currentFocusedElement = null;
         break;
       }
 
       case "click": {
         let currentElement = aEvent.target;
 
         // Prioritize a form validation message over autocomplete suggestions
@@ -302,16 +306,19 @@ var FormAssistant = {
       type: "FormAssist:ValidationMessage",
       validationMessage: aElement.validationMessage,
       rect: this._getBoundingContentRect(aElement),
     });
     return true;
   },
 
   _hideFormAssistPopup: function(aElement) {
+    if (!aElement.ownerGlobal) {
+      return;
+    }
     GeckoViewUtils.getDispatcherForWindow(aElement.ownerGlobal).sendRequest({
       type: "FormAssist:Hide",
     });
   },
 
   _isDisabledElement: function(aElement) {
     let currentElement = aElement;
     while (currentElement) {