mirror of
https://github.com/servo/servo.git
synced 2025-08-11 08:25:32 +01:00
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:
parent
76ddbe4d7a
commit
0ccaa7e1a9
35 changed files with 762 additions and 1604 deletions
|
@ -25,6 +25,7 @@ gfx_traits = {path = "../gfx_traits"}
|
|||
hyper = "0.10"
|
||||
ipc-channel = "0.11"
|
||||
layout_traits = {path = "../layout_traits"}
|
||||
keyboard-types = {version = "0.4.0-serde", features = ["serde"]}
|
||||
log = "0.4"
|
||||
metrics = {path = "../metrics"}
|
||||
msg = {path = "../msg"}
|
||||
|
|
|
@ -111,10 +111,10 @@ use gfx_traits::Epoch;
|
|||
use ipc_channel::{Error as IpcError};
|
||||
use ipc_channel::ipc::{self, IpcSender, IpcReceiver};
|
||||
use ipc_channel::router::ROUTER;
|
||||
use keyboard_types::KeyboardEvent;
|
||||
use layout_traits::LayoutThreadFactory;
|
||||
use log::{Log, Level, LevelFilter, Metadata, Record};
|
||||
use msg::constellation_msg::{BrowsingContextId, PipelineId, HistoryStateId, TopLevelBrowsingContextId};
|
||||
use msg::constellation_msg::{Key, KeyModifiers, KeyState};
|
||||
use msg::constellation_msg::{PipelineNamespace, PipelineNamespaceId, TraversalDirection};
|
||||
use net_traits::{self, IpcSend, FetchResponseMsg, ResourceThreads};
|
||||
use net_traits::pub_domains::reg_host;
|
||||
|
@ -972,8 +972,8 @@ where
|
|||
});
|
||||
let _ = resp_chan.send(focus_browsing_context);
|
||||
},
|
||||
FromCompositorMsg::KeyEvent(ch, key, state, modifiers) => {
|
||||
self.handle_key_msg(ch, key, state, modifiers);
|
||||
FromCompositorMsg::Keyboard(key_event) => {
|
||||
self.handle_key_msg(key_event);
|
||||
},
|
||||
// Load a new page from a typed url
|
||||
// If there is already a pending page (self.pending_changes), it will not be overridden;
|
||||
|
@ -2622,12 +2622,12 @@ where
|
|||
session_history.replace_history_state(pipeline_id, history_state_id, url);
|
||||
}
|
||||
|
||||
fn handle_key_msg(&mut self, ch: Option<char>, key: Key, state: KeyState, mods: KeyModifiers) {
|
||||
fn handle_key_msg(&mut self, event: KeyboardEvent) {
|
||||
// Send to the focused browsing contexts' current pipeline. If it
|
||||
// doesn't exist, fall back to sending to the compositor.
|
||||
match self.focused_browsing_context_id {
|
||||
Some(browsing_context_id) => {
|
||||
let event = CompositorEvent::KeyEvent(ch, key, state, mods);
|
||||
let event = CompositorEvent::KeyboardEvent(event);
|
||||
let pipeline_id = match self.browsing_contexts.get(&browsing_context_id) {
|
||||
Some(ctx) => ctx.pipeline_id,
|
||||
None => return warn!(
|
||||
|
@ -2647,7 +2647,7 @@ where
|
|||
}
|
||||
},
|
||||
None => {
|
||||
let event = (None, EmbedderMsg::KeyEvent(ch, key, state, mods));
|
||||
let event = (None, EmbedderMsg::Keyboard(event));
|
||||
self.embedder_proxy.clone().send(event);
|
||||
},
|
||||
}
|
||||
|
@ -2942,8 +2942,8 @@ where
|
|||
Some(pipeline) => pipeline.event_loop.clone(),
|
||||
None => return warn!("Pipeline {} SendKeys after closure.", pipeline_id),
|
||||
};
|
||||
for (key, mods, state) in cmd {
|
||||
let event = CompositorEvent::KeyEvent(None, key, state, mods);
|
||||
for event in cmd {
|
||||
let event = CompositorEvent::KeyboardEvent(event);
|
||||
let control_msg = ConstellationControlMsg::SendEvent(pipeline_id, event);
|
||||
if let Err(e) = event_loop.send(control_msg) {
|
||||
return self.handle_send_error(pipeline_id, e);
|
||||
|
|
|
@ -22,6 +22,7 @@ extern crate gfx;
|
|||
extern crate gfx_traits;
|
||||
extern crate hyper;
|
||||
extern crate ipc_channel;
|
||||
extern crate keyboard_types;
|
||||
extern crate layout_traits;
|
||||
#[macro_use]
|
||||
extern crate log;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue