It seems that the spell checker does not work. Would it be possible to create this feature? If yes, can we consider the management of multiple languages?
Thank you for your reply and sorry for my broken English ;)
Comment #1
Posted on Oct 27, 2010 by Quick HorseShould be possible. Patches welcome :-).
Comment #2
Posted on Nov 18, 2010 by Quick HorseThis thread discusses changes to the spellcheck framework in Chromium that would make it easier to implement spellcheck support in CEF: http://groups.google.com/a/chromium.org/group/chromium-dev/browse_thread/thread/b1b78a1f9ca12f1d
Comment #3
Posted on Feb 4, 2013 by Massive Rhinoconsidering there has been no word on this since 2010 how likely is this feature to be created?
Comment #4
Posted on Aug 14, 2013 by Quick HorseThe Chromium spell checking implementation lives in chrome/browser/spellchecker/ and chrome/renderer/spellchecker/. Related Chrome UI lives in chrome/browser/tab_contents/.
Searching for "ENABLE_SPELLCHECK" in the Chromium source code gives an idea of the required hooks: https://code.google.com/p/chromium/codesearch#search/&q=ENABLE_SPELLCHECK&sq=package:chromium&type=cs
Add a new SpellCheckMessageFilter or SpellCheckMessageFilterMac in ContentBrowserClient::RenderProcessHostCreated.
Add a new SpellCheck thread observer in ContentRendererClient::RenderThreadStarted.
It would be reasonable to discuss with the spellcheck subsystem owners about moving the implementation from chrome/ to content/ so that CEF can share it more easily. If that's not possible then care should be taken to avoid copying chrome files where the majority of the implementation would be shared because each copied file adds a significant maintenance burden.
Comment #5
Posted on Aug 23, 2013 by Grumpy ElephantI'm currently working on implementing the spellcheck feature, and I am running into code that relies on the Profile functionality. I was wondering if you had run into that with other features and if so, what you did to work around it?
Comment #6
Posted on Aug 23, 2013 by Quick Horse@comment#5: What specific Profile methods do you need? Profile inherits from content::BrowserContext -- CEF has its own BrowserContext implementation in CefBrowserContext.
Comment #7
Posted on Aug 23, 2013 by Grumpy ElephantAfter some more code investigation, it looks like I can refactor the dependency on Profile to a dependency on BrowserContext instead. I will see if the spell check owners approve of this change.
Comment #8
Posted on Aug 26, 2013 by Grumpy ElephantI realize this may be impossible to help with and I am not quite sure if this is me not pulling in everything needed into the gyp files, but I am getting undefined references for some IPC message classes from the spell check code. I can't figure out what is supposed to define the implementation of the missing methods. Any insight from similar classes in the past?
Examples:
out/Release/obj.target/cef/libcef.so: undefined reference to SpellCheckMsg_RespondSpellingService::SpellCheckMsg_RespondSpellingService(int, int const&, bool const&, std::basic_string<unsigned short, base::string16_char_traits, std::allocator<unsigned short> > const&, std::vector<SpellCheckResult, std::allocator<SpellCheckResult> > const&)'
out/Release/obj.target/cef/libcef.so: undefined reference to
SpellCheckMsg_CustomDictionaryChanged::Read(IPC::Message const*, Tuple2, std::allocator >, std::allocator, std::allocator > > >, std::vector, std::allocator >, std::allocator, std::allocator > > > >*)'
Comment #9
Posted on Aug 26, 2013 by Quick Horse@comment#8: The definitions appear to come from chrome/common/spellcheck_messages.h. You should include this file (or copy the definitions, depending on what's required) in libcef/common/cef_messages.h. There's a bunch of macro magic involved -- see ipc/ipc_message_macros.h for details.
Comment #10
Posted on Aug 26, 2013 by Grumpy ElephantAh - perfect! That was the missing piece - knowing where to include that file. Thanks!
Comment #11
Posted on Sep 17, 2013 by Grumpy ElephantAnother question for you. The new spell check code on the chromium trunk utilizes PrefService* UserPrefs::Get(content::BrowserContext* context) to get the pref service. However the libcef code doesn't seem to call UserPrefs::Set() anywhere. Where would be the appropriate place to put this?
Comment #12
Posted on Sep 20, 2013 by Grumpy ElephantI believe I have my first cut complete, however it depends on the current Chromium trunk (a spell check refactor was required). Do you want a patch with just the spell check changes or a patch including the changes required to compile against the trunk?
Comment #13
Posted on Sep 20, 2013 by Quick Horse@comment#11: CEF creates its PrefService in CefBrowserMainParts::PreCreateThreads(). I guess you could set it there.
@comment#12: Please include just the CEF changes with a patch against CEF trunk, and link the chromium commit that provides the necessary Chromium changes.
Comment #14
Posted on Sep 24, 2013 by Grumpy ElephantSpellcheck implementation patch attached. Requires this chromium commit: https://codereview.chromium.org/23868013/
- spellcheck.patch 51.5KB
Comment #15
Posted on Oct 10, 2013 by Swift Pandai got a link error (undefined chrome::kCustomDictionaryFileName)
i think you have to copy
const base::FilePath::CharType kCustomDictionaryFileName[] = FPL("Custom Dictionary.txt");
from chrome/common/chrome_constants.cc:159 to libcef...
Comment #16
Posted on Oct 24, 2013 by Grumpy ElephantUpdated to trunk, removed some code that snuck in from other patches, added missing constant.
- spellcheck2.patch 51.57KB
Comment #17
Posted on Feb 27, 2014 by Massive RhinoHello, has the spellchecker patch been integrated to the CEF binary release? If not do you have a timeline when it will be? Thanks a lot.
Comment #18
Posted on Apr 4, 2014 by Massive LionI updated the patch to support 1750 CEF, but when typing in a contenteditable it is very slow. Has anybody else experienced this?
Comment #19
Posted on May 17, 2014 by Grumpy WombatWhat is the status on the spell check patch? Any ideas on when it could be integrated? I only see the version for rev 1484, where's the rev 1750 version?
Comment #20
Posted on Jun 27, 2014 by Swift BearIt seems that spellcheck still isn't working in CEF. Can anyone please clarify status? There's a patch above - did that not work / why has that not been included in updated versions of CEF?
Comment #21
Posted on Jul 9, 2014 by Massive RabbitHere is an update of the spelling patch for branch 1916. Some notes: Added the Chrome Preference "spellcheck.dictionary_URL" and patched Chrome to use "spellcheck.dictionary_URL" if it is not empty. (We needed to use our own server.) NOTE: This means the patch is from .../src instead of .../src/cef
Made a batch/script file to generate the patch, and sorted the items by path name. (This is to make it easier to compare patches.)
Converted the preferences back to PrefRegistrySimple. (That is what CEF was using.) Changed the dictionary download folder to be next to the Cache. (The app folder may not be a valid download location.)
Added cefclient_gtk.cpp, cefclient_mac.cpp, and cefclient_win.cpp, and implemented the language and locale read in only in cefclient_win.cpp. (It will be a while before we can get to the Mac. The needed code is short. Failure to add the Mac or Linux code won't crash or cause an exception, but it will default to "en-US".)
Things not done: Did not change the name of the name of SpellCheckMessageFilter. Did not add CefString to files that didn't already use it. (Both of these should be changed to better follow the CEF conventions.)
I haven't noticed any performance issue in contenteditable div tags. The issue mentioned for 1750 is probably fixed in Chromium.
Comment #22
Posted on Jul 9, 2014 by Massive RabbitCorrection to a linecount error in the patch.
- spellcheck.patch 68.58KB
Comment #23
Posted on Jul 10, 2014 by Grumpy WombatThanks for the updated patch! I tried compiling the 1916 with the patch applied but out of the box spell checking didn't work on my Mac.
1) Do I need to set up a Hunspell dictionary server to make it work? On the Mac, is there a way to use the native spell check built into OS X? 2) It seems like you forgot to attach the script you used to generate and sort the patch.
Comment #24
Posted on Jul 11, 2014 by Grumpy HippoAlso wondering about an answer to Thomas's questions just now.
Am closely watching this too, extremely grateful for your work on the patch!
Comment #25
Posted on Jul 23, 2014 by Massive RabbitComment deleted
Comment #26
Posted on Jul 23, 2014 by Massive Rabbit1) Do I need to set up a Hunspell dictionary server to make it work? On the Mac, is there a way to use the native spell check built into OS X? Yes you need to specify a server. The spelling features turn off if --dictionary_url= is not on the command line. (If you want to test with the Google server it is http://cache.pack.google.com/edgedl/chrome/dict/) I did not test it but try file:/// for the server url. The test on the server url that turns on the spelling checking is just a string length test. ("about:blank" may also work for forcing the local only file.) I didn't want the spelling to turn on if the url was blank - that will actually fallback to the Google server. Mac - there are more files in the chrome/browser/spellingchecker for Mac. (We wanted Hunspell, not the the Mac native spelling.)
2) It seems like you forgot to attach the script you used to generate and sort the patch. Oh it is just a windows .bat file where I use the file name on continued lines so I can sort them. Attached in case it is useful as a reference.
Comment #27
Posted on Jul 23, 2014 by Massive Rabbit(No comment was entered for this change.)
Attachments- SpellingPatchFiles.bat 1.96KB
Comment #28
Posted on Jul 25, 2014 by Grumpy WombatThanks, however it seems like at least on the Mac it's not working: If I launch cefclient --dictionary_url=http://localhost:2000/ I don't get a connection on that port when accessing a page with a textarea, and the spell check doesn't work. Also Google's URL returns a 404 so I'm not sure what to serve at the dictionary URL.
Comment #29
Posted on Jul 25, 2014 by Swift BearAh, please help us! Spell check is so important.
Comment #30
Posted on Aug 7, 2014 by Massive RabbitThanks, however it seems like at least on the Mac it's not working: If I launch cefclient --dictionary_url=http://localhost:2000/ I don't get a connection on that port when accessing a page with a textarea, and the spell check doesn't work. We haven't build the mac side. (We want to but we have to finish something else first. It may be several weeks.) The mac may not be set to use hunspell, and we didn't add the native spelling support files. If you want to debug the Mac side set breakpoints on these functions and see if they are setting up correctly: SpellcheckHunspellDictionary::SpellcheckHunspellDictionary - To make sure the object is created. void SpellcheckHunspellDictionary::Load() { bool SpellcheckHunspellDictionary::IsDownloadFailure() { - If this happens something went rong trying to get the file. void SpellcheckHunspellDictionary::OnURLFetchComplete( const net::URLFetcher* source) {
Also Google's URL returns a 404 so I'm not sure what to serve at the dictionary URL. The folder will give a 404, but the specific file should work. Here is the en-us dictionary: https://dl.google.com/edgedl/chrome/dict/en-us-3-0.bdic
Comment #31
Posted on Oct 7, 2014 by Quick Horse@#14, #22: Thanks for the patches. I kept the public API that you defined but implemented spell checking support somewhat differently.
Trunk revision 1859 adds spell checking support on all platforms. This includes: - Red underline of misspelled words in html text areas. - Right-click context menu options to correct the misspelled word. - New CefBrowser::ReplaceMisspelling method for accepting a word replacement. - Methods added to CefContextMenuParams for retrieving spelling-related information. - Uses the unified text checker when auto-correct is not enabled to match Google Chrome behavior. - On Windows and Linux a hunspell dictionary file will be downloaded to the "/Dictionaries" directory as needed, or used from the directory if the file already exists there. The dictionary file will be downloaded from http://cache.pack.google.com/edgedl/chrome/dict/-3-0.bdic where is the language abbreviation. - On OS X the spell checking implementation will use the system NSSpellChecker implementation.
The following command-line flags have been added: --disable-spell-checking => Disable spell-checking support (no red underline, no dictionary file download, etc). --enable-spelling-auto-correct => Automatically correct common misspellings while typing (like 'omre' to 'more' on Windows/Linux or 'ehlo' to 'helo' on OS X). --enable-spelling-service => Enable use of the remote Google spelling service (this requires Google API keys). --override-spell-check-lang= => Use the specified dictionary language instead of the language specified in the locales.pak file. To see the default/supported dictionary languages: https://code.google.com/p/chromium/codesearch#search/&q=IDS_SPELLCHECK_DICTIONARY%20xtb&sq=package:chromium
I've also filed http://crbug.com/421186 for moving the Chrome spell checking implementation to somewhere that CEF can more easily share it.
Comment #32
Posted on Oct 9, 2014 by Helpful PandaCompiled and ran cefsimple and cefclient on OSX with spellchecking working properly.
Is there something cefclient/cefsimple are doing that they didn't do previously in order to get spellchecking to work on OSX?
In my own implementation, on this line of user_prefs.cc I get an EXC_BAD_ACCESS as soon as I hit spacebar in a textarea.
return static_cast(context->GetUserData(UserDataKey()))->prefs_;
Comment #33
Posted on Oct 9, 2014 by Quick Horse@#32: Did you update the locales files in the framework Resources directory? Are you setting any CefSettings, CefBrowserSettings or command-line flags? What is the symbolized stack trace for the crash?
Comment #34
Posted on Oct 10, 2014 by Swift DogComment deleted
Comment #35
Posted on Oct 10, 2014 by Helpful PandaI'm running with --disable-gpu flag, and these CefSettings no_sandbox = true windowless_rendering_enabled = false
As far as the resources directory - I used the make_distrib scripts to create a Release binary package, and am usin the results of that in my project.
Comment #36
Posted on Oct 19, 2014 by Quick HorseTrunk revision 1879 and 2171 branch revision 1880 add additional spell checking improvements: - Add "Add to dictionary" context menu option. - Use available translations for "Add to dictionary" and "No spelling suggestions". - Fix placement of context menu separators. - Display the "No spelling suggestions" option as grayed out.
Comment #37
Posted on Oct 23, 2014 by Helpful PandaHere's a rundown of what causes crashing for me on Mac as soon as a textarea spellcheck would occur.
- Simple CefRequestContextHandler implementation with virtual method GetCookieManager()
- CefRequestContext::CreateContext(SimpleRequestContextHandler)
- CefBrowserHost::CreateBrowserSync(... passing the CefRequestContext created earlier)
Crashes cefsimple as soon as a textarea spellcheck would occur.
Comment #38
Posted on Nov 5, 2014 by Swift MonkeyQuestion: Can we change the locale/spell checking language during runtime after initialization? (i.e. not via command-line)
PS: Great work! Using it on Windows now and works very well. Just need to be able to change the spellchecking language.
Comment #39
Posted on Nov 7, 2014 by Quick Horse@#38: Not currently. The ability to change spell checking language during runtime may be added as part of issue #1058 resolution.
Comment #40
Posted on Nov 8, 2014 by Swift MonkeyGreat. Thanks a lot. Is there a place to see the current development focus? (I realize an ETA is hard to give, so just for me to have a sense of whether we're talking weeks, months or next year).
Comment #41
Posted on Dec 29, 2014 by Happy Monkey@#18: Could you Please attach patch for 1750?
Or anyone else who have such one, could you Please attach it here?
I've tried to backport from 1916, compiles Ok, but cefclient.exe doesn't render html at all.
- spellcheck1750.patch 68.55KB
Comment #42
Posted on May 5, 2015 by Grumpy RhinoHello, if someone is still active here, I've wanted to know how the patch needs to be applied to the CEF build. The CEF build doesn't contain some of the files, like: /chrome/browser/spellchecker/spellcheck_action.cc'. Can someone please explain how the integration works?
Status: Fixed
Labels:
Type-Enhancement
Priority-Medium
CEF3