mirror of
https://github.com/servo/servo.git
synced 2025-10-02 17:49:16 +01:00
script: Support keyCode
, charCode
in KeyboardEvent constructor (#39590)
Support `keyCode` and `charCode` fields in KeyboardEventInit for Speedometer 3.0 Speedometer 3.0 fails because Servo's KeyboardEvent constructor ignores keyCode and charCode parameters, hardcoding them to 0. This breaks frameworks that check `event.keyCode === 13` for Enter key detection. This is how [Speedometer 3.0 dispatches key events](8d67f28d02/resources/benchmark-runner.mjs (L166)
) vs [Speedometer 2.0 triggerEnter](491acc2d64/resources/tests.mjs (L60)
). Speedometer 3.0 uses the modern KeyboardEvent constructor but passes [legacy fields like keyCode and charCode](https://w3c.github.io/uievents/#legacy-dictionary-KeyboardEventInit) in the init dictionary for backwards compatibility with older frameworks(for example: backbone.js) This change uncomments the legacy KeyboardEventInit fields and updates the constructor to read them from the init dictionary instead of hardcoding to 0. Testing: No new tests added. Fixes: part of https://github.com/servo/servo/issues/16719 Servo running Speedometer3.0 successfully <img width="1136" height="880" alt="speedometer 3 0" src="https://github.com/user-attachments/assets/cf5199a5-d88d-4495-ae96-05fa6332b97e" /> --------- Signed-off-by: atbrakhi <atbrakhi@igalia.com>
This commit is contained in:
parent
e49fcdeffd
commit
4ea363277e
4 changed files with 40 additions and 4 deletions
|
@ -186,8 +186,8 @@ impl KeyboardEventMethods<crate::DomTypeHolder> for KeyboardEvent {
|
|||
init.repeat,
|
||||
init.isComposing,
|
||||
modifiers,
|
||||
0,
|
||||
0,
|
||||
init.charCode,
|
||||
init.keyCode,
|
||||
can_gc,
|
||||
);
|
||||
*event.key.borrow_mut() = init.key.clone();
|
||||
|
|
|
@ -53,8 +53,8 @@ dictionary KeyboardEventInit : EventModifierInit {
|
|||
};
|
||||
|
||||
// https://w3c.github.io/uievents/#legacy-dictionary-KeyboardEventInit
|
||||
/*partial dictionary KeyboardEventInit {
|
||||
partial dictionary KeyboardEventInit {
|
||||
unsigned long charCode = 0;
|
||||
unsigned long keyCode = 0;
|
||||
unsigned long which = 0;
|
||||
};*/
|
||||
};
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue