Bug 882866 - Ignore all EditAction notifications caused by replaceSurroundingText. r=dflanagan
authorYuan Xulei <xyuan@mozilla.com>
Sun, 23 Jun 2013 20:43:40 -0400
changeset 147716 f2deb05a7ba5e2ccfd147f79634d6dcb7153e296
parent 147694 86ce13c5787159bcc4d2ae95ff96683eb7509872
child 147717 f562d353ac002d0f4176842fa6b4243a9b075009
push id2697
push userbbajaj@mozilla.com
push dateMon, 05 Aug 2013 18:49:53 +0000
treeherdermozilla-beta@dfec938c7b63 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersdflanagan
bugs882866
milestone24.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 882866 - Ignore all EditAction notifications caused by replaceSurroundingText. r=dflanagan
b2g/chrome/content/forms.js
--- a/b2g/chrome/content/forms.js
+++ b/b2g/chrome/content/forms.js
@@ -203,16 +203,17 @@ let FormAssistant = {
   isKeyboardOpened: false,
   selectionStart: -1,
   selectionEnd: -1,
   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;
   },
 
@@ -263,17 +264,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;
 
@@ -359,27 +362,27 @@ let FormAssistant = {
 
       case "input":
         // When the text content changes, notify the keyboard
         this.updateSelection();
         break;
 
       case "keydown":
         // Don't monitor the text change resulting from key event.
-        this._editing = true;
+        this._ignoreEditActionOnce = true;
 
         // We use 'setTimeout' to wait until the input element accomplishes the
         // change in selection range.
         content.setTimeout(function() {
           this.updateSelection();
         }.bind(this), 0);
         break;
 
       case "keyup":
-        this._editing = false;
+        this._ignoreEditActionOnce = false;
         break;
     }
   },
 
   receiveMessage: function fa_receiveMessage(msg) {
     let target = this.focusedElement;
     if (!target) {
       return;