mirror of
https://github.com/servo/servo.git
synced 2025-08-05 21:50:18 +01:00
Bug 1317209 - Part 4: Put animation rule to cascade. r=emilio
We try to get the servo animation rule and declarations during elements matching, and put the rule to the right priority. Note: According to CSS Cascade Level spec, Animations is between Important author declarations and Normal override declarations.
This commit is contained in:
parent
c09b204d5d
commit
3a89e89952
2 changed files with 20 additions and 4 deletions
|
@ -589,12 +589,14 @@ pub trait MatchMethods : TElement {
|
||||||
let mut applicable_declarations: Vec<ApplicableDeclarationBlock> = Vec::with_capacity(16);
|
let mut applicable_declarations: Vec<ApplicableDeclarationBlock> = Vec::with_capacity(16);
|
||||||
let stylist = &context.shared.stylist;
|
let stylist = &context.shared.stylist;
|
||||||
let style_attribute = self.style_attribute();
|
let style_attribute = self.style_attribute();
|
||||||
|
let animation_rule = self.get_animation_rule(None);
|
||||||
|
|
||||||
// Compute the primary rule node.
|
// Compute the primary rule node.
|
||||||
let mut primary_relations =
|
let mut primary_relations =
|
||||||
stylist.push_applicable_declarations(self,
|
stylist.push_applicable_declarations(self,
|
||||||
parent_bf,
|
parent_bf,
|
||||||
style_attribute,
|
style_attribute,
|
||||||
|
animation_rule,
|
||||||
None,
|
None,
|
||||||
&mut applicable_declarations,
|
&mut applicable_declarations,
|
||||||
MatchingReason::ForStyling);
|
MatchingReason::ForStyling);
|
||||||
|
@ -604,7 +606,9 @@ pub trait MatchMethods : TElement {
|
||||||
let mut per_pseudo: PseudoRuleNodes = HashMap::with_hasher(Default::default());
|
let mut per_pseudo: PseudoRuleNodes = HashMap::with_hasher(Default::default());
|
||||||
SelectorImpl::each_eagerly_cascaded_pseudo_element(|pseudo| {
|
SelectorImpl::each_eagerly_cascaded_pseudo_element(|pseudo| {
|
||||||
debug_assert!(applicable_declarations.is_empty());
|
debug_assert!(applicable_declarations.is_empty());
|
||||||
|
let pseudo_animation_rule = self.get_animation_rule(Some(&pseudo));
|
||||||
stylist.push_applicable_declarations(self, parent_bf, None,
|
stylist.push_applicable_declarations(self, parent_bf, None,
|
||||||
|
pseudo_animation_rule,
|
||||||
Some(&pseudo.clone()),
|
Some(&pseudo.clone()),
|
||||||
&mut applicable_declarations,
|
&mut applicable_declarations,
|
||||||
MatchingReason::ForStyling);
|
MatchingReason::ForStyling);
|
||||||
|
|
|
@ -21,6 +21,7 @@ use rule_tree::{RuleTree, StrongRuleNode, StyleSource};
|
||||||
use selector_parser::{ElementExt, SelectorImpl, PseudoElement, Snapshot};
|
use selector_parser::{ElementExt, SelectorImpl, PseudoElement, Snapshot};
|
||||||
use selectors::Element;
|
use selectors::Element;
|
||||||
use selectors::bloom::BloomFilter;
|
use selectors::bloom::BloomFilter;
|
||||||
|
use selectors::matching::AFFECTED_BY_ANIMATIONS;
|
||||||
use selectors::matching::{AFFECTED_BY_STYLE_ATTRIBUTE, AFFECTED_BY_PRESENTATIONAL_HINTS};
|
use selectors::matching::{AFFECTED_BY_STYLE_ATTRIBUTE, AFFECTED_BY_PRESENTATIONAL_HINTS};
|
||||||
use selectors::matching::{MatchingReason, StyleRelations, matches_complex_selector};
|
use selectors::matching::{MatchingReason, StyleRelations, matches_complex_selector};
|
||||||
use selectors::parser::{Selector, SimpleSelector, LocalName as LocalNameSelector, ComplexSelector};
|
use selectors::parser::{Selector, SimpleSelector, LocalName as LocalNameSelector, ComplexSelector};
|
||||||
|
@ -384,6 +385,7 @@ impl Stylist {
|
||||||
let mut declarations = vec![];
|
let mut declarations = vec![];
|
||||||
|
|
||||||
self.push_applicable_declarations(element,
|
self.push_applicable_declarations(element,
|
||||||
|
None,
|
||||||
None,
|
None,
|
||||||
None,
|
None,
|
||||||
Some(pseudo),
|
Some(pseudo),
|
||||||
|
@ -490,6 +492,7 @@ impl Stylist {
|
||||||
element: &E,
|
element: &E,
|
||||||
parent_bf: Option<&BloomFilter>,
|
parent_bf: Option<&BloomFilter>,
|
||||||
style_attribute: Option<&Arc<RwLock<PropertyDeclarationBlock>>>,
|
style_attribute: Option<&Arc<RwLock<PropertyDeclarationBlock>>>,
|
||||||
|
animation_rule: Option<Arc<RwLock<PropertyDeclarationBlock>>>,
|
||||||
pseudo_element: Option<&PseudoElement>,
|
pseudo_element: Option<&PseudoElement>,
|
||||||
applicable_declarations: &mut V,
|
applicable_declarations: &mut V,
|
||||||
reason: MatchingReason) -> StyleRelations
|
reason: MatchingReason) -> StyleRelations
|
||||||
|
@ -560,7 +563,16 @@ impl Stylist {
|
||||||
|
|
||||||
debug!("style attr: {:?}", relations);
|
debug!("style attr: {:?}", relations);
|
||||||
|
|
||||||
// Step 5: Author-supplied `!important` rules.
|
// Step 5: Animations.
|
||||||
|
if let Some(anim) = animation_rule {
|
||||||
|
relations |= AFFECTED_BY_ANIMATIONS;
|
||||||
|
Push::push(
|
||||||
|
applicable_declarations,
|
||||||
|
ApplicableDeclarationBlock::from_declarations(anim.clone(), Importance::Normal));
|
||||||
|
}
|
||||||
|
debug!("animation: {:?}", relations);
|
||||||
|
|
||||||
|
// Step 6: Author-supplied `!important` rules.
|
||||||
map.author.get_all_matching_rules(element,
|
map.author.get_all_matching_rules(element,
|
||||||
parent_bf,
|
parent_bf,
|
||||||
applicable_declarations,
|
applicable_declarations,
|
||||||
|
@ -570,7 +582,7 @@ impl Stylist {
|
||||||
|
|
||||||
debug!("author important: {:?}", relations);
|
debug!("author important: {:?}", relations);
|
||||||
|
|
||||||
// Step 6: `!important` style attributes.
|
// Step 7: `!important` style attributes.
|
||||||
if let Some(sa) = style_attribute {
|
if let Some(sa) = style_attribute {
|
||||||
if sa.read().any_important() {
|
if sa.read().any_important() {
|
||||||
relations |= AFFECTED_BY_STYLE_ATTRIBUTE;
|
relations |= AFFECTED_BY_STYLE_ATTRIBUTE;
|
||||||
|
@ -582,7 +594,7 @@ impl Stylist {
|
||||||
|
|
||||||
debug!("style attr important: {:?}", relations);
|
debug!("style attr important: {:?}", relations);
|
||||||
|
|
||||||
// Step 7: User `!important` rules.
|
// Step 8: User `!important` rules.
|
||||||
map.user.get_all_matching_rules(element,
|
map.user.get_all_matching_rules(element,
|
||||||
parent_bf,
|
parent_bf,
|
||||||
applicable_declarations,
|
applicable_declarations,
|
||||||
|
@ -595,7 +607,7 @@ impl Stylist {
|
||||||
debug!("skipping non-agent rules");
|
debug!("skipping non-agent rules");
|
||||||
}
|
}
|
||||||
|
|
||||||
// Step 8: UA `!important` rules.
|
// Step 9: UA `!important` rules.
|
||||||
map.user_agent.get_all_matching_rules(element,
|
map.user_agent.get_all_matching_rules(element,
|
||||||
parent_bf,
|
parent_bf,
|
||||||
applicable_declarations,
|
applicable_declarations,
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue