Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Format component of webdriver_sever #21603

Merged
merged 1 commit into from Sep 4, 2018
Merged
Changes from all commits
Commits
File filter...
Filter file types
Jump to…
Jump to file
Failed to load files.

Always

Just for now

@@ -4,7 +4,6 @@

use msg::constellation_msg::{Key, KeyState, KeyModifiers};


/// Takes a character and returns an Option containing a tuple of the
/// corresponding keycode and whether shift is required. This is
/// currently pretty much ascii-only and the webdriver spec isn't
@@ -164,22 +163,23 @@ fn key_from_char(key_string: &char) -> Option<(Key, bool)> {
'\u{E03C}' => Some((Key::F12, false)),
'\u{E03D}' => None,
'\u{E040}' => None,
_ => None
_ => None,
}
}

pub fn keycodes_to_keys(key_codes: &str) -> Result<Vec<(Key, KeyModifiers, KeyState)>, String> {
let mut rv = vec![];

for char_code in key_codes.chars() {
let (key, with_shift) = key_from_char(&char_code).ok_or(format!("Unsupported character code {}", char_code))?;
let (key, with_shift) =
key_from_char(&char_code).ok_or(format!("Unsupported character code {}", char_code))?;
let modifiers = if with_shift {
KeyModifiers::SHIFT
} else {
KeyModifiers::empty()
};
rv.push((key, modifiers, KeyState::Pressed));
rv.push((key, modifiers, KeyState::Released));
};
}
Ok(rv)
}
ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.