mirror of
https://github.com/servo/servo.git
synced 2025-08-03 12:40:06 +01:00
style: Minor cleanup of our @page rule setup.
Actually, there's not so much we can improve right now, in the sense that: * We need the ::-moz-page-content pseudo-element to be able to set `display` on the page, since that's a style rule rather than a @page rule. We could get away without it. * Keeping the current code-path (slightly cleaned up) is less code, for now at least. We can have a separate code-path or what not that actually performs the @page rule selector-matching and what not if needed when we get to named pages or other page selectors. Selectors like :first should be pretty trivial to implement, actually. We make some paged mode anon boxes non-inheriting anon boxes. This allows us to share the styles and is generally nicer. They don't need to inherit from anywhere. We could remove the origin handling and don't look at UA rules or what not, but it seems pretty harmless to do that. We also fix the name of the pseudo-elements to match the capitalization. Differential Revision: https://phabricator.services.mozilla.com/D104772
This commit is contained in:
parent
75d6be45f2
commit
4cb0a781d1
1 changed files with 20 additions and 22 deletions
|
@ -669,7 +669,7 @@ impl Stylist {
|
|||
{
|
||||
debug_assert!(pseudo.is_precomputed());
|
||||
|
||||
let rule_node = self.rule_node_for_precomputed_pseudo(guards, pseudo, None);
|
||||
let rule_node = self.rule_node_for_precomputed_pseudo(guards, pseudo, vec![]);
|
||||
|
||||
self.precomputed_values_for_pseudo_with_rule_node::<E>(
|
||||
guards,
|
||||
|
@ -709,42 +709,40 @@ impl Stylist {
|
|||
)
|
||||
}
|
||||
|
||||
/// Returns the rule node for given precomputed pseudo-element.
|
||||
/// Returns the rule node for a given precomputed pseudo-element.
|
||||
///
|
||||
/// If we want to include extra declarations to this precomputed pseudo-element,
|
||||
/// we can provide a vector of ApplicableDeclarationBlock to extra_declarations
|
||||
/// argument. This is useful for providing extra @page rules.
|
||||
/// If we want to include extra declarations to this precomputed
|
||||
/// pseudo-element, we can provide a vector of ApplicableDeclarationBlocks
|
||||
/// to extra_declarations. This is useful for @page rules.
|
||||
pub fn rule_node_for_precomputed_pseudo(
|
||||
&self,
|
||||
guards: &StylesheetGuards,
|
||||
pseudo: &PseudoElement,
|
||||
extra_declarations: Option<Vec<ApplicableDeclarationBlock>>,
|
||||
mut extra_declarations: Vec<ApplicableDeclarationBlock>,
|
||||
) -> StrongRuleNode {
|
||||
let mut decl;
|
||||
let mut declarations_with_extra;
|
||||
let declarations = match self
|
||||
.cascade_data
|
||||
.user_agent
|
||||
.precomputed_pseudo_element_decls
|
||||
.get(pseudo)
|
||||
{
|
||||
Some(declarations) => match extra_declarations {
|
||||
Some(mut extra_decls) => {
|
||||
decl = declarations.clone();
|
||||
decl.append(&mut extra_decls);
|
||||
Some(&decl)
|
||||
},
|
||||
None => Some(declarations),
|
||||
Some(declarations) => {
|
||||
if !extra_declarations.is_empty() {
|
||||
declarations_with_extra = declarations.clone();
|
||||
declarations_with_extra.append(&mut extra_declarations);
|
||||
&*declarations_with_extra
|
||||
} else {
|
||||
&**declarations
|
||||
}
|
||||
},
|
||||
None => extra_declarations.as_ref(),
|
||||
None => &[],
|
||||
};
|
||||
|
||||
match declarations {
|
||||
Some(decls) => self.rule_tree.insert_ordered_rules_with_important(
|
||||
decls.into_iter().map(|a| a.clone().for_rule_tree()),
|
||||
guards,
|
||||
),
|
||||
None => self.rule_tree.root().clone(),
|
||||
}
|
||||
self.rule_tree.insert_ordered_rules_with_important(
|
||||
declarations.into_iter().map(|a| a.clone().for_rule_tree()),
|
||||
guards,
|
||||
)
|
||||
}
|
||||
|
||||
/// Returns the style for an anonymous box of the given type.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue