Check ElementHasAnimations before trying to get animations rules.

In case of ::before and ::after element, the generated content has no
ElementHasAnimations flag, their parent has the flag.
This commit is contained in:
Hiroyuki Ikezoe 2017-05-24 11:12:09 +09:00
parent 4935d972e5
commit fce7c2d885
3 changed files with 24 additions and 12 deletions

View file

@ -506,6 +506,11 @@ pub trait TElement : Eq + PartialEq + Debug + Hash + Sized + Copy + Clone +
/// Returns true if the element has all the specified selector flags.
fn has_selector_flags(&self, flags: ElementSelectorFlags) -> bool;
/// In Gecko, element has a flag that represents the element may have
/// any type of animations or not to bail out animation stuff early.
/// Whereas Servo doesn't have such flag.
fn may_have_animations(&self) -> bool { false }
/// Creates a task to update various animation state on a given (pseudo-)element.
#[cfg(feature = "gecko")]
fn update_animations(&self,

View file

@ -422,11 +422,6 @@ impl<'le> GeckoElement<'le> {
}
}
#[inline]
fn may_have_animations(&self) -> bool {
self.as_node().get_bool_flag(nsINode_BooleanFlag::ElementHasAnimations)
}
#[inline]
fn has_id(&self) -> bool {
self.as_node().get_bool_flag(nsINode_BooleanFlag::ElementHasID)
@ -777,6 +772,11 @@ impl<'le> TElement for GeckoElement<'le> {
(self.flags() & node_flags) == node_flags
}
#[inline]
fn may_have_animations(&self) -> bool {
self.as_node().get_bool_flag(nsINode_BooleanFlag::ElementHasAnimations)
}
fn update_animations(&self,
before_change_style: Option<Arc<ComputedValues>>,
tasks: UpdateAnimationsTasks) {

View file

@ -254,12 +254,15 @@ trait PrivateMatchMethods: TElement {
// We could make that a bit better if the complexity cost is not too
// big, but given further restyles are posted directly to
// pseudo-elements, it doesn't seem worth the effort at a glance.
if pseudo.is_eager() && primary_style.rules.get_animation_rules().is_empty() {
if pseudo.is_eager() {
let parent = self.parent_element().unwrap();
let parent_data = parent.borrow_data().unwrap();
let pseudo_style =
parent_data.styles().pseudos.get(&pseudo).unwrap();
return pseudo_style.values().clone()
if !parent.may_have_animations() ||
primary_style.rules.get_animation_rules().is_empty() {
let parent_data = parent.borrow_data().unwrap();
let pseudo_style =
parent_data.styles().pseudos.get(&pseudo).unwrap();
return pseudo_style.values().clone()
}
}
}
@ -692,7 +695,7 @@ pub trait MatchMethods : TElement {
let pseudo_style =
parent_data.styles().pseudos.get(&pseudo).unwrap();
let mut rules = pseudo_style.rules.clone();
{
if parent.may_have_animations() {
let animation_rules = data.get_animation_rules();
// Handle animations here.
@ -739,7 +742,11 @@ pub trait MatchMethods : TElement {
let style_attribute = self.style_attribute();
{
let smil_override = data.get_smil_override();
let animation_rules = data.get_animation_rules();
let animation_rules = if self.may_have_animations() {
data.get_animation_rules()
} else {
AnimationRules(None, None)
};
let bloom = context.thread_local.bloom_filter.filter();
let map = &mut context.thread_local.selector_flags;