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

Side by Side Diff: third_party/WebKit/Source/web/TextCheckerClientImpl.cpp

Issue 2791753003: Split WebTextCheckClient off WebSpellCheckClient (Closed)
Patch Set: Add TODOs for class renaming Created 3 years, 8 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 unified diff | Download patch
OLDNEW
1 // Copyright 2017 The Chromium Authors. All rights reserved. 1 // Copyright 2017 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "web/TextCheckerClientImpl.h" 5 #include "web/TextCheckerClientImpl.h"
6 #include "public/web/WebSpellCheckClient.h" 6 #include "public/web/WebTextCheckClient.h"
7 #include "public/web/WebTextCheckingResult.h" 7 #include "public/web/WebTextCheckingResult.h"
8 #include "web/WebTextCheckingCompletionImpl.h" 8 #include "web/WebTextCheckingCompletionImpl.h"
9 #include "web/WebViewImpl.h" 9 #include "web/WebViewImpl.h"
10 10
11 namespace blink { 11 namespace blink {
12 12
13 TextCheckerClientImpl::TextCheckerClientImpl(WebViewImpl* webView) 13 TextCheckerClientImpl::TextCheckerClientImpl(WebViewImpl* webView)
14 : m_webView(webView) {} 14 : m_webView(webView) {}
15 15
16 TextCheckerClientImpl::~TextCheckerClientImpl() = default; 16 TextCheckerClientImpl::~TextCheckerClientImpl() = default;
17 17
18 void TextCheckerClientImpl::checkSpellingOfString(const String& text, 18 void TextCheckerClientImpl::checkSpellingOfString(const String& text,
19 int* misspellingLocation, 19 int* misspellingLocation,
20 int* misspellingLength) { 20 int* misspellingLength) {
21 // SpellCheckWord will write (0, 0) into the output vars, which is what our 21 // SpellCheckWord will write (0, 0) into the output vars, which is what our
22 // caller expects if the word is spelled correctly. 22 // caller expects if the word is spelled correctly.
23 int spellLocation = -1; 23 int spellLocation = -1;
24 int spellLength = 0; 24 int spellLength = 0;
25 25
26 // Check to see if the provided text is spelled correctly. 26 // Check to see if the provided text is spelled correctly.
27 if (m_webView->spellCheckClient()) { 27 if (m_webView->textCheckClient()) {
28 m_webView->spellCheckClient()->checkSpelling(text, spellLocation, 28 m_webView->textCheckClient()->checkSpelling(text, spellLocation,
29 spellLength, nullptr); 29 spellLength, nullptr);
30 } else { 30 } else {
31 spellLocation = 0; 31 spellLocation = 0;
32 spellLength = 0; 32 spellLength = 0;
33 } 33 }
34 34
35 // Note: the Mac code checks if the pointers are null before writing to them, 35 // Note: the Mac code checks if the pointers are null before writing to them,
36 // so we do too. 36 // so we do too.
37 if (misspellingLocation) 37 if (misspellingLocation)
38 *misspellingLocation = spellLocation; 38 *misspellingLocation = spellLocation;
39 if (misspellingLength) 39 if (misspellingLength)
40 *misspellingLength = spellLength; 40 *misspellingLength = spellLength;
41 } 41 }
42 42
43 void TextCheckerClientImpl::requestCheckingOfString( 43 void TextCheckerClientImpl::requestCheckingOfString(
44 TextCheckingRequest* request) { 44 TextCheckingRequest* request) {
45 if (!m_webView->spellCheckClient()) 45 if (!m_webView->textCheckClient())
46 return; 46 return;
47 const String& text = request->data().text(); 47 const String& text = request->data().text();
48 m_webView->spellCheckClient()->requestCheckingOfText( 48 m_webView->textCheckClient()->requestCheckingOfText(
49 text, new WebTextCheckingCompletionImpl(request)); 49 text, new WebTextCheckingCompletionImpl(request));
50 } 50 }
51 51
52 void TextCheckerClientImpl::cancelAllPendingRequests() { 52 void TextCheckerClientImpl::cancelAllPendingRequests() {
53 if (!m_webView->spellCheckClient()) 53 if (!m_webView->textCheckClient())
54 return; 54 return;
55 m_webView->spellCheckClient()->cancelAllPendingRequests(); 55 m_webView->textCheckClient()->cancelAllPendingRequests();
56 } 56 }
57 57
58 } // namespace blink 58 } // namespace blink
OLDNEW
« 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