Disable spellcheck preference ignored

Having problems with building or using CEF's C/C++ APIs? This forum is here to help. Please do not post bug reports or feature requests here.

Disable spellcheck preference ignored

Postby HarmlessDave » Tue Dec 12, 2017 2:01 pm

I am trying to disable chromium's incorrect word highlighting but it is not working. This is CEF 3.2924.1575.g97389a9, Windows, 32-bit debug build.

I tried calling this after CefBrowserHost::CreateBrowser()

Code: Select all
void BrowserDisableSpellCheck()
{
   if (!CefCurrentlyOn(TID_UI))
   {
      CefPostTask(TID_UI, base::Bind(&BrowserDisableSpellCheck));
      return;
   }
   CefRefPtr<CefRequestContext> context = CefRequestContext::GetGlobalContext();
   const char kEnableSpellcheck[] = "browser.enable_spellchecking";
   CefString errtext;

   CefRefPtr<CefValue> pval = CefValue::Create();
   pval->SetBool(false);
   bool pset = context->SetPreference(kEnableSpellcheck, pval, errtext);
}


And this just before using browser->LoadURL to navigate the first browser to a website

Code: Select all
void BrowserDisableSpellCheck2(CefRefPtr<CefBrowser> browser)
{
   if (!CefCurrentlyOn(TID_UI))
   {
      CefPostTask(TID_UI, base::Bind(&BrowserDisableSpellCheck2, browser));
      return;
   }
   CefRefPtr<CefRequestContext> context = browser->GetHost()->GetRequestContext();
   const char kEnableSpellcheck[] = "browser.enable_spellchecking";
   CefString errtext;

   CefRefPtr<CefValue> pval = CefValue::Create();
   pval->SetBool(false);
   bool pset = context->SetPreference(kEnableSpellcheck, pval, errtext);
}


The code is running in the UI thread and for both functions SetPreference returns success. I also checked with GetPreference() that the value of browser.enable_spellchecking is now false.

But if I type something like "wronk wrods" both still get the red underlines. Can anyone see what I'm doing wrong?
HarmlessDave
Expert
 
Posts: 370
Joined: Fri Jul 11, 2014 2:02 pm

Re: Disable spellcheck preference ignored

Postby magreenblatt » Tue Dec 12, 2017 2:43 pm

It works for me in cefclient testing with http://tests/preferences at version 3.2924.1575.g97389a9_windows32
magreenblatt
Site Admin
 
Posts: 12408
Joined: Fri May 29, 2009 6:57 pm

Re: Disable spellcheck preference ignored

Postby HarmlessDave » Tue Dec 12, 2017 2:51 pm

magreenblatt wrote:It works for me in cefclient testing with http://tests/preferences at version 3.2924.1575.g97389a9_windows32


That works for me too, I created the second version of my function based loosely on that code. The main difference I can think of is /tests/preferences does not run until after google.com has loaded while I'm calling before loading anything other than about:blank. My code is also not being triggered by a link on a web page.

I'll try calling after the first page loads (OnLoadingStateChange after isloading changes to 0) and see if that helps.
HarmlessDave
Expert
 
Posts: 370
Joined: Fri Jul 11, 2014 2:02 pm

Re: Disable spellcheck preference ignored

Postby HarmlessDave » Tue Dec 12, 2017 4:15 pm

Now this is weird: in CEFClient it takes effect immediately. In our program it is working, but not until after Chromium checks the first word typed on the first page. I didn't notice this before since I'd stop testing after seeing the red-lined word.

It doesn't seem to be a timing issue. I can wait 15 seconds, then type "wronk" + (space) and see it red-lined. Then as soon as I type the first letter of a second word the red line disappears and other misspelled words are ignored. If I refresh the page and misspell the first word it is now ignored.

Strange, but not really a problem for our use case.
HarmlessDave
Expert
 
Posts: 370
Joined: Fri Jul 11, 2014 2:02 pm

Re: Disable spellcheck preference ignored

Postby magreenblatt » Tue Dec 12, 2017 5:19 pm

Are you using windowed or off-screen rendering? If you're using off-screen rendering then perhaps a new frame isn't being generated to remove the underline.
magreenblatt
Site Admin
 
Posts: 12408
Joined: Fri May 29, 2009 6:57 pm

Re: Disable spellcheck preference ignored

Postby HarmlessDave » Tue Dec 12, 2017 7:15 pm

magreenblatt wrote:Are you using windowed or off-screen rendering? If you're using off-screen rendering then perhaps a new frame isn't being generated to remove the underline.


It's windowed, a child window of our main frame. The odd part is the underline appearing only for the first word, only the first page, and only if it is incorrect. "wronk word" = underline after typing the space, then it disappears after typing the first letter of the second word. "word wronk" = never an underline. Page 2-on, never an underline even if that is the first page with an edit field.

If I didn't have a list of other changes to work through this week I'd be tempted to spend a lot more time on trying to figure this out. Since it's harmless I'll just let it haunt me forever :)
HarmlessDave
Expert
 
Posts: 370
Joined: Fri Jul 11, 2014 2:02 pm


Return to Support Forum

Who is online

Users browsing this forum: No registered users and 58 guests