Candidates that don't end in spaces shouldn't have spaces arbitrarily appended to...
authortimothy_horton@apple.com <timothy_horton@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sun, 11 Sep 2016 07:24:17 +0000 (07:24 +0000)
committertimothy_horton@apple.com <timothy_horton@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sun, 11 Sep 2016 07:24:17 +0000 (07:24 +0000)
commit42335c285a37fe88b923a9dda92c39b20deb7b33
tree095f42f7d8d1d28b559ccd98cf8c51be58e92d8d
parent6c267157606dd2ce83d7d3ca8c6bf5af66726555
Candidates that don't end in spaces shouldn't have spaces arbitrarily appended to them
https://bugs.webkit.org/show_bug.cgi?id=161846
<rdar://problem/28245097>

Reviewed by Beth Dakin.

Tests: editing/mac/spelling/accept-candidate-without-adding-space.html,
       editing/mac/spelling/accept-candidate-allows-autocorrect-on-next-word.html

* editing/Editor.cpp:
(WebCore::Editor::handleAcceptedCandidate):
Stop appending a space just because the candidate doesn't end in a space.
There are languages where that doesn't make sense, and the platform
guarantees that candidates will always have spaces if they need them.

Also, adjust the way we compute the AcceptedCandidate document marker range.
There were two problems with the existing code: it expanded outward from
the post-insertion cursor in *both* directions, instead of just backwards,
and it used the length of the replaced text, not the length of the newly
inserted text (more of the confusion mentioned in r205765).

* editing/mac/spelling/accept-candidate-replacing-multiple-words-expected.txt:
* editing/mac/spelling/accept-candidate-replacing-multiple-words.html:
* editing/mac/spelling/accept-candidate-without-crossing-editing-boundary-expected.txt:
* editing/mac/spelling/accept-candidate-without-crossing-editing-boundary.html:
Update existing tests to put spaces at the end of accepted candidates to make them
more similar to what the OS will return to us.

* editing/mac/spelling/accept-candidate-without-adding-space-expected.txt: Added.
* editing/mac/spelling/accept-candidate-without-adding-space.html: Added.
Add a test where the accepted candidate does *not* have a space at the end,
testing that we don't add one where the candidate didn't contain one.

* editing/mac/spelling/accept-candidate-allows-autocorrect-on-next-word-expected.txt: Added.
* editing/mac/spelling/accept-candidate-allows-autocorrect-on-next-word.html: Added.
Add a test ensuring that the document marker added by accepting a candidate
doesn't overlap the next word and prevent autocorrect from working on it.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@205788 268f45cc-cd09-0410-ab3c-d52691b4dbfc
13 files changed:
LayoutTests/ChangeLog
LayoutTests/editing/mac/spelling/accept-candidate-allows-autocorrect-on-next-word-expected.txt [new file with mode: 0644]
LayoutTests/editing/mac/spelling/accept-candidate-allows-autocorrect-on-next-word.html [new file with mode: 0644]
LayoutTests/editing/mac/spelling/accept-candidate-replacing-multiple-words-expected.txt
LayoutTests/editing/mac/spelling/accept-candidate-replacing-multiple-words.html
LayoutTests/editing/mac/spelling/accept-candidate-without-adding-space-expected.txt [new file with mode: 0644]
LayoutTests/editing/mac/spelling/accept-candidate-without-adding-space.html [new file with mode: 0644]
LayoutTests/editing/mac/spelling/accept-candidate-without-crossing-editing-boundary-expected.txt
LayoutTests/editing/mac/spelling/accept-candidate-without-crossing-editing-boundary.html
LayoutTests/editing/mac/spelling/accept-misspelled-candidate-expected.txt
LayoutTests/platform/mac-wk2/TestExpectations
Source/WebCore/ChangeLog
Source/WebCore/editing/Editor.cpp