Bug 1500260 - Use keyboard-types crate. r=emilio
authorPyfisch <pyfisch@gmail.com>
Sat, 06 Oct 2018 17:35:45 +0200
changeset 490348 61bdac71c45c07c9f5f6c3adfcd2c9919b93f7fd
parent 490347 99cc3c6f76ef81913aea6d0a7d785e02e55f4648
child 490349 4fb710869a7746539cbaae952ec26af4286ceb2d
push id247
push userfmarier@mozilla.com
push dateSat, 27 Oct 2018 01:06:44 +0000
reviewersemilio
bugs1500260, 20331, 21881
milestone64.0a1
Bug 1500260 - Use keyboard-types crate. r=emilio 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 cherry-picks part of servo/servo#21881.
servo/components/malloc_size_of/Cargo.toml
servo/components/malloc_size_of/lib.rs
--- a/servo/components/malloc_size_of/Cargo.toml
+++ b/servo/components/malloc_size_of/Cargo.toml
@@ -7,16 +7,17 @@ publish = false
 
 [lib]
 path = "lib.rs"
 
 [features]
 servo = [
     "hyper",
     "hyper_serde",
+    "keyboard-types",
     "mozjs",
     "serde",
     "serde_bytes",
     "servo_channel",
     "string_cache",
     "time",
     "url",
     "webrender_api",
@@ -25,16 +26,17 @@ servo = [
 
 [dependencies]
 app_units = "0.7"
 cssparser = "0.24.0"
 euclid = "0.19"
 hashglobe = { path = "../hashglobe" }
 hyper = { version = "0.10", optional = true }
 hyper_serde = { version = "0.8", optional = true }
+keyboard-types = {version = "0.4.2-servo", features = ["serde"], optional = true}
 mozjs = { version = "0.9.0", optional = true }
 selectors = { path = "../selectors" }
 serde = { version = "1.0.27", optional = true }
 serde_bytes = { version = "0.10", optional = true }
 servo_arc = { path = "../servo_arc" }
 servo_channel = { path = "../channel", optional = true }
 smallbitvec = "2.1.0"
 smallvec = "0.6"
--- a/servo/components/malloc_size_of/lib.rs
+++ b/servo/components/malloc_size_of/lib.rs
@@ -47,16 +47,18 @@ extern crate app_units;
 extern crate cssparser;
 extern crate euclid;
 extern crate hashglobe;
 #[cfg(feature = "servo")]
 extern crate hyper;
 #[cfg(feature = "servo")]
 extern crate hyper_serde;
 #[cfg(feature = "servo")]
+extern crate keyboard_types;
+#[cfg(feature = "servo")]
 extern crate mozjs as js;
 extern crate selectors;
 #[cfg(feature = "servo")]
 extern crate serde;
 #[cfg(feature = "servo")]
 extern crate serde_bytes;
 extern crate servo_arc;
 #[cfg(feature = "servo")]
@@ -953,16 +955,29 @@ malloc_size_of_is_0!(webrender_api::Repe
 #[cfg(feature = "webrender_api")]
 malloc_size_of_is_0!(webrender_api::ScrollSensitivity);
 #[cfg(feature = "webrender_api")]
 malloc_size_of_is_0!(webrender_api::StickyOffsetBounds);
 #[cfg(feature = "webrender_api")]
 malloc_size_of_is_0!(webrender_api::TransformStyle);
 
 #[cfg(feature = "servo")]
+impl MallocSizeOf for keyboard_types::Key {
+    fn size_of(&self, ops: &mut MallocSizeOfOps) -> usize {
+        match self {
+            keyboard_types::Key::Character(ref s) => s.size_of(ops),
+            _ => 0,
+        }
+    }
+}
+
+#[cfg(feature = "servo")]
+malloc_size_of_is_0!(keyboard_types::Modifiers);
+
+#[cfg(feature = "servo")]
 impl MallocSizeOf for xml5ever::QualName {
     fn size_of(&self, ops: &mut MallocSizeOfOps) -> usize {
         self.prefix.size_of(ops) + self.ns.size_of(ops) + self.local.size_of(ops)
     }
 }
 
 #[cfg(feature = "servo")]
 impl MallocSizeOf for hyper::header::Headers {