Commit db48475
committed
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@main1 parent f463a6d commit db48475
File tree
2 files changed
+103
-1
lines changed- Source/WebCore/page
- Tools/TestWebKitAPI/Tests/ios
2 files changed
+103
-1
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
4315 | 4315 | | |
4316 | 4316 | | |
4317 | 4317 | | |
| 4318 | + | |
| 4319 | + | |
| 4320 | + | |
| 4321 | + | |
| 4322 | + | |
| 4323 | + | |
| 4324 | + | |
4318 | 4325 | | |
4319 | 4326 | | |
4320 | | - | |
| 4327 | + | |
4321 | 4328 | | |
4322 | 4329 | | |
4323 | 4330 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1562 | 1562 | | |
1563 | 1563 | | |
1564 | 1564 | | |
| 1565 | + | |
| 1566 | + | |
| 1567 | + | |
| 1568 | + | |
| 1569 | + | |
| 1570 | + | |
| 1571 | + | |
| 1572 | + | |
| 1573 | + | |
| 1574 | + | |
| 1575 | + | |
| 1576 | + | |
| 1577 | + | |
| 1578 | + | |
| 1579 | + | |
| 1580 | + | |
| 1581 | + | |
| 1582 | + | |
| 1583 | + | |
| 1584 | + | |
| 1585 | + | |
| 1586 | + | |
| 1587 | + | |
| 1588 | + | |
| 1589 | + | |
| 1590 | + | |
| 1591 | + | |
| 1592 | + | |
| 1593 | + | |
| 1594 | + | |
| 1595 | + | |
| 1596 | + | |
| 1597 | + | |
| 1598 | + | |
| 1599 | + | |
| 1600 | + | |
| 1601 | + | |
| 1602 | + | |
| 1603 | + | |
| 1604 | + | |
| 1605 | + | |
| 1606 | + | |
| 1607 | + | |
| 1608 | + | |
| 1609 | + | |
| 1610 | + | |
| 1611 | + | |
| 1612 | + | |
| 1613 | + | |
| 1614 | + | |
| 1615 | + | |
| 1616 | + | |
| 1617 | + | |
| 1618 | + | |
| 1619 | + | |
| 1620 | + | |
| 1621 | + | |
| 1622 | + | |
| 1623 | + | |
| 1624 | + | |
| 1625 | + | |
| 1626 | + | |
| 1627 | + | |
| 1628 | + | |
| 1629 | + | |
| 1630 | + | |
| 1631 | + | |
| 1632 | + | |
| 1633 | + | |
| 1634 | + | |
| 1635 | + | |
| 1636 | + | |
| 1637 | + | |
| 1638 | + | |
| 1639 | + | |
| 1640 | + | |
| 1641 | + | |
| 1642 | + | |
| 1643 | + | |
| 1644 | + | |
| 1645 | + | |
| 1646 | + | |
| 1647 | + | |
| 1648 | + | |
| 1649 | + | |
| 1650 | + | |
| 1651 | + | |
| 1652 | + | |
| 1653 | + | |
| 1654 | + | |
| 1655 | + | |
| 1656 | + | |
| 1657 | + | |
| 1658 | + | |
| 1659 | + | |
1565 | 1660 | | |
1566 | 1661 | | |
1567 | 1662 | | |
0 commit comments