Branch: refs/heads/main
  Home:   https://github.com/WebKit/WebKit
  Commit: 36cbace2163012041a2e59ae7ad39394b8123775
      
https://github.com/WebKit/WebKit/commit/36cbace2163012041a2e59ae7ad39394b8123775
  Author: Ahmad Saleem <[email protected]>
  Date:   2026-08-20 (Thu, 20 Aug 2026)

  Changed paths:
    A 
LayoutTests/editing/input/compositionend-after-clicking-outside-editable-expected.txt
    A 
LayoutTests/editing/input/compositionend-after-clicking-outside-editable.html
    A 
LayoutTests/editing/input/compositionend-data-after-aborting-composition-expected.txt
    A 
LayoutTests/editing/input/compositionend-data-after-aborting-composition.html
    M LayoutTests/platform/glib/TestExpectations
    M LayoutTests/platform/ios/TestExpectations
    M Source/WebCore/editing/Editor.cpp

  Log Message:
  -----------
  Aborting a dead key composition fires no compositionend event, or one with 
empty data
https://bugs.webkit.org/show_bug.cgi?id=304068
rdar://166881240

Reviewed by Ryosuke Niwa.

Pressing a dead key in an editable element starts a composition, and clicking
outside the element aborts it, leaving the dead key character in the document. 
Two
separate problems in Editor::setComposition() meant a page could not observe 
what
had happened.

First, compositionend was dispatched to document->focusedElement(). Clicking
outside the editable element fires focusout before the composition is torn down,
so there is no focused element left by then and the event was dropped entirely:
the composition state was cleared and the text left behind with nothing
dispatched. Fall back to the element the composition belongs to when focus has
already moved. A composition inside a text form control lives in a shadow tree, 
so
retarget to the form control rather than to the inner text element.

Second, on the paths where the event was dispatched, its data was the empty
string. Cancelling a composition does not remove the pending composition text 
from
the document: setComposition() skips the deleteSelection() call when the mode is
CancelComposition, and insertTextForConfirmedComposition() early-returns for the
empty string it is handed. Report the composition text instead, captured before
m_compositionNode is cleared.

Chrome and Firefox both fire compositionend with the character left in the
document.

The tests only pass on macOS. Aborting a composition when the selection moves 
out
of it is driven by Editor::selectionWillChange(), which calls 
cancelComposition()
in EditorMac.mm and is an empty stub for every other port, so nothing tears the
composition down and setComposition() is never reached. That is the same gap
fast/events/ime-compositionend-on-selection-change.html already tracks as a
failure on the GLib ports and iOS, so mark the new tests accordingly.

Tests: editing/input/compositionend-after-clicking-outside-editable.html
       editing/input/compositionend-data-after-aborting-composition.html

* 
LayoutTests/editing/input/compositionend-after-clicking-outside-editable-expected.txt:
 Added.
* 
LayoutTests/editing/input/compositionend-after-clicking-outside-editable.html: 
Added.
* 
LayoutTests/editing/input/compositionend-data-after-aborting-composition-expected.txt:
 Added.
* 
LayoutTests/editing/input/compositionend-data-after-aborting-composition.html: 
Added.
* LayoutTests/platform/glib/TestExpectations:
* LayoutTests/platform/ios/TestExpectations:
* Source/WebCore/editing/Editor.cpp:
(WebCore::Editor::setComposition):

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



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

Reply via email to