mirror of
https://github.com/servo/servo.git
synced 2025-08-11 08:25:32 +01:00
style: Add a StylesheetLoader abstraction, and make it a no-op on Geckolib.
Servo doesn't compile at this stage.
This commit is contained in:
parent
444fef164e
commit
a42cfae153
9 changed files with 62 additions and 6 deletions
|
@ -307,6 +307,7 @@ impl CssRule {
|
|||
let mut rule_parser = TopLevelRuleParser {
|
||||
stylesheet_origin: parent_stylesheet.origin,
|
||||
context: context,
|
||||
loader: None,
|
||||
state: Cell::new(state),
|
||||
namespaces: &mut namespaces,
|
||||
};
|
||||
|
@ -605,9 +606,20 @@ rule_filter! {
|
|||
effective_keyframes_rules(Keyframes => KeyframesRule),
|
||||
}
|
||||
|
||||
/// 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.
|
||||
fn request_stylesheet(&self, import: &Arc<RwLock<ImportRule>>);
|
||||
}
|
||||
|
||||
struct TopLevelRuleParser<'a> {
|
||||
stylesheet_origin: Origin,
|
||||
namespaces: &'a mut Namespaces,
|
||||
loader: Option<&'a StylesheetLoader>,
|
||||
context: ParserContext<'a>,
|
||||
state: Cell<State>,
|
||||
}
|
||||
|
@ -679,6 +691,12 @@ impl<'a> AtRuleParser for TopLevelRuleParser<'a> {
|
|||
}
|
||||
));
|
||||
|
||||
if is_valid_url {
|
||||
let loader = self.loader
|
||||
.expect("Expected a stylesheet loader for @import");
|
||||
loader.request_stylesheet(&import_rule);
|
||||
}
|
||||
|
||||
return Ok(AtRuleType::WithoutBlock(CssRule::Import(import_rule)))
|
||||
} else {
|
||||
self.state.set(State::Invalid);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue