mirror of
https://github.com/servo/servo.git
synced 2025-08-06 06:00:15 +01:00
Auto merge of #24489 - garasubo:refactor-submission, r=nox
Refactor submission This is my first contribution, so please correct me if I'm wrong I refactored the code as described #22782. --- <!-- Thank you for contributing to Servo! Please replace each `[ ]` by `[X]` when the step is complete, and replace `___` with appropriate data: --> - [x] `./mach build -d` does not report any errors - [x] `./mach test-tidy` does not report any errors - [ ] These changes fix #22782 (GitHub issue number if applicable) <!-- Either: --> - [ ] There are tests for these changes OR - [ ] These changes do not require tests because ___ <!-- Also, please make sure that "Allow edits from maintainers" checkbox is checked, so that we can help you if you get stuck somewhere along the way.--> <!-- Pull requests that do not address these steps are welcome, but they will require additional verification as part of the review process. -->
This commit is contained in:
commit
e26530341b
7 changed files with 85 additions and 159 deletions
|
@ -121,7 +121,7 @@ use html5ever::{LocalName, Namespace, QualName};
|
|||
use hyper_serde::Serde;
|
||||
use ipc_channel::ipc::{self, IpcSender};
|
||||
use js::jsapi::{JSObject, JSRuntime};
|
||||
use keyboard_types::{Key, KeyState, Modifiers};
|
||||
use keyboard_types::{Code, Key, KeyState};
|
||||
use metrics::{
|
||||
InteractiveFlag, InteractiveMetrics, InteractiveWindow, ProfilerMetadataFactory,
|
||||
ProgressiveWebMetric,
|
||||
|
@ -1469,35 +1469,20 @@ impl Document {
|
|||
// however *when* we do it is up to us.
|
||||
// Here, we're dispatching it after the key event so the script has a chance to cancel it
|
||||
// https://www.w3.org/Bugs/Public/show_bug.cgi?id=27337
|
||||
match keyboard_event.key {
|
||||
Key::Character(ref letter)
|
||||
if letter == " " && keyboard_event.state == KeyState::Up =>
|
||||
{
|
||||
let maybe_elem = target.downcast::<Element>();
|
||||
if let Some(el) = maybe_elem {
|
||||
synthetic_click_activation(
|
||||
el,
|
||||
false,
|
||||
false,
|
||||
false,
|
||||
false,
|
||||
ActivationSource::NotFromClick,
|
||||
)
|
||||
}
|
||||
if (keyboard_event.key == Key::Enter && keyboard_event.state == KeyState::Up) ||
|
||||
(keyboard_event.code == Code::Space && keyboard_event.state == KeyState::Down)
|
||||
{
|
||||
let maybe_elem = target.downcast::<Element>();
|
||||
if let Some(el) = maybe_elem {
|
||||
synthetic_click_activation(
|
||||
el,
|
||||
false,
|
||||
false,
|
||||
false,
|
||||
false,
|
||||
ActivationSource::NotFromClick,
|
||||
)
|
||||
}
|
||||
Key::Enter if keyboard_event.state == KeyState::Up => {
|
||||
let maybe_elem = target.downcast::<Element>();
|
||||
if let Some(el) = maybe_elem {
|
||||
if let Some(a) = el.as_maybe_activatable() {
|
||||
let ctrl = keyboard_event.modifiers.contains(Modifiers::CONTROL);
|
||||
let alt = keyboard_event.modifiers.contains(Modifiers::ALT);
|
||||
let shift = keyboard_event.modifiers.contains(Modifiers::SHIFT);
|
||||
let meta = keyboard_event.modifiers.contains(Modifiers::META);
|
||||
a.implicit_submission(ctrl, alt, shift, meta);
|
||||
}
|
||||
}
|
||||
},
|
||||
_ => (),
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue