added subpage ids to map from iframe to all associated pipelines

This commit is contained in:
Tim Kuehn 2013-07-30 16:13:04 -07:00
parent a2bdab7989
commit 2348fbf46d
6 changed files with 71 additions and 47 deletions

View file

@ -18,6 +18,8 @@ use std::str::eq_slice;
use extra::net::url::Url;
use geom::size::Size2D;
use servo_msg::constellation_msg::SubpageId;
pub struct Element {
parent: Node<ScriptView>,
tag_name: ~str, // TODO: This should be an atom, not a ~str.
@ -112,6 +114,7 @@ pub struct HTMLHeadingElement {
pub struct HTMLIframeElement {
parent: Element,
frame: Option<Url>,
subpage_id: Option<SubpageId>,
size_future_chan: Option<ChanOne<Size2D<uint>>>,
}

View file

@ -42,6 +42,7 @@ use std::str::eq_slice;
use std::result;
use std::task;
use hubbub::hubbub;
use servo_msg::constellation_msg::SubpageId;
use servo_net::image_cache_task::ImageCacheTask;
use servo_net::image_cache_task;
use servo_net::resource_task::{Done, Load, Payload, ResourceTask};
@ -83,7 +84,7 @@ enum JSMessage {
pub struct HtmlParserResult {
root: AbstractNode<ScriptView>,
style_port: Port<Stylesheet>,
iframe_port: Port<(Url, Future<Size2D<uint>>)>,
iframe_port: Port<(Url, SubpageId, Future<Size2D<uint>>)>,
js_port: Port<JSResult>,
}
@ -222,7 +223,7 @@ fn build_element_from_tag(cx: *JSContext, tag: &str) -> AbstractNode<ScriptView>
handle_element!(cx, tag, "ul", HTMLUListElementTypeId, HTMLUListElement, []);
handle_element!(cx, tag, "img", HTMLImageElementTypeId, HTMLImageElement, [(image: None)]);
handle_element!(cx, tag, "iframe", HTMLIframeElementTypeId, HTMLIframeElement, [(frame: None), (size_future_chan: None)]);
handle_element!(cx, tag, "iframe", HTMLIframeElementTypeId, HTMLIframeElement, [(frame: None), (size_future_chan: None), (subpage_id: None)]);
handle_element!(cx, tag, "h1", HTMLHeadingElementTypeId, HTMLHeadingElement, [(level: Heading1)]);
handle_element!(cx, tag, "h2", HTMLHeadingElementTypeId, HTMLHeadingElement, [(level: Heading2)]);
@ -281,6 +282,8 @@ pub fn parse_html(cx: *JSContext,
let (css_chan2, css_chan3, js_chan2) = (css_chan.clone(), css_chan.clone(), js_chan.clone());
let (iframe_port, iframe_chan) = comm::stream();
let next_subpage_id = Cell::new(SubpageId(0));
parser.set_tree_handler(~hubbub::TreeHandler {
create_comment: |data: ~str| {
debug!("create comment");
@ -337,10 +340,18 @@ pub fn parse_html(cx: *JSContext,
for src_opt.iter().advance |src| {
let iframe_url = make_url(src.clone(), Some(url2.clone()));
iframe_element.frame = Some(iframe_url.clone());
// Size future
let (port, chan) = comm::oneshot();
iframe_element.size_future_chan = Some(chan);
let size_future = from_port(port);
iframe_chan.send((iframe_url, size_future));
// Subpage Id
let subpage_id = next_subpage_id.take();
iframe_element.subpage_id = Some(subpage_id);
next_subpage_id.put_back(SubpageId(*subpage_id + 1));
iframe_chan.send((iframe_url, subpage_id, size_future));
}
}
}

View file

@ -21,7 +21,7 @@ use layout_interface::{ReflowDocumentDamage, ReflowForDisplay, ReflowGoal};
use layout_interface::ReflowMsg;
use layout_interface;
use servo_msg::constellation_msg::{ConstellationChan, LoadUrlMsg, NavigationDirection};
use servo_msg::constellation_msg::{PipelineId, RendererReadyMsg, ResizedWindowBroadcast};
use servo_msg::constellation_msg::{PipelineId, SubpageId, RendererReadyMsg, ResizedWindowBroadcast};
use servo_msg::constellation_msg::{LoadIframeUrlMsg};
use servo_msg::constellation_msg;
@ -624,12 +624,13 @@ impl ScriptTask {
// FIXME: These should be streamed to layout as they're parsed. We don't need to stop here
// in the script task.
let get_iframes = |iframe_port: &Port<(Url, Future<Size2D<uint>>)>| loop {
let get_iframes = |iframe_port: &Port<(Url, SubpageId, Future<Size2D<uint>>)>| loop {
match iframe_port.try_recv() {
None => break,
Some((iframe_url, size_future)) => {
Some((iframe_url, subpage_id, size_future)) => {
self.constellation_chan.send(LoadIframeUrlMsg(iframe_url,
pipeline_id,
subpage_id,
size_future));
}
}
@ -652,9 +653,10 @@ impl ScriptTask {
Left(Some(sheet)) => {
page.layout_chan.send(AddStylesheetMsg(sheet));
}
Right(Some((iframe_url, size_future))) => {
Right(Some((iframe_url, subpage_id, size_future))) => {
self.constellation_chan.send(LoadIframeUrlMsg(iframe_url,
pipeline_id,
subpage_id,
size_future));
}
Right(None) => {