summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorsidchat@google.com <sidchat@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2009-06-10 22:32:21 +0000
committersidchat@google.com <sidchat@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2009-06-10 22:32:21 +0000
commit26ea6c409fedeabdabb53f41fcc80b79d2575cf9 (patch)
tree462cc525d12f6cebe47b60094aa5a346e46a92fd
parentfda8974e0a1daa704be0dc33fe04ae4564310c12 (diff)
downloadchromium_src-26ea6c409fedeabdabb53f41fcc80b79d2575cf9.zip
chromium_src-26ea6c409fedeabdabb53f41fcc80b79d2575cf9.tar.gz
chromium_src-26ea6c409fedeabdabb53f41fcc80b79d2575cf9.tar.bz2
Stop auto-correcting abbreviations.BUG= www.crbug.com/12921TEST= For command line --auto-spell-correct, "IMB" should not change to "IBM"
Review URL: http://codereview.chromium.org/119210 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@18099 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--chrome/renderer/render_view.cc7
-rw-r--r--chrome/renderer/render_view.h3
-rw-r--r--webkit/glue/editor_client_impl.cc19
-rw-r--r--webkit/glue/webview_delegate.h4
4 files changed, 22 insertions, 11 deletions
diff --git a/chrome/renderer/render_view.cc b/chrome/renderer/render_view.cc
index 557bc0d..d5db96e 100644
--- a/chrome/renderer/render_view.cc
+++ b/chrome/renderer/render_view.cc
@@ -2165,13 +2165,16 @@ void RenderView::SpellCheck(const std::wstring& word, int& misspell_location,
&misspell_length));
}
-void RenderView::GetAutoCorrectWord(const std::wstring& misspelled_word,
- std::wstring& autocorrect_word) {
+std::wstring RenderView::GetAutoCorrectWord(
+ const std::wstring& misspelled_word) {
+ std::wstring autocorrect_word;
const CommandLine& command_line = *CommandLine::ForCurrentProcess();
if (command_line.HasSwitch(switches::kAutoSpellCorrect)) {
Send(new ViewHostMsg_GetAutoCorrectWord(routing_id_, misspelled_word,
&autocorrect_word));
}
+
+ return autocorrect_word;
}
void RenderView::SetInputMethodState(bool enabled) {
diff --git a/chrome/renderer/render_view.h b/chrome/renderer/render_view.h
index a1928ba..a0dd47a 100644
--- a/chrome/renderer/render_view.h
+++ b/chrome/renderer/render_view.h
@@ -312,8 +312,7 @@ class RenderView : public RenderWidget,
virtual void FocusAccessibilityObject(WebCore::AccessibilityObject* acc_obj);
virtual void SpellCheck(const std::wstring& word, int& misspell_location,
int& misspell_length);
- virtual void GetAutoCorrectWord(const std::wstring& misspelled_word,
- std::wstring& autocorrect_word);
+ virtual std::wstring GetAutoCorrectWord(const std::wstring& word);
virtual void SetInputMethodState(bool enabled);
virtual void ScriptedPrint(WebFrame* frame);
virtual void WebInspectorOpened(int num_resources);
diff --git a/webkit/glue/editor_client_impl.cc b/webkit/glue/editor_client_impl.cc
index a4b8380..04f7321 100644
--- a/webkit/glue/editor_client_impl.cc
+++ b/webkit/glue/editor_client_impl.cc
@@ -686,7 +686,7 @@ void EditorClientImpl::textFieldDidEndEditing(WebCore::Element* element) {
// Hide any showing popup.
web_view_->HideAutoCompletePopup();
-
+
// Notify any password-listener of the focus change.
WebCore::HTMLInputElement* input_element =
webkit_glue::ElementToHTMLInputElement(element);
@@ -846,6 +846,8 @@ void EditorClientImpl::checkSpellingOfString(const UChar* str, int length,
int spell_location = -1;
int spell_length = 0;
WebViewDelegate* d = web_view_->delegate();
+
+ // Check to see if the provided str is spelled correctly.
if (isContinuousSpellCheckingEnabled() && d) {
std::wstring word =
webkit_glue::StringToStdWString(WebCore::String(str, length));
@@ -866,12 +868,19 @@ void EditorClientImpl::checkSpellingOfString(const UChar* str, int length,
WebCore::String EditorClientImpl::getAutoCorrectSuggestionForMisspelledWord(
const WebCore::String& misspelledWord) {
WebViewDelegate* d = web_view_->delegate();
- std::wstring autocorrect_word;
- if (isContinuousSpellCheckingEnabled() && d) {
- std::wstring word = webkit_glue::StringToStdWString(misspelledWord);
- d->GetAutoCorrectWord(word, autocorrect_word);
+ if (!(isContinuousSpellCheckingEnabled() && d))
+ return WebCore::String();
+
+ std::wstring word = webkit_glue::StringToStdWString(misspelledWord);
+
+ // Do not autocorrect words with capital letters in it except the
+ // first letter. This will remove cases changing "IMB" to "IBM".
+ for (size_t i = 1; i < word.length(); i++) {
+ if (u_isupper(static_cast<UChar32>(word[i])))
+ return WebCore::String();
}
+ std::wstring autocorrect_word = d->GetAutoCorrectWord(word);
return webkit_glue::StdWStringToString(autocorrect_word);
}
diff --git a/webkit/glue/webview_delegate.h b/webkit/glue/webview_delegate.h
index e6e0891..a4b5061 100644
--- a/webkit/glue/webview_delegate.h
+++ b/webkit/glue/webview_delegate.h
@@ -780,8 +780,8 @@ class WebViewDelegate : virtual public WebWidgetDelegate {
// Computes an auto correct word for a misspelled word. If no word is found,
// empty string is computed.
- virtual void GetAutoCorrectWord(const std::wstring& misspelled_word,
- std::wstring& autocorrect_word) {
+ virtual std::wstring GetAutoCorrectWord(const std::wstring& misspelled_word) {
+ return std::wstring();
}
// Changes the state of the input method editor.