diff options
author | morrita@chromium.org <morrita@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-02-17 02:14:53 +0000 |
---|---|---|
committer | morrita@chromium.org <morrita@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-02-17 02:14:53 +0000 |
commit | 7ed49c23b6a29b533e3e3550c818f45ef5afe32e (patch) | |
tree | d9c8342ea9494d7e0f406a37f0506a288ce9218c | |
parent | 65bab0bf28dffe0c62f4bb66191c64ce27708517 (diff) | |
download | chromium_src-7ed49c23b6a29b533e3e3550c818f45ef5afe32e.zip chromium_src-7ed49c23b6a29b533e3e3550c818f45ef5afe32e.tar.gz chromium_src-7ed49c23b6a29b533e3e3550c818f45ef5afe32e.tar.bz2 |
Removed WebTextCheckingResult legacy API use.
BUG=none
TEST=unit_tests
Review URL: http://codereview.chromium.org/9368052
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@122429 0039d316-1c4b-4281-b951-d872f2087c98
17 files changed, 176 insertions, 95 deletions
diff --git a/chrome/browser/spellchecker/spellcheck_message_filter.cc b/chrome/browser/spellchecker/spellcheck_message_filter.cc index fd296a8b..5ade8cc 100644 --- a/chrome/browser/spellchecker/spellcheck_message_filter.cc +++ b/chrome/browser/spellchecker/spellcheck_message_filter.cc @@ -103,7 +103,7 @@ void SpellCheckMessageFilter::OnCallSpellingService( const string16& text) { DCHECK(!text.empty()); if (!CallSpellingService(route_id, identifier, document_tag, text)) { - std::vector<WebKit::WebTextCheckingResult> results; + std::vector<SpellCheckResult> results; Send(new SpellCheckMsg_RespondSpellingService(route_id, identifier, document_tag, @@ -116,7 +116,7 @@ void SpellCheckMessageFilter::OnCallSpellingService( void SpellCheckMessageFilter::OnTextCheckComplete( int tag, - const std::vector<WebKit::WebTextCheckingResult>& results) { + const std::vector<SpellCheckResult>& results) { Send(new SpellCheckMsg_RespondSpellingService(route_id_, identifier_, tag, diff --git a/chrome/browser/spellchecker/spellcheck_message_filter.h b/chrome/browser/spellchecker/spellcheck_message_filter.h index 17ddf2d..23e26d2 100644 --- a/chrome/browser/spellchecker/spellcheck_message_filter.h +++ b/chrome/browser/spellchecker/spellcheck_message_filter.h @@ -10,12 +10,9 @@ #include "base/memory/scoped_ptr.h" #include "content/public/browser/browser_message_filter.h" +struct SpellCheckResult; class SpellingServiceClient; -namespace WebKit { -struct WebTextCheckingResult; -} - // A message filter implementation that receives spell checker requests from // SpellCheckProvider. class SpellCheckMessageFilter : public content::BrowserMessageFilter { @@ -43,7 +40,7 @@ class SpellCheckMessageFilter : public content::BrowserMessageFilter { // text. We send the given results to a renderer. void OnTextCheckComplete( int tag, - const std::vector<WebKit::WebTextCheckingResult>& results); + const std::vector<SpellCheckResult>& results); // Checks the user profile and sends a JSON-RPC request to the Spelling // service if a user enables the "Ask Google for suggestions" option. When we diff --git a/chrome/browser/spellchecker/spellcheck_message_filter_mac_browsertest.cc b/chrome/browser/spellchecker/spellcheck_message_filter_mac_browsertest.cc index 949da69..d858e69 100644 --- a/chrome/browser/spellchecker/spellcheck_message_filter_mac_browsertest.cc +++ b/chrome/browser/spellchecker/spellcheck_message_filter_mac_browsertest.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2011 The Chromium Authors. All rights reserved. +// Copyright (c) 2012 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. @@ -8,10 +8,10 @@ #include "base/utf_string_conversions.h" #include "chrome/browser/spellchecker/spellcheck_message_filter_mac.h" #include "chrome/common/spellcheck_messages.h" +#include "chrome/common/spellcheck_result.h" #include "chrome/test/base/in_process_browser_test.h" #include "chrome/test/base/ui_test_utils.h" #include "testing/gtest/include/gtest/gtest.h" -#include "third_party/WebKit/Source/WebKit/chromium/public/WebTextCheckingResult.h" namespace { @@ -56,15 +56,15 @@ IN_PROC_BROWSER_TEST_F(SpellCheckMessageFilterMacBrowserTest, int sent_identifier; int sent_tag; - std::vector<WebKit::WebTextCheckingResult> sent_results; + std::vector<SpellCheckResult> sent_results; bool ok = SpellCheckMsg_RespondTextCheck::Read( target->sent_messages_[0], &sent_identifier, &sent_tag, &sent_results); EXPECT_TRUE(ok); EXPECT_EQ(1U, sent_results.size()); - EXPECT_EQ(sent_results[0].position, 0); + EXPECT_EQ(sent_results[0].location, 0); EXPECT_EQ(sent_results[0].length, 2); - EXPECT_EQ(sent_results[0].error, - WebKit::WebTextCheckingResult::ErrorSpelling); + EXPECT_EQ(sent_results[0].type, + SpellCheckResult::SPELLING); } } // namespace diff --git a/chrome/browser/spellchecker/spellcheck_platform_mac.mm b/chrome/browser/spellchecker/spellcheck_platform_mac.mm index fdf850d..1db8190 100644 --- a/chrome/browser/spellchecker/spellcheck_platform_mac.mm +++ b/chrome/browser/spellchecker/spellcheck_platform_mac.mm @@ -18,9 +18,9 @@ #include "base/time.h" #include "chrome/common/spellcheck_common.h" #include "chrome/common/spellcheck_messages.h" +#include "chrome/common/spellcheck_result.h" #include "content/public/browser/browser_message_filter.h" #include "content/public/browser/browser_thread.h" -#include "third_party/WebKit/Source/WebKit/chromium/public/WebTextCheckingResult.h" using base::TimeTicks; using content::BrowserMessageFilter; @@ -58,7 +58,7 @@ void TextCheckingCallback( int document_tag) { // TODO(morrita): Use [NSSpellChecker requestCheckingOfString] // when the build target goes up to 10.6 - std::vector<WebKit::WebTextCheckingResult> check_results; + std::vector<SpellCheckResult> check_results; NSString* text_to_check = base::SysUTF16ToNSString(text); size_t starting_at = 0; while (starting_at < text.size()) { @@ -71,8 +71,8 @@ void TextCheckingCallback( wordCount:NULL]; if (range.length == 0) break; - check_results.push_back(WebKit::WebTextCheckingResult( - WebKit::WebTextCheckingResult::ErrorSpelling, + check_results.push_back(SpellCheckResult( + SpellCheckResult::SPELLING, range.location, range.length)); starting_at = range.location + range.length; diff --git a/chrome/browser/spellchecker/spelling_service_client.cc b/chrome/browser/spellchecker/spelling_service_client.cc index 5acf9d2..49747c7 100644 --- a/chrome/browser/spellchecker/spelling_service_client.cc +++ b/chrome/browser/spellchecker/spelling_service_client.cc @@ -13,9 +13,9 @@ #include "chrome/browser/prefs/pref_service.h" #include "chrome/browser/profiles/profile.h" #include "chrome/common/pref_names.h" +#include "chrome/common/spellcheck_result.h" #include "content/public/browser/browser_thread.h" #include "content/public/common/url_fetcher.h" -#include "third_party/WebKit/Source/WebKit/chromium/public/WebTextCheckingResult.h" #include "unicode/uloc.h" #if defined(GOOGLE_CHROME_BUILD) @@ -103,7 +103,7 @@ void SpellingServiceClient::OnURLFetchComplete( const content::URLFetcher* source) { DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); scoped_ptr<content::URLFetcher> clean_up_fetcher(fetcher_.release()); - std::vector<WebKit::WebTextCheckingResult> results; + std::vector<SpellCheckResult> results; if (source->GetResponseCode() / 100 == 2) { std::string data; source->GetResponseAsString(&data); @@ -114,7 +114,7 @@ void SpellingServiceClient::OnURLFetchComplete( bool SpellingServiceClient::ParseResponse( const std::string& data, - std::vector<WebKit::WebTextCheckingResult>* results) { + std::vector<SpellCheckResult>* results) { // When this JSON-RPC call finishes successfully, the Spelling service returns // an JSON object listed below. // * result - an envelope object representing the result from the APIARY @@ -162,7 +162,7 @@ bool SpellingServiceClient::ParseResponse( for (size_t i = 0; i < misspellings->GetSize(); ++i) { // Retrieve the i-th misspelling region and put it to the given vector. When // the Spelling service sends two or more suggestions, we read only the - // first one because WebTextCheckingResult can store only one suggestion. + // first one because SpellCheckResult can store only one suggestion. DictionaryValue* misspelling = NULL; if (!misspellings->GetDictionary(i, &misspelling)) return false; @@ -182,8 +182,8 @@ bool SpellingServiceClient::ParseResponse( !suggestion->GetString("suggestion", &replacement)) { return false; } - WebKit::WebTextCheckingResult result( - WebKit::WebTextCheckingTypeSpelling, start, length, replacement); + SpellCheckResult result( + SpellCheckResult::SPELLING, start, length, replacement); results->push_back(result); } return true; diff --git a/chrome/browser/spellchecker/spelling_service_client.h b/chrome/browser/spellchecker/spelling_service_client.h index 89a561f..ac12927 100644 --- a/chrome/browser/spellchecker/spelling_service_client.h +++ b/chrome/browser/spellchecker/spelling_service_client.h @@ -17,10 +17,7 @@ class Profile; class TextCheckClientDelegate; - -namespace WebKit { -struct WebTextCheckingResult; -} +struct SpellCheckResult; // A class that encapsulates a JSON-RPC call to the Spelling service to check // text there. This class creates a JSON-RPC request, sends the request to the @@ -37,7 +34,7 @@ struct WebTextCheckingResult; // // void OnTextCheckComplete( // int tag, -// const std::vector<WebKit::WebTextCheckingResult>& results) { +// const std::vector<SpellCheckResult>& results) { // ... // } // @@ -55,7 +52,7 @@ class SpellingServiceClient : public content::URLFetcherDelegate { public: typedef base::Callback<void( int /* tag */, - const std::vector<WebKit::WebTextCheckingResult>& /* results */)> + const std::vector<SpellCheckResult>& /* results */)> TextCheckCompleteCallback; SpellingServiceClient(); @@ -76,7 +73,7 @@ class SpellingServiceClient : public content::URLFetcherDelegate { private: // Parses a JSON-RPC response from the Spelling service. bool ParseResponse(const std::string& data, - std::vector<WebKit::WebTextCheckingResult>* results); + std::vector<SpellCheckResult>* results); // The URLFetcher object used for sending a JSON-RPC request. scoped_ptr<content::URLFetcher> fetcher_; diff --git a/chrome/browser/tab_contents/spelling_menu_observer.cc b/chrome/browser/tab_contents/spelling_menu_observer.cc index 996c9f6..2edf123 100644 --- a/chrome/browser/tab_contents/spelling_menu_observer.cc +++ b/chrome/browser/tab_contents/spelling_menu_observer.cc @@ -18,11 +18,11 @@ #include "chrome/browser/tab_contents/spelling_bubble_model.h" #include "chrome/common/chrome_switches.h" #include "chrome/common/pref_names.h" +#include "chrome/common/spellcheck_result.h" #include "content/browser/renderer_host/render_view_host.h" #include "content/browser/renderer_host/render_widget_host_view.h" #include "content/public/common/context_menu_params.h" #include "grit/generated_resources.h" -#include "third_party/WebKit/Source/WebKit/chromium/public/WebTextCheckingResult.h" #include "ui/base/l10n/l10n_util.h" using content::BrowserThread; @@ -240,7 +240,7 @@ void SpellingMenuObserver::ExecuteCommand(int command_id) { void SpellingMenuObserver::OnTextCheckComplete( int tag, - const std::vector<WebKit::WebTextCheckingResult>& results) { + const std::vector<SpellCheckResult>& results) { animation_timer_.Stop(); // Scan the text-check results and replace the misspelled regions with @@ -251,10 +251,10 @@ void SpellingMenuObserver::OnTextCheckComplete( if (results.empty()) { succeeded_ = false; } else { - typedef std::vector<WebKit::WebTextCheckingResult> WebTextCheckingResults; - for (WebTextCheckingResults::const_iterator it = results.begin(); + typedef std::vector<SpellCheckResult> SpellCheckResults; + for (SpellCheckResults::const_iterator it = results.begin(); it != results.end(); ++it) { - result_.replace(it->position, it->length, it->replacement); + result_.replace(it->location, it->length, it->replacement); } for (std::vector<string16>::const_iterator it = suggestions_.begin(); it != suggestions_.end(); ++it) { diff --git a/chrome/browser/tab_contents/spelling_menu_observer.h b/chrome/browser/tab_contents/spelling_menu_observer.h index 695a91d..0dfd348 100644 --- a/chrome/browser/tab_contents/spelling_menu_observer.h +++ b/chrome/browser/tab_contents/spelling_menu_observer.h @@ -15,12 +15,9 @@ #include "chrome/browser/tab_contents/render_view_context_menu_observer.h" class RenderViewContextMenuProxy; +struct SpellCheckResult; class SpellingServiceClient; -namespace WebKit { -struct WebTextCheckingResult; -} - // An observer that listens to events from the RenderViewContextMenu class and // shows suggestions from the Spelling ("do you mean") service to a context menu // while we show it. This class implements two interfaces: @@ -55,7 +52,7 @@ class SpellingMenuObserver : public RenderViewContextMenuObserver { // misspelled word. void OnTextCheckComplete( int tag, - const std::vector<WebKit::WebTextCheckingResult>& results); + const std::vector<SpellCheckResult>& results); private: // The callback function for base::RepeatingTimer<SpellingMenuClient>. This diff --git a/chrome/chrome_common.gypi b/chrome/chrome_common.gypi index b6af34d..3415464 100644 --- a/chrome/chrome_common.gypi +++ b/chrome/chrome_common.gypi @@ -227,6 +227,7 @@ 'common/spellcheck_common.cc', 'common/spellcheck_common.h', 'common/spellcheck_messages.h', + 'common/spellcheck_result.h', 'common/string_ordinal.cc', 'common/string_ordinal.h', 'common/switch_utils.cc', diff --git a/chrome/common/spellcheck_messages.h b/chrome/common/spellcheck_messages.h index e69983b..e948b47 100644 --- a/chrome/common/spellcheck_messages.h +++ b/chrome/common/spellcheck_messages.h @@ -5,21 +5,22 @@ // IPC messages for spellcheck. // Multiply-included message file, hence no include guard. +#include "chrome/common/spellcheck_result.h" #include "ipc/ipc_message_macros.h" #include "ipc/ipc_platform_file.h" -#include "third_party/WebKit/Source/WebKit/chromium/public/WebTextCheckingResult.h" + #define IPC_MESSAGE_START SpellCheckMsgStart -IPC_ENUM_TRAITS(WebKit::WebTextCheckingResult::Error) +IPC_ENUM_TRAITS(SpellCheckResult::Type) -IPC_STRUCT_TRAITS_BEGIN(WebKit::WebTextCheckingResult) - IPC_STRUCT_TRAITS_MEMBER(error) - IPC_STRUCT_TRAITS_MEMBER(position) +IPC_STRUCT_TRAITS_BEGIN(SpellCheckResult) + IPC_STRUCT_TRAITS_MEMBER(type) + IPC_STRUCT_TRAITS_MEMBER(location) IPC_STRUCT_TRAITS_MEMBER(length) + IPC_STRUCT_TRAITS_MEMBER(replacement) IPC_STRUCT_TRAITS_END() - // Messages sent from the browser to the renderer. IPC_MESSAGE_ROUTED0(SpellCheckMsg_ToggleSpellCheck) @@ -33,7 +34,7 @@ IPC_MESSAGE_ROUTED1(SpellCheckMsg_ToggleSpellPanel, IPC_MESSAGE_ROUTED3(SpellCheckMsg_RespondTextCheck, int /* request identifier given by WebKit */, int /* document tag */, - std::vector<WebKit::WebTextCheckingResult>) + std::vector<SpellCheckResult>) #endif // This message tells the renderer to advance to the next misspelling. It is @@ -64,7 +65,7 @@ IPC_MESSAGE_CONTROL1(SpellCheckMsg_EnableAutoSpellCorrect, IPC_MESSAGE_ROUTED3(SpellCheckMsg_RespondSpellingService, int /* request identifier given by WebKit */, int /* document tag */, - std::vector<WebKit::WebTextCheckingResult>) + std::vector<SpellCheckResult>) #endif // Messages sent from the renderer to the browser. diff --git a/chrome/common/spellcheck_result.h b/chrome/common/spellcheck_result.h new file mode 100644 index 0000000..dfe23dc --- /dev/null +++ b/chrome/common/spellcheck_result.h @@ -0,0 +1,45 @@ +// Copyright (c) 2012 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. + +#ifndef CHROME_COMMON_SPELLCHECK_RESULT_H_ +#define CHROME_COMMON_SPELLCHECK_RESULT_H_ +#pragma once + +#include "base/string16.h" + +// This class mirrors WebKit::WebTextCheckingResult which holds a +// misspelled range inside the checked text. It also contains a +// possible replacement of the misspelling if it is available. +// +// Although SpellCheckResult::Type defines various values Chromium +// only uses the |Spelling| type. otehr values are just reflecting the +// enum definition in the original WebKit class. +// +struct SpellCheckResult { + enum Type { + SPELLING = 1 << 1, + GRAMMAR = 1 << 2, + LINK = 1 << 5, + QUOTE = 1 << 6, + DASH = 1 << 7, + REPLACEMENT = 1 << 8, + CORRECTION = 1 << 9, + SHOWCORRECTIONPANEL = 1 << 10 + }; + + explicit SpellCheckResult( + Type t = SPELLING, + int loc = 0, + int len = 0, + const string16& rep = string16()) + : type(t), location(loc), length(len), replacement(rep) { + } + + Type type; + int location; + int length; + string16 replacement; +}; + +#endif // CHROME_COMMON_SPELLCHECK_RESULT_H_ diff --git a/chrome/renderer/spellchecker/spellcheck.cc b/chrome/renderer/spellchecker/spellcheck.cc index a423dff..e8ccc1a 100644 --- a/chrome/renderer/spellchecker/spellcheck.cc +++ b/chrome/renderer/spellchecker/spellcheck.cc @@ -11,9 +11,9 @@ #include "chrome/common/render_messages.h" #include "chrome/common/spellcheck_common.h" #include "chrome/common/spellcheck_messages.h" +#include "chrome/common/spellcheck_result.h" #include "content/public/renderer/render_thread.h" #include "third_party/hunspell/src/hunspell/hunspell.hxx" -#include "third_party/WebKit/Source/WebKit/chromium/public/WebTextCheckingResult.h" using base::TimeTicks; using content::RenderThread; @@ -148,7 +148,7 @@ bool SpellCheck::SpellCheckWord( bool SpellCheck::SpellCheckParagraph( const string16& text, int tag, - std::vector<WebKit::WebTextCheckingResult>* results) { + std::vector<SpellCheckResult>* results) { #if !defined(OS_MACOSX) // Mac has its own spell checker, so this method will not be used. @@ -175,8 +175,8 @@ bool SpellCheck::SpellCheckParagraph( } if (results) { - results->push_back(WebKit::WebTextCheckingResult( - WebKit::WebTextCheckingTypeSpelling, + results->push_back(SpellCheckResult( + SpellCheckResult::SPELLING, misspelling_start + offset, misspelling_length)); } diff --git a/chrome/renderer/spellchecker/spellcheck.h b/chrome/renderer/spellchecker/spellcheck.h index c4c0e87..8567163 100644 --- a/chrome/renderer/spellchecker/spellcheck.h +++ b/chrome/renderer/spellchecker/spellcheck.h @@ -20,15 +20,12 @@ #include "unicode/uscript.h" class Hunspell; +struct SpellCheckResult; namespace file_util { class MemoryMappedFile; } -namespace WebKit { -struct WebTextCheckingResult; -} - // TODO(morrita): Needs reorg with SpellCheckProvider. // See http://crbug.com/73699. class SpellCheck : public content::RenderProcessObserver { @@ -64,7 +61,7 @@ class SpellCheck : public content::RenderProcessObserver { // or 0. bool SpellCheckParagraph(const string16& text, int tag, - std::vector<WebKit::WebTextCheckingResult>* results); + std::vector<SpellCheckResult>* results); // Find a possible correctly spelled word for a misspelled word. Computes an // empty string if input misspelled word is too long, there is ambiguity, or diff --git a/chrome/renderer/spellchecker/spellcheck_provider.cc b/chrome/renderer/spellchecker/spellcheck_provider.cc index 07b86d9..81b6643 100644 --- a/chrome/renderer/spellchecker/spellcheck_provider.cc +++ b/chrome/renderer/spellchecker/spellcheck_provider.cc @@ -7,6 +7,7 @@ #include "base/command_line.h" #include "chrome/common/chrome_switches.h" #include "chrome/common/spellcheck_messages.h" +#include "chrome/common/spellcheck_result.h" #include "chrome/renderer/chrome_content_renderer_client.h" #include "chrome/renderer/spellchecker/spellcheck.h" #include "content/public/renderer/render_view.h" @@ -21,8 +22,50 @@ using WebKit::WebFrame; using WebKit::WebString; using WebKit::WebTextCheckingCompletion; using WebKit::WebTextCheckingResult; +using WebKit::WebTextCheckingType; using WebKit::WebVector; +COMPILE_ASSERT(int(WebKit::WebTextCheckingTypeSpelling) == + int(SpellCheckResult::SPELLING), mismatching_enums); +COMPILE_ASSERT(int(WebKit::WebTextCheckingTypeGrammar) == + int(SpellCheckResult::GRAMMAR), mismatching_enums); +COMPILE_ASSERT(int(WebKit::WebTextCheckingTypeLink) == + int(SpellCheckResult::LINK), mismatching_enums); +COMPILE_ASSERT(int(WebKit::WebTextCheckingTypeQuote) == + int(SpellCheckResult::QUOTE), mismatching_enums); +COMPILE_ASSERT(int(WebKit::WebTextCheckingTypeDash) == + int(SpellCheckResult::DASH), mismatching_enums); +COMPILE_ASSERT(int(WebKit::WebTextCheckingTypeReplacement) == + int(SpellCheckResult::REPLACEMENT), mismatching_enums); +COMPILE_ASSERT(int(WebKit::WebTextCheckingTypeCorrection) == + int(SpellCheckResult::CORRECTION), mismatching_enums); +COMPILE_ASSERT(int(WebKit::WebTextCheckingTypeShowCorrectionPanel) == + int(SpellCheckResult::SHOWCORRECTIONPANEL), mismatching_enums); + +namespace { +void ToWebResultList( + const std::vector<SpellCheckResult>& results, + WebVector<WebTextCheckingResult>* web_results) { + WebVector<WebTextCheckingResult> list(results.size()); + for (size_t i = 0; i < results.size(); ++i) { + list[i] = WebTextCheckingResult( + static_cast<WebTextCheckingType>(results[i].type), + results[i].location, + results[i].length, + results[i].replacement); + } + + list.swap(*web_results); +} + +WebVector<WebTextCheckingResult> ToWebResultList( + const std::vector<SpellCheckResult>& results) { + WebVector<WebTextCheckingResult> web_results; + ToWebResultList(results, &web_results); + return web_results; +} +} // namespace + SpellCheckProvider::SpellCheckProvider( content::RenderView* render_view, chrome::ChromeContentRendererClient* renderer_client) @@ -157,12 +200,12 @@ void SpellCheckProvider::checkTextOfParagraph( if (!chrome_content_renderer_client_) return; - std::vector<WebKit::WebTextCheckingResult> tmp_results; + std::vector<SpellCheckResult> tmp_results; chrome_content_renderer_client_->spellcheck()->SpellCheckParagraph( string16(text), document_tag_, &tmp_results); - *results = tmp_results; + ToWebResultList(tmp_results, results); #endif } @@ -214,13 +257,13 @@ void SpellCheckProvider::OnAdvanceToNextMisspelling() { void SpellCheckProvider::OnRespondSpellingService( int identifier, int tag, - const std::vector<WebTextCheckingResult>& results) { + const std::vector<SpellCheckResult>& results) { WebTextCheckingCompletion* completion = text_check_completions_.Lookup(identifier); if (!completion) return; text_check_completions_.Remove(identifier); - completion->didFinishCheckingText(results); + completion->didFinishCheckingText(ToWebResultList(results)); } #endif @@ -228,13 +271,13 @@ void SpellCheckProvider::OnRespondSpellingService( void SpellCheckProvider::OnRespondTextCheck( int identifier, int tag, - const std::vector<WebTextCheckingResult>& results) { + const std::vector<SpellCheckResult>& results) { WebTextCheckingCompletion* completion = text_check_completions_.Lookup(identifier); if (!completion) return; text_check_completions_.Remove(identifier); - completion->didFinishCheckingText(results); + completion->didFinishCheckingText(ToWebResultList(results)); } #endif diff --git a/chrome/renderer/spellchecker/spellcheck_provider.h b/chrome/renderer/spellchecker/spellcheck_provider.h index 4fd79f0..9598184 100644 --- a/chrome/renderer/spellchecker/spellcheck_provider.h +++ b/chrome/renderer/spellchecker/spellcheck_provider.h @@ -13,6 +13,7 @@ #include "third_party/WebKit/Source/WebKit/chromium/public/WebSpellCheckClient.h" class RenderView; +struct SpellCheckResult; namespace chrome { class ChromeContentRendererClient; @@ -81,13 +82,13 @@ class SpellCheckProvider : public content::RenderViewObserver, void OnRespondSpellingService( int identifier, int tag, - const std::vector<WebKit::WebTextCheckingResult>& results); + const std::vector<SpellCheckResult>& results); #endif #if defined(OS_MACOSX) void OnRespondTextCheck( int identifier, int tag, - const std::vector<WebKit::WebTextCheckingResult>& results); + const std::vector<SpellCheckResult>& results); #endif void OnToggleSpellCheck(); void OnToggleSpellPanel(bool is_currently_visible); diff --git a/chrome/renderer/spellchecker/spellcheck_provider_mac_unittest.cc b/chrome/renderer/spellchecker/spellcheck_provider_mac_unittest.cc index 75c5357..257851d 100644 --- a/chrome/renderer/spellchecker/spellcheck_provider_mac_unittest.cc +++ b/chrome/renderer/spellchecker/spellcheck_provider_mac_unittest.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2011 The Chromium Authors. All rights reserved. +// Copyright (c) 2012 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. @@ -7,6 +7,7 @@ #include "base/utf_string_conversions.h" #include "base/stl_util.h" #include "chrome/common/spellcheck_messages.h" +#include "chrome/common/spellcheck_result.h" #include "chrome/renderer/spellchecker/spellcheck_provider.h" #include "testing/gtest/include/gtest/gtest.h" #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebString.h" @@ -89,7 +90,7 @@ MessageParameters ReadRequestTextCheck(IPC::Message* message) { void FakeMessageArrival(SpellCheckProvider* provider, const MessageParameters& parameters) { - std::vector<WebKit::WebTextCheckingResult> fake_result; + std::vector<SpellCheckResult> fake_result; bool handled = provider->OnMessageReceived( SpellCheckMsg_RespondTextCheck( 0, diff --git a/chrome/renderer/spellchecker/spellcheck_unittest.cc b/chrome/renderer/spellchecker/spellcheck_unittest.cc index ed06323..eeb0a4d 100644 --- a/chrome/renderer/spellchecker/spellcheck_unittest.cc +++ b/chrome/renderer/spellchecker/spellcheck_unittest.cc @@ -13,8 +13,9 @@ #include "chrome/renderer/spellchecker/spellcheck.h" #include "chrome/common/chrome_paths.h" #include "chrome/common/spellcheck_common.h" +#include "chrome/common/spellcheck_result.h" #include "testing/gtest/include/gtest/gtest.h" -#include "third_party/WebKit/Source/WebKit/chromium/public/WebTextCheckingResult.h" + namespace { @@ -57,8 +58,8 @@ class SpellCheckTest : public testing::Test { protected: void TestSpellCheckParagraph( const string16& input, - const std::vector<WebKit::WebTextCheckingResult>& expected) { - std::vector<WebKit::WebTextCheckingResult> results; + const std::vector<SpellCheckResult>& expected) { + std::vector<SpellCheckResult> results; spell_check()->SpellCheckParagraph(input, 0, &results); @@ -66,7 +67,7 @@ class SpellCheckTest : public testing::Test { EXPECT_EQ(results.size(), expected.size()); size_t size = std::min(results.size(), expected.size()); for (size_t j = 0; j < size; ++j) { - EXPECT_EQ(results[j].type, WebKit::WebTextCheckingTypeSpelling); + EXPECT_EQ(results[j].type, SpellCheckResult::SPELLING); EXPECT_EQ(results[j].location, expected[j].location); EXPECT_EQ(results[j].length, expected[j].length); } @@ -733,23 +734,23 @@ TEST_F(SpellCheckTest, GetAutoCorrectionWord_EN_US) { // Make sure SpellCheckParagraph does not crash if the input is empty. TEST_F(SpellCheckTest, SpellCheckParagraphEmptyParagraph) { - std::vector<WebKit::WebTextCheckingResult> expected; + std::vector<SpellCheckResult> expected; TestSpellCheckParagraph(UTF8ToUTF16(""), expected); } // A simple test case having no misspellings. TEST_F(SpellCheckTest, SpellCheckParagraphNoMisspellings) { const string16 text = UTF8ToUTF16("apple"); - std::vector<WebKit::WebTextCheckingResult> expected; + std::vector<SpellCheckResult> expected; TestSpellCheckParagraph(text, expected); } // A simple test case having one misspelling. TEST_F(SpellCheckTest, SpellCheckParagraphSingleMisspellings) { const string16 text = UTF8ToUTF16("zz"); - std::vector<WebKit::WebTextCheckingResult> expected; - expected.push_back(WebKit::WebTextCheckingResult( - WebKit::WebTextCheckingTypeSpelling, 0, 2)); + std::vector<SpellCheckResult> expected; + expected.push_back(SpellCheckResult( + SpellCheckResult::SPELLING, 0, 2)); TestSpellCheckParagraph(text, expected); } @@ -757,18 +758,18 @@ TEST_F(SpellCheckTest, SpellCheckParagraphSingleMisspellings) { // A simple test case having multiple misspellings. TEST_F(SpellCheckTest, SpellCheckParagraphMultipleMisspellings) { const string16 text = UTF8ToUTF16("zz, zz"); - std::vector<WebKit::WebTextCheckingResult> expected; - expected.push_back(WebKit::WebTextCheckingResult( - WebKit::WebTextCheckingTypeSpelling, 0, 2)); - expected.push_back(WebKit::WebTextCheckingResult( - WebKit::WebTextCheckingTypeSpelling, 4, 2)); + std::vector<SpellCheckResult> expected; + expected.push_back(SpellCheckResult( + SpellCheckResult::SPELLING, 0, 2)); + expected.push_back(SpellCheckResult( + SpellCheckResult::SPELLING, 4, 2)); TestSpellCheckParagraph(text, expected); } // Make sure a relatively long (correct) sentence can be spellchecked. TEST_F(SpellCheckTest, SpellCheckParagraphLongSentence) { - std::vector<WebKit::WebTextCheckingResult> expected; + std::vector<SpellCheckResult> expected; // The text is taken from US constitution preamble. const string16 text = UTF8ToUTF16( "We the people of the United States, in order to form a more perfect " @@ -782,7 +783,7 @@ TEST_F(SpellCheckTest, SpellCheckParagraphLongSentence) { // Make sure all misspellings can be found in a relatively long sentence. TEST_F(SpellCheckTest, SpellCheckParagraphLongSentenceMultipleMisspellings) { - std::vector<WebKit::WebTextCheckingResult> expected; + std::vector<SpellCheckResult> expected; // All 'the' are converted to 'hte' in US consitition preamble. const string16 text = UTF8ToUTF16( @@ -792,18 +793,18 @@ TEST_F(SpellCheckTest, SpellCheckParagraphLongSentenceMultipleMisspellings) { "blessings of liberty to ourselves and our posterity, do ordain and " "establish this Constitution for hte United States of America."); - expected.push_back(WebKit::WebTextCheckingResult( - WebKit::WebTextCheckingTypeSpelling, 3, 3)); - expected.push_back(WebKit::WebTextCheckingResult( - WebKit::WebTextCheckingTypeSpelling, 17, 3)); - expected.push_back(WebKit::WebTextCheckingResult( - WebKit::WebTextCheckingTypeSpelling, 135, 3)); - expected.push_back(WebKit::WebTextCheckingResult( - WebKit::WebTextCheckingTypeSpelling, 163, 3)); - expected.push_back(WebKit::WebTextCheckingResult( - WebKit::WebTextCheckingTypeSpelling, 195, 3)); - expected.push_back(WebKit::WebTextCheckingResult( - WebKit::WebTextCheckingTypeSpelling, 298, 3)); + expected.push_back(SpellCheckResult( + SpellCheckResult::SPELLING, 3, 3)); + expected.push_back(SpellCheckResult( + SpellCheckResult::SPELLING, 17, 3)); + expected.push_back(SpellCheckResult( + SpellCheckResult::SPELLING, 135, 3)); + expected.push_back(SpellCheckResult( + SpellCheckResult::SPELLING, 163, 3)); + expected.push_back(SpellCheckResult( + SpellCheckResult::SPELLING, 195, 3)); + expected.push_back(SpellCheckResult( + SpellCheckResult::SPELLING, 298, 3)); TestSpellCheckParagraph(text, expected); } |