mirror of
https://github.com/servo/servo.git
synced 2025-07-22 23:03:42 +01:00
Auto merge of #22224 - pyfisch:composition-webdriver, r=nox
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. <!-- Please describe your changes on the following line: --> --- <!-- 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 #__ (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. --> <!-- 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/22224) <!-- Reviewable:end -->
This commit is contained in:
commit
98527ddb8c
12 changed files with 118 additions and 26 deletions
|
@ -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())
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue