Branch: refs/heads/main
  Home:   https://github.com/WebKit/WebKit
  Commit: 253c954e14deea29b85b57813b311ba0ca5e685b
      
https://github.com/WebKit/WebKit/commit/253c954e14deea29b85b57813b311ba0ca5e685b
  Author: Simon Pena <[email protected]>
  Date:   2026-10-05 (Mon, 05 Oct 2026)

  Changed paths:
    M Source/WebKit/UIProcess/API/glib/InputMethodFilter.cpp
    M Tools/TestWebKitAPI/Tests/WebKit/WKWebView/glib/TestInputMethodContext.cpp

  Log Message:
  -----------
  [GTK][WPE] Input method caret inside the preedit is sent as a one-character 
selection
https://bugs.webkit.org/show_bug.cgi?id=325510

Reviewed by Adrian Perez de Castro and Carlos Garcia Campos.

The input method reports where its caret is inside the preedit. 
InputMethodFilter passed this
to Editor::setComposition as a selection one character long, not as a caret. 
When the caret was
inside the preedit, the page then had a one-character selection during the 
composition. With the
caret at the end of the preedit this selection did not show, because 
Editor::setComposition
clamps it to the end of the composition.

Pass a length of 0, as the Cocoa ports do for a caret. Also pass 0 when the 
preedit
finishes. The text is empty there, so the selection is not used, but both calls 
now match.

This also changes one thing that pages can see, wherever the caret is. When a 
composition starts
over text selected in the page, Editor::setComposition looks at the input 
method caret. If the
caret has a length, Editor deletes the selected text as a separate step first, 
and the page gets a
beforeinput event with inputType deleteByComposition. If the caret has no 
length, the composition
text replaces the selected text when it is inserted, and there is no such 
event. The text is the
same either way, and cancelling the composition still leaves the selected text 
deleted. The new
preedit-over-selection test checks this.

Test: Tools/TestWebKitAPI/Tests/WebKit/WKWebView/glib/TestInputMethodContext.cpp

* Source/WebKit/UIProcess/API/glib/InputMethodFilter.cpp:
(WebKit::InputMethodFilter::preeditChanged):
(WebKit::InputMethodFilter::preeditFinished):
* Tools/TestWebKitAPI/Tests/WebKit/WKWebView/glib/TestInputMethodContext.cpp:
(testWebKitInputMethodContextPreeditCursor):
(testWebKitInputMethodContextPreeditOverSelection):
(beforeAll):

Canonical link: https://commits.webkit.org/322689@main



To unsubscribe from these emails, change your notification settings at 
https://github.com/WebKit/WebKit/settings/notifications

Reply via email to