mirror of
https://bitbucket.org/chromiumembedded/cef
synced 2025-06-05 21:39:12 +02:00
Standardize IME callbacks for off-screen rendering (issue #1675)
This commit is contained in:
@ -667,44 +667,81 @@ void CefBrowserHostCToCpp::SetWindowlessFrameRate(int frame_rate) {
|
||||
frame_rate);
|
||||
}
|
||||
|
||||
CefTextInputContext CefBrowserHostCToCpp::GetNSTextInputContext() {
|
||||
void CefBrowserHostCToCpp::ImeSetComposition(const CefString& text,
|
||||
const std::vector<CefCompositionUnderline>& underlines,
|
||||
const CefRange& replacement_range, const CefRange& selection_range) {
|
||||
cef_browser_host_t* _struct = GetStruct();
|
||||
if (CEF_MEMBER_MISSING(_struct, get_nstext_input_context))
|
||||
return NULL;
|
||||
if (CEF_MEMBER_MISSING(_struct, ime_set_composition))
|
||||
return;
|
||||
|
||||
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
|
||||
|
||||
// Execute
|
||||
cef_text_input_context_t _retval = _struct->get_nstext_input_context(_struct);
|
||||
// Unverified params: text, underlines
|
||||
|
||||
// Return type: simple
|
||||
return _retval;
|
||||
// Translate param: underlines; type: simple_vec_byref_const
|
||||
const size_t underlinesCount = underlines.size();
|
||||
cef_composition_underline_t* underlinesList = NULL;
|
||||
if (underlinesCount > 0) {
|
||||
underlinesList = new cef_composition_underline_t[underlinesCount];
|
||||
DCHECK(underlinesList);
|
||||
if (underlinesList) {
|
||||
for (size_t i = 0; i < underlinesCount; ++i) {
|
||||
underlinesList[i] = underlines[i];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Execute
|
||||
_struct->ime_set_composition(_struct,
|
||||
text.GetStruct(),
|
||||
underlinesCount,
|
||||
underlinesList,
|
||||
&replacement_range,
|
||||
&selection_range);
|
||||
|
||||
// Restore param:underlines; type: simple_vec_byref_const
|
||||
if (underlinesList)
|
||||
delete [] underlinesList;
|
||||
}
|
||||
|
||||
void CefBrowserHostCToCpp::HandleKeyEventBeforeTextInputClient(
|
||||
CefEventHandle keyEvent) {
|
||||
void CefBrowserHostCToCpp::ImeCommitText(const CefString& text,
|
||||
const CefRange& replacement_range, int relative_cursor_pos) {
|
||||
cef_browser_host_t* _struct = GetStruct();
|
||||
if (CEF_MEMBER_MISSING(_struct, handle_key_event_before_text_input_client))
|
||||
if (CEF_MEMBER_MISSING(_struct, ime_commit_text))
|
||||
return;
|
||||
|
||||
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
|
||||
|
||||
// Unverified params: text
|
||||
|
||||
// Execute
|
||||
_struct->ime_commit_text(_struct,
|
||||
text.GetStruct(),
|
||||
&replacement_range,
|
||||
relative_cursor_pos);
|
||||
}
|
||||
|
||||
void CefBrowserHostCToCpp::ImeFinishComposingText(bool keep_selection) {
|
||||
cef_browser_host_t* _struct = GetStruct();
|
||||
if (CEF_MEMBER_MISSING(_struct, ime_finish_composing_text))
|
||||
return;
|
||||
|
||||
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
|
||||
|
||||
// Execute
|
||||
_struct->handle_key_event_before_text_input_client(_struct,
|
||||
keyEvent);
|
||||
_struct->ime_finish_composing_text(_struct,
|
||||
keep_selection);
|
||||
}
|
||||
|
||||
void CefBrowserHostCToCpp::HandleKeyEventAfterTextInputClient(
|
||||
CefEventHandle keyEvent) {
|
||||
void CefBrowserHostCToCpp::ImeCancelComposition() {
|
||||
cef_browser_host_t* _struct = GetStruct();
|
||||
if (CEF_MEMBER_MISSING(_struct, handle_key_event_after_text_input_client))
|
||||
if (CEF_MEMBER_MISSING(_struct, ime_cancel_composition))
|
||||
return;
|
||||
|
||||
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
|
||||
|
||||
// Execute
|
||||
_struct->handle_key_event_after_text_input_client(_struct,
|
||||
keyEvent);
|
||||
_struct->ime_cancel_composition(_struct);
|
||||
}
|
||||
|
||||
void CefBrowserHostCToCpp::DragTargetDragEnter(CefRefPtr<CefDragData> drag_data,
|
||||
|
@ -86,9 +86,14 @@ class CefBrowserHostCToCpp
|
||||
void NotifyMoveOrResizeStarted() OVERRIDE;
|
||||
int GetWindowlessFrameRate() OVERRIDE;
|
||||
void SetWindowlessFrameRate(int frame_rate) OVERRIDE;
|
||||
CefTextInputContext GetNSTextInputContext() OVERRIDE;
|
||||
void HandleKeyEventBeforeTextInputClient(CefEventHandle keyEvent) OVERRIDE;
|
||||
void HandleKeyEventAfterTextInputClient(CefEventHandle keyEvent) OVERRIDE;
|
||||
void ImeSetComposition(const CefString& text,
|
||||
const std::vector<CefCompositionUnderline>& underlines,
|
||||
const CefRange& replacement_range,
|
||||
const CefRange& selection_range) OVERRIDE;
|
||||
void ImeCommitText(const CefString& text, const CefRange& replacement_range,
|
||||
int relative_cursor_pos) OVERRIDE;
|
||||
void ImeFinishComposingText(bool keep_selection) OVERRIDE;
|
||||
void ImeCancelComposition() OVERRIDE;
|
||||
void DragTargetDragEnter(CefRefPtr<CefDragData> drag_data,
|
||||
const CefMouseEvent& event, DragOperationsMask allowed_ops) OVERRIDE;
|
||||
void DragTargetDragOver(const CefMouseEvent& event,
|
||||
|
@ -283,6 +283,45 @@ void CefRenderHandlerCToCpp::OnScrollOffsetChanged(
|
||||
y);
|
||||
}
|
||||
|
||||
void CefRenderHandlerCToCpp::OnImeCompositionRangeChanged(
|
||||
CefRefPtr<CefBrowser> browser, const CefRange& selected_range,
|
||||
const RectList& character_bounds) {
|
||||
cef_render_handler_t* _struct = GetStruct();
|
||||
if (CEF_MEMBER_MISSING(_struct, on_ime_composition_range_changed))
|
||||
return;
|
||||
|
||||
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
|
||||
|
||||
// Verify param: browser; type: refptr_diff
|
||||
DCHECK(browser.get());
|
||||
if (!browser.get())
|
||||
return;
|
||||
|
||||
// Translate param: character_bounds; type: simple_vec_byref_const
|
||||
const size_t character_boundsCount = character_bounds.size();
|
||||
cef_rect_t* character_boundsList = NULL;
|
||||
if (character_boundsCount > 0) {
|
||||
character_boundsList = new cef_rect_t[character_boundsCount];
|
||||
DCHECK(character_boundsList);
|
||||
if (character_boundsList) {
|
||||
for (size_t i = 0; i < character_boundsCount; ++i) {
|
||||
character_boundsList[i] = character_bounds[i];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Execute
|
||||
_struct->on_ime_composition_range_changed(_struct,
|
||||
CefBrowserCppToC::Wrap(browser),
|
||||
&selected_range,
|
||||
character_boundsCount,
|
||||
character_boundsList);
|
||||
|
||||
// Restore param:character_bounds; type: simple_vec_byref_const
|
||||
if (character_boundsList)
|
||||
delete [] character_boundsList;
|
||||
}
|
||||
|
||||
|
||||
// CONSTRUCTOR - Do not edit by hand.
|
||||
|
||||
|
@ -51,6 +51,9 @@ class CefRenderHandlerCToCpp
|
||||
DragOperation operation) override;
|
||||
void OnScrollOffsetChanged(CefRefPtr<CefBrowser> browser, double x,
|
||||
double y) override;
|
||||
void OnImeCompositionRangeChanged(CefRefPtr<CefBrowser> browser,
|
||||
const CefRange& selected_range,
|
||||
const RectList& character_bounds) override;
|
||||
};
|
||||
|
||||
#endif // BUILDING_CEF_SHARED
|
||||
|
Reference in New Issue
Block a user