diff options
author | bors-servo <lbergstrom+bors@mozilla.com> | 2018-10-17 05:36:08 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-10-17 05:36:08 -0400 |
commit | 9a0404ac5fc1c463aa68bb0c68d709a61157c2bf (patch) | |
tree | da8e9f03d9e32d67b0b04ceb18f44dc111d55e5f /components/script_traits/lib.rs | |
parent | b158417956a059215bee921dbda767ab09c88f48 (diff) | |
parent | c8619424f20f5ad58b5e36624464605a3111de66 (diff) | |
download | servo-9a0404ac5fc1c463aa68bb0c68d709a61157c2bf.tar.gz servo-9a0404ac5fc1c463aa68bb0c68d709a61157c2bf.zip |
Auto merge of #21881 - pyfisch:keyboard-types, r=paulrouget
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
What this PR does:
* allow the use non-ASCII keyboards for text input
* decouple keyboard event "key" from "code" (key meaning vs location)
What this PR does not do:
* completely improve keyboard events send from winit and webdriver
* add support for CompositionEvent or IME
Notes:
* The winit embedder does not send keyup events for printable keys (this is a regression)
* keyboard-types is on crates.io because I believe it to be useful outside of servo. If you prefer I can add a copy in this repo.
<!-- Reviewable:start -->
---
This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/21881)
<!-- Reviewable:end -->
Diffstat (limited to 'components/script_traits/lib.rs')
-rw-r--r-- | components/script_traits/lib.rs | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/components/script_traits/lib.rs b/components/script_traits/lib.rs index 802e61ea172..341212c8707 100644 --- a/components/script_traits/lib.rs +++ b/components/script_traits/lib.rs @@ -19,6 +19,7 @@ extern crate gfx_traits; extern crate hyper; extern crate hyper_serde; extern crate ipc_channel; +extern crate keyboard_types; extern crate libc; #[macro_use] extern crate malloc_size_of; @@ -50,8 +51,9 @@ use hyper::header::Headers; use hyper::method::Method; use ipc_channel::{Error as IpcError}; use ipc_channel::ipc::{IpcReceiver, IpcSender}; +use keyboard_types::KeyboardEvent; use libc::c_void; -use msg::constellation_msg::{BrowsingContextId, HistoryStateId, Key, KeyModifiers, KeyState, PipelineId}; +use msg::constellation_msg::{BrowsingContextId, HistoryStateId, PipelineId}; use msg::constellation_msg::{PipelineNamespaceId, TraversalDirection, TopLevelBrowsingContextId}; use net_traits::{FetchResponseMsg, ReferrerPolicy, ResourceThreads}; use net_traits::image::base::Image; @@ -477,7 +479,7 @@ pub enum CompositorEvent { Option<UntrustedNodeAddress>, ), /// A key was pressed. - KeyEvent(Option<char>, Key, KeyState, KeyModifiers), + KeyboardEvent(KeyboardEvent), } /// Requests a TimerEvent-Message be sent after the given duration. @@ -708,7 +710,7 @@ pub enum WebDriverCommandMsg { /// of a browsing context. ScriptCommand(BrowsingContextId, WebDriverScriptCommand), /// Act as if keys were pressed in the browsing context with the given ID. - SendKeys(BrowsingContextId, Vec<(Key, KeyModifiers, KeyState)>), + SendKeys(BrowsingContextId, Vec<KeyboardEvent>), /// Set the window size. SetWindowSize( TopLevelBrowsingContextId, @@ -736,7 +738,7 @@ pub enum ConstellationMsg { /// Query the constellation to see if the current compositor output is stable IsReadyToSaveImage(HashMap<PipelineId, Epoch>), /// Inform the constellation of a key event. - KeyEvent(Option<char>, Key, KeyState, KeyModifiers), + Keyboard(KeyboardEvent), /// Request to load a page. LoadUrl(TopLevelBrowsingContextId, ServoUrl), /// Request to traverse the joint session history of the provided browsing context. @@ -780,7 +782,7 @@ impl fmt::Debug for ConstellationMsg { GetPipeline(..) => "GetPipeline", GetFocusTopLevelBrowsingContext(..) => "GetFocusTopLevelBrowsingContext", IsReadyToSaveImage(..) => "IsReadyToSaveImage", - KeyEvent(..) => "KeyEvent", + Keyboard(..) => "Keyboard", LoadUrl(..) => "LoadUrl", TraverseHistory(..) => "TraverseHistory", WindowSize(..) => "WindowSize", |