diff options
-rw-r--r-- | src/components/script/html/hubbub_html_parser.rs | 13 | ||||
-rw-r--r-- | src/components/script/script_task.rs | 3 |
2 files changed, 12 insertions, 4 deletions
diff --git a/src/components/script/html/hubbub_html_parser.rs b/src/components/script/html/hubbub_html_parser.rs index 0364befdb53..7aa91104507 100644 --- a/src/components/script/html/hubbub_html_parser.rs +++ b/src/components/script/html/hubbub_html_parser.rs @@ -129,7 +129,6 @@ pub enum HtmlDiscoveryMessage { pub struct HtmlParserResult { root: AbstractNode<ScriptView>, discovery_port: Port<HtmlDiscoveryMessage>, - url: Url, } trait NodeWrapping { @@ -350,6 +349,17 @@ pub fn parse_html(cx: *JSContext, let url2 = load_response.metadata.final_url.clone(); let url3 = url2.clone(); + // Store the final URL before we start parsing, so that DOM routines + // (e.g. HTMLImageElement::update_image) can resolve relative URLs + // correctly. + // + // FIXME: is this safe? When we instead pass an &mut Page to parse_html, + // we crash with a dynamic borrow failure. + let page = page_from_context(cx); + unsafe { + (*page).url = Some((url2.clone(), true)); + } + // Build the root node. let root = @HTMLHtmlElement { htmlelement: HTMLElement::new(HTMLHtmlElementTypeId, ~"html", document) }; let root = unsafe { Node::as_abstract_node(cx, root) }; @@ -595,7 +605,6 @@ pub fn parse_html(cx: *JSContext, HtmlParserResult { root: root, discovery_port: discovery_port, - url: load_response.metadata.final_url, } } diff --git a/src/components/script/script_task.rs b/src/components/script/script_task.rs index a9dbf66d18e..5966781a6dc 100644 --- a/src/components/script/script_task.rs +++ b/src/components/script/script_task.rs @@ -699,14 +699,13 @@ impl ScriptTask { self.constellation_chan.clone()); - let HtmlParserResult {root, discovery_port, url: final_url} = html_parsing_result; + let HtmlParserResult {root, discovery_port} = html_parsing_result; // Create the root frame. page.frame = Some(Frame { document: document, window: window, }); - page.url = Some((final_url, true)); // Send style sheets over to layout. // |