Implement Reflectable for GlobalRef.

This commit is contained in:
Josh Matthews 2016-09-07 10:40:43 +02:00 committed by Ms2ger
parent 8653450b6e
commit 61fcc72d35
2 changed files with 10 additions and 8 deletions

View file

@ -16,6 +16,7 @@ use dom::bindings::conversions::{ConversionResult, FromJSValConvertible, jsstrin
use dom::bindings::global::GlobalRef;
use dom::bindings::inheritance::Castable;
use dom::bindings::js::Root;
use dom::bindings::reflector::Reflectable;
use dom::bindings::str::DOMString;
use dom::browsingcontext::BrowsingContext;
use dom::element::Element;

View file

@ -271,14 +271,6 @@ impl<'a> GlobalRef<'a> {
}
}
/// Returns the receiver's reflector.
pub fn reflector(&self) -> &Reflector {
match *self {
GlobalRef::Window(ref window) => window.reflector(),
GlobalRef::Worker(ref worker) => worker.reflector(),
}
}
/// Returns a wrapper for runnables to ensure they are cancelled if the global
/// is being destroyed.
pub fn get_runnable_wrapper(&self) -> RunnableWrapper {
@ -297,6 +289,15 @@ impl<'a> GlobalRef<'a> {
}
}
impl<'a> Reflectable for GlobalRef<'a> {
fn reflector(&self) -> &Reflector {
match *self {
GlobalRef::Window(ref window) => window.reflector(),
GlobalRef::Worker(ref worker) => worker.reflector(),
}
}
}
impl GlobalRoot {
/// Obtain a safe reference to the global object that cannot outlive the
/// lifetime of this root.