diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/components/script/dom/document.rs | 2 | ||||
-rw-r--r-- | src/components/script/dom/window.rs | 52 | ||||
-rw-r--r-- | src/components/script/script_task.rs | 2 |
3 files changed, 35 insertions, 21 deletions
diff --git a/src/components/script/dom/document.rs b/src/components/script/dom/document.rs index 3005d23c5f9..086ac778fdd 100644 --- a/src/components/script/dom/document.rs +++ b/src/components/script/dom/document.rs @@ -33,7 +33,7 @@ use dom::nodelist::NodeList; use dom::text::Text; use dom::processinginstruction::ProcessingInstruction; use dom::uievent::UIEvent; -use dom::window::{Window, WindowMethods}; +use dom::window::{Window, WindowMethods, WindowHelpers}; use dom::location::Location; use html::hubbub_html_parser::build_element_from_tag; use hubbub::hubbub::{QuirksMode, NoQuirks, LimitedQuirks, FullQuirks}; diff --git a/src/components/script/dom/window.rs b/src/components/script/dom/window.rs index 7e366492719..8fde7bd8e86 100644 --- a/src/components/script/dom/window.rs +++ b/src/components/script/dom/window.rs @@ -288,7 +288,37 @@ impl Reflectable for Window { } } -impl Window { +pub trait WindowHelpers { + fn damage_and_reflow(&self, damage: DocumentDamageLevel); + fn wait_until_safe_to_modify_dom(&self); + fn init_browser_context(&mut self, doc: &JSRef<Document>); +} + +trait PrivateWindowHelpers { + fn set_timeout_or_interval(&mut self, callback: JSVal, timeout: i32, is_interval: bool) -> i32; +} + +impl<'a> WindowHelpers for JSRef<'a, Window> { + 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 + // doing a query reflow. + self.page().damage(damage); + self.page().reflow(ReflowForDisplay, self.script_chan.clone(), *self.compositor); + } + + 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(&mut self, doc: &JSRef<Document>) { + self.browser_context = Some(BrowserContext::new(doc)); + } +} + +impl<'a> PrivateWindowHelpers for JSRef<'a, Window> { fn set_timeout_or_interval(&mut self, callback: JSVal, timeout: i32, is_interval: bool) -> i32 { let timeout = cmp::max(0, timeout) as u64; let handle = self.next_timer_handle; @@ -346,25 +376,9 @@ impl Window { self.active_timers.insert(timer_id, timer); handle } +} - 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 - // doing a query reflow. - self.page().damage(damage); - self.page().reflow(ReflowForDisplay, self.script_chan.clone(), *self.compositor); - } - - pub 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(); - } - - pub fn init_browser_context(&mut self, doc: &JSRef<Document>) { - self.browser_context = Some(BrowserContext::new(doc)); - } - +impl Window { pub fn new(cx: *JSContext, page: Rc<Page>, script_chan: ScriptChan, diff --git a/src/components/script/script_task.rs b/src/components/script/script_task.rs index 4bd981a5291..f84947cad58 100644 --- a/src/components/script/script_task.rs +++ b/src/components/script/script_task.rs @@ -20,7 +20,7 @@ use dom::uievent::UIEvent; use dom::eventtarget::{EventTarget, EventTargetHelpers}; use dom::node; use dom::node::{Node, NodeHelpers}; -use dom::window::{TimerId, Window}; +use dom::window::{TimerId, Window, WindowHelpers}; use html::hubbub_html_parser::HtmlParserResult; use html::hubbub_html_parser::{HtmlDiscoveredStyle, HtmlDiscoveredScript}; use html::hubbub_html_parser; |