mirror of
https://github.com/servo/servo.git
synced 2025-07-24 15:50:21 +01:00
Use final url for updating stylesheet from @import rule.
This commit is contained in:
parent
37585309e9
commit
2628ebe612
4 changed files with 11 additions and 3 deletions
|
@ -161,6 +161,7 @@ impl FetchResponseListener for StylesheetContext {
|
||||||
&data,
|
&data,
|
||||||
protocol_encoding_label,
|
protocol_encoding_label,
|
||||||
Some(environment_encoding),
|
Some(environment_encoding),
|
||||||
|
&final_url,
|
||||||
Some(&loader),
|
Some(&loader),
|
||||||
win.css_error_reporter());
|
win.css_error_reporter());
|
||||||
}
|
}
|
||||||
|
|
|
@ -74,12 +74,14 @@ impl Stylesheet {
|
||||||
bytes: &[u8],
|
bytes: &[u8],
|
||||||
protocol_encoding_label: Option<&str>,
|
protocol_encoding_label: Option<&str>,
|
||||||
environment_encoding: Option<EncodingRef>,
|
environment_encoding: Option<EncodingRef>,
|
||||||
|
url_data: &UrlExtraData,
|
||||||
stylesheet_loader: Option<&StylesheetLoader>,
|
stylesheet_loader: Option<&StylesheetLoader>,
|
||||||
error_reporter: &ParseErrorReporter) {
|
error_reporter: &ParseErrorReporter) {
|
||||||
let (string, _) = decode_stylesheet_bytes(
|
let (string, _) = decode_stylesheet_bytes(
|
||||||
bytes, protocol_encoding_label, environment_encoding);
|
bytes, protocol_encoding_label, environment_encoding);
|
||||||
Self::update_from_str(existing,
|
Self::update_from_str(existing,
|
||||||
&string,
|
&string,
|
||||||
|
url_data,
|
||||||
stylesheet_loader,
|
stylesheet_loader,
|
||||||
error_reporter)
|
error_reporter)
|
||||||
}
|
}
|
||||||
|
|
|
@ -595,11 +595,14 @@ impl Stylesheet {
|
||||||
/// Updates an empty stylesheet from a given string of text.
|
/// Updates an empty stylesheet from a given string of text.
|
||||||
pub fn update_from_str(existing: &Stylesheet,
|
pub fn update_from_str(existing: &Stylesheet,
|
||||||
css: &str,
|
css: &str,
|
||||||
|
url_data: &UrlExtraData,
|
||||||
stylesheet_loader: Option<&StylesheetLoader>,
|
stylesheet_loader: Option<&StylesheetLoader>,
|
||||||
error_reporter: &ParseErrorReporter) {
|
error_reporter: &ParseErrorReporter) {
|
||||||
let mut namespaces = Namespaces::default();
|
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(
|
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,
|
&existing.shared_lock, stylesheet_loader, error_reporter,
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
|
@ -364,9 +364,10 @@ pub extern "C" fn Servo_StyleSheet_ClearAndUpdate(stylesheet: RawServoStyleSheet
|
||||||
loader: *mut Loader,
|
loader: *mut Loader,
|
||||||
gecko_stylesheet: *mut ServoStyleSheet,
|
gecko_stylesheet: *mut ServoStyleSheet,
|
||||||
data: *const nsACString,
|
data: *const nsACString,
|
||||||
_extra_data: *mut URLExtraData)
|
extra_data: *mut URLExtraData)
|
||||||
{
|
{
|
||||||
let input = unsafe { data.as_ref().unwrap().as_str_unchecked() };
|
let input = unsafe { data.as_ref().unwrap().as_str_unchecked() };
|
||||||
|
let url_data = unsafe { RefPtr::from_ptr_ref(&extra_data) };
|
||||||
|
|
||||||
let loader = if loader.is_null() {
|
let loader = if loader.is_null() {
|
||||||
None
|
None
|
||||||
|
@ -381,7 +382,8 @@ pub extern "C" fn Servo_StyleSheet_ClearAndUpdate(stylesheet: RawServoStyleSheet
|
||||||
};
|
};
|
||||||
|
|
||||||
let sheet = Stylesheet::as_arc(&stylesheet);
|
let sheet = Stylesheet::as_arc(&stylesheet);
|
||||||
Stylesheet::update_from_str(&sheet, input, loader, &StdoutErrorReporter);
|
Stylesheet::update_from_str(&sheet, input, url_data,
|
||||||
|
loader, &StdoutErrorReporter);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[no_mangle]
|
#[no_mangle]
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue