Use final url for updating stylesheet from @import rule.

This commit is contained in:
Xidorn Quan 2017-04-03 21:17:14 +10:00
parent 37585309e9
commit 2628ebe612
4 changed files with 11 additions and 3 deletions

View file

@ -161,6 +161,7 @@ impl FetchResponseListener for StylesheetContext {
&data,
protocol_encoding_label,
Some(environment_encoding),
&final_url,
Some(&loader),
win.css_error_reporter());
}

View file

@ -74,12 +74,14 @@ impl Stylesheet {
bytes: &[u8],
protocol_encoding_label: Option<&str>,
environment_encoding: Option<EncodingRef>,
url_data: &UrlExtraData,
stylesheet_loader: Option<&StylesheetLoader>,
error_reporter: &ParseErrorReporter) {
let (string, _) = decode_stylesheet_bytes(
bytes, protocol_encoding_label, environment_encoding);
Self::update_from_str(existing,
&string,
url_data,
stylesheet_loader,
error_reporter)
}

View file

@ -595,11 +595,14 @@ impl Stylesheet {
/// Updates an empty stylesheet from a given string of text.
pub fn update_from_str(existing: &Stylesheet,
css: &str,
url_data: &UrlExtraData,
stylesheet_loader: Option<&StylesheetLoader>,
error_reporter: &ParseErrorReporter) {
let mut namespaces = Namespaces::default();
// FIXME: we really should update existing.url_data with the given url_data,
// otherwise newly inserted rule may not have the right base url.
let (rules, dirty_on_viewport_size_change) = Stylesheet::parse_rules(
css, &existing.url_data, existing.origin, &mut namespaces,
css, url_data, existing.origin, &mut namespaces,
&existing.shared_lock, stylesheet_loader, error_reporter,
);