CEFInterfaceImeHandler.h 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114
  1. // Engine/Source/Runtime/WebBrowser/Private/CEF/CEFImeHandler.h
  2. #pragma once
  3. #include "CoreMinimal.h"
  4. #if WITH_CEF3 && !PLATFORM_LINUX
  5. #include "Widgets/SWidget.h"
  6. #if PLATFORM_WINDOWS
  7. #include "Windows/AllowWindowsPlatformTypes.h"
  8. #include "Windows/AllowWindowsPlatformAtomics.h"
  9. #endif
  10. #pragma push_macro("OVERRIDE")
  11. #undef OVERRIDE // cef headers provide their own OVERRIDE macro
  12. THIRD_PARTY_INCLUDES_START
  13. #if PLATFORM_APPLE
  14. PRAGMA_DISABLE_DEPRECATION_WARNINGS
  15. #endif
  16. #include "include/cef_client.h"
  17. #include "include/cef_values.h"
  18. #if PLATFORM_APPLE
  19. PRAGMA_ENABLE_DEPRECATION_WARNINGS
  20. #endif
  21. THIRD_PARTY_INCLUDES_END
  22. #pragma pop_macro("OVERRIDE")
  23. #if PLATFORM_WINDOWS
  24. #include "Windows/HideWindowsPlatformAtomics.h"
  25. #include "Windows/HideWindowsPlatformTypes.h"
  26. #endif
  27. #include "Layout/Geometry.h"
  28. class ITextInputMethodSystem;
  29. class FCEFInterfaceTextInputMethodContext;
  30. class ITextInputMethodChangeNotifier;
  31. class SWidget;
  32. class FCEFInterfaceImeHandler
  33. : public TSharedFromThis<FCEFInterfaceImeHandler>
  34. {
  35. public:
  36. FCEFInterfaceImeHandler(CefRefPtr<CefBrowser> Browser);
  37. void UnbindCefBrowser();
  38. void CacheBrowserSlateInfo(const TSharedRef<SWidget>& Widget);
  39. void SetFocus(bool bHasFocus);
  40. void UpdateCachedGeometry(const FGeometry& AllottedGeometry);
  41. /**
  42. * Called when the IME composition DOM node has changed.
  43. *
  44. * @param SelectionRange The range of characters that have been selected.
  45. * @param CharacterBounds The bounds of each character in view coordinates.
  46. */
  47. void CEFCompositionRangeChanged(const CefRange& SelectionRange, const CefRenderHandler::RectList& CharacterBounds);
  48. /**
  49. * Called when a message was received from the renderer process.
  50. *
  51. * @param Browser The CefBrowser for this window.
  52. * @param SourceProcess The process id of the sender of the message. Currently always PID_RENDERER.
  53. * @param Message The actual message.
  54. * @return true if the message was handled, else false.
  55. */
  56. bool OnProcessMessageReceived(CefRefPtr<CefBrowser> Browser, CefProcessId SourceProcess, CefRefPtr<CefProcessMessage> Message);
  57. /**
  58. * Sends a message to the renderer process.
  59. * See https://bitbucket.org/chromiumembedded/cef/wiki/GeneralUsage#markdown-header-inter-process-communication-ipc for more information.
  60. *
  61. * @param Message the message to send to the renderer process
  62. */
  63. void SendProcessMessage(CefRefPtr<CefProcessMessage> Message);
  64. // FWebImeHandler Interface
  65. void BindInputMethodSystem(ITextInputMethodSystem* InTextInputMethodSystem);
  66. void UnbindInputMethodSystem();
  67. private:
  68. bool IsValid()
  69. {
  70. return InternalCefBrowser.get() != nullptr;
  71. }
  72. void InitContext();
  73. void DeactivateContext();
  74. void DestroyContext();
  75. /** Message handling helpers */
  76. bool HandleFocusChangedMessage(CefRefPtr<CefListValue> MessageArguments);
  77. /** Pointer to the CEF Browser for this window. */
  78. CefRefPtr<CefBrowser> InternalCefBrowser;
  79. TWeakPtr<SWidget> InternalBrowserSlateWidget;
  80. ITextInputMethodSystem* TextInputMethodSystem;
  81. /** IME context for this browser window. This gets recreated whenever we change focus to an editable input field. */
  82. TSharedPtr<FCEFInterfaceTextInputMethodContext> TextInputMethodContext;
  83. /** Notification interface object for IMEs */
  84. TSharedPtr<ITextInputMethodChangeNotifier> TextInputMethodChangeNotifier;
  85. // Allow IME context to access functions only it needs.
  86. friend class FCEFInterfaceTextInputMethodContext;
  87. };
  88. #endif