Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1659)

Unified Diff: third_party/WebKit/Source/web/SpellCheckerClientImpl.cpp

Issue 2211813002: Revert removal of grammar checking and marking code (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Minor fix Created 4 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/Source/web/SpellCheckerClientImpl.cpp
diff --git a/third_party/WebKit/Source/web/SpellCheckerClientImpl.cpp b/third_party/WebKit/Source/web/SpellCheckerClientImpl.cpp
index 9bc31d279ad434241a495d263baa955724e83372..3dbc908deca454c3caa331d6ea94dd9d70f0e53b 100644
--- a/third_party/WebKit/Source/web/SpellCheckerClientImpl.cpp
+++ b/third_party/WebKit/Source/web/SpellCheckerClientImpl.cpp
@@ -147,6 +147,41 @@ void SpellCheckerClientImpl::requestCheckingOfString(TextCheckingRequest* reques
m_webView->spellCheckClient()->requestCheckingOfText(text, markers, markerOffsets, new WebTextCheckingCompletionImpl(request));
}
+void SpellCheckerClientImpl::checkGrammarOfString(const String& text, WTF::Vector<GrammarDetail>& details, int* badGrammarLocation, int* badGrammarLength)
+{
+ if (badGrammarLocation)
+ *badGrammarLocation = -1;
+ if (badGrammarLength)
+ *badGrammarLength = 0;
+
+ if (!m_webView->spellCheckClient())
+ return;
+ WebVector<WebTextCheckingResult> webResults;
+ m_webView->spellCheckClient()->checkTextOfParagraph(text, 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].decoration == WebTextDecorationTypeGrammar) {
+ 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 = text.length();
+}
+
void SpellCheckerClientImpl::updateSpellingUIWithMisspelledWord(const String& misspelledWord)
{
if (m_webView->spellCheckClient())
« no previous file with comments | « third_party/WebKit/Source/web/SpellCheckerClientImpl.h ('k') | third_party/WebKit/Source/web/tests/WebFrameTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698