<!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 <bdakin@apple.com>
+
+ 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 <achristensen@webkit.org>
</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<TextCheckingResult> results;
</span><del>- checkTextOfParagraph(*textChecker, stringValue(), TextCheckingTypeSpelling, results);
</del><ins>+ checkTextOfParagraph(*textChecker, stringValue(), TextCheckingTypeSpelling, results, frame->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<TextCheckingResult> results;
</span><del>- checkTextOfParagraph(*checker, text, TextCheckingTypeSpelling, results);
</del><ins>+ checkTextOfParagraph(*checker, text, TextCheckingTypeSpelling, results, node->document().frame()->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<String> suggestions;
</span><del>- textChecker()->getGuessesForWord(m_alternativeTextInfo.originalText, paragraphText, suggestions);
</del><ins>+ textChecker()->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<String> guesses;
</span><span class="cx"> if (client())
</span><del>- textChecker()->getGuessesForWord(word, String(), guesses);
</del><ins>+ textChecker()->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<TextCheckingResult> 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()->requestCheckingOfString(m_processingRequest);
</del><ins>+ client()->requestCheckingOfString(m_processingRequest, m_frame.selection().selection());
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> void SpellChecker::enqueueRequest(PassRefPtr<SpellCheckRequest> 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 "Document.h"
</span><span class="cx"> #include "DocumentMarkerController.h"
</span><span class="cx"> #include "Frame.h"
</span><ins>+#include "FrameSelection.h"
</ins><span class="cx"> #include "Settings.h"
</span><span class="cx"> #include "TextBreakIterator.h"
</span><span class="cx"> #include "TextCheckerClient.h"
</span><span class="lines">@@ -346,7 +347,10 @@
</span><span class="cx">
</span><span class="cx"> Vector<TextCheckingResult> results;
</span><span class="cx"> TextCheckingTypeMask checkingTypes = checkGrammar ? (TextCheckingTypeSpelling | TextCheckingTypeGrammar) : TextCheckingTypeSpelling;
</span><del>- checkTextOfParagraph(*m_client->textChecker(), paragraphString, checkingTypes, results);
</del><ins>+ VisibleSelection currentSelection;
+ if (Frame* frame = paragraphRange->ownerDocument().frame())
+ currentSelection = frame->selection().selection();
+ checkTextOfParagraph(*m_client->textChecker(), paragraphString, checkingTypes, results, currentSelection);
</ins><span class="cx">
</span><span class="cx"> for (auto& result : results) {
</span><span class="cx"> if (result.type == TextCheckingTypeSpelling && result.location >= currentStartOffset && result.location + result.length <= currentEndOffset) {
</span><span class="lines">@@ -578,13 +582,16 @@
</span><span class="cx">
</span><span class="cx"> Vector<TextCheckingResult> results;
</span><span class="cx"> TextCheckingTypeMask checkingTypes = checkGrammar ? (TextCheckingTypeSpelling | TextCheckingTypeGrammar) : TextCheckingTypeSpelling;
</span><del>- checkTextOfParagraph(*m_client->textChecker(), paragraph.text(), checkingTypes, results);
</del><ins>+ VisibleSelection currentSelection;
+ if (Frame* frame = m_range->ownerDocument().frame())
+ currentSelection = frame->selection().selection();
+ checkTextOfParagraph(*m_client->textChecker(), paragraph.text(), checkingTypes, results, currentSelection);
</ins><span class="cx">
</span><span class="cx"> for (auto& result : results) {
</span><span class="cx"> if (result.type == TextCheckingTypeSpelling && 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->textChecker()->getGuessesForWord(misspelledWord, String(), guesses);
</del><ins>+ m_client->textChecker()->getGuessesForWord(misspelledWord, String(), currentSelection, guesses);
</ins><span class="cx"> m_client->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 && WebCore::unifiedTextCheckerEnabled(m_range->ownerDocument().frame());
</span><span class="cx"> }
</span><span class="cx">
</span><del>-void checkTextOfParagraph(TextCheckerClient& client, StringView text, TextCheckingTypeMask checkingTypes, Vector<TextCheckingResult>& results)
</del><ins>+void checkTextOfParagraph(TextCheckerClient& client, StringView text, TextCheckingTypeMask checkingTypes, Vector<TextCheckingResult>& results, const VisibleSelection& 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<TextCheckingResult> mispellings;
</span><span class="cx"> if (checkingTypes & 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&, StringView, TextCheckingTypeMask, Vector<TextCheckingResult>&);
</del><ins>+void checkTextOfParagraph(TextCheckerClient&, StringView, TextCheckingTypeMask, Vector<TextCheckingResult>&, const VisibleSelection& 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<FrameNetworkingContext>();
</span><span class="cx"> }
</span><span class="cx">
</span><del>-void EmptyTextCheckerClient::requestCheckingOfString(PassRefPtr<TextCheckingRequest>)
</del><ins>+void EmptyTextCheckerClient::requestCheckingOfString(PassRefPtr<TextCheckingRequest>, const VisibleSelection&)
</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<GrammarDetail>&, int*, int*) override { }
</span><span class="cx">
</span><span class="cx"> #if USE(UNIFIED_TEXT_CHECKING)
</span><del>- Vector<TextCheckingResult> checkTextOfParagraph(StringView, TextCheckingTypeMask) override { return Vector<TextCheckingResult>(); }
</del><ins>+ Vector<TextCheckingResult> checkTextOfParagraph(StringView, TextCheckingTypeMask, const VisibleSelection&) override { return Vector<TextCheckingResult>(); }
</ins><span class="cx"> #endif
</span><span class="cx">
</span><del>- void getGuessesForWord(const String&, const String&, Vector<String>&) override { }
- void requestCheckingOfString(PassRefPtr<TextCheckingRequest>) override;
</del><ins>+ void getGuessesForWord(const String&, const String&, const VisibleSelection&, Vector<String>&) override { }
+ void requestCheckingOfString(PassRefPtr<TextCheckingRequest>, const VisibleSelection&) 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<NSString *, id> *)options inSpellDocumentWithTag:(NSInteger)tag completionHandler:(void (^)(NSInteger sequenceNumber, NSArray<NSTextCheckingResult *> *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<GrammarDetail>&, int* badGrammarLocation, int* badGrammarLength) = 0;
</span><span class="cx">
</span><span class="cx"> #if USE(UNIFIED_TEXT_CHECKING)
</span><del>- virtual Vector<TextCheckingResult> checkTextOfParagraph(StringView, TextCheckingTypeMask checkingTypes) = 0;
</del><ins>+ virtual Vector<TextCheckingResult> checkTextOfParagraph(StringView, TextCheckingTypeMask checkingTypes, const VisibleSelection& 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 "context" to aid such spellcheckers on language
</span><span class="cx"> // identification. Noramlly it's the text surrounding the "word" for which we are getting correction suggestions.
</span><del>- virtual void getGuessesForWord(const String& word, const String& context, Vector<String>& guesses) = 0;
- virtual void requestCheckingOfString(PassRefPtr<TextCheckingRequest>) = 0;
</del><ins>+ virtual void getGuessesForWord(const String& word, const String& context, const VisibleSelection& currentSelection, Vector<String>& guesses) = 0;
+ virtual void requestCheckingOfString(PassRefPtr<TextCheckingRequest>, const VisibleSelection& 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 <bdakin@apple.com>
+
+ 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 <cdumez@apple.com>
</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&) override;
</span><span class="cx"> void checkGrammarOfString(StringView, Vector<WebCore::GrammarDetail>&, int* badGrammarLocation, int* badGrammarLength) override;
</span><del>- Vector<WebCore::TextCheckingResult> checkTextOfParagraph(StringView, WebCore::TextCheckingTypeMask checkingTypes) override;
</del><ins>+ Vector<WebCore::TextCheckingResult> checkTextOfParagraph(StringView, WebCore::TextCheckingTypeMask checkingTypes, const WebCore::VisibleSelection& currentSelection) override;
</ins><span class="cx"> void updateSpellingUIWithGrammarString(const String&, const WebCore::GrammarDetail&) override;
</span><span class="cx"> void updateSpellingUIWithMisspelledWord(const String&) override;
</span><span class="cx"> void showSpellingUI(bool show) override;
</span><span class="cx"> bool spellingUIIsShowing() override;
</span><del>- void getGuessesForWord(const String& word, const String& context, Vector<String>& guesses) override;
</del><ins>+ void getGuessesForWord(const String& word, const String& context, const WebCore::VisibleSelection& currentSelection, Vector<String>& 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<WebCore::TextCheckingRequest>) override;
</del><ins>+ void requestCheckingOfString(PassRefPtr<WebCore::TextCheckingRequest>, const WebCore::VisibleSelection& currentSelection) override;
</ins><span class="cx">
</span><span class="cx"> #if PLATFORM(MAC) && __MAC_OS_X_VERSION_MIN_REQUIRED >= 101200
</span><span class="cx"> void requestCandidatesForSelection(const WebCore::VisibleSelection&);
</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&, const String&, Vector<String>&)
</del><ins>+inline void WebEditorClient::getGuessesForWord(const String&, const String&, const WebCore::VisibleSelection&, Vector<String>&)
</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<TextCheckingResult> WebEditorClient::checkTextOfParagraph(StringView string, TextCheckingTypeMask checkingTypes)
</del><ins>+Vector<TextCheckingResult> WebEditorClient::checkTextOfParagraph(StringView string, TextCheckingTypeMask checkingTypes, const VisibleSelection&)
</ins><span class="cx"> {
</span><span class="cx"> ASSERT(checkingTypes & 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<TextCheckingResult> WebEditorClient::checkTextOfParagraph(StringView string, TextCheckingTypeMask checkingTypes)
</del><ins>+#if PLATFORM(MAC) && __MAC_OS_X_VERSION_MIN_REQUIRED >= 101200
+static int insertionPointFromCurrentSelection(const VisibleSelection& 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<TextCheckingResult> WebEditorClient::checkTextOfParagraph(StringView string, TextCheckingTypeMask checkingTypes, const VisibleSelection& currentSelection)
+{
+ NSDictionary *options = nil;
+#if PLATFORM(MAC) && __MAC_OS_X_VERSION_MIN_REQUIRED >= 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& badGrammarPhrase, const GrammarDetail& 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& word, const String& context, Vector<String>& guesses) {
</del><ins>+void WebEditorClient::getGuessesForWord(const String& word, const String& context, const WebCore::VisibleSelection& currentSelection, Vector<String>& 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) && __MAC_OS_X_VERSION_MIN_REQUIRED >= 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:&orthography wordCount:0];
</del><ins>+ [checker checkString:context range:NSMakeRange(0, context.length()) types:NSTextCheckingTypeOrthography options:options inSpellDocumentWithTag:spellCheckerDocumentTag() orthography:&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<WebCore::TextCheckingRequest> request)
</del><ins>+void WebEditorClient::requestCheckingOfString(PassRefPtr<WebCore::TextCheckingRequest> request, const VisibleSelection& 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->data().sequence();
</span><span class="cx"> NSRange range = NSMakeRange(0, m_textCheckingRequest->data().text().length());
</span><span class="cx"> NSRunLoop* currentLoop = [NSRunLoop currentRunLoop];
</span><del>- [[NSSpellChecker sharedSpellChecker] requestCheckingOfString:m_textCheckingRequest->data().text() range:range types:NSTextCheckingAllSystemTypes options:0 inSpellDocumentWithTag:0
- completionHandler:^(NSInteger, NSArray* results, NSOrthography*, NSInteger) {
</del><ins>+ NSDictionary *options = nil;
+#if PLATFORM(MAC) && __MAC_OS_X_VERSION_MIN_REQUIRED >= 101200
+ options = @{ NSTextCheckingInsertionPointKey : [NSNumber numberWithUnsignedInteger:insertionPointFromCurrentSelection(currentSelection)] };
+#endif
+ [[NSSpellChecker sharedSpellChecker] requestCheckingOfString:m_textCheckingRequest->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& word, const String& context, Vector<String>& guesses)
</del><ins>+void WebEditorClient::getGuessesForWord(const String& word, const String& context, const VisibleSelection&, Vector<String>& 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&) override;
</span><span class="cx"> void showSpellingUI(bool show) override;
</span><span class="cx"> bool spellingUIIsShowing() override;
</span><del>- void getGuessesForWord(const WTF::String& word, const WTF::String& context, WTF::Vector<WTF::String>& guesses) override;
</del><ins>+ void getGuessesForWord(const WTF::String& word, const WTF::String& context, const WebCore::VisibleSelection& currentSelection, WTF::Vector<WTF::String>& 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<WebCore::TextCheckingRequest>) override { }
</del><ins>+ void requestCheckingOfString(WTF::PassRefPtr<WebCore::TextCheckingRequest>, const WebCore::VisibleSelection&) 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 <bdakin@apple.com>
+
+ 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 <timothy_horton@apple.com>
</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<WebCore::TextCheckingResult> checkTextOfParagraph(int64_t spellDocumentTag, StringView text, uint64_t checkingTypes);
</del><ins>+ static Vector<WebCore::TextCheckingResult> 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& misspellingLocation, int32_t& misspellingLength);
</span><span class="cx"> static void checkGrammarOfString(int64_t spellDocumentTag, StringView text, Vector<WebCore::GrammarDetail>&, int32_t& badGrammarLocation, int32_t& 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& misspelledWord);
</span><span class="cx"> static void updateSpellingUIWithGrammarString(int64_t spellDocumentTag, const String& badGrammarPhrase, const WebCore::GrammarDetail&);
</span><del>- static void getGuessesForWord(int64_t spellDocumentTag, const String& word, const String& context, Vector<String>& guesses);
</del><ins>+ static void getGuessesForWord(int64_t spellDocumentTag, const String& word, const String& context, int32_t insertionPoint, Vector<String>& guesses);
</ins><span class="cx"> static void learnWord(int64_t spellDocumentTag, const String& word);
</span><span class="cx"> static void ignoreWord(int64_t spellDocumentTag, const String& word);
</span><del>- static void requestCheckingOfString(PassRefPtr<TextCheckerCompletion>);
</del><ins>+ static void requestCheckingOfString(PassRefPtr<TextCheckerCompletion>, 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& text, uint64_t checkingTypes, Vector<TextCheckingResult>& results)
</del><ins>+void WebPageProxy::checkTextOfParagraph(const String& text, uint64_t checkingTypes, int32_t insertionPoint, Vector<TextCheckingResult>& 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& word, const String& context, Vector<String>& guesses)
</del><ins>+void WebPageProxy::getGuessesForWord(const String& word, const String& context, int32_t insertionPoint, Vector<String>& 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& 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& request)
</del><ins>+void WebPageProxy::requestCheckingOfString(uint64_t requestID, const TextCheckingRequestData& 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<WebCore::TextCheckingResult>& 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& text, uint64_t checkingTypes, Vector<WebCore::TextCheckingResult>& results);
</del><ins>+ void checkTextOfParagraph(const String& text, uint64_t checkingTypes, int32_t insertionPoint, Vector<WebCore::TextCheckingResult>& results);
</ins><span class="cx"> #endif
</span><del>- void getGuessesForWord(const String& word, const String& context, Vector<String>& guesses);
</del><ins>+ void getGuessesForWord(const String& word, const String& context, int32_t insertionPoint, Vector<String>& 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& badGrammarPhrase, const WebCore::GrammarDetail&);
</span><span class="cx"> void learnWord(const String& word);
</span><span class="cx"> void ignoreWord(const String& word);
</span><del>- void requestCheckingOfString(uint64_t requestID, const WebCore::TextCheckingRequestData&);
</del><ins>+ void requestCheckingOfString(uint64_t requestID, const WebCore::TextCheckingRequestData&, int32_t insertionPoint);
</ins><span class="cx">
</span><span class="cx"> void takeFocus(uint32_t direction);
</span><span class="cx"> void setToolTip(const String&);
</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) -> (Vector<WebCore::TextCheckingResult> results)
</del><ins>+ CheckTextOfParagraph(String text, uint64_t checkingTypes, int32_t insertionPoint) -> (Vector<WebCore::TextCheckingResult> results)
</ins><span class="cx"> #endif
</span><span class="cx"> CheckSpellingOfString(String text) -> (int32_t misspellingLocation, int32_t misspellingLength)
</span><span class="cx"> CheckGrammarOfString(String text) -> (Vector<WebCore::GrammarDetail> results, int32_t badGrammarLocation, int32_t badGrammarLength)
</span><span class="cx"> SpellingUIIsShowing() -> (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) -> (Vector<String> guesses)
</del><ins>+ GetGuessesForWord(String word, String context, int32_t insertionPoint) -> (Vector<String> 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<TextCheckingResult> TextChecker::checkTextOfParagraph(int64_t spellDocumentTag, StringView text, uint64_t checkingTypes)
</del><ins>+Vector<TextCheckingResult> 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<TextCheckingResult> paragraphCheckingResult;
</span><span class="cx"> #if ENABLE(SPELLCHECK)
</span><span class="cx"> if (checkingTypes & 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& word, const String& , Vector<String>& guesses)
</del><ins>+void TextChecker::getGuessesForWord(int64_t spellDocumentTag, const String& word, const String& , int32_t insertionPoint, Vector<String>& guesses)
</ins><span class="cx"> {
</span><ins>+ UNUSED_PARAM(insertionPoint);
</ins><span class="cx"> #if ENABLE(SPELLCHECK)
</span><span class="cx"> WebTextChecker::singleton()->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<TextCheckerCompletion> completion)
</del><ins>+void TextChecker::requestCheckingOfString(PassRefPtr<TextCheckerCompletion> 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->didFinishCheckingText(checkTextOfParagraph(completion->spellDocumentTag(), request.text(), request.mask()));
</del><ins>+ completion->didFinishCheckingText(checkTextOfParagraph(completion->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& word, const String& /* context */, Vector<String>& guesses)
</del><ins>+void TextChecker::getGuessesForWord(int64_t /* spellDocumentTag */, const String& word, const String& /* context */, int32_t /* insertionPoint */, Vector<String>& 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<TextCheckerCompletion> completion)
</del><ins>+void TextChecker::requestCheckingOfString(PassRefPtr<TextCheckerCompletion> 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->didFinishCheckingText(checkTextOfParagraph(completion->spellDocumentTag(), request.text(), request.mask()));
</del><ins>+ completion->didFinishCheckingText(checkTextOfParagraph(completion->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<TextCheckingResult> TextChecker::checkTextOfParagraph(int64_t spellDocumentTag, StringView text, uint64_t checkingTypes)
</del><ins>+Vector<TextCheckingResult> 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 & TextCheckingTypeSpelling))
</span><span class="cx"> return Vector<TextCheckingResult>();
</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<TextCheckingResult> TextChecker::checkTextOfParagraph(int64_t, StringView, uint64_t)
</del><ins>+Vector<TextCheckingResult> TextChecker::checkTextOfParagraph(int64_t, StringView, int32_t, uint64_t)
</ins><span class="cx"> {
</span><span class="cx"> notImplemented();
</span><span class="cx"> return Vector<TextCheckingResult>();
</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&, const String&, Vector<String>&)
</del><ins>+void TextChecker::getGuessesForWord(int64_t, const String&, const String&, int32_t, Vector<String>&)
</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<TextCheckerCompletion>)
</del><ins>+void TextChecker::requestCheckingOfString(PassRefPtr<TextCheckerCompletion>, 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 "TextCheckerState.h"
</span><ins>+#import <WebCore/NSSpellCheckerSPI.h>
</ins><span class="cx"> #import <WebCore/NotImplemented.h>
</span><span class="cx"> #import <wtf/RetainPtr.h>
</span><span class="cx"> #import <wtf/text/StringView.h>
</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<TextCheckingResult> TextChecker::checkTextOfParagraph(int64_t spellDocumentTag, StringView text, uint64_t checkingTypes)
</del><ins>+Vector<TextCheckingResult> TextChecker::checkTextOfParagraph(int64_t spellDocumentTag, StringView text, int32_t insertionPoint, uint64_t checkingTypes)
</ins><span class="cx"> {
</span><span class="cx"> Vector<TextCheckingResult> results;
</span><span class="cx">
</span><span class="cx"> RetainPtr<NSString> textString = text.createNSStringWithoutCopying();
</span><ins>+ NSDictionary *options = nil;
+#if PLATFORM(MAC) && __MAC_OS_X_VERSION_MIN_REQUIRED >= 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& word, const String& context, Vector<String>& guesses)
</del><ins>+void TextChecker::getGuessesForWord(int64_t spellDocumentTag, const String& word, const String& context, int32_t insertionPoint, Vector<String>& 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) && __MAC_OS_X_VERSION_MIN_REQUIRED >= 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:&orthography wordCount:0];
</del><ins>+ [checker checkString:context range:NSMakeRange(0, context.length()) types:NSTextCheckingTypeOrthography options:options inSpellDocumentWithTag:spellDocumentTag orthography:&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<TextCheckerCompletion>)
</del><ins>+void TextChecker::requestCheckingOfString(PassRefPtr<TextCheckerCompletion>, 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 <WebCore/Page.h>
</span><span class="cx"> #include <WebCore/SpellChecker.h>
</span><span class="cx"> #include <WebCore/StyleProperties.h>
</span><ins>+#include <WebCore/TextIterator.h>
</ins><span class="cx"> #include <WebCore/UndoStep.h>
</span><span class="cx"> #include <WebCore/UserTypingGestureIndicator.h>
</span><ins>+#include <WebCore/VisibleUnits.h>
</ins><span class="cx"> #include <wtf/NeverDestroyed.h>
</span><span class="cx"> #include <wtf/text/StringView.h>
</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& 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<TextCheckingResult> WebEditorClient::checkTextOfParagraph(StringView stringView, WebCore::TextCheckingTypeMask checkingTypes)
</del><ins>+Vector<TextCheckingResult> WebEditorClient::checkTextOfParagraph(StringView stringView, WebCore::TextCheckingTypeMask checkingTypes, const VisibleSelection& currentSelection)
</ins><span class="cx"> {
</span><span class="cx"> Vector<TextCheckingResult> results;
</span><span class="cx">
</span><del>- m_page->sendSync(Messages::WebPageProxy::CheckTextOfParagraph(stringView.toStringWithoutCopying(), checkingTypes), Messages::WebPageProxy::CheckTextOfParagraph::Reply(results));
</del><ins>+ m_page->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& word, const String& context, Vector<String>& guesses)
</del><ins>+void WebEditorClient::getGuessesForWord(const String& word, const String& context, const VisibleSelection& currentSelection, Vector<String>& guesses)
</ins><span class="cx"> {
</span><del>- m_page->sendSync(Messages::WebPageProxy::GetGuessesForWord(word, context), Messages::WebPageProxy::GetGuessesForWord::Reply(guesses));
</del><ins>+ m_page->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<TextCheckingRequest> prpRequest)
</del><ins>+void WebEditorClient::requestCheckingOfString(WTF::PassRefPtr<TextCheckingRequest> prpRequest, const WebCore::VisibleSelection& currentSelection)
</ins><span class="cx"> {
</span><span class="cx"> RefPtr<TextCheckingRequest> request = prpRequest;
</span><span class="cx">
</span><span class="cx"> uint64_t requestID = generateTextCheckingRequestID();
</span><span class="cx"> m_page->addTextCheckingRequest(requestID, request);
</span><span class="cx">
</span><del>- m_page->send(Messages::WebPageProxy::RequestCheckingOfString(requestID, request->data()));
</del><ins>+ m_page->send(Messages::WebPageProxy::RequestCheckingOfString(requestID, request->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& misspelledWord) override;
</span><span class="cx"> void checkGrammarOfString(StringView, Vector<WebCore::GrammarDetail>&, int* badGrammarLocation, int* badGrammarLength) override;
</span><span class="cx"> #if USE(UNIFIED_TEXT_CHECKING)
</span><del>- Vector<WebCore::TextCheckingResult> checkTextOfParagraph(StringView, WebCore::TextCheckingTypeMask checkingTypes) override;
</del><ins>+ Vector<WebCore::TextCheckingResult> checkTextOfParagraph(StringView, WebCore::TextCheckingTypeMask checkingTypes, const WebCore::VisibleSelection& currentSelection) override;
</ins><span class="cx"> #endif
</span><span class="cx"> void updateSpellingUIWithGrammarString(const String&, const WebCore::GrammarDetail&) override;
</span><span class="cx"> void updateSpellingUIWithMisspelledWord(const String&) override;
</span><span class="cx"> void showSpellingUI(bool show) override;
</span><span class="cx"> bool spellingUIIsShowing() override;
</span><del>- void getGuessesForWord(const String& word, const String& context, Vector<String>& guesses) override;
</del><ins>+ void getGuessesForWord(const String& word, const String& context, const WebCore::VisibleSelection& currentSelection, Vector<String>& guesses) override;
</ins><span class="cx"> void willSetInputMethodState() override;
</span><span class="cx"> void setInputMethodState(bool enabled) override;
</span><del>- void requestCheckingOfString(WTF::PassRefPtr<WebCore::TextCheckingRequest>) override;
</del><ins>+ void requestCheckingOfString(WTF::PassRefPtr<WebCore::TextCheckingRequest>, const WebCore::VisibleSelection& 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>