Bug 640870 - Form assistant(?): Component returned failure code: 0x80004005 (NS_ERROR_FAILURE) [r=mfinkle]
authorVivien Nicolas <21@vingtetun.org>
Fri, 25 Mar 2011 10:32:47 +0100
changeset 67538 f1d32995682c8df2b3741cc0475ad0bcda070e11
parent 67537 5ff877afac4da3c107a91e2da5b2f3a0c17c4542
child 67539 5ea6b5645d91fe81f35a1f71c2345f0b5a5a8b66
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
bugs640870
Bug 640870 - Form assistant(?): Component returned failure code: 0x80004005 (NS_ERROR_FAILURE) [r=mfinkle]
mobile/chrome/content/forms.js
--- a/mobile/chrome/content/forms.js
+++ b/mobile/chrome/content/forms.js
@@ -98,17 +98,22 @@ FormAssistant.prototype = {
 
     if (this._isVisibleElement(element)) {
       this._currentIndex = aIndex;
       gFocusManager.setFocus(element, Ci.nsIFocusManager.FLAG_NOSCROLL);
 
       // To ensure we get the current caret positionning of the focused
       // element we need to delayed a bit the event
       this._executeDelayed(function(self) {
-        sendAsyncMessage("FormAssist:Show", self._getJSON());
+        // Bug 640870
+        // Sometimes the element inner frame get destroyed while the element
+        // receive the focus because the display is turned to 'none' for
+        // example, in this "fun" case just do nothing if the element is hidden
+        if (self._isVisibleElement(gFocusManager.focusedElement))
+          sendAsyncMessage("FormAssist:Show", self._getJSON());
       });
     } else {
       // Repopulate the list of elements in the page, some could have gone
       // because of AJAX changes for example
       this._elements = [];
       let currentIndex = this._getAllElements(gFocusManager.focusedElement)
 
       if (aIndex < this._currentIndex)
@@ -540,17 +545,17 @@ FormAssistant.prototype = {
     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 && (element.mozIsTextField && element.mozIsTextField(false) ||
-        element instanceof HTMLTextAreaElement) && focusedElement == element) {
+        element instanceof HTMLTextAreaElement) && focusedElement == element && this._isVisibleElement(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);
       }
     }