mirror of
https://github.com/servo/servo.git
synced 2025-08-02 20:20:14 +01:00
Remove Traceable/Untraceable from page.rs
This commit is contained in:
parent
22567762a0
commit
707a2870fa
9 changed files with 95 additions and 76 deletions
|
@ -67,7 +67,7 @@ impl<'a> GlobalRef<'a> {
|
||||||
|
|
||||||
pub fn resource_task(&self) -> ResourceTask {
|
pub fn resource_task(&self) -> ResourceTask {
|
||||||
match *self {
|
match *self {
|
||||||
Window(ref window) => window.page().resource_task.deref().clone(),
|
Window(ref window) => window.page().resource_task.clone(),
|
||||||
Worker(ref worker) => worker.resource_task().clone(),
|
Worker(ref worker) => worker.resource_task().clone(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -50,6 +50,8 @@ use http::headers::request::HeaderCollection as RequestHeaderCollection;
|
||||||
use http::method::Method;
|
use http::method::Method;
|
||||||
use std::io::timer::Timer;
|
use std::io::timer::Timer;
|
||||||
use servo_msg::compositor_msg::ScriptListener;
|
use servo_msg::compositor_msg::ScriptListener;
|
||||||
|
use servo_msg::constellation_msg::ConstellationChan;
|
||||||
|
use layout_interface::{LayoutRPC, LayoutChan};
|
||||||
|
|
||||||
impl<T: Reflectable> JSTraceable for JS<T> {
|
impl<T: Reflectable> JSTraceable for JS<T> {
|
||||||
fn trace(&self, trc: *mut JSTracer) {
|
fn trace(&self, trc: *mut JSTracer) {
|
||||||
|
@ -165,7 +167,7 @@ impl<T: JSTraceable> JSTraceable for RefCell<T> {
|
||||||
|
|
||||||
impl<T: JSTraceable> JSTraceable for Rc<T> {
|
impl<T: JSTraceable> JSTraceable for Rc<T> {
|
||||||
fn trace(&self, trc: *mut JSTracer) {
|
fn trace(&self, trc: *mut JSTracer) {
|
||||||
self.deref().trace(trc)
|
(**self).trace(trc)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -228,6 +230,16 @@ impl<K: Eq+Hash+JSTraceable, V: JSTraceable> JSTraceable for HashMap<K, V> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl<A: JSTraceable, B: JSTraceable> JSTraceable for (A, B) {
|
||||||
|
#[inline]
|
||||||
|
fn trace(&self, trc: *mut JSTracer) {
|
||||||
|
let (ref a, ref b) = *self;
|
||||||
|
a.trace(trc);
|
||||||
|
b.trace(trc);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
untraceable!(bool, f32, f64, String, Url)
|
untraceable!(bool, f32, f64, String, Url)
|
||||||
untraceable!(uint, u8, u16, u32, u64)
|
untraceable!(uint, u8, u16, u32, u64)
|
||||||
untraceable!(int, i8, i16, i32, i64)
|
untraceable!(int, i8, i16, i32, i64)
|
||||||
|
@ -243,6 +255,8 @@ untraceable!(SubpageId, WindowSizeData, PipelineId)
|
||||||
untraceable!(QuirksMode)
|
untraceable!(QuirksMode)
|
||||||
untraceable!(Cx)
|
untraceable!(Cx)
|
||||||
untraceable!(ResponseHeaderCollection, RequestHeaderCollection, Method)
|
untraceable!(ResponseHeaderCollection, RequestHeaderCollection, Method)
|
||||||
|
untraceable!(ConstellationChan)
|
||||||
|
untraceable!(LayoutChan)
|
||||||
|
|
||||||
impl<'a> JSTraceable for &'a str {
|
impl<'a> JSTraceable for &'a str {
|
||||||
#[inline]
|
#[inline]
|
||||||
|
@ -264,3 +278,10 @@ impl JSTraceable for Box<ScriptListener+'static> {
|
||||||
// Do nothing
|
// Do nothing
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl JSTraceable for Box<LayoutRPC+'static> {
|
||||||
|
#[inline]
|
||||||
|
fn trace(&self, _: *mut JSTracer) {
|
||||||
|
// Do nothing
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -56,7 +56,7 @@ impl BrowserContext {
|
||||||
assert!(handler.deref().is_not_null());
|
assert!(handler.deref().is_not_null());
|
||||||
|
|
||||||
let parent = win.deref().reflector().get_jsobject();
|
let parent = win.deref().reflector().get_jsobject();
|
||||||
let cx = js_info.as_ref().unwrap().js_context.deref().deref().ptr;
|
let cx = js_info.as_ref().unwrap().js_context.deref().ptr;
|
||||||
let wrapper = with_compartment(cx, parent, || unsafe {
|
let wrapper = with_compartment(cx, parent, || unsafe {
|
||||||
WrapperNew(cx, parent, *handler.deref())
|
WrapperNew(cx, parent, *handler.deref())
|
||||||
});
|
});
|
||||||
|
|
|
@ -107,7 +107,7 @@ impl<'a> HTMLIFrameElementHelpers for JSRef<'a, HTMLIFrameElement> {
|
||||||
subpage_id: subpage_id,
|
subpage_id: subpage_id,
|
||||||
}));
|
}));
|
||||||
|
|
||||||
let ConstellationChan(ref chan) = *page.constellation_chan.deref();
|
let ConstellationChan(ref chan) = page.constellation_chan;
|
||||||
chan.send(LoadIframeUrlMsg(url, page.id, subpage_id, sandboxed));
|
chan.send(LoadIframeUrlMsg(url, page.id, subpage_id, sandboxed));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -152,12 +152,12 @@ impl<'a> HTMLIFrameElementMethods for JSRef<'a, HTMLIFrameElement> {
|
||||||
fn GetContentWindow(self) -> Option<Temporary<Window>> {
|
fn GetContentWindow(self) -> Option<Temporary<Window>> {
|
||||||
self.size.get().and_then(|size| {
|
self.size.get().and_then(|size| {
|
||||||
let window = window_from_node(self).root();
|
let window = window_from_node(self).root();
|
||||||
let children = window.deref().page.children.deref().borrow();
|
let children = window.deref().page.children.borrow();
|
||||||
let child = children.iter().find(|child| {
|
let child = children.iter().find(|child| {
|
||||||
child.subpage_id.unwrap() == size.subpage_id
|
child.subpage_id.unwrap() == size.subpage_id
|
||||||
});
|
});
|
||||||
child.and_then(|page| {
|
child.and_then(|page| {
|
||||||
page.frame.deref().borrow().as_ref().map(|frame| {
|
page.frame.borrow().as_ref().map(|frame| {
|
||||||
Temporary::new(frame.window.clone())
|
Temporary::new(frame.window.clone())
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
|
@ -118,7 +118,7 @@ impl<'a> PrivateHTMLLinkElementHelpers for JSRef<'a, HTMLLinkElement> {
|
||||||
let window = window_from_node(self).root();
|
let window = window_from_node(self).root();
|
||||||
match UrlParser::new().base_url(&window.deref().page().get_url()).parse(href) {
|
match UrlParser::new().base_url(&window.deref().page().get_url()).parse(href) {
|
||||||
Ok(url) => {
|
Ok(url) => {
|
||||||
let LayoutChan(ref layout_chan) = *window.deref().page().layout_chan;
|
let LayoutChan(ref layout_chan) = window.deref().page().layout_chan;
|
||||||
layout_chan.send(LoadStylesheetMsg(url));
|
layout_chan.send(LoadStylesheetMsg(url));
|
||||||
}
|
}
|
||||||
Err(e) => debug!("Parsing url {:s} failed: {:?}", href, e)
|
Err(e) => debug!("Parsing url {:s} failed: {:?}", href, e)
|
||||||
|
|
|
@ -57,7 +57,7 @@ impl<'a> StyleElementHelpers for JSRef<'a, HTMLStyleElement> {
|
||||||
|
|
||||||
let data = node.GetTextContent().expect("Element.textContent must be a string");
|
let data = node.GetTextContent().expect("Element.textContent must be a string");
|
||||||
let sheet = Stylesheet::from_str(data.as_slice(), url);
|
let sheet = Stylesheet::from_str(data.as_slice(), url);
|
||||||
let LayoutChan(ref layout_chan) = *win.deref().page().layout_chan;
|
let LayoutChan(ref layout_chan) = win.deref().page().layout_chan;
|
||||||
layout_chan.send(AddStylesheetMsg(sheet));
|
layout_chan.send(AddStylesheetMsg(sheet));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -99,7 +99,7 @@ pub struct Window {
|
||||||
impl Window {
|
impl Window {
|
||||||
pub fn get_cx(&self) -> *mut JSContext {
|
pub fn get_cx(&self) -> *mut JSContext {
|
||||||
let js_info = self.page().js_info();
|
let js_info = self.page().js_info();
|
||||||
(**js_info.as_ref().unwrap().js_context).ptr
|
(*js_info.as_ref().unwrap().js_context).ptr
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn page<'a>(&'a self) -> &'a Page {
|
pub fn page<'a>(&'a self) -> &'a Page {
|
||||||
|
|
|
@ -5,7 +5,6 @@
|
||||||
use dom::bindings::codegen::Bindings::DocumentBinding::DocumentMethods;
|
use dom::bindings::codegen::Bindings::DocumentBinding::DocumentMethods;
|
||||||
use dom::bindings::codegen::InheritTypes::NodeCast;
|
use dom::bindings::codegen::InheritTypes::NodeCast;
|
||||||
use dom::bindings::js::{JS, JSRef, Temporary, OptionalRootable};
|
use dom::bindings::js::{JS, JSRef, Temporary, OptionalRootable};
|
||||||
use dom::bindings::trace::{Traceable, Untraceable};
|
|
||||||
use dom::bindings::utils::GlobalStaticData;
|
use dom::bindings::utils::GlobalStaticData;
|
||||||
use dom::document::{Document, DocumentHelpers};
|
use dom::document::{Document, DocumentHelpers};
|
||||||
use dom::element::Element;
|
use dom::element::Element;
|
||||||
|
@ -42,50 +41,50 @@ pub struct Page {
|
||||||
pub subpage_id: Option<SubpageId>,
|
pub subpage_id: Option<SubpageId>,
|
||||||
|
|
||||||
/// Unique id for last reflow request; used for confirming completion reply.
|
/// Unique id for last reflow request; used for confirming completion reply.
|
||||||
pub last_reflow_id: Traceable<Cell<uint>>,
|
pub last_reflow_id: Cell<uint>,
|
||||||
|
|
||||||
/// The outermost frame containing the document, window, and page URL.
|
/// The outermost frame containing the document, window, and page URL.
|
||||||
pub frame: Traceable<RefCell<Option<Frame>>>,
|
pub frame: RefCell<Option<Frame>>,
|
||||||
|
|
||||||
/// A handle for communicating messages to the layout task.
|
/// A handle for communicating messages to the layout task.
|
||||||
pub layout_chan: Untraceable<LayoutChan>,
|
pub layout_chan: LayoutChan,
|
||||||
|
|
||||||
/// A handle to perform RPC calls into the layout, quickly.
|
/// A handle to perform RPC calls into the layout, quickly.
|
||||||
layout_rpc: Untraceable<Box<LayoutRPC+'static>>,
|
layout_rpc: Box<LayoutRPC+'static>,
|
||||||
|
|
||||||
/// The port that we will use to join layout. If this is `None`, then layout is not running.
|
/// The port that we will use to join layout. If this is `None`, then layout is not running.
|
||||||
pub layout_join_port: Untraceable<RefCell<Option<Receiver<()>>>>,
|
pub layout_join_port: RefCell<Option<Receiver<()>>>,
|
||||||
|
|
||||||
/// What parts of the document are dirty, if any.
|
/// What parts of the document are dirty, if any.
|
||||||
damage: Traceable<RefCell<Option<DocumentDamage>>>,
|
damage: RefCell<Option<DocumentDamage>>,
|
||||||
|
|
||||||
/// The current size of the window, in pixels.
|
/// The current size of the window, in pixels.
|
||||||
pub window_size: Traceable<Cell<WindowSizeData>>,
|
pub window_size: Cell<WindowSizeData>,
|
||||||
|
|
||||||
js_info: Traceable<RefCell<Option<JSPageInfo>>>,
|
js_info: RefCell<Option<JSPageInfo>>,
|
||||||
|
|
||||||
/// Cached copy of the most recent url loaded by the script
|
/// Cached copy of the most recent url loaded by the script
|
||||||
/// TODO(tkuehn): this currently does not follow any particular caching policy
|
/// TODO(tkuehn): this currently does not follow any particular caching policy
|
||||||
/// and simply caches pages forever (!). The bool indicates if reflow is required
|
/// and simply caches pages forever (!). The bool indicates if reflow is required
|
||||||
/// when reloading.
|
/// when reloading.
|
||||||
url: Untraceable<RefCell<Option<(Url, bool)>>>,
|
url: RefCell<Option<(Url, bool)>>,
|
||||||
|
|
||||||
next_subpage_id: Traceable<Cell<SubpageId>>,
|
next_subpage_id: Cell<SubpageId>,
|
||||||
|
|
||||||
/// Pending resize event, if any.
|
/// Pending resize event, if any.
|
||||||
pub resize_event: Untraceable<Cell<Option<WindowSizeData>>>,
|
pub resize_event: Cell<Option<WindowSizeData>>,
|
||||||
|
|
||||||
/// Pending scroll to fragment event, if any
|
/// Pending scroll to fragment event, if any
|
||||||
pub fragment_name: RefCell<Option<String>>,
|
pub fragment_name: RefCell<Option<String>>,
|
||||||
|
|
||||||
/// Associated resource task for use by DOM objects like XMLHttpRequest
|
/// Associated resource task for use by DOM objects like XMLHttpRequest
|
||||||
pub resource_task: Untraceable<ResourceTask>,
|
pub resource_task: ResourceTask,
|
||||||
|
|
||||||
/// A handle for communicating messages to the constellation task.
|
/// A handle for communicating messages to the constellation task.
|
||||||
pub constellation_chan: Untraceable<ConstellationChan>,
|
pub constellation_chan: ConstellationChan,
|
||||||
|
|
||||||
// Child Pages.
|
// Child Pages.
|
||||||
pub children: Traceable<RefCell<Vec<Rc<Page>>>>,
|
pub children: RefCell<Vec<Rc<Page>>>,
|
||||||
|
|
||||||
/// Number of pending reflows that were sent while layout was active.
|
/// Number of pending reflows that were sent while layout was active.
|
||||||
pub pending_reflows: Cell<int>,
|
pub pending_reflows: Cell<int>,
|
||||||
|
@ -111,7 +110,7 @@ impl IterablePage for Rc<Page> {
|
||||||
}
|
}
|
||||||
fn find(&self, id: PipelineId) -> Option<Rc<Page>> {
|
fn find(&self, id: PipelineId) -> Option<Rc<Page>> {
|
||||||
if self.id == id { return Some(self.clone()); }
|
if self.id == id { return Some(self.clone()); }
|
||||||
for page in self.children.deref().borrow().iter() {
|
for page in self.children.borrow().iter() {
|
||||||
let found = page.find(id);
|
let found = page.find(id);
|
||||||
if found.is_some() { return found; }
|
if found.is_some() { return found; }
|
||||||
}
|
}
|
||||||
|
@ -129,7 +128,7 @@ impl Page {
|
||||||
js_context: Rc<Cx>) -> Page {
|
js_context: Rc<Cx>) -> Page {
|
||||||
let js_info = JSPageInfo {
|
let js_info = JSPageInfo {
|
||||||
dom_static: GlobalStaticData(),
|
dom_static: GlobalStaticData(),
|
||||||
js_context: Untraceable::new(js_context),
|
js_context: js_context,
|
||||||
};
|
};
|
||||||
let layout_rpc: Box<LayoutRPC> = {
|
let layout_rpc: Box<LayoutRPC> = {
|
||||||
let (rpc_send, rpc_recv) = channel();
|
let (rpc_send, rpc_recv) = channel();
|
||||||
|
@ -140,21 +139,21 @@ impl Page {
|
||||||
Page {
|
Page {
|
||||||
id: id,
|
id: id,
|
||||||
subpage_id: subpage_id,
|
subpage_id: subpage_id,
|
||||||
frame: Traceable::new(RefCell::new(None)),
|
frame: RefCell::new(None),
|
||||||
layout_chan: Untraceable::new(layout_chan),
|
layout_chan: layout_chan,
|
||||||
layout_rpc: Untraceable::new(layout_rpc),
|
layout_rpc: layout_rpc,
|
||||||
layout_join_port: Untraceable::new(RefCell::new(None)),
|
layout_join_port: RefCell::new(None),
|
||||||
damage: Traceable::new(RefCell::new(None)),
|
damage: RefCell::new(None),
|
||||||
window_size: Traceable::new(Cell::new(window_size)),
|
window_size: Cell::new(window_size),
|
||||||
js_info: Traceable::new(RefCell::new(Some(js_info))),
|
js_info: RefCell::new(Some(js_info)),
|
||||||
url: Untraceable::new(RefCell::new(None)),
|
url: RefCell::new(None),
|
||||||
next_subpage_id: Traceable::new(Cell::new(SubpageId(0))),
|
next_subpage_id: Cell::new(SubpageId(0)),
|
||||||
resize_event: Untraceable::new(Cell::new(None)),
|
resize_event: Cell::new(None),
|
||||||
fragment_name: RefCell::new(None),
|
fragment_name: RefCell::new(None),
|
||||||
last_reflow_id: Traceable::new(Cell::new(0)),
|
last_reflow_id: Cell::new(0),
|
||||||
resource_task: Untraceable::new(resource_task),
|
resource_task: resource_task,
|
||||||
constellation_chan: Untraceable::new(constellation_chan),
|
constellation_chan: constellation_chan,
|
||||||
children: Traceable::new(RefCell::new(vec!())),
|
children: RefCell::new(vec!()),
|
||||||
pending_reflows: Cell::new(0),
|
pending_reflows: Cell::new(0),
|
||||||
avoided_reflows: Cell::new(0),
|
avoided_reflows: Cell::new(0),
|
||||||
}
|
}
|
||||||
|
@ -177,7 +176,7 @@ impl Page {
|
||||||
// doing a query reflow.
|
// doing a query reflow.
|
||||||
self.flush_layout(ReflowForDisplay);
|
self.flush_layout(ReflowForDisplay);
|
||||||
self.join_layout(); //FIXME: is this necessary, or is layout_rpc's mutex good enough?
|
self.join_layout(); //FIXME: is this necessary, or is layout_rpc's mutex good enough?
|
||||||
let layout_rpc: &LayoutRPC = &**self.layout_rpc;
|
let layout_rpc: &LayoutRPC = &*self.layout_rpc;
|
||||||
layout_rpc
|
layout_rpc
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -185,7 +184,6 @@ impl Page {
|
||||||
pub fn remove(&self, id: PipelineId) -> Option<Rc<Page>> {
|
pub fn remove(&self, id: PipelineId) -> Option<Rc<Page>> {
|
||||||
let remove_idx = {
|
let remove_idx = {
|
||||||
self.children
|
self.children
|
||||||
.deref()
|
|
||||||
.borrow_mut()
|
.borrow_mut()
|
||||||
.iter_mut()
|
.iter_mut()
|
||||||
.enumerate()
|
.enumerate()
|
||||||
|
@ -197,9 +195,9 @@ impl Page {
|
||||||
.map(|(idx, _)| idx)
|
.map(|(idx, _)| idx)
|
||||||
};
|
};
|
||||||
match remove_idx {
|
match remove_idx {
|
||||||
Some(idx) => return Some(self.children.deref().borrow_mut().remove(idx).unwrap()),
|
Some(idx) => return Some(self.children.borrow_mut().remove(idx).unwrap()),
|
||||||
None => {
|
None => {
|
||||||
for page_tree in self.children.deref().borrow_mut().iter_mut() {
|
for page_tree in self.children.borrow_mut().iter_mut() {
|
||||||
match page_tree.remove(id) {
|
match page_tree.remove(id) {
|
||||||
found @ Some(_) => return found,
|
found @ Some(_) => return found,
|
||||||
None => (), // keep going...
|
None => (), // keep going...
|
||||||
|
@ -215,7 +213,7 @@ impl Iterator<Rc<Page>> for PageIterator {
|
||||||
fn next(&mut self) -> Option<Rc<Page>> {
|
fn next(&mut self) -> Option<Rc<Page>> {
|
||||||
if !self.stack.is_empty() {
|
if !self.stack.is_empty() {
|
||||||
let next = self.stack.pop().unwrap();
|
let next = self.stack.pop().unwrap();
|
||||||
for child in next.children.deref().borrow().iter() {
|
for child in next.children.borrow().iter() {
|
||||||
self.stack.push(child.clone());
|
self.stack.push(child.clone());
|
||||||
}
|
}
|
||||||
Some(next.clone())
|
Some(next.clone())
|
||||||
|
@ -227,33 +225,33 @@ impl Iterator<Rc<Page>> for PageIterator {
|
||||||
|
|
||||||
impl Page {
|
impl Page {
|
||||||
pub fn mut_js_info<'a>(&'a self) -> RefMut<'a, Option<JSPageInfo>> {
|
pub fn mut_js_info<'a>(&'a self) -> RefMut<'a, Option<JSPageInfo>> {
|
||||||
self.js_info.deref().borrow_mut()
|
self.js_info.borrow_mut()
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn js_info<'a>(&'a self) -> Ref<'a, Option<JSPageInfo>> {
|
pub fn js_info<'a>(&'a self) -> Ref<'a, Option<JSPageInfo>> {
|
||||||
self.js_info.deref().borrow()
|
self.js_info.borrow()
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn url<'a>(&'a self) -> Ref<'a, Option<(Url, bool)>> {
|
pub fn url<'a>(&'a self) -> Ref<'a, Option<(Url, bool)>> {
|
||||||
self.url.deref().borrow()
|
self.url.borrow()
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn mut_url<'a>(&'a self) -> RefMut<'a, Option<(Url, bool)>> {
|
pub fn mut_url<'a>(&'a self) -> RefMut<'a, Option<(Url, bool)>> {
|
||||||
self.url.deref().borrow_mut()
|
self.url.borrow_mut()
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn frame<'a>(&'a self) -> Ref<'a, Option<Frame>> {
|
pub fn frame<'a>(&'a self) -> Ref<'a, Option<Frame>> {
|
||||||
self.frame.deref().borrow()
|
self.frame.borrow()
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn mut_frame<'a>(&'a self) -> RefMut<'a, Option<Frame>> {
|
pub fn mut_frame<'a>(&'a self) -> RefMut<'a, Option<Frame>> {
|
||||||
self.frame.deref().borrow_mut()
|
self.frame.borrow_mut()
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn get_next_subpage_id(&self) -> SubpageId {
|
pub fn get_next_subpage_id(&self) -> SubpageId {
|
||||||
let subpage_id = self.next_subpage_id.deref().get();
|
let subpage_id = self.next_subpage_id.get();
|
||||||
let SubpageId(id_num) = subpage_id;
|
let SubpageId(id_num) = subpage_id;
|
||||||
self.next_subpage_id.deref().set(SubpageId(id_num + 1));
|
self.next_subpage_id.set(SubpageId(id_num + 1));
|
||||||
subpage_id
|
subpage_id
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -267,7 +265,7 @@ impl Page {
|
||||||
None => {},
|
None => {},
|
||||||
Some(root) => {
|
Some(root) => {
|
||||||
let root: JSRef<Node> = NodeCast::from_ref(*root);
|
let root: JSRef<Node> = NodeCast::from_ref(*root);
|
||||||
let mut damage = *self.damage.deref().borrow_mut();
|
let mut damage = *self.damage.borrow_mut();
|
||||||
match damage {
|
match damage {
|
||||||
None => {}
|
None => {}
|
||||||
Some(ref mut damage) => {
|
Some(ref mut damage) => {
|
||||||
|
@ -278,7 +276,7 @@ impl Page {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
*self.damage.deref().borrow_mut() = Some(DocumentDamage {
|
*self.damage.borrow_mut() = Some(DocumentDamage {
|
||||||
root: root.to_trusted_node_address(),
|
root: root.to_trusted_node_address(),
|
||||||
level: level,
|
level: level,
|
||||||
})
|
})
|
||||||
|
@ -297,7 +295,7 @@ impl Page {
|
||||||
/// Sends a ping to layout and waits for the response. The response will arrive when the
|
/// Sends a ping to layout and waits for the response. The response will arrive when the
|
||||||
/// layout task has finished any pending request messages.
|
/// layout task has finished any pending request messages.
|
||||||
pub fn join_layout(&self) {
|
pub fn join_layout(&self) {
|
||||||
let mut layout_join_port = self.layout_join_port.deref().borrow_mut();
|
let mut layout_join_port = self.layout_join_port.borrow_mut();
|
||||||
if layout_join_port.is_some() {
|
if layout_join_port.is_some() {
|
||||||
let join_port = replace(&mut *layout_join_port, None);
|
let join_port = replace(&mut *layout_join_port, None);
|
||||||
match join_port {
|
match join_port {
|
||||||
|
@ -355,15 +353,15 @@ impl Page {
|
||||||
|
|
||||||
// Layout will let us know when it's done.
|
// Layout will let us know when it's done.
|
||||||
let (join_chan, join_port) = channel();
|
let (join_chan, join_port) = channel();
|
||||||
let mut layout_join_port = self.layout_join_port.deref().borrow_mut();
|
let mut layout_join_port = self.layout_join_port.borrow_mut();
|
||||||
*layout_join_port = Some(join_port);
|
*layout_join_port = Some(join_port);
|
||||||
|
|
||||||
let last_reflow_id = self.last_reflow_id.deref();
|
let last_reflow_id = &self.last_reflow_id;
|
||||||
last_reflow_id.set(last_reflow_id.get() + 1);
|
last_reflow_id.set(last_reflow_id.get() + 1);
|
||||||
|
|
||||||
let root: JSRef<Node> = NodeCast::from_ref(*root);
|
let root: JSRef<Node> = NodeCast::from_ref(*root);
|
||||||
let mut damage = self.damage.deref().borrow_mut();
|
let mut damage = self.damage.borrow_mut();
|
||||||
let window_size = self.window_size.deref().get();
|
let window_size = self.window_size.get();
|
||||||
|
|
||||||
// Send new document and relevant styles to layout.
|
// Send new document and relevant styles to layout.
|
||||||
let reflow = box Reflow {
|
let reflow = box Reflow {
|
||||||
|
@ -378,7 +376,7 @@ impl Page {
|
||||||
id: last_reflow_id.get(),
|
id: last_reflow_id.get(),
|
||||||
};
|
};
|
||||||
|
|
||||||
let LayoutChan(ref chan) = *self.layout_chan;
|
let LayoutChan(ref chan) = self.layout_chan;
|
||||||
chan.send(ReflowMsg(reflow));
|
chan.send(ReflowMsg(reflow));
|
||||||
|
|
||||||
debug!("script: layout forked")
|
debug!("script: layout forked")
|
||||||
|
@ -450,5 +448,5 @@ pub struct JSPageInfo {
|
||||||
/// Global static data related to the DOM.
|
/// Global static data related to the DOM.
|
||||||
pub dom_static: GlobalStaticData,
|
pub dom_static: GlobalStaticData,
|
||||||
/// The JavaScript context.
|
/// The JavaScript context.
|
||||||
pub js_context: Untraceable<Rc<Cx>>,
|
pub js_context: Rc<Cx>,
|
||||||
}
|
}
|
||||||
|
|
|
@ -395,14 +395,14 @@ impl ScriptTask {
|
||||||
let mut page = self.page.borrow_mut();
|
let mut page = self.page.borrow_mut();
|
||||||
for page in page.iter() {
|
for page in page.iter() {
|
||||||
// Only process a resize if layout is idle.
|
// Only process a resize if layout is idle.
|
||||||
let layout_join_port = page.layout_join_port.deref().borrow();
|
let layout_join_port = page.layout_join_port.borrow();
|
||||||
if layout_join_port.is_none() {
|
if layout_join_port.is_none() {
|
||||||
let mut resize_event = page.resize_event.deref().get();
|
let mut resize_event = page.resize_event.get();
|
||||||
match resize_event.take() {
|
match resize_event.take() {
|
||||||
Some(size) => resizes.push((page.id, size)),
|
Some(size) => resizes.push((page.id, size)),
|
||||||
None => ()
|
None => ()
|
||||||
}
|
}
|
||||||
page.resize_event.deref().set(None);
|
page.resize_event.set(None);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -457,7 +457,7 @@ impl ScriptTask {
|
||||||
FromConstellation(ResizeMsg(id, size)) => {
|
FromConstellation(ResizeMsg(id, size)) => {
|
||||||
let mut page = self.page.borrow_mut();
|
let mut page = self.page.borrow_mut();
|
||||||
let page = page.find(id).expect("resize sent to nonexistent pipeline");
|
let page = page.find(id).expect("resize sent to nonexistent pipeline");
|
||||||
page.resize_event.deref().set(Some(size));
|
page.resize_event.set(Some(size));
|
||||||
}
|
}
|
||||||
_ => {
|
_ => {
|
||||||
sequential.push(event);
|
sequential.push(event);
|
||||||
|
@ -594,15 +594,15 @@ impl ScriptTask {
|
||||||
whose parent has a PipelineId which does not correspond to a pipeline in the script
|
whose parent has a PipelineId which does not correspond to a pipeline in the script
|
||||||
task's page tree. This is a bug.");
|
task's page tree. This is a bug.");
|
||||||
let new_page = {
|
let new_page = {
|
||||||
let window_size = parent_page.window_size.deref().get();
|
let window_size = parent_page.window_size.get();
|
||||||
Page::new(new_pipeline_id, Some(subpage_id),
|
Page::new(new_pipeline_id, Some(subpage_id),
|
||||||
LayoutChan(layout_chan.downcast_ref::<Sender<layout_interface::Msg>>().unwrap().clone()),
|
LayoutChan(layout_chan.downcast_ref::<Sender<layout_interface::Msg>>().unwrap().clone()),
|
||||||
window_size,
|
window_size,
|
||||||
parent_page.resource_task.deref().clone(),
|
parent_page.resource_task.clone(),
|
||||||
self.constellation_chan.clone(),
|
self.constellation_chan.clone(),
|
||||||
self.js_context.borrow().as_ref().unwrap().clone())
|
self.js_context.borrow().as_ref().unwrap().clone())
|
||||||
};
|
};
|
||||||
parent_page.children.deref().borrow_mut().push(Rc::new(new_page));
|
parent_page.children.borrow_mut().push(Rc::new(new_page));
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Handles a timer that fired.
|
/// Handles a timer that fired.
|
||||||
|
@ -622,9 +622,9 @@ impl ScriptTask {
|
||||||
let page = page.find(pipeline_id).expect(
|
let page = page.find(pipeline_id).expect(
|
||||||
"ScriptTask: received a load message for a layout channel that is not associated \
|
"ScriptTask: received a load message for a layout channel that is not associated \
|
||||||
with this script task. This is a bug.");
|
with this script task. This is a bug.");
|
||||||
let last_reflow_id = page.last_reflow_id.deref().get();
|
let last_reflow_id = page.last_reflow_id.get();
|
||||||
if last_reflow_id == reflow_id {
|
if last_reflow_id == reflow_id {
|
||||||
let mut layout_join_port = page.layout_join_port.deref().borrow_mut();
|
let mut layout_join_port = page.layout_join_port.borrow_mut();
|
||||||
*layout_join_port = None;
|
*layout_join_port = None;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -649,7 +649,7 @@ impl ScriptTask {
|
||||||
let mut page = self.page.borrow_mut();
|
let mut page = self.page.borrow_mut();
|
||||||
let page = page.find(id).expect("Received resize message for PipelineId not associated
|
let page = page.find(id).expect("Received resize message for PipelineId not associated
|
||||||
with a page in the page tree. This is a bug.");
|
with a page in the page tree. This is a bug.");
|
||||||
page.window_size.deref().set(new_size);
|
page.window_size.set(new_size);
|
||||||
match &mut *page.mut_url() {
|
match &mut *page.mut_url() {
|
||||||
&Some((_, ref mut needs_reflow)) => *needs_reflow = true,
|
&Some((_, ref mut needs_reflow)) => *needs_reflow = true,
|
||||||
&None => (),
|
&None => (),
|
||||||
|
@ -866,7 +866,7 @@ impl ScriptTask {
|
||||||
|
|
||||||
let window = {
|
let window = {
|
||||||
let page = get_page(&*self.page.borrow(), pipeline_id);
|
let page = get_page(&*self.page.borrow(), pipeline_id);
|
||||||
page.window_size.deref().set(new_size);
|
page.window_size.set(new_size);
|
||||||
|
|
||||||
let frame = page.frame();
|
let frame = page.frame();
|
||||||
if frame.is_some() {
|
if frame.is_some() {
|
||||||
|
@ -911,7 +911,7 @@ impl ScriptTask {
|
||||||
let page = get_page(&*self.page.borrow(), pipeline_id);
|
let page = get_page(&*self.page.borrow(), pipeline_id);
|
||||||
let frame = page.frame();
|
let frame = page.frame();
|
||||||
if frame.is_some() {
|
if frame.is_some() {
|
||||||
let in_layout = page.layout_join_port.deref().borrow().is_some();
|
let in_layout = page.layout_join_port.borrow().is_some();
|
||||||
if in_layout {
|
if in_layout {
|
||||||
page.pending_reflows.set(page.pending_reflows.get() + 1);
|
page.pending_reflows.set(page.pending_reflows.get() + 1);
|
||||||
} else {
|
} else {
|
||||||
|
@ -1062,7 +1062,7 @@ fn shut_down_layout(page_tree: &Rc<Page>, rt: *mut JSRuntime) {
|
||||||
// Tell the layout task to begin shutting down, and wait until it
|
// Tell the layout task to begin shutting down, and wait until it
|
||||||
// processed this message.
|
// processed this message.
|
||||||
let (response_chan, response_port) = channel();
|
let (response_chan, response_port) = channel();
|
||||||
let LayoutChan(ref chan) = *page.layout_chan;
|
let LayoutChan(ref chan) = page.layout_chan;
|
||||||
chan.send(layout_interface::PrepareToExitMsg(response_chan));
|
chan.send(layout_interface::PrepareToExitMsg(response_chan));
|
||||||
response_port.recv();
|
response_port.recv();
|
||||||
}
|
}
|
||||||
|
@ -1085,7 +1085,7 @@ fn shut_down_layout(page_tree: &Rc<Page>, rt: *mut JSRuntime) {
|
||||||
|
|
||||||
// Destroy the layout task. If there were node leaks, layout will now crash safely.
|
// Destroy the layout task. If there were node leaks, layout will now crash safely.
|
||||||
for page in page_tree.iter() {
|
for page in page_tree.iter() {
|
||||||
let LayoutChan(ref chan) = *page.layout_chan;
|
let LayoutChan(ref chan) = page.layout_chan;
|
||||||
chan.send(layout_interface::ExitNowMsg);
|
chan.send(layout_interface::ExitNowMsg);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue