Skip to content

Commit

Permalink
Use keyboard-types::webdriver::send_keys
Browse files Browse the repository at this point in the history
This improves the quality of KeyboardEvents
sent by WebDriver. Now key, code, location and
modifiers are set according to spec.
CompositionEvents are discarded as servo
does not handle them at all.
  • Loading branch information
pyfisch committed Nov 11, 2018
1 parent b60006a commit 2143657
Show file tree
Hide file tree
Showing 12 changed files with 30 additions and 130 deletions.
23 changes: 12 additions & 11 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion components/compositing/Cargo.toml
Expand Up @@ -22,7 +22,7 @@ gleam = {version = "0.6", optional = true}
image = "0.19"
ipc-channel = "0.11"
libc = "0.2"
keyboard-types = {version = "0.4.2-servo", features = ["serde"]}
keyboard-types = "0.4.3"
log = "0.4"
msg = {path = "../msg"}
net_traits = {path = "../net_traits"}
Expand Down
2 changes: 1 addition & 1 deletion components/constellation/Cargo.toml
Expand Up @@ -26,7 +26,7 @@ gfx_traits = {path = "../gfx_traits"}
http = "0.1"
ipc-channel = "0.11"
layout_traits = {path = "../layout_traits"}
keyboard-types = {version = "0.4.2-servo", features = ["serde"]}
keyboard-types = "0.4.3"
log = "0.4"
metrics = {path = "../metrics"}
msg = {path = "../msg"}
Expand Down
2 changes: 1 addition & 1 deletion components/embedder_traits/Cargo.toml
Expand Up @@ -12,7 +12,7 @@ path = "lib.rs"

[dependencies]
ipc-channel = "0.11"
keyboard-types = {version = "0.4.2-servo", features = ["serde"]}
keyboard-types = "0.4.3"
lazy_static = "1"
log = "0.4"
msg = {path = "../msg"}
Expand Down
2 changes: 1 addition & 1 deletion components/malloc_size_of/Cargo.toml
Expand Up @@ -31,7 +31,7 @@ euclid = "0.19"
hashglobe = { path = "../hashglobe" }
hyper = { version = "0.12", optional = true }
hyper_serde = { version = "0.9", optional = true }
keyboard-types = {version = "0.4.2-servo", features = ["serde"], optional = true}
keyboard-types = {version = "0.4.3", optional = true}
mozjs = { version = "0.9.3", optional = true }
selectors = { path = "../selectors" }
serde = { version = "1.0.27", optional = true }
Expand Down
2 changes: 1 addition & 1 deletion components/script/Cargo.toml
Expand Up @@ -65,7 +65,7 @@ ipc-channel = "0.11"
itertools = "0.7.6"
js = {package = "mozjs", version = "0.9.3"}
jstraceable_derive = {path = "../jstraceable_derive"}
keyboard-types = {version = "0.4.2-servo", features = ["serde"]}
keyboard-types = "0.4.3"
lazy_static = "1"
libc = "0.2"
log = "0.4"
Expand Down
2 changes: 1 addition & 1 deletion components/script_traits/Cargo.toml
Expand Up @@ -22,7 +22,7 @@ http = "0.1"
hyper = "0.12"
hyper_serde = "0.9"
ipc-channel = "0.11"
keyboard-types = {version = "0.4.2-servo", features = ["serde"]}
keyboard-types = "0.4.3"
libc = "0.2"
malloc_size_of = { path = "../malloc_size_of" }
malloc_size_of_derive = { path = "../malloc_size_of_derive" }
Expand Down
2 changes: 1 addition & 1 deletion components/webdriver_server/Cargo.toml
Expand Up @@ -17,7 +17,7 @@ euclid = "0.19"
hyper = "0.12"
image = "0.19"
ipc-channel = "0.11"
keyboard-types = {version = "0.4.2-servo", features = ["serde"]}
keyboard-types = "0.4.3"
log = "0.4"
msg = {path = "../msg"}
net_traits = {path = "../net_traits"}
Expand Down
106 changes: 0 additions & 106 deletions components/webdriver_server/keys.rs

This file was deleted.

13 changes: 9 additions & 4 deletions components/webdriver_server/lib.rs
Expand Up @@ -11,14 +11,12 @@ extern crate log;
#[macro_use]
extern crate serde;

mod keys;

use base64;
use crate::keys::keycodes_to_keys;
use euclid::TypedSize2D;
use hyper::Method;
use image::{DynamicImage, ImageFormat, RgbImage};
use ipc_channel::ipc::{self, IpcReceiver, IpcSender};
use keyboard_types::webdriver::{send_keys, Event as KeyEvent};
use msg::constellation_msg::{BrowsingContextId, TopLevelBrowsingContextId, TraversalDirection};
use net_traits::image::base::PixelFormat;
use regex::Captures;
Expand Down Expand Up @@ -1038,7 +1036,14 @@ impl Handler {
))
})?;

let keys = keycodes_to_keys(&keys.text);
// FIXME: Don't discard composition events.
let keys = send_keys(&keys.text)
.drain(..)
.filter_map(|event| match event {
KeyEvent::Keyboard(v) => Some(v),
_ => None,
})
.collect();

// TODO: there's a race condition caused by the focus command and the
// send keys command being two separate messages,
Expand Down
2 changes: 1 addition & 1 deletion ports/servo/Cargo.toml
Expand Up @@ -45,7 +45,7 @@ crossbeam-channel = "0.2"
euclid = "0.19"
gleam = "0.6"
glutin = "0.18"
keyboard-types = {version = "0.4.2-servo", features = ["serde"]}
keyboard-types = "0.4.3"
lazy_static = "1"
libservo = {path = "../../components/servo"}
log = "0.4"
Expand Down
2 changes: 1 addition & 1 deletion tests/unit/script/Cargo.toml
Expand Up @@ -11,6 +11,6 @@ path = "lib.rs"

[dependencies]
euclid = "0.19"
keyboard-types = "0.4.2-servo"
keyboard-types = "0.4.3"
script = {path = "../../../components/script"}
servo_url = {path = "../../../components/url"}

0 comments on commit 2143657

Please sign in to comment.