<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[205788] trunk</title>
</head>
<body>

<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt;  }
#msg dl a { font-weight: bold}
#msg dl a:link    { color:#fc3; }
#msg dl a:active  { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg ul { text-indent: -1em; padding-left: 1em; }#logmsg ol { text-indent: -1.5em; padding-left: 1.5em; }
#logmsg > ul, #logmsg > ol { margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff  {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<dl class="meta">
<dt>Revision</dt> <dd><a href="http://trac.webkit.org/projects/webkit/changeset/205788">205788</a></dd>
<dt>Author</dt> <dd>timothy_horton@apple.com</dd>
<dt>Date</dt> <dd>2016-09-11 00:24:17 -0700 (Sun, 11 Sep 2016)</dd>
</dl>

<h3>Log Message</h3>
<pre>Candidates that don't end in spaces shouldn't have spaces arbitrarily appended to them
https://bugs.webkit.org/show_bug.cgi?id=161846
&lt;rdar://problem/28245097&gt;

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 <a href="http://trac.webkit.org/projects/webkit/changeset/205765">r205765</a>).

* 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.</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkLayoutTestsChangeLog">trunk/LayoutTests/ChangeLog</a></li>
<li><a href="#trunkLayoutTestseditingmacspellingacceptcandidatereplacingmultiplewordsexpectedtxt">trunk/LayoutTests/editing/mac/spelling/accept-candidate-replacing-multiple-words-expected.txt</a></li>
<li><a href="#trunkLayoutTestseditingmacspellingacceptcandidatereplacingmultiplewordshtml">trunk/LayoutTests/editing/mac/spelling/accept-candidate-replacing-multiple-words.html</a></li>
<li><a href="#trunkLayoutTestseditingmacspellingacceptcandidatewithoutcrossingeditingboundaryexpectedtxt">trunk/LayoutTests/editing/mac/spelling/accept-candidate-without-crossing-editing-boundary-expected.txt</a></li>
<li><a href="#trunkLayoutTestseditingmacspellingacceptcandidatewithoutcrossingeditingboundaryhtml">trunk/LayoutTests/editing/mac/spelling/accept-candidate-without-crossing-editing-boundary.html</a></li>
<li><a href="#trunkLayoutTestseditingmacspellingacceptmisspelledcandidateexpectedtxt">trunk/LayoutTests/editing/mac/spelling/accept-misspelled-candidate-expected.txt</a></li>
<li><a href="#trunkLayoutTestsplatformmacwk2TestExpectations">trunk/LayoutTests/platform/mac-wk2/TestExpectations</a></li>
<li><a href="#trunkSourceWebCoreChangeLog">trunk/Source/WebCore/ChangeLog</a></li>
<li><a href="#trunkSourceWebCoreeditingEditorcpp">trunk/Source/WebCore/editing/Editor.cpp</a></li>
</ul>

<h3>Added Paths</h3>
<ul>
<li><a href="#trunkLayoutTestseditingmacspellingacceptcandidateallowsautocorrectonnextwordexpectedtxt">trunk/LayoutTests/editing/mac/spelling/accept-candidate-allows-autocorrect-on-next-word-expected.txt</a></li>
<li><a href="#trunkLayoutTestseditingmacspellingacceptcandidateallowsautocorrectonnextwordhtml">trunk/LayoutTests/editing/mac/spelling/accept-candidate-allows-autocorrect-on-next-word.html</a></li>
<li><a href="#trunkLayoutTestseditingmacspellingacceptcandidatewithoutaddingspaceexpectedtxt">trunk/LayoutTests/editing/mac/spelling/accept-candidate-without-adding-space-expected.txt</a></li>
<li><a href="#trunkLayoutTestseditingmacspellingacceptcandidatewithoutaddingspacehtml">trunk/LayoutTests/editing/mac/spelling/accept-candidate-without-adding-space.html</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkLayoutTestsChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/ChangeLog (205787 => 205788)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/ChangeLog        2016-09-10 18:08:32 UTC (rev 205787)
+++ trunk/LayoutTests/ChangeLog        2016-09-11 07:24:17 UTC (rev 205788)
</span><span class="lines">@@ -1,3 +1,28 @@
</span><ins>+2016-09-11  Tim Horton  &lt;timothy_horton@apple.com&gt;
+
+        Candidates that don't end in spaces shouldn't have spaces arbitrarily appended to them
+        https://bugs.webkit.org/show_bug.cgi?id=161846
+        &lt;rdar://problem/28245097&gt;
+
+        Reviewed by Beth Dakin.
+
+        * 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.
+
</ins><span class="cx"> 2016-09-10  Chris Dumez  &lt;cdumez@apple.com&gt;
</span><span class="cx"> 
</span><span class="cx">         It is possible for Document::m_frame pointer to become stale
</span></span></pre></div>
<a id="trunkLayoutTestseditingmacspellingacceptcandidateallowsautocorrectonnextwordexpectedtxt"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/editing/mac/spelling/accept-candidate-allows-autocorrect-on-next-word-expected.txt (0 => 205788)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/editing/mac/spelling/accept-candidate-allows-autocorrect-on-next-word-expected.txt                                (rev 0)
+++ trunk/LayoutTests/editing/mac/spelling/accept-candidate-allows-autocorrect-on-next-word-expected.txt        2016-09-11 07:24:17 UTC (rev 205788)
</span><span class="lines">@@ -0,0 +1,98 @@
</span><ins>+EDITING DELEGATE: shouldBeginEditingInDOMRange:range from 0 of DIV &gt; BODY &gt; HTML &gt; #document to 2 of DIV &gt; BODY &gt; HTML &gt; #document
+EDITING DELEGATE: webViewDidBeginEditing:WebViewDidBeginEditingNotification
+EDITING DELEGATE: shouldChangeSelectedDOMRange:(null) toDOMRange:range from 0 of DIV &gt; BODY &gt; HTML &gt; #document to 0 of DIV &gt; BODY &gt; HTML &gt; #document affinity:NSSelectionAffinityDownstream stillSelecting:FALSE
+EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
+EDITING DELEGATE: shouldChangeSelectedDOMRange:range from 0 of DIV &gt; BODY &gt; HTML &gt; #document to 0 of DIV &gt; BODY &gt; HTML &gt; #document toDOMRange:range from 1 of #text &gt; DIV &gt; BODY &gt; HTML &gt; #document to 1 of #text &gt; DIV &gt; BODY &gt; HTML &gt; #document affinity:NSSelectionAffinityDownstream stillSelecting:FALSE
+EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
+EDITING DELEGATE: webViewDidChange:WebViewDidChangeNotification
+EDITING DELEGATE: shouldChangeSelectedDOMRange:range from 1 of #text &gt; DIV &gt; BODY &gt; HTML &gt; #document to 1 of #text &gt; DIV &gt; BODY &gt; HTML &gt; #document toDOMRange:range from 2 of #text &gt; DIV &gt; BODY &gt; HTML &gt; #document to 2 of #text &gt; DIV &gt; BODY &gt; HTML &gt; #document affinity:NSSelectionAffinityDownstream stillSelecting:FALSE
+EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
+EDITING DELEGATE: webViewDidChange:WebViewDidChangeNotification
+EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
+EDITING DELEGATE: shouldChangeSelectedDOMRange:range from 1 of #text &gt; DIV &gt; BODY &gt; HTML &gt; #document to 1 of #text &gt; DIV &gt; BODY &gt; HTML &gt; #document toDOMRange:range from 3 of #text &gt; DIV &gt; BODY &gt; HTML &gt; #document to 3 of #text &gt; DIV &gt; BODY &gt; HTML &gt; #document affinity:NSSelectionAffinityDownstream stillSelecting:FALSE
+EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
+EDITING DELEGATE: webViewDidChange:WebViewDidChangeNotification
+EDITING DELEGATE: shouldChangeSelectedDOMRange:range from 3 of #text &gt; DIV &gt; BODY &gt; HTML &gt; #document to 3 of #text &gt; DIV &gt; BODY &gt; HTML &gt; #document toDOMRange:range from 4 of #text &gt; DIV &gt; BODY &gt; HTML &gt; #document to 4 of #text &gt; DIV &gt; BODY &gt; HTML &gt; #document affinity:NSSelectionAffinityDownstream stillSelecting:FALSE
+EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
+EDITING DELEGATE: webViewDidChange:WebViewDidChangeNotification
+EDITING DELEGATE: shouldChangeSelectedDOMRange:range from 4 of #text &gt; DIV &gt; BODY &gt; HTML &gt; #document to 4 of #text &gt; DIV &gt; BODY &gt; HTML &gt; #document toDOMRange:range from 5 of #text &gt; DIV &gt; BODY &gt; HTML &gt; #document to 5 of #text &gt; DIV &gt; BODY &gt; HTML &gt; #document affinity:NSSelectionAffinityDownstream stillSelecting:FALSE
+EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
+EDITING DELEGATE: webViewDidChange:WebViewDidChangeNotification
+EDITING DELEGATE: shouldChangeSelectedDOMRange:range from 5 of #text &gt; DIV &gt; BODY &gt; HTML &gt; #document to 5 of #text &gt; DIV &gt; BODY &gt; HTML &gt; #document toDOMRange:range from 6 of #text &gt; DIV &gt; BODY &gt; HTML &gt; #document to 6 of #text &gt; DIV &gt; BODY &gt; HTML &gt; #document affinity:NSSelectionAffinityDownstream stillSelecting:FALSE
+EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
+EDITING DELEGATE: webViewDidChange:WebViewDidChangeNotification
+EDITING DELEGATE: shouldChangeSelectedDOMRange:range from 6 of #text &gt; DIV &gt; BODY &gt; HTML &gt; #document to 6 of #text &gt; DIV &gt; BODY &gt; HTML &gt; #document toDOMRange:range from 7 of #text &gt; DIV &gt; BODY &gt; HTML &gt; #document to 7 of #text &gt; DIV &gt; BODY &gt; HTML &gt; #document affinity:NSSelectionAffinityDownstream stillSelecting:FALSE
+EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
+EDITING DELEGATE: webViewDidChange:WebViewDidChangeNotification
+EDITING DELEGATE: shouldChangeSelectedDOMRange:range from 7 of #text &gt; DIV &gt; BODY &gt; HTML &gt; #document to 7 of #text &gt; DIV &gt; BODY &gt; HTML &gt; #document toDOMRange:range from 8 of #text &gt; DIV &gt; BODY &gt; HTML &gt; #document to 8 of #text &gt; DIV &gt; BODY &gt; HTML &gt; #document affinity:NSSelectionAffinityDownstream stillSelecting:FALSE
+EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
+EDITING DELEGATE: webViewDidChange:WebViewDidChangeNotification
+EDITING DELEGATE: shouldChangeSelectedDOMRange:range from 8 of #text &gt; DIV &gt; BODY &gt; HTML &gt; #document to 8 of #text &gt; DIV &gt; BODY &gt; HTML &gt; #document toDOMRange:range from 9 of #text &gt; DIV &gt; BODY &gt; HTML &gt; #document to 9 of #text &gt; DIV &gt; BODY &gt; HTML &gt; #document affinity:NSSelectionAffinityDownstream stillSelecting:FALSE
+EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
+EDITING DELEGATE: webViewDidChange:WebViewDidChangeNotification
+EDITING DELEGATE: shouldChangeSelectedDOMRange:range from 9 of #text &gt; DIV &gt; BODY &gt; HTML &gt; #document to 9 of #text &gt; DIV &gt; BODY &gt; HTML &gt; #document toDOMRange:range from 10 of #text &gt; DIV &gt; BODY &gt; HTML &gt; #document to 10 of #text &gt; DIV &gt; BODY &gt; HTML &gt; #document affinity:NSSelectionAffinityDownstream stillSelecting:FALSE
+EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
+EDITING DELEGATE: webViewDidChange:WebViewDidChangeNotification
+EDITING DELEGATE: shouldChangeSelectedDOMRange:range from 10 of #text &gt; DIV &gt; BODY &gt; HTML &gt; #document to 10 of #text &gt; DIV &gt; BODY &gt; HTML &gt; #document toDOMRange:range from 11 of #text &gt; DIV &gt; BODY &gt; HTML &gt; #document to 11 of #text &gt; DIV &gt; BODY &gt; HTML &gt; #document affinity:NSSelectionAffinityDownstream stillSelecting:FALSE
+EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
+EDITING DELEGATE: webViewDidChange:WebViewDidChangeNotification
+EDITING DELEGATE: shouldChangeSelectedDOMRange:range from 11 of #text &gt; DIV &gt; BODY &gt; HTML &gt; #document to 11 of #text &gt; DIV &gt; BODY &gt; HTML &gt; #document toDOMRange:range from 12 of #text &gt; DIV &gt; BODY &gt; HTML &gt; #document to 12 of #text &gt; DIV &gt; BODY &gt; HTML &gt; #document affinity:NSSelectionAffinityDownstream stillSelecting:FALSE
+EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
+EDITING DELEGATE: webViewDidChange:WebViewDidChangeNotification
+EDITING DELEGATE: shouldChangeSelectedDOMRange:range from 12 of #text &gt; DIV &gt; BODY &gt; HTML &gt; #document to 12 of #text &gt; DIV &gt; BODY &gt; HTML &gt; #document toDOMRange:range from 13 of #text &gt; DIV &gt; BODY &gt; HTML &gt; #document to 13 of #text &gt; DIV &gt; BODY &gt; HTML &gt; #document affinity:NSSelectionAffinityDownstream stillSelecting:FALSE
+EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
+EDITING DELEGATE: webViewDidChange:WebViewDidChangeNotification
+EDITING DELEGATE: shouldChangeSelectedDOMRange:range from 13 of #text &gt; DIV &gt; BODY &gt; HTML &gt; #document to 13 of #text &gt; DIV &gt; BODY &gt; HTML &gt; #document toDOMRange:range from 14 of #text &gt; DIV &gt; BODY &gt; HTML &gt; #document to 14 of #text &gt; DIV &gt; BODY &gt; HTML &gt; #document affinity:NSSelectionAffinityDownstream stillSelecting:FALSE
+EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
+EDITING DELEGATE: webViewDidChange:WebViewDidChangeNotification
+EDITING DELEGATE: shouldChangeSelectedDOMRange:range from 14 of #text &gt; DIV &gt; BODY &gt; HTML &gt; #document to 14 of #text &gt; DIV &gt; BODY &gt; HTML &gt; #document toDOMRange:range from 15 of #text &gt; DIV &gt; BODY &gt; HTML &gt; #document to 15 of #text &gt; DIV &gt; BODY &gt; HTML &gt; #document affinity:NSSelectionAffinityDownstream stillSelecting:FALSE
+EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
+EDITING DELEGATE: webViewDidChange:WebViewDidChangeNotification
+EDITING DELEGATE: shouldChangeSelectedDOMRange:range from 15 of #text &gt; DIV &gt; BODY &gt; HTML &gt; #document to 15 of #text &gt; DIV &gt; BODY &gt; HTML &gt; #document toDOMRange:range from 16 of #text &gt; DIV &gt; BODY &gt; HTML &gt; #document to 16 of #text &gt; DIV &gt; BODY &gt; HTML &gt; #document affinity:NSSelectionAffinityDownstream stillSelecting:FALSE
+EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
+EDITING DELEGATE: webViewDidChange:WebViewDidChangeNotification
+EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
+EDITING DELEGATE: shouldChangeSelectedDOMRange:range from 15 of #text &gt; DIV &gt; BODY &gt; HTML &gt; #document to 15 of #text &gt; DIV &gt; BODY &gt; HTML &gt; #document toDOMRange:range from 17 of #text &gt; DIV &gt; BODY &gt; HTML &gt; #document to 17 of #text &gt; DIV &gt; BODY &gt; HTML &gt; #document affinity:NSSelectionAffinityDownstream stillSelecting:FALSE
+EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
+EDITING DELEGATE: webViewDidChange:WebViewDidChangeNotification
+EDITING DELEGATE: shouldChangeSelectedDOMRange:range from 17 of #text &gt; DIV &gt; BODY &gt; HTML &gt; #document to 17 of #text &gt; DIV &gt; BODY &gt; HTML &gt; #document toDOMRange:range from 18 of #text &gt; DIV &gt; BODY &gt; HTML &gt; #document to 18 of #text &gt; DIV &gt; BODY &gt; HTML &gt; #document affinity:NSSelectionAffinityDownstream stillSelecting:FALSE
+EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
+EDITING DELEGATE: webViewDidChange:WebViewDidChangeNotification
+EDITING DELEGATE: shouldChangeSelectedDOMRange:range from 18 of #text &gt; DIV &gt; BODY &gt; HTML &gt; #document to 18 of #text &gt; DIV &gt; BODY &gt; HTML &gt; #document toDOMRange:range from 19 of #text &gt; DIV &gt; BODY &gt; HTML &gt; #document to 19 of #text &gt; DIV &gt; BODY &gt; HTML &gt; #document affinity:NSSelectionAffinityDownstream stillSelecting:FALSE
+EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
+EDITING DELEGATE: webViewDidChange:WebViewDidChangeNotification
+EDITING DELEGATE: shouldChangeSelectedDOMRange:range from 19 of #text &gt; DIV &gt; BODY &gt; HTML &gt; #document to 19 of #text &gt; DIV &gt; BODY &gt; HTML &gt; #document toDOMRange:range from 20 of #text &gt; DIV &gt; BODY &gt; HTML &gt; #document to 20 of #text &gt; DIV &gt; BODY &gt; HTML &gt; #document affinity:NSSelectionAffinityDownstream stillSelecting:FALSE
+EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
+EDITING DELEGATE: webViewDidChange:WebViewDidChangeNotification
+EDITING DELEGATE: shouldChangeSelectedDOMRange:range from 20 of #text &gt; DIV &gt; BODY &gt; HTML &gt; #document to 20 of #text &gt; DIV &gt; BODY &gt; HTML &gt; #document toDOMRange:range from 21 of #text &gt; DIV &gt; BODY &gt; HTML &gt; #document to 21 of #text &gt; DIV &gt; BODY &gt; HTML &gt; #document affinity:NSSelectionAffinityDownstream stillSelecting:FALSE
+EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
+EDITING DELEGATE: webViewDidChange:WebViewDidChangeNotification
+EDITING DELEGATE: shouldChangeSelectedDOMRange:range from 21 of #text &gt; DIV &gt; BODY &gt; HTML &gt; #document to 21 of #text &gt; DIV &gt; BODY &gt; HTML &gt; #document toDOMRange:range from 22 of #text &gt; DIV &gt; BODY &gt; HTML &gt; #document to 22 of #text &gt; DIV &gt; BODY &gt; HTML &gt; #document affinity:NSSelectionAffinityDownstream stillSelecting:FALSE
+EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
+EDITING DELEGATE: webViewDidChange:WebViewDidChangeNotification
+EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
+EDITING DELEGATE: shouldInsertText:extremely long replacingDOMRange:range from 2 of #text &gt; DIV &gt; BODY &gt; HTML &gt; #document to 15 of #text &gt; DIV &gt; BODY &gt; HTML &gt; #document givenAction:WebViewInsertActionTyped
+EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
+EDITING DELEGATE: shouldChangeSelectedDOMRange:range from 2 of #text &gt; DIV &gt; BODY &gt; HTML &gt; #document to 2 of #text &gt; DIV &gt; BODY &gt; HTML &gt; #document toDOMRange:range from 16 of #text &gt; DIV &gt; BODY &gt; HTML &gt; #document to 16 of #text &gt; DIV &gt; BODY &gt; HTML &gt; #document affinity:NSSelectionAffinityDownstream stillSelecting:FALSE
+EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
+EDITING DELEGATE: webViewDidChange:WebViewDidChangeNotification
+EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
+EDITING DELEGATE: shouldChangeSelectedDOMRange:range from 23 of #text &gt; DIV &gt; BODY &gt; HTML &gt; #document to 23 of #text &gt; DIV &gt; BODY &gt; HTML &gt; #document toDOMRange:range from 24 of #text &gt; DIV &gt; BODY &gt; HTML &gt; #document to 24 of #text &gt; DIV &gt; BODY &gt; HTML &gt; #document affinity:NSSelectionAffinityDownstream stillSelecting:FALSE
+EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
+EDITING DELEGATE: webViewDidChange:WebViewDidChangeNotification
+EDITING DELEGATE: shouldChangeSelectedDOMRange:range from 24 of #text &gt; DIV &gt; BODY &gt; HTML &gt; #document to 24 of #text &gt; DIV &gt; BODY &gt; HTML &gt; #document toDOMRange:range from 17 of #text &gt; DIV &gt; BODY &gt; HTML &gt; #document to 23 of #text &gt; DIV &gt; BODY &gt; HTML &gt; #document affinity:NSSelectionAffinityDownstream stillSelecting:FALSE
+EDITING DELEGATE: shouldInsertText:message replacingDOMRange:range from 17 of #text &gt; DIV &gt; BODY &gt; HTML &gt; #document to 23 of #text &gt; DIV &gt; BODY &gt; HTML &gt; #document givenAction:WebViewInsertActionTyped
+EDITING DELEGATE: shouldChangeSelectedDOMRange:range from 24 of #text &gt; DIV &gt; BODY &gt; HTML &gt; #document to 24 of #text &gt; DIV &gt; BODY &gt; HTML &gt; #document toDOMRange:range from 17 of #text &gt; DIV &gt; BODY &gt; HTML &gt; #document to 23 of #text &gt; DIV &gt; BODY &gt; HTML &gt; #document affinity:NSSelectionAffinityDownstream stillSelecting:FALSE
+EDITING DELEGATE: shouldChangeSelectedDOMRange:range from 24 of #text &gt; DIV &gt; BODY &gt; HTML &gt; #document to 24 of #text &gt; DIV &gt; BODY &gt; HTML &gt; #document toDOMRange:range from 17 of #text &gt; DIV &gt; BODY &gt; HTML &gt; #document to 23 of #text &gt; DIV &gt; BODY &gt; HTML &gt; #document affinity:NSSelectionAffinityDownstream stillSelecting:FALSE
+EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
+EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
+EDITING DELEGATE: shouldChangeSelectedDOMRange:range from 17 of #text &gt; DIV &gt; BODY &gt; HTML &gt; #document to 17 of #text &gt; DIV &gt; BODY &gt; HTML &gt; #document toDOMRange:range from 24 of #text &gt; DIV &gt; BODY &gt; HTML &gt; #document to 24 of #text &gt; DIV &gt; BODY &gt; HTML &gt; #document affinity:NSSelectionAffinityDownstream stillSelecting:FALSE
+EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
+EDITING DELEGATE: webViewDidChange:WebViewDidChangeNotification
+EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
+PASS successfullyParsed is true
+
+TEST COMPLETE
+This test verifies that accepted candidates don't disable autocorrection on subsequent words. You should see the phrase &quot;a extremely long message&quot; The bug occurs if &quot;mesage&quot; was not corrected to &quot;message&quot;.
+
+a extremely long message 
</ins></span></pre></div>
<a id="trunkLayoutTestseditingmacspellingacceptcandidateallowsautocorrectonnextwordhtml"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/editing/mac/spelling/accept-candidate-allows-autocorrect-on-next-word.html (0 => 205788)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/editing/mac/spelling/accept-candidate-allows-autocorrect-on-next-word.html                                (rev 0)
+++ trunk/LayoutTests/editing/mac/spelling/accept-candidate-allows-autocorrect-on-next-word.html        2016-09-11 07:24:17 UTC (rev 205788)
</span><span class="lines">@@ -0,0 +1,57 @@
</span><ins>+&lt;html&gt;
+&lt;head&gt;
+&lt;script src=../../editing.js language=&quot;javascript&quot; type=&quot;text/javascript&quot;&gt;&lt;/script&gt;
+&lt;script src=&quot;../../../resources/js-test-pre.js&quot;&gt;&lt;/script&gt;
+&lt;script&gt;
+
+function editingTest() {
+    edit = document.getElementById('edit');
+    edit.focus();
+    var s = window.getSelection();
+    typeCharacterCommand('a');
+    typeCharacterCommand(' ');
+    typeCharacterCommand('e');
+    typeCharacterCommand('x');
+    typeCharacterCommand('t');
+    typeCharacterCommand('r');
+    typeCharacterCommand('e');
+    typeCharacterCommand('m');
+    typeCharacterCommand('e');
+    typeCharacterCommand('l');
+    typeCharacterCommand('y');
+    typeCharacterCommand('l');
+    typeCharacterCommand('o');
+    typeCharacterCommand('n');
+    typeCharacterCommand('g');
+    typeCharacterCommand(' ');
+    typeCharacterCommand('m');
+    typeCharacterCommand('e');
+    typeCharacterCommand('s');
+    typeCharacterCommand('a');
+    typeCharacterCommand('g');
+    typeCharacterCommand('e');
+
+    if (window.internals)
+        internals.handleAcceptedCandidate(&quot;extremely long&quot;, 2, 13);
+
+    // Accepting the candidate is going to cause the selection to move to it, but we want
+    // to type a space after 'mesage' to get it autocorrected.
+    setSelectionCommand(edit.firstChild, 23, edit.firstChild, 23);
+
+    typeCharacterCommand(' ');
+
+    if (window.testRunner)
+        testRunner.dumpAsText(true);
+}
+
+&lt;/script&gt;
+&lt;/head&gt;
+&lt;body&gt;
+&lt;p&gt;This test verifies that accepted candidates don't disable autocorrection on subsequent words. You should see the phrase &quot;a extremely long message&quot; The bug occurs if &quot;mesage&quot; was not corrected to &quot;message&quot;.&lt;/p&gt;
+&lt;div contenteditable=&quot;true&quot; id=&quot;edit&quot;/&gt;
+&lt;script&gt;
+runEditingTest();
+&lt;/script&gt;
+&lt;script src=&quot;../../../resources/js-test-post.js&quot;&gt;&lt;/script&gt;
+&lt;/body&gt;
+&lt;/html&gt;
</ins></span></pre></div>
<a id="trunkLayoutTestseditingmacspellingacceptcandidatereplacingmultiplewordsexpectedtxt"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/editing/mac/spelling/accept-candidate-replacing-multiple-words-expected.txt (205787 => 205788)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/editing/mac/spelling/accept-candidate-replacing-multiple-words-expected.txt        2016-09-10 18:08:32 UTC (rev 205787)
+++ trunk/LayoutTests/editing/mac/spelling/accept-candidate-replacing-multiple-words-expected.txt        2016-09-11 07:24:17 UTC (rev 205788)
</span><span class="lines">@@ -31,15 +31,11 @@
</span><span class="cx"> EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
</span><span class="cx"> EDITING DELEGATE: webViewDidChange:WebViewDidChangeNotification
</span><span class="cx"> EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
</span><del>-EDITING DELEGATE: shouldInsertText:good idea replacingDOMRange:range from 0 of #text &gt; DIV &gt; DIV &gt; BODY &gt; HTML &gt; #document to 9 of #text &gt; DIV &gt; DIV &gt; BODY &gt; HTML &gt; #document givenAction:WebViewInsertActionTyped
</del><ins>+EDITING DELEGATE: shouldInsertText:good idea  replacingDOMRange:range from 0 of #text &gt; DIV &gt; DIV &gt; BODY &gt; HTML &gt; #document to 9 of #text &gt; DIV &gt; DIV &gt; BODY &gt; HTML &gt; #document givenAction:WebViewInsertActionTyped
</ins><span class="cx"> EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
</span><del>-EDITING DELEGATE: shouldChangeSelectedDOMRange:range from 0 of DIV &gt; DIV &gt; BODY &gt; HTML &gt; #document to 0 of DIV &gt; DIV &gt; BODY &gt; HTML &gt; #document toDOMRange:range from 9 of #text &gt; DIV &gt; DIV &gt; BODY &gt; HTML &gt; #document to 9 of #text &gt; DIV &gt; DIV &gt; BODY &gt; HTML &gt; #document affinity:NSSelectionAffinityDownstream stillSelecting:FALSE
</del><ins>+EDITING DELEGATE: shouldChangeSelectedDOMRange:range from 0 of DIV &gt; DIV &gt; BODY &gt; HTML &gt; #document to 0 of DIV &gt; DIV &gt; BODY &gt; HTML &gt; #document toDOMRange:range from 10 of #text &gt; DIV &gt; DIV &gt; BODY &gt; HTML &gt; #document to 10 of #text &gt; DIV &gt; DIV &gt; BODY &gt; HTML &gt; #document affinity:NSSelectionAffinityDownstream stillSelecting:FALSE
</ins><span class="cx"> EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
</span><span class="cx"> EDITING DELEGATE: webViewDidChange:WebViewDidChangeNotification
</span><del>-EDITING DELEGATE: shouldInsertText:  replacingDOMRange:range from 9 of #text &gt; DIV &gt; DIV &gt; BODY &gt; HTML &gt; #document to 9 of #text &gt; DIV &gt; DIV &gt; BODY &gt; HTML &gt; #document givenAction:WebViewInsertActionTyped
-EDITING DELEGATE: shouldChangeSelectedDOMRange:range from 9 of #text &gt; DIV &gt; DIV &gt; BODY &gt; HTML &gt; #document to 9 of #text &gt; DIV &gt; DIV &gt; BODY &gt; HTML &gt; #document toDOMRange:range from 10 of #text &gt; DIV &gt; DIV &gt; BODY &gt; HTML &gt; #document to 10 of #text &gt; DIV &gt; DIV &gt; BODY &gt; HTML &gt; #document affinity:NSSelectionAffinityDownstream stillSelecting:FALSE
-EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
-EDITING DELEGATE: webViewDidChange:WebViewDidChangeNotification
</del><span class="cx"> PASS successfullyParsed is true
</span><span class="cx"> 
</span><span class="cx"> TEST COMPLETE
</span></span></pre></div>
<a id="trunkLayoutTestseditingmacspellingacceptcandidatereplacingmultiplewordshtml"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/editing/mac/spelling/accept-candidate-replacing-multiple-words.html (205787 => 205788)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/editing/mac/spelling/accept-candidate-replacing-multiple-words.html        2016-09-10 18:08:32 UTC (rev 205787)
+++ trunk/LayoutTests/editing/mac/spelling/accept-candidate-replacing-multiple-words.html        2016-09-11 07:24:17 UTC (rev 205788)
</span><span class="lines">@@ -18,7 +18,7 @@
</span><span class="cx">     typeCharacterCommand('a');
</span><span class="cx">     
</span><span class="cx">     if (window.internals)
</span><del>-        internals.handleAcceptedCandidate(&quot;good idea&quot;, 0, 9);
</del><ins>+        internals.handleAcceptedCandidate(&quot;good idea &quot;, 0, 9);
</ins><span class="cx"> 
</span><span class="cx">     if (window.testRunner)
</span><span class="cx">         testRunner.dumpAsText(true);
</span></span></pre></div>
<a id="trunkLayoutTestseditingmacspellingacceptcandidatewithoutaddingspaceexpectedtxt"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/editing/mac/spelling/accept-candidate-without-adding-space-expected.txt (0 => 205788)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/editing/mac/spelling/accept-candidate-without-adding-space-expected.txt                                (rev 0)
+++ trunk/LayoutTests/editing/mac/spelling/accept-candidate-without-adding-space-expected.txt        2016-09-11 07:24:17 UTC (rev 205788)
</span><span class="lines">@@ -0,0 +1,22 @@
</span><ins>+EDITING DELEGATE: shouldBeginEditingInDOMRange:range from 0 of DIV &gt; DIV &gt; BODY &gt; HTML &gt; #document to 0 of DIV &gt; DIV &gt; BODY &gt; HTML &gt; #document
+EDITING DELEGATE: webViewDidBeginEditing:WebViewDidBeginEditingNotification
+EDITING DELEGATE: shouldChangeSelectedDOMRange:(null) toDOMRange:range from 0 of DIV &gt; DIV &gt; BODY &gt; HTML &gt; #document to 0 of DIV &gt; DIV &gt; BODY &gt; HTML &gt; #document affinity:NSSelectionAffinityDownstream stillSelecting:FALSE
+EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
+EDITING DELEGATE: shouldChangeSelectedDOMRange:range from 0 of DIV &gt; DIV &gt; BODY &gt; HTML &gt; #document to 0 of DIV &gt; DIV &gt; BODY &gt; HTML &gt; #document toDOMRange:range from 1 of #text &gt; DIV &gt; DIV &gt; BODY &gt; HTML &gt; #document to 1 of #text &gt; DIV &gt; DIV &gt; BODY &gt; HTML &gt; #document affinity:NSSelectionAffinityDownstream stillSelecting:FALSE
+EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
+EDITING DELEGATE: webViewDidChange:WebViewDidChangeNotification
+EDITING DELEGATE: shouldChangeSelectedDOMRange:range from 1 of #text &gt; DIV &gt; DIV &gt; BODY &gt; HTML &gt; #document to 1 of #text &gt; DIV &gt; DIV &gt; BODY &gt; HTML &gt; #document toDOMRange:range from 2 of #text &gt; DIV &gt; DIV &gt; BODY &gt; HTML &gt; #document to 2 of #text &gt; DIV &gt; DIV &gt; BODY &gt; HTML &gt; #document affinity:NSSelectionAffinityDownstream stillSelecting:FALSE
+EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
+EDITING DELEGATE: webViewDidChange:WebViewDidChangeNotification
+EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
+EDITING DELEGATE: shouldInsertText:is replacingDOMRange:range from 0 of #text &gt; DIV &gt; DIV &gt; BODY &gt; HTML &gt; #document to 2 of #text &gt; DIV &gt; DIV &gt; BODY &gt; HTML &gt; #document givenAction:WebViewInsertActionTyped
+EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
+EDITING DELEGATE: shouldChangeSelectedDOMRange:range from 0 of DIV &gt; DIV &gt; BODY &gt; HTML &gt; #document to 0 of DIV &gt; DIV &gt; BODY &gt; HTML &gt; #document toDOMRange:range from 2 of #text &gt; DIV &gt; DIV &gt; BODY &gt; HTML &gt; #document to 2 of #text &gt; DIV &gt; DIV &gt; BODY &gt; HTML &gt; #document affinity:NSSelectionAffinityDownstream stillSelecting:FALSE
+EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
+EDITING DELEGATE: webViewDidChange:WebViewDidChangeNotification
+PASS successfullyParsed is true
+
+TEST COMPLETE
+This test verifies that accepted candidates that do not have spaces don't add them.
+
+is
</ins></span></pre></div>
<a id="trunkLayoutTestseditingmacspellingacceptcandidatewithoutaddingspacehtml"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/editing/mac/spelling/accept-candidate-without-adding-space.html (0 => 205788)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/editing/mac/spelling/accept-candidate-without-adding-space.html                                (rev 0)
+++ trunk/LayoutTests/editing/mac/spelling/accept-candidate-without-adding-space.html        2016-09-11 07:24:17 UTC (rev 205788)
</span><span class="lines">@@ -0,0 +1,32 @@
</span><ins>+&lt;html&gt;
+&lt;head&gt;
+&lt;script src=../../editing.js&gt;&lt;/script&gt;
+&lt;script src=&quot;../../../resources/js-test-pre.js&quot;&gt;&lt;/script&gt;
+&lt;script&gt;
+
+function editingTest() {
+    edit = document.getElementById('edit');
+    edit.focus();
+    typeCharacterCommand('s');
+    typeCharacterCommand('i');
+    
+    if (window.internals)
+        internals.handleAcceptedCandidate(&quot;is&quot;, 0, 2);
+
+    if (window.testRunner)
+        testRunner.dumpAsText(true);
+}
+
+&lt;/script&gt;
+&lt;/head&gt;
+&lt;body&gt;
+&lt;p&gt;This test verifies that accepted candidates that do not have spaces don't add them.&lt;/p&gt;
+&lt;div style=&quot;border:1px solid black;&quot;&gt;
+    &lt;div contenteditable=&quot;true&quot; id=&quot;edit&quot;&gt;&lt;/div&gt;
+&lt;/div&gt;
+&lt;script&gt;
+runEditingTest();
+&lt;/script&gt;
+&lt;script src=&quot;../../../resources/js-test-post.js&quot;&gt;&lt;/script&gt;
+&lt;/body&gt;
+&lt;/html&gt;
</ins></span></pre></div>
<a id="trunkLayoutTestseditingmacspellingacceptcandidatewithoutcrossingeditingboundaryexpectedtxt"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/editing/mac/spelling/accept-candidate-without-crossing-editing-boundary-expected.txt (205787 => 205788)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/editing/mac/spelling/accept-candidate-without-crossing-editing-boundary-expected.txt        2016-09-10 18:08:32 UTC (rev 205787)
+++ trunk/LayoutTests/editing/mac/spelling/accept-candidate-without-crossing-editing-boundary-expected.txt        2016-09-11 07:24:17 UTC (rev 205788)
</span><span class="lines">@@ -9,15 +9,11 @@
</span><span class="cx"> EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
</span><span class="cx"> EDITING DELEGATE: webViewDidChange:WebViewDidChangeNotification
</span><span class="cx"> EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
</span><del>-EDITING DELEGATE: shouldInsertText:happy replacingDOMRange:range from 0 of #text &gt; DIV &gt; DIV &gt; BODY &gt; HTML &gt; #document to 2 of #text &gt; DIV &gt; DIV &gt; BODY &gt; HTML &gt; #document givenAction:WebViewInsertActionTyped
</del><ins>+EDITING DELEGATE: shouldInsertText:happy  replacingDOMRange:range from 0 of #text &gt; DIV &gt; DIV &gt; BODY &gt; HTML &gt; #document to 2 of #text &gt; DIV &gt; DIV &gt; BODY &gt; HTML &gt; #document givenAction:WebViewInsertActionTyped
</ins><span class="cx"> EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
</span><del>-EDITING DELEGATE: shouldChangeSelectedDOMRange:range from 0 of DIV &gt; DIV &gt; BODY &gt; HTML &gt; #document to 0 of DIV &gt; DIV &gt; BODY &gt; HTML &gt; #document toDOMRange:range from 5 of #text &gt; DIV &gt; DIV &gt; BODY &gt; HTML &gt; #document to 5 of #text &gt; DIV &gt; DIV &gt; BODY &gt; HTML &gt; #document affinity:NSSelectionAffinityDownstream stillSelecting:FALSE
</del><ins>+EDITING DELEGATE: shouldChangeSelectedDOMRange:range from 0 of DIV &gt; DIV &gt; BODY &gt; HTML &gt; #document to 0 of DIV &gt; DIV &gt; BODY &gt; HTML &gt; #document toDOMRange:range from 6 of #text &gt; DIV &gt; DIV &gt; BODY &gt; HTML &gt; #document to 6 of #text &gt; DIV &gt; DIV &gt; BODY &gt; HTML &gt; #document affinity:NSSelectionAffinityDownstream stillSelecting:FALSE
</ins><span class="cx"> EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
</span><span class="cx"> EDITING DELEGATE: webViewDidChange:WebViewDidChangeNotification
</span><del>-EDITING DELEGATE: shouldInsertText:  replacingDOMRange:range from 5 of #text &gt; DIV &gt; DIV &gt; BODY &gt; HTML &gt; #document to 5 of #text &gt; DIV &gt; DIV &gt; BODY &gt; HTML &gt; #document givenAction:WebViewInsertActionTyped
-EDITING DELEGATE: shouldChangeSelectedDOMRange:range from 5 of #text &gt; DIV &gt; DIV &gt; BODY &gt; HTML &gt; #document to 5 of #text &gt; DIV &gt; DIV &gt; BODY &gt; HTML &gt; #document toDOMRange:range from 6 of #text &gt; DIV &gt; DIV &gt; BODY &gt; HTML &gt; #document to 6 of #text &gt; DIV &gt; DIV &gt; BODY &gt; HTML &gt; #document affinity:NSSelectionAffinityDownstream stillSelecting:FALSE
-EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
-EDITING DELEGATE: webViewDidChange:WebViewDidChangeNotification
</del><span class="cx"> PASS successfullyParsed is true
</span><span class="cx"> 
</span><span class="cx"> TEST COMPLETE
</span></span></pre></div>
<a id="trunkLayoutTestseditingmacspellingacceptcandidatewithoutcrossingeditingboundaryhtml"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/editing/mac/spelling/accept-candidate-without-crossing-editing-boundary.html (205787 => 205788)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/editing/mac/spelling/accept-candidate-without-crossing-editing-boundary.html        2016-09-10 18:08:32 UTC (rev 205787)
+++ trunk/LayoutTests/editing/mac/spelling/accept-candidate-without-crossing-editing-boundary.html        2016-09-11 07:24:17 UTC (rev 205788)
</span><span class="lines">@@ -10,7 +10,7 @@
</span><span class="cx">     typeCharacterCommand('h');
</span><span class="cx">     typeCharacterCommand('a');
</span><span class="cx">     if (window.internals)
</span><del>-        internals.handleAcceptedCandidate(&quot;happy&quot;, 0, 2);
</del><ins>+        internals.handleAcceptedCandidate(&quot;happy &quot;, 0, 2);
</ins><span class="cx"> 
</span><span class="cx">     if (window.testRunner)
</span><span class="cx">         testRunner.dumpAsText(true);
</span></span></pre></div>
<a id="trunkLayoutTestseditingmacspellingacceptmisspelledcandidateexpectedtxt"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/editing/mac/spelling/accept-misspelled-candidate-expected.txt (205787 => 205788)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/editing/mac/spelling/accept-misspelled-candidate-expected.txt        2016-09-10 18:08:32 UTC (rev 205787)
+++ trunk/LayoutTests/editing/mac/spelling/accept-misspelled-candidate-expected.txt        2016-09-11 07:24:17 UTC (rev 205788)
</span><span class="lines">@@ -29,17 +29,12 @@
</span><span class="cx"> EDITING DELEGATE: shouldChangeSelectedDOMRange:range from 6 of #text &gt; DIV &gt; BODY &gt; HTML &gt; #document to 6 of #text &gt; DIV &gt; BODY &gt; HTML &gt; #document toDOMRange:range from 13 of #text &gt; DIV &gt; BODY &gt; HTML &gt; #document to 13 of #text &gt; DIV &gt; BODY &gt; HTML &gt; #document affinity:NSSelectionAffinityDownstream stillSelecting:FALSE
</span><span class="cx"> EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
</span><span class="cx"> EDITING DELEGATE: webViewDidChange:WebViewDidChangeNotification
</span><del>-EDITING DELEGATE: shouldInsertText:  replacingDOMRange:range from 13 of #text &gt; DIV &gt; BODY &gt; HTML &gt; #document to 13 of #text &gt; DIV &gt; BODY &gt; HTML &gt; #document givenAction:WebViewInsertActionTyped
</del><span class="cx"> EDITING DELEGATE: shouldChangeSelectedDOMRange:range from 13 of #text &gt; DIV &gt; BODY &gt; HTML &gt; #document to 13 of #text &gt; DIV &gt; BODY &gt; HTML &gt; #document toDOMRange:range from 14 of #text &gt; DIV &gt; BODY &gt; HTML &gt; #document to 14 of #text &gt; DIV &gt; BODY &gt; HTML &gt; #document affinity:NSSelectionAffinityDownstream stillSelecting:FALSE
</span><span class="cx"> EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
</span><span class="cx"> EDITING DELEGATE: webViewDidChange:WebViewDidChangeNotification
</span><del>-EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
-EDITING DELEGATE: shouldChangeSelectedDOMRange:range from 13 of #text &gt; DIV &gt; BODY &gt; HTML &gt; #document to 13 of #text &gt; DIV &gt; BODY &gt; HTML &gt; #document toDOMRange:range from 15 of #text &gt; DIV &gt; BODY &gt; HTML &gt; #document to 15 of #text &gt; DIV &gt; BODY &gt; HTML &gt; #document affinity:NSSelectionAffinityDownstream stillSelecting:FALSE
-EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
-EDITING DELEGATE: webViewDidChange:WebViewDidChangeNotification
</del><span class="cx"> PASS successfullyParsed is true
</span><span class="cx"> 
</span><span class="cx"> TEST COMPLETE
</span><span class="cx"> This test verifies that accepted candidates are not autocorrected. You should see phrase &quot;it's a mesage.&quot; The bug occurs if &quot;mesage&quot; was corrected to &quot;message.&quot;
</span><span class="cx"> 
</span><del>-it's a mesage  
</del><ins>+it's a mesage 
</ins></span></pre></div>
<a id="trunkLayoutTestsplatformmacwk2TestExpectations"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/platform/mac-wk2/TestExpectations (205787 => 205788)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/platform/mac-wk2/TestExpectations        2016-09-10 18:08:32 UTC (rev 205787)
+++ trunk/LayoutTests/platform/mac-wk2/TestExpectations        2016-09-11 07:24:17 UTC (rev 205788)
</span><span class="lines">@@ -163,6 +163,7 @@
</span><span class="cx"> webkit.org/b/105616 editing/mac/spelling/move-cursor-to-autocorrected-word.html [ Failure ]
</span><span class="cx"> webkit.org/b/105616 editing/mac/spelling/move-cursor-to-beginning-of-autocorrected-word.html [ Failure ]
</span><span class="cx"> webkit.org/b/105616 editing/mac/spelling/removing-underline-after-accepting-autocorrection-using-punctuation.html [ Failure ]
</span><ins>+webkit.org/b/105616 editing/mac/spelling/accept-candidate-allows-autocorrect-on-next-word.html [ Failure ]
</ins><span class="cx"> 
</span><span class="cx"> # [WK2] [Mac] Support drag in mouse events for WebKit2 EventSender
</span><span class="cx"> # &lt;https://bugs.webkit.org/show_bug.cgi?id=68552&gt;
</span></span></pre></div>
<a id="trunkSourceWebCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/ChangeLog (205787 => 205788)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/ChangeLog        2016-09-10 18:08:32 UTC (rev 205787)
+++ trunk/Source/WebCore/ChangeLog        2016-09-11 07:24:17 UTC (rev 205788)
</span><span class="lines">@@ -1,3 +1,26 @@
</span><ins>+2016-09-11  Tim Horton  &lt;timothy_horton@apple.com&gt;
+
+        Candidates that don't end in spaces shouldn't have spaces arbitrarily appended to them
+        https://bugs.webkit.org/show_bug.cgi?id=161846
+        &lt;rdar://problem/28245097&gt;
+
+        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).
+
</ins><span class="cx"> 2016-09-10  Chris Dumez  &lt;cdumez@apple.com&gt;
</span><span class="cx"> 
</span><span class="cx">         parseHTMLInteger() should take a StringView in parameter
</span></span></pre></div>
<a id="trunkSourceWebCoreeditingEditorcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/editing/Editor.cpp (205787 => 205788)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/editing/Editor.cpp        2016-09-10 18:08:32 UTC (rev 205787)
+++ trunk/Source/WebCore/editing/Editor.cpp        2016-09-11 07:24:17 UTC (rev 205788)
</span><span class="lines">@@ -3636,7 +3636,6 @@
</span><span class="cx"> void Editor::handleAcceptedCandidate(TextCheckingResult acceptedCandidate)
</span><span class="cx"> {
</span><span class="cx">     const VisibleSelection&amp; selection = m_frame.selection().selection();
</span><del>-    int candidateLength = acceptedCandidate.length;
</del><span class="cx"> 
</span><span class="cx">     m_isHandlingAcceptedCandidate = true;
</span><span class="cx"> 
</span><span class="lines">@@ -3643,13 +3642,7 @@
</span><span class="cx">     selectTextCheckingResult(acceptedCandidate);
</span><span class="cx">     insertText(acceptedCandidate.replacement, 0);
</span><span class="cx"> 
</span><del>-    // Some candidates come with a space built in, and we do not need to add another space in that case.
-    if (!acceptedCandidate.replacement.endsWith(' ')) {
-        insertText(ASCIILiteral(&quot; &quot;), 0);
-        ++candidateLength;
-    }
-
-    RefPtr&lt;Range&gt; insertedCandidateRange = rangeExpandedAroundPositionByCharacters(selection.visibleStart(), candidateLength);
</del><ins>+    RefPtr&lt;Range&gt; insertedCandidateRange = rangeExpandedByCharactersInDirectionAtWordBoundary(selection.visibleStart(), acceptedCandidate.replacement.length(), DirectionBackward);
</ins><span class="cx">     if (insertedCandidateRange)
</span><span class="cx">         insertedCandidateRange-&gt;startContainer().document().markers().addMarker(insertedCandidateRange.get(), DocumentMarker::AcceptedCandidate, acceptedCandidate.replacement);
</span><span class="cx"> 
</span></span></pre>
</div>
</div>

</body>
</html>