alderlopez / chromiumembedded

Automatically exported from code.google.com/p/chromiumembedded
0 stars 1 forks source link

CEF3: Add spell checking support #137

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
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 ;)

Original issue reported on code.google.com by f.camon....@gmail.com on 27 Oct 2010 at 2:07

GoogleCodeExporter commented 9 years ago
Should be possible.  Patches welcome :-).

Original comment by magreenb...@gmail.com on 27 Oct 2010 at 2:11

GoogleCodeExporter commented 9 years ago
This 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

Original comment by magreenb...@gmail.com on 18 Nov 2010 at 3:22

GoogleCodeExporter commented 9 years ago
considering there has been no word on this since 2010 how likely is this 
feature to be created? 

Original comment by ke...@realrussia.co.uk on 4 Feb 2013 at 6:16

GoogleCodeExporter commented 9 years ago
The 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=pac
kage:chromium&type=cs

1. Add a new SpellCheckMessageFilter or SpellCheckMessageFilterMac in 
ContentBrowserClient::RenderProcessHostCreated.

2. 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.

Original comment by magreenb...@gmail.com on 14 Aug 2013 at 6:25

GoogleCodeExporter commented 9 years ago
I'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?

Original comment by megsmi...@gmail.com on 23 Aug 2013 at 4:19

GoogleCodeExporter commented 9 years ago
@comment#5: What specific Profile methods do you need? Profile inherits from 
content::BrowserContext -- CEF has its own BrowserContext implementation in 
CefBrowserContext.

Original comment by magreenb...@gmail.com on 23 Aug 2013 at 4:30

GoogleCodeExporter commented 9 years ago
After 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.

Original comment by megsmi...@gmail.com on 23 Aug 2013 at 8:37

GoogleCodeExporter commented 9 years ago
I 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::vector<std::basic_string<char, std::char_traits<char>, 
std::allocator<char> >, std::allocator<std::basic_string<char, 
std::char_traits<char>, std::allocator<char> > > >, 
std::vector<std::basic_string<char, std::char_traits<char>, 
std::allocator<char> >, std::allocator<std::basic_string<char, 
std::char_traits<char>, std::allocator<char> > > > >*)'

Original comment by megsmi...@gmail.com on 26 Aug 2013 at 9:00

GoogleCodeExporter commented 9 years ago
@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.

Original comment by magreenb...@gmail.com on 26 Aug 2013 at 9:13

GoogleCodeExporter commented 9 years ago
Ah - perfect! That was the missing piece - knowing where to include that file. 
Thanks!

Original comment by megsmi...@gmail.com on 26 Aug 2013 at 9:33

GoogleCodeExporter commented 9 years ago
Another 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?

Original comment by megsmi...@gmail.com on 17 Sep 2013 at 9:51

GoogleCodeExporter commented 9 years ago
I 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?

Original comment by megsmi...@gmail.com on 20 Sep 2013 at 6:31

GoogleCodeExporter commented 9 years ago
@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.

Original comment by magreenb...@gmail.com on 20 Sep 2013 at 7:41

GoogleCodeExporter commented 9 years ago
Spellcheck implementation patch attached. Requires this chromium commit: 
https://codereview.chromium.org/23868013/

Original comment by megsmi...@gmail.com on 24 Sep 2013 at 4:11

Attachments:

GoogleCodeExporter commented 9 years ago
i 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...

Original comment by es.night...@gmail.com on 10 Oct 2013 at 11:23

GoogleCodeExporter commented 9 years ago
Updated to trunk, removed some code that snuck in from other patches, added 
missing constant.

Original comment by megsmi...@gmail.com on 24 Oct 2013 at 5:16

Attachments:

GoogleCodeExporter commented 9 years ago
Hello, 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.

Original comment by i...@flydart.com on 27 Feb 2014 at 3:05

GoogleCodeExporter commented 9 years ago
I updated the patch to support 1750 CEF, but when typing in a contenteditable 
it is very slow. Has anybody else experienced this?

Original comment by alaudic...@compcc.com on 4 Apr 2014 at 9:37

GoogleCodeExporter commented 9 years ago
What 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?

Original comment by thomas...@gmail.com on 17 May 2014 at 3:17

GoogleCodeExporter commented 9 years ago
It 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?

Original comment by eshash...@gmail.com on 27 Jun 2014 at 10:38

GoogleCodeExporter commented 9 years ago
Here 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.

Original comment by Fe3...@gmail.com on 9 Jul 2014 at 7:21

Attachments:

GoogleCodeExporter commented 9 years ago
Correction to a linecount error in the patch.

Original comment by Fe3...@gmail.com on 9 Jul 2014 at 9:22

Attachments:

GoogleCodeExporter commented 9 years ago
Thanks 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.

Original comment by thomas...@gmail.com on 10 Jul 2014 at 11:56

GoogleCodeExporter commented 9 years ago
Also wondering about an answer to Thomas's questions just now. 

Am closely watching this too, extremely grateful for your work on the patch!

Original comment by andrea.b...@gmail.com on 11 Jul 2014 at 12:38

GoogleCodeExporter commented 9 years ago
[deleted comment]
GoogleCodeExporter commented 9 years ago
 >>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?
  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.

Original comment by Fe3...@gmail.com on 23 Jul 2014 at 5:24

GoogleCodeExporter commented 9 years ago

Original comment by Fe3...@gmail.com on 23 Jul 2014 at 5:25

Attachments:

GoogleCodeExporter commented 9 years ago
Thanks, 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.

Original comment by thomas...@gmail.com on 25 Jul 2014 at 9:13

GoogleCodeExporter commented 9 years ago
Ah, please help us! Spell check is so important.

Original comment by eshash...@gmail.com on 25 Jul 2014 at 9:19

GoogleCodeExporter commented 9 years ago
>>Thanks, 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

Original comment by Fe3...@gmail.com on 7 Aug 2014 at 7:41

GoogleCodeExporter commented 9 years ago
@#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 
"<cache_path>/Dictionaries" directory as needed, or used from the <cache_path> 
directory if the file already exists there. The dictionary file will be 
downloaded from http://cache.pack.google.com/edgedl/chrome/dict/<LANG>-3-0.bdic 
where <LANG> 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=<LANG> => Use the specified dictionary language 
<LANG> 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_DICTIONAR
Y%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.

Original comment by magreenb...@gmail.com on 7 Oct 2014 at 8:46

GoogleCodeExporter commented 9 years ago
Compiled 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<UserPrefs*>(context->GetUserData(UserDataKey()))->prefs_;

Original comment by r...@slightblue.com on 9 Oct 2014 at 7:18

Attachments:

GoogleCodeExporter commented 9 years ago
@#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?

Original comment by magreenb...@gmail.com on 9 Oct 2014 at 4:04

GoogleCodeExporter commented 9 years ago
[deleted comment]
GoogleCodeExporter commented 9 years ago
I'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.

Original comment by r...@slightblue.com on 10 Oct 2014 at 4:00

Attachments:

GoogleCodeExporter commented 9 years ago
Trunk 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.

Original comment by magreenb...@gmail.com on 19 Oct 2014 at 1:49

GoogleCodeExporter commented 9 years ago
Here's a rundown of what causes crashing for me on Mac as soon as a textarea 
spellcheck would occur.

1. Simple CefRequestContextHandler implementation with virtual method 
GetCookieManager()
2. CefRequestContext::CreateContext(SimpleRequestContextHandler)
3. CefBrowserHost::CreateBrowserSync(... passing the CefRequestContext created 
earlier)

Crashes cefsimple as soon as a textarea spellcheck would occur.

Original comment by r...@slightblue.com on 23 Oct 2014 at 10:49

GoogleCodeExporter commented 9 years ago
Question:
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.

Original comment by mich...@liv.it on 5 Nov 2014 at 5:40

GoogleCodeExporter commented 9 years ago
@#38: Not currently. The ability to change spell checking language during 
runtime may be added as part of issue #1058 resolution.

Original comment by magreenb...@gmail.com on 7 Nov 2014 at 6:12

GoogleCodeExporter commented 9 years ago
Great. 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).

Original comment by mich...@liv.it on 8 Nov 2014 at 6:04

GoogleCodeExporter commented 9 years ago
@#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.

Original comment by rtt...@gmail.com on 29 Dec 2014 at 9:10

Attachments:

GoogleCodeExporter commented 9 years ago
Hello, 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?

Original comment by romil...@gmail.com on 5 May 2015 at 1:11