Skip to content

Commit

Permalink
Implement Reflectable for GlobalRef.
Browse files Browse the repository at this point in the history
  • Loading branch information
jdm authored and Ms2ger committed Sep 7, 2016
1 parent 8653450 commit 61fcc72
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 8 deletions.
1 change: 1 addition & 0 deletions components/script/devtools.rs
Expand Up @@ -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;
Expand Down
17 changes: 9 additions & 8 deletions components/script/dom/bindings/global.rs
Expand Up @@ -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 {
Expand All @@ -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.
Expand Down

0 comments on commit 61fcc72

Please sign in to comment.