<!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>[193848] tags/Safari-602.1.13.2/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/193848">193848</a></dd>
<dt>Author</dt> <dd>bshafiei@apple.com</dd>
<dt>Date</dt> <dd>2015-12-09 11:48:32 -0800 (Wed, 09 Dec 2015)</dd>
</dl>
<h3>Log Message</h3>
<pre>Merged <a href="http://trac.webkit.org/projects/webkit/changeset/193645">r193645</a>. rdar://problem/23751214</pre>
<h3>Modified Paths</h3>
<ul>
<li><a href="#tagsSafari6021132SourceWebCoreChangeLog">tags/Safari-602.1.13.2/Source/WebCore/ChangeLog</a></li>
<li><a href="#tagsSafari6021132SourceWebCoreWebCorexcodeprojprojectpbxproj">tags/Safari-602.1.13.2/Source/WebCore/WebCore.xcodeproj/project.pbxproj</a></li>
<li><a href="#tagsSafari6021132SourceWebCoreeditingEditorcpp">tags/Safari-602.1.13.2/Source/WebCore/editing/Editor.cpp</a></li>
<li><a href="#tagsSafari6021132SourceWebCoreloaderEmptyClientsh">tags/Safari-602.1.13.2/Source/WebCore/loader/EmptyClients.h</a></li>
<li><a href="#tagsSafari6021132SourceWebCorepageEditorClienth">tags/Safari-602.1.13.2/Source/WebCore/page/EditorClient.h</a></li>
<li><a href="#tagsSafari6021132SourceWebKitmacChangeLog">tags/Safari-602.1.13.2/Source/WebKit/mac/ChangeLog</a></li>
<li><a href="#tagsSafari6021132SourceWebKitmacWebCoreSupportWebEditorClienth">tags/Safari-602.1.13.2/Source/WebKit/mac/WebCoreSupport/WebEditorClient.h</a></li>
<li><a href="#tagsSafari6021132SourceWebKitmacWebCoreSupportWebEditorClientmm">tags/Safari-602.1.13.2/Source/WebKit/mac/WebCoreSupport/WebEditorClient.mm</a></li>
<li><a href="#tagsSafari6021132SourceWebKit2ChangeLog">tags/Safari-602.1.13.2/Source/WebKit2/ChangeLog</a></li>
<li><a href="#tagsSafari6021132SourceWebKit2WebProcessWebCoreSupportWebEditorClienth">tags/Safari-602.1.13.2/Source/WebKit2/WebProcess/WebCoreSupport/WebEditorClient.h</a></li>
</ul>
<h3>Added Paths</h3>
<ul>
<li><a href="#tagsSafari6021132SourceWebCoreplatformspimacNSSpellCheckerSPIh">tags/Safari-602.1.13.2/Source/WebCore/platform/spi/mac/NSSpellCheckerSPI.h</a></li>
</ul>
</div>
<div id="patch">
<h3>Diff</h3>
<a id="tagsSafari6021132SourceWebCoreChangeLog"></a>
<div class="modfile"><h4>Modified: tags/Safari-602.1.13.2/Source/WebCore/ChangeLog (193847 => 193848)</h4>
<pre class="diff"><span>
<span class="info">--- tags/Safari-602.1.13.2/Source/WebCore/ChangeLog        2015-12-09 19:20:49 UTC (rev 193847)
+++ tags/Safari-602.1.13.2/Source/WebCore/ChangeLog        2015-12-09 19:48:32 UTC (rev 193848)
</span><span class="lines">@@ -1,3 +1,29 @@
</span><ins>+2015-12-09 Babak Shafiei <bshafiei@apple.com>
+
+ Merge r193645.
+
+ 2015-12-07 Beth Dakin <bdakin@apple.com>
+
+ Hook up request and show for typing candidates in WK1
+ https://bugs.webkit.org/show_bug.cgi?id=151831
+ -and corresponding-
+ <rdar://problem/23751214>
+
+ 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-08 Babak Shafiei <bshafiei@apple.com>
</span><span class="cx">
</span><span class="cx"> Roll out r193645.
</span></span></pre></div>
<a id="tagsSafari6021132SourceWebCoreWebCorexcodeprojprojectpbxproj"></a>
<div class="modfile"><h4>Modified: tags/Safari-602.1.13.2/Source/WebCore/WebCore.xcodeproj/project.pbxproj (193847 => 193848)</h4>
<pre class="diff"><span>
<span class="info">--- tags/Safari-602.1.13.2/Source/WebCore/WebCore.xcodeproj/project.pbxproj        2015-12-09 19:20:49 UTC (rev 193847)
+++ tags/Safari-602.1.13.2/Source/WebCore/WebCore.xcodeproj/project.pbxproj        2015-12-09 19:48:32 UTC (rev 193848)
</span><span class="lines">@@ -3571,6 +3571,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">@@ -11095,6 +11096,7 @@
</span><span class="cx">                 933A14A90B7D1D0900A53FFD /* DOMTextEvent.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = DOMTextEvent.mm; sourceTree = "<group>"; };
</span><span class="cx">                 933A14B60B7D1D5200A53FFD /* JSTextEvent.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSTextEvent.cpp; sourceTree = "<group>"; };
</span><span class="cx">                 933A14B70B7D1D5200A53FFD /* JSTextEvent.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSTextEvent.h; sourceTree = "<group>"; };
</span><ins>+                933C7A741C0FBC440034FB97 /* NSSpellCheckerSPI.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = NSSpellCheckerSPI.h; sourceTree = "<group>"; };
</ins><span class="cx">                 9343CB7F12F25E510033C5EE /* TextCodecUTF8.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = TextCodecUTF8.cpp; sourceTree = "<group>"; };
</span><span class="cx">                 9343CB8012F25E510033C5EE /* TextCodecUTF8.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TextCodecUTF8.h; sourceTree = "<group>"; };
</span><span class="cx">                 93442C9D0D2B335C00338FF9 /* HTMLTableRowsCollection.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = HTMLTableRowsCollection.h; sourceTree = "<group>"; };
</span><span class="lines">@@ -18737,6 +18739,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">@@ -27756,6 +27759,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="tagsSafari6021132SourceWebCoreeditingEditorcpp"></a>
<div class="modfile"><h4>Modified: tags/Safari-602.1.13.2/Source/WebCore/editing/Editor.cpp (193847 => 193848)</h4>
<pre class="diff"><span>
<span class="info">--- tags/Safari-602.1.13.2/Source/WebCore/editing/Editor.cpp        2015-12-09 19:20:49 UTC (rev 193847)
+++ tags/Safari-602.1.13.2/Source/WebCore/editing/Editor.cpp        2015-12-09 19:48:32 UTC (rev 193848)
</span><span class="lines">@@ -3264,6 +3264,11 @@
</span><span class="cx"> if (client())
</span><span class="cx"> client()->respondToChangedSelection(&m_frame);
</span><span class="cx">
</span><ins>+#if PLATFORM(MAC) && __MAC_OS_X_VERSION_MIN_REQUIRED >= 101200
+ if (client() && canEdit())
+ client()->requestCandidatesForSelection(m_frame.selection().selection());
+#endif
+
</ins><span class="cx"> #if ENABLE(TELEPHONE_NUMBER_DETECTION) && !PLATFORM(IOS)
</span><span class="cx"> if (shouldDetectTelephoneNumbers())
</span><span class="cx"> m_telephoneNumberDetectionUpdateTimer.startOneShot(0);
</span></span></pre></div>
<a id="tagsSafari6021132SourceWebCoreloaderEmptyClientsh"></a>
<div class="modfile"><h4>Modified: tags/Safari-602.1.13.2/Source/WebCore/loader/EmptyClients.h (193847 => 193848)</h4>
<pre class="diff"><span>
<span class="info">--- tags/Safari-602.1.13.2/Source/WebCore/loader/EmptyClients.h        2015-12-09 19:20:49 UTC (rev 193847)
+++ tags/Safari-602.1.13.2/Source/WebCore/loader/EmptyClients.h        2015-12-09 19:48:32 UTC (rev 193848)
</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) && __MAC_OS_X_VERSION_MIN_REQUIRED >= 101200
+ virtual void requestCandidatesForSelection(const VisibleSelection&) override { }
+#endif
+
</ins><span class="cx"> private:
</span><span class="cx"> EmptyTextCheckerClient m_textCheckerClient;
</span><span class="cx"> };
</span></span></pre></div>
<a id="tagsSafari6021132SourceWebCorepageEditorClienth"></a>
<div class="modfile"><h4>Modified: tags/Safari-602.1.13.2/Source/WebCore/page/EditorClient.h (193847 => 193848)</h4>
<pre class="diff"><span>
<span class="info">--- tags/Safari-602.1.13.2/Source/WebCore/page/EditorClient.h        2015-12-09 19:20:49 UTC (rev 193847)
+++ tags/Safari-602.1.13.2/Source/WebCore/page/EditorClient.h        2015-12-09 19:48:32 UTC (rev 193848)
</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) && __MAC_OS_X_VERSION_MIN_REQUIRED >= 101200
+ virtual void requestCandidatesForSelection(const VisibleSelection&) = 0;
+#endif
</ins><span class="cx"> };
</span><span class="cx">
</span><span class="cx"> }
</span></span></pre></div>
<a id="tagsSafari6021132SourceWebCoreplatformspimacNSSpellCheckerSPIhfromrev193645trunkSourceWebCoreplatformspimacNSSpellCheckerSPIh"></a>
<div class="copfile"><h4>Copied: tags/Safari-602.1.13.2/Source/WebCore/platform/spi/mac/NSSpellCheckerSPI.h (from rev 193645, trunk/Source/WebCore/platform/spi/mac/NSSpellCheckerSPI.h) (0 => 193848)</h4>
<pre class="diff"><span>
<span class="info">--- tags/Safari-602.1.13.2/Source/WebCore/platform/spi/mac/NSSpellCheckerSPI.h         (rev 0)
+++ tags/Safari-602.1.13.2/Source/WebCore/platform/spi/mac/NSSpellCheckerSPI.h        2015-12-09 19:48:32 UTC (rev 193848)
</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) && __MAC_OS_X_VERSION_MIN_REQUIRED >= 101200
+
+// FIXME: This header should include system headers when possible.
+
+@interface NSSpellChecker ()
+- (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;
+- (void)showCandidates:(NSArray<NSTextCheckingResult *> *)candidates forString:(NSString *)string inRect:(NSRect)rectOfTypedString view:(NSView *)view completionHandler:(void (^)(NSTextCheckingResult *acceptedCandidate))completionBlock;
+@end
+
+#endif // PLATFORM(MAC) && __MAC_OS_X_VERSION_MIN_REQUIRED >= 102000
+
+#endif // NSSpellCheckerSPI_h
</ins></span></pre></div>
<a id="tagsSafari6021132SourceWebKitmacChangeLog"></a>
<div class="modfile"><h4>Modified: tags/Safari-602.1.13.2/Source/WebKit/mac/ChangeLog (193847 => 193848)</h4>
<pre class="diff"><span>
<span class="info">--- tags/Safari-602.1.13.2/Source/WebKit/mac/ChangeLog        2015-12-09 19:20:49 UTC (rev 193847)
+++ tags/Safari-602.1.13.2/Source/WebKit/mac/ChangeLog        2015-12-09 19:48:32 UTC (rev 193848)
</span><span class="lines">@@ -1,3 +1,40 @@
</span><ins>+2015-12-09 Babak Shafiei <bshafiei@apple.com>
+
+ Merge r193645.
+
+ 2015-12-07 Beth Dakin <bdakin@apple.com>
+
+ Hook up request and show for typing candidates in WK1
+ https://bugs.webkit.org/show_bug.cgi?id=151831
+ -and corresponding-
+ <rdar://problem/23751214>
+
+ 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-08 Babak Shafiei <bshafiei@apple.com>
</span><span class="cx">
</span><span class="cx"> Roll out r193661.
</span></span></pre></div>
<a id="tagsSafari6021132SourceWebKitmacWebCoreSupportWebEditorClienth"></a>
<div class="modfile"><h4>Modified: tags/Safari-602.1.13.2/Source/WebKit/mac/WebCoreSupport/WebEditorClient.h (193847 => 193848)</h4>
<pre class="diff"><span>
<span class="info">--- tags/Safari-602.1.13.2/Source/WebKit/mac/WebCoreSupport/WebEditorClient.h        2015-12-09 19:20:49 UTC (rev 193847)
+++ tags/Safari-602.1.13.2/Source/WebKit/mac/WebCoreSupport/WebEditorClient.h        2015-12-09 19:48:32 UTC (rev 193848)
</span><span class="lines">@@ -29,9 +29,11 @@
</span><span class="cx">
</span><span class="cx"> #import <WebCore/EditorClient.h>
</span><span class="cx"> #import <WebCore/TextCheckerClient.h>
</span><ins>+#import <WebCore/VisibleSelection.h>
</ins><span class="cx"> #import <wtf/Forward.h>
</span><span class="cx"> #import <wtf/RetainPtr.h>
</span><span class="cx"> #import <wtf/Vector.h>
</span><ins>+#import <wtf/WeakPtr.h>
</ins><span class="cx"> #import <wtf/text/StringView.h>
</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<WebCore::TextCheckingRequest>) override;
</span><span class="cx">
</span><ins>+#if PLATFORM(MAC) && __MAC_OS_X_VERSION_MIN_REQUIRED >= 101200
+ virtual void requestCandidatesForSelection(const WebCore::VisibleSelection&) override;
+ void handleRequestedCandidates(NSInteger, NSArray<NSTextCheckingResult *> *);
+ void handleAcceptedCandidate(NSTextCheckingResult *);
+#endif
+
</ins><span class="cx"> void registerUndoOrRedoStep(PassRefPtr<WebCore::UndoStep>, 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<WebEditorClient> m_weakPtrFactory;
</ins><span class="cx"> };
</span><span class="cx">
</span><span class="cx"> #if PLATFORM(COCOA)
</span></span></pre></div>
<a id="tagsSafari6021132SourceWebKitmacWebCoreSupportWebEditorClientmm"></a>
<div class="modfile"><h4>Modified: tags/Safari-602.1.13.2/Source/WebKit/mac/WebCoreSupport/WebEditorClient.mm (193847 => 193848)</h4>
<pre class="diff"><span>
<span class="info">--- tags/Safari-602.1.13.2/Source/WebKit/mac/WebCoreSupport/WebEditorClient.mm        2015-12-09 19:20:49 UTC (rev 193847)
+++ tags/Safari-602.1.13.2/Source/WebKit/mac/WebCoreSupport/WebEditorClient.mm        2015-12-09 19:48:32 UTC (rev 193848)
</span><span class="lines">@@ -54,18 +54,25 @@
</span><span class="cx"> #import <WebCore/ArchiveResource.h>
</span><span class="cx"> #import <WebCore/Document.h>
</span><span class="cx"> #import <WebCore/DocumentFragment.h>
</span><ins>+#import <WebCore/Editor.h>
+#import <WebCore/FloatQuad.h>
+#import <WebCore/Frame.h>
+#import <WebCore/FrameView.h>
</ins><span class="cx"> #import <WebCore/HTMLInputElement.h>
</span><span class="cx"> #import <WebCore/HTMLNames.h>
</span><span class="cx"> #import <WebCore/HTMLTextAreaElement.h>
</span><span class="cx"> #import <WebCore/KeyboardEvent.h>
</span><span class="cx"> #import <WebCore/LegacyWebArchive.h>
</span><ins>+#import <WebCore/NSSpellCheckerSPI.h>
</ins><span class="cx"> #import <WebCore/Page.h>
</span><span class="cx"> #import <WebCore/PlatformKeyboardEvent.h>
</span><span class="cx"> #import <WebCore/Settings.h>
</span><span class="cx"> #import <WebCore/SpellChecker.h>
</span><span class="cx"> #import <WebCore/StyleProperties.h>
</span><ins>+#import <WebCore/TextIterator.h>
</ins><span class="cx"> #import <WebCore/UndoStep.h>
</span><span class="cx"> #import <WebCore/UserTypingGestureIndicator.h>
</span><ins>+#import <WebCore/VisibleUnits.h>
</ins><span class="cx"> #import <WebCore/WebCoreObjCExtras.h>
</span><span class="cx"> #import <runtime/InitializeThreading.h>
</span><span class="cx"> #import <wtf/MainThread.h>
</span><span class="lines">@@ -195,6 +202,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">@@ -1109,6 +1117,114 @@
</span><span class="cx"> {
</span><span class="cx"> }
</span><span class="cx">
</span><ins>+#if PLATFORM(MAC) && __MAC_OS_X_VERSION_MIN_REQUIRED >= 101200
+void WebEditorClient::requestCandidatesForSelection(const VisibleSelection& selection)
+{
+ RefPtr<Range> 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<NSTextCheckingResult *> *candidates) {
+ dispatch_async(dispatch_get_main_queue(), ^{
+ if (!weakEditor)
+ return;
+ weakEditor->handleRequestedCandidates(sequenceNumber, candidates);
+ });
+ }];
+}
+
+static RefPtr<Range> candidateRangeForSelection(const VisibleSelection& selection, Frame* frame)
+{
+ return selection.isCaret() ? wordRangeFromPosition(selection.start()) : frame->selection().toNormalizedRange();
+}
+
+static bool candidateWouldReplaceText(const VisibleSelection& 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<NSTextCheckingResult *> *candidates)
+{
+ Frame* frame = core([m_webView _selectedOrMainFrame]);
+ if (!frame)
+ return;
+
+ const VisibleSelection& selection = frame->selection().selection();
+ if (selection != m_lastSelectionForRequestedCandidates)
+ return;
+
+ RefPtr<Range> rangeForCurrentlyTypedString = candidateRangeForSelection(selection, frame);
+ NSString *currentlyTypedString;
+ if (rangeForCurrentlyTypedString && candidateWouldReplaceText(selection))
+ currentlyTypedString = plainText(rangeForCurrentlyTypedString.get());
+ else
+ currentlyTypedString = @"";
+
+ RefPtr<Range> selectedRange = frame->selection().selection().toNormalizedRange();
+ if (!selectedRange)
+ return;
+
+ IntRect rectForSelectionCandidates;
+ Vector<FloatQuad> quads;
+ selectedRange->absoluteTextQuads(quads);
+ if (!quads.isEmpty())
+ rectForSelectionCandidates = frame->view()->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->handleAcceptedCandidate(acceptedCandidate);
+ });
+ }];
+
+}
+
+void WebEditorClient::handleAcceptedCandidate(NSTextCheckingResult *acceptedCandidate)
+{
+ Frame* frame = core([m_webView _selectedOrMainFrame]);
+ if (!frame)
+ return;
+
+ const VisibleSelection& selection = frame->selection().selection();
+ if (selection != m_lastSelectionForRequestedCandidates)
+ return;
+
+ RefPtr<Range> candidateRange = candidateRangeForSelection(selection, frame);
+
+ frame->editor().setIgnoreCompositionSelectionChange(true);
+
+ if (candidateWouldReplaceText(selection))
+ frame->selection().setSelectedRange(candidateRange.get(), UPSTREAM, true);
+
+ frame->editor().insertText(acceptedCandidate.replacementString, 0);
+ frame->editor().insertText(String(" "), 0);
+ frame->editor().setIgnoreCompositionSelectionChange(false);
+}
+#endif // PLATFORM(MAC) && __MAC_OS_X_VERSION_MIN_REQUIRED >= 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="tagsSafari6021132SourceWebKit2ChangeLog"></a>
<div class="modfile"><h4>Modified: tags/Safari-602.1.13.2/Source/WebKit2/ChangeLog (193847 => 193848)</h4>
<pre class="diff"><span>
<span class="info">--- tags/Safari-602.1.13.2/Source/WebKit2/ChangeLog        2015-12-09 19:20:49 UTC (rev 193847)
+++ tags/Safari-602.1.13.2/Source/WebKit2/ChangeLog        2015-12-09 19:48:32 UTC (rev 193848)
</span><span class="lines">@@ -1,3 +1,19 @@
</span><ins>+2015-12-09 Babak Shafiei <bshafiei@apple.com>
+
+ Merge r193645.
+
+ 2015-12-07 Beth Dakin <bdakin@apple.com>
+
+ Hook up request and show for typing candidates in WK1
+ https://bugs.webkit.org/show_bug.cgi?id=151831
+ -and corresponding-
+ <rdar://problem/23751214>
+
+ Reviewed by Enrica Casucci.
+
+ Empty client for now.
+ * WebProcess/WebCoreSupport/WebEditorClient.h:
+
</ins><span class="cx"> 2015-12-08 Babak Shafiei <bshafiei@apple.com>
</span><span class="cx">
</span><span class="cx"> Roll out r193645.
</span></span></pre></div>
<a id="tagsSafari6021132SourceWebKit2WebProcessWebCoreSupportWebEditorClienth"></a>
<div class="modfile"><h4>Modified: tags/Safari-602.1.13.2/Source/WebKit2/WebProcess/WebCoreSupport/WebEditorClient.h (193847 => 193848)</h4>
<pre class="diff"><span>
<span class="info">--- tags/Safari-602.1.13.2/Source/WebKit2/WebProcess/WebCoreSupport/WebEditorClient.h        2015-12-09 19:20:49 UTC (rev 193847)
+++ tags/Safari-602.1.13.2/Source/WebKit2/WebProcess/WebCoreSupport/WebEditorClient.h        2015-12-09 19:48:32 UTC (rev 193848)
</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<WebCore::TextCheckingRequest>) override;
</span><ins>+
+#if PLATFORM(MAC) && __MAC_OS_X_VERSION_MIN_REQUIRED >= 101200
+ virtual void requestCandidatesForSelection(const WebCore::VisibleSelection&) 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>