mirror of
https://github.com/servo/servo.git
synced 2025-08-07 06:25:32 +01:00
style: Factor out adding a rule in CascadeData::add_rule
This shouldn't have any behavior change, but is necessary because for cascade layers we are going to need to handle the child rules / sheets ourselves, in order to handle nested layers properly. Differential Revision: https://phabricator.services.mozilla.com/D124334
This commit is contained in:
parent
9822db5d3c
commit
9976f9a589
1 changed files with 183 additions and 157 deletions
|
@ -2125,10 +2125,11 @@ impl CascadeData {
|
|||
}
|
||||
}
|
||||
|
||||
// Returns Err(..) to signify OOM
|
||||
fn add_stylesheet<S>(
|
||||
#[inline]
|
||||
fn add_rule<S>(
|
||||
&mut self,
|
||||
device: &Device,
|
||||
rule: &CssRule,
|
||||
_device: &Device,
|
||||
quirks_mode: QuirksMode,
|
||||
stylesheet: &S,
|
||||
guard: &SharedRwLockReadGuard,
|
||||
|
@ -2138,18 +2139,6 @@ impl CascadeData {
|
|||
where
|
||||
S: StylesheetInDocument + 'static,
|
||||
{
|
||||
if !stylesheet.enabled() || !stylesheet.is_effective_for_device(device, guard) {
|
||||
return Ok(());
|
||||
}
|
||||
|
||||
let contents = stylesheet.contents();
|
||||
let origin = contents.origin;
|
||||
|
||||
if rebuild_kind.should_rebuild_invalidation() {
|
||||
self.effective_media_query_results.saw_effective(contents);
|
||||
}
|
||||
|
||||
for rule in stylesheet.effective_rules(device, guard) {
|
||||
match *rule {
|
||||
CssRule::Style(ref locked) => {
|
||||
let style_rule = locked.read_with(&guard);
|
||||
|
@ -2162,7 +2151,7 @@ impl CascadeData {
|
|||
if let Some(pseudo) = pseudo_element {
|
||||
if pseudo.is_precomputed() {
|
||||
debug_assert!(selector.is_universal());
|
||||
debug_assert!(matches!(origin, Origin::UserAgent));
|
||||
debug_assert_eq!(stylesheet.contents().origin, Origin::UserAgent);
|
||||
|
||||
precomputed_pseudo_element_decls
|
||||
.as_mut()
|
||||
|
@ -2306,6 +2295,43 @@ impl CascadeData {
|
|||
// We don't care about any other rule.
|
||||
_ => {},
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
|
||||
// Returns Err(..) to signify OOM
|
||||
fn add_stylesheet<S>(
|
||||
&mut self,
|
||||
device: &Device,
|
||||
quirks_mode: QuirksMode,
|
||||
stylesheet: &S,
|
||||
guard: &SharedRwLockReadGuard,
|
||||
rebuild_kind: SheetRebuildKind,
|
||||
mut precomputed_pseudo_element_decls: Option<&mut PrecomputedPseudoElementDeclarations>,
|
||||
) -> Result<(), FailedAllocationError>
|
||||
where
|
||||
S: StylesheetInDocument + 'static,
|
||||
{
|
||||
if !stylesheet.enabled() || !stylesheet.is_effective_for_device(device, guard) {
|
||||
return Ok(());
|
||||
}
|
||||
|
||||
let contents = stylesheet.contents();
|
||||
|
||||
if rebuild_kind.should_rebuild_invalidation() {
|
||||
self.effective_media_query_results.saw_effective(contents);
|
||||
}
|
||||
|
||||
|
||||
for rule in stylesheet.effective_rules(device, guard) {
|
||||
self.add_rule(
|
||||
rule,
|
||||
device,
|
||||
quirks_mode,
|
||||
stylesheet,
|
||||
guard,
|
||||
rebuild_kind,
|
||||
precomputed_pseudo_element_decls.as_deref_mut(),
|
||||
)?;
|
||||
}
|
||||
|
||||
Ok(())
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue