auto merge of #2425 : saneyuki/servo/window_helper, r=jdm

Fix #2418
This commit is contained in:
bors-servo 2014-05-14 00:55:17 -04:00
commit 049fa56fff
3 changed files with 35 additions and 21 deletions

View file

@ -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};

View file

@ -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,

View file

@ -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;