Use keyboard-types crate

Have embedders send DOM keys to servo and use a strongly typed KeyboardEvent
from the W3C UI Events spec. All keyboard handling now uses the new types.

Introduce a ShortcutMatcher to recognize key bindings. Shortcuts are now
recognized in a uniform way.

Updated the winit port.
Updated webdriver integration.

part of #20331
This commit is contained in:
Pyfisch 2018-10-06 17:35:45 +02:00
parent 76ddbe4d7a
commit 0ccaa7e1a9
35 changed files with 762 additions and 1604 deletions

View file

@ -109,7 +109,7 @@ use webvr::{WebVRThread, WebVRCompositorHandler};
pub use gleam::gl;
pub use servo_config as config;
pub use servo_url as url;
pub use msg::constellation_msg::{KeyState, TopLevelBrowsingContextId as BrowserId};
pub use msg::constellation_msg::{TopLevelBrowsingContextId as BrowserId};
/// The in-process interface to Servo.
///
@ -316,10 +316,10 @@ where
}
},
WindowEvent::KeyEvent(ch, key, state, modifiers) => {
let msg = ConstellationMsg::KeyEvent(ch, key, state, modifiers);
WindowEvent::Keyboard(key_event) => {
let msg = ConstellationMsg::Keyboard(key_event);
if let Err(e) = self.constellation_chan.send(msg) {
warn!("Sending key event to constellation failed ({:?}).", e);
warn!("Sending keyboard event to constellation failed ({:?}).", e);
}
},
@ -395,12 +395,12 @@ where
(_, ShutdownState::ShuttingDown) => {},
(
EmbedderMsg::KeyEvent(ch, key, state, modified),
EmbedderMsg::Keyboard(key_event),
ShutdownState::NotShuttingDown,
) => {
let event = (
top_level_browsing_context,
EmbedderMsg::KeyEvent(ch, key, state, modified),
EmbedderMsg::Keyboard(key_event),
);
self.embedder_events.push(event);
},