mirror of
https://github.com/servo/servo.git
synced 2025-08-07 06:25:32 +01:00
style: Use non-locked rules for all rule types that can
Anything that doesn't need interior mutability doesn't need Locked<> around it. Depends on D179059 Differential Revision: https://phabricator.services.mozilla.com/D179060
This commit is contained in:
parent
0aed54f636
commit
6728158188
7 changed files with 126 additions and 206 deletions
|
@ -78,15 +78,13 @@ impl_locked_arc_ffi!(
|
||||||
Servo_KeyframesRule_AddRef,
|
Servo_KeyframesRule_AddRef,
|
||||||
Servo_KeyframesRule_Release
|
Servo_KeyframesRule_Release
|
||||||
);
|
);
|
||||||
impl_locked_arc_ffi!(
|
impl_simple_arc_ffi!(
|
||||||
LayerBlockRule,
|
LayerBlockRule,
|
||||||
LockedLayerBlockRule,
|
|
||||||
Servo_LayerBlockRule_AddRef,
|
Servo_LayerBlockRule_AddRef,
|
||||||
Servo_LayerBlockRule_Release
|
Servo_LayerBlockRule_Release
|
||||||
);
|
);
|
||||||
impl_locked_arc_ffi!(
|
impl_simple_arc_ffi!(
|
||||||
LayerStatementRule,
|
LayerStatementRule,
|
||||||
LockedLayerStatementRule,
|
|
||||||
Servo_LayerStatementRule_AddRef,
|
Servo_LayerStatementRule_AddRef,
|
||||||
Servo_LayerStatementRule_Release
|
Servo_LayerStatementRule_Release
|
||||||
);
|
);
|
||||||
|
@ -96,15 +94,13 @@ impl_locked_arc_ffi!(
|
||||||
Servo_MediaList_AddRef,
|
Servo_MediaList_AddRef,
|
||||||
Servo_MediaList_Release
|
Servo_MediaList_Release
|
||||||
);
|
);
|
||||||
impl_locked_arc_ffi!(
|
impl_simple_arc_ffi!(
|
||||||
MediaRule,
|
MediaRule,
|
||||||
LockedMediaRule,
|
|
||||||
Servo_MediaRule_AddRef,
|
Servo_MediaRule_AddRef,
|
||||||
Servo_MediaRule_Release
|
Servo_MediaRule_Release
|
||||||
);
|
);
|
||||||
impl_locked_arc_ffi!(
|
impl_simple_arc_ffi!(
|
||||||
NamespaceRule,
|
NamespaceRule,
|
||||||
LockedNamespaceRule,
|
|
||||||
Servo_NamespaceRule_AddRef,
|
Servo_NamespaceRule_AddRef,
|
||||||
Servo_NamespaceRule_Release
|
Servo_NamespaceRule_Release
|
||||||
);
|
);
|
||||||
|
@ -119,33 +115,28 @@ impl_simple_arc_ffi!(
|
||||||
Servo_PropertyRule_AddRef,
|
Servo_PropertyRule_AddRef,
|
||||||
Servo_PropertyRule_Release
|
Servo_PropertyRule_Release
|
||||||
);
|
);
|
||||||
impl_locked_arc_ffi!(
|
impl_simple_arc_ffi!(
|
||||||
SupportsRule,
|
SupportsRule,
|
||||||
LockedSupportsRule,
|
|
||||||
Servo_SupportsRule_AddRef,
|
Servo_SupportsRule_AddRef,
|
||||||
Servo_SupportsRule_Release
|
Servo_SupportsRule_Release
|
||||||
);
|
);
|
||||||
impl_locked_arc_ffi!(
|
impl_simple_arc_ffi!(
|
||||||
ContainerRule,
|
ContainerRule,
|
||||||
LockedContainerRule,
|
|
||||||
Servo_ContainerRule_AddRef,
|
Servo_ContainerRule_AddRef,
|
||||||
Servo_ContainerRule_Release
|
Servo_ContainerRule_Release
|
||||||
);
|
);
|
||||||
impl_locked_arc_ffi!(
|
impl_simple_arc_ffi!(
|
||||||
DocumentRule,
|
DocumentRule,
|
||||||
LockedDocumentRule,
|
|
||||||
Servo_DocumentRule_AddRef,
|
Servo_DocumentRule_AddRef,
|
||||||
Servo_DocumentRule_Release
|
Servo_DocumentRule_Release
|
||||||
);
|
);
|
||||||
impl_locked_arc_ffi!(
|
impl_simple_arc_ffi!(
|
||||||
FontFeatureValuesRule,
|
FontFeatureValuesRule,
|
||||||
LockedFontFeatureValuesRule,
|
|
||||||
Servo_FontFeatureValuesRule_AddRef,
|
Servo_FontFeatureValuesRule_AddRef,
|
||||||
Servo_FontFeatureValuesRule_Release
|
Servo_FontFeatureValuesRule_Release
|
||||||
);
|
);
|
||||||
impl_locked_arc_ffi!(
|
impl_simple_arc_ffi!(
|
||||||
FontPaletteValuesRule,
|
FontPaletteValuesRule,
|
||||||
LockedFontPaletteValuesRule,
|
|
||||||
Servo_FontPaletteValuesRule_AddRef,
|
Servo_FontPaletteValuesRule_AddRef,
|
||||||
Servo_FontPaletteValuesRule_Release
|
Servo_FontPaletteValuesRule_Release
|
||||||
);
|
);
|
||||||
|
|
|
@ -226,14 +226,3 @@ impl ToCssWithGuard for LayerStatementRule {
|
||||||
writer.write_char(';')
|
writer.write_char(';')
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl DeepCloneWithLock for LayerStatementRule {
|
|
||||||
fn deep_clone_with_lock(
|
|
||||||
&self,
|
|
||||||
_: &SharedRwLock,
|
|
||||||
_: &SharedRwLockReadGuard,
|
|
||||||
_: &DeepCloneParams,
|
|
||||||
) -> Self {
|
|
||||||
self.clone()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
|
@ -250,23 +250,23 @@ impl Eq for UrlExtraData {}
|
||||||
pub enum CssRule {
|
pub enum CssRule {
|
||||||
// No Charset here, CSSCharsetRule has been removed from CSSOM
|
// No Charset here, CSSCharsetRule has been removed from CSSOM
|
||||||
// https://drafts.csswg.org/cssom/#changes-from-5-december-2013
|
// https://drafts.csswg.org/cssom/#changes-from-5-december-2013
|
||||||
Namespace(Arc<Locked<NamespaceRule>>),
|
Namespace(Arc<NamespaceRule>),
|
||||||
Import(Arc<Locked<ImportRule>>),
|
Import(Arc<Locked<ImportRule>>),
|
||||||
Style(Arc<Locked<StyleRule>>),
|
Style(Arc<Locked<StyleRule>>),
|
||||||
Media(Arc<Locked<MediaRule>>),
|
Media(Arc<MediaRule>),
|
||||||
Container(Arc<Locked<ContainerRule>>),
|
Container(Arc<ContainerRule>),
|
||||||
FontFace(Arc<Locked<FontFaceRule>>),
|
FontFace(Arc<Locked<FontFaceRule>>),
|
||||||
FontFeatureValues(Arc<Locked<FontFeatureValuesRule>>),
|
FontFeatureValues(Arc<FontFeatureValuesRule>),
|
||||||
FontPaletteValues(Arc<Locked<FontPaletteValuesRule>>),
|
FontPaletteValues(Arc<FontPaletteValuesRule>),
|
||||||
CounterStyle(Arc<Locked<CounterStyleRule>>),
|
CounterStyle(Arc<Locked<CounterStyleRule>>),
|
||||||
Viewport(Arc<Locked<ViewportRule>>),
|
Viewport(Arc<ViewportRule>),
|
||||||
Keyframes(Arc<Locked<KeyframesRule>>),
|
Keyframes(Arc<Locked<KeyframesRule>>),
|
||||||
Supports(Arc<Locked<SupportsRule>>),
|
Supports(Arc<SupportsRule>),
|
||||||
Page(Arc<Locked<PageRule>>),
|
Page(Arc<Locked<PageRule>>),
|
||||||
Property(Arc<PropertyRule>),
|
Property(Arc<PropertyRule>),
|
||||||
Document(Arc<Locked<DocumentRule>>),
|
Document(Arc<DocumentRule>),
|
||||||
LayerBlock(Arc<Locked<LayerBlockRule>>),
|
LayerBlock(Arc<LayerBlockRule>),
|
||||||
LayerStatement(Arc<Locked<LayerStatementRule>>),
|
LayerStatement(Arc<LayerStatementRule>),
|
||||||
}
|
}
|
||||||
|
|
||||||
impl CssRule {
|
impl CssRule {
|
||||||
|
@ -285,36 +285,30 @@ impl CssRule {
|
||||||
CssRule::Style(ref lock) => {
|
CssRule::Style(ref lock) => {
|
||||||
lock.unconditional_shallow_size_of(ops) + lock.read_with(guard).size_of(guard, ops)
|
lock.unconditional_shallow_size_of(ops) + lock.read_with(guard).size_of(guard, ops)
|
||||||
},
|
},
|
||||||
|
CssRule::Media(ref arc) => {
|
||||||
CssRule::Media(ref lock) => {
|
arc.unconditional_shallow_size_of(ops) + arc.size_of(guard, ops)
|
||||||
lock.unconditional_shallow_size_of(ops) + lock.read_with(guard).size_of(guard, ops)
|
|
||||||
},
|
},
|
||||||
|
CssRule::Container(ref arc) => {
|
||||||
CssRule::Container(ref lock) => {
|
arc.unconditional_shallow_size_of(ops) + arc.size_of(guard, ops)
|
||||||
lock.unconditional_shallow_size_of(ops) + lock.read_with(guard).size_of(guard, ops)
|
|
||||||
},
|
},
|
||||||
|
|
||||||
CssRule::FontFace(_) => 0,
|
CssRule::FontFace(_) => 0,
|
||||||
CssRule::FontFeatureValues(_) => 0,
|
CssRule::FontFeatureValues(_) => 0,
|
||||||
CssRule::FontPaletteValues(_) => 0,
|
CssRule::FontPaletteValues(_) => 0,
|
||||||
CssRule::CounterStyle(_) => 0,
|
CssRule::CounterStyle(_) => 0,
|
||||||
CssRule::Viewport(_) => 0,
|
CssRule::Viewport(_) => 0,
|
||||||
CssRule::Keyframes(_) => 0,
|
CssRule::Keyframes(_) => 0,
|
||||||
|
CssRule::Supports(ref arc) => {
|
||||||
CssRule::Supports(ref lock) => {
|
arc.unconditional_shallow_size_of(ops) + arc.size_of(guard, ops)
|
||||||
lock.unconditional_shallow_size_of(ops) + lock.read_with(guard).size_of(guard, ops)
|
|
||||||
},
|
},
|
||||||
|
|
||||||
CssRule::Page(ref lock) => {
|
CssRule::Page(ref lock) => {
|
||||||
lock.unconditional_shallow_size_of(ops) + lock.read_with(guard).size_of(guard, ops)
|
lock.unconditional_shallow_size_of(ops) + lock.read_with(guard).size_of(guard, ops)
|
||||||
},
|
},
|
||||||
|
CssRule::Property(ref rule) => {
|
||||||
CssRule::Property(ref rule) => rule.size_of(guard, ops),
|
rule.unconditional_shallow_size_of(ops) + rule.size_of(guard, ops)
|
||||||
|
},
|
||||||
CssRule::Document(ref lock) => {
|
CssRule::Document(ref arc) => {
|
||||||
lock.unconditional_shallow_size_of(ops) + lock.read_with(guard).size_of(guard, ops)
|
arc.unconditional_shallow_size_of(ops) + arc.size_of(guard, ops)
|
||||||
},
|
},
|
||||||
|
|
||||||
// TODO(emilio): Add memory reporting for these rules.
|
// TODO(emilio): Add memory reporting for these rules.
|
||||||
CssRule::LayerBlock(_) | CssRule::LayerStatement(_) => 0,
|
CssRule::LayerBlock(_) | CssRule::LayerStatement(_) => 0,
|
||||||
}
|
}
|
||||||
|
@ -488,8 +482,7 @@ impl DeepCloneWithLock for CssRule {
|
||||||
) -> CssRule {
|
) -> CssRule {
|
||||||
match *self {
|
match *self {
|
||||||
CssRule::Namespace(ref arc) => {
|
CssRule::Namespace(ref arc) => {
|
||||||
let rule = arc.read_with(guard);
|
CssRule::Namespace(arc.clone())
|
||||||
CssRule::Namespace(Arc::new(lock.wrap(rule.clone())))
|
|
||||||
},
|
},
|
||||||
CssRule::Import(ref arc) => {
|
CssRule::Import(ref arc) => {
|
||||||
let rule = arc
|
let rule = arc
|
||||||
|
@ -504,36 +497,27 @@ impl DeepCloneWithLock for CssRule {
|
||||||
))
|
))
|
||||||
},
|
},
|
||||||
CssRule::Container(ref arc) => {
|
CssRule::Container(ref arc) => {
|
||||||
let rule = arc.read_with(guard);
|
CssRule::Container(Arc::new(arc.deep_clone_with_lock(lock, guard, params)))
|
||||||
CssRule::Container(Arc::new(
|
|
||||||
lock.wrap(rule.deep_clone_with_lock(lock, guard, params)),
|
|
||||||
))
|
|
||||||
},
|
},
|
||||||
CssRule::Media(ref arc) => {
|
CssRule::Media(ref arc) => {
|
||||||
let rule = arc.read_with(guard);
|
CssRule::Media(Arc::new(arc.deep_clone_with_lock(lock, guard, params)))
|
||||||
CssRule::Media(Arc::new(
|
|
||||||
lock.wrap(rule.deep_clone_with_lock(lock, guard, params)),
|
|
||||||
))
|
|
||||||
},
|
},
|
||||||
CssRule::FontFace(ref arc) => {
|
CssRule::FontFace(ref arc) => {
|
||||||
let rule = arc.read_with(guard);
|
let rule = arc.read_with(guard);
|
||||||
CssRule::FontFace(Arc::new(lock.wrap(rule.clone())))
|
CssRule::FontFace(Arc::new(lock.wrap(rule.clone())))
|
||||||
},
|
},
|
||||||
CssRule::FontFeatureValues(ref arc) => {
|
CssRule::FontFeatureValues(ref arc) => {
|
||||||
let rule = arc.read_with(guard);
|
CssRule::FontFeatureValues(arc.clone())
|
||||||
CssRule::FontFeatureValues(Arc::new(lock.wrap(rule.clone())))
|
|
||||||
},
|
},
|
||||||
CssRule::FontPaletteValues(ref arc) => {
|
CssRule::FontPaletteValues(ref arc) => {
|
||||||
let rule = arc.read_with(guard);
|
CssRule::FontPaletteValues(arc.clone())
|
||||||
CssRule::FontPaletteValues(Arc::new(lock.wrap(rule.clone())))
|
|
||||||
},
|
},
|
||||||
CssRule::CounterStyle(ref arc) => {
|
CssRule::CounterStyle(ref arc) => {
|
||||||
let rule = arc.read_with(guard);
|
let rule = arc.read_with(guard);
|
||||||
CssRule::CounterStyle(Arc::new(lock.wrap(rule.clone())))
|
CssRule::CounterStyle(Arc::new(lock.wrap(rule.clone())))
|
||||||
},
|
},
|
||||||
CssRule::Viewport(ref arc) => {
|
CssRule::Viewport(ref arc) => {
|
||||||
let rule = arc.read_with(guard);
|
CssRule::Viewport(arc.clone())
|
||||||
CssRule::Viewport(Arc::new(lock.wrap(rule.clone())))
|
|
||||||
},
|
},
|
||||||
CssRule::Keyframes(ref arc) => {
|
CssRule::Keyframes(ref arc) => {
|
||||||
let rule = arc.read_with(guard);
|
let rule = arc.read_with(guard);
|
||||||
|
@ -542,10 +526,7 @@ impl DeepCloneWithLock for CssRule {
|
||||||
))
|
))
|
||||||
},
|
},
|
||||||
CssRule::Supports(ref arc) => {
|
CssRule::Supports(ref arc) => {
|
||||||
let rule = arc.read_with(guard);
|
CssRule::Supports(Arc::new(arc.deep_clone_with_lock(lock, guard, params)))
|
||||||
CssRule::Supports(Arc::new(
|
|
||||||
lock.wrap(rule.deep_clone_with_lock(lock, guard, params)),
|
|
||||||
))
|
|
||||||
},
|
},
|
||||||
CssRule::Page(ref arc) => {
|
CssRule::Page(ref arc) => {
|
||||||
let rule = arc.read_with(guard);
|
let rule = arc.read_with(guard);
|
||||||
|
@ -559,22 +540,13 @@ impl DeepCloneWithLock for CssRule {
|
||||||
CssRule::Property(arc.clone())
|
CssRule::Property(arc.clone())
|
||||||
},
|
},
|
||||||
CssRule::Document(ref arc) => {
|
CssRule::Document(ref arc) => {
|
||||||
let rule = arc.read_with(guard);
|
CssRule::Document(Arc::new(arc.deep_clone_with_lock(lock, guard, params)))
|
||||||
CssRule::Document(Arc::new(
|
|
||||||
lock.wrap(rule.deep_clone_with_lock(lock, guard, params)),
|
|
||||||
))
|
|
||||||
},
|
},
|
||||||
CssRule::LayerStatement(ref arc) => {
|
CssRule::LayerStatement(ref arc) => {
|
||||||
let rule = arc.read_with(guard);
|
CssRule::LayerStatement(arc.clone())
|
||||||
CssRule::LayerStatement(Arc::new(
|
|
||||||
lock.wrap(rule.deep_clone_with_lock(lock, guard, params)),
|
|
||||||
))
|
|
||||||
},
|
},
|
||||||
CssRule::LayerBlock(ref arc) => {
|
CssRule::LayerBlock(ref arc) => {
|
||||||
let rule = arc.read_with(guard);
|
CssRule::LayerBlock(Arc::new(arc.deep_clone_with_lock(lock, guard, params)))
|
||||||
CssRule::LayerBlock(Arc::new(
|
|
||||||
lock.wrap(rule.deep_clone_with_lock(lock, guard, params)),
|
|
||||||
))
|
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -584,23 +556,23 @@ impl ToCssWithGuard for CssRule {
|
||||||
// https://drafts.csswg.org/cssom/#serialize-a-css-rule
|
// https://drafts.csswg.org/cssom/#serialize-a-css-rule
|
||||||
fn to_css(&self, guard: &SharedRwLockReadGuard, dest: &mut CssStringWriter) -> fmt::Result {
|
fn to_css(&self, guard: &SharedRwLockReadGuard, dest: &mut CssStringWriter) -> fmt::Result {
|
||||||
match *self {
|
match *self {
|
||||||
CssRule::Namespace(ref lock) => lock.read_with(guard).to_css(guard, dest),
|
CssRule::Namespace(ref rule) => rule.to_css(guard, dest),
|
||||||
CssRule::Import(ref lock) => lock.read_with(guard).to_css(guard, dest),
|
CssRule::Import(ref lock) => lock.read_with(guard).to_css(guard, dest),
|
||||||
CssRule::Style(ref lock) => lock.read_with(guard).to_css(guard, dest),
|
CssRule::Style(ref lock) => lock.read_with(guard).to_css(guard, dest),
|
||||||
CssRule::FontFace(ref lock) => lock.read_with(guard).to_css(guard, dest),
|
CssRule::FontFace(ref lock) => lock.read_with(guard).to_css(guard, dest),
|
||||||
CssRule::FontFeatureValues(ref lock) => lock.read_with(guard).to_css(guard, dest),
|
CssRule::FontFeatureValues(ref rule) => rule.to_css(guard, dest),
|
||||||
CssRule::FontPaletteValues(ref lock) => lock.read_with(guard).to_css(guard, dest),
|
CssRule::FontPaletteValues(ref rule) => rule.to_css(guard, dest),
|
||||||
CssRule::CounterStyle(ref lock) => lock.read_with(guard).to_css(guard, dest),
|
CssRule::CounterStyle(ref lock) => lock.read_with(guard).to_css(guard, dest),
|
||||||
CssRule::Viewport(ref lock) => lock.read_with(guard).to_css(guard, dest),
|
CssRule::Viewport(ref rule) => rule.to_css(guard, dest),
|
||||||
CssRule::Keyframes(ref lock) => lock.read_with(guard).to_css(guard, dest),
|
CssRule::Keyframes(ref lock) => lock.read_with(guard).to_css(guard, dest),
|
||||||
CssRule::Media(ref lock) => lock.read_with(guard).to_css(guard, dest),
|
CssRule::Media(ref rule) => rule.to_css(guard, dest),
|
||||||
CssRule::Supports(ref lock) => lock.read_with(guard).to_css(guard, dest),
|
CssRule::Supports(ref rule) => rule.to_css(guard, dest),
|
||||||
CssRule::Page(ref lock) => lock.read_with(guard).to_css(guard, dest),
|
CssRule::Page(ref lock) => lock.read_with(guard).to_css(guard, dest),
|
||||||
CssRule::Property(ref rule) => rule.to_css(guard, dest),
|
CssRule::Property(ref rule) => rule.to_css(guard, dest),
|
||||||
CssRule::Document(ref lock) => lock.read_with(guard).to_css(guard, dest),
|
CssRule::Document(ref rule) => rule.to_css(guard, dest),
|
||||||
CssRule::LayerBlock(ref lock) => lock.read_with(guard).to_css(guard, dest),
|
CssRule::LayerBlock(ref rule) => rule.to_css(guard, dest),
|
||||||
CssRule::LayerStatement(ref lock) => lock.read_with(guard).to_css(guard, dest),
|
CssRule::LayerStatement(ref rule) => rule.to_css(guard, dest),
|
||||||
CssRule::Container(ref lock) => lock.read_with(guard).to_css(guard, dest),
|
CssRule::Container(ref rule) => rule.to_css(guard, dest),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -357,13 +357,11 @@ impl<'a, 'i> AtRuleParser<'i> for TopLevelRuleParser<'a, 'i> {
|
||||||
|
|
||||||
self.state = State::Namespaces;
|
self.state = State::Namespaces;
|
||||||
self.rules
|
self.rules
|
||||||
.push(CssRule::Namespace(Arc::new(self.shared_lock.wrap(
|
.push(CssRule::Namespace(Arc::new(NamespaceRule {
|
||||||
NamespaceRule {
|
prefix,
|
||||||
prefix,
|
url,
|
||||||
url,
|
source_location: start.source_location(),
|
||||||
source_location: start.source_location(),
|
})));
|
||||||
},
|
|
||||||
))));
|
|
||||||
},
|
},
|
||||||
AtRulePrelude::Layer(..) => {
|
AtRulePrelude::Layer(..) => {
|
||||||
AtRuleParser::rule_without_block(&mut self.nested(), prelude, start)?;
|
AtRuleParser::rule_without_block(&mut self.nested(), prelude, start)?;
|
||||||
|
@ -637,25 +635,21 @@ impl<'a, 'b, 'i> AtRuleParser<'i> for NestedRuleParser<'a, 'b, 'i> {
|
||||||
}),
|
}),
|
||||||
AtRulePrelude::FontFeatureValues(family_names) => {
|
AtRulePrelude::FontFeatureValues(family_names) => {
|
||||||
self.nest_for_rule(CssRuleType::FontFeatureValues, |p| {
|
self.nest_for_rule(CssRuleType::FontFeatureValues, |p| {
|
||||||
CssRule::FontFeatureValues(Arc::new(p.shared_lock.wrap(
|
CssRule::FontFeatureValues(Arc::new(FontFeatureValuesRule::parse(
|
||||||
FontFeatureValuesRule::parse(
|
&p.context,
|
||||||
&p.context,
|
input,
|
||||||
input,
|
family_names,
|
||||||
family_names,
|
start.source_location(),
|
||||||
start.source_location(),
|
|
||||||
),
|
|
||||||
)))
|
)))
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
AtRulePrelude::FontPaletteValues(name) => {
|
AtRulePrelude::FontPaletteValues(name) => {
|
||||||
self.nest_for_rule(CssRuleType::FontPaletteValues, |p| {
|
self.nest_for_rule(CssRuleType::FontPaletteValues, |p| {
|
||||||
CssRule::FontPaletteValues(Arc::new(p.shared_lock.wrap(
|
CssRule::FontPaletteValues(Arc::new(FontPaletteValuesRule::parse(
|
||||||
FontPaletteValuesRule::parse(
|
&p.context,
|
||||||
&p.context,
|
input,
|
||||||
input,
|
name,
|
||||||
name,
|
start.source_location(),
|
||||||
start.source_location(),
|
|
||||||
),
|
|
||||||
)))
|
)))
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
|
@ -667,36 +661,32 @@ impl<'a, 'b, 'i> AtRuleParser<'i> for NestedRuleParser<'a, 'b, 'i> {
|
||||||
},
|
},
|
||||||
AtRulePrelude::Media(media_queries) => {
|
AtRulePrelude::Media(media_queries) => {
|
||||||
let source_location = start.source_location();
|
let source_location = start.source_location();
|
||||||
CssRule::Media(Arc::new(
|
CssRule::Media(Arc::new(MediaRule {
|
||||||
self.shared_lock.wrap(MediaRule {
|
media_queries,
|
||||||
media_queries,
|
rules: self
|
||||||
rules: self
|
.parse_nested(input, CssRuleType::Media, None)
|
||||||
.parse_nested(input, CssRuleType::Media, None)
|
.into_rules(self.shared_lock, source_location),
|
||||||
.into_rules(self.shared_lock, source_location),
|
source_location,
|
||||||
source_location,
|
}))
|
||||||
}),
|
|
||||||
))
|
|
||||||
},
|
},
|
||||||
AtRulePrelude::Supports(condition) => {
|
AtRulePrelude::Supports(condition) => {
|
||||||
let enabled =
|
let enabled =
|
||||||
self.nest_for_rule(CssRuleType::Style, |p| condition.eval(&p.context));
|
self.nest_for_rule(CssRuleType::Style, |p| condition.eval(&p.context));
|
||||||
let source_location = start.source_location();
|
let source_location = start.source_location();
|
||||||
CssRule::Supports(Arc::new(
|
CssRule::Supports(Arc::new(SupportsRule {
|
||||||
self.shared_lock.wrap(SupportsRule {
|
condition,
|
||||||
condition,
|
rules: self
|
||||||
rules: self
|
.parse_nested(input, CssRuleType::Supports, None)
|
||||||
.parse_nested(input, CssRuleType::Supports, None)
|
.into_rules(self.shared_lock, source_location),
|
||||||
.into_rules(self.shared_lock, source_location),
|
enabled,
|
||||||
enabled,
|
source_location,
|
||||||
source_location,
|
}))
|
||||||
}),
|
|
||||||
))
|
|
||||||
},
|
},
|
||||||
AtRulePrelude::Viewport => {
|
AtRulePrelude::Viewport => {
|
||||||
let body = self.nest_for_rule(CssRuleType::Viewport, |p| {
|
let body = self.nest_for_rule(CssRuleType::Viewport, |p| {
|
||||||
ViewportRule::parse(&p.context, input)
|
ViewportRule::parse(&p.context, input)
|
||||||
})?;
|
})?;
|
||||||
CssRule::Viewport(Arc::new(self.shared_lock.wrap(body)))
|
CssRule::Viewport(Arc::new(body))
|
||||||
},
|
},
|
||||||
AtRulePrelude::Keyframes(name, vendor_prefix) => {
|
AtRulePrelude::Keyframes(name, vendor_prefix) => {
|
||||||
self.nest_for_rule(CssRuleType::Keyframe, |p| {
|
self.nest_for_rule(CssRuleType::Keyframe, |p| {
|
||||||
|
@ -732,27 +722,23 @@ impl<'a, 'b, 'i> AtRuleParser<'i> for NestedRuleParser<'a, 'b, 'i> {
|
||||||
unreachable!()
|
unreachable!()
|
||||||
}
|
}
|
||||||
let source_location = start.source_location();
|
let source_location = start.source_location();
|
||||||
CssRule::Document(Arc::new(
|
CssRule::Document(Arc::new(DocumentRule {
|
||||||
self.shared_lock.wrap(DocumentRule {
|
condition,
|
||||||
condition,
|
rules: self
|
||||||
rules: self
|
.parse_nested(input, CssRuleType::Document, None)
|
||||||
.parse_nested(input, CssRuleType::Document, None)
|
.into_rules(self.shared_lock, source_location),
|
||||||
.into_rules(self.shared_lock, source_location),
|
source_location,
|
||||||
source_location,
|
}))
|
||||||
}),
|
|
||||||
))
|
|
||||||
},
|
},
|
||||||
AtRulePrelude::Container(condition) => {
|
AtRulePrelude::Container(condition) => {
|
||||||
let source_location = start.source_location();
|
let source_location = start.source_location();
|
||||||
CssRule::Container(Arc::new(
|
CssRule::Container(Arc::new(ContainerRule {
|
||||||
self.shared_lock.wrap(ContainerRule {
|
condition,
|
||||||
condition,
|
rules: self
|
||||||
rules: self
|
.parse_nested(input, CssRuleType::Container, None)
|
||||||
.parse_nested(input, CssRuleType::Container, None)
|
.into_rules(self.shared_lock, source_location),
|
||||||
.into_rules(self.shared_lock, source_location),
|
source_location,
|
||||||
source_location,
|
}))
|
||||||
}),
|
|
||||||
))
|
|
||||||
},
|
},
|
||||||
AtRulePrelude::Layer(names) => {
|
AtRulePrelude::Layer(names) => {
|
||||||
let name = match names.len() {
|
let name = match names.len() {
|
||||||
|
@ -760,15 +746,13 @@ impl<'a, 'b, 'i> AtRuleParser<'i> for NestedRuleParser<'a, 'b, 'i> {
|
||||||
_ => return Err(input.new_error(BasicParseErrorKind::AtRuleBodyInvalid)),
|
_ => return Err(input.new_error(BasicParseErrorKind::AtRuleBodyInvalid)),
|
||||||
};
|
};
|
||||||
let source_location = start.source_location();
|
let source_location = start.source_location();
|
||||||
CssRule::LayerBlock(Arc::new(
|
CssRule::LayerBlock(Arc::new(LayerBlockRule {
|
||||||
self.shared_lock.wrap(LayerBlockRule {
|
name,
|
||||||
name,
|
rules: self
|
||||||
rules: self
|
.parse_nested(input, CssRuleType::LayerBlock, None)
|
||||||
.parse_nested(input, CssRuleType::LayerBlock, None)
|
.into_rules(self.shared_lock, source_location),
|
||||||
.into_rules(self.shared_lock, source_location),
|
source_location,
|
||||||
source_location,
|
}))
|
||||||
}),
|
|
||||||
))
|
|
||||||
},
|
},
|
||||||
AtRulePrelude::Import(..) | AtRulePrelude::Namespace(..) => {
|
AtRulePrelude::Import(..) | AtRulePrelude::Namespace(..) => {
|
||||||
// These rules don't have blocks.
|
// These rules don't have blocks.
|
||||||
|
@ -790,10 +774,10 @@ impl<'a, 'b, 'i> AtRuleParser<'i> for NestedRuleParser<'a, 'b, 'i> {
|
||||||
if names.is_empty() {
|
if names.is_empty() {
|
||||||
return Err(());
|
return Err(());
|
||||||
}
|
}
|
||||||
CssRule::LayerStatement(Arc::new(self.shared_lock.wrap(LayerStatementRule {
|
CssRule::LayerStatement(Arc::new(LayerStatementRule {
|
||||||
names,
|
names,
|
||||||
source_location: start.source_location(),
|
source_location: start.source_location(),
|
||||||
})))
|
}))
|
||||||
},
|
},
|
||||||
_ => return Err(()),
|
_ => return Err(()),
|
||||||
};
|
};
|
||||||
|
|
|
@ -85,35 +85,30 @@ where
|
||||||
Some(import_rule.stylesheet.rules(guard).iter())
|
Some(import_rule.stylesheet.rules(guard).iter())
|
||||||
},
|
},
|
||||||
CssRule::Document(ref doc_rule) => {
|
CssRule::Document(ref doc_rule) => {
|
||||||
let doc_rule = doc_rule.read_with(guard);
|
|
||||||
if !C::process_document(guard, device, quirks_mode, doc_rule) {
|
if !C::process_document(guard, device, quirks_mode, doc_rule) {
|
||||||
*effective = false;
|
*effective = false;
|
||||||
return None;
|
return None;
|
||||||
}
|
}
|
||||||
Some(doc_rule.rules.read_with(guard).0.iter())
|
Some(doc_rule.rules.read_with(guard).0.iter())
|
||||||
},
|
},
|
||||||
CssRule::Container(ref lock) => {
|
CssRule::Container(ref container_rule) => {
|
||||||
let container_rule = lock.read_with(guard);
|
|
||||||
Some(container_rule.rules.read_with(guard).0.iter())
|
Some(container_rule.rules.read_with(guard).0.iter())
|
||||||
},
|
},
|
||||||
CssRule::Media(ref lock) => {
|
CssRule::Media(ref media_rule) => {
|
||||||
let media_rule = lock.read_with(guard);
|
|
||||||
if !C::process_media(guard, device, quirks_mode, media_rule) {
|
if !C::process_media(guard, device, quirks_mode, media_rule) {
|
||||||
*effective = false;
|
*effective = false;
|
||||||
return None;
|
return None;
|
||||||
}
|
}
|
||||||
Some(media_rule.rules.read_with(guard).0.iter())
|
Some(media_rule.rules.read_with(guard).0.iter())
|
||||||
},
|
},
|
||||||
CssRule::Supports(ref lock) => {
|
CssRule::Supports(ref supports_rule) => {
|
||||||
let supports_rule = lock.read_with(guard);
|
|
||||||
if !C::process_supports(guard, device, quirks_mode, supports_rule) {
|
if !C::process_supports(guard, device, quirks_mode, supports_rule) {
|
||||||
*effective = false;
|
*effective = false;
|
||||||
return None;
|
return None;
|
||||||
}
|
}
|
||||||
Some(supports_rule.rules.read_with(guard).0.iter())
|
Some(supports_rule.rules.read_with(guard).0.iter())
|
||||||
},
|
},
|
||||||
CssRule::LayerBlock(ref lock) => {
|
CssRule::LayerBlock(ref layer_rule) => {
|
||||||
let layer_rule = lock.read_with(guard);
|
|
||||||
Some(layer_rule.rules.read_with(guard).0.iter())
|
Some(layer_rule.rules.read_with(guard).0.iter())
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
@ -218,15 +213,12 @@ impl EffectiveRules {
|
||||||
Self::process_import(guard, device, quirks_mode, import_rule)
|
Self::process_import(guard, device, quirks_mode, import_rule)
|
||||||
},
|
},
|
||||||
CssRule::Document(ref doc_rule) => {
|
CssRule::Document(ref doc_rule) => {
|
||||||
let doc_rule = doc_rule.read_with(guard);
|
|
||||||
Self::process_document(guard, device, quirks_mode, doc_rule)
|
Self::process_document(guard, device, quirks_mode, doc_rule)
|
||||||
},
|
},
|
||||||
CssRule::Media(ref lock) => {
|
CssRule::Media(ref media_rule) => {
|
||||||
let media_rule = lock.read_with(guard);
|
|
||||||
Self::process_media(guard, device, quirks_mode, media_rule)
|
Self::process_media(guard, device, quirks_mode, media_rule)
|
||||||
},
|
},
|
||||||
CssRule::Supports(ref lock) => {
|
CssRule::Supports(ref supports_rule) => {
|
||||||
let supports_rule = lock.read_with(guard);
|
|
||||||
Self::process_supports(guard, device, quirks_mode, supports_rule)
|
Self::process_supports(guard, device, quirks_mode, supports_rule)
|
||||||
},
|
},
|
||||||
_ => true,
|
_ => true,
|
||||||
|
|
|
@ -218,8 +218,7 @@ macro_rules! rule_filter {
|
||||||
use crate::stylesheets::CssRule;
|
use crate::stylesheets::CssRule;
|
||||||
|
|
||||||
for rule in self.effective_rules(device, guard) {
|
for rule in self.effective_rules(device, guard) {
|
||||||
if let CssRule::$variant(ref lock) = *rule {
|
if let CssRule::$variant(ref rule) = *rule {
|
||||||
let rule = lock.read_with(guard);
|
|
||||||
f(&rule)
|
f(&rule)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -283,7 +282,6 @@ pub trait StylesheetInDocument: ::std::fmt::Debug {
|
||||||
}
|
}
|
||||||
|
|
||||||
rule_filter! {
|
rule_filter! {
|
||||||
effective_style_rules(Style => StyleRule),
|
|
||||||
effective_font_face_rules(FontFace => FontFaceRule),
|
effective_font_face_rules(FontFace => FontFaceRule),
|
||||||
effective_viewport_rules(Viewport => ViewportRule),
|
effective_viewport_rules(Viewport => ViewportRule),
|
||||||
}
|
}
|
||||||
|
|
|
@ -1710,11 +1710,11 @@ pub struct ExtraStyleData {
|
||||||
|
|
||||||
/// A list of effective font-feature-values rules.
|
/// A list of effective font-feature-values rules.
|
||||||
#[cfg(feature = "gecko")]
|
#[cfg(feature = "gecko")]
|
||||||
pub font_feature_values: LayerOrderedVec<Arc<Locked<FontFeatureValuesRule>>>,
|
pub font_feature_values: LayerOrderedVec<Arc<FontFeatureValuesRule>>,
|
||||||
|
|
||||||
/// A list of effective font-palette-values rules.
|
/// A list of effective font-palette-values rules.
|
||||||
#[cfg(feature = "gecko")]
|
#[cfg(feature = "gecko")]
|
||||||
pub font_palette_values: LayerOrderedVec<Arc<Locked<FontPaletteValuesRule>>>,
|
pub font_palette_values: LayerOrderedVec<Arc<FontPaletteValuesRule>>,
|
||||||
|
|
||||||
/// A map of effective counter-style rules.
|
/// A map of effective counter-style rules.
|
||||||
#[cfg(feature = "gecko")]
|
#[cfg(feature = "gecko")]
|
||||||
|
@ -1735,7 +1735,7 @@ impl ExtraStyleData {
|
||||||
/// Add the given @font-feature-values rule.
|
/// Add the given @font-feature-values rule.
|
||||||
fn add_font_feature_values(
|
fn add_font_feature_values(
|
||||||
&mut self,
|
&mut self,
|
||||||
rule: &Arc<Locked<FontFeatureValuesRule>>,
|
rule: &Arc<FontFeatureValuesRule>,
|
||||||
layer: LayerId,
|
layer: LayerId,
|
||||||
) {
|
) {
|
||||||
self.font_feature_values.push(rule.clone(), layer);
|
self.font_feature_values.push(rule.clone(), layer);
|
||||||
|
@ -1744,7 +1744,7 @@ impl ExtraStyleData {
|
||||||
/// Add the given @font-palette-values rule.
|
/// Add the given @font-palette-values rule.
|
||||||
fn add_font_palette_values(
|
fn add_font_palette_values(
|
||||||
&mut self,
|
&mut self,
|
||||||
rule: &Arc<Locked<FontPaletteValuesRule>>,
|
rule: &Arc<FontPaletteValuesRule>,
|
||||||
layer: LayerId,
|
layer: LayerId,
|
||||||
) {
|
) {
|
||||||
self.font_palette_values.push(rule.clone(), layer);
|
self.font_palette_values.push(rule.clone(), layer);
|
||||||
|
@ -2630,8 +2630,7 @@ impl CascadeData {
|
||||||
debug!(" + {:?}", import_rule.stylesheet.media(guard));
|
debug!(" + {:?}", import_rule.stylesheet.media(guard));
|
||||||
results.push(import_rule.to_media_list_key());
|
results.push(import_rule.to_media_list_key());
|
||||||
},
|
},
|
||||||
CssRule::Media(ref lock) => {
|
CssRule::Media(ref media_rule) => {
|
||||||
let media_rule = lock.read_with(guard);
|
|
||||||
debug!(" + {:?}", media_rule.media_queries.read_with(guard));
|
debug!(" + {:?}", media_rule.media_queries.read_with(guard));
|
||||||
results.push(media_rule.to_media_list_key());
|
results.push(media_rule.to_media_list_key());
|
||||||
},
|
},
|
||||||
|
@ -2952,19 +2951,16 @@ impl CascadeData {
|
||||||
ImportLayer::None => {},
|
ImportLayer::None => {},
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
CssRule::Media(ref lock) => {
|
CssRule::Media(ref media_rule) => {
|
||||||
if rebuild_kind.should_rebuild_invalidation() {
|
if rebuild_kind.should_rebuild_invalidation() {
|
||||||
let media_rule = lock.read_with(guard);
|
self.effective_media_query_results.saw_effective(&**media_rule);
|
||||||
self.effective_media_query_results.saw_effective(media_rule);
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
CssRule::LayerBlock(ref lock) => {
|
CssRule::LayerBlock(ref rule) => {
|
||||||
let layer_rule = lock.read_with(guard);
|
maybe_register_layers(self, rule.name.as_ref(), containing_rule_state);
|
||||||
maybe_register_layers(self, layer_rule.name.as_ref(), containing_rule_state);
|
|
||||||
},
|
},
|
||||||
CssRule::LayerStatement(ref lock) => {
|
CssRule::LayerStatement(ref rule) => {
|
||||||
let layer_rule = lock.read_with(guard);
|
for name in &*rule.names {
|
||||||
for name in &*layer_rule.names {
|
|
||||||
maybe_register_layers(self, Some(name), containing_rule_state);
|
maybe_register_layers(self, Some(name), containing_rule_state);
|
||||||
// Register each layer individually.
|
// Register each layer individually.
|
||||||
containing_rule_state.restore(&saved_containing_rule_state);
|
containing_rule_state.restore(&saved_containing_rule_state);
|
||||||
|
@ -2975,12 +2971,11 @@ impl CascadeData {
|
||||||
containing_rule_state.ancestor_selector_lists.push(s);
|
containing_rule_state.ancestor_selector_lists.push(s);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
CssRule::Container(ref lock) => {
|
CssRule::Container(ref rule) => {
|
||||||
let container_rule = lock.read_with(guard);
|
|
||||||
let id = ContainerConditionId(self.container_conditions.len() as u16);
|
let id = ContainerConditionId(self.container_conditions.len() as u16);
|
||||||
self.container_conditions.push(ContainerConditionReference {
|
self.container_conditions.push(ContainerConditionReference {
|
||||||
parent: containing_rule_state.container_condition_id,
|
parent: containing_rule_state.container_condition_id,
|
||||||
condition: Some(container_rule.condition.clone()),
|
condition: Some(rule.condition.clone()),
|
||||||
});
|
});
|
||||||
containing_rule_state.container_condition_id = id;
|
containing_rule_state.container_condition_id = id;
|
||||||
},
|
},
|
||||||
|
@ -3124,12 +3119,11 @@ impl CascadeData {
|
||||||
iter.skip_children();
|
iter.skip_children();
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
CssRule::Media(ref lock) => {
|
CssRule::Media(ref media_rule) => {
|
||||||
let media_rule = lock.read_with(guard);
|
|
||||||
let mq = media_rule.media_queries.read_with(guard);
|
let mq = media_rule.media_queries.read_with(guard);
|
||||||
let effective_now = mq.evaluate(device, quirks_mode);
|
let effective_now = mq.evaluate(device, quirks_mode);
|
||||||
let effective_then =
|
let effective_then =
|
||||||
self.effective_media_query_results.was_effective(media_rule);
|
self.effective_media_query_results.was_effective(&**media_rule);
|
||||||
|
|
||||||
if effective_now != effective_then {
|
if effective_now != effective_then {
|
||||||
debug!(
|
debug!(
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue