mirror of
https://github.com/servo/servo.git
synced 2025-06-06 16:45:39 +00:00
Make reflect_dom_object take a &GlobalScope
This commit is contained in:
parent
093b189b48
commit
fcb59d3057
132 changed files with 488 additions and 407 deletions
|
@ -4,19 +4,25 @@
|
|||
|
||||
//! The `Reflector` struct.
|
||||
|
||||
use dom::bindings::global::{GlobalRef, GlobalRoot, global_root_from_reflector};
|
||||
use dom::bindings::conversions::DerivedFrom;
|
||||
use dom::bindings::global::{GlobalRoot, global_root_from_reflector};
|
||||
use dom::bindings::js::Root;
|
||||
use dom::globalscope::GlobalScope;
|
||||
use js::jsapi::{HandleObject, JSContext, JSObject};
|
||||
use std::cell::UnsafeCell;
|
||||
use std::ptr;
|
||||
|
||||
/// Create the reflector for a new DOM object and yield ownership to the
|
||||
/// reflector.
|
||||
pub fn reflect_dom_object<T: Reflectable>(obj: Box<T>,
|
||||
global: GlobalRef,
|
||||
wrap_fn: fn(*mut JSContext, GlobalRef, Box<T>) -> Root<T>)
|
||||
-> Root<T> {
|
||||
wrap_fn(global.get_cx(), global, obj)
|
||||
pub fn reflect_dom_object<T, U>(
|
||||
obj: Box<T>,
|
||||
global: &U,
|
||||
wrap_fn: fn(*mut JSContext, &GlobalScope, Box<T>) -> Root<T>)
|
||||
-> Root<T>
|
||||
where T: Reflectable, U: DerivedFrom<GlobalScope>
|
||||
{
|
||||
let global_scope = global.upcast();
|
||||
wrap_fn(global_scope.get_cx(), global_scope, obj)
|
||||
}
|
||||
|
||||
/// A struct to store a reference to the reflector of a DOM object.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue