Title: [193645] trunk/Source
Revision
193645
Author
[email protected]
Date
2015-12-07 12:37:03 -0800 (Mon, 07 Dec 2015)

Log Message

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.

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:

Modified Paths

Added Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (193644 => 193645)


--- 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)
@@ -1,3 +1,25 @@
+2015-12-07  Beth Dakin  <[email protected]>
+
+        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):
+
 2015-12-07  Brady Eidson  <[email protected]>
 
         Modern IDB: Fix "old versions" when upgrading databases.

Modified: trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj (193644 => 193645)


--- 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)
@@ -3556,6 +3556,7 @@
 		933A14AA0B7D1D0900A53FFD /* DOMTextEvent.mm in Sources */ = {isa = PBXBuildFile; fileRef = 933A14A90B7D1D0900A53FFD /* DOMTextEvent.mm */; };
 		933A14B80B7D1D5200A53FFD /* JSTextEvent.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 933A14B60B7D1D5200A53FFD /* JSTextEvent.cpp */; };
 		933A14B90B7D1D5200A53FFD /* JSTextEvent.h in Headers */ = {isa = PBXBuildFile; fileRef = 933A14B70B7D1D5200A53FFD /* JSTextEvent.h */; };
+		933C7A751C0FBC440034FB97 /* NSSpellCheckerSPI.h in Headers */ = {isa = PBXBuildFile; fileRef = 933C7A741C0FBC440034FB97 /* NSSpellCheckerSPI.h */; settings = {ATTRIBUTES = (Private, ); }; };
 		9343CB8112F25E510033C5EE /* TextCodecUTF8.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 9343CB7F12F25E510033C5EE /* TextCodecUTF8.cpp */; };
 		9343CB8212F25E510033C5EE /* TextCodecUTF8.h in Headers */ = {isa = PBXBuildFile; fileRef = 9343CB8012F25E510033C5EE /* TextCodecUTF8.h */; };
 		93442C9E0D2B335C00338FF9 /* HTMLTableRowsCollection.h in Headers */ = {isa = PBXBuildFile; fileRef = 93442C9D0D2B335C00338FF9 /* HTMLTableRowsCollection.h */; };
@@ -11050,6 +11051,7 @@
 		933A14A90B7D1D0900A53FFD /* DOMTextEvent.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = DOMTextEvent.mm; sourceTree = "<group>"; };
 		933A14B60B7D1D5200A53FFD /* JSTextEvent.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSTextEvent.cpp; sourceTree = "<group>"; };
 		933A14B70B7D1D5200A53FFD /* JSTextEvent.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSTextEvent.h; sourceTree = "<group>"; };
+		933C7A741C0FBC440034FB97 /* NSSpellCheckerSPI.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = NSSpellCheckerSPI.h; sourceTree = "<group>"; };
 		9343CB7F12F25E510033C5EE /* TextCodecUTF8.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = TextCodecUTF8.cpp; sourceTree = "<group>"; };
 		9343CB8012F25E510033C5EE /* TextCodecUTF8.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TextCodecUTF8.h; sourceTree = "<group>"; };
 		93442C9D0D2B335C00338FF9 /* HTMLTableRowsCollection.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = HTMLTableRowsCollection.h; sourceTree = "<group>"; };
@@ -18656,6 +18658,7 @@
 				F40EA8AA1B867D6500CE5581 /* NSScrollingInputFilterSPI.h */,
 				2DCB837719F99BBA00A7FBE4 /* NSSharingServicePickerSPI.h */,
 				2DCB837819F99BBA00A7FBE4 /* NSSharingServiceSPI.h */,
+				933C7A741C0FBC440034FB97 /* NSSpellCheckerSPI.h */,
 				2D77AC281BF2B9860072470A /* NSTextFinderSPI.h */,
 				2D77AC2C1BF2B9A00072470A /* NSViewSPI.h */,
 				2D0CF8161BCF5DE1007A4937 /* NSWindowSPI.h */,
@@ -27665,6 +27668,7 @@
 				83C1D430178D5AB500141E68 /* SVGPathSegLinetoHorizontalAbs.h in Headers */,
 				83C1D431178D5AB500141E68 /* SVGPathSegLinetoHorizontalRel.h in Headers */,
 				83C1D432178D5AB500141E68 /* SVGPathSegLinetoRel.h in Headers */,
+				933C7A751C0FBC440034FB97 /* NSSpellCheckerSPI.h in Headers */,
 				B2227A7D0D00BF220071B782 /* SVGPathSegLinetoVertical.h in Headers */,
 				83C1D433178D5AB500141E68 /* SVGPathSegLinetoVerticalAbs.h in Headers */,
 				83C1D434178D5AB500141E68 /* SVGPathSegLinetoVerticalRel.h in Headers */,

Modified: trunk/Source/WebCore/editing/Editor.cpp (193644 => 193645)


--- 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)
@@ -3264,6 +3264,11 @@
     if (client())
         client()->respondToChangedSelection(&m_frame);
 
+#if PLATFORM(MAC) && __MAC_OS_X_VERSION_MIN_REQUIRED >= 101200
+    if (client() && canEdit())
+        client()->requestCandidatesForSelection(m_frame.selection().selection());
+#endif
+
 #if ENABLE(TELEPHONE_NUMBER_DETECTION) && !PLATFORM(IOS)
     if (shouldDetectTelephoneNumbers())
         m_telephoneNumberDetectionUpdateTimer.startOneShot(0);

Modified: trunk/Source/WebCore/loader/EmptyClients.h (193644 => 193645)


--- 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)
@@ -537,6 +537,10 @@
     virtual void willSetInputMethodState() override { }
     virtual void setInputMethodState(bool) override { }
 
+#if PLATFORM(MAC) && __MAC_OS_X_VERSION_MIN_REQUIRED >= 101200
+    virtual void requestCandidatesForSelection(const VisibleSelection&) override { }
+#endif
+
 private:
     EmptyTextCheckerClient m_textCheckerClient;
 };

Modified: trunk/Source/WebCore/page/EditorClient.h (193644 => 193645)


--- 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)
@@ -186,6 +186,10 @@
     // Support for global selections, used on platforms like the X Window System that treat
     // selection as a type of clipboard.
     virtual bool supportsGlobalSelection() { return false; }
+
+#if PLATFORM(MAC) && __MAC_OS_X_VERSION_MIN_REQUIRED >= 101200
+    virtual void requestCandidatesForSelection(const VisibleSelection&) = 0;
+#endif
 };
 
 }

Added: trunk/Source/WebCore/platform/spi/mac/NSSpellCheckerSPI.h (0 => 193645)


--- 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)
@@ -0,0 +1,39 @@
+/*
+ * 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

Modified: trunk/Source/WebKit/mac/ChangeLog (193644 => 193645)


--- 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)
@@ -1,3 +1,36 @@
+2015-12-07  Beth Dakin  <[email protected]>
+
+        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):
+
 2015-12-03  Jer Noble  <[email protected]>
 
         Expose WebCore's InvisibleAutoplayNotPermitted setting to WebKit & WebKit2

Modified: trunk/Source/WebKit/mac/WebCoreSupport/WebEditorClient.h (193644 => 193645)


--- 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)
@@ -29,9 +29,11 @@
 
 #import <WebCore/EditorClient.h>
 #import <WebCore/TextCheckerClient.h>
+#import <WebCore/VisibleSelection.h>
 #import <wtf/Forward.h>
 #import <wtf/RetainPtr.h>
 #import <wtf/Vector.h>
+#import <wtf/WeakPtr.h>
 #import <wtf/text/StringView.h>
 
 #if PLATFORM(IOS)
@@ -167,6 +169,12 @@
     virtual void setInputMethodState(bool enabled) override;
     virtual void requestCheckingOfString(PassRefPtr<WebCore::TextCheckingRequest>) override;
 
+#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
+
     void registerUndoOrRedoStep(PassRefPtr<WebCore::UndoStep>, bool isRedo);
 
     WebView *m_webView;
@@ -177,6 +185,10 @@
     bool m_delayingContentChangeNotifications;
     bool m_hasDelayedContentChangeNotification;
 #endif
+
+    WebCore::VisibleSelection m_lastSelectionForRequestedCandidates;
+
+    WeakPtrFactory<WebEditorClient> m_weakPtrFactory;
 };
 
 #if PLATFORM(COCOA)

Modified: trunk/Source/WebKit/mac/WebCoreSupport/WebEditorClient.mm (193644 => 193645)


--- 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)
@@ -54,18 +54,25 @@
 #import <WebCore/ArchiveResource.h>
 #import <WebCore/Document.h>
 #import <WebCore/DocumentFragment.h>
+#import <WebCore/Editor.h>
+#import <WebCore/FloatQuad.h>
+#import <WebCore/Frame.h>
+#import <WebCore/FrameView.h>
 #import <WebCore/HTMLInputElement.h>
 #import <WebCore/HTMLNames.h>
 #import <WebCore/HTMLTextAreaElement.h>
 #import <WebCore/KeyboardEvent.h>
 #import <WebCore/LegacyWebArchive.h>
+#import <WebCore/NSSpellCheckerSPI.h>
 #import <WebCore/Page.h>
 #import <WebCore/PlatformKeyboardEvent.h>
 #import <WebCore/Settings.h>
 #import <WebCore/SpellChecker.h>
 #import <WebCore/StyleProperties.h>
+#import <WebCore/TextIterator.h>
 #import <WebCore/UndoStep.h>
 #import <WebCore/UserTypingGestureIndicator.h>
+#import <WebCore/VisibleUnits.h>
 #import <WebCore/WebCoreObjCExtras.h>
 #import <runtime/InitializeThreading.h>
 #import <wtf/MainThread.h>
@@ -189,6 +196,7 @@
     , m_delayingContentChangeNotifications(0)
     , m_hasDelayedContentChangeNotification(0)
 #endif
+    , m_weakPtrFactory(this)
 {
 }
 
@@ -1103,6 +1111,114 @@
 {
 }
 
+#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
+
 #if !PLATFORM(IOS)
 @interface WebEditorSpellCheckResponder : NSObject
 {

Modified: trunk/Source/WebKit2/ChangeLog (193644 => 193645)


--- 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)
@@ -1,3 +1,15 @@
+2015-12-07  Beth Dakin  <[email protected]>
+
+        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:
+
 2015-12-07  Philippe Normand  <[email protected]>
 
         [GTK][Mac] socketpair assertion failure

Modified: trunk/Source/WebKit2/WebProcess/WebCoreSupport/WebEditorClient.h (193644 => 193645)


--- 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)
@@ -149,6 +149,11 @@
     virtual void willSetInputMethodState() override;
     virtual void setInputMethodState(bool enabled) override;
     virtual void requestCheckingOfString(WTF::PassRefPtr<WebCore::TextCheckingRequest>) override;
+
+#if PLATFORM(MAC) && __MAC_OS_X_VERSION_MIN_REQUIRED >= 101200
+    virtual void requestCandidatesForSelection(const WebCore::VisibleSelection&) override { }
+#endif
+
 #if PLATFORM(GTK)
     virtual bool shouldShowUnicodeMenu() override;
 #endif
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to