mirror of
https://github.com/servo/servo.git
synced 2025-06-21 07:38:59 +01:00
Store the Page's final URL before parsing
We were parsing URLs like //bits.wikimedia.org/static-1.22wmf22/skins/vector/images/search-ltr.png?303-4 as local filenames because HTMLImageElement::update_image didn't have a current_url to pass to make_url().
This commit is contained in:
parent
da6c27c421
commit
cbcd04ffa8
2 changed files with 12 additions and 4 deletions
|
@ -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,
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -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.
|
||||
//
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue