fix borrow check failures by reverting to storing *mut Page in window

This commit is contained in:
Tim Kuehn 2013-07-29 20:22:01 -07:00
parent 2b94dd6664
commit 2e6ad0a4a3
8 changed files with 46 additions and 63 deletions

View file

@ -88,7 +88,7 @@ impl Document {
parent: Element::new(HTMLHtmlElementTypeId, ~"html")
};
let cx = _owner.page.js_info.get_ref().js_compartment.cx.ptr;
let cx = unsafe {(*_owner.page).js_info.get_ref().js_compartment.cx.ptr};
let root = unsafe { Node::as_abstract_node(cx, root) };
Document(root, None)
}
@ -130,7 +130,7 @@ impl Document {
}
};
let win = self.window.get_ref();
let cx = win.page.js_info.get_ref().js_compartment.cx.ptr;
let cx = unsafe {(*win.page).js_info.get_ref().js_compartment.cx.ptr};
let cache = win.get_wrappercache();
let scope = cache.get_wrapper();
HTMLCollection::new(elements, cx, scope)
@ -138,7 +138,7 @@ impl Document {
pub fn GetElementsByTagNameNS(&self, _ns: DOMString, _tag: DOMString) -> @mut HTMLCollection {
let win = self.window.get_ref();
let cx = win.page.js_info.get_ref().js_compartment.cx.ptr;
let cx = unsafe {(*win.page).js_info.get_ref().js_compartment.cx.ptr};
let cache = win.get_wrappercache();
let scope = cache.get_wrapper();
HTMLCollection::new(~[], cx, scope)
@ -146,7 +146,7 @@ impl Document {
pub fn GetElementsByClassName(&self, _class: DOMString) -> @mut HTMLCollection {
let win = self.window.get_ref();
let cx = win.page.js_info.get_ref().js_compartment.cx.ptr;
let cx = unsafe {(*win.page).js_info.get_ref().js_compartment.cx.ptr};
let cache = win.get_wrappercache();
let scope = cache.get_wrapper();
HTMLCollection::new(~[], cx, scope)
@ -289,7 +289,7 @@ impl Document {
}
};
let win = self.window.get_ref();
let cx = win.page.js_info.get_ref().js_compartment.cx.ptr;
let cx = unsafe {(*win.page).js_info.get_ref().js_compartment.cx.ptr};
let cache = win.get_wrappercache();
let scope = cache.get_wrapper();
HTMLCollection::new(elements, cx, scope)

View file

@ -22,7 +22,7 @@ impl DOMParser {
};
// TODO(tkuehn): This just handles the top-level page. Need to handle subframes.
let cx = owner.page.js_info.get_ref().js_compartment.cx.ptr;
let cx = unsafe {(*owner.page).js_info.get_ref().js_compartment.cx.ptr};
let cache = owner.get_wrappercache();
let scope = cache.get_wrapper();
parser.wrap_object_shared(cx, scope);

View file

@ -179,9 +179,9 @@ impl<'self> Element {
let (port, chan) = comm::stream();
// TODO(tkuehn): currently just queries top-level page layout. Needs to query
// subframe layout if this element is in a subframe. Probably need an ID field.
match page.query_layout(ContentBoxesQuery(node, chan), port) {
match unsafe {(*page).query_layout(ContentBoxesQuery(node, chan), port)} {
Ok(ContentBoxesResponse(rects)) => {
let cx = (*page).js_info.get_ref().js_compartment.cx.ptr;
let cx = unsafe {(*page).js_info.get_ref().js_compartment.cx.ptr};
let cache = win.get_wrappercache();
let scope = cache.get_wrapper();
let rects = do rects.map |r| {
@ -225,11 +225,9 @@ impl<'self> Element {
let node = self.parent.abstract.get();
assert!(node.is_element());
let (port, chan) = comm::stream();
// TODO(tkuehn): currently just queries top-level page layout. Needs to query
// subframe layout if this element is in a subframe. Probably need an ID field.
match page.query_layout(ContentBoxQuery(node, chan), port) {
match unsafe{(*page).query_layout(ContentBoxQuery(node, chan), port)} {
Ok(ContentBoxResponse(rect)) => {
let cx = (*page).js_info.get_ref().js_compartment.cx.ptr;
let cx = unsafe {(*page).js_info.get_ref().js_compartment.cx.ptr};
let cache = win.get_wrappercache();
let scope = cache.get_wrapper();
Some(ClientRect::new(

View file

@ -25,10 +25,9 @@ pub enum TimerControlMsg {
TimerMessage_TriggerExit //XXXjdm this is just a quick hack to talk to the script task
}
//FIXME If we're going to store the script task, find a way to do so safely. Currently it's
// only used for querying layout from arbitrary script.
//FIXME If we're going to store the page, find a way to do so safely.
pub struct Window {
page: @mut Page,
page: *mut Page,
script_chan: ScriptChan,
compositor: @ScriptListener,
wrapper: WrapperCache,
@ -91,13 +90,14 @@ impl Window {
}
pub fn content_changed(&self) {
self.page.reflow_all(ReflowForScriptQuery, self.script_chan.clone(), self.compositor);
unsafe {
(*self.page).reflow_all(ReflowForScriptQuery, self.script_chan.clone(), self.compositor);
}
}
pub fn new(page: @mut Page, script_chan: ScriptChan, compositor: @ScriptListener)
pub fn new(page: *mut Page, script_chan: ScriptChan, compositor: @ScriptListener)
-> @mut Window {
let script_chan_clone = script_chan.clone();
let page_id = page.id.clone();
let win = @mut Window {
page: page,
script_chan: script_chan,
@ -109,7 +109,7 @@ impl Window {
loop {
match timer_port.recv() {
TimerMessage_Close => break,
TimerMessage_Fire(td) => script_chan_clone.chan.send(FireTimerMsg(page_id.clone(), td)),
TimerMessage_Fire(td) => unsafe {script_chan_clone.chan.send(FireTimerMsg((*page).id.clone(), td))},
TimerMessage_TriggerExit => script_chan_clone.chan.send(ExitMsg),
}
}
@ -118,8 +118,11 @@ impl Window {
},
};
let compartment = page.js_info.get_ref().js_compartment;
window::create(compartment, win);
unsafe {
// TODO(tkuehn): This just grabs the top-level page. Need to handle subframes.
let compartment = (*page).js_info.get_ref().js_compartment;
window::create(compartment, win);
}
win
}
}

View file

@ -601,7 +601,7 @@ impl ScriptTask {
let HtmlParserResult {root, js_port, style_port, iframe_port} = html_parsing_result;
// Create the window and document objects.
let window = Window::new(page, self.chan.clone(), self.compositor);
let window = Window::new(&mut *page, self.chan.clone(), self.compositor);
let document = Document(root, Some(window));
// Tie the root into the document.