<!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>[198306] trunk/Source</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/198306">198306</a></dd>
<dt>Author</dt> <dd>bdakin@apple.com</dd>
<dt>Date</dt> <dd>2016-03-16 16:25:09 -0700 (Wed, 16 Mar 2016)</dd>
</dl>

<h3>Log Message</h3>
<pre>Provide NSSpellChecker spellChecking methods with the current insertion point
https://bugs.webkit.org/show_bug.cgi?id=155532
-and corresponding-
rdar://problem/24066952

Reviewed by Simon Fraser.

Source/WebCore:

Pass the Frame’s selection to a handful of spelling checking methods that 
call into WebKit/WebKit2 to ultimately call into NSSpellChecker.
* accessibility/AccessibilityObject.cpp:
(WebCore::AccessibilityObject::hasMisspelling):
* accessibility/mac/WebAccessibilityObjectWrapperMac.mm:
(AXAttributeStringSetSpelling):
* editing/AlternativeTextController.cpp:
(WebCore::AlternativeTextController::timerFired):
* editing/Editor.cpp:
(WebCore::Editor::guessesForMisspelledWord):
(WebCore::Editor::markAllMisspellingsAndBadGrammarInRanges):
* editing/SpellChecker.cpp:
(WebCore::SpellChecker::invokeRequest):
(WebCore::SpellChecker::enqueueRequest):
* editing/TextCheckingHelper.cpp:
(WebCore::TextCheckingHelper::findFirstMisspellingOrBadGrammar):
(WebCore::TextCheckingHelper::guessesForMisspelledOrUngrammaticalRange):
(WebCore::TextCheckingHelper::unifiedTextCheckerEnabled):
(WebCore::checkTextOfParagraph):
* editing/TextCheckingHelper.h:
* loader/EmptyClients.cpp:
(WebCore::EmptyFrameLoaderClient::createNetworkingContext):
(WebCore::EmptyTextCheckerClient::requestCheckingOfString):
* loader/EmptyClients.h:
* platform/text/TextCheckerClient.h:
(WebCore::TextCheckerClient::~TextCheckerClient):

The key needed to include the insertion point.
* platform/spi/mac/NSSpellCheckerSPI.h:

Source/WebKit/mac:

Extract the insertion point from the VisibleSelection that WebCore has 
passed. 
* WebCoreSupport/WebEditorClient.h:
(WebEditorClient::getGuessesForWord):
* WebCoreSupport/WebEditorClient.mm:
(WebEditorClient::checkTextOfParagraph):
(insertionPointFromCurrentSelection):
(WebEditorClient::getGuessesForWord):
(WebEditorClient::requestCheckingOfString):

Source/WebKit2:

Pass the insertionPoint to the UIProcess
* UIProcess/TextChecker.h:
* UIProcess/WebPageProxy.cpp:
(WebKit::WebPageProxy::checkTextOfParagraph):
(WebKit::WebPageProxy::getGuessesForWord):
(WebKit::WebPageProxy::requestCheckingOfString):
* UIProcess/WebPageProxy.h:
* UIProcess/WebPageProxy.messages.in:
* UIProcess/efl/TextCheckerEfl.cpp:
(WebKit::TextChecker::checkTextOfParagraph):
(WebKit::TextChecker::getGuessesForWord):
(WebKit::TextChecker::requestCheckingOfString):
* UIProcess/gtk/TextCheckerGtk.cpp:
(WebKit::TextChecker::getGuessesForWord):
(WebKit::TextChecker::requestCheckingOfString):
(WebKit::TextChecker::checkTextOfParagraph):
* UIProcess/ios/TextCheckerIOS.mm:
(WebKit::TextChecker::checkTextOfParagraph):
(WebKit::TextChecker::getGuessesForWord):
(WebKit::TextChecker::requestCheckingOfString):
* UIProcess/mac/TextCheckerMac.mm:
(WebKit::TextChecker::checkTextOfParagraph):
(WebKit::TextChecker::getGuessesForWord):
(WebKit::TextChecker::ignoreWord):
(WebKit::TextChecker::requestCheckingOfString):

Extract the insertion point from the VisibleSelection that WebCore has 
passed. 
* WebProcess/WebCoreSupport/WebEditorClient.cpp:
(WebKit::insertionPointFromCurrentSelection):
(WebKit::WebEditorClient::checkTextOfParagraph):
(WebKit::WebEditorClient::getGuessesForWord):
(WebKit::WebEditorClient::requestCheckingOfString):
* WebProcess/WebCoreSupport/WebEditorClient.h:</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkSourceWebCoreChangeLog">trunk/Source/WebCore/ChangeLog</a></li>
<li><a href="#trunkSourceWebCoreaccessibilityAccessibilityObjectcpp">trunk/Source/WebCore/accessibility/AccessibilityObject.cpp</a></li>
<li><a href="#trunkSourceWebCoreaccessibilitymacWebAccessibilityObjectWrapperMacmm">trunk/Source/WebCore/accessibility/mac/WebAccessibilityObjectWrapperMac.mm</a></li>
<li><a href="#trunkSourceWebCoreeditingAlternativeTextControllercpp">trunk/Source/WebCore/editing/AlternativeTextController.cpp</a></li>
<li><a href="#trunkSourceWebCoreeditingEditorcpp">trunk/Source/WebCore/editing/Editor.cpp</a></li>
<li><a href="#trunkSourceWebCoreeditingSpellCheckercpp">trunk/Source/WebCore/editing/SpellChecker.cpp</a></li>
<li><a href="#trunkSourceWebCoreeditingTextCheckingHelpercpp">trunk/Source/WebCore/editing/TextCheckingHelper.cpp</a></li>
<li><a href="#trunkSourceWebCoreeditingTextCheckingHelperh">trunk/Source/WebCore/editing/TextCheckingHelper.h</a></li>
<li><a href="#trunkSourceWebCoreloaderEmptyClientscpp">trunk/Source/WebCore/loader/EmptyClients.cpp</a></li>
<li><a href="#trunkSourceWebCoreloaderEmptyClientsh">trunk/Source/WebCore/loader/EmptyClients.h</a></li>
<li><a href="#trunkSourceWebCoreplatformspimacNSSpellCheckerSPIh">trunk/Source/WebCore/platform/spi/mac/NSSpellCheckerSPI.h</a></li>
<li><a href="#trunkSourceWebCoreplatformtextTextCheckerClienth">trunk/Source/WebCore/platform/text/TextCheckerClient.h</a></li>
<li><a href="#trunkSourceWebKitmacChangeLog">trunk/Source/WebKit/mac/ChangeLog</a></li>
<li><a href="#trunkSourceWebKitmacWebCoreSupportWebEditorClienth">trunk/Source/WebKit/mac/WebCoreSupport/WebEditorClient.h</a></li>
<li><a href="#trunkSourceWebKitmacWebCoreSupportWebEditorClientmm">trunk/Source/WebKit/mac/WebCoreSupport/WebEditorClient.mm</a></li>
<li><a href="#trunkSourceWebKitwinWebCoreSupportWebEditorClientcpp">trunk/Source/WebKit/win/WebCoreSupport/WebEditorClient.cpp</a></li>
<li><a href="#trunkSourceWebKitwinWebCoreSupportWebEditorClienth">trunk/Source/WebKit/win/WebCoreSupport/WebEditorClient.h</a></li>
<li><a href="#trunkSourceWebKit2ChangeLog">trunk/Source/WebKit2/ChangeLog</a></li>
<li><a href="#trunkSourceWebKit2UIProcessTextCheckerh">trunk/Source/WebKit2/UIProcess/TextChecker.h</a></li>
<li><a href="#trunkSourceWebKit2UIProcessWebPageProxycpp">trunk/Source/WebKit2/UIProcess/WebPageProxy.cpp</a></li>
<li><a href="#trunkSourceWebKit2UIProcessWebPageProxyh">trunk/Source/WebKit2/UIProcess/WebPageProxy.h</a></li>
<li><a href="#trunkSourceWebKit2UIProcessWebPageProxymessagesin">trunk/Source/WebKit2/UIProcess/WebPageProxy.messages.in</a></li>
<li><a href="#trunkSourceWebKit2UIProcesseflTextCheckerEflcpp">trunk/Source/WebKit2/UIProcess/efl/TextCheckerEfl.cpp</a></li>
<li><a href="#trunkSourceWebKit2UIProcessgtkTextCheckerGtkcpp">trunk/Source/WebKit2/UIProcess/gtk/TextCheckerGtk.cpp</a></li>
<li><a href="#trunkSourceWebKit2UIProcessiosTextCheckerIOSmm">trunk/Source/WebKit2/UIProcess/ios/TextCheckerIOS.mm</a></li>
<li><a href="#trunkSourceWebKit2UIProcessmacTextCheckerMacmm">trunk/Source/WebKit2/UIProcess/mac/TextCheckerMac.mm</a></li>
<li><a href="#trunkSourceWebKit2WebProcessWebCoreSupportWebEditorClientcpp">trunk/Source/WebKit2/WebProcess/WebCoreSupport/WebEditorClient.cpp</a></li>
<li><a href="#trunkSourceWebKit2WebProcessWebCoreSupportWebEditorClienth">trunk/Source/WebKit2/WebProcess/WebCoreSupport/WebEditorClient.h</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkSourceWebCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/ChangeLog (198305 => 198306)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/ChangeLog        2016-03-16 22:10:02 UTC (rev 198305)
+++ trunk/Source/WebCore/ChangeLog        2016-03-16 23:25:09 UTC (rev 198306)
</span><span class="lines">@@ -1,3 +1,42 @@
</span><ins>+2016-03-16  Beth Dakin  &lt;bdakin@apple.com&gt;
+
+        Provide NSSpellChecker spellChecking methods with the current insertion point
+        https://bugs.webkit.org/show_bug.cgi?id=155532
+        -and corresponding-
+        rdar://problem/24066952
+
+        Reviewed by Simon Fraser.
+
+        Pass the Frame’s selection to a handful of spelling checking methods that 
+        call into WebKit/WebKit2 to ultimately call into NSSpellChecker.
+        * accessibility/AccessibilityObject.cpp:
+        (WebCore::AccessibilityObject::hasMisspelling):
+        * accessibility/mac/WebAccessibilityObjectWrapperMac.mm:
+        (AXAttributeStringSetSpelling):
+        * editing/AlternativeTextController.cpp:
+        (WebCore::AlternativeTextController::timerFired):
+        * editing/Editor.cpp:
+        (WebCore::Editor::guessesForMisspelledWord):
+        (WebCore::Editor::markAllMisspellingsAndBadGrammarInRanges):
+        * editing/SpellChecker.cpp:
+        (WebCore::SpellChecker::invokeRequest):
+        (WebCore::SpellChecker::enqueueRequest):
+        * editing/TextCheckingHelper.cpp:
+        (WebCore::TextCheckingHelper::findFirstMisspellingOrBadGrammar):
+        (WebCore::TextCheckingHelper::guessesForMisspelledOrUngrammaticalRange):
+        (WebCore::TextCheckingHelper::unifiedTextCheckerEnabled):
+        (WebCore::checkTextOfParagraph):
+        * editing/TextCheckingHelper.h:
+        * loader/EmptyClients.cpp:
+        (WebCore::EmptyFrameLoaderClient::createNetworkingContext):
+        (WebCore::EmptyTextCheckerClient::requestCheckingOfString):
+        * loader/EmptyClients.h:
+        * platform/text/TextCheckerClient.h:
+        (WebCore::TextCheckerClient::~TextCheckerClient):
+
+        The key needed to include the insertion point.
+        * platform/spi/mac/NSSpellCheckerSPI.h:
+
</ins><span class="cx"> 2016-03-16  Alex Christensen  &lt;achristensen@webkit.org&gt;
</span><span class="cx"> 
</span><span class="cx">         Fix assertion failure on drive.google.com after r196052
</span></span></pre></div>
<a id="trunkSourceWebCoreaccessibilityAccessibilityObjectcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/accessibility/AccessibilityObject.cpp (198305 => 198306)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/accessibility/AccessibilityObject.cpp        2016-03-16 22:10:02 UTC (rev 198305)
+++ trunk/Source/WebCore/accessibility/AccessibilityObject.cpp        2016-03-16 23:25:09 UTC (rev 198306)
</span><span class="lines">@@ -424,7 +424,7 @@
</span><span class="cx"> 
</span><span class="cx">     if (unifiedTextCheckerEnabled(frame)) {
</span><span class="cx">         Vector&lt;TextCheckingResult&gt; results;
</span><del>-        checkTextOfParagraph(*textChecker, stringValue(), TextCheckingTypeSpelling, results);
</del><ins>+        checkTextOfParagraph(*textChecker, stringValue(), TextCheckingTypeSpelling, results, frame-&gt;selection().selection());
</ins><span class="cx">         if (!results.isEmpty())
</span><span class="cx">             isMisspelled = true;
</span><span class="cx">         return isMisspelled;
</span></span></pre></div>
<a id="trunkSourceWebCoreaccessibilitymacWebAccessibilityObjectWrapperMacmm"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/accessibility/mac/WebAccessibilityObjectWrapperMac.mm (198305 => 198306)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/accessibility/mac/WebAccessibilityObjectWrapperMac.mm        2016-03-16 22:10:02 UTC (rev 198305)
+++ trunk/Source/WebCore/accessibility/mac/WebAccessibilityObjectWrapperMac.mm        2016-03-16 23:25:09 UTC (rev 198306)
</span><span class="lines">@@ -1142,7 +1142,7 @@
</span><span class="cx">         
</span><span class="cx">         // checkTextOfParagraph is the only spelling/grammar checker implemented in WK1 and WK2
</span><span class="cx">         Vector&lt;TextCheckingResult&gt; results;
</span><del>-        checkTextOfParagraph(*checker, text, TextCheckingTypeSpelling, results);
</del><ins>+        checkTextOfParagraph(*checker, text, TextCheckingTypeSpelling, results, node-&gt;document().frame()-&gt;selection().selection());
</ins><span class="cx">         
</span><span class="cx">         size_t size = results.size();
</span><span class="cx">         NSNumber* trueValue = [NSNumber numberWithBool:YES];
</span></span></pre></div>
<a id="trunkSourceWebCoreeditingAlternativeTextControllercpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/editing/AlternativeTextController.cpp (198305 => 198306)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/editing/AlternativeTextController.cpp        2016-03-16 22:10:02 UTC (rev 198305)
+++ trunk/Source/WebCore/editing/AlternativeTextController.cpp        2016-03-16 23:25:09 UTC (rev 198306)
</span><span class="lines">@@ -353,7 +353,7 @@
</span><span class="cx">             break;
</span><span class="cx">         String paragraphText = plainText(TextCheckingParagraph(m_alternativeTextInfo.rangeWithAlternative).paragraphRange().get());
</span><span class="cx">         Vector&lt;String&gt; suggestions;
</span><del>-        textChecker()-&gt;getGuessesForWord(m_alternativeTextInfo.originalText, paragraphText, suggestions);
</del><ins>+        textChecker()-&gt;getGuessesForWord(m_alternativeTextInfo.originalText, paragraphText, m_frame.selection().selection(), suggestions);
</ins><span class="cx">         if (suggestions.isEmpty()) {
</span><span class="cx">             m_alternativeTextInfo.rangeWithAlternative = nullptr;
</span><span class="cx">             break;
</span></span></pre></div>
<a id="trunkSourceWebCoreeditingEditorcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/editing/Editor.cpp (198305 => 198306)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/editing/Editor.cpp        2016-03-16 22:10:02 UTC (rev 198305)
+++ trunk/Source/WebCore/editing/Editor.cpp        2016-03-16 23:25:09 UTC (rev 198306)
</span><span class="lines">@@ -2128,7 +2128,7 @@
</span><span class="cx"> 
</span><span class="cx">     Vector&lt;String&gt; guesses;
</span><span class="cx">     if (client())
</span><del>-        textChecker()-&gt;getGuessesForWord(word, String(), guesses);
</del><ins>+        textChecker()-&gt;getGuessesForWord(word, String(), m_frame.selection().selection(), guesses);
</ins><span class="cx">     return guesses;
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="lines">@@ -2402,7 +2402,7 @@
</span><span class="cx">     }
</span><span class="cx"> 
</span><span class="cx">     Vector&lt;TextCheckingResult&gt; results;
</span><del>-    checkTextOfParagraph(*textChecker(), paragraphToCheck.text(), resolveTextCheckingTypeMask(textCheckingOptions), results);
</del><ins>+    checkTextOfParagraph(*textChecker(), paragraphToCheck.text(), resolveTextCheckingTypeMask(textCheckingOptions), results, m_frame.selection().selection());
</ins><span class="cx">     markAndReplaceFor(request.release(), results);
</span><span class="cx"> }
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceWebCoreeditingSpellCheckercpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/editing/SpellChecker.cpp (198305 => 198306)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/editing/SpellChecker.cpp        2016-03-16 22:10:02 UTC (rev 198305)
+++ trunk/Source/WebCore/editing/SpellChecker.cpp        2016-03-16 23:25:09 UTC (rev 198306)
</span><span class="lines">@@ -181,7 +181,7 @@
</span><span class="cx">     if (!client())
</span><span class="cx">         return;
</span><span class="cx">     m_processingRequest = request;
</span><del>-    client()-&gt;requestCheckingOfString(m_processingRequest);
</del><ins>+    client()-&gt;requestCheckingOfString(m_processingRequest, m_frame.selection().selection());
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void SpellChecker::enqueueRequest(PassRefPtr&lt;SpellCheckRequest&gt; request)
</span></span></pre></div>
<a id="trunkSourceWebCoreeditingTextCheckingHelpercpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/editing/TextCheckingHelper.cpp (198305 => 198306)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/editing/TextCheckingHelper.cpp        2016-03-16 22:10:02 UTC (rev 198305)
+++ trunk/Source/WebCore/editing/TextCheckingHelper.cpp        2016-03-16 23:25:09 UTC (rev 198306)
</span><span class="lines">@@ -30,6 +30,7 @@
</span><span class="cx"> #include &quot;Document.h&quot;
</span><span class="cx"> #include &quot;DocumentMarkerController.h&quot;
</span><span class="cx"> #include &quot;Frame.h&quot;
</span><ins>+#include &quot;FrameSelection.h&quot;
</ins><span class="cx"> #include &quot;Settings.h&quot;
</span><span class="cx"> #include &quot;TextBreakIterator.h&quot;
</span><span class="cx"> #include &quot;TextCheckerClient.h&quot;
</span><span class="lines">@@ -346,7 +347,10 @@
</span><span class="cx">                 
</span><span class="cx">                 Vector&lt;TextCheckingResult&gt; results;
</span><span class="cx">                 TextCheckingTypeMask checkingTypes = checkGrammar ? (TextCheckingTypeSpelling | TextCheckingTypeGrammar) : TextCheckingTypeSpelling;
</span><del>-                checkTextOfParagraph(*m_client-&gt;textChecker(), paragraphString, checkingTypes, results);
</del><ins>+                VisibleSelection currentSelection;
+                if (Frame* frame = paragraphRange-&gt;ownerDocument().frame())
+                    currentSelection = frame-&gt;selection().selection();
+                checkTextOfParagraph(*m_client-&gt;textChecker(), paragraphString, checkingTypes, results, currentSelection);
</ins><span class="cx"> 
</span><span class="cx">                 for (auto&amp; result : results) {
</span><span class="cx">                     if (result.type == TextCheckingTypeSpelling &amp;&amp; result.location &gt;= currentStartOffset &amp;&amp; result.location + result.length &lt;= currentEndOffset) {
</span><span class="lines">@@ -578,13 +582,16 @@
</span><span class="cx"> 
</span><span class="cx">     Vector&lt;TextCheckingResult&gt; results;
</span><span class="cx">     TextCheckingTypeMask checkingTypes = checkGrammar ? (TextCheckingTypeSpelling | TextCheckingTypeGrammar) : TextCheckingTypeSpelling;
</span><del>-    checkTextOfParagraph(*m_client-&gt;textChecker(), paragraph.text(), checkingTypes, results);
</del><ins>+    VisibleSelection currentSelection;
+    if (Frame* frame = m_range-&gt;ownerDocument().frame())
+        currentSelection = frame-&gt;selection().selection();
+    checkTextOfParagraph(*m_client-&gt;textChecker(), paragraph.text(), checkingTypes, results, currentSelection);
</ins><span class="cx"> 
</span><span class="cx">     for (auto&amp; result : results) {
</span><span class="cx">         if (result.type == TextCheckingTypeSpelling &amp;&amp; paragraph.checkingRangeMatches(result.location, result.length)) {
</span><span class="cx">             String misspelledWord = paragraph.checkingSubstring();
</span><span class="cx">             ASSERT(misspelledWord.length());
</span><del>-            m_client-&gt;textChecker()-&gt;getGuessesForWord(misspelledWord, String(), guesses);
</del><ins>+            m_client-&gt;textChecker()-&gt;getGuessesForWord(misspelledWord, String(), currentSelection, guesses);
</ins><span class="cx">             m_client-&gt;updateSpellingUIWithMisspelledWord(misspelledWord);
</span><span class="cx">             misspelled = true;
</span><span class="cx">             return guesses;
</span><span class="lines">@@ -638,11 +645,13 @@
</span><span class="cx">     return m_range &amp;&amp; WebCore::unifiedTextCheckerEnabled(m_range-&gt;ownerDocument().frame());
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-void checkTextOfParagraph(TextCheckerClient&amp; client, StringView text, TextCheckingTypeMask checkingTypes, Vector&lt;TextCheckingResult&gt;&amp; results)
</del><ins>+void checkTextOfParagraph(TextCheckerClient&amp; client, StringView text, TextCheckingTypeMask checkingTypes, Vector&lt;TextCheckingResult&gt;&amp; results, const VisibleSelection&amp; currentSelection)
</ins><span class="cx"> {
</span><span class="cx"> #if USE(UNIFIED_TEXT_CHECKING)
</span><del>-    results = client.checkTextOfParagraph(text, checkingTypes);
</del><ins>+    results = client.checkTextOfParagraph(text, checkingTypes, currentSelection);
</ins><span class="cx"> #else
</span><ins>+    UNUSED_PARAM(currentSelection);
+
</ins><span class="cx">     Vector&lt;TextCheckingResult&gt; mispellings;
</span><span class="cx">     if (checkingTypes &amp; TextCheckingTypeSpelling)
</span><span class="cx">         findMisspellings(client, text, mispellings);
</span></span></pre></div>
<a id="trunkSourceWebCoreeditingTextCheckingHelperh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/editing/TextCheckingHelper.h (198305 => 198306)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/editing/TextCheckingHelper.h        2016-03-16 22:10:02 UTC (rev 198305)
+++ trunk/Source/WebCore/editing/TextCheckingHelper.h        2016-03-16 23:25:09 UTC (rev 198306)
</span><span class="lines">@@ -103,7 +103,7 @@
</span><span class="cx"> #endif
</span><span class="cx"> };
</span><span class="cx"> 
</span><del>-void checkTextOfParagraph(TextCheckerClient&amp;, StringView, TextCheckingTypeMask, Vector&lt;TextCheckingResult&gt;&amp;);
</del><ins>+void checkTextOfParagraph(TextCheckerClient&amp;, StringView, TextCheckingTypeMask, Vector&lt;TextCheckingResult&gt;&amp;, const VisibleSelection&amp; currentSelection);
</ins><span class="cx"> 
</span><span class="cx"> bool unifiedTextCheckerEnabled(const Frame*);
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceWebCoreloaderEmptyClientscpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/loader/EmptyClients.cpp (198305 => 198306)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/loader/EmptyClients.cpp        2016-03-16 22:10:02 UTC (rev 198305)
+++ trunk/Source/WebCore/loader/EmptyClients.cpp        2016-03-16 23:25:09 UTC (rev 198306)
</span><span class="lines">@@ -237,7 +237,7 @@
</span><span class="cx">     return PassRefPtr&lt;FrameNetworkingContext&gt;();
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-void EmptyTextCheckerClient::requestCheckingOfString(PassRefPtr&lt;TextCheckingRequest&gt;)
</del><ins>+void EmptyTextCheckerClient::requestCheckingOfString(PassRefPtr&lt;TextCheckingRequest&gt;, const VisibleSelection&amp;)
</ins><span class="cx"> {
</span><span class="cx"> }
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceWebCoreloaderEmptyClientsh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/loader/EmptyClients.h (198305 => 198306)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/loader/EmptyClients.h        2016-03-16 22:10:02 UTC (rev 198305)
+++ trunk/Source/WebCore/loader/EmptyClients.h        2016-03-16 23:25:09 UTC (rev 198306)
</span><span class="lines">@@ -425,11 +425,11 @@
</span><span class="cx">     void checkGrammarOfString(StringView, Vector&lt;GrammarDetail&gt;&amp;, int*, int*) override { }
</span><span class="cx"> 
</span><span class="cx"> #if USE(UNIFIED_TEXT_CHECKING)
</span><del>-    Vector&lt;TextCheckingResult&gt; checkTextOfParagraph(StringView, TextCheckingTypeMask) override { return Vector&lt;TextCheckingResult&gt;(); }
</del><ins>+    Vector&lt;TextCheckingResult&gt; checkTextOfParagraph(StringView, TextCheckingTypeMask, const VisibleSelection&amp;) override { return Vector&lt;TextCheckingResult&gt;(); }
</ins><span class="cx"> #endif
</span><span class="cx"> 
</span><del>-    void getGuessesForWord(const String&amp;, const String&amp;, Vector&lt;String&gt;&amp;) override { }
-    void requestCheckingOfString(PassRefPtr&lt;TextCheckingRequest&gt;) override;
</del><ins>+    void getGuessesForWord(const String&amp;, const String&amp;, const VisibleSelection&amp;, Vector&lt;String&gt;&amp;) override { }
+    void requestCheckingOfString(PassRefPtr&lt;TextCheckingRequest&gt;, const VisibleSelection&amp;) override;
</ins><span class="cx"> };
</span><span class="cx"> 
</span><span class="cx"> class EmptyEditorClient : public EditorClient {
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformspimacNSSpellCheckerSPIh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/spi/mac/NSSpellCheckerSPI.h (198305 => 198306)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/spi/mac/NSSpellCheckerSPI.h        2016-03-16 22:10:02 UTC (rev 198305)
+++ trunk/Source/WebCore/platform/spi/mac/NSSpellCheckerSPI.h        2016-03-16 23:25:09 UTC (rev 198306)
</span><span class="lines">@@ -29,6 +29,8 @@
</span><span class="cx"> 
</span><span class="cx"> // FIXME: This header should include system headers when possible.
</span><span class="cx"> 
</span><ins>+extern NSString *NSTextCheckingInsertionPointKey;
+
</ins><span class="cx"> @interface NSSpellChecker ()
</span><span class="cx"> - (NSInteger)requestCandidatesForSelectedRange:(NSRange)selectedRange inString:(NSString *)stringToCheck types:(NSTextCheckingTypes)checkingTypes options:(NSDictionary&lt;NSString *, id&gt; *)options inSpellDocumentWithTag:(NSInteger)tag completionHandler:(void (^)(NSInteger sequenceNumber, NSArray&lt;NSTextCheckingResult *&gt; *candidates))completionHandler;
</span><span class="cx"> - (BOOL)deletesAutospaceBeforeString:(NSString *)string language:(NSString *)language;
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformtextTextCheckerClienth"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/text/TextCheckerClient.h (198305 => 198306)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/text/TextCheckerClient.h        2016-03-16 22:10:02 UTC (rev 198305)
+++ trunk/Source/WebCore/platform/text/TextCheckerClient.h        2016-03-16 23:25:09 UTC (rev 198306)
</span><span class="lines">@@ -37,6 +37,8 @@
</span><span class="cx"> 
</span><span class="cx"> namespace WebCore {
</span><span class="cx"> 
</span><ins>+class VisibleSelection;
+
</ins><span class="cx"> class TextCheckerClient {
</span><span class="cx"> public:
</span><span class="cx">     virtual ~TextCheckerClient() {}
</span><span class="lines">@@ -49,14 +51,14 @@
</span><span class="cx">     virtual void checkGrammarOfString(StringView, Vector&lt;GrammarDetail&gt;&amp;, int* badGrammarLocation, int* badGrammarLength) = 0;
</span><span class="cx"> 
</span><span class="cx"> #if USE(UNIFIED_TEXT_CHECKING)
</span><del>-    virtual Vector&lt;TextCheckingResult&gt; checkTextOfParagraph(StringView, TextCheckingTypeMask checkingTypes) = 0;
</del><ins>+    virtual Vector&lt;TextCheckingResult&gt; checkTextOfParagraph(StringView, TextCheckingTypeMask checkingTypes, const VisibleSelection&amp; currentSelection) = 0;
</ins><span class="cx"> #endif
</span><span class="cx"> 
</span><span class="cx">     // For spellcheckers that support multiple languages, it's often important to be able to identify the language in order to
</span><span class="cx">     // provide more accurate correction suggestions. Caller can pass in more text in &quot;context&quot; to aid such spellcheckers on language
</span><span class="cx">     // identification. Noramlly it's the text surrounding the &quot;word&quot; for which we are getting correction suggestions.
</span><del>-    virtual void getGuessesForWord(const String&amp; word, const String&amp; context, Vector&lt;String&gt;&amp; guesses) = 0;
-    virtual void requestCheckingOfString(PassRefPtr&lt;TextCheckingRequest&gt;) = 0;
</del><ins>+    virtual void getGuessesForWord(const String&amp; word, const String&amp; context, const VisibleSelection&amp; currentSelection, Vector&lt;String&gt;&amp; guesses) = 0;
+    virtual void requestCheckingOfString(PassRefPtr&lt;TextCheckingRequest&gt;, const VisibleSelection&amp; currentSelection) = 0;
</ins><span class="cx"> };
</span><span class="cx"> 
</span><span class="cx"> }
</span></span></pre></div>
<a id="trunkSourceWebKitmacChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit/mac/ChangeLog (198305 => 198306)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit/mac/ChangeLog        2016-03-16 22:10:02 UTC (rev 198305)
+++ trunk/Source/WebKit/mac/ChangeLog        2016-03-16 23:25:09 UTC (rev 198306)
</span><span class="lines">@@ -1,3 +1,22 @@
</span><ins>+2016-03-16  Beth Dakin  &lt;bdakin@apple.com&gt;
+
+        Provide NSSpellChecker spellChecking methods with the current insertion point
+        https://bugs.webkit.org/show_bug.cgi?id=155532
+        -and corresponding-
+        rdar://problem/24066952
+
+        Reviewed by Simon Fraser.
+
+        Extract the insertion point from the VisibleSelection that WebCore has 
+        passed. 
+        * WebCoreSupport/WebEditorClient.h:
+        (WebEditorClient::getGuessesForWord):
+        * WebCoreSupport/WebEditorClient.mm:
+        (WebEditorClient::checkTextOfParagraph):
+        (insertionPointFromCurrentSelection):
+        (WebEditorClient::getGuessesForWord):
+        (WebEditorClient::requestCheckingOfString):
+
</ins><span class="cx"> 2016-03-16  Chris Dumez  &lt;cdumez@apple.com&gt;
</span><span class="cx"> 
</span><span class="cx">         Unreviewed, rolling out r198235, r198240, r198241, and
</span></span></pre></div>
<a id="trunkSourceWebKitmacWebCoreSupportWebEditorClienth"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit/mac/WebCoreSupport/WebEditorClient.h (198305 => 198306)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit/mac/WebCoreSupport/WebEditorClient.h        2016-03-16 22:10:02 UTC (rev 198305)
+++ trunk/Source/WebKit/mac/WebCoreSupport/WebEditorClient.h        2016-03-16 23:25:09 UTC (rev 198306)
</span><span class="lines">@@ -158,16 +158,16 @@
</span><span class="cx">     void checkSpellingOfString(StringView, int* misspellingLocation, int* misspellingLength) override;
</span><span class="cx">     String getAutoCorrectSuggestionForMisspelledWord(const String&amp;) override;
</span><span class="cx">     void checkGrammarOfString(StringView, Vector&lt;WebCore::GrammarDetail&gt;&amp;, int* badGrammarLocation, int* badGrammarLength) override;
</span><del>-    Vector&lt;WebCore::TextCheckingResult&gt; checkTextOfParagraph(StringView, WebCore::TextCheckingTypeMask checkingTypes) override;
</del><ins>+    Vector&lt;WebCore::TextCheckingResult&gt; checkTextOfParagraph(StringView, WebCore::TextCheckingTypeMask checkingTypes, const WebCore::VisibleSelection&amp; currentSelection) override;
</ins><span class="cx">     void updateSpellingUIWithGrammarString(const String&amp;, const WebCore::GrammarDetail&amp;) override;
</span><span class="cx">     void updateSpellingUIWithMisspelledWord(const String&amp;) override;
</span><span class="cx">     void showSpellingUI(bool show) override;
</span><span class="cx">     bool spellingUIIsShowing() override;
</span><del>-    void getGuessesForWord(const String&amp; word, const String&amp; context, Vector&lt;String&gt;&amp; guesses) override;
</del><ins>+    void getGuessesForWord(const String&amp; word, const String&amp; context, const WebCore::VisibleSelection&amp; currentSelection, Vector&lt;String&gt;&amp; guesses) override;
</ins><span class="cx"> 
</span><span class="cx">     void willSetInputMethodState() override;
</span><span class="cx">     void setInputMethodState(bool enabled) override;
</span><del>-    void requestCheckingOfString(PassRefPtr&lt;WebCore::TextCheckingRequest&gt;) override;
</del><ins>+    void requestCheckingOfString(PassRefPtr&lt;WebCore::TextCheckingRequest&gt;, const WebCore::VisibleSelection&amp; currentSelection) override;
</ins><span class="cx"> 
</span><span class="cx"> #if PLATFORM(MAC) &amp;&amp; __MAC_OS_X_VERSION_MIN_REQUIRED &gt;= 101200
</span><span class="cx">     void requestCandidatesForSelection(const WebCore::VisibleSelection&amp;);
</span><span class="lines">@@ -280,7 +280,7 @@
</span><span class="cx">     return false;
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-inline void WebEditorClient::getGuessesForWord(const String&amp;, const String&amp;, Vector&lt;String&gt;&amp;)
</del><ins>+inline void WebEditorClient::getGuessesForWord(const String&amp;, const String&amp;, const WebCore::VisibleSelection&amp;, Vector&lt;String&gt;&amp;)
</ins><span class="cx"> {
</span><span class="cx"> }
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceWebKitmacWebCoreSupportWebEditorClientmm"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit/mac/WebCoreSupport/WebEditorClient.mm (198305 => 198306)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit/mac/WebCoreSupport/WebEditorClient.mm        2016-03-16 22:10:02 UTC (rev 198305)
+++ trunk/Source/WebKit/mac/WebCoreSupport/WebEditorClient.mm        2016-03-16 23:25:09 UTC (rev 198306)
</span><span class="lines">@@ -881,7 +881,7 @@
</span><span class="cx">     return 0;
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-Vector&lt;TextCheckingResult&gt; WebEditorClient::checkTextOfParagraph(StringView string, TextCheckingTypeMask checkingTypes)
</del><ins>+Vector&lt;TextCheckingResult&gt; WebEditorClient::checkTextOfParagraph(StringView string, TextCheckingTypeMask checkingTypes, const VisibleSelection&amp;)
</ins><span class="cx"> {
</span><span class="cx">     ASSERT(checkingTypes &amp; NSTextCheckingTypeSpelling);
</span><span class="cx"> 
</span><span class="lines">@@ -1050,11 +1050,24 @@
</span><span class="cx">     return results;
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-Vector&lt;TextCheckingResult&gt; WebEditorClient::checkTextOfParagraph(StringView string, TextCheckingTypeMask checkingTypes)
</del><ins>+#if PLATFORM(MAC) &amp;&amp; __MAC_OS_X_VERSION_MIN_REQUIRED &gt;= 101200
+static int insertionPointFromCurrentSelection(const VisibleSelection&amp; currentSelection)
</ins><span class="cx"> {
</span><del>-    return core([[NSSpellChecker sharedSpellChecker] checkString:string.createNSStringWithoutCopying().get() range:NSMakeRange(0, string.length()) types:(checkingTypes | NSTextCheckingTypeOrthography) options:nil inSpellDocumentWithTag:spellCheckerDocumentTag() orthography:NULL wordCount:NULL], checkingTypes);
</del><ins>+    VisiblePosition selectionStart = currentSelection.visibleStart();
+    VisiblePosition paragraphStart = startOfParagraph(selectionStart);
+    return TextIterator::rangeLength(makeRange(paragraphStart, selectionStart).get());
</ins><span class="cx"> }
</span><ins>+#endif
</ins><span class="cx"> 
</span><ins>+Vector&lt;TextCheckingResult&gt; WebEditorClient::checkTextOfParagraph(StringView string, TextCheckingTypeMask checkingTypes, const VisibleSelection&amp; currentSelection)
+{
+    NSDictionary *options = nil;
+#if PLATFORM(MAC) &amp;&amp; __MAC_OS_X_VERSION_MIN_REQUIRED &gt;= 101200
+    options = @{ NSTextCheckingInsertionPointKey :  [NSNumber numberWithUnsignedInteger:insertionPointFromCurrentSelection(currentSelection)] };
+#endif
+    return core([[NSSpellChecker sharedSpellChecker] checkString:string.createNSStringWithoutCopying().get() range:NSMakeRange(0, string.length()) types:(checkingTypes | NSTextCheckingTypeOrthography) options:options inSpellDocumentWithTag:spellCheckerDocumentTag() orthography:NULL wordCount:NULL], checkingTypes);
+}
+
</ins><span class="cx"> void WebEditorClient::updateSpellingUIWithGrammarString(const String&amp; badGrammarPhrase, const GrammarDetail&amp; grammarDetail)
</span><span class="cx"> {
</span><span class="cx">     NSMutableArray* corrections = [NSMutableArray array];
</span><span class="lines">@@ -1088,13 +1101,18 @@
</span><span class="cx">     return [[[NSSpellChecker sharedSpellChecker] spellingPanel] isVisible];
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-void WebEditorClient::getGuessesForWord(const String&amp; word, const String&amp; context, Vector&lt;String&gt;&amp; guesses) {
</del><ins>+void WebEditorClient::getGuessesForWord(const String&amp; word, const String&amp; context, const WebCore::VisibleSelection&amp; currentSelection, Vector&lt;String&gt;&amp; guesses)
+{
</ins><span class="cx">     guesses.clear();
</span><span class="cx">     NSString* language = nil;
</span><span class="cx">     NSOrthography* orthography = nil;
</span><span class="cx">     NSSpellChecker *checker = [NSSpellChecker sharedSpellChecker];
</span><ins>+    NSDictionary *options = nil;
+#if PLATFORM(MAC) &amp;&amp; __MAC_OS_X_VERSION_MIN_REQUIRED &gt;= 101200
+    options = @{ NSTextCheckingInsertionPointKey :  [NSNumber numberWithUnsignedInteger:insertionPointFromCurrentSelection(currentSelection)] };
+#endif
</ins><span class="cx">     if (context.length()) {
</span><del>-        [checker checkString:context range:NSMakeRange(0, context.length()) types:NSTextCheckingTypeOrthography options:0 inSpellDocumentWithTag:spellCheckerDocumentTag() orthography:&amp;orthography wordCount:0];
</del><ins>+        [checker checkString:context range:NSMakeRange(0, context.length()) types:NSTextCheckingTypeOrthography options:options inSpellDocumentWithTag:spellCheckerDocumentTag() orthography:&amp;orthography wordCount:0];
</ins><span class="cx">         language = [checker languageForWordRange:NSMakeRange(0, context.length()) inString:context orthography:orthography];
</span><span class="cx">     }
</span><span class="cx">     NSArray* stringsArray = [checker guessesForWordRange:NSMakeRange(0, word.length()) inString:word language:language inSpellDocumentWithTag:spellCheckerDocumentTag()];
</span><span class="lines">@@ -1268,7 +1286,7 @@
</span><span class="cx"> }
</span><span class="cx"> #endif
</span><span class="cx"> 
</span><del>-void WebEditorClient::requestCheckingOfString(PassRefPtr&lt;WebCore::TextCheckingRequest&gt; request)
</del><ins>+void WebEditorClient::requestCheckingOfString(PassRefPtr&lt;WebCore::TextCheckingRequest&gt; request, const VisibleSelection&amp; currentSelection)
</ins><span class="cx"> {
</span><span class="cx"> #if !PLATFORM(IOS)
</span><span class="cx">     ASSERT(!m_textCheckingRequest);
</span><span class="lines">@@ -1277,8 +1295,11 @@
</span><span class="cx">     int sequence = m_textCheckingRequest-&gt;data().sequence();
</span><span class="cx">     NSRange range = NSMakeRange(0, m_textCheckingRequest-&gt;data().text().length());
</span><span class="cx">     NSRunLoop* currentLoop = [NSRunLoop currentRunLoop];
</span><del>-    [[NSSpellChecker sharedSpellChecker] requestCheckingOfString:m_textCheckingRequest-&gt;data().text() range:range types:NSTextCheckingAllSystemTypes options:0 inSpellDocumentWithTag:0
-                                         completionHandler:^(NSInteger, NSArray* results, NSOrthography*, NSInteger) {
</del><ins>+    NSDictionary *options = nil;
+#if PLATFORM(MAC) &amp;&amp; __MAC_OS_X_VERSION_MIN_REQUIRED &gt;= 101200
+    options = @{ NSTextCheckingInsertionPointKey :  [NSNumber numberWithUnsignedInteger:insertionPointFromCurrentSelection(currentSelection)] };
+#endif
+    [[NSSpellChecker sharedSpellChecker] requestCheckingOfString:m_textCheckingRequest-&gt;data().text() range:range types:NSTextCheckingAllSystemTypes options:options inSpellDocumentWithTag:0 completionHandler:^(NSInteger, NSArray* results, NSOrthography*, NSInteger) {
</ins><span class="cx">             [currentLoop performSelector:@selector(perform) 
</span><span class="cx">                                   target:[[[WebEditorSpellCheckResponder alloc] initWithClient:this sequence:sequence results:results] autorelease]
</span><span class="cx">                                 argument:nil order:0 modes:[NSArray arrayWithObject:NSDefaultRunLoopMode]];
</span></span></pre></div>
<a id="trunkSourceWebKitwinWebCoreSupportWebEditorClientcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit/win/WebCoreSupport/WebEditorClient.cpp (198305 => 198306)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit/win/WebCoreSupport/WebEditorClient.cpp        2016-03-16 22:10:02 UTC (rev 198305)
+++ trunk/Source/WebKit/win/WebCoreSupport/WebEditorClient.cpp        2016-03-16 23:25:09 UTC (rev 198306)
</span><span class="lines">@@ -846,7 +846,7 @@
</span><span class="cx">     return !!showing;
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-void WebEditorClient::getGuessesForWord(const String&amp; word, const String&amp; context, Vector&lt;String&gt;&amp; guesses)
</del><ins>+void WebEditorClient::getGuessesForWord(const String&amp; word, const String&amp; context, const VisibleSelection&amp;, Vector&lt;String&gt;&amp; guesses)
</ins><span class="cx"> {
</span><span class="cx">     guesses.clear();
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceWebKitwinWebCoreSupportWebEditorClienth"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit/win/WebCoreSupport/WebEditorClient.h (198305 => 198306)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit/win/WebCoreSupport/WebEditorClient.h        2016-03-16 22:10:02 UTC (rev 198305)
+++ trunk/Source/WebKit/win/WebCoreSupport/WebEditorClient.h        2016-03-16 23:25:09 UTC (rev 198306)
</span><span class="lines">@@ -110,11 +110,11 @@
</span><span class="cx">     void updateSpellingUIWithMisspelledWord(const WTF::String&amp;) override;
</span><span class="cx">     void showSpellingUI(bool show) override;
</span><span class="cx">     bool spellingUIIsShowing() override;
</span><del>-    void getGuessesForWord(const WTF::String&amp; word, const WTF::String&amp; context, WTF::Vector&lt;WTF::String&gt;&amp; guesses) override;
</del><ins>+    void getGuessesForWord(const WTF::String&amp; word, const WTF::String&amp; context, const WebCore::VisibleSelection&amp; currentSelection, WTF::Vector&lt;WTF::String&gt;&amp; guesses) override;
</ins><span class="cx"> 
</span><span class="cx">     void willSetInputMethodState() override;
</span><span class="cx">     void setInputMethodState(bool) override;
</span><del>-    void requestCheckingOfString(WTF::PassRefPtr&lt;WebCore::TextCheckingRequest&gt;) override { }
</del><ins>+    void requestCheckingOfString(WTF::PassRefPtr&lt;WebCore::TextCheckingRequest&gt;, const WebCore::VisibleSelection&amp;) override { }
</ins><span class="cx"> 
</span><span class="cx">     WebCore::TextCheckerClient* textChecker() override { return this; }
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceWebKit2ChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/ChangeLog (198305 => 198306)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/ChangeLog        2016-03-16 22:10:02 UTC (rev 198305)
+++ trunk/Source/WebKit2/ChangeLog        2016-03-16 23:25:09 UTC (rev 198306)
</span><span class="lines">@@ -1,3 +1,47 @@
</span><ins>+2016-03-16  Beth Dakin  &lt;bdakin@apple.com&gt;
+
+        Provide NSSpellChecker spellChecking methods with the current insertion point
+        https://bugs.webkit.org/show_bug.cgi?id=155532
+        -and corresponding-
+        rdar://problem/24066952
+
+        Reviewed by Simon Fraser.
+
+        Pass the insertionPoint to the UIProcess
+        * UIProcess/TextChecker.h:
+        * UIProcess/WebPageProxy.cpp:
+        (WebKit::WebPageProxy::checkTextOfParagraph):
+        (WebKit::WebPageProxy::getGuessesForWord):
+        (WebKit::WebPageProxy::requestCheckingOfString):
+        * UIProcess/WebPageProxy.h:
+        * UIProcess/WebPageProxy.messages.in:
+        * UIProcess/efl/TextCheckerEfl.cpp:
+        (WebKit::TextChecker::checkTextOfParagraph):
+        (WebKit::TextChecker::getGuessesForWord):
+        (WebKit::TextChecker::requestCheckingOfString):
+        * UIProcess/gtk/TextCheckerGtk.cpp:
+        (WebKit::TextChecker::getGuessesForWord):
+        (WebKit::TextChecker::requestCheckingOfString):
+        (WebKit::TextChecker::checkTextOfParagraph):
+        * UIProcess/ios/TextCheckerIOS.mm:
+        (WebKit::TextChecker::checkTextOfParagraph):
+        (WebKit::TextChecker::getGuessesForWord):
+        (WebKit::TextChecker::requestCheckingOfString):
+        * UIProcess/mac/TextCheckerMac.mm:
+        (WebKit::TextChecker::checkTextOfParagraph):
+        (WebKit::TextChecker::getGuessesForWord):
+        (WebKit::TextChecker::ignoreWord):
+        (WebKit::TextChecker::requestCheckingOfString):
+
+        Extract the insertion point from the VisibleSelection that WebCore has 
+        passed. 
+        * WebProcess/WebCoreSupport/WebEditorClient.cpp:
+        (WebKit::insertionPointFromCurrentSelection):
+        (WebKit::WebEditorClient::checkTextOfParagraph):
+        (WebKit::WebEditorClient::getGuessesForWord):
+        (WebKit::WebEditorClient::requestCheckingOfString):
+        * WebProcess/WebCoreSupport/WebEditorClient.h:
+
</ins><span class="cx"> 2016-03-16  Tim Horton  &lt;timothy_horton@apple.com&gt;
</span><span class="cx"> 
</span><span class="cx">         REGRESSION (r192184): CleanMyDrive 2's tutorial window is blank
</span></span></pre></div>
<a id="trunkSourceWebKit2UIProcessTextCheckerh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/UIProcess/TextChecker.h (198305 => 198306)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/UIProcess/TextChecker.h        2016-03-16 22:10:02 UTC (rev 198305)
+++ trunk/Source/WebKit2/UIProcess/TextChecker.h        2016-03-16 23:25:09 UTC (rev 198306)
</span><span class="lines">@@ -72,7 +72,7 @@
</span><span class="cx">     static int64_t uniqueSpellDocumentTag(WebPageProxy*);
</span><span class="cx">     static void closeSpellDocumentWithTag(int64_t);
</span><span class="cx"> #if USE(UNIFIED_TEXT_CHECKING)
</span><del>-    static Vector&lt;WebCore::TextCheckingResult&gt; checkTextOfParagraph(int64_t spellDocumentTag, StringView text, uint64_t checkingTypes);
</del><ins>+    static Vector&lt;WebCore::TextCheckingResult&gt; checkTextOfParagraph(int64_t spellDocumentTag, StringView text, int32_t insertionPoint, uint64_t checkingTypes);
</ins><span class="cx"> #endif
</span><span class="cx">     static void checkSpellingOfString(int64_t spellDocumentTag, StringView text, int32_t&amp; misspellingLocation, int32_t&amp; misspellingLength);
</span><span class="cx">     static void checkGrammarOfString(int64_t spellDocumentTag, StringView text, Vector&lt;WebCore::GrammarDetail&gt;&amp;, int32_t&amp; badGrammarLocation, int32_t&amp; badGrammarLength);
</span><span class="lines">@@ -80,10 +80,10 @@
</span><span class="cx">     static void toggleSpellingUIIsShowing();
</span><span class="cx">     static void updateSpellingUIWithMisspelledWord(int64_t spellDocumentTag, const String&amp; misspelledWord);
</span><span class="cx">     static void updateSpellingUIWithGrammarString(int64_t spellDocumentTag, const String&amp; badGrammarPhrase, const WebCore::GrammarDetail&amp;);
</span><del>-    static void getGuessesForWord(int64_t spellDocumentTag, const String&amp; word, const String&amp; context, Vector&lt;String&gt;&amp; guesses);
</del><ins>+    static void getGuessesForWord(int64_t spellDocumentTag, const String&amp; word, const String&amp; context, int32_t insertionPoint, Vector&lt;String&gt;&amp; guesses);
</ins><span class="cx">     static void learnWord(int64_t spellDocumentTag, const String&amp; word);
</span><span class="cx">     static void ignoreWord(int64_t spellDocumentTag, const String&amp; word);
</span><del>-    static void requestCheckingOfString(PassRefPtr&lt;TextCheckerCompletion&gt;);
</del><ins>+    static void requestCheckingOfString(PassRefPtr&lt;TextCheckerCompletion&gt;, int32_t insertionPoint);
</ins><span class="cx"> };
</span><span class="cx"> 
</span><span class="cx"> } // namespace WebKit
</span></span></pre></div>
<a id="trunkSourceWebKit2UIProcessWebPageProxycpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/UIProcess/WebPageProxy.cpp (198305 => 198306)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/UIProcess/WebPageProxy.cpp        2016-03-16 22:10:02 UTC (rev 198305)
+++ trunk/Source/WebKit2/UIProcess/WebPageProxy.cpp        2016-03-16 23:25:09 UTC (rev 198306)
</span><span class="lines">@@ -4441,9 +4441,9 @@
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> #if USE(UNIFIED_TEXT_CHECKING)
</span><del>-void WebPageProxy::checkTextOfParagraph(const String&amp; text, uint64_t checkingTypes, Vector&lt;TextCheckingResult&gt;&amp; results)
</del><ins>+void WebPageProxy::checkTextOfParagraph(const String&amp; text, uint64_t checkingTypes, int32_t insertionPoint, Vector&lt;TextCheckingResult&gt;&amp; results)
</ins><span class="cx"> {
</span><del>-    results = TextChecker::checkTextOfParagraph(spellDocumentTag(), text, checkingTypes);
</del><ins>+    results = TextChecker::checkTextOfParagraph(spellDocumentTag(), text, insertionPoint, checkingTypes);
</ins><span class="cx"> }
</span><span class="cx"> #endif
</span><span class="cx"> 
</span><span class="lines">@@ -4472,9 +4472,9 @@
</span><span class="cx">     TextChecker::updateSpellingUIWithGrammarString(spellDocumentTag(), badGrammarPhrase, grammarDetail);
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-void WebPageProxy::getGuessesForWord(const String&amp; word, const String&amp; context, Vector&lt;String&gt;&amp; guesses)
</del><ins>+void WebPageProxy::getGuessesForWord(const String&amp; word, const String&amp; context, int32_t insertionPoint, Vector&lt;String&gt;&amp; guesses)
</ins><span class="cx"> {
</span><del>-    TextChecker::getGuessesForWord(spellDocumentTag(), word, context, guesses);
</del><ins>+    TextChecker::getGuessesForWord(spellDocumentTag(), word, context, insertionPoint, guesses);
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void WebPageProxy::learnWord(const String&amp; word)
</span><span class="lines">@@ -4493,9 +4493,9 @@
</span><span class="cx">     TextChecker::ignoreWord(spellDocumentTag(), word);
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-void WebPageProxy::requestCheckingOfString(uint64_t requestID, const TextCheckingRequestData&amp; request)
</del><ins>+void WebPageProxy::requestCheckingOfString(uint64_t requestID, const TextCheckingRequestData&amp; request, int32_t insertionPoint)
</ins><span class="cx"> {
</span><del>-    TextChecker::requestCheckingOfString(TextCheckerCompletion::create(requestID, request, this));
</del><ins>+    TextChecker::requestCheckingOfString(TextCheckerCompletion::create(requestID, request, this), insertionPoint);
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void WebPageProxy::didFinishCheckingText(uint64_t requestID, const Vector&lt;WebCore::TextCheckingResult&gt;&amp; result)
</span></span></pre></div>
<a id="trunkSourceWebKit2UIProcessWebPageProxyh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/UIProcess/WebPageProxy.h (198305 => 198306)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/UIProcess/WebPageProxy.h        2016-03-16 22:10:02 UTC (rev 198305)
+++ trunk/Source/WebKit2/UIProcess/WebPageProxy.h        2016-03-16 23:25:09 UTC (rev 198306)
</span><span class="lines">@@ -1055,9 +1055,9 @@
</span><span class="cx"> #endif
</span><span class="cx"> 
</span><span class="cx"> #if USE(UNIFIED_TEXT_CHECKING)
</span><del>-    void checkTextOfParagraph(const String&amp; text, uint64_t checkingTypes, Vector&lt;WebCore::TextCheckingResult&gt;&amp; results);
</del><ins>+    void checkTextOfParagraph(const String&amp; text, uint64_t checkingTypes, int32_t insertionPoint, Vector&lt;WebCore::TextCheckingResult&gt;&amp; results);
</ins><span class="cx"> #endif
</span><del>-    void getGuessesForWord(const String&amp; word, const String&amp; context, Vector&lt;String&gt;&amp; guesses);
</del><ins>+    void getGuessesForWord(const String&amp; word, const String&amp; context, int32_t insertionPoint, Vector&lt;String&gt;&amp; guesses);
</ins><span class="cx"> 
</span><span class="cx">     void setShouldDispatchFakeMouseMoveEvents(bool);
</span><span class="cx"> 
</span><span class="lines">@@ -1330,7 +1330,7 @@
</span><span class="cx">     void updateSpellingUIWithGrammarString(const String&amp; badGrammarPhrase, const WebCore::GrammarDetail&amp;);
</span><span class="cx">     void learnWord(const String&amp; word);
</span><span class="cx">     void ignoreWord(const String&amp; word);
</span><del>-    void requestCheckingOfString(uint64_t requestID, const WebCore::TextCheckingRequestData&amp;);
</del><ins>+    void requestCheckingOfString(uint64_t requestID, const WebCore::TextCheckingRequestData&amp;, int32_t insertionPoint);
</ins><span class="cx"> 
</span><span class="cx">     void takeFocus(uint32_t direction);
</span><span class="cx">     void setToolTip(const String&amp;);
</span></span></pre></div>
<a id="trunkSourceWebKit2UIProcessWebPageProxymessagesin"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/UIProcess/WebPageProxy.messages.in (198305 => 198306)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/UIProcess/WebPageProxy.messages.in        2016-03-16 22:10:02 UTC (rev 198305)
+++ trunk/Source/WebKit2/UIProcess/WebPageProxy.messages.in        2016-03-16 23:25:09 UTC (rev 198306)
</span><span class="lines">@@ -277,17 +277,17 @@
</span><span class="cx"> 
</span><span class="cx">     # Spelling and grammar messages
</span><span class="cx"> #if USE(UNIFIED_TEXT_CHECKING)  
</span><del>-    CheckTextOfParagraph(String text, uint64_t checkingTypes) -&gt; (Vector&lt;WebCore::TextCheckingResult&gt; results)
</del><ins>+    CheckTextOfParagraph(String text, uint64_t checkingTypes, int32_t insertionPoint) -&gt; (Vector&lt;WebCore::TextCheckingResult&gt; results)
</ins><span class="cx"> #endif
</span><span class="cx">     CheckSpellingOfString(String text) -&gt; (int32_t misspellingLocation, int32_t misspellingLength)
</span><span class="cx">     CheckGrammarOfString(String text) -&gt; (Vector&lt;WebCore::GrammarDetail&gt; results, int32_t badGrammarLocation, int32_t badGrammarLength)
</span><span class="cx">     SpellingUIIsShowing() -&gt; (bool isShowing)
</span><span class="cx">     UpdateSpellingUIWithMisspelledWord(String misspelledWord)
</span><span class="cx">     UpdateSpellingUIWithGrammarString(String badGrammarPhrase, struct WebCore::GrammarDetail grammarDetail)
</span><del>-    GetGuessesForWord(String word, String context) -&gt; (Vector&lt;String&gt; guesses)
</del><ins>+    GetGuessesForWord(String word, String context, int32_t insertionPoint) -&gt; (Vector&lt;String&gt; guesses)
</ins><span class="cx">     LearnWord(String word);
</span><span class="cx">     IgnoreWord(String word);
</span><del>-    RequestCheckingOfString(uint64_t requestID, WebCore::TextCheckingRequestData request)
</del><ins>+    RequestCheckingOfString(uint64_t requestID, WebCore::TextCheckingRequestData request, int32_t insertionPoint)
</ins><span class="cx"> 
</span><span class="cx">     # Drag and drop messages
</span><span class="cx"> #if ENABLE(DRAG_SUPPORT)
</span></span></pre></div>
<a id="trunkSourceWebKit2UIProcesseflTextCheckerEflcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/UIProcess/efl/TextCheckerEfl.cpp (198305 => 198306)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/UIProcess/efl/TextCheckerEfl.cpp        2016-03-16 22:10:02 UTC (rev 198305)
+++ trunk/Source/WebKit2/UIProcess/efl/TextCheckerEfl.cpp        2016-03-16 23:25:09 UTC (rev 198306)
</span><span class="lines">@@ -148,8 +148,10 @@
</span><span class="cx"> #endif // ENABLE(SPELLCHECK)
</span><span class="cx"> 
</span><span class="cx"> #if USE(UNIFIED_TEXT_CHECKING)
</span><del>-Vector&lt;TextCheckingResult&gt; TextChecker::checkTextOfParagraph(int64_t spellDocumentTag, StringView text, uint64_t checkingTypes)
</del><ins>+Vector&lt;TextCheckingResult&gt; TextChecker::checkTextOfParagraph(int64_t spellDocumentTag, StringView text, int32_t insertionPoint, uint64_t checkingTypes)
</ins><span class="cx"> {
</span><ins>+    UNUSED_PARAM(insertionPoint);
+
</ins><span class="cx">     Vector&lt;TextCheckingResult&gt; paragraphCheckingResult;
</span><span class="cx"> #if ENABLE(SPELLCHECK)
</span><span class="cx">     if (checkingTypes &amp; TextCheckingTypeSpelling) {
</span><span class="lines">@@ -230,8 +232,9 @@
</span><span class="cx">     notImplemented();
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-void TextChecker::getGuessesForWord(int64_t spellDocumentTag, const String&amp; word, const String&amp; , Vector&lt;String&gt;&amp; guesses)
</del><ins>+void TextChecker::getGuessesForWord(int64_t spellDocumentTag, const String&amp; word, const String&amp; , int32_t insertionPoint, Vector&lt;String&gt;&amp; guesses)
</ins><span class="cx"> {
</span><ins>+    UNUSED_PARAM(insertionPoint);
</ins><span class="cx"> #if ENABLE(SPELLCHECK)
</span><span class="cx">     WebTextChecker::singleton()-&gt;client().guessesForWord(spellDocumentTag, word, guesses);
</span><span class="cx"> #else
</span><span class="lines">@@ -261,7 +264,7 @@
</span><span class="cx"> #endif
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-void TextChecker::requestCheckingOfString(PassRefPtr&lt;TextCheckerCompletion&gt; completion)
</del><ins>+void TextChecker::requestCheckingOfString(PassRefPtr&lt;TextCheckerCompletion&gt; completion, int32_t insertionPoint)
</ins><span class="cx"> {
</span><span class="cx"> #if ENABLE(SPELLCHECK)
</span><span class="cx">     if (!completion)
</span><span class="lines">@@ -271,9 +274,10 @@
</span><span class="cx">     ASSERT(request.sequence() != unrequestedTextCheckingSequence);
</span><span class="cx">     ASSERT(request.mask() != TextCheckingTypeNone);
</span><span class="cx"> 
</span><del>-    completion-&gt;didFinishCheckingText(checkTextOfParagraph(completion-&gt;spellDocumentTag(), request.text(), request.mask()));
</del><ins>+    completion-&gt;didFinishCheckingText(checkTextOfParagraph(completion-&gt;spellDocumentTag(), request.text(), insertionPoint, request.mask()));
</ins><span class="cx"> #else
</span><span class="cx">     UNUSED_PARAM(completion);
</span><ins>+    UNUSED_PARAM(insertionPoint);
</ins><span class="cx"> #endif
</span><span class="cx"> }
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceWebKit2UIProcessgtkTextCheckerGtkcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/UIProcess/gtk/TextCheckerGtk.cpp (198305 => 198306)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/UIProcess/gtk/TextCheckerGtk.cpp        2016-03-16 22:10:02 UTC (rev 198305)
+++ trunk/Source/WebKit2/UIProcess/gtk/TextCheckerGtk.cpp        2016-03-16 23:25:09 UTC (rev 198306)
</span><span class="lines">@@ -166,7 +166,7 @@
</span><span class="cx"> {
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-void TextChecker::getGuessesForWord(int64_t /* spellDocumentTag */, const String&amp; word, const String&amp; /* context */, Vector&lt;String&gt;&amp; guesses)
</del><ins>+void TextChecker::getGuessesForWord(int64_t /* spellDocumentTag */, const String&amp; word, const String&amp; /* context */, int32_t /* insertionPoint */, Vector&lt;String&gt;&amp; guesses)
</ins><span class="cx"> {
</span><span class="cx"> #if ENABLE(SPELLCHECK)
</span><span class="cx">     guesses = enchantTextChecker().getGuessesForWord(word);
</span><span class="lines">@@ -194,7 +194,7 @@
</span><span class="cx"> #endif
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-void TextChecker::requestCheckingOfString(PassRefPtr&lt;TextCheckerCompletion&gt; completion)
</del><ins>+void TextChecker::requestCheckingOfString(PassRefPtr&lt;TextCheckerCompletion&gt; completion, int32_t insertionPoint)
</ins><span class="cx"> {
</span><span class="cx"> #if ENABLE(SPELLCHECK)
</span><span class="cx">     if (!completion)
</span><span class="lines">@@ -204,7 +204,7 @@
</span><span class="cx">     ASSERT(request.sequence() != unrequestedTextCheckingSequence);
</span><span class="cx">     ASSERT(request.mask() != TextCheckingTypeNone);
</span><span class="cx"> 
</span><del>-    completion-&gt;didFinishCheckingText(checkTextOfParagraph(completion-&gt;spellDocumentTag(), request.text(), request.mask()));
</del><ins>+    completion-&gt;didFinishCheckingText(checkTextOfParagraph(completion-&gt;spellDocumentTag(), request.text(), insertionPoint, request.mask()));
</ins><span class="cx"> #else
</span><span class="cx">     UNUSED_PARAM(completion);
</span><span class="cx"> #endif
</span><span class="lines">@@ -239,8 +239,9 @@
</span><span class="cx"> #endif
</span><span class="cx"> 
</span><span class="cx"> #if USE(UNIFIED_TEXT_CHECKING)
</span><del>-Vector&lt;TextCheckingResult&gt; TextChecker::checkTextOfParagraph(int64_t spellDocumentTag, StringView text, uint64_t checkingTypes)
</del><ins>+Vector&lt;TextCheckingResult&gt; TextChecker::checkTextOfParagraph(int64_t spellDocumentTag, StringView text, int32_t insertionPoint, uint64_t checkingTypes)
</ins><span class="cx"> {
</span><ins>+    UNUSED_PARAM(insertionPoint);
</ins><span class="cx"> #if ENABLE(SPELLCHECK)
</span><span class="cx">     if (!(checkingTypes &amp; TextCheckingTypeSpelling))
</span><span class="cx">         return Vector&lt;TextCheckingResult&gt;();
</span></span></pre></div>
<a id="trunkSourceWebKit2UIProcessiosTextCheckerIOSmm"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/UIProcess/ios/TextCheckerIOS.mm (198305 => 198306)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/UIProcess/ios/TextCheckerIOS.mm        2016-03-16 22:10:02 UTC (rev 198305)
+++ trunk/Source/WebKit2/UIProcess/ios/TextCheckerIOS.mm        2016-03-16 23:25:09 UTC (rev 198306)
</span><span class="lines">@@ -132,7 +132,7 @@
</span><span class="cx"> 
</span><span class="cx"> #if USE(UNIFIED_TEXT_CHECKING)
</span><span class="cx"> 
</span><del>-Vector&lt;TextCheckingResult&gt; TextChecker::checkTextOfParagraph(int64_t, StringView, uint64_t)
</del><ins>+Vector&lt;TextCheckingResult&gt; TextChecker::checkTextOfParagraph(int64_t, StringView, int32_t, uint64_t)
</ins><span class="cx"> {
</span><span class="cx">     notImplemented();
</span><span class="cx">     return Vector&lt;TextCheckingResult&gt;();
</span><span class="lines">@@ -171,7 +171,7 @@
</span><span class="cx">     notImplemented();
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-void TextChecker::getGuessesForWord(int64_t, const String&amp;, const String&amp;, Vector&lt;String&gt;&amp;)
</del><ins>+void TextChecker::getGuessesForWord(int64_t, const String&amp;, const String&amp;, int32_t, Vector&lt;String&gt;&amp;)
</ins><span class="cx"> {
</span><span class="cx">     notImplemented();
</span><span class="cx"> }
</span><span class="lines">@@ -186,7 +186,7 @@
</span><span class="cx">     notImplemented();
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-void TextChecker::requestCheckingOfString(PassRefPtr&lt;TextCheckerCompletion&gt;)
</del><ins>+void TextChecker::requestCheckingOfString(PassRefPtr&lt;TextCheckerCompletion&gt;, int32_t)
</ins><span class="cx"> {
</span><span class="cx">     notImplemented();
</span><span class="cx"> }
</span></span></pre></div>
<a id="trunkSourceWebKit2UIProcessmacTextCheckerMacmm"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/UIProcess/mac/TextCheckerMac.mm (198305 => 198306)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/UIProcess/mac/TextCheckerMac.mm        2016-03-16 22:10:02 UTC (rev 198305)
+++ trunk/Source/WebKit2/UIProcess/mac/TextCheckerMac.mm        2016-03-16 23:25:09 UTC (rev 198306)
</span><span class="lines">@@ -29,6 +29,7 @@
</span><span class="cx"> #if PLATFORM(MAC)
</span><span class="cx"> 
</span><span class="cx"> #import &quot;TextCheckerState.h&quot;
</span><ins>+#import &lt;WebCore/NSSpellCheckerSPI.h&gt;
</ins><span class="cx"> #import &lt;WebCore/NotImplemented.h&gt;
</span><span class="cx"> #import &lt;wtf/RetainPtr.h&gt;
</span><span class="cx"> #import &lt;wtf/text/StringView.h&gt;
</span><span class="lines">@@ -290,15 +291,19 @@
</span><span class="cx"> 
</span><span class="cx"> #if USE(UNIFIED_TEXT_CHECKING)
</span><span class="cx"> 
</span><del>-Vector&lt;TextCheckingResult&gt; TextChecker::checkTextOfParagraph(int64_t spellDocumentTag, StringView text, uint64_t checkingTypes)
</del><ins>+Vector&lt;TextCheckingResult&gt; TextChecker::checkTextOfParagraph(int64_t spellDocumentTag, StringView text, int32_t insertionPoint, uint64_t checkingTypes)
</ins><span class="cx"> {
</span><span class="cx">     Vector&lt;TextCheckingResult&gt; results;
</span><span class="cx"> 
</span><span class="cx">     RetainPtr&lt;NSString&gt; textString = text.createNSStringWithoutCopying();
</span><ins>+    NSDictionary *options = nil;
+#if PLATFORM(MAC) &amp;&amp; __MAC_OS_X_VERSION_MIN_REQUIRED &gt;= 101200
+    options = @{ NSTextCheckingInsertionPointKey :  [NSNumber numberWithUnsignedInteger:insertionPoint] };
+#endif
</ins><span class="cx">     NSArray *incomingResults = [[NSSpellChecker sharedSpellChecker] checkString:textString.get()
</span><span class="cx">                                                                           range:NSMakeRange(0, text.length())
</span><span class="cx">                                                                           types:checkingTypes | NSTextCheckingTypeOrthography
</span><del>-                                                                        options:nil
</del><ins>+                                                                        options:options
</ins><span class="cx">                                                          inSpellDocumentWithTag:spellDocumentTag 
</span><span class="cx">                                                                     orthography:NULL
</span><span class="cx">                                                                       wordCount:NULL];
</span><span class="lines">@@ -425,13 +430,17 @@
</span><span class="cx">     [[NSSpellChecker sharedSpellChecker] updateSpellingPanelWithGrammarString:badGrammarPhrase detail:grammarDetailDict.get()];
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-void TextChecker::getGuessesForWord(int64_t spellDocumentTag, const String&amp; word, const String&amp; context, Vector&lt;String&gt;&amp; guesses)
</del><ins>+void TextChecker::getGuessesForWord(int64_t spellDocumentTag, const String&amp; word, const String&amp; context, int32_t insertionPoint, Vector&lt;String&gt;&amp; guesses)
</ins><span class="cx"> {
</span><span class="cx">     NSString* language = nil;
</span><span class="cx">     NSOrthography* orthography = nil;
</span><span class="cx">     NSSpellChecker *checker = [NSSpellChecker sharedSpellChecker];
</span><ins>+    NSDictionary *options = nil;
+#if PLATFORM(MAC) &amp;&amp; __MAC_OS_X_VERSION_MIN_REQUIRED &gt;= 101200
+    options = @{ NSTextCheckingInsertionPointKey :  [NSNumber numberWithUnsignedInteger:insertionPoint] };
+#endif
</ins><span class="cx">     if (context.length()) {
</span><del>-        [checker checkString:context range:NSMakeRange(0, context.length()) types:NSTextCheckingTypeOrthography options:0 inSpellDocumentWithTag:spellDocumentTag orthography:&amp;orthography wordCount:0];
</del><ins>+        [checker checkString:context range:NSMakeRange(0, context.length()) types:NSTextCheckingTypeOrthography options:options inSpellDocumentWithTag:spellDocumentTag orthography:&amp;orthography wordCount:0];
</ins><span class="cx">         language = [checker languageForWordRange:NSMakeRange(0, context.length()) inString:context orthography:orthography];
</span><span class="cx">     }
</span><span class="cx">     NSArray* stringsArray = [checker guessesForWordRange:NSMakeRange(0, word.length()) inString:word language:language inSpellDocumentWithTag:spellDocumentTag];
</span><span class="lines">@@ -450,7 +459,7 @@
</span><span class="cx">     [[NSSpellChecker sharedSpellChecker] ignoreWord:word inSpellDocumentWithTag:spellDocumentTag];
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-void TextChecker::requestCheckingOfString(PassRefPtr&lt;TextCheckerCompletion&gt;)
</del><ins>+void TextChecker::requestCheckingOfString(PassRefPtr&lt;TextCheckerCompletion&gt;, int32_t)
</ins><span class="cx"> {
</span><span class="cx">     notImplemented();
</span><span class="cx"> }
</span></span></pre></div>
<a id="trunkSourceWebKit2WebProcessWebCoreSupportWebEditorClientcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/WebProcess/WebCoreSupport/WebEditorClient.cpp (198305 => 198306)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/WebProcess/WebCoreSupport/WebEditorClient.cpp        2016-03-16 22:10:02 UTC (rev 198305)
+++ trunk/Source/WebKit2/WebProcess/WebCoreSupport/WebEditorClient.cpp        2016-03-16 23:25:09 UTC (rev 198306)
</span><span class="lines">@@ -48,8 +48,10 @@
</span><span class="cx"> #include &lt;WebCore/Page.h&gt;
</span><span class="cx"> #include &lt;WebCore/SpellChecker.h&gt;
</span><span class="cx"> #include &lt;WebCore/StyleProperties.h&gt;
</span><ins>+#include &lt;WebCore/TextIterator.h&gt;
</ins><span class="cx"> #include &lt;WebCore/UndoStep.h&gt;
</span><span class="cx"> #include &lt;WebCore/UserTypingGestureIndicator.h&gt;
</span><ins>+#include &lt;WebCore/VisibleUnits.h&gt;
</ins><span class="cx"> #include &lt;wtf/NeverDestroyed.h&gt;
</span><span class="cx"> #include &lt;wtf/text/StringView.h&gt;
</span><span class="cx"> 
</span><span class="lines">@@ -474,12 +476,19 @@
</span><span class="cx">     *badGrammarLength = resultLength;
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+static int32_t insertionPointFromCurrentSelection(const VisibleSelection&amp; currentSelection)
+{
+    VisiblePosition selectionStart = currentSelection.visibleStart();
+    VisiblePosition paragraphStart = startOfParagraph(selectionStart);
+    return TextIterator::rangeLength(makeRange(paragraphStart, selectionStart).get());
+}
+
</ins><span class="cx"> #if USE(UNIFIED_TEXT_CHECKING)
</span><del>-Vector&lt;TextCheckingResult&gt; WebEditorClient::checkTextOfParagraph(StringView stringView, WebCore::TextCheckingTypeMask checkingTypes)
</del><ins>+Vector&lt;TextCheckingResult&gt; WebEditorClient::checkTextOfParagraph(StringView stringView, WebCore::TextCheckingTypeMask checkingTypes, const VisibleSelection&amp; currentSelection)
</ins><span class="cx"> {
</span><span class="cx">     Vector&lt;TextCheckingResult&gt; results;
</span><span class="cx"> 
</span><del>-    m_page-&gt;sendSync(Messages::WebPageProxy::CheckTextOfParagraph(stringView.toStringWithoutCopying(), checkingTypes), Messages::WebPageProxy::CheckTextOfParagraph::Reply(results));
</del><ins>+    m_page-&gt;sendSync(Messages::WebPageProxy::CheckTextOfParagraph(stringView.toStringWithoutCopying(), checkingTypes, insertionPointFromCurrentSelection(currentSelection)), Messages::WebPageProxy::CheckTextOfParagraph::Reply(results));
</ins><span class="cx"> 
</span><span class="cx">     return results;
</span><span class="cx"> }
</span><span class="lines">@@ -507,19 +516,19 @@
</span><span class="cx">     return isShowing;
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-void WebEditorClient::getGuessesForWord(const String&amp; word, const String&amp; context, Vector&lt;String&gt;&amp; guesses)
</del><ins>+void WebEditorClient::getGuessesForWord(const String&amp; word, const String&amp; context, const VisibleSelection&amp; currentSelection, Vector&lt;String&gt;&amp; guesses)
</ins><span class="cx"> {
</span><del>-    m_page-&gt;sendSync(Messages::WebPageProxy::GetGuessesForWord(word, context), Messages::WebPageProxy::GetGuessesForWord::Reply(guesses));
</del><ins>+    m_page-&gt;sendSync(Messages::WebPageProxy::GetGuessesForWord(word, context, insertionPointFromCurrentSelection(currentSelection)), Messages::WebPageProxy::GetGuessesForWord::Reply(guesses));
</ins><span class="cx"> }
</span><span class="cx"> 
</span><del>-void WebEditorClient::requestCheckingOfString(WTF::PassRefPtr&lt;TextCheckingRequest&gt; prpRequest)
</del><ins>+void WebEditorClient::requestCheckingOfString(WTF::PassRefPtr&lt;TextCheckingRequest&gt; prpRequest, const WebCore::VisibleSelection&amp; currentSelection)
</ins><span class="cx"> {
</span><span class="cx">     RefPtr&lt;TextCheckingRequest&gt; request = prpRequest;
</span><span class="cx"> 
</span><span class="cx">     uint64_t requestID = generateTextCheckingRequestID();
</span><span class="cx">     m_page-&gt;addTextCheckingRequest(requestID, request);
</span><span class="cx"> 
</span><del>-    m_page-&gt;send(Messages::WebPageProxy::RequestCheckingOfString(requestID, request-&gt;data()));
</del><ins>+    m_page-&gt;send(Messages::WebPageProxy::RequestCheckingOfString(requestID, request-&gt;data(), insertionPointFromCurrentSelection(currentSelection)));
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void WebEditorClient::willSetInputMethodState()
</span></span></pre></div>
<a id="trunkSourceWebKit2WebProcessWebCoreSupportWebEditorClienth"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/WebProcess/WebCoreSupport/WebEditorClient.h (198305 => 198306)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/WebProcess/WebCoreSupport/WebEditorClient.h        2016-03-16 22:10:02 UTC (rev 198305)
+++ trunk/Source/WebKit2/WebProcess/WebCoreSupport/WebEditorClient.h        2016-03-16 23:25:09 UTC (rev 198306)
</span><span class="lines">@@ -139,16 +139,16 @@
</span><span class="cx">     String getAutoCorrectSuggestionForMisspelledWord(const String&amp; misspelledWord) override;
</span><span class="cx">     void checkGrammarOfString(StringView, Vector&lt;WebCore::GrammarDetail&gt;&amp;, int* badGrammarLocation, int* badGrammarLength) override;
</span><span class="cx"> #if USE(UNIFIED_TEXT_CHECKING)
</span><del>-    Vector&lt;WebCore::TextCheckingResult&gt; checkTextOfParagraph(StringView, WebCore::TextCheckingTypeMask checkingTypes) override;
</del><ins>+    Vector&lt;WebCore::TextCheckingResult&gt; checkTextOfParagraph(StringView, WebCore::TextCheckingTypeMask checkingTypes, const WebCore::VisibleSelection&amp; currentSelection) override;
</ins><span class="cx"> #endif
</span><span class="cx">     void updateSpellingUIWithGrammarString(const String&amp;, const WebCore::GrammarDetail&amp;) override;
</span><span class="cx">     void updateSpellingUIWithMisspelledWord(const String&amp;) override;
</span><span class="cx">     void showSpellingUI(bool show) override;
</span><span class="cx">     bool spellingUIIsShowing() override;
</span><del>-    void getGuessesForWord(const String&amp; word, const String&amp; context, Vector&lt;String&gt;&amp; guesses) override;
</del><ins>+    void getGuessesForWord(const String&amp; word, const String&amp; context, const WebCore::VisibleSelection&amp; currentSelection, Vector&lt;String&gt;&amp; guesses) override;
</ins><span class="cx">     void willSetInputMethodState() override;
</span><span class="cx">     void setInputMethodState(bool enabled) override;
</span><del>-    void requestCheckingOfString(WTF::PassRefPtr&lt;WebCore::TextCheckingRequest&gt;) override;
</del><ins>+    void requestCheckingOfString(WTF::PassRefPtr&lt;WebCore::TextCheckingRequest&gt;, const WebCore::VisibleSelection&amp; currentSelection) override;
</ins><span class="cx"> 
</span><span class="cx"> #if PLATFORM(GTK)
</span><span class="cx">     bool shouldShowUnicodeMenu() override;
</span></span></pre>
</div>
</div>

</body>
</html>