<!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>[193645] 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/193645">193645</a></dd>
<dt>Author</dt> <dd>bdakin@apple.com</dd>
<dt>Date</dt> <dd>2015-12-07 12:37:03 -0800 (Mon, 07 Dec 2015)</dd>
</dl>

<h3>Log Message</h3>
<pre>Hook up request and show for typing candidates in WK1
https://bugs.webkit.org/show_bug.cgi?id=151831
-and corresponding-
&lt;rdar://problem/23751214&gt;

Reviewed by Enrica Casucci.

Source/WebCore:

New SPI that is needed.
* WebCore.xcodeproj/project.pbxproj:
* platform/spi/mac/NSSpellCheckerSPI.h: Added.

Request candidates for editable content whenever selection changes.
* editing/Editor.cpp:
(WebCore::Editor::respondToChangedSelection):

Implement requestCandidatesForSelection on the EditorClient.
* loader/EmptyClients.h:
* page/EditorClient.h:
(WebCore::EditorClient::requestCandidatesForSelection):

Source/WebKit/mac:

Add member variables to WebEditorClient. One is a WeakPtrFactory for the 
asynchronous handlers, and the other caches the VisibleSelection at the time 
candidates were requested so that we can make sure the candidates are still 
valid once we receive them.
* WebCoreSupport/WebEditorClient.h:
* WebCoreSupport/WebEditorClient.mm:
(WebEditorClient::WebEditorClient):

Call [NSSpellChecker requestCandidatesForSelectedRange] with the appropriate 
parameters.
(WebEditorClient::requestCandidatesForSelection):

Two helpers to compute information that we need for both of the handlers 
below.
(candidateRangeForSelection):
(candidateWouldReplaceText):

In this handler, we just need to call [NSSpellChecker showCandidates] with 
the appropriate parameters.
(WebEditorClient::handleRequestedCandidates):

Once a candidate is accepted, it should be inserted in the right way.
(WebEditorClient::handleAcceptedCandidate):

Source/WebKit2:

Empty client for now.
* WebProcess/WebCoreSupport/WebEditorClient.h:</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkSourceWebCoreChangeLog">trunk/Source/WebCore/ChangeLog</a></li>
<li><a href="#trunkSourceWebCoreWebCorexcodeprojprojectpbxproj">trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj</a></li>
<li><a href="#trunkSourceWebCoreeditingEditorcpp">trunk/Source/WebCore/editing/Editor.cpp</a></li>
<li><a href="#trunkSourceWebCoreloaderEmptyClientsh">trunk/Source/WebCore/loader/EmptyClients.h</a></li>
<li><a href="#trunkSourceWebCorepageEditorClienth">trunk/Source/WebCore/page/EditorClient.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="#trunkSourceWebKit2ChangeLog">trunk/Source/WebKit2/ChangeLog</a></li>
<li><a href="#trunkSourceWebKit2WebProcessWebCoreSupportWebEditorClienth">trunk/Source/WebKit2/WebProcess/WebCoreSupport/WebEditorClient.h</a></li>
</ul>

<h3>Added Paths</h3>
<ul>
<li><a href="#trunkSourceWebCoreplatformspimacNSSpellCheckerSPIh">trunk/Source/WebCore/platform/spi/mac/NSSpellCheckerSPI.h</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkSourceWebCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/ChangeLog (193644 => 193645)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/ChangeLog        2015-12-07 20:35:09 UTC (rev 193644)
+++ trunk/Source/WebCore/ChangeLog        2015-12-07 20:37:03 UTC (rev 193645)
</span><span class="lines">@@ -1,3 +1,25 @@
</span><ins>+2015-12-07  Beth Dakin  &lt;bdakin@apple.com&gt;
+
+        Hook up request and show for typing candidates in WK1
+        https://bugs.webkit.org/show_bug.cgi?id=151831
+        -and corresponding-
+        &lt;rdar://problem/23751214&gt;
+
+        Reviewed by Enrica Casucci.
+
+        New SPI that is needed.
+        * WebCore.xcodeproj/project.pbxproj:
+        * platform/spi/mac/NSSpellCheckerSPI.h: Added.
+
+        Request candidates for editable content whenever selection changes.
+        * editing/Editor.cpp:
+        (WebCore::Editor::respondToChangedSelection):
+
+        Implement requestCandidatesForSelection on the EditorClient.
+        * loader/EmptyClients.h:
+        * page/EditorClient.h:
+        (WebCore::EditorClient::requestCandidatesForSelection):
+
</ins><span class="cx"> 2015-12-07  Brady Eidson  &lt;beidson@apple.com&gt;
</span><span class="cx"> 
</span><span class="cx">         Modern IDB: Fix &quot;old versions&quot; when upgrading databases.
</span></span></pre></div>
<a id="trunkSourceWebCoreWebCorexcodeprojprojectpbxproj"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj (193644 => 193645)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj        2015-12-07 20:35:09 UTC (rev 193644)
+++ trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj        2015-12-07 20:37:03 UTC (rev 193645)
</span><span class="lines">@@ -3556,6 +3556,7 @@
</span><span class="cx">                 933A14AA0B7D1D0900A53FFD /* DOMTextEvent.mm in Sources */ = {isa = PBXBuildFile; fileRef = 933A14A90B7D1D0900A53FFD /* DOMTextEvent.mm */; };
</span><span class="cx">                 933A14B80B7D1D5200A53FFD /* JSTextEvent.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 933A14B60B7D1D5200A53FFD /* JSTextEvent.cpp */; };
</span><span class="cx">                 933A14B90B7D1D5200A53FFD /* JSTextEvent.h in Headers */ = {isa = PBXBuildFile; fileRef = 933A14B70B7D1D5200A53FFD /* JSTextEvent.h */; };
</span><ins>+                933C7A751C0FBC440034FB97 /* NSSpellCheckerSPI.h in Headers */ = {isa = PBXBuildFile; fileRef = 933C7A741C0FBC440034FB97 /* NSSpellCheckerSPI.h */; settings = {ATTRIBUTES = (Private, ); }; };
</ins><span class="cx">                 9343CB8112F25E510033C5EE /* TextCodecUTF8.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 9343CB7F12F25E510033C5EE /* TextCodecUTF8.cpp */; };
</span><span class="cx">                 9343CB8212F25E510033C5EE /* TextCodecUTF8.h in Headers */ = {isa = PBXBuildFile; fileRef = 9343CB8012F25E510033C5EE /* TextCodecUTF8.h */; };
</span><span class="cx">                 93442C9E0D2B335C00338FF9 /* HTMLTableRowsCollection.h in Headers */ = {isa = PBXBuildFile; fileRef = 93442C9D0D2B335C00338FF9 /* HTMLTableRowsCollection.h */; };
</span><span class="lines">@@ -11050,6 +11051,7 @@
</span><span class="cx">                 933A14A90B7D1D0900A53FFD /* DOMTextEvent.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = DOMTextEvent.mm; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><span class="cx">                 933A14B60B7D1D5200A53FFD /* JSTextEvent.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSTextEvent.cpp; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><span class="cx">                 933A14B70B7D1D5200A53FFD /* JSTextEvent.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSTextEvent.h; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><ins>+                933C7A741C0FBC440034FB97 /* NSSpellCheckerSPI.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = NSSpellCheckerSPI.h; sourceTree = &quot;&lt;group&gt;&quot;; };
</ins><span class="cx">                 9343CB7F12F25E510033C5EE /* TextCodecUTF8.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = TextCodecUTF8.cpp; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><span class="cx">                 9343CB8012F25E510033C5EE /* TextCodecUTF8.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TextCodecUTF8.h; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><span class="cx">                 93442C9D0D2B335C00338FF9 /* HTMLTableRowsCollection.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = HTMLTableRowsCollection.h; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><span class="lines">@@ -18656,6 +18658,7 @@
</span><span class="cx">                                 F40EA8AA1B867D6500CE5581 /* NSScrollingInputFilterSPI.h */,
</span><span class="cx">                                 2DCB837719F99BBA00A7FBE4 /* NSSharingServicePickerSPI.h */,
</span><span class="cx">                                 2DCB837819F99BBA00A7FBE4 /* NSSharingServiceSPI.h */,
</span><ins>+                                933C7A741C0FBC440034FB97 /* NSSpellCheckerSPI.h */,
</ins><span class="cx">                                 2D77AC281BF2B9860072470A /* NSTextFinderSPI.h */,
</span><span class="cx">                                 2D77AC2C1BF2B9A00072470A /* NSViewSPI.h */,
</span><span class="cx">                                 2D0CF8161BCF5DE1007A4937 /* NSWindowSPI.h */,
</span><span class="lines">@@ -27665,6 +27668,7 @@
</span><span class="cx">                                 83C1D430178D5AB500141E68 /* SVGPathSegLinetoHorizontalAbs.h in Headers */,
</span><span class="cx">                                 83C1D431178D5AB500141E68 /* SVGPathSegLinetoHorizontalRel.h in Headers */,
</span><span class="cx">                                 83C1D432178D5AB500141E68 /* SVGPathSegLinetoRel.h in Headers */,
</span><ins>+                                933C7A751C0FBC440034FB97 /* NSSpellCheckerSPI.h in Headers */,
</ins><span class="cx">                                 B2227A7D0D00BF220071B782 /* SVGPathSegLinetoVertical.h in Headers */,
</span><span class="cx">                                 83C1D433178D5AB500141E68 /* SVGPathSegLinetoVerticalAbs.h in Headers */,
</span><span class="cx">                                 83C1D434178D5AB500141E68 /* SVGPathSegLinetoVerticalRel.h in Headers */,
</span></span></pre></div>
<a id="trunkSourceWebCoreeditingEditorcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/editing/Editor.cpp (193644 => 193645)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/editing/Editor.cpp        2015-12-07 20:35:09 UTC (rev 193644)
+++ trunk/Source/WebCore/editing/Editor.cpp        2015-12-07 20:37:03 UTC (rev 193645)
</span><span class="lines">@@ -3264,6 +3264,11 @@
</span><span class="cx">     if (client())
</span><span class="cx">         client()-&gt;respondToChangedSelection(&amp;m_frame);
</span><span class="cx"> 
</span><ins>+#if PLATFORM(MAC) &amp;&amp; __MAC_OS_X_VERSION_MIN_REQUIRED &gt;= 101200
+    if (client() &amp;&amp; canEdit())
+        client()-&gt;requestCandidatesForSelection(m_frame.selection().selection());
+#endif
+
</ins><span class="cx"> #if ENABLE(TELEPHONE_NUMBER_DETECTION) &amp;&amp; !PLATFORM(IOS)
</span><span class="cx">     if (shouldDetectTelephoneNumbers())
</span><span class="cx">         m_telephoneNumberDetectionUpdateTimer.startOneShot(0);
</span></span></pre></div>
<a id="trunkSourceWebCoreloaderEmptyClientsh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/loader/EmptyClients.h (193644 => 193645)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/loader/EmptyClients.h        2015-12-07 20:35:09 UTC (rev 193644)
+++ trunk/Source/WebCore/loader/EmptyClients.h        2015-12-07 20:37:03 UTC (rev 193645)
</span><span class="lines">@@ -537,6 +537,10 @@
</span><span class="cx">     virtual void willSetInputMethodState() override { }
</span><span class="cx">     virtual void setInputMethodState(bool) override { }
</span><span class="cx"> 
</span><ins>+#if PLATFORM(MAC) &amp;&amp; __MAC_OS_X_VERSION_MIN_REQUIRED &gt;= 101200
+    virtual void requestCandidatesForSelection(const VisibleSelection&amp;) override { }
+#endif
+
</ins><span class="cx"> private:
</span><span class="cx">     EmptyTextCheckerClient m_textCheckerClient;
</span><span class="cx"> };
</span></span></pre></div>
<a id="trunkSourceWebCorepageEditorClienth"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/page/EditorClient.h (193644 => 193645)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/page/EditorClient.h        2015-12-07 20:35:09 UTC (rev 193644)
+++ trunk/Source/WebCore/page/EditorClient.h        2015-12-07 20:37:03 UTC (rev 193645)
</span><span class="lines">@@ -186,6 +186,10 @@
</span><span class="cx">     // Support for global selections, used on platforms like the X Window System that treat
</span><span class="cx">     // selection as a type of clipboard.
</span><span class="cx">     virtual bool supportsGlobalSelection() { return false; }
</span><ins>+
+#if PLATFORM(MAC) &amp;&amp; __MAC_OS_X_VERSION_MIN_REQUIRED &gt;= 101200
+    virtual void requestCandidatesForSelection(const VisibleSelection&amp;) = 0;
+#endif
</ins><span class="cx"> };
</span><span class="cx"> 
</span><span class="cx"> }
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformspimacNSSpellCheckerSPIh"></a>
<div class="addfile"><h4>Added: trunk/Source/WebCore/platform/spi/mac/NSSpellCheckerSPI.h (0 => 193645)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/spi/mac/NSSpellCheckerSPI.h                                (rev 0)
+++ trunk/Source/WebCore/platform/spi/mac/NSSpellCheckerSPI.h        2015-12-07 20:37:03 UTC (rev 193645)
</span><span class="lines">@@ -0,0 +1,39 @@
</span><ins>+/*
+ * Copyright (C) 2015 Apple Inc.  All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL APPLE INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 
+ */
+#ifndef NSSpellCheckerSPI_h
+#define NSSpellCheckerSPI_h
+
+#if PLATFORM(MAC) &amp;&amp; __MAC_OS_X_VERSION_MIN_REQUIRED &gt;= 101200
+
+// FIXME: This header should include system headers when possible.
+
+@interface NSSpellChecker ()
+- (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;
+- (void)showCandidates:(NSArray&lt;NSTextCheckingResult *&gt; *)candidates forString:(NSString *)string inRect:(NSRect)rectOfTypedString view:(NSView *)view completionHandler:(void (^)(NSTextCheckingResult *acceptedCandidate))completionBlock;
+@end
+
+#endif // PLATFORM(MAC) &amp;&amp; __MAC_OS_X_VERSION_MIN_REQUIRED &gt;= 102000
+
+#endif // NSSpellCheckerSPI_h
</ins></span></pre></div>
<a id="trunkSourceWebKitmacChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit/mac/ChangeLog (193644 => 193645)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit/mac/ChangeLog        2015-12-07 20:35:09 UTC (rev 193644)
+++ trunk/Source/WebKit/mac/ChangeLog        2015-12-07 20:37:03 UTC (rev 193645)
</span><span class="lines">@@ -1,3 +1,36 @@
</span><ins>+2015-12-07  Beth Dakin  &lt;bdakin@apple.com&gt;
+
+        Hook up request and show for typing candidates in WK1
+        https://bugs.webkit.org/show_bug.cgi?id=151831
+        -and corresponding-
+        &lt;rdar://problem/23751214&gt;
+
+        Reviewed by Enrica Casucci.
+
+        Add member variables to WebEditorClient. One is a WeakPtrFactory for the 
+        asynchronous handlers, and the other caches the VisibleSelection at the time 
+        candidates were requested so that we can make sure the candidates are still 
+        valid once we receive them.
+        * WebCoreSupport/WebEditorClient.h:
+        * WebCoreSupport/WebEditorClient.mm:
+        (WebEditorClient::WebEditorClient):
+
+        Call [NSSpellChecker requestCandidatesForSelectedRange] with the appropriate 
+        parameters.
+        (WebEditorClient::requestCandidatesForSelection):
+
+        Two helpers to compute information that we need for both of the handlers 
+        below.
+        (candidateRangeForSelection):
+        (candidateWouldReplaceText):
+
+        In this handler, we just need to call [NSSpellChecker showCandidates] with 
+        the appropriate parameters.
+        (WebEditorClient::handleRequestedCandidates):
+
+        Once a candidate is accepted, it should be inserted in the right way.
+        (WebEditorClient::handleAcceptedCandidate):
+
</ins><span class="cx"> 2015-12-03  Jer Noble  &lt;jer.noble@apple.com&gt;
</span><span class="cx"> 
</span><span class="cx">         Expose WebCore's InvisibleAutoplayNotPermitted setting to WebKit &amp; WebKit2
</span></span></pre></div>
<a id="trunkSourceWebKitmacWebCoreSupportWebEditorClienth"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit/mac/WebCoreSupport/WebEditorClient.h (193644 => 193645)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit/mac/WebCoreSupport/WebEditorClient.h        2015-12-07 20:35:09 UTC (rev 193644)
+++ trunk/Source/WebKit/mac/WebCoreSupport/WebEditorClient.h        2015-12-07 20:37:03 UTC (rev 193645)
</span><span class="lines">@@ -29,9 +29,11 @@
</span><span class="cx"> 
</span><span class="cx"> #import &lt;WebCore/EditorClient.h&gt;
</span><span class="cx"> #import &lt;WebCore/TextCheckerClient.h&gt;
</span><ins>+#import &lt;WebCore/VisibleSelection.h&gt;
</ins><span class="cx"> #import &lt;wtf/Forward.h&gt;
</span><span class="cx"> #import &lt;wtf/RetainPtr.h&gt;
</span><span class="cx"> #import &lt;wtf/Vector.h&gt;
</span><ins>+#import &lt;wtf/WeakPtr.h&gt;
</ins><span class="cx"> #import &lt;wtf/text/StringView.h&gt;
</span><span class="cx"> 
</span><span class="cx"> #if PLATFORM(IOS)
</span><span class="lines">@@ -167,6 +169,12 @@
</span><span class="cx">     virtual void setInputMethodState(bool enabled) override;
</span><span class="cx">     virtual void requestCheckingOfString(PassRefPtr&lt;WebCore::TextCheckingRequest&gt;) override;
</span><span class="cx"> 
</span><ins>+#if PLATFORM(MAC) &amp;&amp; __MAC_OS_X_VERSION_MIN_REQUIRED &gt;= 101200
+    virtual void requestCandidatesForSelection(const WebCore::VisibleSelection&amp;) override;
+    void handleRequestedCandidates(NSInteger, NSArray&lt;NSTextCheckingResult *&gt; *);
+    void handleAcceptedCandidate(NSTextCheckingResult *);
+#endif
+
</ins><span class="cx">     void registerUndoOrRedoStep(PassRefPtr&lt;WebCore::UndoStep&gt;, bool isRedo);
</span><span class="cx"> 
</span><span class="cx">     WebView *m_webView;
</span><span class="lines">@@ -177,6 +185,10 @@
</span><span class="cx">     bool m_delayingContentChangeNotifications;
</span><span class="cx">     bool m_hasDelayedContentChangeNotification;
</span><span class="cx"> #endif
</span><ins>+
+    WebCore::VisibleSelection m_lastSelectionForRequestedCandidates;
+
+    WeakPtrFactory&lt;WebEditorClient&gt; m_weakPtrFactory;
</ins><span class="cx"> };
</span><span class="cx"> 
</span><span class="cx"> #if PLATFORM(COCOA)
</span></span></pre></div>
<a id="trunkSourceWebKitmacWebCoreSupportWebEditorClientmm"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit/mac/WebCoreSupport/WebEditorClient.mm (193644 => 193645)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit/mac/WebCoreSupport/WebEditorClient.mm        2015-12-07 20:35:09 UTC (rev 193644)
+++ trunk/Source/WebKit/mac/WebCoreSupport/WebEditorClient.mm        2015-12-07 20:37:03 UTC (rev 193645)
</span><span class="lines">@@ -54,18 +54,25 @@
</span><span class="cx"> #import &lt;WebCore/ArchiveResource.h&gt;
</span><span class="cx"> #import &lt;WebCore/Document.h&gt;
</span><span class="cx"> #import &lt;WebCore/DocumentFragment.h&gt;
</span><ins>+#import &lt;WebCore/Editor.h&gt;
+#import &lt;WebCore/FloatQuad.h&gt;
+#import &lt;WebCore/Frame.h&gt;
+#import &lt;WebCore/FrameView.h&gt;
</ins><span class="cx"> #import &lt;WebCore/HTMLInputElement.h&gt;
</span><span class="cx"> #import &lt;WebCore/HTMLNames.h&gt;
</span><span class="cx"> #import &lt;WebCore/HTMLTextAreaElement.h&gt;
</span><span class="cx"> #import &lt;WebCore/KeyboardEvent.h&gt;
</span><span class="cx"> #import &lt;WebCore/LegacyWebArchive.h&gt;
</span><ins>+#import &lt;WebCore/NSSpellCheckerSPI.h&gt;
</ins><span class="cx"> #import &lt;WebCore/Page.h&gt;
</span><span class="cx"> #import &lt;WebCore/PlatformKeyboardEvent.h&gt;
</span><span class="cx"> #import &lt;WebCore/Settings.h&gt;
</span><span class="cx"> #import &lt;WebCore/SpellChecker.h&gt;
</span><span class="cx"> #import &lt;WebCore/StyleProperties.h&gt;
</span><ins>+#import &lt;WebCore/TextIterator.h&gt;
</ins><span class="cx"> #import &lt;WebCore/UndoStep.h&gt;
</span><span class="cx"> #import &lt;WebCore/UserTypingGestureIndicator.h&gt;
</span><ins>+#import &lt;WebCore/VisibleUnits.h&gt;
</ins><span class="cx"> #import &lt;WebCore/WebCoreObjCExtras.h&gt;
</span><span class="cx"> #import &lt;runtime/InitializeThreading.h&gt;
</span><span class="cx"> #import &lt;wtf/MainThread.h&gt;
</span><span class="lines">@@ -189,6 +196,7 @@
</span><span class="cx">     , m_delayingContentChangeNotifications(0)
</span><span class="cx">     , m_hasDelayedContentChangeNotification(0)
</span><span class="cx"> #endif
</span><ins>+    , m_weakPtrFactory(this)
</ins><span class="cx"> {
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="lines">@@ -1103,6 +1111,114 @@
</span><span class="cx"> {
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+#if PLATFORM(MAC) &amp;&amp; __MAC_OS_X_VERSION_MIN_REQUIRED &gt;= 101200
+void WebEditorClient::requestCandidatesForSelection(const VisibleSelection&amp; selection)
+{
+    RefPtr&lt;Range&gt; selectedRange = selection.toNormalizedRange();
+    if (!selectedRange)
+        return;
+
+    m_lastSelectionForRequestedCandidates = selection;
+
+    VisiblePosition selectionStart = selection.visibleStart();
+    VisiblePosition selectionEnd = selection.visibleEnd();
+
+    // Use the surrounding paragraphs of text as context.
+    VisiblePosition paragraphStart = startOfParagraph(selectionStart);
+    VisiblePosition paragraphEnd = endOfParagraph(selectionEnd);
+
+    int lengthToSelectionStart = TextIterator::rangeLength(makeRange(paragraphStart, selectionStart).get());
+    int lengthToSelectionEnd = TextIterator::rangeLength(makeRange(paragraphStart, selectionEnd).get());
+    NSRange rangeForCandidates = NSMakeRange(lengthToSelectionStart, lengthToSelectionEnd - lengthToSelectionStart);
+
+    String fullPlainTextStringOfParagraph = plainText(makeRange(paragraphStart, paragraphEnd).get());
+
+    NSTextCheckingTypes checkingTypes = NSTextCheckingTypeSpelling | NSTextCheckingTypeReplacement | NSTextCheckingTypeCorrection;
+    auto weakEditor = m_weakPtrFactory.createWeakPtr();
+    [[NSSpellChecker sharedSpellChecker] requestCandidatesForSelectedRange:rangeForCandidates inString:fullPlainTextStringOfParagraph types:checkingTypes options:nil inSpellDocumentWithTag:spellCheckerDocumentTag() completionHandler:[weakEditor](NSInteger sequenceNumber, NSArray&lt;NSTextCheckingResult *&gt; *candidates) {
+        dispatch_async(dispatch_get_main_queue(), ^{
+            if (!weakEditor)
+                return;
+            weakEditor-&gt;handleRequestedCandidates(sequenceNumber, candidates);
+        });
+    }];
+}
+
+static RefPtr&lt;Range&gt; candidateRangeForSelection(const VisibleSelection&amp; selection, Frame* frame)
+{
+    return selection.isCaret() ? wordRangeFromPosition(selection.start()) : frame-&gt;selection().toNormalizedRange();
+}
+
+static bool candidateWouldReplaceText(const VisibleSelection&amp; selection)
+{
+    // If the character behind the caret in the current selection is anything but a space or a newline then we should
+    // replace the whole current word with the candidate.
+    UChar32 characterAfterSelection, characterBeforeSelection, twoCharacterBeforeSelection = 0;
+    charactersAroundPosition(selection.visibleStart(), characterAfterSelection, characterBeforeSelection, twoCharacterBeforeSelection);
+    return !(characterBeforeSelection == '\0' || characterBeforeSelection == '\n' || characterBeforeSelection == ' ');
+}
+
+void WebEditorClient::handleRequestedCandidates(NSInteger sequenceNumber, NSArray&lt;NSTextCheckingResult *&gt; *candidates)
+{
+    Frame* frame = core([m_webView _selectedOrMainFrame]);
+    if (!frame)
+        return;
+
+    const VisibleSelection&amp; selection = frame-&gt;selection().selection();
+    if (selection != m_lastSelectionForRequestedCandidates)
+        return;
+
+    RefPtr&lt;Range&gt; rangeForCurrentlyTypedString = candidateRangeForSelection(selection, frame);
+    NSString *currentlyTypedString;
+    if (rangeForCurrentlyTypedString &amp;&amp; candidateWouldReplaceText(selection))
+        currentlyTypedString = plainText(rangeForCurrentlyTypedString.get());
+    else
+        currentlyTypedString = @&quot;&quot;;
+
+    RefPtr&lt;Range&gt; selectedRange = frame-&gt;selection().selection().toNormalizedRange();
+    if (!selectedRange)
+        return;
+
+    IntRect rectForSelectionCandidates;
+    Vector&lt;FloatQuad&gt; quads;
+    selectedRange-&gt;absoluteTextQuads(quads);
+    if (!quads.isEmpty())
+        rectForSelectionCandidates = frame-&gt;view()-&gt;contentsToWindow(quads[0].enclosingBoundingBox());
+
+    auto weakEditor = m_weakPtrFactory.createWeakPtr();
+    [[NSSpellChecker sharedSpellChecker] showCandidates:candidates forString:currentlyTypedString inRect:rectForSelectionCandidates view:m_webView completionHandler:[weakEditor](NSTextCheckingResult *acceptedCandidate) {
+        dispatch_async(dispatch_get_main_queue(), ^{
+            if (!weakEditor)
+                return;
+            weakEditor-&gt;handleAcceptedCandidate(acceptedCandidate);
+        });
+    }];
+
+}
+
+void WebEditorClient::handleAcceptedCandidate(NSTextCheckingResult *acceptedCandidate)
+{
+    Frame* frame = core([m_webView _selectedOrMainFrame]);
+    if (!frame)
+        return;
+
+    const VisibleSelection&amp; selection = frame-&gt;selection().selection();
+    if (selection != m_lastSelectionForRequestedCandidates)
+        return;
+
+    RefPtr&lt;Range&gt; candidateRange = candidateRangeForSelection(selection, frame);
+
+    frame-&gt;editor().setIgnoreCompositionSelectionChange(true);
+
+    if (candidateWouldReplaceText(selection))
+        frame-&gt;selection().setSelectedRange(candidateRange.get(), UPSTREAM, true);
+
+    frame-&gt;editor().insertText(acceptedCandidate.replacementString, 0);
+    frame-&gt;editor().insertText(String(&quot; &quot;), 0);
+    frame-&gt;editor().setIgnoreCompositionSelectionChange(false);
+}
+#endif // PLATFORM(MAC) &amp;&amp; __MAC_OS_X_VERSION_MIN_REQUIRED &gt;= 101200
+
</ins><span class="cx"> #if !PLATFORM(IOS)
</span><span class="cx"> @interface WebEditorSpellCheckResponder : NSObject
</span><span class="cx"> {
</span></span></pre></div>
<a id="trunkSourceWebKit2ChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/ChangeLog (193644 => 193645)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/ChangeLog        2015-12-07 20:35:09 UTC (rev 193644)
+++ trunk/Source/WebKit2/ChangeLog        2015-12-07 20:37:03 UTC (rev 193645)
</span><span class="lines">@@ -1,3 +1,15 @@
</span><ins>+2015-12-07  Beth Dakin  &lt;bdakin@apple.com&gt;
+
+        Hook up request and show for typing candidates in WK1
+        https://bugs.webkit.org/show_bug.cgi?id=151831
+        -and corresponding-
+        &lt;rdar://problem/23751214&gt;
+
+        Reviewed by Enrica Casucci.
+
+        Empty client for now.
+        * WebProcess/WebCoreSupport/WebEditorClient.h:
+
</ins><span class="cx"> 2015-12-07  Philippe Normand  &lt;pnormand@igalia.com&gt;
</span><span class="cx"> 
</span><span class="cx">         [GTK][Mac] socketpair assertion failure
</span></span></pre></div>
<a id="trunkSourceWebKit2WebProcessWebCoreSupportWebEditorClienth"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/WebProcess/WebCoreSupport/WebEditorClient.h (193644 => 193645)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/WebProcess/WebCoreSupport/WebEditorClient.h        2015-12-07 20:35:09 UTC (rev 193644)
+++ trunk/Source/WebKit2/WebProcess/WebCoreSupport/WebEditorClient.h        2015-12-07 20:37:03 UTC (rev 193645)
</span><span class="lines">@@ -149,6 +149,11 @@
</span><span class="cx">     virtual void willSetInputMethodState() override;
</span><span class="cx">     virtual void setInputMethodState(bool enabled) override;
</span><span class="cx">     virtual void requestCheckingOfString(WTF::PassRefPtr&lt;WebCore::TextCheckingRequest&gt;) override;
</span><ins>+
+#if PLATFORM(MAC) &amp;&amp; __MAC_OS_X_VERSION_MIN_REQUIRED &gt;= 101200
+    virtual void requestCandidatesForSelection(const WebCore::VisibleSelection&amp;) override { }
+#endif
+
</ins><span class="cx"> #if PLATFORM(GTK)
</span><span class="cx">     virtual bool shouldShowUnicodeMenu() override;
</span><span class="cx"> #endif
</span></span></pre>
</div>
</div>

</body>
</html>