diff options
Diffstat (limited to 'src/components/script/dom/window.rs')
-rw-r--r-- | src/components/script/dom/window.rs | 40 |
1 files changed, 19 insertions, 21 deletions
diff --git a/src/components/script/dom/window.rs b/src/components/script/dom/window.rs index 04a117650d1..54575882ed3 100644 --- a/src/components/script/dom/window.rs +++ b/src/components/script/dom/window.rs @@ -6,6 +6,7 @@ use dom::bindings::codegen::WindowBinding; use dom::bindings::js::JS; use dom::bindings::trace::Untraceable; use dom::bindings::utils::{Reflectable, Reflector}; +use dom::browsercontext::BrowserContext; use dom::document::Document; use dom::element::Element; use dom::eventtarget::{EventTarget, WindowTypeId}; @@ -20,9 +21,8 @@ use servo_net::image_cache_task::ImageCacheTask; use servo_util::str::DOMString; use servo_util::task::{spawn_named}; -use js::jsapi::{JSContext, JS_DefineProperty, JS_PropertyStub, JS_StrictPropertyStub}; -use js::jsval::{NullValue, ObjectValue, JSVal}; -use js::JSPROP_ENUMERATE; +use js::jsapi::JSContext; +use js::jsval::{NullValue, JSVal}; use collections::hashmap::HashMap; use std::cmp; @@ -87,6 +87,7 @@ pub struct Window { next_timer_handle: i32, compositor: Untraceable<~ScriptListener>, timer_chan: Untraceable<Sender<TimerControlMsg>>, + browser_context: Option<BrowserContext>, page: Rc<Page>, } @@ -290,6 +291,14 @@ impl Window { self.ClearTimeout(handle); } + pub fn Window(&self, abstract_self: &JS<Window>) -> JS<Window> { + abstract_self.clone() + } + + pub fn Self(&self, abstract_self: &JS<Window>) -> JS<Window> { + self.Window(abstract_self) + } + pub fn damage_and_reflow(&self, damage: DocumentDamageLevel) { // FIXME This should probably be ReflowForQuery, not Display. All queries currently // currently rely on the display list, which means we can't destroy it by @@ -304,6 +313,10 @@ impl Window { self.page().join_layout(); } + pub fn init_browser_context(&mut self, doc: &JS<Document>) { + self.browser_context = Some(BrowserContext::new(doc)); + } + pub fn new(cx: *JSContext, page: Rc<Page>, script_chan: ScriptChan, @@ -335,25 +348,10 @@ impl Window { navigator: None, image_cache_task: image_cache_task, active_timers: ~HashMap::new(), - next_timer_handle: 0 + next_timer_handle: 0, + browser_context: None, }; - let global = WindowBinding::Wrap(cx, win); - let fn_names = ["window", "self"]; - for str in fn_names.iter() { - (*str).to_c_str().with_ref(|name| { - let object = global.reflector().get_jsobject(); - assert!(object.is_not_null()); - unsafe { - JS_DefineProperty(cx, object, name, - ObjectValue(&*object), - Some(JS_PropertyStub), - Some(JS_StrictPropertyStub), - JSPROP_ENUMERATE); - } - }) - - } - global + WindowBinding::Wrap(cx, win) } } |