mirror of
https://github.com/servo/servo.git
synced 2025-08-03 12:40:06 +01:00
Format script component
This commit is contained in:
parent
2ca7a13473
commit
c37a345dc9
357 changed files with 25485 additions and 18076 deletions
|
@ -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) })
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue