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

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

Issue 227006: Move some more methods from WebViewDelegate to WebViewClient.... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 11 years, 2 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 | « webkit/api/public/WebViewClient.h ('k') | webkit/glue/webview_delegate.h » ('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 805 matching lines...) Expand 10 before | Expand all | Expand 10 after
816 } 816 }
817 817
818 void EditorClientImpl::ignoreWordInSpellDocument(const WebCore::String&) { 818 void EditorClientImpl::ignoreWordInSpellDocument(const WebCore::String&) {
819 NOTIMPLEMENTED(); 819 NOTIMPLEMENTED();
820 } 820 }
821 821
822 void EditorClientImpl::learnWord(const WebCore::String&) { 822 void EditorClientImpl::learnWord(const WebCore::String&) {
823 NOTIMPLEMENTED(); 823 NOTIMPLEMENTED();
824 } 824 }
825 825
826 void EditorClientImpl::checkSpellingOfString(const UChar* str, int length, 826 void EditorClientImpl::checkSpellingOfString(const UChar* text, int length,
827 int* misspellingLocation, 827 int* misspellingLocation,
828 int* misspellingLength) { 828 int* misspellingLength) {
829 // SpellCheckWord will write (0, 0) into the output vars, which is what our 829 // SpellCheckWord will write (0, 0) into the output vars, which is what our
830 // caller expects if the word is spelled correctly. 830 // caller expects if the word is spelled correctly.
831 int spell_location = -1; 831 int spell_location = -1;
832 int spell_length = 0; 832 int spell_length = 0;
833 WebViewDelegate* d = webview_->delegate();
834 833
835 // Check to see if the provided str is spelled correctly. 834 // Check to see if the provided text is spelled correctly.
836 if (isContinuousSpellCheckingEnabled() && d) { 835 if (isContinuousSpellCheckingEnabled() && webview_->client()) {
837 std::wstring word = 836 webview_->client()->spellCheck(
838 webkit_glue::StringToStdWString(WebCore::String(str, length)); 837 WebString(text, length), spell_location, spell_length);
839 d->SpellCheck(word, &spell_location, &spell_length);
840 } else { 838 } else {
841 spell_location = 0; 839 spell_location = 0;
842 spell_length = 0; 840 spell_length = 0;
843 } 841 }
844 842
845 // Note: the Mac code checks if the pointers are NULL before writing to them, 843 // Note: the Mac code checks if the pointers are NULL before writing to them,
846 // so we do too. 844 // so we do too.
847 if (misspellingLocation) 845 if (misspellingLocation)
848 *misspellingLocation = spell_location; 846 *misspellingLocation = spell_location;
849 if (misspellingLength) 847 if (misspellingLength)
850 *misspellingLength = spell_length; 848 *misspellingLength = spell_length;
851 } 849 }
852 850
853 WebCore::String EditorClientImpl::getAutoCorrectSuggestionForMisspelledWord( 851 WebCore::String EditorClientImpl::getAutoCorrectSuggestionForMisspelledWord(
854 const WebCore::String& misspelledWord) { 852 const WebCore::String& misspelledWord) {
855 WebViewDelegate* d = webview_->delegate(); 853 if (!(isContinuousSpellCheckingEnabled() && webview_->client()))
856 if (!(isContinuousSpellCheckingEnabled() && d))
857 return WebCore::String(); 854 return WebCore::String();
858 855
859 std::wstring word = webkit_glue::StringToStdWString(misspelledWord);
860
861 // Do not autocorrect words with capital letters in it except the 856 // Do not autocorrect words with capital letters in it except the
862 // first letter. This will remove cases changing "IMB" to "IBM". 857 // first letter. This will remove cases changing "IMB" to "IBM".
863 for (size_t i = 1; i < word.length(); i++) { 858 for (size_t i = 1; i < misspelledWord.length(); i++) {
864 if (u_isupper(static_cast<UChar32>(word[i]))) 859 if (u_isupper(static_cast<UChar32>(misspelledWord[i])))
865 return WebCore::String(); 860 return WebCore::String();
866 } 861 }
867 862
868 std::wstring autocorrect_word = d->GetAutoCorrectWord(word); 863 return webkit_glue::WebStringToString(webview_->client()->autoCorrectWord(
869 return webkit_glue::StdWStringToString(autocorrect_word); 864 webkit_glue::StringToWebString(misspelledWord)));
870 } 865 }
871 866
872 void EditorClientImpl::checkGrammarOfString(const UChar*, int length, 867 void EditorClientImpl::checkGrammarOfString(const UChar*, int length,
873 WTF::Vector<WebCore::GrammarDetail>& , 868 WTF::Vector<WebCore::GrammarDetail>& ,
874 int* badGrammarLocation, 869 int* badGrammarLocation,
875 int* badGrammarLength) { 870 int* badGrammarLength) {
876 NOTIMPLEMENTED(); 871 NOTIMPLEMENTED();
877 if (badGrammarLocation) 872 if (badGrammarLocation)
878 *badGrammarLocation = 0; 873 *badGrammarLocation = 0;
879 if (badGrammarLength) 874 if (badGrammarLength)
880 *badGrammarLength = 0; 875 *badGrammarLength = 0;
881 } 876 }
882 877
883 void EditorClientImpl::updateSpellingUIWithGrammarString(const WebCore::String&, 878 void EditorClientImpl::updateSpellingUIWithGrammarString(const WebCore::String&,
884 const WebCore::GrammarD etail& detail) { 879 const WebCore::GrammarD etail& detail) {
885 NOTIMPLEMENTED(); 880 NOTIMPLEMENTED();
886 } 881 }
887 882
888 void EditorClientImpl::updateSpellingUIWithMisspelledWord( 883 void EditorClientImpl::updateSpellingUIWithMisspelledWord(
889 const WebCore::String& misspelled_word) { 884 const WebCore::String& misspelled_word) {
890 std::wstring word = webkit_glue::StringToStdWString(misspelled_word); 885 if (webview_->client()) {
891 WebViewDelegate* d = webview_->delegate(); 886 webview_->client()->updateSpellingUIWithMisspelledWord(
892 if (d) { 887 webkit_glue::StringToWebString(misspelled_word));
893 d->UpdateSpellingUIWithMisspelledWord(word);
894 } 888 }
895 } 889 }
896 890
897 void EditorClientImpl::showSpellingUI(bool show) { 891 void EditorClientImpl::showSpellingUI(bool show) {
898 WebViewDelegate* d = webview_->delegate(); 892 ASSERT_NOT_REACHED();
899 if (d) {
900 d->ShowSpellingUI(show);
901 }
902 } 893 }
903 894
904 bool EditorClientImpl::spellingUIIsShowing() { 895 bool EditorClientImpl::spellingUIIsShowing() {
905 // SpellingPanel visibility is stored in the webview_ every time a toggle 896 // SpellingPanel visibility is stored in the webview_ every time a toggle
906 // message is sent from the browser. If we were to send a message to the 897 // message is sent from the browser. If we were to send a message to the
907 // browser and ask for the visibility, then we run into problems accessing 898 // browser and ask for the visibility, then we run into problems accessing
908 // cocoa methods on the UI thread. 899 // cocoa methods on the UI thread.
909 return webview_->GetSpellingPanelVisibility(); 900 return webview_->GetSpellingPanelVisibility();
910 } 901 }
911 902
912 void EditorClientImpl::getGuessesForWord(const WebCore::String&, 903 void EditorClientImpl::getGuessesForWord(const WebCore::String&,
913 WTF::Vector<WebCore::String>& guesses) { 904 WTF::Vector<WebCore::String>& guesses) {
914 NOTIMPLEMENTED(); 905 NOTIMPLEMENTED();
915 } 906 }
916 907
917 void EditorClientImpl::setInputMethodState(bool enabled) { 908 void EditorClientImpl::setInputMethodState(bool enabled) {
918 if (webview_->client()) 909 if (webview_->client())
919 webview_->client()->setInputMethodEnabled(enabled); 910 webview_->client()->setInputMethodEnabled(enabled);
920 } 911 }
OLDNEW
« no previous file with comments | « webkit/api/public/WebViewClient.h ('k') | webkit/glue/webview_delegate.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698