navigation bug fix

This commit is contained in:
Tim Kuehn 2013-07-29 13:50:41 -07:00
parent b7e2eab2f4
commit 43491d5b23
4 changed files with 17 additions and 14 deletions

View file

@ -320,8 +320,7 @@ impl Constellation {
if url.path.ends_with(".js") {
pipeline.script_chan.send(ExecuteMsg(pipeline.id, url));
} else {
pipeline.load(url);
pipeline.navigation_type = Some(constellation_msg::Load);
pipeline.load(url, Some(constellation_msg::Load));
self.pending_frames.push(FrameChange{
before: None,
@ -374,6 +373,7 @@ impl Constellation {
source's Url is None. There should never be a LoadUrlIframeMsg from a pipeline
that was never given a url to load.");
// FIXME(tkuehn): Need to follow the standardized spec for checking same-origin
let pipeline = @mut if (source_url.host == url.host &&
source_url.port == url.port) {
// Reuse the script task if same-origin url's
@ -400,8 +400,7 @@ impl Constellation {
if url.path.ends_with(".js") {
pipeline.execute(url);
} else {
pipeline.load(url);
pipeline.navigation_type = None;
pipeline.load(url, None);
}
frame_tree.children.push(@mut FrameTree {
pipeline: pipeline,
@ -445,8 +444,7 @@ impl Constellation {
if url.path.ends_with(".js") {
pipeline.script_chan.send(ExecuteMsg(pipeline.id, url));
} else {
pipeline.load(url);
pipeline.navigation_type = Some(constellation_msg::Load);
pipeline.load(url, Some(constellation_msg::Load));
let parent = if self.current_frame().get_ref().pipeline.id == source_id {
// source_id is the root of the current frame tree; replace whole tree
@ -494,8 +492,7 @@ impl Constellation {
for destination_frame.iter().advance |frame| {
let pipeline = &frame.pipeline;
pipeline.navigation_type = Some(constellation_msg::Navigate);
pipeline.reload();
pipeline.reload(Some(constellation_msg::Navigate));
}
self.compositor_chan.send(SetIds(destination_frame.to_sendable(), self.chan.clone()));

View file

@ -137,8 +137,9 @@ impl Pipeline {
}
}
pub fn load(&mut self, url: Url) {
pub fn load(&mut self, url: Url, navigation_type: Option<NavigationType>) {
self.url = Some(url.clone());
self.navigation_type = navigation_type;
self.script_chan.send(LoadMsg(self.id, url));
}
@ -155,9 +156,10 @@ impl Pipeline {
self.render_chan.send(PaintPermissionRevoked);
}
pub fn reload(&self) {
for self.url.iter().advance |url| {
self.script_chan.send(LoadMsg(self.id, url.clone()));
pub fn reload(&mut self, navigation_type: Option<NavigationType>) {
if self.url.is_some() {
let url = self.url.get_ref().clone();
self.load(url, navigation_type);
}
}

View file

@ -241,6 +241,7 @@ pub fn parse_html(cx: *JSContext,
url: Url,
resource_task: ResourceTask,
image_cache_task: ImageCacheTask) -> HtmlParserResult {
debug!("Hubbub: parsing %?", url);
// Spawn a CSS parser to receive links to CSS style sheets.
let resource_task2 = resource_task.clone();

View file

@ -560,6 +560,8 @@ impl ScriptTask {
/// The entry point to document loading. Defines bindings, sets up the window and document
/// objects, parses HTML and CSS, and kicks off initial layout.
fn load(&mut self, pipeline_id: PipelineId, url: Url) {
debug!("ScriptTask: loading %?", url);
let page = self.page_tree.find(pipeline_id).expect("ScriptTask: received a load
message for a layout channel that is not associated with this script task. This
is a bug.").page;
@ -569,8 +571,8 @@ impl ScriptTask {
if *last_loaded_url == url {
if needs_reflow {
page.reflow_all(ReflowForDisplay, self.chan.clone(), self.compositor);
page.url = Some((last_loaded_url.clone(), false));
}
page.url = Some((last_loaded_url.clone(), false));
return;
}
}
@ -758,10 +760,11 @@ impl ScriptTask {
// if the node's element is "a," load url from href attr
let href = element.get_attr("href");
for href.iter().advance |href| {
debug!("clicked on link to %s", *href);
debug!("ScriptTask: clicked on link to %s", *href);
let current_url = do page.url.map |&(ref url, _)| {
url.clone()
};
debug!("ScriptTask: current url is %?", current_url);
let url = make_url(href.to_owned(), current_url);
self.constellation_chan.send(LoadUrlMsg(page.id, url, from_value(page.window_size.get())));
}