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