Bug 882866 - Ignore all EditAction notifications caused by replaceSurroundingText. r=dflanagan, a=leo+
authorYuan Xulei <xyuan@mozilla.com>
Sun, 23 Jun 2013 20:43:40 -0400
changeset 119628 c1f696b4b80df03dad8ccb0c0a75c0bd41ea3c03
parent 119627 0961cb6c0d6d62c1e4b736ca2622732fc10ac3ab
child 119629 d2e1e105d5d4c28a2ed9e49b854ee661bf226b22
push id906
push userryanvm@gmail.com
push dateMon, 24 Jun 2013 15:25:59 +0000
reviewersdflanagan, leo
bugs882866
milestone18.1
Bug 882866 - Ignore all EditAction notifications caused by replaceSurroundingText. r=dflanagan, a=leo+
b2g/chrome/content/forms.js
--- a/b2g/chrome/content/forms.js
+++ b/b2g/chrome/content/forms.js
@@ -200,16 +200,17 @@ let FormAssistant = {
   isKeyboardOpened: false,
   selectionStart: 0,
   selectionEnd: 0,
   scrollIntoViewTimeout: null,
   _focusedElement: null,
   _documentEncoder: null,
   _editor: null,
   _editing: false,
+  _ignoreEditActionOnce: false,
 
   get focusedElement() {
     if (this._focusedElement && Cu.isDeadWrapper(this._focusedElement))
       this._focusedElement = null;
 
     return this._focusedElement;
   },
 
@@ -260,17 +261,19 @@ let FormAssistant = {
   get editor() {
     return this._editor;
   },
 
   // Implements nsIEditorObserver get notification when the text content of
   // current input field has changed.
   EditAction: function fa_editAction() {
     if (this._editing) {
-      this._editing = false;
+      return;
+    } else if (this._ignoreEditActionOnce) {
+      this._ignoreEditActionOnce = false;
       return;
     }
     this.sendKeyboardState(this.focusedElement);
   },
 
   handleEvent: function fa_handleEvent(evt) {
     let target = evt.target;
 
@@ -339,21 +342,21 @@ let FormAssistant = {
               this.focusedElement.scrollIntoView(false);
             }
           }.bind(this), RESIZE_SCROLL_DELAY);
         }
         break;
 
       case "keydown":
         // Don't monitor the text change resulting from key event.
-        this._editing = true;
+        this._ignoreEditActionOnce = true;
         break;
 
       case "keyup":
-        this._editing = false;
+        this._ignoreEditActionOnce = false;
         break;
     }
   },
 
   receiveMessage: function fa_receiveMessage(msg) {
     let target = this.focusedElement;
     if (!target) {
       return;