Bug 828990 - Hide thumb on compositionend. r=margaret, f=jchen, a=bajaj
authorBrian Nicholson <bnicholson@mozilla.com>
Thu, 21 Mar 2013 13:07:07 -0700
changeset 128708 90b3c33b1eddc019ea175940ac908cdf88111cf6
parent 128707 7fb5d55e62dfacbadf6ba33d2cad2ad746009599
child 128709 fc077ab0cebf06003fd9bf75c8fc8d32e5e50e26
push id3564
push userryanvm@gmail.com
push dateThu, 28 Mar 2013 14:51:16 +0000
treeherdermozilla-aurora@ac5ed16b6a74 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmargaret, bajaj
bugs828990
milestone21.0a2
Bug 828990 - Hide thumb on compositionend. r=margaret, f=jchen, a=bajaj
mobile/android/chrome/content/browser.js
--- a/mobile/android/chrome/content/browser.js
+++ b/mobile/android/chrome/content/browser.js
@@ -82,30 +82,16 @@ XPCOMUtils.defineLazyServiceGetter(windo
 XPCOMUtils.defineLazyServiceGetter(this, "MediaManagerService",
   "@mozilla.org/mediaManagerService;1", "nsIMediaManagerService");
 #endif
 
 const kStateActive = 0x00000001; // :active pseudoclass for elements
 
 const kXLinkNamespace = "http://www.w3.org/1999/xlink";
 
-// The element tag names that are considered to receive input. Mouse-down
-// events directed to one of these are allowed to go through.
-const kElementsReceivingInput = {
-    applet: true,
-    audio: true,
-    button: true,
-    embed: true,
-    input: true,
-    map: true,
-    select: true,
-    textarea: true,
-    video: true
-};
-
 const kDefaultCSSViewportWidth = 980;
 const kDefaultCSSViewportHeight = 480;
 
 function dump(a) {
   Cc["@mozilla.org/consoleservice;1"].getService(Ci.nsIConsoleService).logStringMessage(a);
 }
 
 function getBridge() {
@@ -1950,25 +1936,27 @@ var SelectionHandler = {
 
   init: function sh_init() {
     Services.obs.addObserver(this, "Gesture:SingleTap", false);
     Services.obs.addObserver(this, "Window:Resize", false);
     Services.obs.addObserver(this, "Tab:Selected", false);
     Services.obs.addObserver(this, "after-viewport-change", false);
     Services.obs.addObserver(this, "TextSelection:Move", false);
     Services.obs.addObserver(this, "TextSelection:Position", false);
+    BrowserApp.deck.addEventListener("compositionend", this, false);
   },
 
   uninit: function sh_uninit() {
     Services.obs.removeObserver(this, "Gesture:SingleTap");
     Services.obs.removeObserver(this, "Window:Resize");
     Services.obs.removeObserver(this, "Tab:Selected");
     Services.obs.removeObserver(this, "after-viewport-change");
     Services.obs.removeObserver(this, "TextSelection:Move");
     Services.obs.removeObserver(this, "TextSelection:Position");
+    BrowserApp.deck.removeEventListener("compositionend", this);
   },
 
   observe: function sh_observe(aSubject, aTopic, aData) {
     switch (aTopic) {
       case "Gesture:SingleTap": {
         if (this._activeType == this.TYPE_SELECTION) {
           let data = JSON.parse(aData);
           this.endSelection(data.x, data.y);
@@ -2044,16 +2032,23 @@ var SelectionHandler = {
           this.hideThumb();
         break;
 
       case "keydown":
       case "blur":
         if (this._activeType == this.TYPE_CURSOR)
           this.hideThumb();
         break;
+
+      case "compositionend":
+        // If the handles are displayed during user input, hide them.
+        if (this._activeType == this.TYPE_CURSOR) {
+          this.hideThumb();
+        }
+        break;
     }
   },
 
   _ignoreCollapsedSelection: false,
 
   notifySelectionChanged: function sh_notifySelectionChanged(aDoc, aSel, aReason) {
     if (aSel.isCollapsed) {
       // Bail if we're ignoring events for a collapsed selection.
@@ -4492,36 +4487,16 @@ var BrowserEventHandler = {
     }
 
     if (!scrollable)
       return null;
 
     return elem;
   },
 
-  _elementReceivesInput: function(aElement) {
-    return aElement instanceof Element &&
-        kElementsReceivingInput.hasOwnProperty(aElement.tagName.toLowerCase()) ||
-        this._isEditable(aElement);
-  },
-
-  _isEditable: function(aElement) {
-    let canEdit = false;
-
-    if (aElement.isContentEditable || aElement.designMode == "on") {
-      canEdit = true;
-    } else if (aElement instanceof HTMLIFrameElement && (aElement.contentDocument.body.isContentEditable || aElement.contentDocument.designMode == "on")) {
-      canEdit = true;
-    } else {
-      canEdit = aElement.ownerDocument && aElement.ownerDocument.designMode == "on";
-    }
-
-    return canEdit;
-  },
-
   _scrollElementBy: function(elem, x, y) {
     elem.scrollTop = elem.scrollTop + y;
     elem.scrollLeft = elem.scrollLeft + x;
   },
 
   _elementCanScroll: function(elem, x, y) {
     let scrollX = (x < 0 && elem.scrollLeft > 0)
                || (x > 0 && elem.scrollLeft < (elem.scrollWidth - elem.clientWidth));
@@ -5073,16 +5048,17 @@ var FormAssistant = {
         // Prioritize a form validation message over autocomplete suggestions
         // when the element is first focused (a form validation message will
         // only be available if an invalid form was submitted)
         if (this._showValidationMessage(currentElement))
           break;
         if (!this._showAutoCompleteSuggestions(currentElement))
           this._hideFormAssistPopup();
         break;
+
       case "input":
         currentElement = aEvent.target;
 
         // Since we can only show one popup at a time, prioritze autocomplete
         // suggestions over a form validation message
         if (this._showAutoCompleteSuggestions(currentElement))
           break;
         if (this._showValidationMessage(currentElement))