mirror of
https://github.com/servo/servo.git
synced 2025-08-10 16:05:43 +01:00
Add Servo_GetProperties_Overriding_Animation.
We add one FFI, Servo_GetProperties_Overriding_Animation, which calls StrongRuleNode::get_properties_overriding_animations() to get a LonghandIdSet, which may override animation properties running on compositor.
This commit is contained in:
parent
f05491166f
commit
60e7a89d57
4 changed files with 95 additions and 3 deletions
|
@ -10,6 +10,7 @@ use gecko_bindings::structs::mozilla::css::URLValue;
|
|||
use gecko_bindings::structs::mozilla::Side;
|
||||
use gecko_bindings::structs::RawGeckoAnimationPropertySegment;
|
||||
use gecko_bindings::structs::RawGeckoComputedTiming;
|
||||
use gecko_bindings::structs::RawGeckoCSSPropertyIDList;
|
||||
use gecko_bindings::structs::RawGeckoDocument;
|
||||
use gecko_bindings::structs::RawGeckoElement;
|
||||
use gecko_bindings::structs::RawGeckoKeyframeList;
|
||||
|
@ -48,6 +49,7 @@ use gecko_bindings::structs::nsCSSCounterStyleRule;
|
|||
use gecko_bindings::structs::nsCSSFontFaceRule;
|
||||
use gecko_bindings::structs::nsCSSKeyword;
|
||||
use gecko_bindings::structs::nsCSSPropertyID;
|
||||
use gecko_bindings::structs::nsCSSPropertyIDSet;
|
||||
use gecko_bindings::structs::nsCSSShadowArray;
|
||||
use gecko_bindings::structs::nsCSSUnit;
|
||||
use gecko_bindings::structs::nsCSSValue;
|
||||
|
@ -316,6 +318,10 @@ pub type RawGeckoPresContextBorrowed<'a> = &'a RawGeckoPresContext;
|
|||
pub type RawGeckoPresContextBorrowedOrNull<'a> = Option<&'a RawGeckoPresContext>;
|
||||
pub type RawGeckoStyleAnimationListBorrowed<'a> = &'a RawGeckoStyleAnimationList;
|
||||
pub type RawGeckoStyleAnimationListBorrowedOrNull<'a> = Option<&'a RawGeckoStyleAnimationList>;
|
||||
pub type nsCSSPropertyIDSetBorrowed<'a> = &'a nsCSSPropertyIDSet;
|
||||
pub type nsCSSPropertyIDSetBorrowedOrNull<'a> = Option<&'a nsCSSPropertyIDSet>;
|
||||
pub type nsCSSPropertyIDSetBorrowedMut<'a> = &'a mut nsCSSPropertyIDSet;
|
||||
pub type nsCSSPropertyIDSetBorrowedMutOrNull<'a> = Option<&'a mut nsCSSPropertyIDSet>;
|
||||
pub type nsCSSValueBorrowed<'a> = &'a nsCSSValue;
|
||||
pub type nsCSSValueBorrowedOrNull<'a> = Option<&'a nsCSSValue>;
|
||||
pub type nsCSSValueBorrowedMut<'a> = &'a mut nsCSSValue;
|
||||
|
@ -352,6 +358,10 @@ pub type RawGeckoServoStyleRuleListBorrowed<'a> = &'a RawGeckoServoStyleRuleList
|
|||
pub type RawGeckoServoStyleRuleListBorrowedOrNull<'a> = Option<&'a RawGeckoServoStyleRuleList>;
|
||||
pub type RawGeckoServoStyleRuleListBorrowedMut<'a> = &'a mut RawGeckoServoStyleRuleList;
|
||||
pub type RawGeckoServoStyleRuleListBorrowedMutOrNull<'a> = Option<&'a mut RawGeckoServoStyleRuleList>;
|
||||
pub type RawGeckoCSSPropertyIDListBorrowed<'a> = &'a RawGeckoCSSPropertyIDList;
|
||||
pub type RawGeckoCSSPropertyIDListBorrowedOrNull<'a> = Option<&'a RawGeckoCSSPropertyIDList>;
|
||||
pub type RawGeckoCSSPropertyIDListBorrowedMut<'a> = &'a mut RawGeckoCSSPropertyIDList;
|
||||
pub type RawGeckoCSSPropertyIDListBorrowedMutOrNull<'a> = Option<&'a mut RawGeckoCSSPropertyIDList>;
|
||||
|
||||
extern "C" {
|
||||
pub fn Gecko_EnsureTArrayCapacity(aArray: *mut ::std::os::raw::c_void,
|
||||
|
@ -1363,6 +1373,10 @@ extern "C" {
|
|||
ident: *const u16,
|
||||
set_slow_selector: *mut bool) -> bool;
|
||||
}
|
||||
extern "C" {
|
||||
pub fn Gecko_AddPropertyToSet(arg1: nsCSSPropertyIDSetBorrowedMut,
|
||||
arg2: nsCSSPropertyID);
|
||||
}
|
||||
extern "C" {
|
||||
pub fn Gecko_Construct_Default_nsStyleFont(ptr: *mut nsStyleFont,
|
||||
pres_context:
|
||||
|
@ -2076,6 +2090,14 @@ extern "C" {
|
|||
pub fn Servo_Property_IsDiscreteAnimatable(property: nsCSSPropertyID)
|
||||
-> bool;
|
||||
}
|
||||
extern "C" {
|
||||
pub fn Servo_GetProperties_Overriding_Animation(arg1:
|
||||
RawGeckoElementBorrowed,
|
||||
arg2:
|
||||
RawGeckoCSSPropertyIDListBorrowed,
|
||||
arg3:
|
||||
nsCSSPropertyIDSetBorrowedMut);
|
||||
}
|
||||
extern "C" {
|
||||
pub fn Servo_AnimationValues_Interpolate(from:
|
||||
RawServoAnimationValueBorrowed,
|
||||
|
|
|
@ -954,7 +954,7 @@ impl PropertyId {
|
|||
}
|
||||
}
|
||||
|
||||
/// Returns a property id from Gecko's nsCSSPropertyID.
|
||||
/// Returns an nsCSSPropertyID.
|
||||
#[cfg(feature = "gecko")]
|
||||
#[allow(non_upper_case_globals)]
|
||||
pub fn to_nscsspropertyid(&self) -> Result<nsCSSPropertyID, ()> {
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
|
||||
#[cfg(feature = "servo")]
|
||||
use heapsize::HeapSizeOf;
|
||||
use properties::{Importance, PropertyDeclarationBlock};
|
||||
use properties::{Importance, LonghandIdSet, PropertyDeclarationBlock};
|
||||
use shared_lock::{Locked, StylesheetGuards, SharedRwLockReadGuard};
|
||||
use smallvec::SmallVec;
|
||||
use std::io::{self, Write};
|
||||
|
@ -1092,6 +1092,42 @@ impl StrongRuleNode {
|
|||
.take_while(|node| node.cascade_level() >= CascadeLevel::SMILOverride)
|
||||
.any(|node| node.cascade_level().is_animation())
|
||||
}
|
||||
|
||||
/// Get a set of properties whose CascadeLevel are higher than Animations but not equal to
|
||||
/// Transitions. If there are any custom properties, we set the boolean value of the returned
|
||||
/// tuple to true.
|
||||
pub fn get_properties_overriding_animations(&self, guards: &StylesheetGuards)
|
||||
-> (LonghandIdSet, bool) {
|
||||
use properties::PropertyDeclarationId;
|
||||
|
||||
// We want to iterate over cascade levels that override the animations level, i.e.
|
||||
// !important levels and the transitions level. However, we actually want to skip the
|
||||
// transitions level because although it is higher in the cascade than animations, when
|
||||
// both transitions and animations are present for a given element and property, transitions
|
||||
// are suppressed so that they don't actually override animations.
|
||||
let iter = self.self_and_ancestors()
|
||||
.skip_while(|node| node.cascade_level() == CascadeLevel::Transitions)
|
||||
.take_while(|node| node.cascade_level() > CascadeLevel::Animations);
|
||||
let mut result = (LonghandIdSet::new(), false);
|
||||
for node in iter {
|
||||
let style = node.style_source().unwrap();
|
||||
for &(ref decl, important) in style.read(node.cascade_level().guard(guards))
|
||||
.declarations()
|
||||
.iter() {
|
||||
// Although we are only iterating over cascade levels that override animations,
|
||||
// in a given property declaration block we can have a mixture of !important and
|
||||
// non-!important declarations but only the !important declarations actually
|
||||
// override animations.
|
||||
if important.important() {
|
||||
match decl.id() {
|
||||
PropertyDeclarationId::Longhand(id) => result.0.insert(id),
|
||||
PropertyDeclarationId::Custom(_) => result.1 = true
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
result
|
||||
}
|
||||
}
|
||||
|
||||
/// An iterator over a rule node and its ancestors.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue