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

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

Issue 2796473002: Split TextCheckerClientImpl off SpellCheckerClientImpl (Closed)
Patch Set: Remove explicit Created 3 years, 9 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
« no previous file with comments | « third_party/WebKit/Source/web/TextCheckerClientImpl.h ('k') | third_party/WebKit/Source/web/WebViewImpl.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/WebKit/Source/web/TextCheckerClientImpl.cpp
diff --git a/third_party/WebKit/Source/web/TextCheckerClientImpl.cpp b/third_party/WebKit/Source/web/TextCheckerClientImpl.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..4d9be402ab98429be59ecd585dc79ddd87a50956
--- /dev/null
+++ b/third_party/WebKit/Source/web/TextCheckerClientImpl.cpp
@@ -0,0 +1,58 @@
+// Copyright 2017 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "web/TextCheckerClientImpl.h"
+#include "public/web/WebSpellCheckClient.h"
+#include "public/web/WebTextCheckingResult.h"
+#include "web/WebTextCheckingCompletionImpl.h"
+#include "web/WebViewImpl.h"
+
+namespace blink {
+
+TextCheckerClientImpl::TextCheckerClientImpl(WebViewImpl* webView)
+ : m_webView(webView) {}
+
+TextCheckerClientImpl::~TextCheckerClientImpl() = default;
+
+void TextCheckerClientImpl::checkSpellingOfString(const String& text,
+ int* misspellingLocation,
+ int* misspellingLength) {
+ // SpellCheckWord will write (0, 0) into the output vars, which is what our
+ // caller expects if the word is spelled correctly.
+ int spellLocation = -1;
+ int spellLength = 0;
+
+ // Check to see if the provided text is spelled correctly.
+ if (m_webView->spellCheckClient()) {
+ m_webView->spellCheckClient()->checkSpelling(text, spellLocation,
+ spellLength, nullptr);
+ } else {
+ spellLocation = 0;
+ spellLength = 0;
+ }
+
+ // Note: the Mac code checks if the pointers are null before writing to them,
+ // so we do too.
+ if (misspellingLocation)
+ *misspellingLocation = spellLocation;
+ if (misspellingLength)
+ *misspellingLength = spellLength;
+}
+
+void TextCheckerClientImpl::requestCheckingOfString(
+ TextCheckingRequest* request) {
+ if (!m_webView->spellCheckClient())
+ return;
+ const String& text = request->data().text();
+ m_webView->spellCheckClient()->requestCheckingOfText(
+ text, new WebTextCheckingCompletionImpl(request));
+}
+
+void TextCheckerClientImpl::cancelAllPendingRequests() {
+ if (!m_webView->spellCheckClient())
+ return;
+ m_webView->spellCheckClient()->cancelAllPendingRequests();
+}
+
+} // namespace blink
« no previous file with comments | « third_party/WebKit/Source/web/TextCheckerClientImpl.h ('k') | third_party/WebKit/Source/web/WebViewImpl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698