Bug 617077 - Form helper doesn't disappear after searching on grooveshark [r=mfinkle]
authorVivien Nicolas <21@vingtetun.org>
Fri, 25 Mar 2011 10:29:31 +0100
changeset 67536 0a6bc90779a8f75e7ec1fae9cc42732f9d487b12
parent 67535 bcaa623a76961dd178763dd276bd0bfd0072543b
child 67537 5ff877afac4da3c107a91e2da5b2f3a0c17c4542
push id1
push userroot
push dateTue, 26 Apr 2011 22:38:44 +0000
treeherdermozilla-beta@bfdb6e623a36 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmfinkle
bugs617077
Bug 617077 - Form helper doesn't disappear after searching on grooveshark [r=mfinkle]
mobile/chrome/content/forms.js
--- a/mobile/chrome/content/forms.js
+++ b/mobile/chrome/content/forms.js
@@ -394,16 +394,20 @@ FormAssistant.prototype = {
               this.currentIndex = this.currentIndex;
               return;
             }
 
             this.currentIndex--;
             break;
 
           case aEvent.DOM_VK_RETURN:
+            if (!this._isVisibleElement(currentElement))
+              this.close();
+            break;
+
           case aEvent.DOM_VK_ESCAPE:
           case aEvent.DOM_VK_TAB:
             break;
 
           default:
             if (this._isAutocomplete(aEvent.target))
               sendAsyncMessage("FormAssist:AutoComplete", this._getJSON());
             else if (currentElement && this._isSelectElement(currentElement))
@@ -535,17 +539,17 @@ FormAssistant.prototype = {
   _isSelectElement: function formHelperIsSelectElement(aElement) {
     return (aElement instanceof HTMLSelectElement || aElement instanceof XULMenuListElement);
   },
 
   /** Caret is used to input text for this element. */
   _getCaretRect: function _formHelperGetCaretRect() {
     let element = this.currentElement;
     let focusedElement = gFocusManager.getFocusedElementForWindow(content, true, {});
-    if ((element.mozIsTextField && element.mozIsTextField(false) ||
+    if (element && (element.mozIsTextField && element.mozIsTextField(false) ||
         element instanceof HTMLTextAreaElement) && focusedElement == element) {
       let utils = Util.getWindowUtils(element.ownerDocument.defaultView);
       let rect = utils.sendQueryContentEvent(utils.QUERY_CARET_RECT, element.selectionEnd, 0, 0, 0);
       if (rect) {
         let scroll = ContentScroll.getScrollOffset(element.ownerDocument.defaultView);
         return new Rect(scroll.x + rect.left, scroll.y + rect.top, rect.width, rect.height);
       }
     }