Title: [148221] trunk
Revision
148221
Author
rn...@webkit.org
Date
2013-04-11 11:56:16 -0700 (Thu, 11 Apr 2013)

Log Message

Autocorrected text doesn't have a marker of type autocorrected
https://bugs.webkit.org/show_bug.cgi?id=114337

Reviewed by Darin Adler.

Source/WebCore:

The bug was caused by markAndReplaceFor's text replacement errornously assuming that there are
no other text checking result starting at the same offset. That resulted in us adjusting location
offsets of the subsequent results pointing at the replaced text, hit an assertion, and blow up.

Fixed the bug by skipping all remaining results for the replaced text since they're no longer
applicable.

Tests: Existing autocorection tests have been updated to assert new behavior.

* editing/Editor.cpp:
(WebCore::Editor::markAndReplaceFor):

LayoutTests:

Updated tests to assert the existence of "autocorrected" markers.

* platform/mac/editing/spelling/click-autocorrected-word-expected.png:
* platform/mac/editing/spelling/click-autocorrected-word-expected.txt:
* platform/mac/editing/spelling/click-autocorrected-word.html:
* platform/mac/editing/spelling/delete-into-autocorrected-word-expected.png:
* platform/mac/editing/spelling/delete-into-autocorrected-word-expected.txt:
* platform/mac/editing/spelling/delete-into-autocorrected-word.html:
* platform/mac/editing/spelling/forward-delete-into-autocorrected-word-expected.png:
* platform/mac/editing/spelling/forward-delete-into-autocorrected-word-expected.txt:
* platform/mac/editing/spelling/forward-delete-into-autocorrected-word.html:
* platform/mac/editing/spelling/move-cursor-to-autocorrected-word-expected.png:
* platform/mac/editing/spelling/move-cursor-to-autocorrected-word-expected.txt:
* platform/mac/editing/spelling/move-cursor-to-autocorrected-word.html:
* platform/mac/editing/spelling/move-cursor-to-beginning-of-autocorrected-word-expected.png:
* platform/mac/editing/spelling/move-cursor-to-beginning-of-autocorrected-word-expected.txt:
* platform/mac/editing/spelling/move-cursor-to-beginning-of-autocorrected-word.html:

Modified Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (148220 => 148221)


--- trunk/LayoutTests/ChangeLog	2013-04-11 18:54:09 UTC (rev 148220)
+++ trunk/LayoutTests/ChangeLog	2013-04-11 18:56:16 UTC (rev 148221)
@@ -1,3 +1,28 @@
+2013-04-11  Ryosuke Niwa  <rn...@webkit.org>
+
+        Autocorrected text doesn't have a marker of type autocorrected
+        https://bugs.webkit.org/show_bug.cgi?id=114337
+
+        Reviewed by Darin Adler.
+
+        Updated tests to assert the existence of "autocorrected" markers.
+
+        * platform/mac/editing/spelling/click-autocorrected-word-expected.png:
+        * platform/mac/editing/spelling/click-autocorrected-word-expected.txt:
+        * platform/mac/editing/spelling/click-autocorrected-word.html:
+        * platform/mac/editing/spelling/delete-into-autocorrected-word-expected.png:
+        * platform/mac/editing/spelling/delete-into-autocorrected-word-expected.txt:
+        * platform/mac/editing/spelling/delete-into-autocorrected-word.html:
+        * platform/mac/editing/spelling/forward-delete-into-autocorrected-word-expected.png:
+        * platform/mac/editing/spelling/forward-delete-into-autocorrected-word-expected.txt:
+        * platform/mac/editing/spelling/forward-delete-into-autocorrected-word.html:
+        * platform/mac/editing/spelling/move-cursor-to-autocorrected-word-expected.png:
+        * platform/mac/editing/spelling/move-cursor-to-autocorrected-word-expected.txt:
+        * platform/mac/editing/spelling/move-cursor-to-autocorrected-word.html:
+        * platform/mac/editing/spelling/move-cursor-to-beginning-of-autocorrected-word-expected.png:
+        * platform/mac/editing/spelling/move-cursor-to-beginning-of-autocorrected-word-expected.txt:
+        * platform/mac/editing/spelling/move-cursor-to-beginning-of-autocorrected-word.html:
+
 2013-04-11  Michelangelo De Simone  <michelang...@webkit.org>
 
         [CSS Shaders] Parse the geometry descriptor

Modified: trunk/LayoutTests/platform/mac/editing/spelling/click-autocorrected-word-expected.png


(Binary files differ)

Modified: trunk/LayoutTests/platform/mac/editing/spelling/click-autocorrected-word-expected.txt (148220 => 148221)


--- trunk/LayoutTests/platform/mac/editing/spelling/click-autocorrected-word-expected.txt	2013-04-11 18:54:09 UTC (rev 148220)
+++ trunk/LayoutTests/platform/mac/editing/spelling/click-autocorrected-word-expected.txt	2013-04-11 18:56:16 UTC (rev 148221)
@@ -64,7 +64,12 @@
 PASS markerRange.endOffset is markerRange.startOffset + markerRange.toString().length
 PASS internals.markerRangeForNode(textNode, 'replacement', 1) is null
 PASS internals.markerRangeForNode(textNode, 'spelling', 0) is null
-PASS internals.markerRangeForNode(textNode, 'autocorrected', 0) is null
+PASS markerRange = internals.markerRangeForNode(textNode, 'autocorrected', 0); markerRange.startContainer is textNode
+PASS markerRange.toString() is 'message'
+PASS markerRange.endContainer is textNode
+PASS markerRange.startOffset is textNode.textContent.indexOf(markerRange.toString())
+PASS markerRange.endOffset is markerRange.startOffset + markerRange.toString().length
+PASS internals.markerRangeForNode(textNode, 'autocorrected', 1) is null
 PASS successfullyParsed is true
 
 TEST COMPLETE

Modified: trunk/LayoutTests/platform/mac/editing/spelling/click-autocorrected-word.html (148220 => 148221)


--- trunk/LayoutTests/platform/mac/editing/spelling/click-autocorrected-word.html	2013-04-11 18:54:09 UTC (rev 148220)
+++ trunk/LayoutTests/platform/mac/editing/spelling/click-autocorrected-word.html	2013-04-11 18:56:16 UTC (rev 148221)
@@ -34,7 +34,13 @@
         shouldBe("markerRange.endOffset", "markerRange.startOffset + markerRange.toString().length");
         shouldBeNull("internals.markerRangeForNode(textNode, 'replacement', 1)");
         shouldBeNull("internals.markerRangeForNode(textNode, 'spelling', 0)");
-        shouldBeNull("internals.markerRangeForNode(textNode, 'autocorrected', 0)");
+
+        shouldBe("markerRange = internals.markerRangeForNode(textNode, 'autocorrected', 0); markerRange.startContainer", "textNode");
+        shouldBe("markerRange.toString()", "'message'");
+        shouldBe("markerRange.endContainer", "textNode");
+        shouldBe("markerRange.startOffset", "textNode.textContent.indexOf(markerRange.toString())");
+        shouldBe("markerRange.endOffset", "markerRange.startOffset + markerRange.toString().length");
+        shouldBeNull("internals.markerRangeForNode(textNode, 'autocorrected', 1)");
     }
 }
 

Modified: trunk/LayoutTests/platform/mac/editing/spelling/delete-into-autocorrected-word-expected.png


(Binary files differ)

Modified: trunk/LayoutTests/platform/mac/editing/spelling/delete-into-autocorrected-word-expected.txt (148220 => 148221)


--- trunk/LayoutTests/platform/mac/editing/spelling/delete-into-autocorrected-word-expected.txt	2013-04-11 18:54:09 UTC (rev 148220)
+++ trunk/LayoutTests/platform/mac/editing/spelling/delete-into-autocorrected-word-expected.txt	2013-04-11 18:56:16 UTC (rev 148221)
@@ -67,7 +67,12 @@
 PASS markerRange.endOffset is markerRange.startOffset + markerRange.toString().length
 PASS internals.markerRangeForNode(textNode, 'replacement', 1) is null
 PASS internals.markerRangeForNode(textNode, 'spelling', 0) is null
-PASS internals.markerRangeForNode(textNode, 'autocorrected', 0) is null
+PASS markerRange = internals.markerRangeForNode(textNode, 'autocorrected', 0); markerRange.startContainer is textNode
+PASS markerRange.toString() is 'message'
+PASS markerRange.endContainer is textNode
+PASS markerRange.startOffset is textNode.textContent.indexOf(markerRange.toString())
+PASS markerRange.endOffset is markerRange.startOffset + markerRange.toString().length
+PASS internals.markerRangeForNode(textNode, 'autocorrected', 1) is null
 PASS successfullyParsed is true
 
 TEST COMPLETE

Modified: trunk/LayoutTests/platform/mac/editing/spelling/delete-into-autocorrected-word.html (148220 => 148221)


--- trunk/LayoutTests/platform/mac/editing/spelling/delete-into-autocorrected-word.html	2013-04-11 18:54:09 UTC (rev 148220)
+++ trunk/LayoutTests/platform/mac/editing/spelling/delete-into-autocorrected-word.html	2013-04-11 18:56:16 UTC (rev 148221)
@@ -33,7 +33,13 @@
         shouldBe("markerRange.endOffset", "markerRange.startOffset + markerRange.toString().length");
         shouldBeNull("internals.markerRangeForNode(textNode, 'replacement', 1)");
         shouldBeNull("internals.markerRangeForNode(textNode, 'spelling', 0)");
-        shouldBeNull("internals.markerRangeForNode(textNode, 'autocorrected', 0)");
+
+        shouldBe("markerRange = internals.markerRangeForNode(textNode, 'autocorrected', 0); markerRange.startContainer", "textNode");
+        shouldBe("markerRange.toString()", "'message'");
+        shouldBe("markerRange.endContainer", "textNode");
+        shouldBe("markerRange.startOffset", "textNode.textContent.indexOf(markerRange.toString())");
+        shouldBe("markerRange.endOffset", "markerRange.startOffset + markerRange.toString().length");
+        shouldBeNull("internals.markerRangeForNode(textNode, 'autocorrected', 1)");
     }
 }
 

Modified: trunk/LayoutTests/platform/mac/editing/spelling/forward-delete-into-autocorrected-word-expected.png


(Binary files differ)

Modified: trunk/LayoutTests/platform/mac/editing/spelling/forward-delete-into-autocorrected-word-expected.txt (148220 => 148221)


--- trunk/LayoutTests/platform/mac/editing/spelling/forward-delete-into-autocorrected-word-expected.txt	2013-04-11 18:54:09 UTC (rev 148220)
+++ trunk/LayoutTests/platform/mac/editing/spelling/forward-delete-into-autocorrected-word-expected.txt	2013-04-11 18:56:16 UTC (rev 148221)
@@ -72,7 +72,12 @@
 PASS markerRange.startOffset is textNode.textContent.indexOf(markerRange.toString())
 PASS markerRange.endOffset is markerRange.startOffset + markerRange.toString().length
 PASS internals.markerRangeForNode(textNode, 'spelling', 1) is null
-PASS internals.markerRangeForNode(textNode, 'autocorrected', 0) is null
+PASS markerRange = internals.markerRangeForNode(textNode, 'autocorrected', 0); markerRange.startContainer is textNode
+PASS markerRange.toString() is 'message'
+PASS markerRange.endContainer is textNode
+PASS markerRange.startOffset is textNode.textContent.indexOf(markerRange.toString())
+PASS markerRange.endOffset is markerRange.startOffset + markerRange.toString().length
+PASS internals.markerRangeForNode(textNode, 'autocorrected', 1) is null
 PASS successfullyParsed is true
 
 TEST COMPLETE

Modified: trunk/LayoutTests/platform/mac/editing/spelling/forward-delete-into-autocorrected-word.html (148220 => 148221)


--- trunk/LayoutTests/platform/mac/editing/spelling/forward-delete-into-autocorrected-word.html	2013-04-11 18:54:09 UTC (rev 148220)
+++ trunk/LayoutTests/platform/mac/editing/spelling/forward-delete-into-autocorrected-word.html	2013-04-11 18:56:16 UTC (rev 148221)
@@ -42,7 +42,12 @@
         shouldBe("markerRange.endOffset", "markerRange.startOffset + markerRange.toString().length");
         shouldBeNull("internals.markerRangeForNode(textNode, 'spelling', 1)");
 
-        shouldBeNull("internals.markerRangeForNode(textNode, 'autocorrected', 0)");
+        shouldBe("markerRange = internals.markerRangeForNode(textNode, 'autocorrected', 0); markerRange.startContainer", "textNode");
+        shouldBe("markerRange.toString()", "'message'");
+        shouldBe("markerRange.endContainer", "textNode");
+        shouldBe("markerRange.startOffset", "textNode.textContent.indexOf(markerRange.toString())");
+        shouldBe("markerRange.endOffset", "markerRange.startOffset + markerRange.toString().length");
+        shouldBeNull("internals.markerRangeForNode(textNode, 'autocorrected', 1)");
     }
 }
 

Modified: trunk/LayoutTests/platform/mac/editing/spelling/move-cursor-to-autocorrected-word-expected.png


(Binary files differ)

Modified: trunk/LayoutTests/platform/mac/editing/spelling/move-cursor-to-autocorrected-word-expected.txt (148220 => 148221)


--- trunk/LayoutTests/platform/mac/editing/spelling/move-cursor-to-autocorrected-word-expected.txt	2013-04-11 18:54:09 UTC (rev 148220)
+++ trunk/LayoutTests/platform/mac/editing/spelling/move-cursor-to-autocorrected-word-expected.txt	2013-04-11 18:56:16 UTC (rev 148221)
@@ -64,7 +64,12 @@
 PASS markerRange.endOffset is markerRange.startOffset + markerRange.toString().length
 PASS internals.markerRangeForNode(textNode, 'replacement', 1) is null
 PASS internals.markerRangeForNode(textNode, 'spelling', 0) is null
-PASS internals.markerRangeForNode(textNode, 'autocorrected', 0) is null
+PASS markerRange = internals.markerRangeForNode(textNode, 'autocorrected', 0); markerRange.startContainer is textNode
+PASS markerRange.toString() is 'message'
+PASS markerRange.endContainer is textNode
+PASS markerRange.startOffset is textNode.textContent.indexOf(markerRange.toString())
+PASS markerRange.endOffset is markerRange.startOffset + markerRange.toString().length
+PASS internals.markerRangeForNode(textNode, 'autocorrected', 1) is null
 PASS successfullyParsed is true
 
 TEST COMPLETE

Modified: trunk/LayoutTests/platform/mac/editing/spelling/move-cursor-to-autocorrected-word.html (148220 => 148221)


--- trunk/LayoutTests/platform/mac/editing/spelling/move-cursor-to-autocorrected-word.html	2013-04-11 18:54:09 UTC (rev 148220)
+++ trunk/LayoutTests/platform/mac/editing/spelling/move-cursor-to-autocorrected-word.html	2013-04-11 18:56:16 UTC (rev 148221)
@@ -33,7 +33,13 @@
         shouldBe("markerRange.endOffset", "markerRange.startOffset + markerRange.toString().length");
         shouldBeNull("internals.markerRangeForNode(textNode, 'replacement', 1)");
         shouldBeNull("internals.markerRangeForNode(textNode, 'spelling', 0)");
-        shouldBeNull("internals.markerRangeForNode(textNode, 'autocorrected', 0)");
+
+        shouldBe("markerRange = internals.markerRangeForNode(textNode, 'autocorrected', 0); markerRange.startContainer", "textNode");
+        shouldBe("markerRange.toString()", "'message'");
+        shouldBe("markerRange.endContainer", "textNode");
+        shouldBe("markerRange.startOffset", "textNode.textContent.indexOf(markerRange.toString())");
+        shouldBe("markerRange.endOffset", "markerRange.startOffset + markerRange.toString().length");
+        shouldBeNull("internals.markerRangeForNode(textNode, 'autocorrected', 1)");
     }
 }
 

Modified: trunk/LayoutTests/platform/mac/editing/spelling/move-cursor-to-beginning-of-autocorrected-word-expected.png


(Binary files differ)

Modified: trunk/LayoutTests/platform/mac/editing/spelling/move-cursor-to-beginning-of-autocorrected-word-expected.txt (148220 => 148221)


--- trunk/LayoutTests/platform/mac/editing/spelling/move-cursor-to-beginning-of-autocorrected-word-expected.txt	2013-04-11 18:54:09 UTC (rev 148220)
+++ trunk/LayoutTests/platform/mac/editing/spelling/move-cursor-to-beginning-of-autocorrected-word-expected.txt	2013-04-11 18:56:16 UTC (rev 148221)
@@ -65,7 +65,12 @@
 PASS markerRange.endOffset is markerRange.startOffset + markerRange.toString().length
 PASS internals.markerRangeForNode(textNode, 'replacement', 1) is null
 PASS internals.markerRangeForNode(textNode, 'spelling', 0) is null
-PASS internals.markerRangeForNode(textNode, 'autocorrected', 0) is null
+PASS markerRange = internals.markerRangeForNode(textNode, 'autocorrected', 0); markerRange.startContainer is textNode
+PASS markerRange.toString() is 'message'
+PASS markerRange.endContainer is textNode
+PASS markerRange.startOffset is textNode.textContent.indexOf(markerRange.toString())
+PASS markerRange.endOffset is markerRange.startOffset + markerRange.toString().length
+PASS internals.markerRangeForNode(textNode, 'autocorrected', 1) is null
 PASS successfullyParsed is true
 
 TEST COMPLETE

Modified: trunk/LayoutTests/platform/mac/editing/spelling/move-cursor-to-beginning-of-autocorrected-word.html (148220 => 148221)


--- trunk/LayoutTests/platform/mac/editing/spelling/move-cursor-to-beginning-of-autocorrected-word.html	2013-04-11 18:54:09 UTC (rev 148220)
+++ trunk/LayoutTests/platform/mac/editing/spelling/move-cursor-to-beginning-of-autocorrected-word.html	2013-04-11 18:56:16 UTC (rev 148221)
@@ -37,7 +37,13 @@
         shouldBe("markerRange.endOffset", "markerRange.startOffset + markerRange.toString().length");
         shouldBeNull("internals.markerRangeForNode(textNode, 'replacement', 1)");
         shouldBeNull("internals.markerRangeForNode(textNode, 'spelling', 0)");
-        shouldBeNull("internals.markerRangeForNode(textNode, 'autocorrected', 0)");
+
+        shouldBe("markerRange = internals.markerRangeForNode(textNode, 'autocorrected', 0); markerRange.startContainer", "textNode");
+        shouldBe("markerRange.toString()", "'message'");
+        shouldBe("markerRange.endContainer", "textNode");
+        shouldBe("markerRange.startOffset", "textNode.textContent.indexOf(markerRange.toString())");
+        shouldBe("markerRange.endOffset", "markerRange.startOffset + markerRange.toString().length");
+        shouldBeNull("internals.markerRangeForNode(textNode, 'autocorrected', 1)");
     }
 }
 

Modified: trunk/Source/WebCore/ChangeLog (148220 => 148221)


--- trunk/Source/WebCore/ChangeLog	2013-04-11 18:54:09 UTC (rev 148220)
+++ trunk/Source/WebCore/ChangeLog	2013-04-11 18:56:16 UTC (rev 148221)
@@ -1,3 +1,22 @@
+2013-04-11  Ryosuke Niwa  <rn...@webkit.org>
+
+        Autocorrected text doesn't have a marker of type autocorrected
+        https://bugs.webkit.org/show_bug.cgi?id=114337
+
+        Reviewed by Darin Adler.
+
+        The bug was caused by markAndReplaceFor's text replacement errornously assuming that there are
+        no other text checking result starting at the same offset. That resulted in us adjusting location
+        offsets of the subsequent results pointing at the replaced text, hit an assertion, and blow up.
+
+        Fixed the bug by skipping all remaining results for the replaced text since they're no longer
+        applicable.
+
+        Tests: Existing autocorection tests have been updated to assert new behavior.
+
+        * editing/Editor.cpp:
+        (WebCore::Editor::markAndReplaceFor):
+
 2013-04-11  Michelangelo De Simone  <michelang...@webkit.org>
 
         [CSS Shaders] Parse the geometry descriptor

Modified: trunk/Source/WebCore/editing/Editor.cpp (148220 => 148221)


--- trunk/Source/WebCore/editing/Editor.cpp	2013-04-11 18:54:09 UTC (rev 148220)
+++ trunk/Source/WebCore/editing/Editor.cpp	2013-04-11 18:56:16 UTC (rev 148221)
@@ -2298,6 +2298,10 @@
                         cache->postNotification(root, AXObjectCache::AXAutocorrectionOccured, true);
                 }
 
+                // Skip all other results for the replaced text.
+                while (i + 1 < results.size() && results[i + 1].location + offsetDueToReplacement <= resultLocation)
+                    i++;
+
                 selectionChanged = true;
                 offsetDueToReplacement += replacement.length() - resultLength;
                 if (resultLocation < selectionOffset)
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to