mirror of
https://github.com/servo/servo.git
synced 2025-06-06 16:45:39 +00:00
Rewrite From/TryFrom conversions on generated types to avoid future orphan rule violations (#34554)
* script: Add traits to allow converting between types that are not defined in the script crate. Signed-off-by: Josh Matthews <josh@joshmatthews.net> * script: Rewrite all From/TryFrom implementations on generated WebIDL types to use new Convert/TryConvert traits. Signed-off-by: Josh Matthews <josh@joshmatthews.net> --------- Signed-off-by: Josh Matthews <josh@joshmatthews.net>
This commit is contained in:
parent
e10e989abb
commit
e0cbab2fbb
40 changed files with 439 additions and 380 deletions
|
@ -9,6 +9,7 @@ use embedder_traits::{MediaMetadata as EmbedderMediaMetadata, MediaSessionEvent}
|
|||
use script_traits::{MediaSessionActionType, ScriptMsg};
|
||||
|
||||
use super::bindings::trace::HashMapTracedValues;
|
||||
use crate::conversions::Convert;
|
||||
use crate::dom::bindings::callback::ExceptionHandling;
|
||||
use crate::dom::bindings::cell::DomRefCell;
|
||||
use crate::dom::bindings::codegen::Bindings::HTMLMediaElementBinding::HTMLMediaElementMethods;
|
||||
|
@ -188,8 +189,8 @@ impl MediaSessionMethods<crate::DomTypeHolder> for MediaSession {
|
|||
Some(handler) => self
|
||||
.action_handlers
|
||||
.borrow_mut()
|
||||
.insert(action.into(), handler.clone()),
|
||||
None => self.action_handlers.borrow_mut().remove(&action.into()),
|
||||
.insert(action.convert(), handler.clone()),
|
||||
None => self.action_handlers.borrow_mut().remove(&action.convert()),
|
||||
};
|
||||
}
|
||||
|
||||
|
@ -249,9 +250,9 @@ impl MediaSessionMethods<crate::DomTypeHolder> for MediaSession {
|
|||
}
|
||||
}
|
||||
|
||||
impl From<MediaSessionAction> for MediaSessionActionType {
|
||||
fn from(action: MediaSessionAction) -> MediaSessionActionType {
|
||||
match action {
|
||||
impl Convert<MediaSessionActionType> for MediaSessionAction {
|
||||
fn convert(self) -> MediaSessionActionType {
|
||||
match self {
|
||||
MediaSessionAction::Play => MediaSessionActionType::Play,
|
||||
MediaSessionAction::Pause => MediaSessionActionType::Pause,
|
||||
MediaSessionAction::Seekbackward => MediaSessionActionType::SeekBackward,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue