diff options
author | Cameron Zwarich <zwarich@mozilla.com> | 2014-09-19 19:57:50 -0700 |
---|---|---|
committer | Cameron Zwarich <zwarich@mozilla.com> | 2014-09-20 11:54:11 -0700 |
commit | d768ee77adab5e5f53b7fb978c07ddbb798e8954 (patch) | |
tree | ec960fb625e8f3c1717e79e8aa27ccb93336c637 /components/script/dom/window.rs | |
parent | 2c8d51a37c84fb5de531d00c45de9c0020930b11 (diff) | |
download | servo-d768ee77adab5e5f53b7fb978c07ddbb798e8954.tar.gz servo-d768ee77adab5e5f53b7fb978c07ddbb798e8954.zip |
Convert various helper traits from &JSRef to JSRef
I converted them all with a few exceptions:
- Methods that were used by trait objects, since trait objects don't
work with `self` methods.
- Methods that take an &'b JSRef<'a, T> and return an &'b. In reality,
many (all?) could return an &'a instead, but this isn't allowed by the
Deref trait.
- Methods that internally rely on the same issue with Deref.
- I left out the traits involved in layout entirely, even though not all
of their methods suffer from one of the above problems.
There will probably be solutions to all of these problems in the future.
Diffstat (limited to 'components/script/dom/window.rs')
-rw-r--r-- | components/script/dom/window.rs | 32 |
1 files changed, 16 insertions, 16 deletions
diff --git a/components/script/dom/window.rs b/components/script/dom/window.rs index fd147aaefdf..631dfbec858 100644 --- a/components/script/dom/window.rs +++ b/components/script/dom/window.rs @@ -364,21 +364,21 @@ impl Reflectable for Window { } pub trait WindowHelpers { - fn damage_and_reflow(&self, damage: DocumentDamageLevel); - fn flush_layout(&self, goal: ReflowGoal); - fn wait_until_safe_to_modify_dom(&self); - fn init_browser_context(&self, doc: JSRef<Document>); - fn load_url(&self, href: DOMString); - fn handle_fire_timer(&self, timer_id: TimerId, cx: *mut JSContext); - fn evaluate_js_with_result(&self, code: &str) -> JSVal; + fn damage_and_reflow(self, damage: DocumentDamageLevel); + fn flush_layout(self, goal: ReflowGoal); + fn wait_until_safe_to_modify_dom(self); + fn init_browser_context(self, doc: JSRef<Document>); + fn load_url(self, href: DOMString); + fn handle_fire_timer(self, timer_id: TimerId, cx: *mut JSContext); + fn evaluate_js_with_result(self, code: &str) -> JSVal; } trait PrivateWindowHelpers { - fn set_timeout_or_interval(&self, callback: JSVal, timeout: i32, is_interval: bool) -> i32; + fn set_timeout_or_interval(self, callback: JSVal, timeout: i32, is_interval: bool) -> i32; } impl<'a> WindowHelpers for JSRef<'a, Window> { - fn evaluate_js_with_result(&self, code: &str) -> JSVal { + fn evaluate_js_with_result(self, code: &str) -> JSVal { let global = self.reflector().get_jsobject(); let code: Vec<u16> = code.as_slice().utf16_units().collect(); let mut rval = UndefinedValue(); @@ -397,27 +397,27 @@ impl<'a> WindowHelpers for JSRef<'a, Window> { }) } - fn damage_and_reflow(&self, damage: DocumentDamageLevel) { + fn damage_and_reflow(self, damage: DocumentDamageLevel) { self.page().damage(damage); self.page().avoided_reflows.set(self.page().avoided_reflows.get() + 1); } - fn flush_layout(&self, goal: ReflowGoal) { + fn flush_layout(self, goal: ReflowGoal) { self.page().flush_layout(goal); } - fn wait_until_safe_to_modify_dom(&self) { + fn wait_until_safe_to_modify_dom(self) { // FIXME: This disables concurrent layout while we are modifying the DOM, since // our current architecture is entirely unsafe in the presence of races. self.page().join_layout(); } - fn init_browser_context(&self, doc: JSRef<Document>) { + fn init_browser_context(self, doc: JSRef<Document>) { *self.browser_context.deref().borrow_mut() = Some(BrowserContext::new(doc)); } /// Commence a new URL load which will either replace this window or scroll to a fragment. - fn load_url(&self, href: DOMString) { + fn load_url(self, href: DOMString) { let base_url = self.page().get_url(); debug!("current page url is {:?}", base_url); let url = UrlParser::new().base_url(&base_url).parse(href.as_slice()); @@ -431,7 +431,7 @@ impl<'a> WindowHelpers for JSRef<'a, Window> { } } - fn handle_fire_timer(&self, timer_id: TimerId, cx: *mut JSContext) { + fn handle_fire_timer(self, timer_id: TimerId, cx: *mut JSContext) { let this_value = self.reflector().get_jsobject(); let data = match self.active_timers.deref().borrow().find(&timer_id) { @@ -455,7 +455,7 @@ impl<'a> WindowHelpers for JSRef<'a, Window> { } impl<'a> PrivateWindowHelpers for JSRef<'a, Window> { - fn set_timeout_or_interval(&self, callback: JSVal, timeout: i32, is_interval: bool) -> i32 { + fn set_timeout_or_interval(self, callback: JSVal, timeout: i32, is_interval: bool) -> i32 { let timeout = cmp::max(0, timeout) as u64; let handle = self.next_timer_handle.deref().get(); self.next_timer_handle.deref().set(handle + 1); |