[SCM] WebKit Debian packaging branch, debian/experimental, updated. debian/1.3.8-1-1049-g2e11a8e
andersca at apple.com
andersca at apple.com
Fri Jan 21 14:56:27 UTC 2011
The following commit has been merged in the debian/experimental branch:
commit 33241f7596f01d050c62c92881ba53a07885beea
Author: andersca at apple.com <andersca at apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date: Wed Jan 5 02:13:12 2011 +0000
2011-01-04 Anders Carlsson <andersca at apple.com>
Reviewed by Sam Weinig.
More work on spelling and grammar
https://bugs.webkit.org/show_bug.cgi?id=51910
* Scripts/webkit2/messages.py:
Add special case for WebCore::TextCheckingResult.
* Shared/NotImplemented.h:
Fix macro so that defining DISABLE_NOT_IMPLEMENTED_WARNINGS to 0 will enable the warnings.
* Shared/WebCoreArgumentCoders.h:
Add argument coders for WebCore::GrammarDetail and WebCore::TextCheckingResult.
* UIProcess/API/mac/WKView.mm:
(-[WKView checkSpelling:]):
Call advanceToNextMisspelling.
* UIProcess/TextChecker.h:
Add new NSSpellChecker wrappers.
* UIProcess/WebPageProxy.cpp:
(WebKit::WebPageProxy::WebPageProxy):
Initialize the new member variables.
(WebKit::WebPageProxy::~WebPageProxy):
Call TextChecker::closeSpellDocumentWithTag.
(WebKit::WebPageProxy::advanceToNextMisspelling):
Send the AdvanceToNextMisspelling message.
(WebKit::WebPageProxy::spellDocumentTag):
Create a spell document tag if necessary.
(WebKit::WebPageProxy::checkTextOfParagraph):
(WebKit::WebPageProxy::updateSpellingUIWithMisspelledWord):
(WebKit::WebPageProxy::getGuessesForWord):
Call the TextChecker.
* UIProcess/WebPageProxy.messages.in:
Add new messages.
* UIProcess/mac/TextCheckerMac.mm:
(WebKit::TextChecker::uniqueSpellDocumentTag):
(WebKit::TextChecker::closeSpellDocumentWithTag):
(WebKit::TextChecker::checkTextOfParagraph):
(WebKit::TextChecker::updateSpellingUIWithMisspelledWord):
(WebKit::TextChecker::getGuessesForWord):
Add NSSpellChecker wrappers.
* UIProcess/qt/TextCheckerQt.cpp:
* UIProcess/win/TextCheckerWin.cpp:
Add stubs.
* WebProcess/WebCoreSupport/WebEditorClient.cpp:
(WebKit::WebEditorClient::isContinuousSpellCheckingEnabled):
(WebKit::WebEditorClient::isGrammarCheckingEnabled):
Get the text checking state from the web process.
(WebKit::WebEditorClient::updateSpellingUIWithMisspelledWord):
(WebKit::WebEditorClient::getGuessesForWord):
Proxy calls to the UI process.
* WebProcess/WebCoreSupport/mac/WebEditorClientMac.mm:
(WebKit::WebEditorClient::isAutomaticSpellingCorrectionEnabled):
(WebKit::WebEditorClient::checkTextOfParagraph):
Proxy calls to the UI process.
* WebProcess/WebPage/WebPage.cpp:
(WebKit::WebPage::advanceToNextMisspelling):
Call the frame.
* WebProcess/WebPage/WebPage.messages.in:
Add AdvanceToNextMisspelling message.
* WebProcess/WebProcess.cpp:
(WebKit::WebProcess::initializeWebProcess):
Set the text checker state.
git-svn-id: http://svn.webkit.org/repository/webkit/trunk@75037 268f45cc-cd09-0410-ab3c-d52691b4dbfc
diff --git a/WebKit2/ChangeLog b/WebKit2/ChangeLog
index 597c555..652e084 100644
--- a/WebKit2/ChangeLog
+++ b/WebKit2/ChangeLog
@@ -1,3 +1,85 @@
+2011-01-04 Anders Carlsson <andersca at apple.com>
+
+ Reviewed by Sam Weinig.
+
+ More work on spelling and grammar
+ https://bugs.webkit.org/show_bug.cgi?id=51910
+
+ * Scripts/webkit2/messages.py:
+ Add special case for WebCore::TextCheckingResult.
+
+ * Shared/NotImplemented.h:
+ Fix macro so that defining DISABLE_NOT_IMPLEMENTED_WARNINGS to 0 will enable the warnings.
+
+ * Shared/WebCoreArgumentCoders.h:
+ Add argument coders for WebCore::GrammarDetail and WebCore::TextCheckingResult.
+
+ * UIProcess/API/mac/WKView.mm:
+ (-[WKView checkSpelling:]):
+ Call advanceToNextMisspelling.
+
+ * UIProcess/TextChecker.h:
+ Add new NSSpellChecker wrappers.
+
+ * UIProcess/WebPageProxy.cpp:
+ (WebKit::WebPageProxy::WebPageProxy):
+ Initialize the new member variables.
+
+ (WebKit::WebPageProxy::~WebPageProxy):
+ Call TextChecker::closeSpellDocumentWithTag.
+
+ (WebKit::WebPageProxy::advanceToNextMisspelling):
+ Send the AdvanceToNextMisspelling message.
+
+ (WebKit::WebPageProxy::spellDocumentTag):
+ Create a spell document tag if necessary.
+
+ (WebKit::WebPageProxy::checkTextOfParagraph):
+ (WebKit::WebPageProxy::updateSpellingUIWithMisspelledWord):
+ (WebKit::WebPageProxy::getGuessesForWord):
+ Call the TextChecker.
+
+ * UIProcess/WebPageProxy.messages.in:
+ Add new messages.
+
+ * UIProcess/mac/TextCheckerMac.mm:
+ (WebKit::TextChecker::uniqueSpellDocumentTag):
+ (WebKit::TextChecker::closeSpellDocumentWithTag):
+ (WebKit::TextChecker::checkTextOfParagraph):
+ (WebKit::TextChecker::updateSpellingUIWithMisspelledWord):
+ (WebKit::TextChecker::getGuessesForWord):
+ Add NSSpellChecker wrappers.
+
+ * UIProcess/qt/TextCheckerQt.cpp:
+ * UIProcess/win/TextCheckerWin.cpp:
+ Add stubs.
+
+ * WebProcess/WebCoreSupport/WebEditorClient.cpp:
+ (WebKit::WebEditorClient::isContinuousSpellCheckingEnabled):
+ (WebKit::WebEditorClient::isGrammarCheckingEnabled):
+ Get the text checking state from the web process.
+
+ (WebKit::WebEditorClient::updateSpellingUIWithMisspelledWord):
+ (WebKit::WebEditorClient::getGuessesForWord):
+ Proxy calls to the UI process.
+
+ * WebProcess/WebCoreSupport/mac/WebEditorClientMac.mm:
+ (WebKit::WebEditorClient::isAutomaticSpellingCorrectionEnabled):
+
+ (WebKit::WebEditorClient::checkTextOfParagraph):
+ Proxy calls to the UI process.
+
+ * WebProcess/WebPage/WebPage.cpp:
+ (WebKit::WebPage::advanceToNextMisspelling):
+ Call the frame.
+
+ * WebProcess/WebPage/WebPage.messages.in:
+ Add AdvanceToNextMisspelling message.
+
+ * WebProcess/WebProcess.cpp:
+ (WebKit::WebProcess::initializeWebProcess):
+ Set the text checker state.
+
2011-01-04 Chris Fleizach <cfleizach at apple.com>
Unreviewed. Build fix.
diff --git a/WebKit2/Scripts/webkit2/messages.py b/WebKit2/Scripts/webkit2/messages.py
index 4adabae..6b6431e 100644
--- a/WebKit2/Scripts/webkit2/messages.py
+++ b/WebKit2/Scripts/webkit2/messages.py
@@ -415,6 +415,7 @@ def headers_for_type(type):
'WebCore::CompositionUnderline': '<WebCore/Editor.h>',
'WebCore::KeypressCommand': '<WebCore/KeyboardEvent.h>',
'WebCore::PluginInfo': '<WebCore/PluginData.h>',
+ 'WebCore::TextCheckingResult': '<WebCore/EditorClient.h>',
'WebKit::WebKeyboardEvent': '"WebEvent.h"',
'WebKit::WebMouseEvent': '"WebEvent.h"',
'WebKit::WebTouchEvent': '"WebEvent.h"',
diff --git a/WebKit2/Shared/NotImplemented.h b/WebKit2/Shared/NotImplemented.h
index 84addfb..d93da50 100644
--- a/WebKit2/Shared/NotImplemented.h
+++ b/WebKit2/Shared/NotImplemented.h
@@ -29,7 +29,7 @@
#include <stdio.h>
#include <wtf/Assertions.h>
-#if defined(NDEBUG) || defined(DISABLE_NOT_IMPLEMENTED_WARNINGS)
+#if defined(NDEBUG) || (defined(DISABLE_NOT_IMPLEMENTED_WARNINGS) && DISABLE_NOT_IMPLEMENTED_WARNINGS)
#define notImplemented() ((void)0)
#else
diff --git a/WebKit2/Shared/WebCoreArgumentCoders.h b/WebKit2/Shared/WebCoreArgumentCoders.h
index e6325ca..62c68c7 100644
--- a/WebKit2/Shared/WebCoreArgumentCoders.h
+++ b/WebKit2/Shared/WebCoreArgumentCoders.h
@@ -35,6 +35,7 @@
#include <WebCore/Cursor.h>
#include <WebCore/DatabaseDetails.h>
#include <WebCore/Editor.h>
+#include <WebCore/EditorClient.h>
#include <WebCore/FloatRect.h>
#include <WebCore/IntRect.h>
#include <WebCore/KeyboardEvent.h>
@@ -394,6 +395,56 @@ template<> struct ArgumentCoder<WebCore::DatabaseDetails> {
}
};
+template<> struct ArgumentCoder<WebCore::GrammarDetail> {
+ static void encode(ArgumentEncoder* encoder, const WebCore::GrammarDetail& detail)
+ {
+ encoder->encodeInt32(detail.location);
+ encoder->encodeInt32(detail.length);
+ encoder->encode(detail.guesses);
+ encoder->encode(detail.userDescription);
+ }
+
+ static bool decode(ArgumentDecoder* decoder, WebCore::GrammarDetail& detail)
+ {
+ if (!decoder->decodeInt32(detail.location))
+ return false;
+ if (!decoder->decodeInt32(detail.length))
+ return false;
+ if (!decoder->decode(detail.guesses))
+ return false;
+ if (!decoder->decode(detail.userDescription))
+ return false;
+
+ return true;
+ }
+};
+
+template<> struct ArgumentCoder<WebCore::TextCheckingResult> {
+ static void encode(ArgumentEncoder* encoder, const WebCore::TextCheckingResult& result)
+ {
+ encoder->encodeEnum(result.type);
+ encoder->encodeInt32(result.location);
+ encoder->encodeInt32(result.length);
+ encoder->encode(result.details);
+ encoder->encode(result.replacement);
+ }
+
+ static bool decode(ArgumentDecoder* decoder, WebCore::TextCheckingResult& result)
+ {
+ if (!decoder->decodeEnum(result.type))
+ return false;
+ if (!decoder->decodeInt32(result.location))
+ return false;
+ if (!decoder->decodeInt32(result.length))
+ return false;
+ if (!decoder->decode(result.details))
+ return false;
+ if (!decoder->decode(result.replacement))
+ return false;
+ return true;
+ }
+};
+
} // namespace CoreIPC
#endif // WebCoreArgumentCoders_h
diff --git a/WebKit2/UIProcess/API/mac/WKView.mm b/WebKit2/UIProcess/API/mac/WKView.mm
index 56c6670..bd20fe2 100644
--- a/WebKit2/UIProcess/API/mac/WKView.mm
+++ b/WebKit2/UIProcess/API/mac/WKView.mm
@@ -431,7 +431,7 @@ static void speakString(WKStringRef string, WKErrorRef error, void*)
- (IBAction)checkSpelling:(id)sender
{
- // FIXME (WebKit2) <rdar://problem/8245958> Make Spelling/Grammar checking work in WebKit2
+ _data->_page->advanceToNextMisspelling();
}
- (IBAction)toggleContinuousSpellChecking:(id)sender
diff --git a/WebKit2/UIProcess/TextChecker.h b/WebKit2/UIProcess/TextChecker.h
index f14c53d..94e119d 100644
--- a/WebKit2/UIProcess/TextChecker.h
+++ b/WebKit2/UIProcess/TextChecker.h
@@ -26,6 +26,8 @@
#ifndef TextChecker_h
#define TextChecker_h
+#include <WebCore/EditorClient.h>
+
namespace WebKit {
class TextCheckerState;
@@ -41,6 +43,13 @@ public:
#if PLATFORM(MAC)
static void setAutomaticSpellingCorrectionEnabled(bool);
#endif
+
+ static int64_t uniqueSpellDocumentTag();
+ static void closeSpellDocumentWithTag(int64_t);
+
+ static Vector<WebCore::TextCheckingResult> checkTextOfParagraph(int64_t spellDocumentTag, const UChar* text, int length, uint64_t checkingTypes);
+ static void updateSpellingUIWithMisspelledWord(const String& misspelledWord);
+ static void getGuessesForWord(int64_t spellDocumentTag, const String& word, const String& context, Vector<String>& guesses);
};
} // namespace WebKit
diff --git a/WebKit2/UIProcess/WebPageProxy.cpp b/WebKit2/UIProcess/WebPageProxy.cpp
index 52337f9..50bf165 100644
--- a/WebKit2/UIProcess/WebPageProxy.cpp
+++ b/WebKit2/UIProcess/WebPageProxy.cpp
@@ -34,6 +34,7 @@
#include "NativeWebKeyboardEvent.h"
#include "PageClient.h"
#include "StringPairVector.h"
+#include "TextChecker.h"
#include "WKContextPrivate.h"
#include "WebBackForwardList.h"
#include "WebBackForwardListItem.h"
@@ -111,6 +112,8 @@ WebPageProxy::WebPageProxy(WebContext* context, WebPageGroup* pageGroup, uint64_
, m_processingWheelEvent(false)
, m_processingMouseMoveEvent(false)
, m_pageID(pageID)
+ , m_spellDocumentTag(0)
+ , m_hasSpellDocumentTag(false)
, m_mainFrameHasCustomRepresentation(false)
{
#ifndef NDEBUG
@@ -126,6 +129,9 @@ WebPageProxy::~WebPageProxy()
{
WebContext::statistics().wkPageCount--;
+ if (m_hasSpellDocumentTag)
+ TextChecker::closeSpellDocumentWithTag(m_spellDocumentTag);
+
m_pageGroup->removePage(this);
#ifndef NDEBUG
@@ -1723,6 +1729,11 @@ void WebPageProxy::didCancelForOpenPanel()
m_openPanelResultListener = 0;
}
+void WebPageProxy::advanceToNextMisspelling()
+{
+ process()->send(Messages::WebPage::AdvanceToNextMisspelling(), m_pageID);
+}
+
void WebPageProxy::unmarkAllMisspellings()
{
process()->send(Messages::WebPage::UnmarkAllMisspellings(), m_pageID);
@@ -1752,6 +1763,31 @@ void WebPageProxy::removeEditCommand(WebEditCommandProxy* command)
process()->send(Messages::WebPage::DidRemoveEditCommand(command->commandID()), m_pageID);
}
+int64_t WebPageProxy::spellDocumentTag()
+{
+ if (!m_hasSpellDocumentTag) {
+ m_spellDocumentTag = TextChecker::uniqueSpellDocumentTag();
+ m_hasSpellDocumentTag = true;
+ }
+
+ return m_spellDocumentTag;
+}
+
+void WebPageProxy::checkTextOfParagraph(const String& text, uint64_t checkingTypes, Vector<TextCheckingResult>& results)
+{
+ results = TextChecker::checkTextOfParagraph(spellDocumentTag(), text.characters(), text.length(), checkingTypes);
+}
+
+void WebPageProxy::updateSpellingUIWithMisspelledWord(const String& misspelledWord)
+{
+ TextChecker::updateSpellingUIWithMisspelledWord(misspelledWord);
+}
+
+void WebPageProxy::getGuessesForWord(const String& word, const String& context, Vector<String>& guesses)
+{
+ TextChecker::getGuessesForWord(spellDocumentTag(), word, context, guesses);
+}
+
// Other
void WebPageProxy::takeFocus(bool direction)
diff --git a/WebKit2/UIProcess/WebPageProxy.h b/WebKit2/UIProcess/WebPageProxy.h
index e7db489..8a97c3f 100644
--- a/WebKit2/UIProcess/WebPageProxy.h
+++ b/WebKit2/UIProcess/WebPageProxy.h
@@ -69,6 +69,7 @@ namespace WebCore {
class FloatRect;
class IntSize;
class ProtectionSpace;
+ struct TextCheckingResult;
struct ViewportArguments;
struct WindowFeatures;
}
@@ -297,6 +298,7 @@ public:
void findZoomableAreaForPoint(const WebCore::IntPoint&);
#endif
+ void advanceToNextMisspelling();
void unmarkAllMisspellings();
void unmarkAllBadGrammar();
@@ -427,6 +429,12 @@ private:
void stopSpeaking();
#endif
+ // Spelling and grammar.
+ int64_t spellDocumentTag();
+ void checkTextOfParagraph(const String& text, uint64_t checkingTypes, Vector<WebCore::TextCheckingResult>& results);
+ void updateSpellingUIWithMisspelledWord(const String& misspelledWord);
+ void getGuessesForWord(const String& word, const String& context, Vector<String>& guesses);
+
void takeFocus(bool direction);
void setToolTip(const String&);
void setCursor(const WebCore::Cursor&);
@@ -530,6 +538,9 @@ private:
uint64_t m_pageID;
+ int64_t m_spellDocumentTag;
+ bool m_hasSpellDocumentTag;
+
bool m_mainFrameHasCustomRepresentation;
};
diff --git a/WebKit2/UIProcess/WebPageProxy.messages.in b/WebKit2/UIProcess/WebPageProxy.messages.in
index cf6f52a..eb2089e 100644
--- a/WebKit2/UIProcess/WebPageProxy.messages.in
+++ b/WebKit2/UIProcess/WebPageProxy.messages.in
@@ -175,4 +175,9 @@ messages -> WebPageProxy {
Speak(WTF::String string)
StopSpeaking()
#endif
+
+ # Spelling and grammar.
+ CheckTextOfParagraph(WTF::String text, uint64_t checkingTypes) -> (Vector<WebCore::TextCheckingResult> results)
+ UpdateSpellingUIWithMisspelledWord(WTF::String misspelledWord)
+ GetGuessesForWord(WTF::String word, WTF::String context) -> (Vector<WTF::String> guesses)
}
diff --git a/WebKit2/UIProcess/mac/TextCheckerMac.mm b/WebKit2/UIProcess/mac/TextCheckerMac.mm
index b244579..98fe6a7 100644
--- a/WebKit2/UIProcess/mac/TextCheckerMac.mm
+++ b/WebKit2/UIProcess/mac/TextCheckerMac.mm
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2010 Apple Inc. All rights reserved.
+ * Copyright (C) 2010, 2011 Apple Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -26,11 +26,14 @@
#include "TextChecker.h"
#include "TextCheckerState.h"
+#include <wtf/RetainPtr.h>
static const NSString * const WebAutomaticSpellingCorrectionEnabled = @"WebAutomaticSpellingCorrectionEnabled";
static const NSString * const WebContinuousSpellCheckingEnabled = @"WebContinuousSpellCheckingEnabled";
static const NSString * const WebGrammarCheckingEnabled = @"WebGrammarCheckingEnabled";
+using namespace WebCore;
+
namespace WebKit {
TextCheckerState textCheckerState;
@@ -109,4 +112,125 @@ void TextChecker::setAutomaticSpellingCorrectionEnabled(bool isAutomaticSpelling
[[NSSpellChecker sharedSpellChecker] updatePanels];
}
+int64_t TextChecker::uniqueSpellDocumentTag()
+{
+ return [NSSpellChecker uniqueSpellDocumentTag];
+}
+
+void TextChecker::closeSpellDocumentWithTag(int64_t tag)
+{
+ [[NSSpellChecker sharedSpellChecker] closeSpellDocumentWithTag:tag];
+}
+
+Vector<TextCheckingResult> TextChecker::checkTextOfParagraph(int64_t spellDocumentTag, const UChar* text, int length, uint64_t checkingTypes)
+{
+ Vector<TextCheckingResult> results;
+
+ RetainPtr<NSString> textString(AdoptNS, [[NSString alloc] initWithCharactersNoCopy:const_cast<UChar*>(text) length:length freeWhenDone:NO]);
+ NSArray *incomingResults = [[NSSpellChecker sharedSpellChecker] checkString:textString .get()
+ range:NSMakeRange(0, length)
+ types:checkingTypes | NSTextCheckingTypeOrthography
+ options:nil
+ inSpellDocumentWithTag:spellDocumentTag
+ orthography:NULL
+ wordCount:NULL];
+ for (NSTextCheckingResult *incomingResult in incomingResults) {
+ NSRange resultRange = [incomingResult range];
+ NSTextCheckingType resultType = [incomingResult resultType];
+ ASSERT(resultRange.location != NSNotFound);
+ ASSERT(resultRange.length > 0);
+ if (resultType == NSTextCheckingTypeSpelling && (checkingTypes & NSTextCheckingTypeSpelling)) {
+ TextCheckingResult result;
+ result.type = TextCheckingTypeSpelling;
+ result.location = resultRange.location;
+ result.length = resultRange.length;
+ results.append(result);
+ } else if (resultType == NSTextCheckingTypeGrammar && (checkingTypes & NSTextCheckingTypeGrammar)) {
+ TextCheckingResult result;
+ NSArray *details = [incomingResult grammarDetails];
+ result.type = TextCheckingTypeGrammar;
+ result.location = resultRange.location;
+ result.length = resultRange.length;
+ for (NSDictionary *incomingDetail in details) {
+ ASSERT(incomingDetail);
+ GrammarDetail detail;
+ NSValue *detailRangeAsNSValue = [incomingDetail objectForKey:NSGrammarRange];
+ ASSERT(detailRangeAsNSValue);
+ NSRange detailNSRange = [detailRangeAsNSValue rangeValue];
+ ASSERT(detailNSRange.location != NSNotFound);
+ ASSERT(detailNSRange.length > 0);
+ detail.location = detailNSRange.location;
+ detail.length = detailNSRange.length;
+ detail.userDescription = [incomingDetail objectForKey:NSGrammarUserDescription];
+ NSArray *guesses = [incomingDetail objectForKey:NSGrammarCorrections];
+ for (NSString *guess in guesses)
+ detail.guesses.append(String(guess));
+ result.details.append(detail);
+ }
+ results.append(result);
+ } else if (resultType == NSTextCheckingTypeLink && (checkingTypes & NSTextCheckingTypeLink)) {
+ TextCheckingResult result;
+ result.type = TextCheckingTypeLink;
+ result.location = resultRange.location;
+ result.length = resultRange.length;
+ result.replacement = [[incomingResult URL] absoluteString];
+ results.append(result);
+ } else if (resultType == NSTextCheckingTypeQuote && (checkingTypes & NSTextCheckingTypeQuote)) {
+ TextCheckingResult result;
+ result.type = TextCheckingTypeQuote;
+ result.location = resultRange.location;
+ result.length = resultRange.length;
+ result.replacement = [incomingResult replacementString];
+ results.append(result);
+ } else if (resultType == NSTextCheckingTypeDash && (checkingTypes & NSTextCheckingTypeDash)) {
+ TextCheckingResult result;
+ result.type = TextCheckingTypeDash;
+ result.location = resultRange.location;
+ result.length = resultRange.length;
+ result.replacement = [incomingResult replacementString];
+ results.append(result);
+ } else if (resultType == NSTextCheckingTypeReplacement && (checkingTypes & NSTextCheckingTypeReplacement)) {
+ TextCheckingResult result;
+ result.type = TextCheckingTypeReplacement;
+ result.location = resultRange.location;
+ result.length = resultRange.length;
+ result.replacement = [incomingResult replacementString];
+ results.append(result);
+ } else if (resultType == NSTextCheckingTypeCorrection && (checkingTypes & NSTextCheckingTypeCorrection)) {
+ TextCheckingResult result;
+ result.type = TextCheckingTypeCorrection;
+ result.location = resultRange.location;
+ result.length = resultRange.length;
+ result.replacement = [incomingResult replacementString];
+ results.append(result);
+ }
+ }
+
+ return results;
+}
+
+void TextChecker::updateSpellingUIWithMisspelledWord(const String& misspelledWord)
+{
+ [[NSSpellChecker sharedSpellChecker] updateSpellingPanelWithMisspelledWord:misspelledWord];
+}
+
+void TextChecker::getGuessesForWord(int64_t spellDocumentTag, const String& word, const String& context, Vector<String>& guesses)
+{
+#if !defined(BUILDING_ON_SNOW_LEOPARD)
+ NSString* language = nil;
+ NSOrthography* orthography = nil;
+ NSSpellChecker *checker = [NSSpellChecker sharedSpellChecker];
+ if (context.length()) {
+ [checker checkString:context range:NSMakeRange(0, context.length()) types:NSTextCheckingTypeOrthography options:0 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()];
+#else
+ NSArray* stringsArray = [[NSSpellChecker sharedSpellChecker] guessesForWord:word];
+#endif
+
+ for (NSString *guess in stringsArray)
+ guesses.append(guess);
+}
+
} // namespace WebKit
diff --git a/WebKit2/UIProcess/qt/TextCheckerQt.cpp b/WebKit2/UIProcess/qt/TextCheckerQt.cpp
index 8be13f6..78fc9cc 100644
--- a/WebKit2/UIProcess/qt/TextCheckerQt.cpp
+++ b/WebKit2/UIProcess/qt/TextCheckerQt.cpp
@@ -28,6 +28,8 @@
#include "NotImplemented.h"
#include "TextCheckerState.h"
+using namespace WebCore;
+
namespace WebKit {
static TextCheckerState textCheckerState;
@@ -56,4 +58,31 @@ void TextChecker::setGrammarCheckingEnabled(bool isGrammarCheckingEnabled)
notImplemented();
}
+int64_t TextChecker::uniqueSpellDocumentTag()
+{
+ notImplemented();
+ return 0;
+}
+
+void TextChecker::closeSpellDocumentWithTag(int64_t)
+{
+ notImplemented();
+}
+
+Vector<TextCheckingResult> TextChecker::checkTextOfParagraph(int64_t spellDocumentTag, const UChar* text, int length, uint64_t checkingTypes)
+{
+ notImplemented();
+ return Vector<WebCore::TextCheckingResult>();
+}
+
+void TextChecker::updateSpellingUIWithMisspelledWord(const String& misspelledWord)
+{
+ notImplemented();
+}
+
+void TextChecker::getGuessesForWord(int64_t spellDocumentTag, const String& word, const String& context, Vector<String>& guesses)
+{
+ notImplemented();
+}
+
} // namespace WebKit
diff --git a/WebKit2/UIProcess/win/TextCheckerWin.cpp b/WebKit2/UIProcess/win/TextCheckerWin.cpp
index d2b2040..95ab2af 100644
--- a/WebKit2/UIProcess/win/TextCheckerWin.cpp
+++ b/WebKit2/UIProcess/win/TextCheckerWin.cpp
@@ -28,6 +28,8 @@
#include "NotImplemented.h"
#include "TextCheckerState.h"
+using namespace WebCore;
+
namespace WebKit {
static TextCheckerState textCheckerState;
@@ -56,4 +58,31 @@ void TextChecker::setGrammarCheckingEnabled(bool isGrammarCheckingEnabled)
notImplemented();
}
+int64_t TextChecker::uniqueSpellDocumentTag()
+{
+ notImplemented();
+ return 0;
+}
+
+void TextChecker::closeSpellDocumentWithTag(int64_t)
+{
+ notImplemented();
+}
+
+Vector<TextCheckingResult> TextChecker::checkTextOfParagraph(int64_t spellDocumentTag, const UChar* text, int length, uint64_t checkingTypes)
+{
+ notImplemented();
+ return Vector<WebCore::TextCheckingResult>();
+}
+
+void TextChecker::updateSpellingUIWithMisspelledWord(const String& misspelledWord)
+{
+ notImplemented();
+}
+
+void TextChecker::getGuessesForWord(int64_t spellDocumentTag, const String& word, const String& context, Vector<String>& guesses)
+{
+ notImplemented();
+}
+
} // namespace WebKit
diff --git a/WebKit2/WebProcess/WebCoreSupport/WebEditorClient.cpp b/WebKit2/WebProcess/WebCoreSupport/WebEditorClient.cpp
index c2c3a3e..3d7c5a9 100644
--- a/WebKit2/WebProcess/WebCoreSupport/WebEditorClient.cpp
+++ b/WebKit2/WebProcess/WebCoreSupport/WebEditorClient.cpp
@@ -82,8 +82,7 @@ bool WebEditorClient::isSelectTrailingWhitespaceEnabled()
bool WebEditorClient::isContinuousSpellCheckingEnabled()
{
- notImplemented();
- return false;
+ return WebProcess::shared().textCheckerState().isContinuousSpellCheckingEnabled;
}
void WebEditorClient::toggleContinuousSpellChecking()
@@ -93,8 +92,7 @@ void WebEditorClient::toggleContinuousSpellChecking()
bool WebEditorClient::isGrammarCheckingEnabled()
{
- notImplemented();
- return false;
+ return WebProcess::shared().textCheckerState().isGrammarCheckingEnabled;
}
void WebEditorClient::toggleGrammarChecking()
@@ -397,9 +395,9 @@ void WebEditorClient::updateSpellingUIWithGrammarString(const String&, const Gra
notImplemented();
}
-void WebEditorClient::updateSpellingUIWithMisspelledWord(const String&)
+void WebEditorClient::updateSpellingUIWithMisspelledWord(const String& misspelledWord)
{
- notImplemented();
+ m_page->send(Messages::WebPageProxy::UpdateSpellingUIWithMisspelledWord(misspelledWord));
}
void WebEditorClient::showSpellingUI(bool)
@@ -413,9 +411,9 @@ bool WebEditorClient::spellingUIIsShowing()
return false;
}
-void WebEditorClient::getGuessesForWord(const String&, const String&, Vector<String>&)
+void WebEditorClient::getGuessesForWord(const String& word, const String& context, Vector<String>& guesses)
{
- notImplemented();
+ m_page->sendSync(Messages::WebPageProxy::GetGuessesForWord(word, context), Messages::WebPageProxy::GetGuessesForWord::Reply(guesses));
}
void WebEditorClient::willSetInputMethodState()
diff --git a/WebKit2/WebProcess/WebCoreSupport/mac/WebEditorClientMac.mm b/WebKit2/WebProcess/WebCoreSupport/mac/WebEditorClientMac.mm
index 51e009c..b1888d6 100644
--- a/WebKit2/WebProcess/WebCoreSupport/mac/WebEditorClientMac.mm
+++ b/WebKit2/WebProcess/WebCoreSupport/mac/WebEditorClientMac.mm
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2006 Apple Computer, Inc. All rights reserved.
+ * Copyright (C) 2006, 2010, 2011 Apple Computer, Inc. All rights reserved.
* Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies)
*
* Redistribution and use in source and binary forms, with or without
@@ -32,6 +32,7 @@
#define DISABLE_NOT_IMPLEMENTED_WARNINGS 1
#include "NotImplemented.h"
+#include "WebCoreArgumentCoders.h"
#include "WebPage.h"
#include "WebFrame.h"
#include "WebPageProxyMessages.h"
@@ -207,8 +208,7 @@ void WebEditorClient::toggleAutomaticTextReplacement()
bool WebEditorClient::isAutomaticSpellingCorrectionEnabled()
{
- notImplemented();
- return false;
+ return WebProcess::shared().textCheckerState().isAutomaticSpellingCorrectionEnabled;
}
void WebEditorClient::toggleAutomaticSpellingCorrection()
@@ -216,9 +216,10 @@ void WebEditorClient::toggleAutomaticSpellingCorrection()
notImplemented();
}
-void WebEditorClient::checkTextOfParagraph(const UChar *, int length, uint64_t, Vector<TextCheckingResult>&)
+void WebEditorClient::checkTextOfParagraph(const UChar* text, int length, uint64_t checkingTypes, Vector<TextCheckingResult>& results)
{
- notImplemented();
+ // FIXME: It would be nice if we wouldn't have to copy the text here.
+ m_page->sendSync(Messages::WebPageProxy::CheckTextOfParagraph(String(text, length), checkingTypes), Messages::WebPageProxy::CheckTextOfParagraph::Reply(results));
}
#endif
diff --git a/WebKit2/WebProcess/WebPage/WebPage.cpp b/WebKit2/WebProcess/WebPage/WebPage.cpp
index 649171b..f636ee2 100644
--- a/WebKit2/WebProcess/WebPage/WebPage.cpp
+++ b/WebKit2/WebProcess/WebPage/WebPage.cpp
@@ -1256,6 +1256,12 @@ void WebPage::didCancelForOpenPanel()
m_activeOpenPanelResultListener = 0;
}
+void WebPage::advanceToNextMisspelling()
+{
+ if (Frame* frame = m_page->focusController()->focusedOrMainFrame())
+ frame->editor()->advanceToNextMisspelling();
+}
+
void WebPage::unmarkAllMisspellings()
{
for (Frame* frame = m_page->mainFrame(); frame; frame = frame->tree()->traverseNext()) {
diff --git a/WebKit2/WebProcess/WebPage/WebPage.h b/WebKit2/WebProcess/WebPage/WebPage.h
index 8769976..12633f0 100644
--- a/WebKit2/WebProcess/WebPage/WebPage.h
+++ b/WebKit2/WebProcess/WebPage/WebPage.h
@@ -374,6 +374,7 @@ private:
void didChooseFilesForOpenPanel(const Vector<String>&);
void didCancelForOpenPanel();
+ void advanceToNextMisspelling();
void unmarkAllMisspellings();
void unmarkAllBadGrammar();
diff --git a/WebKit2/WebProcess/WebPage/WebPage.messages.in b/WebKit2/WebProcess/WebPage/WebPage.messages.in
index 3b57185..baa5ae8 100644
--- a/WebKit2/WebProcess/WebPage/WebPage.messages.in
+++ b/WebKit2/WebProcess/WebPage/WebPage.messages.in
@@ -101,6 +101,7 @@ messages -> WebPage {
DidCancelForOpenPanel()
# Speling and grammer.
+ AdvanceToNextMisspelling()
UnmarkAllMisspellings()
UnmarkAllBadGrammar()
diff --git a/WebKit2/WebProcess/WebProcess.cpp b/WebKit2/WebProcess/WebProcess.cpp
index 4c802f4..f7ceadd 100644
--- a/WebKit2/WebProcess/WebProcess.cpp
+++ b/WebKit2/WebProcess/WebProcess.cpp
@@ -162,6 +162,8 @@ void WebProcess::initializeWebProcess(const WebProcessCreationParameters& parame
if (!parameters.languageCode.isEmpty())
overrideDefaultLanguage(parameters.languageCode);
+ m_textCheckerState = parameters.textCheckerState;
+
for (size_t i = 0; i < parameters.urlSchemesRegistererdAsEmptyDocument.size(); ++i)
registerURLSchemeAsEmptyDocument(parameters.urlSchemesRegistererdAsEmptyDocument[i]);
--
WebKit Debian packaging
More information about the Pkg-webkit-commits
mailing list