mirror of
https://github.com/servo/servo.git
synced 2025-06-25 01:24:37 +01:00
commit
049fa56fff
3 changed files with 35 additions and 21 deletions
|
@ -33,7 +33,7 @@ use dom::nodelist::NodeList;
|
||||||
use dom::text::Text;
|
use dom::text::Text;
|
||||||
use dom::processinginstruction::ProcessingInstruction;
|
use dom::processinginstruction::ProcessingInstruction;
|
||||||
use dom::uievent::UIEvent;
|
use dom::uievent::UIEvent;
|
||||||
use dom::window::{Window, WindowMethods};
|
use dom::window::{Window, WindowMethods, WindowHelpers};
|
||||||
use dom::location::Location;
|
use dom::location::Location;
|
||||||
use html::hubbub_html_parser::build_element_from_tag;
|
use html::hubbub_html_parser::build_element_from_tag;
|
||||||
use hubbub::hubbub::{QuirksMode, NoQuirks, LimitedQuirks, FullQuirks};
|
use hubbub::hubbub::{QuirksMode, NoQuirks, LimitedQuirks, FullQuirks};
|
||||||
|
|
|
@ -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 {
|
fn set_timeout_or_interval(&mut self, callback: JSVal, timeout: i32, is_interval: bool) -> i32 {
|
||||||
let timeout = cmp::max(0, timeout) as u64;
|
let timeout = cmp::max(0, timeout) as u64;
|
||||||
let handle = self.next_timer_handle;
|
let handle = self.next_timer_handle;
|
||||||
|
@ -346,25 +376,9 @@ impl Window {
|
||||||
self.active_timers.insert(timer_id, timer);
|
self.active_timers.insert(timer_id, timer);
|
||||||
handle
|
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,
|
pub fn new(cx: *JSContext,
|
||||||
page: Rc<Page>,
|
page: Rc<Page>,
|
||||||
script_chan: ScriptChan,
|
script_chan: ScriptChan,
|
||||||
|
|
|
@ -20,7 +20,7 @@ use dom::uievent::UIEvent;
|
||||||
use dom::eventtarget::{EventTarget, EventTargetHelpers};
|
use dom::eventtarget::{EventTarget, EventTargetHelpers};
|
||||||
use dom::node;
|
use dom::node;
|
||||||
use dom::node::{Node, NodeHelpers};
|
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::HtmlParserResult;
|
||||||
use html::hubbub_html_parser::{HtmlDiscoveredStyle, HtmlDiscoveredScript};
|
use html::hubbub_html_parser::{HtmlDiscoveredStyle, HtmlDiscoveredScript};
|
||||||
use html::hubbub_html_parser;
|
use html::hubbub_html_parser;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue