mirror of
https://github.com/servo/servo.git
synced 2025-08-05 05:30:08 +01:00
switched window.page from *mut Page to @mut Page
This commit is contained in:
parent
43491d5b23
commit
df5306e358
5 changed files with 17 additions and 26 deletions
|
@ -88,7 +88,7 @@ impl Document {
|
||||||
parent: Element::new(HTMLHtmlElementTypeId, ~"html")
|
parent: Element::new(HTMLHtmlElementTypeId, ~"html")
|
||||||
};
|
};
|
||||||
|
|
||||||
let cx = unsafe {(*_owner.page).js_info.get_ref().js_compartment.cx.ptr};
|
let cx = _owner.page.js_info.get_ref().js_compartment.cx.ptr;
|
||||||
let root = unsafe { Node::as_abstract_node(cx, root) };
|
let root = unsafe { Node::as_abstract_node(cx, root) };
|
||||||
Document(root, None)
|
Document(root, None)
|
||||||
}
|
}
|
||||||
|
@ -130,7 +130,7 @@ impl Document {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
let win = self.window.get_ref();
|
let win = self.window.get_ref();
|
||||||
let cx = unsafe {(*win.page).js_info.get_ref().js_compartment.cx.ptr};
|
let cx = win.page.js_info.get_ref().js_compartment.cx.ptr;
|
||||||
let cache = win.get_wrappercache();
|
let cache = win.get_wrappercache();
|
||||||
let scope = cache.get_wrapper();
|
let scope = cache.get_wrapper();
|
||||||
HTMLCollection::new(elements, cx, scope)
|
HTMLCollection::new(elements, cx, scope)
|
||||||
|
@ -138,7 +138,7 @@ impl Document {
|
||||||
|
|
||||||
pub fn GetElementsByTagNameNS(&self, _ns: DOMString, _tag: DOMString) -> @mut HTMLCollection {
|
pub fn GetElementsByTagNameNS(&self, _ns: DOMString, _tag: DOMString) -> @mut HTMLCollection {
|
||||||
let win = self.window.get_ref();
|
let win = self.window.get_ref();
|
||||||
let cx = unsafe {(*win.page).js_info.get_ref().js_compartment.cx.ptr};
|
let cx = win.page.js_info.get_ref().js_compartment.cx.ptr;
|
||||||
let cache = win.get_wrappercache();
|
let cache = win.get_wrappercache();
|
||||||
let scope = cache.get_wrapper();
|
let scope = cache.get_wrapper();
|
||||||
HTMLCollection::new(~[], cx, scope)
|
HTMLCollection::new(~[], cx, scope)
|
||||||
|
@ -146,7 +146,7 @@ impl Document {
|
||||||
|
|
||||||
pub fn GetElementsByClassName(&self, _class: DOMString) -> @mut HTMLCollection {
|
pub fn GetElementsByClassName(&self, _class: DOMString) -> @mut HTMLCollection {
|
||||||
let win = self.window.get_ref();
|
let win = self.window.get_ref();
|
||||||
let cx = unsafe {(*win.page).js_info.get_ref().js_compartment.cx.ptr};
|
let cx = win.page.js_info.get_ref().js_compartment.cx.ptr;
|
||||||
let cache = win.get_wrappercache();
|
let cache = win.get_wrappercache();
|
||||||
let scope = cache.get_wrapper();
|
let scope = cache.get_wrapper();
|
||||||
HTMLCollection::new(~[], cx, scope)
|
HTMLCollection::new(~[], cx, scope)
|
||||||
|
@ -289,7 +289,7 @@ impl Document {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
let win = self.window.get_ref();
|
let win = self.window.get_ref();
|
||||||
let cx = unsafe {(*win.page).js_info.get_ref().js_compartment.cx.ptr};
|
let cx = win.page.js_info.get_ref().js_compartment.cx.ptr;
|
||||||
let cache = win.get_wrappercache();
|
let cache = win.get_wrappercache();
|
||||||
let scope = cache.get_wrapper();
|
let scope = cache.get_wrapper();
|
||||||
HTMLCollection::new(elements, cx, scope)
|
HTMLCollection::new(elements, cx, scope)
|
||||||
|
|
|
@ -22,7 +22,7 @@ impl DOMParser {
|
||||||
};
|
};
|
||||||
|
|
||||||
// TODO(tkuehn): This just handles the top-level page. Need to handle subframes.
|
// TODO(tkuehn): This just handles the top-level page. Need to handle subframes.
|
||||||
let cx = unsafe {(*owner.page).js_info.get_ref().js_compartment.cx.ptr};
|
let cx = owner.page.js_info.get_ref().js_compartment.cx.ptr;
|
||||||
let cache = owner.get_wrappercache();
|
let cache = owner.get_wrappercache();
|
||||||
let scope = cache.get_wrapper();
|
let scope = cache.get_wrapper();
|
||||||
parser.wrap_object_shared(cx, scope);
|
parser.wrap_object_shared(cx, scope);
|
||||||
|
|
|
@ -175,9 +175,7 @@ impl<'self> Element {
|
||||||
Some(win) => {
|
Some(win) => {
|
||||||
let node = self.parent.abstract.get();
|
let node = self.parent.abstract.get();
|
||||||
assert!(node.is_element());
|
assert!(node.is_element());
|
||||||
let page = unsafe {
|
let page = win.page;
|
||||||
&mut *win.page
|
|
||||||
};
|
|
||||||
let (port, chan) = comm::stream();
|
let (port, chan) = comm::stream();
|
||||||
// TODO(tkuehn): currently just queries top-level page layout. Needs to query
|
// 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.
|
// subframe layout if this element is in a subframe. Probably need an ID field.
|
||||||
|
@ -223,9 +221,7 @@ impl<'self> Element {
|
||||||
Some(doc) => {
|
Some(doc) => {
|
||||||
match doc.window {
|
match doc.window {
|
||||||
Some(win) => {
|
Some(win) => {
|
||||||
let page = unsafe {
|
let page = win.page;
|
||||||
&mut *win.page
|
|
||||||
};
|
|
||||||
let node = self.parent.abstract.get();
|
let node = self.parent.abstract.get();
|
||||||
assert!(node.is_element());
|
assert!(node.is_element());
|
||||||
let (port, chan) = comm::stream();
|
let (port, chan) = comm::stream();
|
||||||
|
|
|
@ -28,7 +28,7 @@ pub enum TimerControlMsg {
|
||||||
//FIXME If we're going to store the script task, find a way to do so safely. Currently it's
|
//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.
|
// only used for querying layout from arbitrary script.
|
||||||
pub struct Window {
|
pub struct Window {
|
||||||
page: *mut Page,
|
page: @mut Page,
|
||||||
script_chan: ScriptChan,
|
script_chan: ScriptChan,
|
||||||
compositor: @ScriptListener,
|
compositor: @ScriptListener,
|
||||||
wrapper: WrapperCache,
|
wrapper: WrapperCache,
|
||||||
|
@ -91,15 +91,13 @@ impl Window {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn content_changed(&self) {
|
pub fn content_changed(&self) {
|
||||||
unsafe {
|
self.page.reflow_all(ReflowForScriptQuery, self.script_chan.clone(), self.compositor);
|
||||||
// TODO(tkuehn): currently reflow top-level, but want to reflow only the associated frame
|
|
||||||
(*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 {
|
-> @mut Window {
|
||||||
let script_chan_clone = script_chan.clone();
|
let script_chan_clone = script_chan.clone();
|
||||||
|
let page_id = page.id.clone();
|
||||||
let win = @mut Window {
|
let win = @mut Window {
|
||||||
page: page,
|
page: page,
|
||||||
script_chan: script_chan,
|
script_chan: script_chan,
|
||||||
|
@ -111,7 +109,7 @@ impl Window {
|
||||||
loop {
|
loop {
|
||||||
match timer_port.recv() {
|
match timer_port.recv() {
|
||||||
TimerMessage_Close => break,
|
TimerMessage_Close => break,
|
||||||
TimerMessage_Fire(td) => unsafe {script_chan_clone.chan.send(FireTimerMsg((*page).id.clone(), td))},
|
TimerMessage_Fire(td) => script_chan_clone.chan.send(FireTimerMsg(page_id.clone(), td)),
|
||||||
TimerMessage_TriggerExit => script_chan_clone.chan.send(ExitMsg),
|
TimerMessage_TriggerExit => script_chan_clone.chan.send(ExitMsg),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -120,11 +118,8 @@ impl Window {
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
unsafe {
|
let compartment = page.js_info.get_ref().js_compartment;
|
||||||
// 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);
|
window::create(compartment, win);
|
||||||
}
|
|
||||||
win
|
win
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -569,10 +569,10 @@ impl ScriptTask {
|
||||||
for last_loaded_url.iter().advance |last_loaded_url| {
|
for last_loaded_url.iter().advance |last_loaded_url| {
|
||||||
let (ref last_loaded_url, needs_reflow) = *last_loaded_url;
|
let (ref last_loaded_url, needs_reflow) = *last_loaded_url;
|
||||||
if *last_loaded_url == url {
|
if *last_loaded_url == url {
|
||||||
|
page.url = Some((last_loaded_url.clone(), false));
|
||||||
if needs_reflow {
|
if needs_reflow {
|
||||||
page.reflow_all(ReflowForDisplay, self.chan.clone(), self.compositor);
|
page.reflow_all(ReflowForDisplay, self.chan.clone(), self.compositor);
|
||||||
}
|
}
|
||||||
page.url = Some((last_loaded_url.clone(), false));
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -601,7 +601,7 @@ impl ScriptTask {
|
||||||
let HtmlParserResult {root, js_port, style_port, iframe_port} = html_parsing_result;
|
let HtmlParserResult {root, js_port, style_port, iframe_port} = html_parsing_result;
|
||||||
|
|
||||||
// Create the window and document objects.
|
// Create the window and document objects.
|
||||||
let window = Window::new(&mut *page, self.chan.clone(), self.compositor);
|
let window = Window::new(page, self.chan.clone(), self.compositor);
|
||||||
let document = Document(root, Some(window));
|
let document = Document(root, Some(window));
|
||||||
|
|
||||||
// Tie the root into the document.
|
// Tie the root into the document.
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue