mirror of
https://github.com/servo/servo.git
synced 2025-08-06 22:15:33 +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_Release
|
||||
);
|
||||
impl_locked_arc_ffi!(
|
||||
impl_simple_arc_ffi!(
|
||||
LayerBlockRule,
|
||||
LockedLayerBlockRule,
|
||||
Servo_LayerBlockRule_AddRef,
|
||||
Servo_LayerBlockRule_Release
|
||||
);
|
||||
impl_locked_arc_ffi!(
|
||||
impl_simple_arc_ffi!(
|
||||
LayerStatementRule,
|
||||
LockedLayerStatementRule,
|
||||
Servo_LayerStatementRule_AddRef,
|
||||
Servo_LayerStatementRule_Release
|
||||
);
|
||||
|
@ -96,15 +94,13 @@ impl_locked_arc_ffi!(
|
|||
Servo_MediaList_AddRef,
|
||||
Servo_MediaList_Release
|
||||
);
|
||||
impl_locked_arc_ffi!(
|
||||
impl_simple_arc_ffi!(
|
||||
MediaRule,
|
||||
LockedMediaRule,
|
||||
Servo_MediaRule_AddRef,
|
||||
Servo_MediaRule_Release
|
||||
);
|
||||
impl_locked_arc_ffi!(
|
||||
impl_simple_arc_ffi!(
|
||||
NamespaceRule,
|
||||
LockedNamespaceRule,
|
||||
Servo_NamespaceRule_AddRef,
|
||||
Servo_NamespaceRule_Release
|
||||
);
|
||||
|
@ -119,33 +115,28 @@ impl_simple_arc_ffi!(
|
|||
Servo_PropertyRule_AddRef,
|
||||
Servo_PropertyRule_Release
|
||||
);
|
||||
impl_locked_arc_ffi!(
|
||||
impl_simple_arc_ffi!(
|
||||
SupportsRule,
|
||||
LockedSupportsRule,
|
||||
Servo_SupportsRule_AddRef,
|
||||
Servo_SupportsRule_Release
|
||||
);
|
||||
impl_locked_arc_ffi!(
|
||||
impl_simple_arc_ffi!(
|
||||
ContainerRule,
|
||||
LockedContainerRule,
|
||||
Servo_ContainerRule_AddRef,
|
||||
Servo_ContainerRule_Release
|
||||
);
|
||||
impl_locked_arc_ffi!(
|
||||
impl_simple_arc_ffi!(
|
||||
DocumentRule,
|
||||
LockedDocumentRule,
|
||||
Servo_DocumentRule_AddRef,
|
||||
Servo_DocumentRule_Release
|
||||
);
|
||||
impl_locked_arc_ffi!(
|
||||
impl_simple_arc_ffi!(
|
||||
FontFeatureValuesRule,
|
||||
LockedFontFeatureValuesRule,
|
||||
Servo_FontFeatureValuesRule_AddRef,
|
||||
Servo_FontFeatureValuesRule_Release
|
||||
);
|
||||
impl_locked_arc_ffi!(
|
||||
impl_simple_arc_ffi!(
|
||||
FontPaletteValuesRule,
|
||||
LockedFontPaletteValuesRule,
|
||||
Servo_FontPaletteValuesRule_AddRef,
|
||||
Servo_FontPaletteValuesRule_Release
|
||||
);
|
||||
|
|
|
@ -226,14 +226,3 @@ impl ToCssWithGuard for LayerStatementRule {
|
|||
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 {
|
||||
// No Charset here, CSSCharsetRule has been removed from CSSOM
|
||||
// https://drafts.csswg.org/cssom/#changes-from-5-december-2013
|
||||
Namespace(Arc<Locked<NamespaceRule>>),
|
||||
Namespace(Arc<NamespaceRule>),
|
||||
Import(Arc<Locked<ImportRule>>),
|
||||
Style(Arc<Locked<StyleRule>>),
|
||||
Media(Arc<Locked<MediaRule>>),
|
||||
Container(Arc<Locked<ContainerRule>>),
|
||||
Media(Arc<MediaRule>),
|
||||
Container(Arc<ContainerRule>),
|
||||
FontFace(Arc<Locked<FontFaceRule>>),
|
||||
FontFeatureValues(Arc<Locked<FontFeatureValuesRule>>),
|
||||
FontPaletteValues(Arc<Locked<FontPaletteValuesRule>>),
|
||||
FontFeatureValues(Arc<FontFeatureValuesRule>),
|
||||
FontPaletteValues(Arc<FontPaletteValuesRule>),
|
||||
CounterStyle(Arc<Locked<CounterStyleRule>>),
|
||||
Viewport(Arc<Locked<ViewportRule>>),
|
||||
Viewport(Arc<ViewportRule>),
|
||||
Keyframes(Arc<Locked<KeyframesRule>>),
|
||||
Supports(Arc<Locked<SupportsRule>>),
|
||||
Supports(Arc<SupportsRule>),
|
||||
Page(Arc<Locked<PageRule>>),
|
||||
Property(Arc<PropertyRule>),
|
||||
Document(Arc<Locked<DocumentRule>>),
|
||||
LayerBlock(Arc<Locked<LayerBlockRule>>),
|
||||
LayerStatement(Arc<Locked<LayerStatementRule>>),
|
||||
Document(Arc<DocumentRule>),
|
||||
LayerBlock(Arc<LayerBlockRule>),
|
||||
LayerStatement(Arc<LayerStatementRule>),
|
||||
}
|
||||
|
||||
impl CssRule {
|
||||
|
@ -285,36 +285,30 @@ impl CssRule {
|
|||
CssRule::Style(ref lock) => {
|
||||
lock.unconditional_shallow_size_of(ops) + lock.read_with(guard).size_of(guard, ops)
|
||||
},
|
||||
|
||||
CssRule::Media(ref lock) => {
|
||||
lock.unconditional_shallow_size_of(ops) + lock.read_with(guard).size_of(guard, ops)
|
||||
CssRule::Media(ref arc) => {
|
||||
arc.unconditional_shallow_size_of(ops) + arc.size_of(guard, ops)
|
||||
},
|
||||
|
||||
CssRule::Container(ref lock) => {
|
||||
lock.unconditional_shallow_size_of(ops) + lock.read_with(guard).size_of(guard, ops)
|
||||
CssRule::Container(ref arc) => {
|
||||
arc.unconditional_shallow_size_of(ops) + arc.size_of(guard, ops)
|
||||
},
|
||||
|
||||
CssRule::FontFace(_) => 0,
|
||||
CssRule::FontFeatureValues(_) => 0,
|
||||
CssRule::FontPaletteValues(_) => 0,
|
||||
CssRule::CounterStyle(_) => 0,
|
||||
CssRule::Viewport(_) => 0,
|
||||
CssRule::Keyframes(_) => 0,
|
||||
|
||||
CssRule::Supports(ref lock) => {
|
||||
lock.unconditional_shallow_size_of(ops) + lock.read_with(guard).size_of(guard, ops)
|
||||
CssRule::Supports(ref arc) => {
|
||||
arc.unconditional_shallow_size_of(ops) + arc.size_of(guard, ops)
|
||||
},
|
||||
|
||||
CssRule::Page(ref lock) => {
|
||||
lock.unconditional_shallow_size_of(ops) + lock.read_with(guard).size_of(guard, ops)
|
||||
},
|
||||
|
||||
CssRule::Property(ref rule) => rule.size_of(guard, ops),
|
||||
|
||||
CssRule::Document(ref lock) => {
|
||||
lock.unconditional_shallow_size_of(ops) + lock.read_with(guard).size_of(guard, ops)
|
||||
CssRule::Property(ref rule) => {
|
||||
rule.unconditional_shallow_size_of(ops) + rule.size_of(guard, ops)
|
||||
},
|
||||
CssRule::Document(ref arc) => {
|
||||
arc.unconditional_shallow_size_of(ops) + arc.size_of(guard, ops)
|
||||
},
|
||||
|
||||
// TODO(emilio): Add memory reporting for these rules.
|
||||
CssRule::LayerBlock(_) | CssRule::LayerStatement(_) => 0,
|
||||
}
|
||||
|
@ -488,8 +482,7 @@ impl DeepCloneWithLock for CssRule {
|
|||
) -> CssRule {
|
||||
match *self {
|
||||
CssRule::Namespace(ref arc) => {
|
||||
let rule = arc.read_with(guard);
|
||||
CssRule::Namespace(Arc::new(lock.wrap(rule.clone())))
|
||||
CssRule::Namespace(arc.clone())
|
||||
},
|
||||
CssRule::Import(ref arc) => {
|
||||
let rule = arc
|
||||
|
@ -504,36 +497,27 @@ impl DeepCloneWithLock for CssRule {
|
|||
))
|
||||
},
|
||||
CssRule::Container(ref arc) => {
|
||||
let rule = arc.read_with(guard);
|
||||
CssRule::Container(Arc::new(
|
||||
lock.wrap(rule.deep_clone_with_lock(lock, guard, params)),
|
||||
))
|
||||
CssRule::Container(Arc::new(arc.deep_clone_with_lock(lock, guard, params)))
|
||||
},
|
||||
CssRule::Media(ref arc) => {
|
||||
let rule = arc.read_with(guard);
|
||||
CssRule::Media(Arc::new(
|
||||
lock.wrap(rule.deep_clone_with_lock(lock, guard, params)),
|
||||
))
|
||||
CssRule::Media(Arc::new(arc.deep_clone_with_lock(lock, guard, params)))
|
||||
},
|
||||
CssRule::FontFace(ref arc) => {
|
||||
let rule = arc.read_with(guard);
|
||||
CssRule::FontFace(Arc::new(lock.wrap(rule.clone())))
|
||||
},
|
||||
CssRule::FontFeatureValues(ref arc) => {
|
||||
let rule = arc.read_with(guard);
|
||||
CssRule::FontFeatureValues(Arc::new(lock.wrap(rule.clone())))
|
||||
CssRule::FontFeatureValues(arc.clone())
|
||||
},
|
||||
CssRule::FontPaletteValues(ref arc) => {
|
||||
let rule = arc.read_with(guard);
|
||||
CssRule::FontPaletteValues(Arc::new(lock.wrap(rule.clone())))
|
||||
CssRule::FontPaletteValues(arc.clone())
|
||||
},
|
||||
CssRule::CounterStyle(ref arc) => {
|
||||
let rule = arc.read_with(guard);
|
||||
CssRule::CounterStyle(Arc::new(lock.wrap(rule.clone())))
|
||||
},
|
||||
CssRule::Viewport(ref arc) => {
|
||||
let rule = arc.read_with(guard);
|
||||
CssRule::Viewport(Arc::new(lock.wrap(rule.clone())))
|
||||
CssRule::Viewport(arc.clone())
|
||||
},
|
||||
CssRule::Keyframes(ref arc) => {
|
||||
let rule = arc.read_with(guard);
|
||||
|
@ -542,10 +526,7 @@ impl DeepCloneWithLock for CssRule {
|
|||
))
|
||||
},
|
||||
CssRule::Supports(ref arc) => {
|
||||
let rule = arc.read_with(guard);
|
||||
CssRule::Supports(Arc::new(
|
||||
lock.wrap(rule.deep_clone_with_lock(lock, guard, params)),
|
||||
))
|
||||
CssRule::Supports(Arc::new(arc.deep_clone_with_lock(lock, guard, params)))
|
||||
},
|
||||
CssRule::Page(ref arc) => {
|
||||
let rule = arc.read_with(guard);
|
||||
|
@ -559,22 +540,13 @@ impl DeepCloneWithLock for CssRule {
|
|||
CssRule::Property(arc.clone())
|
||||
},
|
||||
CssRule::Document(ref arc) => {
|
||||
let rule = arc.read_with(guard);
|
||||
CssRule::Document(Arc::new(
|
||||
lock.wrap(rule.deep_clone_with_lock(lock, guard, params)),
|
||||
))
|
||||
CssRule::Document(Arc::new(arc.deep_clone_with_lock(lock, guard, params)))
|
||||
},
|
||||
CssRule::LayerStatement(ref arc) => {
|
||||
let rule = arc.read_with(guard);
|
||||
CssRule::LayerStatement(Arc::new(
|
||||
lock.wrap(rule.deep_clone_with_lock(lock, guard, params)),
|
||||
))
|
||||
CssRule::LayerStatement(arc.clone())
|
||||
},
|
||||
CssRule::LayerBlock(ref arc) => {
|
||||
let rule = arc.read_with(guard);
|
||||
CssRule::LayerBlock(Arc::new(
|
||||
lock.wrap(rule.deep_clone_with_lock(lock, guard, params)),
|
||||
))
|
||||
CssRule::LayerBlock(Arc::new(arc.deep_clone_with_lock(lock, guard, params)))
|
||||
},
|
||||
}
|
||||
}
|
||||
|
@ -584,23 +556,23 @@ impl ToCssWithGuard for CssRule {
|
|||
// https://drafts.csswg.org/cssom/#serialize-a-css-rule
|
||||
fn to_css(&self, guard: &SharedRwLockReadGuard, dest: &mut CssStringWriter) -> fmt::Result {
|
||||
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::Style(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::FontPaletteValues(ref lock) => lock.read_with(guard).to_css(guard, dest),
|
||||
CssRule::FontFeatureValues(ref rule) => rule.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::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::Media(ref lock) => lock.read_with(guard).to_css(guard, dest),
|
||||
CssRule::Supports(ref lock) => lock.read_with(guard).to_css(guard, dest),
|
||||
CssRule::Media(ref rule) => rule.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::Property(ref rule) => rule.to_css(guard, dest),
|
||||
CssRule::Document(ref lock) => lock.read_with(guard).to_css(guard, dest),
|
||||
CssRule::LayerBlock(ref lock) => lock.read_with(guard).to_css(guard, dest),
|
||||
CssRule::LayerStatement(ref lock) => lock.read_with(guard).to_css(guard, dest),
|
||||
CssRule::Container(ref lock) => lock.read_with(guard).to_css(guard, dest),
|
||||
CssRule::Document(ref rule) => rule.to_css(guard, dest),
|
||||
CssRule::LayerBlock(ref rule) => rule.to_css(guard, dest),
|
||||
CssRule::LayerStatement(ref rule) => rule.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.rules
|
||||
.push(CssRule::Namespace(Arc::new(self.shared_lock.wrap(
|
||||
NamespaceRule {
|
||||
prefix,
|
||||
url,
|
||||
source_location: start.source_location(),
|
||||
},
|
||||
))));
|
||||
.push(CssRule::Namespace(Arc::new(NamespaceRule {
|
||||
prefix,
|
||||
url,
|
||||
source_location: start.source_location(),
|
||||
})));
|
||||
},
|
||||
AtRulePrelude::Layer(..) => {
|
||||
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) => {
|
||||
self.nest_for_rule(CssRuleType::FontFeatureValues, |p| {
|
||||
CssRule::FontFeatureValues(Arc::new(p.shared_lock.wrap(
|
||||
FontFeatureValuesRule::parse(
|
||||
&p.context,
|
||||
input,
|
||||
family_names,
|
||||
start.source_location(),
|
||||
),
|
||||
CssRule::FontFeatureValues(Arc::new(FontFeatureValuesRule::parse(
|
||||
&p.context,
|
||||
input,
|
||||
family_names,
|
||||
start.source_location(),
|
||||
)))
|
||||
})
|
||||
},
|
||||
AtRulePrelude::FontPaletteValues(name) => {
|
||||
self.nest_for_rule(CssRuleType::FontPaletteValues, |p| {
|
||||
CssRule::FontPaletteValues(Arc::new(p.shared_lock.wrap(
|
||||
FontPaletteValuesRule::parse(
|
||||
&p.context,
|
||||
input,
|
||||
name,
|
||||
start.source_location(),
|
||||
),
|
||||
CssRule::FontPaletteValues(Arc::new(FontPaletteValuesRule::parse(
|
||||
&p.context,
|
||||
input,
|
||||
name,
|
||||
start.source_location(),
|
||||
)))
|
||||
})
|
||||
},
|
||||
|
@ -667,36 +661,32 @@ impl<'a, 'b, 'i> AtRuleParser<'i> for NestedRuleParser<'a, 'b, 'i> {
|
|||
},
|
||||
AtRulePrelude::Media(media_queries) => {
|
||||
let source_location = start.source_location();
|
||||
CssRule::Media(Arc::new(
|
||||
self.shared_lock.wrap(MediaRule {
|
||||
media_queries,
|
||||
rules: self
|
||||
.parse_nested(input, CssRuleType::Media, None)
|
||||
.into_rules(self.shared_lock, source_location),
|
||||
source_location,
|
||||
}),
|
||||
))
|
||||
CssRule::Media(Arc::new(MediaRule {
|
||||
media_queries,
|
||||
rules: self
|
||||
.parse_nested(input, CssRuleType::Media, None)
|
||||
.into_rules(self.shared_lock, source_location),
|
||||
source_location,
|
||||
}))
|
||||
},
|
||||
AtRulePrelude::Supports(condition) => {
|
||||
let enabled =
|
||||
self.nest_for_rule(CssRuleType::Style, |p| condition.eval(&p.context));
|
||||
let source_location = start.source_location();
|
||||
CssRule::Supports(Arc::new(
|
||||
self.shared_lock.wrap(SupportsRule {
|
||||
condition,
|
||||
rules: self
|
||||
.parse_nested(input, CssRuleType::Supports, None)
|
||||
.into_rules(self.shared_lock, source_location),
|
||||
enabled,
|
||||
source_location,
|
||||
}),
|
||||
))
|
||||
CssRule::Supports(Arc::new(SupportsRule {
|
||||
condition,
|
||||
rules: self
|
||||
.parse_nested(input, CssRuleType::Supports, None)
|
||||
.into_rules(self.shared_lock, source_location),
|
||||
enabled,
|
||||
source_location,
|
||||
}))
|
||||
},
|
||||
AtRulePrelude::Viewport => {
|
||||
let body = self.nest_for_rule(CssRuleType::Viewport, |p| {
|
||||
ViewportRule::parse(&p.context, input)
|
||||
})?;
|
||||
CssRule::Viewport(Arc::new(self.shared_lock.wrap(body)))
|
||||
CssRule::Viewport(Arc::new(body))
|
||||
},
|
||||
AtRulePrelude::Keyframes(name, vendor_prefix) => {
|
||||
self.nest_for_rule(CssRuleType::Keyframe, |p| {
|
||||
|
@ -732,27 +722,23 @@ impl<'a, 'b, 'i> AtRuleParser<'i> for NestedRuleParser<'a, 'b, 'i> {
|
|||
unreachable!()
|
||||
}
|
||||
let source_location = start.source_location();
|
||||
CssRule::Document(Arc::new(
|
||||
self.shared_lock.wrap(DocumentRule {
|
||||
condition,
|
||||
rules: self
|
||||
.parse_nested(input, CssRuleType::Document, None)
|
||||
.into_rules(self.shared_lock, source_location),
|
||||
source_location,
|
||||
}),
|
||||
))
|
||||
CssRule::Document(Arc::new(DocumentRule {
|
||||
condition,
|
||||
rules: self
|
||||
.parse_nested(input, CssRuleType::Document, None)
|
||||
.into_rules(self.shared_lock, source_location),
|
||||
source_location,
|
||||
}))
|
||||
},
|
||||
AtRulePrelude::Container(condition) => {
|
||||
let source_location = start.source_location();
|
||||
CssRule::Container(Arc::new(
|
||||
self.shared_lock.wrap(ContainerRule {
|
||||
condition,
|
||||
rules: self
|
||||
.parse_nested(input, CssRuleType::Container, None)
|
||||
.into_rules(self.shared_lock, source_location),
|
||||
source_location,
|
||||
}),
|
||||
))
|
||||
CssRule::Container(Arc::new(ContainerRule {
|
||||
condition,
|
||||
rules: self
|
||||
.parse_nested(input, CssRuleType::Container, None)
|
||||
.into_rules(self.shared_lock, source_location),
|
||||
source_location,
|
||||
}))
|
||||
},
|
||||
AtRulePrelude::Layer(names) => {
|
||||
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)),
|
||||
};
|
||||
let source_location = start.source_location();
|
||||
CssRule::LayerBlock(Arc::new(
|
||||
self.shared_lock.wrap(LayerBlockRule {
|
||||
name,
|
||||
rules: self
|
||||
.parse_nested(input, CssRuleType::LayerBlock, None)
|
||||
.into_rules(self.shared_lock, source_location),
|
||||
source_location,
|
||||
}),
|
||||
))
|
||||
CssRule::LayerBlock(Arc::new(LayerBlockRule {
|
||||
name,
|
||||
rules: self
|
||||
.parse_nested(input, CssRuleType::LayerBlock, None)
|
||||
.into_rules(self.shared_lock, source_location),
|
||||
source_location,
|
||||
}))
|
||||
},
|
||||
AtRulePrelude::Import(..) | AtRulePrelude::Namespace(..) => {
|
||||
// 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() {
|
||||
return Err(());
|
||||
}
|
||||
CssRule::LayerStatement(Arc::new(self.shared_lock.wrap(LayerStatementRule {
|
||||
CssRule::LayerStatement(Arc::new(LayerStatementRule {
|
||||
names,
|
||||
source_location: start.source_location(),
|
||||
})))
|
||||
}))
|
||||
},
|
||||
_ => return Err(()),
|
||||
};
|
||||
|
|
|
@ -85,35 +85,30 @@ where
|
|||
Some(import_rule.stylesheet.rules(guard).iter())
|
||||
},
|
||||
CssRule::Document(ref doc_rule) => {
|
||||
let doc_rule = doc_rule.read_with(guard);
|
||||
if !C::process_document(guard, device, quirks_mode, doc_rule) {
|
||||
*effective = false;
|
||||
return None;
|
||||
}
|
||||
Some(doc_rule.rules.read_with(guard).0.iter())
|
||||
},
|
||||
CssRule::Container(ref lock) => {
|
||||
let container_rule = lock.read_with(guard);
|
||||
CssRule::Container(ref container_rule) => {
|
||||
Some(container_rule.rules.read_with(guard).0.iter())
|
||||
},
|
||||
CssRule::Media(ref lock) => {
|
||||
let media_rule = lock.read_with(guard);
|
||||
CssRule::Media(ref media_rule) => {
|
||||
if !C::process_media(guard, device, quirks_mode, media_rule) {
|
||||
*effective = false;
|
||||
return None;
|
||||
}
|
||||
Some(media_rule.rules.read_with(guard).0.iter())
|
||||
},
|
||||
CssRule::Supports(ref lock) => {
|
||||
let supports_rule = lock.read_with(guard);
|
||||
CssRule::Supports(ref supports_rule) => {
|
||||
if !C::process_supports(guard, device, quirks_mode, supports_rule) {
|
||||
*effective = false;
|
||||
return None;
|
||||
}
|
||||
Some(supports_rule.rules.read_with(guard).0.iter())
|
||||
},
|
||||
CssRule::LayerBlock(ref lock) => {
|
||||
let layer_rule = lock.read_with(guard);
|
||||
CssRule::LayerBlock(ref layer_rule) => {
|
||||
Some(layer_rule.rules.read_with(guard).0.iter())
|
||||
},
|
||||
}
|
||||
|
@ -218,15 +213,12 @@ impl EffectiveRules {
|
|||
Self::process_import(guard, device, quirks_mode, import_rule)
|
||||
},
|
||||
CssRule::Document(ref doc_rule) => {
|
||||
let doc_rule = doc_rule.read_with(guard);
|
||||
Self::process_document(guard, device, quirks_mode, doc_rule)
|
||||
},
|
||||
CssRule::Media(ref lock) => {
|
||||
let media_rule = lock.read_with(guard);
|
||||
CssRule::Media(ref media_rule) => {
|
||||
Self::process_media(guard, device, quirks_mode, media_rule)
|
||||
},
|
||||
CssRule::Supports(ref lock) => {
|
||||
let supports_rule = lock.read_with(guard);
|
||||
CssRule::Supports(ref supports_rule) => {
|
||||
Self::process_supports(guard, device, quirks_mode, supports_rule)
|
||||
},
|
||||
_ => true,
|
||||
|
|
|
@ -218,8 +218,7 @@ macro_rules! rule_filter {
|
|||
use crate::stylesheets::CssRule;
|
||||
|
||||
for rule in self.effective_rules(device, guard) {
|
||||
if let CssRule::$variant(ref lock) = *rule {
|
||||
let rule = lock.read_with(guard);
|
||||
if let CssRule::$variant(ref rule) = *rule {
|
||||
f(&rule)
|
||||
}
|
||||
}
|
||||
|
@ -283,7 +282,6 @@ pub trait StylesheetInDocument: ::std::fmt::Debug {
|
|||
}
|
||||
|
||||
rule_filter! {
|
||||
effective_style_rules(Style => StyleRule),
|
||||
effective_font_face_rules(FontFace => FontFaceRule),
|
||||
effective_viewport_rules(Viewport => ViewportRule),
|
||||
}
|
||||
|
|
|
@ -1710,11 +1710,11 @@ pub struct ExtraStyleData {
|
|||
|
||||
/// A list of effective font-feature-values rules.
|
||||
#[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.
|
||||
#[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.
|
||||
#[cfg(feature = "gecko")]
|
||||
|
@ -1735,7 +1735,7 @@ impl ExtraStyleData {
|
|||
/// Add the given @font-feature-values rule.
|
||||
fn add_font_feature_values(
|
||||
&mut self,
|
||||
rule: &Arc<Locked<FontFeatureValuesRule>>,
|
||||
rule: &Arc<FontFeatureValuesRule>,
|
||||
layer: LayerId,
|
||||
) {
|
||||
self.font_feature_values.push(rule.clone(), layer);
|
||||
|
@ -1744,7 +1744,7 @@ impl ExtraStyleData {
|
|||
/// Add the given @font-palette-values rule.
|
||||
fn add_font_palette_values(
|
||||
&mut self,
|
||||
rule: &Arc<Locked<FontPaletteValuesRule>>,
|
||||
rule: &Arc<FontPaletteValuesRule>,
|
||||
layer: LayerId,
|
||||
) {
|
||||
self.font_palette_values.push(rule.clone(), layer);
|
||||
|
@ -2630,8 +2630,7 @@ impl CascadeData {
|
|||
debug!(" + {:?}", import_rule.stylesheet.media(guard));
|
||||
results.push(import_rule.to_media_list_key());
|
||||
},
|
||||
CssRule::Media(ref lock) => {
|
||||
let media_rule = lock.read_with(guard);
|
||||
CssRule::Media(ref media_rule) => {
|
||||
debug!(" + {:?}", media_rule.media_queries.read_with(guard));
|
||||
results.push(media_rule.to_media_list_key());
|
||||
},
|
||||
|
@ -2952,19 +2951,16 @@ impl CascadeData {
|
|||
ImportLayer::None => {},
|
||||
}
|
||||
},
|
||||
CssRule::Media(ref lock) => {
|
||||
CssRule::Media(ref media_rule) => {
|
||||
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) => {
|
||||
let layer_rule = lock.read_with(guard);
|
||||
maybe_register_layers(self, layer_rule.name.as_ref(), containing_rule_state);
|
||||
CssRule::LayerBlock(ref rule) => {
|
||||
maybe_register_layers(self, rule.name.as_ref(), containing_rule_state);
|
||||
},
|
||||
CssRule::LayerStatement(ref lock) => {
|
||||
let layer_rule = lock.read_with(guard);
|
||||
for name in &*layer_rule.names {
|
||||
CssRule::LayerStatement(ref rule) => {
|
||||
for name in &*rule.names {
|
||||
maybe_register_layers(self, Some(name), containing_rule_state);
|
||||
// Register each layer individually.
|
||||
containing_rule_state.restore(&saved_containing_rule_state);
|
||||
|
@ -2975,12 +2971,11 @@ impl CascadeData {
|
|||
containing_rule_state.ancestor_selector_lists.push(s);
|
||||
}
|
||||
}
|
||||
CssRule::Container(ref lock) => {
|
||||
let container_rule = lock.read_with(guard);
|
||||
CssRule::Container(ref rule) => {
|
||||
let id = ContainerConditionId(self.container_conditions.len() as u16);
|
||||
self.container_conditions.push(ContainerConditionReference {
|
||||
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;
|
||||
},
|
||||
|
@ -3124,12 +3119,11 @@ impl CascadeData {
|
|||
iter.skip_children();
|
||||
}
|
||||
},
|
||||
CssRule::Media(ref lock) => {
|
||||
let media_rule = lock.read_with(guard);
|
||||
CssRule::Media(ref media_rule) => {
|
||||
let mq = media_rule.media_queries.read_with(guard);
|
||||
let effective_now = mq.evaluate(device, quirks_mode);
|
||||
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 {
|
||||
debug!(
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue