Format script component

This commit is contained in:
chansuke 2018-09-18 23:24:15 +09:00 committed by Josh Matthews
parent 2ca7a13473
commit c37a345dc9
357 changed files with 25485 additions and 18076 deletions

View file

@ -16,7 +16,8 @@ use std::mem;
pub trait Castable: IDLInterface + DomObject + Sized {
/// Check whether a DOM object implements one of its deriving interfaces.
fn is<T>(&self) -> bool
where T: DerivedFrom<Self>
where
T: DerivedFrom<Self>,
{
let class = unsafe { get_dom_class(self.reflector().get_jsobject().get()).unwrap() };
T::derives(class)
@ -24,15 +25,17 @@ pub trait Castable: IDLInterface + DomObject + Sized {
/// Cast a DOM object upwards to one of the interfaces it derives from.
fn upcast<T>(&self) -> &T
where T: Castable,
Self: DerivedFrom<T>
where
T: Castable,
Self: DerivedFrom<T>,
{
unsafe { mem::transmute(self) }
}
/// Cast a DOM object downwards to one of the interfaces it might implement.
fn downcast<T>(&self) -> Option<&T>
where T: DerivedFrom<Self>
where
T: DerivedFrom<Self>,
{
if self.is::<T>() {
Some(unsafe { mem::transmute(self) })