summaryrefslogtreecommitdiff
path: root/Source/WebKit/chromium/src/EditorClientImpl.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'Source/WebKit/chromium/src/EditorClientImpl.cpp')
-rw-r--r--Source/WebKit/chromium/src/EditorClientImpl.cpp37
1 files changed, 30 insertions, 7 deletions
diff --git a/Source/WebKit/chromium/src/EditorClientImpl.cpp b/Source/WebKit/chromium/src/EditorClientImpl.cpp
index 417fe9429..b2d060f0e 100644
--- a/Source/WebKit/chromium/src/EditorClientImpl.cpp
+++ b/Source/WebKit/chromium/src/EditorClientImpl.cpp
@@ -170,7 +170,7 @@ void EditorClientImpl::toggleContinuousSpellChecking()
bool EditorClientImpl::isGrammarCheckingEnabled()
{
const Frame* frame = m_webView->focusedWebCoreFrame();
- return frame && frame->settings() && frame->settings()->asynchronousSpellCheckingEnabled();
+ return frame && frame->settings() && (frame->settings()->asynchronousSpellCheckingEnabled() || frame->settings()->unifiedTextCheckerEnabled());
}
void EditorClientImpl::toggleGrammarChecking()
@@ -703,7 +703,7 @@ void EditorClientImpl::textDidChangeInTextArea(Element*)
bool EditorClientImpl::shouldEraseMarkersAfterChangeSelection(TextCheckingType type) const
{
const Frame* frame = m_webView->focusedWebCoreFrame();
- return !frame || !frame->settings() || !frame->settings()->asynchronousSpellCheckingEnabled();
+ return !frame || !frame->settings() || (!frame->settings()->asynchronousSpellCheckingEnabled() && !frame->settings()->unifiedTextCheckerEnabled());
}
void EditorClientImpl::ignoreWordInSpellDocument(const String&)
@@ -766,16 +766,39 @@ String EditorClientImpl::getAutoCorrectSuggestionForMisspelledWord(const String&
return String();
}
-void EditorClientImpl::checkGrammarOfString(const UChar*, int length,
- WTF::Vector<GrammarDetail>&,
- int* badGrammarLocation,
- int* badGrammarLength)
+void EditorClientImpl::checkGrammarOfString(const UChar* text, int length, WTF::Vector<GrammarDetail>& details, int* badGrammarLocation, int* badGrammarLength)
{
- notImplemented();
if (badGrammarLocation)
*badGrammarLocation = -1;
if (badGrammarLength)
*badGrammarLength = 0;
+
+ if (!m_webView->spellCheckClient())
+ return;
+ WebVector<WebTextCheckingResult> webResults;
+ m_webView->spellCheckClient()->checkTextOfParagraph(WebString(text, length), WebTextCheckingTypeGrammar, &webResults);
+ if (!webResults.size())
+ return;
+
+ // Convert a list of WebTextCheckingResults to a list of GrammarDetails. If
+ // the converted vector of GrammarDetails has grammar errors, we set
+ // badGrammarLocation and badGrammarLength to tell WebKit that the input
+ // text has grammar errors.
+ for (size_t i = 0; i < webResults.size(); ++i) {
+ if (webResults[i].type == WebTextCheckingTypeGrammar) {
+ GrammarDetail detail;
+ detail.location = webResults[i].location;
+ detail.length = webResults[i].length;
+ detail.userDescription = webResults[i].replacement;
+ details.append(detail);
+ }
+ }
+ if (!details.size())
+ return;
+ if (badGrammarLocation)
+ *badGrammarLocation = 0;
+ if (badGrammarLength)
+ *badGrammarLength = length;
}
void EditorClientImpl::checkTextOfParagraph(const UChar* text, int length,