mirror of
https://github.com/servo/servo.git
synced 2025-09-30 00:29:14 +01:00
script: Implement getModifierState
for mouse event (#38535)
Implement missing idl function `getModifierState` for mouse event. The
implementation is exactly the same as in keyboard event
https://w3c.github.io/uievents/#dom-keyboardevent-getmodifierstate.
6651f37c05/components/script/dom/keyboardevent.rs (L267-L283)
Testing: Fix
`./tests/wpt/tests/infrastructure/testdriver/actions/actionsWithKeyPressed.html`
---------
Signed-off-by: PotatoCP <Kenzie.Raditya.Tirtarahardja@huawei.com>
This commit is contained in:
parent
2e2bfc6067
commit
c0d884ddb2
3 changed files with 20 additions and 16 deletions
|
@ -527,4 +527,23 @@ impl MouseEventMethods<crate::DomTypeHolder> for MouseEvent {
|
|||
fn IsTrusted(&self) -> bool {
|
||||
self.uievent.IsTrusted()
|
||||
}
|
||||
|
||||
/// <https://w3c.github.io/uievents/#dom-mouseevent-getmodifierstate>
|
||||
fn GetModifierState(&self, key_arg: DOMString) -> bool {
|
||||
self.modifiers.get().contains(match &*key_arg {
|
||||
"Alt" => Modifiers::ALT,
|
||||
"AltGraph" => Modifiers::ALT_GRAPH,
|
||||
"CapsLock" => Modifiers::CAPS_LOCK,
|
||||
"Control" => Modifiers::CONTROL,
|
||||
"Fn" => Modifiers::FN,
|
||||
"FnLock" => Modifiers::FN_LOCK,
|
||||
"Meta" => Modifiers::META,
|
||||
"NumLock" => Modifiers::NUM_LOCK,
|
||||
"ScrollLock" => Modifiers::SCROLL_LOCK,
|
||||
"Shift" => Modifiers::SHIFT,
|
||||
"Symbol" => Modifiers::SYMBOL,
|
||||
"SymbolLock" => Modifiers::SYMBOL_LOCK,
|
||||
_ => return false,
|
||||
})
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue