Auto merge of #25159 - garasubo:fix-composition-event, r=jdm

implement composition event creation in Document.createEvent

Solved the problem mentioned in https://github.com/servo/servo/issues/24724#issuecomment-562326328

Add logic to create composition event for Document.createEvent. This resolved some WPT test failure, so updated the metadata as well

Ref: https://developer.mozilla.org/en-US/docs/Web/API/Document/createEvent

---
<!-- 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. -->
This commit is contained in:
bors-servo 2019-12-12 01:33:04 -05:00 committed by GitHub
commit 82fd8d1daf
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 18 additions and 42 deletions

View file

@ -21,6 +21,21 @@ pub struct CompositionEvent {
}
impl CompositionEvent {
pub fn new_inherited() -> CompositionEvent {
CompositionEvent {
uievent: UIEvent::new_inherited(),
data: DOMString::new(),
}
}
pub fn new_uninitialized(window: &Window) -> DomRoot<CompositionEvent> {
reflect_dom_object(
Box::new(CompositionEvent::new_inherited()),
window,
CompositionEventBinding::Wrap,
)
}
pub fn new(
window: &Window,
type_: DOMString,

View file

@ -3811,6 +3811,9 @@ impl DocumentMethods for Document {
"beforeunloadevent" => Ok(DomRoot::upcast(BeforeUnloadEvent::new_uninitialized(
&self.window,
))),
"compositionevent" | "textevent" => Ok(DomRoot::upcast(
CompositionEvent::new_uninitialized(&self.window),
)),
"closeevent" => Ok(DomRoot::upcast(CloseEvent::new_uninitialized(
self.window.upcast(),
))),