mirror of
https://github.com/servo/servo
synced 2026-04-27 18:07:52 +02:00
Forward WebDriver CompositionEvent
Dispatch composition events in JS. Insert characters from composition events to text input. CompositionEvents currently can only be created by WebDriver and not by embedders.
This commit is contained in:
@@ -6,6 +6,7 @@
|
||||
|
||||
use crate::clipboard_provider::ClipboardProvider;
|
||||
use crate::dom::bindings::str::DOMString;
|
||||
use crate::dom::compositionevent::CompositionEvent;
|
||||
use crate::dom::keyboardevent::KeyboardEvent;
|
||||
use keyboard_types::{Key, KeyState, Modifiers, ShortcutMatcher};
|
||||
use std::borrow::ToOwned;
|
||||
@@ -831,6 +832,11 @@ impl<T: ClipboardProvider> TextInput<T> {
|
||||
.unwrap()
|
||||
}
|
||||
|
||||
pub fn handle_compositionend(&mut self, event: &CompositionEvent) -> KeyReaction {
|
||||
self.insert_string(event.data());
|
||||
KeyReaction::DispatchInput
|
||||
}
|
||||
|
||||
/// Whether the content is empty.
|
||||
pub fn is_empty(&self) -> bool {
|
||||
self.lines.len() <= 1 && self.lines.get(0).map_or(true, |line| line.is_empty())
|
||||
|
||||
Reference in New Issue
Block a user