mirror of
https://github.com/servo/servo.git
synced 2025-08-07 22:45:34 +01:00
Further changes required by Servo
This commit is contained in:
parent
1ac62a4ce8
commit
9ce567d7fe
3 changed files with 58 additions and 9 deletions
|
@ -107,18 +107,45 @@ impl DeepCloneWithLock for ImportSheet {
|
|||
/// A sheet that is held from an import rule.
|
||||
#[cfg(feature = "servo")]
|
||||
#[derive(Debug)]
|
||||
pub struct ImportSheet(pub ::servo_arc::Arc<crate::stylesheets::Stylesheet>);
|
||||
pub enum ImportSheet {
|
||||
/// A bonafide stylesheet.
|
||||
Sheet(::servo_arc::Arc<crate::stylesheets::Stylesheet>),
|
||||
|
||||
/// An @import created with a false <supports-condition>, so will never be fetched.
|
||||
Refused,
|
||||
}
|
||||
|
||||
#[cfg(feature = "servo")]
|
||||
impl ImportSheet {
|
||||
/// Creates a new ImportSheet from a stylesheet.
|
||||
pub fn new(sheet: ::servo_arc::Arc<crate::stylesheets::Stylesheet>) -> Self {
|
||||
ImportSheet::Sheet(sheet)
|
||||
}
|
||||
|
||||
/// Creates a refused ImportSheet for a load that will not happen.
|
||||
pub fn new_refused() -> Self {
|
||||
ImportSheet::Refused
|
||||
}
|
||||
|
||||
/// Returns a reference to the stylesheet in this ImportSheet, if it exists.
|
||||
pub fn as_sheet(&self) -> Option<&::servo_arc::Arc<crate::stylesheets::Stylesheet>> {
|
||||
match *self {
|
||||
ImportSheet::Sheet(ref s) => Some(s),
|
||||
ImportSheet::Refused => None,
|
||||
}
|
||||
}
|
||||
|
||||
/// Returns the media list for this import rule.
|
||||
pub fn media<'a>(&'a self, guard: &'a SharedRwLockReadGuard) -> Option<&'a MediaList> {
|
||||
self.0.media(guard)
|
||||
self.as_sheet().and_then(|s| s.media(guard))
|
||||
}
|
||||
|
||||
/// Returns the rules for this import rule.
|
||||
pub fn rules<'a>(&'a self, guard: &'a SharedRwLockReadGuard) -> &'a [CssRule] {
|
||||
self.0.rules(guard)
|
||||
match self.as_sheet() {
|
||||
Some(s) => s.rules(guard),
|
||||
None => &[],
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -130,9 +157,13 @@ impl DeepCloneWithLock for ImportSheet {
|
|||
_guard: &SharedRwLockReadGuard,
|
||||
_params: &DeepCloneParams,
|
||||
) -> Self {
|
||||
use servo_arc::Arc;
|
||||
|
||||
ImportSheet(Arc::new((&*self.0).clone()))
|
||||
match *self {
|
||||
ImportSheet::Sheet(ref s) => {
|
||||
use servo_arc::Arc;
|
||||
ImportSheet::Sheet(Arc::new((&**s).clone()))
|
||||
},
|
||||
ImportSheet::Refused => ImportSheet::Refused,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -241,7 +241,12 @@ impl<'a, 'i> AtRuleParser<'i> for TopLevelRuleParser<'a> {
|
|||
let url_string = input.expect_url_or_string()?.as_ref().to_owned();
|
||||
let url = CssUrl::parse_from_string(url_string, &self.context, CorsMode::None);
|
||||
|
||||
let supports = if !static_prefs::pref!("layout.css.import-supports.enabled") {
|
||||
#[cfg(feature = "gecko")]
|
||||
let supports_enabled = static_prefs::pref!("layout.css.import-supports.enabled");
|
||||
#[cfg(feature = "servo")]
|
||||
let supports_enabled = false;
|
||||
|
||||
let supports = if !supports_enabled {
|
||||
None
|
||||
} else {
|
||||
input.try_parse(SupportsCondition::parse_for_import).map(|condition| {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue