Bug 1319660 - 1. Don't take shortcut if old replacement ranges don't match; r=esawin
authorJim Chen <nchen@mozilla.com>
Wed, 04 Jan 2017 14:46:10 -0500
changeset 327945 9a7c2edd54b8dd6c3d6471560ac1b096b2955536
parent 327944 5b9702d8fe4e8ddf3ce155e81d54b9d199805843
child 327946 93353b53a706c7dc9b559d6224fd7f1f4ca50ccb
push id85331
push usernchen@mozilla.com
push dateWed, 04 Jan 2017 19:46:26 +0000
treeherdermozilla-inbound@d506d3c193c9 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersesawin
bugs1319660
milestone53.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 1319660 - 1. Don't take shortcut if old replacement ranges don't match; r=esawin The block at [1] is a shortcut we take when we reconcile Java text changes with Gecko text changes. However, we only checked that the new ranges are the same, i.e. that the new Gecko text is the same as the new Java text. We should also be checking that the old ranges are the same, i.e. that the replaced Gecko text is the same as the replaced Java text. [1] https://dxr.mozilla.org/mozilla-central/rev/bbbd2f7539f224a482cc6d2dd10e6a5f31c8baf3/mobile/android/geckoview/src/main/java/org/mozilla/gecko/GeckoEditable.java#1233
mobile/android/geckoview/src/main/java/org/mozilla/gecko/GeckoEditable.java
--- a/mobile/android/geckoview/src/main/java/org/mozilla/gecko/GeckoEditable.java
+++ b/mobile/android/geckoview/src/main/java/org/mozilla/gecko/GeckoEditable.java
@@ -1225,18 +1225,19 @@ final class GeckoEditable extends JNIObj
             if (indexInText < 0) {
                 // Text was changed from under us. We are forced to discard any new spans.
                 mText.currentReplace(start, oldEnd, text);
 
                 // Don't ignore the next selection change because we are forced to re-sync
                 // with Gecko here.
                 mIgnoreSelectionChange = false;
 
-            } else if (indexInText == 0 && text.length() == action.mSequence.length()) {
-                // The new text exactly matches our sequence, so do a direct replace.
+            } else if (indexInText == 0 && text.length() == action.mSequence.length() &&
+                    oldEnd - start == action.mEnd - action.mStart) {
+                // The new change exactly matches our saved change, so do a direct replace.
                 mText.currentReplace(start, oldEnd, action.mSequence);
 
                 // Ignore the next selection change because the selection change is a
                 // side-effect of the replace-text event we sent.
                 mIgnoreSelectionChange = true;
 
             } else {
                 // The sequence is embedded within the changed text, so we have to perform