After applying the CEF3 mac off screen rendering patch, I've noticed IME input is not available.
After some research, I've found a few possible ways of adding this feature which I'd like to discuss before jumping into an implementation.
In general, enabling IME for Mac implies having a NSView in the responder hierarchy that conforms to the NSTextInputClient protocol. For example, IME is enabled on both
Chromium and CEF3 on screen rendering through a NSView owned by the RenderWidgetHostViewMac class called RenderWidgetHostViewCocoa which implements the NSTextInputClient protocol.
In other words, for enabling IME, we have to port the RenderWidgetHostViewCocoa implementation in one of the views included in the off screen rendering responder chain.
After doing some investigation, these are the options I've found:
The first option is to add another NSView in libcef, owned by the CefRenderWidgetHostViewOSR class, which would implement the NSTextInputClient protocol.
A major advantage is the fact that any client application will have IME enabled without any additional development effort. Unfortunately, this solution implies adding a NSView in an off screen rendering model, which perhaps isn't such a good idea.
Another potential solution implies implementing the NSTextInputClient protocol in CefClient, in the OSRTest_mac view. This comes with the advantage of not adding another NSView in the off screen rendering model, however, it implies that every embedding application should implement this protocol and copy most of the code in the CefClient view. Also, another problem consists of the API's that the content module should expose for compositing and editing text, API's which should be available to the NSTextInputClient protocol methods.
The final solution I've found is to implement the NSTextInputClient corresponding methods in CefRenderWidgetHostViewOSR as C++ methods. Then, each embedding application, including CefClient would add the protocol methods in the NSView used for displaying the rendered content and call the corresponding CefRenderWidgetHostViewOSR methods. For example, in the NSView - (BOOL)hasMarkedText selector, the embedder would call the bool CefRenderWidgetHostViewOSR::hasMarkedText method. This method has the advantage of not exposing any extra content methods, however, it still implies that the embedder should do some work for enabling IME.
I probably think the third option is the best we have considering the circumstances, but I'd like your opinion on this matter, perhaps we might find a more suitable way of adding this feature.