Branch: refs/heads/main
  Home:   https://github.com/WebKit/WebKit
  Commit: db4847511d666d207a8a5d66accac527e2cd56bf
      
https://github.com/WebKit/WebKit/commit/db4847511d666d207a8a5d66accac527e2cd56bf
  Author: Vitor Roriz <[email protected]>
  Date:   2026-01-20 (Tue, 20 Jan 2026)

  Changed paths:
    M Source/WebCore/page/EventHandler.cpp
    M Tools/TestWebKitAPI/Tests/ios/KeyboardInputTestsIOS.mm

  Log Message:
  -----------
  docs.google.com: Emojis don't show properly
https://bugs.webkit.org/show_bug.cgi?id=305666
rdar://122678873

Reviewed by Wenson Hsieh.

Suppress keypress events for supplementary characters to fix emoji input

Emoji with codepoints > 0xFFFF (like 🥹 U+1F979) are encoded as UTF-16
surrogate pairs. The deprecated KeyboardEvent.charCode property returns
the full 32-bit codepoint (e.g., 129401), but JavaScript's
String.fromCharCode() only uses the lower 16 bits, causing truncation
(129401 & 0xFFFF = 0xF979 = "凉", a Chinese character).

This breaks sites like Google Docs that rely on charCode to insert text.

The fix suppresses keypress events for supplementary characters
(codepoint > 0xFFFF) and manually inserts the text via Editor::insertText,
ensuring beforeinput/input events fire correctly with the proper emoji.

This matches Blink's behavior: Android Chrome routes emoji through IME
(keyCode=229) and suppresses keypress. macOS Safari's emoji picker bypasses
keyboard events entirely.

Regular characters and BMP emoji (codepoint ≤ 0xFFFF) continue to fire
keypress normally, preserving backward compatibility.

Test: Tools/TestWebKitAPI/Tests/ios/KeyboardInputTestsIOS.mm

* Source/WebCore/page/EventHandler.cpp:
(WebCore::EventHandler::internalKeyEvent):
* Tools/TestWebKitAPI/Tests/ios/KeyboardInputTestsIOS.mm:
(TestWebKitAPI::sendKeyEventWithCharacters):
(TestWebKitAPI::TEST(KeyboardInputTests, 
SuppressKeypressForSupplementaryCharacterEmoji)):
(TestWebKitAPI::TEST(KeyboardInputTests, AllowKeypressForRegularCharacters)):
(TestWebKitAPI::TEST(KeyboardInputTests, AllowKeypressForBMPEmoji)):

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



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

Reply via email to