Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 16 additions & 7 deletions style/matching.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@ use crate::dom::TElement;
#[cfg(feature = "servo")]
use crate::dom::TNode;
use crate::invalidation::element::restyle_hints::RestyleHint;
use crate::properties::longhands::display::computed_value::T as Display;
use crate::properties::ComputedValues;
use crate::properties::PropertyDeclarationBlock;
use crate::properties::longhands::display::computed_value::T as Display;
#[cfg(feature = "servo")]
use crate::rule_tree::RuleCascadeFlags;
use crate::rule_tree::{CascadeLevel, CascadeOrigin, StrongRuleNode};
Expand Down Expand Up @@ -1010,12 +1010,21 @@ pub trait MatchMethods: TElement {
mut new_styles: ResolvedElementStyles,
important_rules_changed: bool,
) -> RestyleHint {
self.process_animations(
context,
&mut data.styles,
&mut new_styles,
important_rules_changed,
);
#[cfg(feature = "servo")]
let update_animations = !context
.shared
.traversal_flags
.contains(TraversalFlags::SkipAnimationUpdates);
#[cfg(feature = "gecko")]
let update_animations = true;
if update_animations {
self.process_animations(
context,
&mut data.styles,
&mut new_styles,
important_rules_changed,
);
}

let root_font_relative_state_changed = new_styles.root_font_relative_state_changed();

Expand Down
28 changes: 26 additions & 2 deletions style/moli_declaration_block.rs
Original file line number Diff line number Diff line change
Expand Up @@ -546,8 +546,6 @@ mod tests {
fn parsed_values_match_declaration_block_serialization() {
with_detached_style_context(|context| {
for (name, value) in [
("all", "inherit"),
("all", "var(--shared, revert-layer)"),
("width", "var(--width, 2px)"),
("padding", "1px 2px 3px 4px"),
("margin", "var(--margin, 1px 2px)"),
Expand Down Expand Up @@ -576,6 +574,32 @@ mod tests {
});
}

#[test]
fn parsed_all_serializes_its_compact_value() {
with_detached_style_context(|context| {
// Expanding all into a block and reading it back runs two passes
// over enabled longhands. Other unit tests can enable preferences
// between those passes. Its own specified value is independent of
// which longhands are currently enabled.
for (value, unresolved) in [("inherit", false), ("var(--shared, revert-layer)", true)] {
for priority in [false, true] {
let parsed =
ParsedCssomProperty::parse("all", value, priority, context).unwrap();
assert_eq!(parsed.value().as_deref(), Some(value));
assert_eq!(parsed.has_unresolved_value(), unresolved);
assert_eq!(
parsed.entries().unwrap(),
[CssDeclarationEntry {
name: "all".to_owned(),
value: value.to_owned(),
priority,
}],
);
}
}
});
}

#[test]
fn parsed_property_names_use_the_resolved_property_and_preserve_custom_case() {
with_detached_style_context(|context| {
Expand Down
9 changes: 7 additions & 2 deletions style/traversal.rs
Original file line number Diff line number Diff line change
Expand Up @@ -377,7 +377,7 @@ pub fn recalc_style_at<E, D, F>(

// Compute style for this element if necessary.
if let Some(restyle_kind) = restyle_kind {
child_restyle_hint = compute_style(context, element, data, restyle_kind);
child_restyle_hint = restyle_element(context, element, data, restyle_kind);

if !element.matches_user_and_content_rules() {
// We must always cascade native anonymous subtrees, since they
Expand Down Expand Up @@ -483,7 +483,12 @@ where
}
}

fn compute_style<E>(
/// Apply the restyle kind selected by `ElementData::restyle_kind` to one element.
///
/// The caller resolves the element's ancestors first and sets the current DOM
/// depth for selector matching. The returned hint describes work for the
/// children. The caller owns hint propagation, traversal and damage consumption.
pub fn restyle_element<E>(
context: &mut StyleContext<E>,
element: E,
data: &mut ElementData,
Expand Down
4 changes: 4 additions & 0 deletions style/traversal_flags.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,10 @@ bitflags! {
/// unconditionally tick and process them.
const FlushThrottledAnimations = 1 << 8;

/// The embedder owns the animation timeline and resolves base styles here.
#[cfg(feature = "servo")]
const SkipAnimationUpdates = 1 << 9;

}
}

Expand Down
Loading