[Webkit-unassigned] [Bug 218148] using input method in the preedit mode , if the cursor not in the last letter , webkit2gtk report the wrong location

bugzilla-daemon at webkit.org bugzilla-daemon at webkit.org
Sat Apr 13 10:24:57 PDT 2024


https://bugs.webkit.org/show_bug.cgi?id=218148

--- Comment #4 from Keyu Tao <taoky99 at outlook.com> ---
After a success build locally with git main branch webkitgtk, and a lot of `printf()` manually added and running with MiniBrowser, the reason for the Gtk cursor update function getting empty rect in IM preedit mode is that:

1. In `FrameSelection::recomputeCaretRect()`, `clearCaretRect()` makes it empty, as `m_selection` is a Type::Range (isNonOrphanedCaret returns false).

2. `frame.selection().absoluteCaretBounds()` in `WebPage::getPlatformEditorState()` (glib) gets that empty rect and gives it to 

3. `WebPage::sendEditorStateUpdate` => `WebPage::editorState()` => `getPlatformEditorState()`

4. `sendEditorStateUpdate` sends IPC msg (Messages::WebPageProxy::EditorStateChanged(state)), with the empty rect.

5. It gets to `WebPageProxy::editorStateChanged` => `WebPageProxy::updateEditorState` => `WebPageProxy::didUpdateEditorState` => `PageClientImpl::selectionDidChange()` => `webkitWebViewBaseUpdateTextInputState()` => `webkitWebViewBase->priv->inputMethodFilter.notifyCursorRect()` = `InputMethodFilter::notifyCursorRect` (glib) => `webkit_input_method_context_notify_cursor_area` => `imClass->notify_cursor_area` => `webkitInputMethodContextImplGtkNotifyCursorArea()` => `gtk_im_context_set_cursor_location()`.

Looks like the most naive workaround is to check if the rect is empty (x, y, width and height are all 0) in webkit_input_method_context_notify_cursor_area, and if so, just don't notify cursor area. However, unfortunately I could not get the flatpak WebKit SDK working on my computer so I guess I would not submit this as a patch in recent. It would be very appreciated if anyone could help validate this (or find a better solution).

-- 
You are receiving this mail because:
You are the assignee for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.webkit.org/pipermail/webkit-unassigned/attachments/20240413/366dedb9/attachment.htm>


More information about the webkit-unassigned mailing list