mirror of
https://github.com/servo/servo.git
synced 2025-08-06 14:10:11 +01:00
Rollup merge of #17014 - hiikezoe:animation-rules-in-norma-restyle, r=emilio,birtles
Animation rules in norma restyle <!-- Please describe your changes on the following line: --> This is a PR for https://bugzilla.mozilla.org/show_bug.cgi?id=1366631 and https://bugzilla.mozilla.org/show_bug.cgi?id=1367225 - [X] `./mach build -d` does not report any errors - [X] `./mach test-tidy` does not report any errors - [X] These changes do not require tests because it's for stylo <!-- Reviewable:start --> --- This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/17014) <!-- Reviewable:end -->
This commit is contained in:
commit
a19dd8142e
8 changed files with 231 additions and 149 deletions
|
@ -8,7 +8,7 @@
|
|||
|
||||
#[cfg(feature = "servo")]
|
||||
use heapsize::HeapSizeOf;
|
||||
use properties::{Importance, LonghandIdSet, PropertyDeclarationBlock};
|
||||
use properties::{AnimationRules, Importance, LonghandIdSet, PropertyDeclarationBlock};
|
||||
use shared_lock::{Locked, StylesheetGuards, SharedRwLockReadGuard};
|
||||
use smallvec::SmallVec;
|
||||
use std::io::{self, Write};
|
||||
|
@ -1142,6 +1142,56 @@ impl StrongRuleNode {
|
|||
}
|
||||
result
|
||||
}
|
||||
|
||||
/// Returns PropertyDeclarationBlock for this node.
|
||||
/// This function must be called only for animation level node.
|
||||
fn get_animation_style(&self) -> &Arc<Locked<PropertyDeclarationBlock>> {
|
||||
debug_assert!(self.cascade_level().is_animation(),
|
||||
"The cascade level should be an animation level");
|
||||
match *self.style_source().unwrap() {
|
||||
StyleSource::Declarations(ref block) => block,
|
||||
StyleSource::Style(_) => unreachable!("animating style should not be a style rule"),
|
||||
}
|
||||
}
|
||||
|
||||
/// Returns SMIL override declaration block if exists.
|
||||
pub fn get_smil_animation_rule(&self) -> Option<&Arc<Locked<PropertyDeclarationBlock>>> {
|
||||
if cfg!(feature = "servo") {
|
||||
// Servo has no knowledge of a SMIL rule, so just avoid looking for it.
|
||||
return None;
|
||||
}
|
||||
|
||||
self.self_and_ancestors()
|
||||
.take_while(|node| node.cascade_level() >= CascadeLevel::SMILOverride)
|
||||
.find(|node| node.cascade_level() == CascadeLevel::SMILOverride)
|
||||
.map(|node| node.get_animation_style())
|
||||
}
|
||||
|
||||
/// Returns AnimationRules that has processed during animation-only restyles.
|
||||
pub fn get_animation_rules(&self) -> AnimationRules {
|
||||
if cfg!(feature = "servo") {
|
||||
return AnimationRules(None, None);
|
||||
}
|
||||
|
||||
let mut animation = None;
|
||||
let mut transition = None;
|
||||
|
||||
for node in self.self_and_ancestors()
|
||||
.take_while(|node| node.cascade_level() >= CascadeLevel::Animations) {
|
||||
match node.cascade_level() {
|
||||
CascadeLevel::Animations => {
|
||||
debug_assert!(animation.is_none());
|
||||
animation = Some(node.get_animation_style())
|
||||
},
|
||||
CascadeLevel::Transitions => {
|
||||
debug_assert!(transition.is_none());
|
||||
transition = Some(node.get_animation_style())
|
||||
},
|
||||
_ => {},
|
||||
}
|
||||
}
|
||||
AnimationRules(animation, transition)
|
||||
}
|
||||
}
|
||||
|
||||
/// An iterator over a rule node and its ancestors.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue