cargo: Upgrade keyboard-types to 0.8.0 and xcomponent-sys to 0.3.4 (#38375)

With some adjustment for `NamedKey`. The two crates need to be bumped
together to avoid duplicate of `keyboard-types` action.

---------

Signed-off-by: PotatoCP <Kenzie.Raditya.Tirtarahardja@huawei.com>
This commit is contained in:
Kenzie Raditya Tirtarahardja 2025-08-01 16:14:38 +08:00 committed by GitHub
parent a063b5e78a
commit 05ad9026f5
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
15 changed files with 471 additions and 432 deletions

12
Cargo.lock generated
View file

@ -1359,7 +1359,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "117725a109d387c937a1533ce01b450cbde6b88abceea8473c4d7a85853cda3c"
dependencies = [
"lazy_static",
"windows-sys 0.48.0",
"windows-sys 0.59.0",
]
[[package]]
@ -4664,9 +4664,9 @@ dependencies = [
[[package]]
name = "keyboard-types"
version = "0.7.0"
version = "0.8.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b750dcadc39a09dbadd74e118f6dd6598df77fa01df0cfcdc52c28dece74528a"
checksum = "fd6e0f18953c66af118a70064505bd3780a226d65b06553b7293fb8933067967"
dependencies = [
"bitflags 2.9.1",
"serde",
@ -9921,7 +9921,7 @@ version = "0.1.9"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "cf221c93e13a30d793f7645a0e7762c55d169dbb0a49671918a2319d289b10bb"
dependencies = [
"windows-sys 0.48.0",
"windows-sys 0.59.0",
]
[[package]]
@ -10510,9 +10510,9 @@ dependencies = [
[[package]]
name = "xcomponent-sys"
version = "0.3.3"
version = "0.3.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b9e652372b831785d7d215786c83163c9eebb6c96c24e938c7f35d58af03a160"
checksum = "329659c48163c2aad88ef9a68eb478f21307a563179d4304b5ead737543533c1"
dependencies = [
"arkui-sys",
"keyboard-types",

View file

@ -87,7 +87,7 @@ indexmap = { version = "2.10.0", features = ["std"] }
ipc-channel = "0.20"
itertools = "0.14"
js = { package = "mozjs", git = "https://github.com/servo/mozjs" }
keyboard-types = "0.7"
keyboard-types = { version = "0.8.0", features = ["webdriver", "serde"] }
kurbo = { version = "0.11.3", features = ["euclid"] }
libc = "0.2"
log = "0.4"

View file

@ -142,7 +142,7 @@ use fonts::SystemFontServiceProxy;
use ipc_channel::Error as IpcError;
use ipc_channel::ipc::{self, IpcReceiver, IpcSender};
use ipc_channel::router::ROUTER;
use keyboard_types::{Key, KeyState, Modifiers};
use keyboard_types::{Key, KeyState, Modifiers, NamedKey};
use layout_api::{LayoutFactory, ScriptThreadFactory};
use log::{debug, error, info, trace, warn};
use media::WindowGLContext;
@ -2835,6 +2835,7 @@ where
}
}
#[allow(deprecated)]
fn update_active_keybord_modifiers(&mut self, event: &KeyboardEvent) {
self.active_keyboard_modifiers = event.event.modifiers;
@ -2842,23 +2843,27 @@ where
// either pressed or released, but `active_keyboard_modifiers` should track the subsequent
// state. If this event will update that state, we need to ensure that we are tracking what
// the event changes.
let modified_modifier = match event.event.key {
Key::Alt => Modifiers::ALT,
Key::AltGraph => Modifiers::ALT_GRAPH,
Key::CapsLock => Modifiers::CAPS_LOCK,
Key::Control => Modifiers::CONTROL,
Key::Fn => Modifiers::FN,
Key::FnLock => Modifiers::FN_LOCK,
Key::Meta => Modifiers::META,
Key::NumLock => Modifiers::NUM_LOCK,
Key::ScrollLock => Modifiers::SCROLL_LOCK,
Key::Shift => Modifiers::SHIFT,
Key::Symbol => Modifiers::SYMBOL,
Key::SymbolLock => Modifiers::SYMBOL_LOCK,
Key::Hyper => Modifiers::HYPER,
let Key::Named(named_key) = event.event.key else {
return;
};
let modified_modifier = match named_key {
NamedKey::Alt => Modifiers::ALT,
NamedKey::AltGraph => Modifiers::ALT_GRAPH,
NamedKey::CapsLock => Modifiers::CAPS_LOCK,
NamedKey::Control => Modifiers::CONTROL,
NamedKey::Fn => Modifiers::FN,
NamedKey::FnLock => Modifiers::FN_LOCK,
NamedKey::Meta => Modifiers::META,
NamedKey::NumLock => Modifiers::NUM_LOCK,
NamedKey::ScrollLock => Modifiers::SCROLL_LOCK,
NamedKey::Shift => Modifiers::SHIFT,
NamedKey::Symbol => Modifiers::SYMBOL,
NamedKey::SymbolLock => Modifiers::SYMBOL_LOCK,
NamedKey::Hyper => Modifiers::HYPER,
// The web doesn't make a distinction between these keys (there is only
// "meta") so map "super" to "meta".
Key::Super => Modifiers::META,
NamedKey::Super => Modifiers::META,
_ => return,
};
match event.event.state {

View file

@ -41,7 +41,7 @@ use html5ever::{LocalName, Namespace, QualName, local_name, ns};
use hyper_serde::Serde;
use ipc_channel::ipc;
use js::rust::{HandleObject, HandleValue, MutableHandleValue};
use keyboard_types::{Code, Key, KeyState, Modifiers};
use keyboard_types::{Code, Key, KeyState, Modifiers, NamedKey};
use layout_api::{
PendingRestyle, ReflowGoal, RestyleReason, TrustedNodeAddress, node_id_from_scroll_id,
};
@ -2547,7 +2547,7 @@ impl Document {
let keyevent = KeyboardEvent::new(
&self.window,
DOMString::from(keyboard_event.event.state.to_string()),
DOMString::from(keyboard_event.event.state.event_type()),
true,
true,
Some(&self.window),
@ -2607,7 +2607,8 @@ impl Document {
// however *when* we do it is up to us.
// Here, we're dispatching it after the key event so the script has a chance to cancel it
// https://www.w3.org/Bugs/Public/show_bug.cgi?id=27337
if (keyboard_event.event.key == Key::Enter || keyboard_event.event.code == Code::Space) &&
if (keyboard_event.event.key == Key::Named(NamedKey::Enter) ||
keyboard_event.event.code == Code::Space) &&
keyboard_event.event.state == KeyState::Up
{
if let Some(elem) = target.downcast::<Element>() {
@ -2647,7 +2648,7 @@ impl Document {
let compositionevent = CompositionEvent::new(
&self.window,
DOMString::from(composition_event.state.to_string()),
DOMString::from(composition_event.state.event_type()),
true,
cancelable,
Some(&self.window),
@ -4045,7 +4046,7 @@ impl Document {
}
fn is_character_value_key(key: &Key) -> bool {
matches!(key, Key::Character(_) | Key::Enter)
matches!(key, Key::Character(_) | Key::Named(NamedKey::Enter))
}
#[derive(MallocSizeOf, PartialEq)]

View file

@ -6,7 +6,7 @@ use std::cell::Cell;
use dom_struct::dom_struct;
use js::rust::HandleObject;
use keyboard_types::{Key, Modifiers};
use keyboard_types::{Key, Modifiers, NamedKey};
use crate::dom::bindings::cell::DomRefCell;
use crate::dom::bindings::codegen::Bindings::KeyboardEventBinding;
@ -43,7 +43,7 @@ impl KeyboardEvent {
KeyboardEvent {
uievent: UIEvent::new_inherited(),
key: DomRefCell::new(DOMString::new()),
typed_key: DomRefCell::new(Key::Unidentified),
typed_key: DomRefCell::new(Key::Named(NamedKey::Unidentified)),
code: DomRefCell::new(DOMString::new()),
location: Cell::new(0),
modifiers: Cell::new(Modifiers::empty()),
@ -180,7 +180,7 @@ impl KeyboardEventMethods<crate::DomTypeHolder> for KeyboardEvent {
init.parent.parent.parent.cancelable,
init.parent.parent.view.as_deref(),
init.parent.parent.detail,
Key::Unidentified,
Key::Named(NamedKey::Unidentified),
init.code.clone(),
init.location,
init.repeat,

View file

@ -9,7 +9,7 @@ use std::cmp::min;
use std::default::Default;
use std::ops::{Add, AddAssign, Range};
use keyboard_types::{Key, KeyState, Modifiers, ShortcutMatcher};
use keyboard_types::{Key, KeyState, Modifiers, NamedKey, ShortcutMatcher};
use unicode_segmentation::UnicodeSegmentation;
use crate::clipboard_provider::{ClipboardProvider, EmbedderClipboardProvider};
@ -921,75 +921,102 @@ impl<T: ClipboardProvider> TextInput<T> {
}
KeyReaction::DispatchInput
})
.shortcut(Modifiers::empty(), Key::Delete, || {
.shortcut(Modifiers::empty(), Key::Named(NamedKey::Delete), || {
if self.delete_char(Direction::Forward) {
KeyReaction::DispatchInput
} else {
KeyReaction::Nothing
}
})
.shortcut(Modifiers::empty(), Key::Backspace, || {
.shortcut(Modifiers::empty(), Key::Named(NamedKey::Backspace), || {
if self.delete_char(Direction::Backward) {
KeyReaction::DispatchInput
} else {
KeyReaction::Nothing
}
})
.optional_shortcut(macos, Modifiers::META, Key::ArrowLeft, || {
self.adjust_horizontal_to_line_end(Direction::Backward, maybe_select);
KeyReaction::RedrawSelection
})
.optional_shortcut(macos, Modifiers::META, Key::ArrowRight, || {
self.adjust_horizontal_to_line_end(Direction::Forward, maybe_select);
KeyReaction::RedrawSelection
})
.optional_shortcut(macos, Modifiers::META, Key::ArrowUp, || {
self.adjust_horizontal_to_limit(Direction::Backward, maybe_select);
KeyReaction::RedrawSelection
})
.optional_shortcut(macos, Modifiers::META, Key::ArrowDown, || {
self.adjust_horizontal_to_limit(Direction::Forward, maybe_select);
KeyReaction::RedrawSelection
})
.shortcut(Modifiers::ALT, Key::ArrowLeft, || {
.optional_shortcut(
macos,
Modifiers::META,
Key::Named(NamedKey::ArrowLeft),
|| {
self.adjust_horizontal_to_line_end(Direction::Backward, maybe_select);
KeyReaction::RedrawSelection
},
)
.optional_shortcut(
macos,
Modifiers::META,
Key::Named(NamedKey::ArrowRight),
|| {
self.adjust_horizontal_to_line_end(Direction::Forward, maybe_select);
KeyReaction::RedrawSelection
},
)
.optional_shortcut(
macos,
Modifiers::META,
Key::Named(NamedKey::ArrowUp),
|| {
self.adjust_horizontal_to_limit(Direction::Backward, maybe_select);
KeyReaction::RedrawSelection
},
)
.optional_shortcut(
macos,
Modifiers::META,
Key::Named(NamedKey::ArrowDown),
|| {
self.adjust_horizontal_to_limit(Direction::Forward, maybe_select);
KeyReaction::RedrawSelection
},
)
.shortcut(Modifiers::ALT, Key::Named(NamedKey::ArrowLeft), || {
self.adjust_horizontal_by_word(Direction::Backward, maybe_select);
KeyReaction::RedrawSelection
})
.shortcut(Modifiers::ALT, Key::ArrowRight, || {
.shortcut(Modifiers::ALT, Key::Named(NamedKey::ArrowRight), || {
self.adjust_horizontal_by_word(Direction::Forward, maybe_select);
KeyReaction::RedrawSelection
})
.shortcut(Modifiers::empty(), Key::ArrowLeft, || {
.shortcut(Modifiers::empty(), Key::Named(NamedKey::ArrowLeft), || {
self.adjust_horizontal_by_one(Direction::Backward, maybe_select);
KeyReaction::RedrawSelection
})
.shortcut(Modifiers::empty(), Key::ArrowRight, || {
.shortcut(Modifiers::empty(), Key::Named(NamedKey::ArrowRight), || {
self.adjust_horizontal_by_one(Direction::Forward, maybe_select);
KeyReaction::RedrawSelection
})
.shortcut(Modifiers::empty(), Key::ArrowUp, || {
.shortcut(Modifiers::empty(), Key::Named(NamedKey::ArrowUp), || {
self.adjust_vertical(-1, maybe_select);
KeyReaction::RedrawSelection
})
.shortcut(Modifiers::empty(), Key::ArrowDown, || {
.shortcut(Modifiers::empty(), Key::Named(NamedKey::ArrowDown), || {
self.adjust_vertical(1, maybe_select);
KeyReaction::RedrawSelection
})
.shortcut(Modifiers::empty(), Key::Enter, || self.handle_return())
.optional_shortcut(macos, Modifiers::empty(), Key::Home, || {
self.edit_point.index = UTF8Bytes::zero();
KeyReaction::RedrawSelection
.shortcut(Modifiers::empty(), Key::Named(NamedKey::Enter), || {
self.handle_return()
})
.optional_shortcut(macos, Modifiers::empty(), Key::End, || {
.optional_shortcut(
macos,
Modifiers::empty(),
Key::Named(NamedKey::Home),
|| {
self.edit_point.index = UTF8Bytes::zero();
KeyReaction::RedrawSelection
},
)
.optional_shortcut(macos, Modifiers::empty(), Key::Named(NamedKey::End), || {
self.edit_point.index = self.current_line_length();
self.assert_ok_selection();
KeyReaction::RedrawSelection
})
.shortcut(Modifiers::empty(), Key::PageUp, || {
.shortcut(Modifiers::empty(), Key::Named(NamedKey::PageUp), || {
self.adjust_vertical(-28, maybe_select);
KeyReaction::RedrawSelection
})
.shortcut(Modifiers::empty(), Key::PageDown, || {
.shortcut(Modifiers::empty(), Key::Named(NamedKey::PageDown), || {
self.adjust_vertical(28, maybe_select);
KeyReaction::RedrawSelection
})
@ -998,7 +1025,7 @@ impl<T: ClipboardProvider> TextInput<T> {
self.insert_string(c.as_str());
return KeyReaction::DispatchInput;
}
if matches!(key, Key::Process) {
if matches!(key, Key::Named(NamedKey::Process)) {
return KeyReaction::DispatchInput;
}
KeyReaction::Nothing

View file

@ -628,6 +628,7 @@ pub(crate) unsafe fn windowproxy_from_handlevalue<D: crate::DomTypes>(
Ok(DomRoot::from_ref(&*ptr))
}
#[allow(deprecated)]
impl<D: crate::DomTypes> EventModifierInit<D> {
pub fn modifiers(&self) -> Modifiers {
let mut modifiers = Modifiers::empty();

View file

@ -85,7 +85,7 @@ use ipc_channel::ipc::{self, IpcSender};
use ipc_channel::router::ROUTER;
use javascript_evaluator::JavaScriptEvaluator;
pub use keyboard_types::{
Code, CompositionEvent, CompositionState, Key, KeyState, Location, Modifiers,
Code, CompositionEvent, CompositionState, Key, KeyState, Location, Modifiers, NamedKey,
};
use layout::LayoutFactoryImpl;
use log::{Log, Metadata, Record, debug, error, warn};

View file

@ -100,7 +100,7 @@ ohos-deviceinfo = "0.1.0"
ohos-abilitykit-sys = { version = "0.1.2", features = ["api-14"] }
ohos-vsync = "0.1.3"
ohos-window-manager-sys = { version = "0.1", features = ["api-14"] }
xcomponent-sys = { version = "0.3.3", features = ["api-14", "keyboard-types"] }
xcomponent-sys = { version = "0.3.4", features = ["api-14", "keyboard-types"] }
[target.'cfg(any(target_os = "android", target_env = "ohos"))'.dependencies]
nix = { workspace = true, features = ["fs"] }

View file

@ -10,7 +10,7 @@ use std::rc::Rc;
use crossbeam_channel::Receiver;
use euclid::Vector2D;
use keyboard_types::{Key, Modifiers, ShortcutMatcher};
use keyboard_types::{Key, Modifiers, NamedKey, ShortcutMatcher};
use log::{error, info};
use servo::base::id::WebViewId;
use servo::config::pref;
@ -418,39 +418,39 @@ impl RunningAppState {
.shortcut(CMD_OR_CONTROL, '0', || {
webview.reset_zoom();
})
.shortcut(Modifiers::empty(), Key::PageDown, || {
.shortcut(Modifiers::empty(), Key::Named(NamedKey::PageDown), || {
let scroll_location = ScrollLocation::Delta(Vector2D::new(
0.0,
self.inner().window.page_height() - 2.0 * LINE_HEIGHT,
));
webview.notify_scroll_event(scroll_location, origin);
})
.shortcut(Modifiers::empty(), Key::PageUp, || {
.shortcut(Modifiers::empty(), Key::Named(NamedKey::PageUp), || {
let scroll_location = ScrollLocation::Delta(Vector2D::new(
0.0,
-self.inner().window.page_height() + 2.0 * LINE_HEIGHT,
));
webview.notify_scroll_event(scroll_location, origin);
})
.shortcut(Modifiers::empty(), Key::Home, || {
.shortcut(Modifiers::empty(), Key::Named(NamedKey::Home), || {
webview.notify_scroll_event(ScrollLocation::Start, origin);
})
.shortcut(Modifiers::empty(), Key::End, || {
.shortcut(Modifiers::empty(), Key::Named(NamedKey::End), || {
webview.notify_scroll_event(ScrollLocation::End, origin);
})
.shortcut(Modifiers::empty(), Key::ArrowUp, || {
.shortcut(Modifiers::empty(), Key::Named(NamedKey::ArrowUp), || {
let location = ScrollLocation::Delta(Vector2D::new(0.0, -1.0 * LINE_HEIGHT));
webview.notify_scroll_event(location, origin);
})
.shortcut(Modifiers::empty(), Key::ArrowDown, || {
.shortcut(Modifiers::empty(), Key::Named(NamedKey::ArrowDown), || {
let location = ScrollLocation::Delta(Vector2D::new(0.0, 1.0 * LINE_HEIGHT));
webview.notify_scroll_event(location, origin);
})
.shortcut(Modifiers::empty(), Key::ArrowLeft, || {
.shortcut(Modifiers::empty(), Key::Named(NamedKey::ArrowLeft), || {
let location = ScrollLocation::Delta(Vector2D::new(-LINE_WIDTH, 0.0));
webview.notify_scroll_event(location, origin);
})
.shortcut(Modifiers::empty(), Key::ArrowRight, || {
.shortcut(Modifiers::empty(), Key::Named(NamedKey::ArrowRight), || {
let location = ScrollLocation::Delta(Vector2D::new(LINE_WIDTH, 0.0));
webview.notify_scroll_event(location, origin);
});

View file

@ -11,7 +11,7 @@ use std::rc::Rc;
use std::time::Duration;
use euclid::{Angle, Length, Point2D, Rotation3D, Scale, Size2D, UnknownUnit, Vector2D, Vector3D};
use keyboard_types::{Modifiers, ShortcutMatcher};
use keyboard_types::ShortcutMatcher;
use log::{debug, info};
use raw_window_handle::{HasDisplayHandle, HasWindowHandle, RawWindowHandle};
use servo::servo_config::pref;
@ -21,11 +21,11 @@ use servo::servo_geometry::{
use servo::webrender_api::ScrollLocation;
use servo::webrender_api::units::{DeviceIntPoint, DeviceIntRect, DeviceIntSize, DevicePixel};
use servo::{
Cursor, ImeEvent, InputEvent, Key, KeyState, KeyboardEvent, MouseButton as ServoMouseButton,
MouseButtonAction, MouseButtonEvent, MouseLeaveEvent, MouseMoveEvent,
OffscreenRenderingContext, RenderingContext, ScreenGeometry, Theme, TouchEvent, TouchEventType,
TouchId, WebRenderDebugOption, WebView, WheelDelta, WheelEvent, WheelMode,
WindowRenderingContext,
Cursor, ImeEvent, InputEvent, Key, KeyState, KeyboardEvent, Modifiers,
MouseButton as ServoMouseButton, MouseButtonAction, MouseButtonEvent, MouseLeaveEvent,
MouseMoveEvent, NamedKey, OffscreenRenderingContext, RenderingContext, ScreenGeometry, Theme,
TouchEvent, TouchEventType, TouchId, WebRenderDebugOption, WebView, WheelDelta, WheelEvent,
WheelMode, WindowRenderingContext,
};
use surfman::{Context, Device};
use url::Url;
@ -34,7 +34,7 @@ use winit::event::{
ElementState, Ime, KeyEvent, MouseButton, MouseScrollDelta, TouchPhase, WindowEvent,
};
use winit::event_loop::ActiveEventLoop;
use winit::keyboard::{Key as LogicalKey, ModifiersState, NamedKey};
use winit::keyboard::{Key as LogicalKey, ModifiersState, NamedKey as WinitNamedKey};
#[cfg(target_os = "linux")]
use winit::platform::wayland::WindowAttributesExtWayland;
#[cfg(any(target_os = "linux", target_os = "windows"))]
@ -238,7 +238,7 @@ impl Window {
}
if keyboard_event.event.state == KeyState::Down &&
keyboard_event.event.key == Key::Unidentified
keyboard_event.event.key == Key::Named(NamedKey::Unidentified)
{
// If pressed and probably printable, we expect a ReceivedCharacter event.
// Wait for that to be received and don't queue any event right now.
@ -246,7 +246,7 @@ impl Window {
.set(Some((keyboard_event, Some(winit_event.logical_key))));
return;
} else if keyboard_event.event.state == KeyState::Up &&
keyboard_event.event.key == Key::Unidentified
keyboard_event.event.key == Key::Named(NamedKey::Unidentified)
{
// If release and probably printable, this is following a ReceiverCharacter event.
if let Some(key) = self.keys_down.borrow_mut().remove(&winit_event.logical_key) {
@ -254,7 +254,7 @@ impl Window {
}
}
if keyboard_event.event.key != Key::Unidentified {
if keyboard_event.event.key != Key::Named(NamedKey::Unidentified) {
self.last_pressed.set(None);
let xr_poses = self.xr_window_poses.borrow();
for xr_window_pose in &*xr_poses {
@ -333,19 +333,19 @@ impl Window {
focused_webview
.notify_input_event(InputEvent::EditingAction(servo::EditingActionEvent::Paste))
})
.shortcut(Modifiers::CONTROL, Key::F9, || {
.shortcut(Modifiers::CONTROL, Key::Named(NamedKey::F9), || {
focused_webview.capture_webrender();
})
.shortcut(Modifiers::CONTROL, Key::F10, || {
.shortcut(Modifiers::CONTROL, Key::Named(NamedKey::F10), || {
focused_webview.toggle_webrender_debugging(WebRenderDebugOption::RenderTargetDebug);
})
.shortcut(Modifiers::CONTROL, Key::F11, || {
.shortcut(Modifiers::CONTROL, Key::Named(NamedKey::F11), || {
focused_webview.toggle_webrender_debugging(WebRenderDebugOption::TextureCacheDebug);
})
.shortcut(Modifiers::CONTROL, Key::F12, || {
.shortcut(Modifiers::CONTROL, Key::Named(NamedKey::F12), || {
focused_webview.toggle_webrender_debugging(WebRenderDebugOption::Profiler);
})
.shortcut(CMD_OR_ALT, Key::ArrowRight, || {
.shortcut(CMD_OR_ALT, Key::Named(NamedKey::ArrowRight), || {
focused_webview.go_forward(1);
})
.optional_shortcut(
@ -356,7 +356,7 @@ impl Window {
focused_webview.go_forward(1);
},
)
.shortcut(CMD_OR_ALT, Key::ArrowLeft, || {
.shortcut(CMD_OR_ALT, Key::Named(NamedKey::ArrowLeft), || {
focused_webview.go_back(1);
})
.optional_shortcut(
@ -370,7 +370,7 @@ impl Window {
.optional_shortcut(
self.get_fullscreen(),
Modifiers::empty(),
Key::Escape,
Key::Named(NamedKey::Escape),
|| focused_webview.exit_fullscreen(),
)
// Select the first 8 tabs via shortcuts
@ -389,12 +389,12 @@ impl Window {
state.focus_webview_by_index(len - 1)
}
})
.shortcut(Modifiers::CONTROL, Key::PageDown, || {
.shortcut(Modifiers::CONTROL, Key::Named(NamedKey::PageDown), || {
if let Some(index) = state.get_focused_webview_index() {
state.focus_webview_by_index((index + 1) % state.webviews().len())
}
})
.shortcut(Modifiers::CONTROL, Key::PageUp, || {
.shortcut(Modifiers::CONTROL, Key::Named(NamedKey::PageUp), || {
if let Some(index) = state.get_focused_webview_index() {
let new_index = if index == 0 {
state.webviews().len() - 1
@ -925,10 +925,10 @@ impl XRWindowPose {
let mut x = 0.0;
let mut y = 0.0;
match input.logical_key {
LogicalKey::Named(NamedKey::ArrowUp) => x = 1.0,
LogicalKey::Named(NamedKey::ArrowDown) => x = -1.0,
LogicalKey::Named(NamedKey::ArrowLeft) => y = 1.0,
LogicalKey::Named(NamedKey::ArrowRight) => y = -1.0,
LogicalKey::Named(WinitNamedKey::ArrowUp) => x = 1.0,
LogicalKey::Named(WinitNamedKey::ArrowDown) => x = -1.0,
LogicalKey::Named(WinitNamedKey::ArrowLeft) => y = 1.0,
LogicalKey::Named(WinitNamedKey::ArrowRight) => y = -1.0,
_ => return,
};
if modifiers.shift_key() {

View file

@ -2,12 +2,12 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
use keyboard_types::{Code, Key, KeyState, Location, Modifiers};
use keyboard_types::{Code, Key, KeyState, Location, Modifiers, NamedKey};
use servo::KeyboardEvent;
use winit::event::{ElementState, KeyEvent};
use winit::keyboard::{
Key as WinitKey, KeyCode, KeyLocation as WinitKeyLocation, ModifiersState, NamedKey,
PhysicalKey,
Key as WinitKey, KeyCode, KeyLocation as WinitKeyLocation, ModifiersState,
NamedKey as WinitNamedKey, PhysicalKey,
};
// Some shortcuts use Cmd on Mac and Control on other systems.
@ -26,323 +26,327 @@ trait FromWinitKeyEvent {
fn from_winit_key_event(key_event: &KeyEvent) -> Self;
}
#[allow(deprecated)]
impl FromWinitKeyEvent for Key {
fn from_winit_key_event(key_event: &KeyEvent) -> Self {
let named_key = match key_event.logical_key {
WinitKey::Named(named_key) => named_key,
WinitKey::Character(ref string) => return Key::Character(string.to_string()),
WinitKey::Unidentified(_) => return Key::Unidentified,
WinitKey::Dead(_) => return Key::Unidentified,
WinitKey::Unidentified(_) | WinitKey::Dead(_) => {
return Key::Named(NamedKey::Unidentified);
},
};
match named_key {
NamedKey::AVRInput => Key::AVRInput,
NamedKey::AVRPower => Key::AVRPower,
NamedKey::Accept => Key::Accept,
NamedKey::Again => Key::Again,
NamedKey::AllCandidates => Key::AllCandidates,
NamedKey::Alphanumeric => Key::Alphanumeric,
NamedKey::Alt => Key::Alt,
NamedKey::AltGraph => Key::AltGraph,
NamedKey::AppSwitch => Key::AppSwitch,
NamedKey::ArrowDown => Key::ArrowDown,
NamedKey::ArrowLeft => Key::ArrowLeft,
NamedKey::ArrowRight => Key::ArrowRight,
NamedKey::ArrowUp => Key::ArrowUp,
NamedKey::Attn => Key::Attn,
NamedKey::AudioBalanceLeft => Key::AudioBalanceLeft,
NamedKey::AudioBalanceRight => Key::AudioBalanceRight,
NamedKey::AudioBassBoostDown => Key::AudioBassBoostDown,
NamedKey::AudioBassBoostToggle => Key::AudioBassBoostToggle,
NamedKey::AudioBassBoostUp => Key::AudioBassBoostUp,
NamedKey::AudioFaderFront => Key::AudioFaderFront,
NamedKey::AudioFaderRear => Key::AudioFaderRear,
NamedKey::AudioSurroundModeNext => Key::AudioSurroundModeNext,
NamedKey::AudioTrebleDown => Key::AudioTrebleDown,
NamedKey::AudioTrebleUp => Key::AudioTrebleUp,
NamedKey::AudioVolumeDown => Key::AudioVolumeDown,
NamedKey::AudioVolumeMute => Key::AudioVolumeMute,
NamedKey::AudioVolumeUp => Key::AudioVolumeUp,
NamedKey::Backspace => Key::Backspace,
NamedKey::BrightnessDown => Key::BrightnessDown,
NamedKey::BrightnessUp => Key::BrightnessUp,
NamedKey::BrowserBack => Key::BrowserBack,
NamedKey::BrowserFavorites => Key::BrowserFavorites,
NamedKey::BrowserForward => Key::BrowserForward,
NamedKey::BrowserHome => Key::BrowserHome,
NamedKey::BrowserRefresh => Key::BrowserRefresh,
NamedKey::BrowserSearch => Key::BrowserSearch,
NamedKey::BrowserStop => Key::BrowserStop,
NamedKey::Call => Key::Call,
NamedKey::Camera => Key::Camera,
NamedKey::CameraFocus => Key::CameraFocus,
NamedKey::Cancel => Key::Cancel,
NamedKey::CapsLock => Key::CapsLock,
NamedKey::ChannelDown => Key::ChannelDown,
NamedKey::ChannelUp => Key::ChannelUp,
NamedKey::Clear => Key::Clear,
NamedKey::Close => Key::Close,
NamedKey::ClosedCaptionToggle => Key::ClosedCaptionToggle,
NamedKey::CodeInput => Key::CodeInput,
NamedKey::ColorF0Red => Key::ColorF0Red,
NamedKey::ColorF1Green => Key::ColorF1Green,
NamedKey::ColorF2Yellow => Key::ColorF2Yellow,
NamedKey::ColorF3Blue => Key::ColorF3Blue,
NamedKey::ColorF4Grey => Key::ColorF4Grey,
NamedKey::ColorF5Brown => Key::ColorF5Brown,
NamedKey::Compose => Key::Compose,
NamedKey::ContextMenu => Key::ContextMenu,
NamedKey::Control => Key::Control,
NamedKey::Convert => Key::Convert,
NamedKey::Copy => Key::Copy,
NamedKey::CrSel => Key::CrSel,
NamedKey::Cut => Key::Cut,
NamedKey::DVR => Key::DVR,
NamedKey::Delete => Key::Delete,
NamedKey::Dimmer => Key::Dimmer,
NamedKey::DisplaySwap => Key::DisplaySwap,
NamedKey::Eisu => Key::Eisu,
NamedKey::Eject => Key::Eject,
NamedKey::End => Key::End,
NamedKey::EndCall => Key::EndCall,
NamedKey::Enter => Key::Enter,
NamedKey::EraseEof => Key::EraseEof,
NamedKey::Escape => Key::Escape,
NamedKey::ExSel => Key::ExSel,
NamedKey::Execute => Key::Execute,
NamedKey::Exit => Key::Exit,
NamedKey::F1 => Key::F1,
NamedKey::F10 => Key::F10,
NamedKey::F11 => Key::F11,
NamedKey::F12 => Key::F12,
NamedKey::F13 => Key::F13,
NamedKey::F14 => Key::F14,
NamedKey::F15 => Key::F15,
NamedKey::F16 => Key::F16,
NamedKey::F17 => Key::F17,
NamedKey::F18 => Key::F18,
NamedKey::F19 => Key::F19,
NamedKey::F2 => Key::F2,
NamedKey::F20 => Key::F20,
NamedKey::F21 => Key::F21,
NamedKey::F22 => Key::F22,
NamedKey::F23 => Key::F23,
NamedKey::F24 => Key::F24,
NamedKey::F25 => Key::F25,
NamedKey::F26 => Key::F26,
NamedKey::F27 => Key::F27,
NamedKey::F28 => Key::F28,
NamedKey::F29 => Key::F29,
NamedKey::F3 => Key::F3,
NamedKey::F30 => Key::F30,
NamedKey::F31 => Key::F31,
NamedKey::F32 => Key::F32,
NamedKey::F33 => Key::F33,
NamedKey::F34 => Key::F34,
NamedKey::F35 => Key::F35,
NamedKey::F4 => Key::F4,
NamedKey::F5 => Key::F5,
NamedKey::F6 => Key::F6,
NamedKey::F7 => Key::F7,
NamedKey::F8 => Key::F8,
NamedKey::F9 => Key::F9,
NamedKey::FavoriteClear0 => Key::FavoriteClear0,
NamedKey::FavoriteClear1 => Key::FavoriteClear1,
NamedKey::FavoriteClear2 => Key::FavoriteClear2,
NamedKey::FavoriteClear3 => Key::FavoriteClear3,
NamedKey::FavoriteRecall0 => Key::FavoriteRecall0,
NamedKey::FavoriteRecall1 => Key::FavoriteRecall1,
NamedKey::FavoriteRecall2 => Key::FavoriteRecall2,
NamedKey::FavoriteRecall3 => Key::FavoriteRecall3,
NamedKey::FavoriteStore0 => Key::FavoriteStore0,
NamedKey::FavoriteStore1 => Key::FavoriteStore1,
NamedKey::FavoriteStore2 => Key::FavoriteStore2,
NamedKey::FavoriteStore3 => Key::FavoriteStore3,
NamedKey::FinalMode => Key::FinalMode,
NamedKey::Find => Key::Find,
NamedKey::Fn => Key::Fn,
NamedKey::FnLock => Key::FnLock,
NamedKey::GoBack => Key::GoBack,
NamedKey::GoHome => Key::GoHome,
NamedKey::GroupFirst => Key::GroupFirst,
NamedKey::GroupLast => Key::GroupLast,
NamedKey::GroupNext => Key::GroupNext,
NamedKey::GroupPrevious => Key::GroupPrevious,
NamedKey::Guide => Key::Guide,
NamedKey::GuideNextDay => Key::GuideNextDay,
NamedKey::GuidePreviousDay => Key::GuidePreviousDay,
NamedKey::HangulMode => Key::HangulMode,
NamedKey::HanjaMode => Key::HanjaMode,
NamedKey::Hankaku => Key::Hankaku,
NamedKey::HeadsetHook => Key::HeadsetHook,
NamedKey::Help => Key::Help,
NamedKey::Hibernate => Key::Hibernate,
NamedKey::Hiragana => Key::Hiragana,
NamedKey::HiraganaKatakana => Key::HiraganaKatakana,
NamedKey::Home => Key::Home,
NamedKey::Hyper => Key::Hyper,
NamedKey::Info => Key::Info,
NamedKey::Insert => Key::Insert,
NamedKey::InstantReplay => Key::InstantReplay,
NamedKey::JunjaMode => Key::JunjaMode,
NamedKey::KanaMode => Key::KanaMode,
NamedKey::KanjiMode => Key::KanjiMode,
NamedKey::Katakana => Key::Katakana,
NamedKey::Key11 => Key::Key11,
NamedKey::Key12 => Key::Key12,
NamedKey::LastNumberRedial => Key::LastNumberRedial,
NamedKey::LaunchApplication1 => Key::LaunchApplication1,
NamedKey::LaunchApplication2 => Key::LaunchApplication2,
NamedKey::LaunchCalendar => Key::LaunchCalendar,
NamedKey::LaunchContacts => Key::LaunchContacts,
NamedKey::LaunchMail => Key::LaunchMail,
NamedKey::LaunchMediaPlayer => Key::LaunchMediaPlayer,
NamedKey::LaunchMusicPlayer => Key::LaunchMusicPlayer,
NamedKey::LaunchPhone => Key::LaunchPhone,
NamedKey::LaunchScreenSaver => Key::LaunchScreenSaver,
NamedKey::LaunchSpreadsheet => Key::LaunchSpreadsheet,
NamedKey::LaunchWebBrowser => Key::LaunchWebBrowser,
NamedKey::LaunchWebCam => Key::LaunchWebCam,
NamedKey::LaunchWordProcessor => Key::LaunchWordProcessor,
NamedKey::Link => Key::Link,
NamedKey::ListProgram => Key::ListProgram,
NamedKey::LiveContent => Key::LiveContent,
NamedKey::Lock => Key::Lock,
NamedKey::LogOff => Key::LogOff,
NamedKey::MailForward => Key::MailForward,
NamedKey::MailReply => Key::MailReply,
NamedKey::MailSend => Key::MailSend,
NamedKey::MannerMode => Key::MannerMode,
NamedKey::MediaApps => Key::MediaApps,
NamedKey::MediaAudioTrack => Key::MediaAudioTrack,
NamedKey::MediaClose => Key::MediaClose,
NamedKey::MediaFastForward => Key::MediaFastForward,
NamedKey::MediaLast => Key::MediaLast,
NamedKey::MediaPause => Key::MediaPause,
NamedKey::MediaPlay => Key::MediaPlay,
NamedKey::MediaPlayPause => Key::MediaPlayPause,
NamedKey::MediaRecord => Key::MediaRecord,
NamedKey::MediaRewind => Key::MediaRewind,
NamedKey::MediaSkipBackward => Key::MediaSkipBackward,
NamedKey::MediaSkipForward => Key::MediaSkipForward,
NamedKey::MediaStepBackward => Key::MediaStepBackward,
NamedKey::MediaStepForward => Key::MediaStepForward,
NamedKey::MediaStop => Key::MediaStop,
NamedKey::MediaTopMenu => Key::MediaTopMenu,
NamedKey::MediaTrackNext => Key::MediaTrackNext,
NamedKey::MediaTrackPrevious => Key::MediaTrackPrevious,
NamedKey::Meta => Key::Meta,
NamedKey::MicrophoneToggle => Key::MicrophoneToggle,
NamedKey::MicrophoneVolumeDown => Key::MicrophoneVolumeDown,
NamedKey::MicrophoneVolumeMute => Key::MicrophoneVolumeMute,
NamedKey::MicrophoneVolumeUp => Key::MicrophoneVolumeUp,
NamedKey::ModeChange => Key::ModeChange,
NamedKey::NavigateIn => Key::NavigateIn,
NamedKey::NavigateNext => Key::NavigateNext,
NamedKey::NavigateOut => Key::NavigateOut,
NamedKey::NavigatePrevious => Key::NavigatePrevious,
NamedKey::New => Key::New,
NamedKey::NextCandidate => Key::NextCandidate,
NamedKey::NextFavoriteChannel => Key::NextFavoriteChannel,
NamedKey::NextUserProfile => Key::NextUserProfile,
NamedKey::NonConvert => Key::NonConvert,
NamedKey::Notification => Key::Notification,
NamedKey::NumLock => Key::NumLock,
NamedKey::OnDemand => Key::OnDemand,
NamedKey::Open => Key::Open,
NamedKey::PageDown => Key::PageDown,
NamedKey::PageUp => Key::PageUp,
NamedKey::Pairing => Key::Pairing,
NamedKey::Paste => Key::Paste,
NamedKey::Pause => Key::Pause,
NamedKey::PinPDown => Key::PinPDown,
NamedKey::PinPMove => Key::PinPMove,
NamedKey::PinPToggle => Key::PinPToggle,
NamedKey::PinPUp => Key::PinPUp,
NamedKey::Play => Key::Play,
NamedKey::PlaySpeedDown => Key::PlaySpeedDown,
NamedKey::PlaySpeedReset => Key::PlaySpeedReset,
NamedKey::PlaySpeedUp => Key::PlaySpeedUp,
NamedKey::Power => Key::Power,
NamedKey::PowerOff => Key::PowerOff,
NamedKey::PreviousCandidate => Key::PreviousCandidate,
NamedKey::Print => Key::Print,
NamedKey::PrintScreen => Key::PrintScreen,
NamedKey::Process => Key::Process,
NamedKey::Props => Key::Props,
NamedKey::RandomToggle => Key::RandomToggle,
NamedKey::RcLowBattery => Key::RcLowBattery,
NamedKey::RecordSpeedNext => Key::RecordSpeedNext,
NamedKey::Redo => Key::Redo,
NamedKey::RfBypass => Key::RfBypass,
NamedKey::Romaji => Key::Romaji,
NamedKey::STBInput => Key::STBInput,
NamedKey::STBPower => Key::STBPower,
NamedKey::Save => Key::Save,
NamedKey::ScanChannelsToggle => Key::ScanChannelsToggle,
NamedKey::ScreenModeNext => Key::ScreenModeNext,
NamedKey::ScrollLock => Key::ScrollLock,
NamedKey::Select => Key::Select,
NamedKey::Settings => Key::Settings,
NamedKey::Shift => Key::Shift,
NamedKey::SingleCandidate => Key::SingleCandidate,
NamedKey::Soft1 => Key::Soft1,
NamedKey::Soft2 => Key::Soft2,
NamedKey::Soft3 => Key::Soft3,
NamedKey::Soft4 => Key::Soft4,
NamedKey::Space => Key::Character(" ".to_string()),
NamedKey::SpeechCorrectionList => Key::SpeechCorrectionList,
NamedKey::SpeechInputToggle => Key::SpeechInputToggle,
NamedKey::SpellCheck => Key::SpellCheck,
NamedKey::SplitScreenToggle => Key::SplitScreenToggle,
NamedKey::Standby => Key::Standby,
NamedKey::Subtitle => Key::Subtitle,
NamedKey::Super => Key::Super,
NamedKey::Symbol => Key::Symbol,
NamedKey::SymbolLock => Key::SymbolLock,
NamedKey::TV => Key::TV,
NamedKey::TV3DMode => Key::TV3DMode,
NamedKey::TVAntennaCable => Key::TVAntennaCable,
NamedKey::TVAudioDescription => Key::TVAudioDescription,
NamedKey::TVAudioDescriptionMixDown => Key::TVAudioDescriptionMixDown,
NamedKey::TVAudioDescriptionMixUp => Key::TVAudioDescriptionMixUp,
NamedKey::TVContentsMenu => Key::TVContentsMenu,
NamedKey::TVDataService => Key::TVDataService,
NamedKey::TVInput => Key::TVInput,
NamedKey::TVInputComponent1 => Key::TVInputComponent1,
NamedKey::TVInputComponent2 => Key::TVInputComponent2,
NamedKey::TVInputComposite1 => Key::TVInputComposite1,
NamedKey::TVInputComposite2 => Key::TVInputComposite2,
NamedKey::TVInputHDMI1 => Key::TVInputHDMI1,
NamedKey::TVInputHDMI2 => Key::TVInputHDMI2,
NamedKey::TVInputHDMI3 => Key::TVInputHDMI3,
NamedKey::TVInputHDMI4 => Key::TVInputHDMI4,
NamedKey::TVInputVGA1 => Key::TVInputVGA1,
NamedKey::TVMediaContext => Key::TVMediaContext,
NamedKey::TVNetwork => Key::TVNetwork,
NamedKey::TVNumberEntry => Key::TVNumberEntry,
NamedKey::TVPower => Key::TVPower,
NamedKey::TVRadioService => Key::TVRadioService,
NamedKey::TVSatellite => Key::TVSatellite,
NamedKey::TVSatelliteBS => Key::TVSatelliteBS,
NamedKey::TVSatelliteCS => Key::TVSatelliteCS,
NamedKey::TVSatelliteToggle => Key::TVSatelliteToggle,
NamedKey::TVTerrestrialAnalog => Key::TVTerrestrialAnalog,
NamedKey::TVTerrestrialDigital => Key::TVTerrestrialDigital,
NamedKey::TVTimer => Key::TVTimer,
NamedKey::Tab => Key::Tab,
NamedKey::Teletext => Key::Teletext,
NamedKey::Undo => Key::Undo,
NamedKey::VideoModeNext => Key::VideoModeNext,
NamedKey::VoiceDial => Key::VoiceDial,
NamedKey::WakeUp => Key::WakeUp,
NamedKey::Wink => Key::Wink,
NamedKey::Zenkaku => Key::Zenkaku,
NamedKey::ZenkakuHankaku => Key::ZenkakuHankaku,
NamedKey::ZoomIn => Key::ZoomIn,
NamedKey::ZoomOut => Key::ZoomOut,
NamedKey::ZoomToggle => Key::ZoomToggle,
_ => Key::Unidentified,
WinitNamedKey::AVRInput => Key::Named(NamedKey::AVRInput),
WinitNamedKey::AVRPower => Key::Named(NamedKey::AVRPower),
WinitNamedKey::Accept => Key::Named(NamedKey::Accept),
WinitNamedKey::Again => Key::Named(NamedKey::Again),
WinitNamedKey::AllCandidates => Key::Named(NamedKey::AllCandidates),
WinitNamedKey::Alphanumeric => Key::Named(NamedKey::Alphanumeric),
WinitNamedKey::Alt => Key::Named(NamedKey::Alt),
WinitNamedKey::AltGraph => Key::Named(NamedKey::AltGraph),
WinitNamedKey::AppSwitch => Key::Named(NamedKey::AppSwitch),
WinitNamedKey::ArrowDown => Key::Named(NamedKey::ArrowDown),
WinitNamedKey::ArrowLeft => Key::Named(NamedKey::ArrowLeft),
WinitNamedKey::ArrowRight => Key::Named(NamedKey::ArrowRight),
WinitNamedKey::ArrowUp => Key::Named(NamedKey::ArrowUp),
WinitNamedKey::Attn => Key::Named(NamedKey::Attn),
WinitNamedKey::AudioBalanceLeft => Key::Named(NamedKey::AudioBalanceLeft),
WinitNamedKey::AudioBalanceRight => Key::Named(NamedKey::AudioBalanceRight),
WinitNamedKey::AudioBassBoostDown => Key::Named(NamedKey::AudioBassBoostDown),
WinitNamedKey::AudioBassBoostToggle => Key::Named(NamedKey::AudioBassBoostToggle),
WinitNamedKey::AudioBassBoostUp => Key::Named(NamedKey::AudioBassBoostUp),
WinitNamedKey::AudioFaderFront => Key::Named(NamedKey::AudioFaderFront),
WinitNamedKey::AudioFaderRear => Key::Named(NamedKey::AudioFaderRear),
WinitNamedKey::AudioSurroundModeNext => Key::Named(NamedKey::AudioSurroundModeNext),
WinitNamedKey::AudioTrebleDown => Key::Named(NamedKey::AudioTrebleDown),
WinitNamedKey::AudioTrebleUp => Key::Named(NamedKey::AudioTrebleUp),
WinitNamedKey::AudioVolumeDown => Key::Named(NamedKey::AudioVolumeDown),
WinitNamedKey::AudioVolumeMute => Key::Named(NamedKey::AudioVolumeMute),
WinitNamedKey::AudioVolumeUp => Key::Named(NamedKey::AudioVolumeUp),
WinitNamedKey::Backspace => Key::Named(NamedKey::Backspace),
WinitNamedKey::BrightnessDown => Key::Named(NamedKey::BrightnessDown),
WinitNamedKey::BrightnessUp => Key::Named(NamedKey::BrightnessUp),
WinitNamedKey::BrowserBack => Key::Named(NamedKey::BrowserBack),
WinitNamedKey::BrowserFavorites => Key::Named(NamedKey::BrowserFavorites),
WinitNamedKey::BrowserForward => Key::Named(NamedKey::BrowserForward),
WinitNamedKey::BrowserHome => Key::Named(NamedKey::BrowserHome),
WinitNamedKey::BrowserRefresh => Key::Named(NamedKey::BrowserRefresh),
WinitNamedKey::BrowserSearch => Key::Named(NamedKey::BrowserSearch),
WinitNamedKey::BrowserStop => Key::Named(NamedKey::BrowserStop),
WinitNamedKey::Call => Key::Named(NamedKey::Call),
WinitNamedKey::Camera => Key::Named(NamedKey::Camera),
WinitNamedKey::CameraFocus => Key::Named(NamedKey::CameraFocus),
WinitNamedKey::Cancel => Key::Named(NamedKey::Cancel),
WinitNamedKey::CapsLock => Key::Named(NamedKey::CapsLock),
WinitNamedKey::ChannelDown => Key::Named(NamedKey::ChannelDown),
WinitNamedKey::ChannelUp => Key::Named(NamedKey::ChannelUp),
WinitNamedKey::Clear => Key::Named(NamedKey::Clear),
WinitNamedKey::Close => Key::Named(NamedKey::Close),
WinitNamedKey::ClosedCaptionToggle => Key::Named(NamedKey::ClosedCaptionToggle),
WinitNamedKey::CodeInput => Key::Named(NamedKey::CodeInput),
WinitNamedKey::ColorF0Red => Key::Named(NamedKey::ColorF0Red),
WinitNamedKey::ColorF1Green => Key::Named(NamedKey::ColorF1Green),
WinitNamedKey::ColorF2Yellow => Key::Named(NamedKey::ColorF2Yellow),
WinitNamedKey::ColorF3Blue => Key::Named(NamedKey::ColorF3Blue),
WinitNamedKey::ColorF4Grey => Key::Named(NamedKey::ColorF4Grey),
WinitNamedKey::ColorF5Brown => Key::Named(NamedKey::ColorF5Brown),
WinitNamedKey::Compose => Key::Named(NamedKey::Compose),
WinitNamedKey::ContextMenu => Key::Named(NamedKey::ContextMenu),
WinitNamedKey::Control => Key::Named(NamedKey::Control),
WinitNamedKey::Convert => Key::Named(NamedKey::Convert),
WinitNamedKey::Copy => Key::Named(NamedKey::Copy),
WinitNamedKey::CrSel => Key::Named(NamedKey::CrSel),
WinitNamedKey::Cut => Key::Named(NamedKey::Cut),
WinitNamedKey::DVR => Key::Named(NamedKey::DVR),
WinitNamedKey::Delete => Key::Named(NamedKey::Delete),
WinitNamedKey::Dimmer => Key::Named(NamedKey::Dimmer),
WinitNamedKey::DisplaySwap => Key::Named(NamedKey::DisplaySwap),
WinitNamedKey::Eisu => Key::Named(NamedKey::Eisu),
WinitNamedKey::Eject => Key::Named(NamedKey::Eject),
WinitNamedKey::End => Key::Named(NamedKey::End),
WinitNamedKey::EndCall => Key::Named(NamedKey::EndCall),
WinitNamedKey::Enter => Key::Named(NamedKey::Enter),
WinitNamedKey::EraseEof => Key::Named(NamedKey::EraseEof),
WinitNamedKey::Escape => Key::Named(NamedKey::Escape),
WinitNamedKey::ExSel => Key::Named(NamedKey::ExSel),
WinitNamedKey::Execute => Key::Named(NamedKey::Execute),
WinitNamedKey::Exit => Key::Named(NamedKey::Exit),
WinitNamedKey::F1 => Key::Named(NamedKey::F1),
WinitNamedKey::F10 => Key::Named(NamedKey::F10),
WinitNamedKey::F11 => Key::Named(NamedKey::F11),
WinitNamedKey::F12 => Key::Named(NamedKey::F12),
WinitNamedKey::F13 => Key::Named(NamedKey::F13),
WinitNamedKey::F14 => Key::Named(NamedKey::F14),
WinitNamedKey::F15 => Key::Named(NamedKey::F15),
WinitNamedKey::F16 => Key::Named(NamedKey::F16),
WinitNamedKey::F17 => Key::Named(NamedKey::F17),
WinitNamedKey::F18 => Key::Named(NamedKey::F18),
WinitNamedKey::F19 => Key::Named(NamedKey::F19),
WinitNamedKey::F2 => Key::Named(NamedKey::F2),
WinitNamedKey::F20 => Key::Named(NamedKey::F20),
WinitNamedKey::F21 => Key::Named(NamedKey::F21),
WinitNamedKey::F22 => Key::Named(NamedKey::F22),
WinitNamedKey::F23 => Key::Named(NamedKey::F23),
WinitNamedKey::F24 => Key::Named(NamedKey::F24),
WinitNamedKey::F25 => Key::Named(NamedKey::F25),
WinitNamedKey::F26 => Key::Named(NamedKey::F26),
WinitNamedKey::F27 => Key::Named(NamedKey::F27),
WinitNamedKey::F28 => Key::Named(NamedKey::F28),
WinitNamedKey::F29 => Key::Named(NamedKey::F29),
WinitNamedKey::F3 => Key::Named(NamedKey::F3),
WinitNamedKey::F30 => Key::Named(NamedKey::F30),
WinitNamedKey::F31 => Key::Named(NamedKey::F31),
WinitNamedKey::F32 => Key::Named(NamedKey::F32),
WinitNamedKey::F33 => Key::Named(NamedKey::F33),
WinitNamedKey::F34 => Key::Named(NamedKey::F34),
WinitNamedKey::F35 => Key::Named(NamedKey::F35),
WinitNamedKey::F4 => Key::Named(NamedKey::F4),
WinitNamedKey::F5 => Key::Named(NamedKey::F5),
WinitNamedKey::F6 => Key::Named(NamedKey::F6),
WinitNamedKey::F7 => Key::Named(NamedKey::F7),
WinitNamedKey::F8 => Key::Named(NamedKey::F8),
WinitNamedKey::F9 => Key::Named(NamedKey::F9),
WinitNamedKey::FavoriteClear0 => Key::Named(NamedKey::FavoriteClear0),
WinitNamedKey::FavoriteClear1 => Key::Named(NamedKey::FavoriteClear1),
WinitNamedKey::FavoriteClear2 => Key::Named(NamedKey::FavoriteClear2),
WinitNamedKey::FavoriteClear3 => Key::Named(NamedKey::FavoriteClear3),
WinitNamedKey::FavoriteRecall0 => Key::Named(NamedKey::FavoriteRecall0),
WinitNamedKey::FavoriteRecall1 => Key::Named(NamedKey::FavoriteRecall1),
WinitNamedKey::FavoriteRecall2 => Key::Named(NamedKey::FavoriteRecall2),
WinitNamedKey::FavoriteRecall3 => Key::Named(NamedKey::FavoriteRecall3),
WinitNamedKey::FavoriteStore0 => Key::Named(NamedKey::FavoriteStore0),
WinitNamedKey::FavoriteStore1 => Key::Named(NamedKey::FavoriteStore1),
WinitNamedKey::FavoriteStore2 => Key::Named(NamedKey::FavoriteStore2),
WinitNamedKey::FavoriteStore3 => Key::Named(NamedKey::FavoriteStore3),
WinitNamedKey::FinalMode => Key::Named(NamedKey::FinalMode),
WinitNamedKey::Find => Key::Named(NamedKey::Find),
WinitNamedKey::Fn => Key::Named(NamedKey::Fn),
WinitNamedKey::FnLock => Key::Named(NamedKey::FnLock),
WinitNamedKey::GoBack => Key::Named(NamedKey::GoBack),
WinitNamedKey::GoHome => Key::Named(NamedKey::GoHome),
WinitNamedKey::GroupFirst => Key::Named(NamedKey::GroupFirst),
WinitNamedKey::GroupLast => Key::Named(NamedKey::GroupLast),
WinitNamedKey::GroupNext => Key::Named(NamedKey::GroupNext),
WinitNamedKey::GroupPrevious => Key::Named(NamedKey::GroupPrevious),
WinitNamedKey::Guide => Key::Named(NamedKey::Guide),
WinitNamedKey::GuideNextDay => Key::Named(NamedKey::GuideNextDay),
WinitNamedKey::GuidePreviousDay => Key::Named(NamedKey::GuidePreviousDay),
WinitNamedKey::HangulMode => Key::Named(NamedKey::HangulMode),
WinitNamedKey::HanjaMode => Key::Named(NamedKey::HanjaMode),
WinitNamedKey::Hankaku => Key::Named(NamedKey::Hankaku),
WinitNamedKey::HeadsetHook => Key::Named(NamedKey::HeadsetHook),
WinitNamedKey::Help => Key::Named(NamedKey::Help),
WinitNamedKey::Hibernate => Key::Named(NamedKey::Hibernate),
WinitNamedKey::Hiragana => Key::Named(NamedKey::Hiragana),
WinitNamedKey::HiraganaKatakana => Key::Named(NamedKey::HiraganaKatakana),
WinitNamedKey::Home => Key::Named(NamedKey::Home),
WinitNamedKey::Hyper => Key::Named(NamedKey::Hyper),
WinitNamedKey::Info => Key::Named(NamedKey::Info),
WinitNamedKey::Insert => Key::Named(NamedKey::Insert),
WinitNamedKey::InstantReplay => Key::Named(NamedKey::InstantReplay),
WinitNamedKey::JunjaMode => Key::Named(NamedKey::JunjaMode),
WinitNamedKey::KanaMode => Key::Named(NamedKey::KanaMode),
WinitNamedKey::KanjiMode => Key::Named(NamedKey::KanjiMode),
WinitNamedKey::Katakana => Key::Named(NamedKey::Katakana),
WinitNamedKey::Key11 => Key::Named(NamedKey::Key11),
WinitNamedKey::Key12 => Key::Named(NamedKey::Key12),
WinitNamedKey::LastNumberRedial => Key::Named(NamedKey::LastNumberRedial),
WinitNamedKey::LaunchApplication1 => Key::Named(NamedKey::LaunchApplication1),
WinitNamedKey::LaunchApplication2 => Key::Named(NamedKey::LaunchApplication2),
WinitNamedKey::LaunchCalendar => Key::Named(NamedKey::LaunchCalendar),
WinitNamedKey::LaunchContacts => Key::Named(NamedKey::LaunchContacts),
WinitNamedKey::LaunchMail => Key::Named(NamedKey::LaunchMail),
WinitNamedKey::LaunchMediaPlayer => Key::Named(NamedKey::LaunchMediaPlayer),
WinitNamedKey::LaunchMusicPlayer => Key::Named(NamedKey::LaunchMusicPlayer),
WinitNamedKey::LaunchPhone => Key::Named(NamedKey::LaunchPhone),
WinitNamedKey::LaunchScreenSaver => Key::Named(NamedKey::LaunchScreenSaver),
WinitNamedKey::LaunchSpreadsheet => Key::Named(NamedKey::LaunchSpreadsheet),
WinitNamedKey::LaunchWebBrowser => Key::Named(NamedKey::LaunchWebBrowser),
WinitNamedKey::LaunchWebCam => Key::Named(NamedKey::LaunchWebCam),
WinitNamedKey::LaunchWordProcessor => Key::Named(NamedKey::LaunchWordProcessor),
WinitNamedKey::Link => Key::Named(NamedKey::Link),
WinitNamedKey::ListProgram => Key::Named(NamedKey::ListProgram),
WinitNamedKey::LiveContent => Key::Named(NamedKey::LiveContent),
WinitNamedKey::Lock => Key::Named(NamedKey::Lock),
WinitNamedKey::LogOff => Key::Named(NamedKey::LogOff),
WinitNamedKey::MailForward => Key::Named(NamedKey::MailForward),
WinitNamedKey::MailReply => Key::Named(NamedKey::MailReply),
WinitNamedKey::MailSend => Key::Named(NamedKey::MailSend),
WinitNamedKey::MannerMode => Key::Named(NamedKey::MannerMode),
WinitNamedKey::MediaApps => Key::Named(NamedKey::MediaApps),
WinitNamedKey::MediaAudioTrack => Key::Named(NamedKey::MediaAudioTrack),
WinitNamedKey::MediaClose => Key::Named(NamedKey::MediaClose),
WinitNamedKey::MediaFastForward => Key::Named(NamedKey::MediaFastForward),
WinitNamedKey::MediaLast => Key::Named(NamedKey::MediaLast),
WinitNamedKey::MediaPause => Key::Named(NamedKey::MediaPause),
WinitNamedKey::MediaPlay => Key::Named(NamedKey::MediaPlay),
WinitNamedKey::MediaPlayPause => Key::Named(NamedKey::MediaPlayPause),
WinitNamedKey::MediaRecord => Key::Named(NamedKey::MediaRecord),
WinitNamedKey::MediaRewind => Key::Named(NamedKey::MediaRewind),
WinitNamedKey::MediaSkipBackward => Key::Named(NamedKey::MediaSkipBackward),
WinitNamedKey::MediaSkipForward => Key::Named(NamedKey::MediaSkipForward),
WinitNamedKey::MediaStepBackward => Key::Named(NamedKey::MediaStepBackward),
WinitNamedKey::MediaStepForward => Key::Named(NamedKey::MediaStepForward),
WinitNamedKey::MediaStop => Key::Named(NamedKey::MediaStop),
WinitNamedKey::MediaTopMenu => Key::Named(NamedKey::MediaTopMenu),
WinitNamedKey::MediaTrackNext => Key::Named(NamedKey::MediaTrackNext),
WinitNamedKey::MediaTrackPrevious => Key::Named(NamedKey::MediaTrackPrevious),
WinitNamedKey::Meta => Key::Named(NamedKey::Meta),
WinitNamedKey::MicrophoneToggle => Key::Named(NamedKey::MicrophoneToggle),
WinitNamedKey::MicrophoneVolumeDown => Key::Named(NamedKey::MicrophoneVolumeDown),
WinitNamedKey::MicrophoneVolumeMute => Key::Named(NamedKey::MicrophoneVolumeMute),
WinitNamedKey::MicrophoneVolumeUp => Key::Named(NamedKey::MicrophoneVolumeUp),
WinitNamedKey::ModeChange => Key::Named(NamedKey::ModeChange),
WinitNamedKey::NavigateIn => Key::Named(NamedKey::NavigateIn),
WinitNamedKey::NavigateNext => Key::Named(NamedKey::NavigateNext),
WinitNamedKey::NavigateOut => Key::Named(NamedKey::NavigateOut),
WinitNamedKey::NavigatePrevious => Key::Named(NamedKey::NavigatePrevious),
WinitNamedKey::New => Key::Named(NamedKey::New),
WinitNamedKey::NextCandidate => Key::Named(NamedKey::NextCandidate),
WinitNamedKey::NextFavoriteChannel => Key::Named(NamedKey::NextFavoriteChannel),
WinitNamedKey::NextUserProfile => Key::Named(NamedKey::NextUserProfile),
WinitNamedKey::NonConvert => Key::Named(NamedKey::NonConvert),
WinitNamedKey::Notification => Key::Named(NamedKey::Notification),
WinitNamedKey::NumLock => Key::Named(NamedKey::NumLock),
WinitNamedKey::OnDemand => Key::Named(NamedKey::OnDemand),
WinitNamedKey::Open => Key::Named(NamedKey::Open),
WinitNamedKey::PageDown => Key::Named(NamedKey::PageDown),
WinitNamedKey::PageUp => Key::Named(NamedKey::PageUp),
WinitNamedKey::Pairing => Key::Named(NamedKey::Pairing),
WinitNamedKey::Paste => Key::Named(NamedKey::Paste),
WinitNamedKey::Pause => Key::Named(NamedKey::Pause),
WinitNamedKey::PinPDown => Key::Named(NamedKey::PinPDown),
WinitNamedKey::PinPMove => Key::Named(NamedKey::PinPMove),
WinitNamedKey::PinPToggle => Key::Named(NamedKey::PinPToggle),
WinitNamedKey::PinPUp => Key::Named(NamedKey::PinPUp),
WinitNamedKey::Play => Key::Named(NamedKey::Play),
WinitNamedKey::PlaySpeedDown => Key::Named(NamedKey::PlaySpeedDown),
WinitNamedKey::PlaySpeedReset => Key::Named(NamedKey::PlaySpeedReset),
WinitNamedKey::PlaySpeedUp => Key::Named(NamedKey::PlaySpeedUp),
WinitNamedKey::Power => Key::Named(NamedKey::Power),
WinitNamedKey::PowerOff => Key::Named(NamedKey::PowerOff),
WinitNamedKey::PreviousCandidate => Key::Named(NamedKey::PreviousCandidate),
WinitNamedKey::Print => Key::Named(NamedKey::Print),
WinitNamedKey::PrintScreen => Key::Named(NamedKey::PrintScreen),
WinitNamedKey::Process => Key::Named(NamedKey::Process),
WinitNamedKey::Props => Key::Named(NamedKey::Props),
WinitNamedKey::RandomToggle => Key::Named(NamedKey::RandomToggle),
WinitNamedKey::RcLowBattery => Key::Named(NamedKey::RcLowBattery),
WinitNamedKey::RecordSpeedNext => Key::Named(NamedKey::RecordSpeedNext),
WinitNamedKey::Redo => Key::Named(NamedKey::Redo),
WinitNamedKey::RfBypass => Key::Named(NamedKey::RfBypass),
WinitNamedKey::Romaji => Key::Named(NamedKey::Romaji),
WinitNamedKey::STBInput => Key::Named(NamedKey::STBInput),
WinitNamedKey::STBPower => Key::Named(NamedKey::STBPower),
WinitNamedKey::Save => Key::Named(NamedKey::Save),
WinitNamedKey::ScanChannelsToggle => Key::Named(NamedKey::ScanChannelsToggle),
WinitNamedKey::ScreenModeNext => Key::Named(NamedKey::ScreenModeNext),
WinitNamedKey::ScrollLock => Key::Named(NamedKey::ScrollLock),
WinitNamedKey::Select => Key::Named(NamedKey::Select),
WinitNamedKey::Settings => Key::Named(NamedKey::Settings),
WinitNamedKey::Shift => Key::Named(NamedKey::Shift),
WinitNamedKey::SingleCandidate => Key::Named(NamedKey::SingleCandidate),
WinitNamedKey::Soft1 => Key::Named(NamedKey::Soft1),
WinitNamedKey::Soft2 => Key::Named(NamedKey::Soft2),
WinitNamedKey::Soft3 => Key::Named(NamedKey::Soft3),
WinitNamedKey::Soft4 => Key::Named(NamedKey::Soft4),
WinitNamedKey::Space => Key::Character(" ".to_string()),
WinitNamedKey::SpeechCorrectionList => Key::Named(NamedKey::SpeechCorrectionList),
WinitNamedKey::SpeechInputToggle => Key::Named(NamedKey::SpeechInputToggle),
WinitNamedKey::SpellCheck => Key::Named(NamedKey::SpellCheck),
WinitNamedKey::SplitScreenToggle => Key::Named(NamedKey::SplitScreenToggle),
WinitNamedKey::Standby => Key::Named(NamedKey::Standby),
WinitNamedKey::Subtitle => Key::Named(NamedKey::Subtitle),
WinitNamedKey::Super => Key::Named(NamedKey::Super),
WinitNamedKey::Symbol => Key::Named(NamedKey::Symbol),
WinitNamedKey::SymbolLock => Key::Named(NamedKey::SymbolLock),
WinitNamedKey::TV => Key::Named(NamedKey::TV),
WinitNamedKey::TV3DMode => Key::Named(NamedKey::TV3DMode),
WinitNamedKey::TVAntennaCable => Key::Named(NamedKey::TVAntennaCable),
WinitNamedKey::TVAudioDescription => Key::Named(NamedKey::TVAudioDescription),
WinitNamedKey::TVAudioDescriptionMixDown => {
Key::Named(NamedKey::TVAudioDescriptionMixDown)
},
WinitNamedKey::TVAudioDescriptionMixUp => Key::Named(NamedKey::TVAudioDescriptionMixUp),
WinitNamedKey::TVContentsMenu => Key::Named(NamedKey::TVContentsMenu),
WinitNamedKey::TVDataService => Key::Named(NamedKey::TVDataService),
WinitNamedKey::TVInput => Key::Named(NamedKey::TVInput),
WinitNamedKey::TVInputComponent1 => Key::Named(NamedKey::TVInputComponent1),
WinitNamedKey::TVInputComponent2 => Key::Named(NamedKey::TVInputComponent2),
WinitNamedKey::TVInputComposite1 => Key::Named(NamedKey::TVInputComposite1),
WinitNamedKey::TVInputComposite2 => Key::Named(NamedKey::TVInputComposite2),
WinitNamedKey::TVInputHDMI1 => Key::Named(NamedKey::TVInputHDMI1),
WinitNamedKey::TVInputHDMI2 => Key::Named(NamedKey::TVInputHDMI2),
WinitNamedKey::TVInputHDMI3 => Key::Named(NamedKey::TVInputHDMI3),
WinitNamedKey::TVInputHDMI4 => Key::Named(NamedKey::TVInputHDMI4),
WinitNamedKey::TVInputVGA1 => Key::Named(NamedKey::TVInputVGA1),
WinitNamedKey::TVMediaContext => Key::Named(NamedKey::TVMediaContext),
WinitNamedKey::TVNetwork => Key::Named(NamedKey::TVNetwork),
WinitNamedKey::TVNumberEntry => Key::Named(NamedKey::TVNumberEntry),
WinitNamedKey::TVPower => Key::Named(NamedKey::TVPower),
WinitNamedKey::TVRadioService => Key::Named(NamedKey::TVRadioService),
WinitNamedKey::TVSatellite => Key::Named(NamedKey::TVSatellite),
WinitNamedKey::TVSatelliteBS => Key::Named(NamedKey::TVSatelliteBS),
WinitNamedKey::TVSatelliteCS => Key::Named(NamedKey::TVSatelliteCS),
WinitNamedKey::TVSatelliteToggle => Key::Named(NamedKey::TVSatelliteToggle),
WinitNamedKey::TVTerrestrialAnalog => Key::Named(NamedKey::TVTerrestrialAnalog),
WinitNamedKey::TVTerrestrialDigital => Key::Named(NamedKey::TVTerrestrialDigital),
WinitNamedKey::TVTimer => Key::Named(NamedKey::TVTimer),
WinitNamedKey::Tab => Key::Named(NamedKey::Tab),
WinitNamedKey::Teletext => Key::Named(NamedKey::Teletext),
WinitNamedKey::Undo => Key::Named(NamedKey::Undo),
WinitNamedKey::VideoModeNext => Key::Named(NamedKey::VideoModeNext),
WinitNamedKey::VoiceDial => Key::Named(NamedKey::VoiceDial),
WinitNamedKey::WakeUp => Key::Named(NamedKey::WakeUp),
WinitNamedKey::Wink => Key::Named(NamedKey::Wink),
WinitNamedKey::Zenkaku => Key::Named(NamedKey::Zenkaku),
WinitNamedKey::ZenkakuHankaku => Key::Named(NamedKey::ZenkakuHankaku),
WinitNamedKey::ZoomIn => Key::Named(NamedKey::ZoomIn),
WinitNamedKey::ZoomOut => Key::Named(NamedKey::ZoomOut),
WinitNamedKey::ZoomToggle => Key::Named(NamedKey::ZoomToggle),
_ => Key::Named(NamedKey::Unidentified),
}
}
}
@ -358,6 +362,7 @@ impl FromWinitKeyEvent for Location {
}
}
#[allow(deprecated)]
impl FromWinitKeyEvent for Code {
fn from_winit_key_event(key_event: &KeyEvent) -> Self {
let key_code = match key_event.physical_key {

View file

@ -7,7 +7,6 @@ use std::rc::Rc;
use dpi::PhysicalSize;
use ipc_channel::ipc::IpcSender;
use keyboard_types::{CompositionEvent, CompositionState};
use log::{debug, error, info, warn};
use raw_window_handle::{RawWindowHandle, WindowHandle};
use servo::base::id::WebViewId;
@ -16,11 +15,12 @@ use servo::servo_geometry::DeviceIndependentPixel;
use servo::webrender_api::ScrollLocation;
use servo::webrender_api::units::{DeviceIntRect, DeviceIntSize, DevicePixel};
use servo::{
AllowOrDenyRequest, ContextMenuResult, ImeEvent, InputEvent, InputMethodType, Key, KeyState,
KeyboardEvent, LoadStatus, MediaSessionActionType, MediaSessionEvent, MouseButton,
MouseButtonAction, MouseButtonEvent, MouseMoveEvent, NavigationRequest, PermissionRequest,
RenderingContext, ScreenGeometry, Servo, ServoDelegate, ServoError, SimpleDialog, TouchEvent,
TouchEventType, TouchId, WebView, WebViewBuilder, WebViewDelegate, WindowRenderingContext,
AllowOrDenyRequest, CompositionEvent, CompositionState, ContextMenuResult, ImeEvent,
InputEvent, InputMethodType, Key, KeyState, KeyboardEvent, LoadStatus, MediaSessionActionType,
MediaSessionEvent, MouseButton, MouseButtonAction, MouseButtonEvent, MouseMoveEvent, NamedKey,
NavigationRequest, PermissionRequest, RenderingContext, ScreenGeometry, Servo, ServoDelegate,
ServoError, SimpleDialog, TouchEvent, TouchEventType, TouchId, WebView, WebViewBuilder,
WebViewDelegate, WindowRenderingContext,
};
use url::Url;
@ -613,7 +613,7 @@ impl RunningAppState {
let active_webview = self.active_webview();
active_webview.notify_input_event(InputEvent::Keyboard(KeyboardEvent::from_state_and_key(
KeyState::Down,
Key::Process,
Key::Named(NamedKey::Process),
)));
active_webview.notify_input_event(InputEvent::Ime(ImeEvent::Composition(
CompositionEvent {
@ -623,7 +623,7 @@ impl RunningAppState {
)));
active_webview.notify_input_event(InputEvent::Keyboard(KeyboardEvent::from_state_and_key(
KeyState::Up,
Key::Process,
Key::Named(NamedKey::Process),
)));
self.perform_updates();
}

View file

@ -13,7 +13,7 @@ use std::thread;
use std::thread::sleep;
use std::time::Duration;
use keyboard_types::Key;
use keyboard_types::{Key, NamedKey};
use log::{LevelFilter, debug, error, info, trace, warn};
use napi_derive_ohos::{module_exports, napi};
use napi_ohos::bindgen_prelude::Function;
@ -185,19 +185,19 @@ impl ServoAction {
InsertText(text) => servo.ime_insert_text(text.clone()),
ImeDeleteForward(len) => {
for _ in 0..*len {
servo.key_down(Key::Delete);
servo.key_up(Key::Delete);
servo.key_down(Key::Named(NamedKey::Delete));
servo.key_up(Key::Named(NamedKey::Delete));
}
},
ImeDeleteBackward(len) => {
for _ in 0..*len {
servo.key_down(Key::Backspace);
servo.key_up(Key::Backspace);
servo.key_down(Key::Named(NamedKey::Backspace));
servo.key_up(Key::Named(NamedKey::Backspace));
}
},
ImeSendEnter => {
servo.key_down(Key::Enter);
servo.key_up(Key::Enter);
servo.key_down(Key::Named(NamedKey::Enter));
servo.key_up(Key::Named(NamedKey::Enter));
},
Initialize(_init_opts) => {
panic!("Received Initialize event, even though servo is already initialized")

View file

@ -7,7 +7,7 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
use keyboard_types::{Key, Modifiers};
use keyboard_types::{Key, Modifiers, NamedKey};
use script::test::DOMString;
use script::test::textinput::{
ClipboardProvider, Direction, Lines, Selection, SelectionDirection, TextInput, TextPoint,
@ -488,10 +488,10 @@ fn test_navigation_keyboard_shortcuts() {
let mut textinput = text_input(Lines::Multiple, "hello áéc");
// Test that CMD + Right moves to the end of the current line.
textinput.handle_keydown_aux(Key::ArrowRight, Modifiers::META, true);
textinput.handle_keydown_aux(Key::Named(NamedKey::ArrowRight), Modifiers::META, true);
assert_eq!(textinput.edit_point().index, UTF8Bytes(11));
// Test that CMD + Right moves to the beginning of the current line.
textinput.handle_keydown_aux(Key::ArrowLeft, Modifiers::META, true);
textinput.handle_keydown_aux(Key::Named(NamedKey::ArrowLeft), Modifiers::META, true);
assert_eq!(textinput.edit_point().index, UTF8Bytes::zero());
// Test that CTRL + ALT + E moves to the end of the current line also.
textinput.handle_keydown_aux(
@ -509,7 +509,7 @@ fn test_navigation_keyboard_shortcuts() {
assert_eq!(textinput.edit_point().index, UTF8Bytes::zero());
// Test that ALT + Right moves to the end of the word.
textinput.handle_keydown_aux(Key::ArrowRight, Modifiers::ALT, true);
textinput.handle_keydown_aux(Key::Named(NamedKey::ArrowRight), Modifiers::ALT, true);
assert_eq!(textinput.edit_point().index, UTF8Bytes(5));
// Test that CTRL + ALT + F moves to the end of the word also.
textinput.handle_keydown_aux(
@ -519,7 +519,7 @@ fn test_navigation_keyboard_shortcuts() {
);
assert_eq!(textinput.edit_point().index, UTF8Bytes(11));
// Test that ALT + Left moves to the end of the word.
textinput.handle_keydown_aux(Key::ArrowLeft, Modifiers::ALT, true);
textinput.handle_keydown_aux(Key::Named(NamedKey::ArrowLeft), Modifiers::ALT, true);
assert_eq!(textinput.edit_point().index, UTF8Bytes(6));
// Test that CTRL + ALT + B moves to the end of the word also.
textinput.handle_keydown_aux(
@ -860,7 +860,7 @@ fn test_select_all() {
#[test]
fn test_backspace_in_textarea_at_beginning_of_line() {
let mut textinput = text_input(Lines::Multiple, "first line\n");
textinput.handle_keydown_aux(Key::ArrowDown, Modifiers::empty(), false);
textinput.handle_keydown_aux(Key::Backspace, Modifiers::empty(), false);
textinput.handle_keydown_aux(Key::Named(NamedKey::ArrowDown), Modifiers::empty(), false);
textinput.handle_keydown_aux(Key::Named(NamedKey::Backspace), Modifiers::empty(), false);
assert_eq!(textinput.get_content(), DOMString::from("first line"));
}