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

Side by Side Diff: webkit/glue/editor_client_impl.cc

Issue 160565: Adds support for the os x spelling panel to chromium. Users can... (Closed) Base URL: http://src.chromium.org/svn/trunk/src/
Patch Set: '' Created 11 years, 3 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 | Annotate | Revision Log
« no previous file with comments | « chrome/renderer/render_view.cc ('k') | webkit/glue/webframe_impl.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2006-2008 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 // The Mac interface forwards most of these commands to the application layer, 5 // The Mac interface forwards most of these commands to the application layer,
6 // and I'm not really sure what to do about most of them. 6 // and I'm not really sure what to do about most of them.
7 7
8 #include "config.h" 8 #include "config.h"
9 9
10 #include "Document.h" 10 #include "Document.h"
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after
145 145
146 bool EditorClientImpl::isGrammarCheckingEnabled() { 146 bool EditorClientImpl::isGrammarCheckingEnabled() {
147 return false; 147 return false;
148 } 148 }
149 149
150 void EditorClientImpl::toggleGrammarChecking() { 150 void EditorClientImpl::toggleGrammarChecking() {
151 NOTIMPLEMENTED(); 151 NOTIMPLEMENTED();
152 } 152 }
153 153
154 int EditorClientImpl::spellCheckerDocumentTag() { 154 int EditorClientImpl::spellCheckerDocumentTag() {
155 #if defined(OS_MACOSX)
156 WebViewDelegate* d = web_view_->delegate();
157 if (d)
158 return d->SpellCheckerDocumentTag();
159 #else
155 NOTIMPLEMENTED(); 160 NOTIMPLEMENTED();
161 #endif // OS_MACOSX
156 return 0; 162 return 0;
157 } 163 }
158 164
159 bool EditorClientImpl::isEditable() { 165 bool EditorClientImpl::isEditable() {
160 return false; 166 return false;
161 } 167 }
162 168
163 bool EditorClientImpl::shouldBeginEditing(WebCore::Range* range) { 169 bool EditorClientImpl::shouldBeginEditing(WebCore::Range* range) {
164 if (editing_client_) { 170 if (editing_client_) {
165 return editing_client_->shouldBeginEditing( 171 return editing_client_->shouldBeginEditing(
(...skipping 665 matching lines...) Expand 10 before | Expand all | Expand 10 after
831 // SpellCheckWord will write (0, 0) into the output vars, which is what our 837 // SpellCheckWord will write (0, 0) into the output vars, which is what our
832 // caller expects if the word is spelled correctly. 838 // caller expects if the word is spelled correctly.
833 int spell_location = -1; 839 int spell_location = -1;
834 int spell_length = 0; 840 int spell_length = 0;
835 WebViewDelegate* d = web_view_->delegate(); 841 WebViewDelegate* d = web_view_->delegate();
836 842
837 // Check to see if the provided str is spelled correctly. 843 // Check to see if the provided str is spelled correctly.
838 if (isContinuousSpellCheckingEnabled() && d) { 844 if (isContinuousSpellCheckingEnabled() && d) {
839 std::wstring word = 845 std::wstring word =
840 webkit_glue::StringToStdWString(WebCore::String(str, length)); 846 webkit_glue::StringToStdWString(WebCore::String(str, length));
841 d->SpellCheck(word, &spell_location, &spell_length); 847 d->SpellCheck(word, spellCheckerDocumentTag(),
848 &spell_location, &spell_length);
842 } else { 849 } else {
843 spell_location = 0; 850 spell_location = 0;
844 spell_length = 0; 851 spell_length = 0;
845 } 852 }
846 853
847 // Note: the Mac code checks if the pointers are NULL before writing to them, 854 // Note: the Mac code checks if the pointers are NULL before writing to them,
848 // so we do too. 855 // so we do too.
849 if (misspellingLocation) 856 if (misspellingLocation)
850 *misspellingLocation = spell_location; 857 *misspellingLocation = spell_location;
851 if (misspellingLength) 858 if (misspellingLength)
852 *misspellingLength = spell_length; 859 *misspellingLength = spell_length;
853 } 860 }
854 861
855 WebCore::String EditorClientImpl::getAutoCorrectSuggestionForMisspelledWord( 862 WebCore::String EditorClientImpl::getAutoCorrectSuggestionForMisspelledWord(
856 const WebCore::String& misspelledWord) { 863 const WebCore::String& misspelledWord) {
857 WebViewDelegate* d = web_view_->delegate(); 864 WebViewDelegate* d = web_view_->delegate();
858 if (!(isContinuousSpellCheckingEnabled() && d)) 865 if (!(isContinuousSpellCheckingEnabled() && d))
859 return WebCore::String(); 866 return WebCore::String();
860 867
861 std::wstring word = webkit_glue::StringToStdWString(misspelledWord); 868 std::wstring word = webkit_glue::StringToStdWString(misspelledWord);
862 869
863 // Do not autocorrect words with capital letters in it except the 870 // Do not autocorrect words with capital letters in it except the
864 // first letter. This will remove cases changing "IMB" to "IBM". 871 // first letter. This will remove cases changing "IMB" to "IBM".
865 for (size_t i = 1; i < word.length(); i++) { 872 for (size_t i = 1; i < word.length(); i++) {
866 if (u_isupper(static_cast<UChar32>(word[i]))) 873 if (u_isupper(static_cast<UChar32>(word[i])))
867 return WebCore::String(); 874 return WebCore::String();
868 } 875 }
869 876
870 std::wstring autocorrect_word = d->GetAutoCorrectWord(word); 877 std::wstring autocorrect_word =
878 d->GetAutoCorrectWord(word, spellCheckerDocumentTag());
871 return webkit_glue::StdWStringToString(autocorrect_word); 879 return webkit_glue::StdWStringToString(autocorrect_word);
872 } 880 }
873 881
874 void EditorClientImpl::checkGrammarOfString(const UChar*, int length, 882 void EditorClientImpl::checkGrammarOfString(const UChar*, int length,
875 WTF::Vector<WebCore::GrammarDetail>& , 883 WTF::Vector<WebCore::GrammarDetail>& ,
876 int* badGrammarLocation, 884 int* badGrammarLocation,
877 int* badGrammarLength) { 885 int* badGrammarLength) {
878 NOTIMPLEMENTED(); 886 NOTIMPLEMENTED();
879 if (badGrammarLocation) 887 if (badGrammarLocation)
880 *badGrammarLocation = 0; 888 *badGrammarLocation = 0;
881 if (badGrammarLength) 889 if (badGrammarLength)
882 *badGrammarLength = 0; 890 *badGrammarLength = 0;
883 } 891 }
884 892
885 void EditorClientImpl::updateSpellingUIWithGrammarString(const WebCore::String&, 893 void EditorClientImpl::updateSpellingUIWithGrammarString(const WebCore::String&,
886 const WebCore::GrammarD etail& detail) { 894 const WebCore::GrammarD etail& detail) {
887 NOTIMPLEMENTED(); 895 NOTIMPLEMENTED();
888 } 896 }
889 897
890 void EditorClientImpl::updateSpellingUIWithMisspelledWord(const WebCore::String& ) { 898 void EditorClientImpl::updateSpellingUIWithMisspelledWord(
891 NOTIMPLEMENTED(); 899 const WebCore::String& misspelled_word) {
900 std::wstring word = webkit_glue::StringToStdWString(misspelled_word);
901 WebViewDelegate* d = web_view_->delegate();
902 if (d) {
903 d->UpdateSpellingUIWithMisspelledWord(word);
904 }
892 } 905 }
893 906
894 void EditorClientImpl::showSpellingUI(bool show) { 907 void EditorClientImpl::showSpellingUI(bool show) {
895 NOTIMPLEMENTED(); 908 WebViewDelegate* d = web_view_->delegate();
909 if (d) {
910 d->ShowSpellingUI(show);
911 }
896 } 912 }
897 913
898 bool EditorClientImpl::spellingUIIsShowing() { 914 bool EditorClientImpl::spellingUIIsShowing() {
899 return false; 915 // SpellingPanel visibility is stored in the web_view_ every time a toggle
916 // message is sent from the browser. If we were to send a message to the
917 // browser and ask for the visibility, then we run into problems accessing
918 // cocoa methods on the UI thread.
919 return web_view_->GetSpellingPanelVisibility();
900 } 920 }
901 921
902 void EditorClientImpl::getGuessesForWord(const WebCore::String&, 922 void EditorClientImpl::getGuessesForWord(const WebCore::String&,
903 WTF::Vector<WebCore::String>& guesses) { 923 WTF::Vector<WebCore::String>& guesses) {
904 NOTIMPLEMENTED(); 924 NOTIMPLEMENTED();
905 } 925 }
906 926
907 void EditorClientImpl::setInputMethodState(bool enabled) { 927 void EditorClientImpl::setInputMethodState(bool enabled) {
908 if (editing_client_) 928 if (editing_client_)
909 editing_client_->setInputMethodEnabled(enabled); 929 editing_client_->setInputMethodEnabled(enabled);
910 } 930 }
OLDNEW
« no previous file with comments | « chrome/renderer/render_view.cc ('k') | webkit/glue/webframe_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698