mirror of
https://github.com/servo/servo.git
synced 2025-08-05 05:30:08 +01:00
cargo: Upgrade keyboard-types
to 0.8.0
and xcomponent-sys
to 0.3.4
(#38375)
With some adjustment for `NamedKey`. The two crates need to be bumped together to avoid duplicate of `keyboard-types` action. --------- Signed-off-by: PotatoCP <Kenzie.Raditya.Tirtarahardja@huawei.com>
This commit is contained in:
parent
a063b5e78a
commit
05ad9026f5
15 changed files with 471 additions and 432 deletions
|
@ -41,7 +41,7 @@ use html5ever::{LocalName, Namespace, QualName, local_name, ns};
|
|||
use hyper_serde::Serde;
|
||||
use ipc_channel::ipc;
|
||||
use js::rust::{HandleObject, HandleValue, MutableHandleValue};
|
||||
use keyboard_types::{Code, Key, KeyState, Modifiers};
|
||||
use keyboard_types::{Code, Key, KeyState, Modifiers, NamedKey};
|
||||
use layout_api::{
|
||||
PendingRestyle, ReflowGoal, RestyleReason, TrustedNodeAddress, node_id_from_scroll_id,
|
||||
};
|
||||
|
@ -2547,7 +2547,7 @@ impl Document {
|
|||
|
||||
let keyevent = KeyboardEvent::new(
|
||||
&self.window,
|
||||
DOMString::from(keyboard_event.event.state.to_string()),
|
||||
DOMString::from(keyboard_event.event.state.event_type()),
|
||||
true,
|
||||
true,
|
||||
Some(&self.window),
|
||||
|
@ -2607,7 +2607,8 @@ 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
|
||||
if (keyboard_event.event.key == Key::Enter || keyboard_event.event.code == Code::Space) &&
|
||||
if (keyboard_event.event.key == Key::Named(NamedKey::Enter) ||
|
||||
keyboard_event.event.code == Code::Space) &&
|
||||
keyboard_event.event.state == KeyState::Up
|
||||
{
|
||||
if let Some(elem) = target.downcast::<Element>() {
|
||||
|
@ -2647,7 +2648,7 @@ impl Document {
|
|||
|
||||
let compositionevent = CompositionEvent::new(
|
||||
&self.window,
|
||||
DOMString::from(composition_event.state.to_string()),
|
||||
DOMString::from(composition_event.state.event_type()),
|
||||
true,
|
||||
cancelable,
|
||||
Some(&self.window),
|
||||
|
@ -4045,7 +4046,7 @@ impl Document {
|
|||
}
|
||||
|
||||
fn is_character_value_key(key: &Key) -> bool {
|
||||
matches!(key, Key::Character(_) | Key::Enter)
|
||||
matches!(key, Key::Character(_) | Key::Named(NamedKey::Enter))
|
||||
}
|
||||
|
||||
#[derive(MallocSizeOf, PartialEq)]
|
||||
|
|
|
@ -6,7 +6,7 @@ use std::cell::Cell;
|
|||
|
||||
use dom_struct::dom_struct;
|
||||
use js::rust::HandleObject;
|
||||
use keyboard_types::{Key, Modifiers};
|
||||
use keyboard_types::{Key, Modifiers, NamedKey};
|
||||
|
||||
use crate::dom::bindings::cell::DomRefCell;
|
||||
use crate::dom::bindings::codegen::Bindings::KeyboardEventBinding;
|
||||
|
@ -43,7 +43,7 @@ impl KeyboardEvent {
|
|||
KeyboardEvent {
|
||||
uievent: UIEvent::new_inherited(),
|
||||
key: DomRefCell::new(DOMString::new()),
|
||||
typed_key: DomRefCell::new(Key::Unidentified),
|
||||
typed_key: DomRefCell::new(Key::Named(NamedKey::Unidentified)),
|
||||
code: DomRefCell::new(DOMString::new()),
|
||||
location: Cell::new(0),
|
||||
modifiers: Cell::new(Modifiers::empty()),
|
||||
|
@ -180,7 +180,7 @@ impl KeyboardEventMethods<crate::DomTypeHolder> for KeyboardEvent {
|
|||
init.parent.parent.parent.cancelable,
|
||||
init.parent.parent.view.as_deref(),
|
||||
init.parent.parent.detail,
|
||||
Key::Unidentified,
|
||||
Key::Named(NamedKey::Unidentified),
|
||||
init.code.clone(),
|
||||
init.location,
|
||||
init.repeat,
|
||||
|
|
|
@ -9,7 +9,7 @@ use std::cmp::min;
|
|||
use std::default::Default;
|
||||
use std::ops::{Add, AddAssign, Range};
|
||||
|
||||
use keyboard_types::{Key, KeyState, Modifiers, ShortcutMatcher};
|
||||
use keyboard_types::{Key, KeyState, Modifiers, NamedKey, ShortcutMatcher};
|
||||
use unicode_segmentation::UnicodeSegmentation;
|
||||
|
||||
use crate::clipboard_provider::{ClipboardProvider, EmbedderClipboardProvider};
|
||||
|
@ -921,75 +921,102 @@ impl<T: ClipboardProvider> TextInput<T> {
|
|||
}
|
||||
KeyReaction::DispatchInput
|
||||
})
|
||||
.shortcut(Modifiers::empty(), Key::Delete, || {
|
||||
.shortcut(Modifiers::empty(), Key::Named(NamedKey::Delete), || {
|
||||
if self.delete_char(Direction::Forward) {
|
||||
KeyReaction::DispatchInput
|
||||
} else {
|
||||
KeyReaction::Nothing
|
||||
}
|
||||
})
|
||||
.shortcut(Modifiers::empty(), Key::Backspace, || {
|
||||
.shortcut(Modifiers::empty(), Key::Named(NamedKey::Backspace), || {
|
||||
if self.delete_char(Direction::Backward) {
|
||||
KeyReaction::DispatchInput
|
||||
} else {
|
||||
KeyReaction::Nothing
|
||||
}
|
||||
})
|
||||
.optional_shortcut(macos, Modifiers::META, Key::ArrowLeft, || {
|
||||
self.adjust_horizontal_to_line_end(Direction::Backward, maybe_select);
|
||||
KeyReaction::RedrawSelection
|
||||
})
|
||||
.optional_shortcut(macos, Modifiers::META, Key::ArrowRight, || {
|
||||
self.adjust_horizontal_to_line_end(Direction::Forward, maybe_select);
|
||||
KeyReaction::RedrawSelection
|
||||
})
|
||||
.optional_shortcut(macos, Modifiers::META, Key::ArrowUp, || {
|
||||
self.adjust_horizontal_to_limit(Direction::Backward, maybe_select);
|
||||
KeyReaction::RedrawSelection
|
||||
})
|
||||
.optional_shortcut(macos, Modifiers::META, Key::ArrowDown, || {
|
||||
self.adjust_horizontal_to_limit(Direction::Forward, maybe_select);
|
||||
KeyReaction::RedrawSelection
|
||||
})
|
||||
.shortcut(Modifiers::ALT, Key::ArrowLeft, || {
|
||||
.optional_shortcut(
|
||||
macos,
|
||||
Modifiers::META,
|
||||
Key::Named(NamedKey::ArrowLeft),
|
||||
|| {
|
||||
self.adjust_horizontal_to_line_end(Direction::Backward, maybe_select);
|
||||
KeyReaction::RedrawSelection
|
||||
},
|
||||
)
|
||||
.optional_shortcut(
|
||||
macos,
|
||||
Modifiers::META,
|
||||
Key::Named(NamedKey::ArrowRight),
|
||||
|| {
|
||||
self.adjust_horizontal_to_line_end(Direction::Forward, maybe_select);
|
||||
KeyReaction::RedrawSelection
|
||||
},
|
||||
)
|
||||
.optional_shortcut(
|
||||
macos,
|
||||
Modifiers::META,
|
||||
Key::Named(NamedKey::ArrowUp),
|
||||
|| {
|
||||
self.adjust_horizontal_to_limit(Direction::Backward, maybe_select);
|
||||
KeyReaction::RedrawSelection
|
||||
},
|
||||
)
|
||||
.optional_shortcut(
|
||||
macos,
|
||||
Modifiers::META,
|
||||
Key::Named(NamedKey::ArrowDown),
|
||||
|| {
|
||||
self.adjust_horizontal_to_limit(Direction::Forward, maybe_select);
|
||||
KeyReaction::RedrawSelection
|
||||
},
|
||||
)
|
||||
.shortcut(Modifiers::ALT, Key::Named(NamedKey::ArrowLeft), || {
|
||||
self.adjust_horizontal_by_word(Direction::Backward, maybe_select);
|
||||
KeyReaction::RedrawSelection
|
||||
})
|
||||
.shortcut(Modifiers::ALT, Key::ArrowRight, || {
|
||||
.shortcut(Modifiers::ALT, Key::Named(NamedKey::ArrowRight), || {
|
||||
self.adjust_horizontal_by_word(Direction::Forward, maybe_select);
|
||||
KeyReaction::RedrawSelection
|
||||
})
|
||||
.shortcut(Modifiers::empty(), Key::ArrowLeft, || {
|
||||
.shortcut(Modifiers::empty(), Key::Named(NamedKey::ArrowLeft), || {
|
||||
self.adjust_horizontal_by_one(Direction::Backward, maybe_select);
|
||||
KeyReaction::RedrawSelection
|
||||
})
|
||||
.shortcut(Modifiers::empty(), Key::ArrowRight, || {
|
||||
.shortcut(Modifiers::empty(), Key::Named(NamedKey::ArrowRight), || {
|
||||
self.adjust_horizontal_by_one(Direction::Forward, maybe_select);
|
||||
KeyReaction::RedrawSelection
|
||||
})
|
||||
.shortcut(Modifiers::empty(), Key::ArrowUp, || {
|
||||
.shortcut(Modifiers::empty(), Key::Named(NamedKey::ArrowUp), || {
|
||||
self.adjust_vertical(-1, maybe_select);
|
||||
KeyReaction::RedrawSelection
|
||||
})
|
||||
.shortcut(Modifiers::empty(), Key::ArrowDown, || {
|
||||
.shortcut(Modifiers::empty(), Key::Named(NamedKey::ArrowDown), || {
|
||||
self.adjust_vertical(1, maybe_select);
|
||||
KeyReaction::RedrawSelection
|
||||
})
|
||||
.shortcut(Modifiers::empty(), Key::Enter, || self.handle_return())
|
||||
.optional_shortcut(macos, Modifiers::empty(), Key::Home, || {
|
||||
self.edit_point.index = UTF8Bytes::zero();
|
||||
KeyReaction::RedrawSelection
|
||||
.shortcut(Modifiers::empty(), Key::Named(NamedKey::Enter), || {
|
||||
self.handle_return()
|
||||
})
|
||||
.optional_shortcut(macos, Modifiers::empty(), Key::End, || {
|
||||
.optional_shortcut(
|
||||
macos,
|
||||
Modifiers::empty(),
|
||||
Key::Named(NamedKey::Home),
|
||||
|| {
|
||||
self.edit_point.index = UTF8Bytes::zero();
|
||||
KeyReaction::RedrawSelection
|
||||
},
|
||||
)
|
||||
.optional_shortcut(macos, Modifiers::empty(), Key::Named(NamedKey::End), || {
|
||||
self.edit_point.index = self.current_line_length();
|
||||
self.assert_ok_selection();
|
||||
KeyReaction::RedrawSelection
|
||||
})
|
||||
.shortcut(Modifiers::empty(), Key::PageUp, || {
|
||||
.shortcut(Modifiers::empty(), Key::Named(NamedKey::PageUp), || {
|
||||
self.adjust_vertical(-28, maybe_select);
|
||||
KeyReaction::RedrawSelection
|
||||
})
|
||||
.shortcut(Modifiers::empty(), Key::PageDown, || {
|
||||
.shortcut(Modifiers::empty(), Key::Named(NamedKey::PageDown), || {
|
||||
self.adjust_vertical(28, maybe_select);
|
||||
KeyReaction::RedrawSelection
|
||||
})
|
||||
|
@ -998,7 +1025,7 @@ impl<T: ClipboardProvider> TextInput<T> {
|
|||
self.insert_string(c.as_str());
|
||||
return KeyReaction::DispatchInput;
|
||||
}
|
||||
if matches!(key, Key::Process) {
|
||||
if matches!(key, Key::Named(NamedKey::Process)) {
|
||||
return KeyReaction::DispatchInput;
|
||||
}
|
||||
KeyReaction::Nothing
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue