mirror of
https://github.com/servo/servo.git
synced 2025-08-04 21:20:23 +01:00
Bug 1325878: Don't use nsMediaList for loading imports. r=xidorn
MozReview-Commit-ID: HR23bqZcmcA Signed-off-by: Emilio Cobos Álvarez <emilio@crisal.io>
This commit is contained in:
parent
fbd4049e46
commit
2999222436
3 changed files with 15 additions and 26 deletions
|
@ -271,15 +271,15 @@ impl<'a> StylesheetLoader<'a> {
|
||||||
impl<'a> StyleStylesheetLoader for StylesheetLoader<'a> {
|
impl<'a> StyleStylesheetLoader for StylesheetLoader<'a> {
|
||||||
fn request_stylesheet(
|
fn request_stylesheet(
|
||||||
&self,
|
&self,
|
||||||
media: MediaList,
|
media: Arc<Locked<MediaList>>,
|
||||||
make_import: &mut FnMut(MediaList) -> ImportRule,
|
make_import: &mut FnMut(Arc<Locked<MediaList>>) -> ImportRule,
|
||||||
make_arc: &mut FnMut(ImportRule) -> Arc<StyleLocked<ImportRule>>,
|
make_arc: &mut FnMut(ImportRule) -> Arc<StyleLocked<ImportRule>>,
|
||||||
) -> Arc<StyleLocked<ImportRule>> {
|
) -> Arc<StyleLocked<ImportRule>> {
|
||||||
let import = make_import(media);
|
let import = make_import(media);
|
||||||
let url = import.url.url().expect("Invalid urls shouldn't enter the loader").clone();
|
let url = import.url.url().expect("Invalid urls shouldn't enter the loader").clone();
|
||||||
|
|
||||||
//TODO (mrnayak) : Whether we should use the original loader's CORS setting?
|
// TODO (mrnayak) : Whether we should use the original loader's CORS
|
||||||
//Fix this when spec has more details.
|
// setting? Fix this when spec has more details.
|
||||||
let source = StylesheetContextSource::Import(import.stylesheet.clone());
|
let source = StylesheetContextSource::Import(import.stylesheet.clone());
|
||||||
self.load(source, url, None, "".to_owned());
|
self.load(source, url, None, "".to_owned());
|
||||||
|
|
||||||
|
|
|
@ -825,8 +825,8 @@ pub trait StylesheetLoader {
|
||||||
/// before they’re locked, while keeping the trait object-safe.
|
/// before they’re locked, while keeping the trait object-safe.
|
||||||
fn request_stylesheet(
|
fn request_stylesheet(
|
||||||
&self,
|
&self,
|
||||||
media: MediaList,
|
media: Arc<Locked<MediaList>>,
|
||||||
make_import: &mut FnMut(MediaList) -> ImportRule,
|
make_import: &mut FnMut(Arc<Locked<MediaList>>) -> ImportRule,
|
||||||
make_arc: &mut FnMut(ImportRule) -> Arc<Locked<ImportRule>>,
|
make_arc: &mut FnMut(ImportRule) -> Arc<Locked<ImportRule>>,
|
||||||
) -> Arc<Locked<ImportRule>>;
|
) -> Arc<Locked<ImportRule>>;
|
||||||
}
|
}
|
||||||
|
@ -836,8 +836,8 @@ struct NoOpLoader;
|
||||||
impl StylesheetLoader for NoOpLoader {
|
impl StylesheetLoader for NoOpLoader {
|
||||||
fn request_stylesheet(
|
fn request_stylesheet(
|
||||||
&self,
|
&self,
|
||||||
media: MediaList,
|
media: Arc<Locked<MediaList>>,
|
||||||
make_import: &mut FnMut(MediaList) -> ImportRule,
|
make_import: &mut FnMut(Arc<Locked<MediaList>>) -> ImportRule,
|
||||||
make_arc: &mut FnMut(ImportRule) -> Arc<Locked<ImportRule>>,
|
make_arc: &mut FnMut(ImportRule) -> Arc<Locked<ImportRule>>,
|
||||||
) -> Arc<Locked<ImportRule>> {
|
) -> Arc<Locked<ImportRule>> {
|
||||||
make_arc(make_import(media))
|
make_arc(make_import(media))
|
||||||
|
@ -906,6 +906,7 @@ impl<'a> AtRuleParser for TopLevelRuleParser<'a> {
|
||||||
let specified_url = SpecifiedUrl::parse_from_string(url_string, &self.context)?;
|
let specified_url = SpecifiedUrl::parse_from_string(url_string, &self.context)?;
|
||||||
|
|
||||||
let media = parse_media_query_list(&self.context, input);
|
let media = parse_media_query_list(&self.context, input);
|
||||||
|
let media = Arc::new(self.shared_lock.wrap(media));
|
||||||
|
|
||||||
let noop_loader = NoOpLoader;
|
let noop_loader = NoOpLoader;
|
||||||
let loader = if !specified_url.is_invalid() {
|
let loader = if !specified_url.is_invalid() {
|
||||||
|
@ -920,7 +921,7 @@ impl<'a> AtRuleParser for TopLevelRuleParser<'a> {
|
||||||
url: specified_url.take().unwrap(),
|
url: specified_url.take().unwrap(),
|
||||||
stylesheet: Arc::new(Stylesheet {
|
stylesheet: Arc::new(Stylesheet {
|
||||||
rules: CssRules::new(Vec::new(), self.shared_lock),
|
rules: CssRules::new(Vec::new(), self.shared_lock),
|
||||||
media: Arc::new(self.shared_lock.wrap(media)),
|
media: media,
|
||||||
shared_lock: self.shared_lock.clone(),
|
shared_lock: self.shared_lock.clone(),
|
||||||
origin: self.context.stylesheet_origin,
|
origin: self.context.stylesheet_origin,
|
||||||
url_data: self.context.url_data.clone(),
|
url_data: self.context.url_data.clone(),
|
||||||
|
|
|
@ -5,11 +5,10 @@
|
||||||
use std::sync::Arc;
|
use std::sync::Arc;
|
||||||
use style::gecko_bindings::bindings::Gecko_LoadStyleSheet;
|
use style::gecko_bindings::bindings::Gecko_LoadStyleSheet;
|
||||||
use style::gecko_bindings::structs::{Loader, ServoStyleSheet};
|
use style::gecko_bindings::structs::{Loader, ServoStyleSheet};
|
||||||
use style::gecko_bindings::sugar::ownership::HasArcFFI;
|
use style::gecko_bindings::sugar::ownership::{HasArcFFI, FFIArcHelpers};
|
||||||
use style::media_queries::MediaList;
|
use style::media_queries::MediaList;
|
||||||
use style::shared_lock::Locked;
|
use style::shared_lock::Locked;
|
||||||
use style::stylesheets::{ImportRule, Stylesheet, StylesheetLoader as StyleStylesheetLoader};
|
use style::stylesheets::{ImportRule, Stylesheet, StylesheetLoader as StyleStylesheetLoader};
|
||||||
use style_traits::ToCss;
|
|
||||||
|
|
||||||
pub struct StylesheetLoader(*mut Loader, *mut ServoStyleSheet);
|
pub struct StylesheetLoader(*mut Loader, *mut ServoStyleSheet);
|
||||||
|
|
||||||
|
@ -22,21 +21,11 @@ impl StylesheetLoader {
|
||||||
impl StyleStylesheetLoader for StylesheetLoader {
|
impl StyleStylesheetLoader for StylesheetLoader {
|
||||||
fn request_stylesheet(
|
fn request_stylesheet(
|
||||||
&self,
|
&self,
|
||||||
media: MediaList,
|
media: Arc<Locked<MediaList>>,
|
||||||
make_import: &mut FnMut(MediaList) -> ImportRule,
|
make_import: &mut FnMut(Arc<Locked<MediaList>>) -> ImportRule,
|
||||||
make_arc: &mut FnMut(ImportRule) -> Arc<Locked<ImportRule>>,
|
make_arc: &mut FnMut(ImportRule) -> Arc<Locked<ImportRule>>,
|
||||||
) -> Arc<Locked<ImportRule>> {
|
) -> Arc<Locked<ImportRule>> {
|
||||||
// TODO(emilio): We probably want to share media representation with
|
let import = make_import(media.clone());
|
||||||
// Gecko in Stylo.
|
|
||||||
//
|
|
||||||
// This also allows us to get rid of a bunch of extra work to evaluate
|
|
||||||
// and ensure parity, and shouldn't be much Gecko work given we always
|
|
||||||
// evaluate them on the main thread.
|
|
||||||
//
|
|
||||||
// Meanwhile, this works.
|
|
||||||
let media_string = media.to_css_string();
|
|
||||||
|
|
||||||
let import = make_import(media);
|
|
||||||
|
|
||||||
// After we get this raw pointer ImportRule will be moved into a lock and Arc
|
// After we get this raw pointer ImportRule will be moved into a lock and Arc
|
||||||
// and so the Arc<Url> pointer inside will also move,
|
// and so the Arc<Url> pointer inside will also move,
|
||||||
|
@ -52,8 +41,7 @@ impl StyleStylesheetLoader for StylesheetLoader {
|
||||||
base_url_data,
|
base_url_data,
|
||||||
spec_bytes,
|
spec_bytes,
|
||||||
spec_len as u32,
|
spec_len as u32,
|
||||||
media_string.as_bytes().as_ptr(),
|
media.into_strong())
|
||||||
media_string.len() as u32);
|
|
||||||
}
|
}
|
||||||
make_arc(import)
|
make_arc(import)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue