mirror of
https://github.com/servo/servo.git
synced 2025-09-16 09:58:23 +01:00
stylo: Fix StyleSheetInner/Stylesheet mapping
The key of this patch is the split between Stylesheet and StylesheetContents. Gecko will use StylesheetContents, which maps to a ServoStyleSheetInner.
This commit is contained in:
parent
fd65ac8924
commit
1263075776
38 changed files with 3818 additions and 2931 deletions
|
@ -5,39 +5,25 @@
|
|||
//! The stylesheet loader is the abstraction used to trigger network requests
|
||||
//! for `@import` rules.
|
||||
|
||||
use cssparser::SourceLocation;
|
||||
use media_queries::MediaList;
|
||||
use shared_lock::Locked;
|
||||
use parser::ParserContext;
|
||||
use shared_lock::{Locked, SharedRwLock};
|
||||
use stylearc::Arc;
|
||||
use stylesheets::ImportRule;
|
||||
use stylesheets::import_rule::ImportRule;
|
||||
use values::specified::url::SpecifiedUrl;
|
||||
|
||||
/// The stylesheet loader is the abstraction used to trigger network requests
|
||||
/// for `@import` rules.
|
||||
pub trait StylesheetLoader {
|
||||
/// Request a stylesheet after parsing a given `@import` rule.
|
||||
///
|
||||
/// The called code is responsible to update the `stylesheet` rules field
|
||||
/// when the sheet is done loading.
|
||||
///
|
||||
/// The convoluted signature allows impls to look at MediaList and
|
||||
/// ImportRule before they’re locked, while keeping the trait object-safe.
|
||||
/// Request a stylesheet after parsing a given `@import` rule, and return
|
||||
/// the constructed `@import` rule.
|
||||
fn request_stylesheet(
|
||||
&self,
|
||||
url: SpecifiedUrl,
|
||||
location: SourceLocation,
|
||||
context: &ParserContext,
|
||||
lock: &SharedRwLock,
|
||||
media: Arc<Locked<MediaList>>,
|
||||
make_import: &mut FnMut(Arc<Locked<MediaList>>) -> ImportRule,
|
||||
make_arc: &mut FnMut(ImportRule) -> Arc<Locked<ImportRule>>,
|
||||
) -> Arc<Locked<ImportRule>>;
|
||||
}
|
||||
|
||||
/// A dummy loader that just creates the import rule with the empty stylesheet.
|
||||
pub struct NoOpLoader;
|
||||
|
||||
impl StylesheetLoader for NoOpLoader {
|
||||
fn request_stylesheet(
|
||||
&self,
|
||||
media: Arc<Locked<MediaList>>,
|
||||
make_import: &mut FnMut(Arc<Locked<MediaList>>) -> ImportRule,
|
||||
make_arc: &mut FnMut(ImportRule) -> Arc<Locked<ImportRule>>,
|
||||
) -> Arc<Locked<ImportRule>> {
|
||||
make_arc(make_import(media))
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue