Truly independent web browser
LibWeb: Return keyframes for CSS animations and transitions
sideshowbarkere7af0e14b780
diff --git a/Libraries/LibWeb/Animations/KeyframeEffect.cpp b/Libraries/LibWeb/Animations/KeyframeEffect.cppindex f49f1c908f2..ca787894ebe 100644--- a/Libraries/LibWeb/Animations/KeyframeEffect.cpp+++ b/Libraries/LibWeb/Animations/KeyframeEffect.cpp@@ -6,6 +6,7 @@#include <AK/Atomic.h>#include <AK/Bitmap.h>+#include <AK/InsertionSort.h>#include <AK/QuickSort.h>#include <LibGC/Heap.h>#include <LibJS/Runtime/Iterator.h>@@ -14,12 +15,14 @@#include <LibWeb/Animations/KeyframeEffect.h>#include <LibWeb/Animations/PseudoElementParsing.h>#include <LibWeb/Bindings/KeyframeEffect.h>+#include <LibWeb/CSS/CSSAnimation.h>#include <LibWeb/CSS/ComputedStyleWorkingSet.h>#include <LibWeb/CSS/Parser/Parser.h>#include <LibWeb/CSS/PropertyID.h>#include <LibWeb/CSS/StyleComputer.h>#include <LibWeb/CSS/StyleEngineInput.h>#include <LibWeb/CSS/StyleValues/KeywordStyleValue.h>+#include <LibWeb/CSS/Zoom.h>#include <LibWeb/ComputedValuesRustFFI.h>#include <LibWeb/DOM/AbstractElement.h>#include <LibWeb/DOM/Document.h>@@ -620,15 +623,19 @@ void KeyframeEffect::generate_initial_and_final_frames(RefPtr<KeyFrameSet> keyfrinitial_keyframe = keyframe_set->keyframes_by_key.find(0);}- auto expanded_properties = [&](HashMap<CSS::PropertyNameAndID, Variant<KeyFrameSet::UseInitial, CSS::RustStyleValueHandle>>& properties) {+ auto expanded_properties_at_offset = [&](u64 offset) {HashTable<CSS::PropertyNameAndID> result;- for (auto property : properties) {- if (!property.key.is_custom_property() && property_is_shorthand(property.key.id())) {- for (auto longhand : expanded_longhands_for_shorthand(property.key.id()))- result.set(CSS::PropertyNameAndID::from_id(longhand));- } else {- result.set(property.key);+ for (auto it = keyframe_set->keyframes_by_key.begin(); it != keyframe_set->keyframes_by_key.end(); ++it) {+ if (it.key() != offset)+ continue;+ for (auto const& property : it->properties) {+ if (!property.key.is_custom_property() && property_is_shorthand(property.key.id())) {+ for (auto longhand : expanded_longhands_for_shorthand(property.key.id()))+ result.set(CSS::PropertyNameAndID::from_id(longhand));+ } else {+ result.set(property.key);+ }}}@@ -638,8 +645,9 @@ void KeyframeEffect::generate_initial_and_final_frames(RefPtr<KeyFrameSet> keyfr// 2. For any property in animated properties that is not otherwise present in a keyframe with an offset of// 0% or one that would be positioned earlier in the used keyframe order, add the computed value of that// property on element to initial keyframe’s keyframe values.+ auto initial_properties = expanded_properties_at_offset(0);for (auto property : animated_properties) {- if (!expanded_properties(initial_keyframe->properties).contains(property))+ if (!initial_properties.contains(property))initial_keyframe->properties.set(property, KeyFrameSet::UseInitial {});}@@ -655,8 +663,9 @@ void KeyframeEffect::generate_initial_and_final_frames(RefPtr<KeyFrameSet> keyfrfinal_keyframe = keyframe_set->keyframes_by_key.find(100 * AnimationKeyFrameKeyScaleFactor);}+ auto final_properties = expanded_properties_at_offset(100 * AnimationKeyFrameKeyScaleFactor);for (auto property : animated_properties) {- if (!expanded_properties(final_keyframe->properties).contains(property))+ if (!final_properties.contains(property))final_keyframe->properties.set(property, KeyFrameSet::UseInitial {});}}@@ -801,9 +810,24 @@ WebIDL::ExceptionOr<GC::Ref<KeyframeEffect>> KeyframeEffect::construct_impl(GC::// - effect target,effect->m_target_element = source->target();+ effect->m_target_pseudo_selector = source->m_target_pseudo_selector;// - keyframes,- effect->m_keyframes = source->m_keyframes;+ auto keyframes = source->m_keyframes_from_css ? source->declared_css_keyframes() : source->m_keyframes;+ if (source->m_keyframes_from_css)+ insertion_sort(keyframes, [](auto const& a, auto const& b) { return *a.offset < *b.offset; });+ if (source->m_key_frame_set && source->m_key_frame_set->computed_value_zoom.has_value()) {+ for (auto& frame : keyframes) {+ for (auto& [property, value] : frame.parsed_properties()) {+ if (!property.is_custom_property()) {+ auto style_value = CSS::StyleValue::adopt_rust_style_value_data(CSS::StyleValueFFI::rust_style_value_retain(value.data()));+ auto unscaled = CSS::unscaled_by_zoom(property.id(), move(style_value), *source->m_key_frame_set->computed_value_zoom);+ value = CSS::RustStyleValueHandle::retained(unscaled->rust_style_value_data());+ }+ }+ }+ }+ effect->set_keyframes(move(keyframes), source->m_key_frame_set ? source->m_key_frame_set->style_sheet_resource_context : Optional<KeyFrameSet::StyleSheetResourceContext> {});// - composite operation, andeffect->set_composite(source->composite());@@ -920,8 +944,9 @@ void KeyframeEffect::set_composite(Bindings::CompositeOperation value)void KeyframeEffect::set_key_frame_set(RefPtr<KeyFrameSet const> key_frame_set){- if (m_key_frame_set == key_frame_set)+ if (m_ignore_css_keyframes || m_key_frame_set == key_frame_set)return;+ m_keyframes_from_css = true;m_target_properties.clear();if (key_frame_set) {@@ -943,9 +968,145 @@ Bindings::CompositeOperation KeyframeEffect::composite_for_bindings() constreturn composite();}-// https://www.w3.org/TR/web-animations-1/#dom-keyframeeffect-getkeyframes+// https://drafts.csswg.org/css-animations-2/#keyframes+CSS::EasingFunction KeyframeEffect::default_keyframe_easing() const+{+ if (auto animation = associated_animation(); animation && is<CSS::CSSAnimation>(*animation))+ return static_cast<CSS::CSSAnimation const&>(*animation).default_easing();+ return CSS::EasingFunction::linear();+}++Vector<BaseKeyframe> KeyframeEffect::declared_css_keyframes() const+{+ Vector<BaseKeyframe> frames;+ if (!m_key_frame_set)+ return frames;++ auto default_easing = default_keyframe_easing();++ auto append_frame = [&](u64 key, KeyFrameSet::ResolvedKeyFrame const& source) {+ auto offset = static_cast<double>(key) / (100 * AnimationKeyFrameKeyScaleFactor);+ // AD-HOC: Step 2.2 uses the computed timing function. Substitution-dependent keyframe easings use the+ // animation-wide easing for web compatibility.+ auto easing = source.easing.has<CSS::EasingFunction>() ? source.easing.get<CSS::EasingFunction>() : default_easing;+ auto matching_frame = frames.find_if([&](BaseKeyframe const& frame) {+ return frame.offset == offset && frame.easing.get<CSS::EasingFunction>() == easing && frame.composite == source.composite;+ });+ if (matching_frame == frames.end()) {+ frames.append(BaseKeyframe {+ .offset = offset,+ .easing = easing,+ .composite = source.composite,+ .computed_offset = offset,+ .properties = BaseKeyframe::ParsedProperties {},+ });+ matching_frame = frames.end() - 1;+ }+ for (auto const& [property, value] : source.properties) {+ if (auto const* declared = value.get_pointer<CSS::RustStyleValueHandle>())+ matching_frame->parsed_properties().set(property, *declared);+ }+ };+ if (m_key_frame_set->css_keyframes.has_value()) {+ // 2.3.1. Cascade together all of its declaration blocks such that for each CSS property (except those that are+ // "not animatable", which must be ignored) the last declaration among all its <keyframe-block>+ // declarations takes precedence.+ for (auto const& frame : *m_key_frame_set->css_keyframes)+ append_frame(frame.key, frame.values);+ } else {+ for (auto it = m_key_frame_set->keyframes_by_key.begin(); it != m_key_frame_set->keyframes_by_key.end(); ++it)+ append_frame(it.key(), *it);+ }+ return frames;+}++// https://drafts.csswg.org/css-animations-2/#keyframes+Vector<BaseKeyframe> KeyframeEffect::computed_css_keyframes() const+{+ auto frames = declared_css_keyframes();+ if (!m_key_frame_set || !m_key_frame_set->css_keyframes.has_value())+ return frames;+ bool has_custom_properties = false;+ for (auto& frame : frames)+ frame.parsed_properties().remove_all_matching([&](auto const& property, auto const&) {+ has_custom_properties |= property.is_custom_property();+ return property.is_custom_property();+ });+ auto default_easing = default_keyframe_easing();+ if (!has_custom_properties && !frames.contains([](auto const& frame) { return !frame.parsed_properties().is_empty(); }))+ return {};++ auto target = target_abstract_element();+ if (target.has_value() && target->installed_style()) {+ auto underlying_values = target->element().document().style_computer().compute_css_keyframe_values(*target, frames, m_key_frame_set->style_sheet_resource_context);+ for (auto offset : { 0.0, 1.0 }) {+ HashTable<CSS::PropertyNameAndID> present;+ Optional<size_t> destination;+ for (size_t i = 0; i < frames.size(); ++i) {+ auto const& frame = frames[i];+ if (frame.offset != offset)+ continue;+ for (auto const& property : frame.parsed_properties())+ present.set(property.key);+ // AD-HOC: Step 3.1 uses the default composite. Underlying-value endpoints use "replace", even for an+ // additive effect, so their values aren't added to themselves.+ if (!destination.has_value() && frame.easing.get<CSS::EasingFunction>() == default_easing+ && (frame.composite == CompositeOperationOrAuto::Auto || frame.composite == CompositeOperationOrAuto::Replace))+ destination = i;+ }+ BaseKeyframe::ParsedProperties missing;+ for (auto const& [property, value] : underlying_values) {+ if (!present.contains(property))+ missing.set(property, value);+ }+ // AD-HOC: Custom properties contribute keyframe offsets and implicit endpoints, but their values are+ // omitted from CSS keyframe reflection for web compatibility.+ if (missing.is_empty() && !has_custom_properties)+ continue;+ // 3.2. For any property in animated properties that is not otherwise present in a keyframe with an offset+ // of 0% or one that would be positioned earlier in the used keyframe order, add the computed value of+ // that property on element to initial keyframe's keyframe values.+ if (destination.has_value()) {+ for (auto const& [property, value] : missing)+ frames[*destination].parsed_properties().set(property, value);+ } else {+ BaseKeyframe frame {+ .offset = offset,+ .easing = default_easing,+ .composite = CompositeOperationOrAuto::Replace,+ .computed_offset = offset,+ .properties = move(missing),+ };+ // AD-HOC: Step 3.3 prepends the initial keyframe. For web compatibility, reflected synthetic endpoints+ // follow explicitly declared frames at the same offset.+ frames.append(move(frame));+ }+ }+ }+ // 4. The computed order of keyframes—which is the order returned by getKeyframes()—is found by shifting any+ // keyframes whose offset was specified as a <percentage>, from keyword, or to keyword to the front of the list+ // (after the generated initial keyframe, if any), and performing a stable sort on these keyframes by their+ // keyframe offsets.+ insertion_sort(frames, [](auto const& a, auto const& b) { return *a.offset < *b.offset; });+ return frames;+}++// https://drafts.csswg.org/web-animations-1/#dom-keyframeeffect-getkeyframesWebIDL::ExceptionOr<GC::RootVector<GC::Ref<JS::Object>>> KeyframeEffect::get_keyframes(JS::Object& relevant_global_object){+ update_style_if_needed();+ auto css_keyframes = m_keyframes_from_css ? computed_css_keyframes() : Vector<BaseKeyframe> {};+ auto const& reflected_keyframes = m_keyframes_from_css ? css_keyframes : m_keyframes;+ double zoom = 1;+ if (m_keyframes_from_css) {+ if (m_key_frame_set && m_key_frame_set->computed_value_zoom.has_value()) {+ zoom = *m_key_frame_set->computed_value_zoom;+ } else if (auto target = target_abstract_element(); target.has_value()) {+ if (auto style = target->computed_style())+ zoom = style->effective_zoom();+ }+ }+// The getKeyframes() algorithm returns a fresh sequence of fresh objects on// every invocation. Do not expose the previous result as a mutable cache:// callers are allowed to modify the returned dictionaries without changing@@ -956,7 +1117,7 @@ WebIDL::ExceptionOr<GC::RootVector<GC::Ref<JS::Object>>> KeyframeEffect::get_keyauto& realm = HTML::relevant_realm(relevant_global_object);auto& vm = realm.vm();- for (auto& keyframe : m_keyframes) {+ for (auto const& keyframe : reflected_keyframes) {auto object = JS::Object::create(realm, realm.intrinsics().object_prototype());TRY(object->set(vm.names.offset, keyframe.offset.has_value() ? JS::Value(keyframe.offset.value()) : JS::js_null(), JS::Object::ShouldThrowExceptions::Yes));TRY(object->set(vm.names.computedOffset, JS::Value(keyframe.computed_offset.value()), JS::Object::ShouldThrowExceptions::Yes));@@ -991,7 +1152,9 @@ WebIDL::ExceptionOr<GC::RootVector<GC::Ref<JS::Object>>> KeyframeEffect::get_keykey = CSS::camel_case_string_from_property_id(property.id());// Serialization can still fall back to C++, which needs the typed facade; reflection is cold, so// wrap on demand.- auto style_value = CSS::StyleValue::adopt_rust_style_value_data(CSS::StyleValueFFI::rust_style_value_retain(value.data()));+ NonnullRefPtr<CSS::StyleValue const> style_value = CSS::StyleValue::adopt_rust_style_value_data(CSS::StyleValueFFI::rust_style_value_retain(value.data()));+ if (m_keyframes_from_css && !property.is_custom_property())+ style_value = CSS::unscaled_by_zoom(property.id(), move(style_value), zoom);auto value_string = JS::PrimitiveString::create(vm, style_value->to_utf16_string(CSS::SerializationMode::Normal));TRY(object->set(JS::PropertyKey { move(key), JS::PropertyKey::StringMayBeNumber::No }, value_string, JS::Object::ShouldThrowExceptions::Yes));}@@ -1014,9 +1177,11 @@ WebIDL::ExceptionOr<void> KeyframeEffect::set_keyframes_from_js(JS::Realm& realmreturn {};}-void KeyframeEffect::set_keyframes(Vector<BaseKeyframe> keyframes)+void KeyframeEffect::set_keyframes(Vector<BaseKeyframe> keyframes, Optional<KeyFrameSet::StyleSheetResourceContext> resource_context){m_keyframe_objects_cache.clear();+ m_ignore_css_keyframes |= m_keyframes_from_css;+ m_keyframes_from_css = false;m_keyframes = move(keyframes);// FIXME: After processing the keyframe argument, we need to turn the set of keyframes into a set of computed// keyframes using the procedure outlined in the second half of@@ -1025,6 +1190,7 @@ void KeyframeEffect::set_keyframes(Vector<BaseKeyframe> keyframes)compute_missing_keyframe_offsets(m_keyframes);auto keyframe_set = adopt_ref(*new KeyFrameSet);+ keyframe_set->style_sheet_resource_context = move(resource_context);m_target_properties.clear();for (auto& keyframe : m_keyframes) {diff --git a/Libraries/LibWeb/Animations/KeyframeEffect.h b/Libraries/LibWeb/Animations/KeyframeEffect.hindex cc1fd138c95..9279d8ec9ab 100644--- a/Libraries/LibWeb/Animations/KeyframeEffect.h+++ b/Libraries/LibWeb/Animations/KeyframeEffect.h@@ -93,6 +93,12 @@ public:CompositeOperationOrAuto composite { CompositeOperationOrAuto::Auto };Variant<Empty, CSS::EasingFunction, CSS::RustStyleValueHandle> easing {};};+ struct CSSKeyframe {+ u64 key;+ ResolvedKeyFrame values;+ };+ Optional<Vector<CSSKeyframe>> css_keyframes;+ Optional<double> computed_value_zoom;RedBlackTree<u64, ResolvedKeyFrame> keyframes_by_key;Optional<StyleSheetResourceContext> style_sheet_resource_context;};@@ -138,7 +144,7 @@ public:void set_composite(Bindings::CompositeOperation value);Vector<BaseKeyframe> const& keyframes() const { return m_keyframes; }- void set_keyframes(Vector<BaseKeyframe>);+ void set_keyframes(Vector<BaseKeyframe>, Optional<KeyFrameSet::StyleSheetResourceContext> = {});WebIDL::ExceptionOr<void> set_keyframes_from_js(JS::Realm&, GC::Ptr<JS::Object>);WebIDL::ExceptionOr<GC::RootVector<GC::Ref<JS::Object>>> get_keyframes(JS::Object& relevant_global_object);@@ -239,6 +245,11 @@ private:// A cached version of m_keyframes suitable for returning from get_keyframes()Vector<GC::Ref<JS::Object>> m_keyframe_objects_cache {};+ CSS::EasingFunction default_keyframe_easing() const;+ Vector<BaseKeyframe> declared_css_keyframes() const;+ Vector<BaseKeyframe> computed_css_keyframes() const;+ bool m_keyframes_from_css { false };+ bool m_ignore_css_keyframes { false };RefPtr<KeyFrameSet const> m_key_frame_set {};u64 m_animation_preparation_identity { 0 };u64 m_animation_preparation_generation { 0 };diff --git a/Libraries/LibWeb/CSS/CSSTransition.cpp b/Libraries/LibWeb/CSS/CSSTransition.cppindex 2dee5222f5f..6b83049217a 100644--- a/Libraries/LibWeb/CSS/CSSTransition.cpp+++ b/Libraries/LibWeb/CSS/CSSTransition.cpp@@ -156,6 +156,7 @@ CSSTransition::CSSTransition(m_keyframe_effect->set_timing_function(move(timing_function));auto key_frame_set = adopt_ref(*new Animations::KeyframeEffect::KeyFrameSet);+ key_frame_set->computed_value_zoom = abstract_element.computed_style()->effective_zoom();Animations::KeyframeEffect::KeyFrameSet::ResolvedKeyFrame initial_keyframe;initial_keyframe.properties.set(m_transition_property, RustStyleValueHandle::retained(m_start_value->rust_style_value_data()));diff --git a/Libraries/LibWeb/CSS/StyleComputer.cpp b/Libraries/LibWeb/CSS/StyleComputer.cppindex 562a8e05103..d521066a4a4 100644--- a/Libraries/LibWeb/CSS/StyleComputer.cpp+++ b/Libraries/LibWeb/CSS/StyleComputer.cpp@@ -750,6 +750,34 @@ NonnullOwnPtr<StyleComputer::AnimationSample> StyleComputer::begin_animation_samreturn sample;}+Animations::BaseKeyframe::ParsedProperties StyleComputer::compute_css_keyframe_values(DOM::AbstractElement element, Vector<Animations::BaseKeyframe>& frames, Optional<Animations::KeyframeEffect::KeyFrameSet::StyleSheetResourceContext> const& resource_context) const+{+ Layout::ForcedReadScope read { element.element().document() };+ auto properties = reconstruct_computed_properties_for_animation(element.installed_style());+ auto sample = begin_animation_sample(read, element, {}, *properties, AnimationSamplePurpose::KeyframeReflection);+ Vector<ComputedValuesFFI::FfiReflectedKeyframeProperty> declarations;+ for (size_t i = 0; i < frames.size(); ++i) {+ for (auto const& [property, value] : frames[i].parsed_properties()) {+ declarations.append({ i, to_underlying(property.id()), value.data() });+ }+ }+ ComputedValuesFFI::FfiStyleSheetResourceContext context {};+ if (resource_context.has_value()) {+ auto bytes = resource_context->base_url.bytes();+ context = { bytes.data(), bytes.size(), true, resource_context->origin_clean };+ }+ Vector<Animations::BaseKeyframe::ParsedProperties> computed;+ computed.resize(frames.size() + 1);+ ComputedValuesFFI::rust_compute_css_keyframe_values(&sample->input, read, declarations.data(), declarations.size(), frames.size(), &context, &computed,+ [](void* context, size_t index, u16 property, auto* value) {+ auto& computed = *static_cast<Vector<Animations::BaseKeyframe::ParsedProperties>*>(context);+ computed[index].set(PropertyNameAndID::from_id(static_cast<PropertyID>(property)), RustStyleValueHandle::retained(value));+ });+ for (size_t i = 0; i < frames.size(); ++i)+ frames[i].properties = move(computed[i]);+ return move(computed.last());+}+void StyleComputer::finish_animation_sample(AnimationSample& sample, ComputedValuesFFI::FfiHostAnimationSampleResult const& result) const{auto abstract_element = sample.context.abstract_element;diff --git a/Libraries/LibWeb/CSS/StyleComputer.h b/Libraries/LibWeb/CSS/StyleComputer.hindex b854d27f8ba..0666db42873 100644--- a/Libraries/LibWeb/CSS/StyleComputer.h+++ b/Libraries/LibWeb/CSS/StyleComputer.h@@ -71,6 +71,8 @@ public:void register_style_engine_sheet_source(StyleSheetState const&);[[nodiscard]] Optional<StyleEngineRuleTarget> style_engine_rule_target(Layout::BegunRead const& read, StyleEngineRuleID rule_id) const;+ Animations::BaseKeyframe::ParsedProperties compute_css_keyframe_values(DOM::AbstractElement, Vector<Animations::BaseKeyframe>&, Optional<Animations::KeyframeEffect::KeyFrameSet::StyleSheetResourceContext> const&) const;+static CSSPixels default_user_font_size();void set_viewport_rect(Badge<DOM::Document>, CSSPixelRect const& viewport_rect) { m_viewport_rect = viewport_rect; }@@ -195,6 +197,7 @@ private:enum class AnimationSamplePurpose {Rendering,CommitStyles,+ KeyframeReflection,};struct AnimationSample;[[nodiscard]] NonnullOwnPtr<AnimationSample> begin_animation_sample(Layout::BegunRead const& read, DOM::AbstractElement, ReadonlySpan<GC::Ref<Animations::KeyframeEffect>>, ComputedStyleWorkingSet&, AnimationSamplePurpose = AnimationSamplePurpose::Rendering) const;diff --git a/Libraries/LibWeb/CSS/StyleScope.cpp b/Libraries/LibWeb/CSS/StyleScope.cppindex 095388e5c4e..d8da8ed7069 100644--- a/Libraries/LibWeb/CSS/StyleScope.cpp+++ b/Libraries/LibWeb/CSS/StyleScope.cpp@@ -468,6 +468,7 @@ void StyleRuleCache::add_rules_from_sheet(StyleSheetState& sheet, CascadeOrigin// Loosely based on https://drafts.csswg.org/css-animations-2/#keyframe-processingauto name = rule.name();auto keyframe_set = adopt_ref(*new Animations::KeyframeEffect::KeyFrameSet);+ keyframe_set->css_keyframes.emplace();auto base_url = sheet.style_resource_base_url();keyframe_set->style_sheet_resource_context = {.base_url = base_url.has_value() ? base_url->to_string() : String {},@@ -545,6 +546,7 @@ void StyleRuleCache::add_rules_from_sheet(StyleSheetState& sheet, CascadeOriginfor (auto key : keys) {auto resolved_key = static_cast<u64>(key * Animations::KeyframeEffect::AnimationKeyFrameKeyScaleFactor);+ keyframe_set->css_keyframes->append({ resolved_key, resolved_keyframe });if (auto* existing_keyframe = keyframe_set->keyframes_by_key.find(resolved_key)) {for (auto& [property, value] : resolved_keyframe.properties)existing_keyframe->properties.set(property, value);diff --git a/Libraries/LibWeb/Rust/src/css/computed_values.rs b/Libraries/LibWeb/Rust/src/css/computed_values.rsindex 63aac34c0e0..bfcf3b54f6f 100644--- a/Libraries/LibWeb/Rust/src/css/computed_values.rs+++ b/Libraries/LibWeb/Rust/src/css/computed_values.rs@@ -4137,6 +4137,8 @@ impl crate::heap_size::HeapSize for InheritanceDependentValue {#[derive(Clone)]pub(crate) struct GroupValueFacts {inheritance_dependent_values: Option<std::sync::Arc<[InheritanceDependentValue]>>,+ /// Computed background lists with entries beyond the image layers, for keyframe reflection.+ uncoordinated_background_values: Option<std::sync::Arc<Vec<(u16, RetainedStyleValueData)>>>,effective_zoom: f32,display_before_box_type_transformation: u32,effective_color_scheme: i8,@@ -4169,7 +4171,7 @@ fn read_in_place_bit(property: u16) -> u16 {impl crate::heap_size::HeapSize for GroupValueFacts {fn heap_size(&self, sizer: &mut crate::heap_size::HeapSizer) -> usize {- self.inheritance_dependent_values.heap_size(sizer)+ self.inheritance_dependent_values.heap_size(sizer) + self.uncoordinated_background_values.heap_size(sizer)}}@@ -4179,6 +4181,7 @@ impl GroupValueFacts {pub(crate) fn empty() -> Self {Self {inheritance_dependent_values: None,+ uncoordinated_background_values: None,effective_zoom: 1.0,display_before_box_type_transformation: 0,effective_color_scheme: -1,@@ -4188,6 +4191,18 @@ impl GroupValueFacts {}}+ pub(crate) fn uncoordinated_background_value(&self, property: u16) -> Option<&RetainedStyleValueData> {+ self.uncoordinated_background_values+ .as_ref()?+ .iter()+ .find(|(held, _)| *held == property)+ .map(|(_, value)| value)+ }++ fn same_uncoordinated_background_values(&self, other: &Self) -> bool {+ self.uncoordinated_background_values == other.uncoordinated_background_values+ }+/// The groups holding colors resolved against `currentcolor`.pub(crate) fn current_color_groups(&self) -> u32 {self.current_color_groups@@ -4257,7 +4272,8 @@ impl GroupValueFacts {other.inheritance_dependent_values.as_deref().unwrap_or_default(),);let same_recorded_values = std::ptr::eq(mine, theirs);- self.effective_zoom.to_bits() == other.effective_zoom.to_bits()+ self.same_uncoordinated_background_values(other)+ && self.effective_zoom.to_bits() == other.effective_zoom.to_bits()&& self.display_before_box_type_transformation == other.display_before_box_type_transformation&& self.effective_color_scheme == other.effective_color_scheme&& self.native_appearance_disabled == other.native_appearance_disabled@@ -4283,6 +4299,9 @@ impl GroupValueFacts {values.sort_unstable();values};+ if !self.same_uncoordinated_background_values(other) {+ return Some("the uncoordinated background values".into());+ }if recorded(self) != recorded(other) {return Some("the recorded specified values".into());}@@ -4790,6 +4809,7 @@ pub(crate) struct GroupValuesWriter<'a> {/// The recorded specified values of the longhands whose computed values depend on what the/// element inherits, once the computation records others than the seeded ones.inheritance_dependent_values: Option<Vec<(u16, RetainedStyleValueData)>>,+ uncoordinated_background_values: Option<std::sync::Arc<Vec<(u16, RetainedStyleValueData)>>>,effective_zoom: f32,display_before_box_type_transformation: u32,effective_color_scheme: i16,@@ -4861,6 +4881,7 @@ impl<'a> GroupValuesWriter<'a> {},seeded_inheritance_dependent_values: initial.facts.inheritance_dependent_values.clone(),inheritance_dependent_values: None,+ uncoordinated_background_values: initial.facts.uncoordinated_background_values.clone(),effective_zoom: parent.facts.effective_zoom,display_before_box_type_transformation: initial.facts.display_before_box_type_transformation,effective_color_scheme: parent.facts.effective_color_scheme(),@@ -5035,6 +5056,24 @@ impl<'a> GroupValuesWriter<'a> {});}+ pub(crate) fn set_uncoordinated_background_value(&mut self, property: u16, value: Option<RetainedStyleValueData>) {+ if self.uncoordinated_background_values.is_none() && value.is_none() {+ return;+ }+ let values = self+ .uncoordinated_background_values+ .get_or_insert_with(Default::default);+ let values = std::sync::Arc::make_mut(values);+ values.retain(|(held, _)| *held != property);+ if let Some(value) = value {+ values.push((property, value));+ values.sort_by_key(|(property, _)| *property);+ }+ if values.is_empty() {+ self.uncoordinated_background_values = None;+ }+ }+/// Records `value` as the specified value of `property` where its computed value depends on/// what the element inherits, or that it does not depend on it for none.pub(crate) fn set_inheritance_dependent_value(&mut self, property: u16, value: Option<RetainedStyleValueData>) {@@ -5278,6 +5317,7 @@ impl<'a> GroupValuesWriter<'a> {bits: self.bits,facts: GroupValueFacts {inheritance_dependent_values,+ uncoordinated_background_values: self.uncoordinated_background_values,effective_zoom: self.effective_zoom,display_before_box_type_transformation: self.display_before_box_type_transformation,effective_color_scheme: i8::try_from(self.effective_color_scheme)diff --git a/Libraries/LibWeb/Rust/src/css/style/computed.rs b/Libraries/LibWeb/Rust/src/css/style/computed.rsindex 31008c5b9f5..9aa235d589a 100644--- a/Libraries/LibWeb/Rust/src/css/style/computed.rs+++ b/Libraries/LibWeb/Rust/src/css/style/computed.rs@@ -390,6 +390,10 @@ impl<'a> ViewLonghands<'a> {.map(|entry| (entry.property, entry.clone_value()))}+ pub(crate) fn uncoordinated_background_value(self, property: u16) -> Option<&'a RetainedStyleValueData> {+ self.0.rare().value_facts.uncoordinated_background_value(property)+ }+/// The recorded specified values of the longhands whose computed values depend on what the/// element inherits.pub(crate) fn inheritance_dependent_values(self) -> impl Iterator<Item = (u16, &'a RetainedStyleValueData)> {diff --git a/Libraries/LibWeb/Rust/src/css/style/effect_descriptions.rs b/Libraries/LibWeb/Rust/src/css/style/effect_descriptions.rsindex 80c5a5796d4..6ecbd7d5c22 100644--- a/Libraries/LibWeb/Rust/src/css/style/effect_descriptions.rs+++ b/Libraries/LibWeb/Rust/src/css/style/effect_descriptions.rs@@ -64,6 +64,44 @@ impl PublishedValue {}impl PublishedEffect {+ pub(crate) fn for_keyframe_computation(+ frames: Vec<Vec<PublishedDeclaration>>,+ resource_context: Option<PublishedResourceContext>,+ ) -> Self {+ let mut declarations = Vec::new();+ let keyframes = frames+ .into_iter()+ .enumerate()+ .map(|(index, frame)| {+ let first = declarations.len();+ declarations.extend(frame);+ PublishedKeyframe {+ key: i64::try_from(index).expect("keyframe index fits in i64"),+ easing: Easing::default(),+ easing_value: None,+ composite: FfiCompositeOperation::Replace,+ declarations: first..declarations.len(),+ custom_declarations: 0..0,+ }+ })+ .collect();+ Self {+ identity: 0,+ generation: 0,+ is_transition: false,+ keyframes: Arc::new(PublishedKeyframes {+ resource_context,+ target_properties: target_properties(declarations.iter().map(|declaration| declaration.property_id)),+ keyframes,+ declarations: declarations.into_boxed_slice(),+ custom_declarations: Box::new([]),+ }),+ custom_property_interval_values: None,+ timing: None,+ reversing: None,+ }+ }+/// The values the effect's keyframes declare, and those they run their easing by.pub(crate) fn declared_values(&self) -> impl Iterator<Item = &StyleValueData> {let keyframes = &self.keyframes;diff --git a/Libraries/LibWeb/Rust/src/css/style/pipeline/drive.rs b/Libraries/LibWeb/Rust/src/css/style/pipeline/drive.rsindex d307f1902b0..5d0f5c83f75 100644--- a/Libraries/LibWeb/Rust/src/css/style/pipeline/drive.rs+++ b/Libraries/LibWeb/Rust/src/css/style/pipeline/drive.rs@@ -573,6 +573,7 @@ impl RetainedState {results,effective_color_scheme,true,+ false,);counters.add(Counter::EnginePhysicalLonghandEvaluations,diff --git a/Libraries/LibWeb/Rust/src/css/style/pipeline/records.rs b/Libraries/LibWeb/Rust/src/css/style/pipeline/records.rsindex 86650c7b46e..bcbc87934be 100644--- a/Libraries/LibWeb/Rust/src/css/style/pipeline/records.rs+++ b/Libraries/LibWeb/Rust/src/css/style/pipeline/records.rs@@ -320,8 +320,8 @@ const _: () = assert!(size_of::<Record>() == 64);const _: () = assert!(std::mem::offset_of!(Record, payloads) == 0);const _: () = assert!(std::mem::offset_of!(Record, header) == 56);const _: () = assert!(size_of::<RecordFacts>() == 4);-const _: () = assert!(size_of::<GroupValueFacts>() == 32);-const _: () = assert!(size_of::<RareStyleFacts>() == 120);+const _: () = assert!(size_of::<GroupValueFacts>() == 40);+const _: () = assert!(size_of::<RareStyleFacts>() == 128);impl RareStyleFacts {/// These facts, with `inheritable` as the custom properties the element's children inherit.diff --git a/Libraries/LibWeb/Rust/src/css/style/position_try.rs b/Libraries/LibWeb/Rust/src/css/style/position_try.rsindex 6833980201b..4e37f2f7bf8 100644--- a/Libraries/LibWeb/Rust/src/css/style/position_try.rs+++ b/Libraries/LibWeb/Rust/src/css/style/position_try.rs@@ -1051,6 +1051,7 @@ impl RetainedState {&mut results,&mut effective_color_scheme,false,+ false,);}declareddiff --git a/Libraries/LibWeb/Rust/src/css/style_compute.rs b/Libraries/LibWeb/Rust/src/css/style_compute.rsindex 0213a24e76e..3f1579cfce0 100644--- a/Libraries/LibWeb/Rust/src/css/style_compute.rs+++ b/Libraries/LibWeb/Rust/src/css/style_compute.rs@@ -3134,6 +3134,7 @@ pub(crate) unsafe fn drive_property_computation(results: &mut LonghandDriverResults,effective_color_scheme: &mut i16,coordinate_overflow_keywords: bool,+ preserve_background_lists: bool,) {use crate::css::property_metadata::{NUMBER_OF_LONGHAND_PROPERTIES, REQUIRES_COMPUTATION_ALWAYS, REQUIRES_COMPUTATION_CASCADED,@@ -3234,6 +3235,9 @@ pub(crate) unsafe fn drive_property_computation(if !required_driver_input && !property_is_selected && computed_property_words.is_some() {continue;}+ if BACKGROUND_LAYER_LONGHANDS.contains(&property_id) {+ writer.set_uncoordinated_background_value(property_id, None);+ }set_longhand_bit(&mut evaluated_words, property_id);results.longhand_evaluations = results.longhand_evaluations@@ -3907,7 +3911,14 @@ pub(crate) unsafe fn drive_property_computation() => {// NB: The background properties are coordinated at compute time rather// than use time, unlike other coordinating list property groups.- let layer_count = background_image_list_length+ let declared_count = match value_data {+ StyleValueData::ValueList { values, .. } if preserve_background_lists => {+ Some(values.as_slice().len())+ }+ _ => None,+ };+ let layer_count = declared_count+ .or(background_image_list_length).or_else(|| {writer.get(prop::BACKGROUND_IMAGE).and_then(|value| match value.data() {StyleValueData::ValueList { values, .. } => Some(values.as_slice().len()),@@ -3917,21 +3928,29 @@ pub(crate) unsafe fn drive_property_computation(.expect("background-image must be a computed value list");let resolution_context =length_resolution_context.expect("background lists require a length resolution context");- match absolutize_for_rule(value_data, resolution_context, current_effective_color_scheme, results) {- Absolutized::Unchanged => {- match repeat_style_value_list_to_n_elements(value_data, layer_count) {- Some(None) => NativeValue::Unchanged,- Some(Some(value)) => NativeValue::StyleValue(value),- None => unsupported(),- }- }+ let full = match absolutize_for_rule(+ value_data,+ resolution_context,+ current_effective_color_scheme,+ results,+ ) {+ Absolutized::Unchanged => match &externally_absolutized {+ Some(value) => std::borrow::Cow::Owned(RetainedStyleValueData::from_arc(value.clone())),+ None => std::borrow::Cow::Borrowed(value),+ },Absolutized::Changed(value) => {- match repeat_style_value_list_to_n_elements(value.data(), layer_count) {- Some(None) => NativeValue::StyleValue(value.into_arc()),- Some(Some(value)) => NativeValue::StyleValue(value),- None => unsupported(),- }+ std::borrow::Cow::Owned(RetainedStyleValueData::from_arc(value.into_arc()))}+ };+ let excess = matches!(full.data(), StyleValueData::ValueList { values, .. } if values.as_slice().len() > layer_count);+ writer.set_uncoordinated_background_value(property_id, excess.then(|| full.clone().into_owned()));+ match repeat_style_value_list_to_n_elements(full.data(), layer_count) {+ Some(None) => match full {+ std::borrow::Cow::Borrowed(_) => NativeValue::Unchanged,+ std::borrow::Cow::Owned(value) => NativeValue::StyleValue(value.into_arc()),+ },+ Some(Some(value)) => NativeValue::StyleValue(value),+ None => unsupported(),}}(Some(_), prop::ANIMATION_NAME)@@ -6148,6 +6167,7 @@ unsafe fn create_document_style_record(&mut results,&mut effective_color_scheme,true,+ false,);}}@@ -6210,6 +6230,7 @@ pub(crate) struct AnimationKeyframeLonghands {/// from the underlying style, then all of that keyframe's specified values are/// cascaded together before its selected properties are evaluated. A custom/// property's value is the one `custom_property_values` holds at its index.+#[allow(clippy::too_many_arguments)]pub(crate) fn compute_animation_keyframe_longhands(underlying_longhands: crate::css::style::ViewLonghands<'_>,style_engine: &crate::css::style::StyleEngine,@@ -6218,6 +6239,7 @@ pub(crate) fn compute_animation_keyframe_longhands(environment: &FfiStyleComputationEnvironment,length_contexts: &FfiAnimationLengthContexts,custom_property_values: &[Option<RetainedStyleValueData>],+ preserve_background_lists: bool,) -> AnimationKeyframeLonghands {use crate::css::property_metadata::{FIRST_LONGHAND_PROPERTY_ID, LAST_LONGHAND_PROPERTY_ID, NUMBER_OF_LONGHAND_PROPERTIES,@@ -6372,6 +6394,7 @@ pub(crate) fn compute_animation_keyframe_longhands(&mut results,&mut effective_color_scheme,false,+ preserve_background_lists,);}}@@ -6795,6 +6818,171 @@ impl FfiHostAnimationSample {}}+#[repr(C)]+pub struct FfiReflectedKeyframeProperty {+ pub keyframe_index: usize,+ pub property_id: u16,+ pub value: *const StyleValueData,+}++/// Compute CSS keyframe declarations without sampling or publishing an effect.+/// The callback receives underlying values with `keyframe_count` as their index.+///+/// # Safety+/// The input, declarations, resource context, and callback must be live for the call.+/// No caller may hold a borrow of the style engine.+#[unsafe(no_mangle)]+pub unsafe extern "C" fn rust_compute_css_keyframe_values(+ input: &FfiHostAnimationSample,+ read: &crate::render_state::BegunRead,+ properties: *const FfiReflectedKeyframeProperty,+ property_count: usize,+ keyframe_count: usize,+ resource_context: &FfiStyleSheetResourceContext,+ context: *mut c_void,+ emit: unsafe extern "C" fn(*mut c_void, usize, u16, *const StyleValueData),+) {+ use crate::css::animation as anim;+ use crate::css::style::effect_descriptions::{+ PublishedDeclaration, PublishedEffect, PublishedResourceContext, PublishedValue,+ };+ use crate::css::style::engine_calls::{document_host, with_engine};++ // SAFETY: Guaranteed by the caller.+ let (host, (sample, mut callbacks), properties) = unsafe {+ (+ document_host(input.host),+ input.adopt(),+ ak::slice_from_raw_parts(properties, property_count),+ )+ };+ let Some(node) = crate::css::style::tree::StyleNodeID::from_raw(sample.style_node) else {+ return;+ };+ let mut frames = vec![Vec::new(); keyframe_count];+ for property in properties {+ // SAFETY: Each declaration's value is live for the call.+ let value = unsafe {+ RetainedStyleValueData::from_retained_pointer(crate::css::style_value::retain_style_value(property.value))+ };+ frames[property.keyframe_index].push(PublishedDeclaration {+ property_id: property.property_id,+ value: PublishedValue::Declared(value),+ });+ }+ let resource_context = resource_context.has_value.then(|| PublishedResourceContext {+ // SAFETY: The resource context's URL is live for the call.+ base_url: unsafe { ak::slice_from_raw_parts(resource_context.base_url, resource_context.base_url_length) }+ .into(),+ origin_clean: resource_context.origin_clean,+ });+ let effect = PublishedEffect::for_keyframe_computation(frames, resource_context);+ let resolved = with_engine(read, host, |engine| {+ let (writing_mode, direction) = computed_writing_mode_and_direction(sample.longhands);+ let conversions = std::cell::RefCell::new(anim::KeyframeConversionCache::new(+ None,+ sample.stores,+ sample.custom_property_registration_generation,+ ));+ anim::resolve_published_animation_declarations(+ engine,+ node,+ sample.pseudo(),+ &[anim::SelectedEffect {+ effect: &effect,+ current_key: 0.0,+ }],+ sample.longhands,+ sample.stores,+ writing_mode,+ direction,+ &[],+ &conversions,+ )+ .resolved+ });+ let length_contexts = callbacks.length_contexts(resolved.container_relative_length_unit_mask);+ let values = with_engine(read, host, |engine| {+ let sibling_position = resolved+ .uses_tree_counting_function+ .then(|| engine.element_sibling_position(node))+ .flatten();+ let random_base_values = resolved+ .unfixed_random_sharings+ .iter()+ .map(|sharing| FfiRandomBaseValue {+ source: sharing.source.cast(),+ value: engine.ensure_random_base_value(Some(node), &sharing.name, sharing.element_shared),+ })+ .collect::<Vec<_>>();+ let mut environment = *sample.environment;+ environment.has_tree_counting_context = sibling_position.is_some();+ environment.sibling_count = sibling_position.map_or(0, |(count, _)| u64::from(count));+ environment.sibling_index = sibling_position.map_or(0, |(_, index)| u64::from(index));+ environment.random_base_values = random_base_values.as_ptr();+ environment.random_base_value_count = random_base_values.len();+ compute_animation_keyframe_longhands(+ sample.longhands,+ engine,+ sample.inheritance_parent_record.as_ref(),+ &resolved.properties,+ &environment,+ &length_contexts,+ &[],+ true,+ )+ .values+ });+ for (property, value) in resolved.properties.iter().zip(&values) {+ let coordinated = sample+ .longhands+ .handle(property.physical_property_id)+ .expect("an animated longhand has an underlying value");+ let underlying = sample+ .longhands+ .uncoordinated_background_value(property.physical_property_id)+ .unwrap_or(coordinated);+ let mut reflected = value.clone();+ // AD-HOC: Computed keyframe values need not have the underlying background list's length. For web+ // compatibility, reflection preserves underlying layers beyond a shorter keyframe declaration.+ if BACKGROUND_LAYER_LONGHANDS.contains(&property.physical_property_id)+ && let StyleValueData::ValueList {+ values: declared,+ separator,+ collapsible,+ } = value.data()+ && let StyleValueData::ValueList { values: base, .. } = coordinated.data()+ && declared.as_slice().len() < base.as_slice().len()+ {+ let mut items = declared.as_slice().to_vec();+ items.extend_from_slice(&base.as_slice()[items.len()..]);+ reflected = RetainedStyleValueData::from_owned(StyleValueData::ValueList {+ values: crate::css::style_value::RetainedStyleValueDataList::from_retained_values(items),+ separator: *separator,+ collapsible: *collapsible,+ });+ }+ // SAFETY: The callback and underlying value are live for this call.+ unsafe {+ emit(+ context,+ keyframe_count,+ property.physical_property_id,+ underlying.pointer(),+ );+ }+ // SAFETY: The callback is live, and each computed value stays live until it returns.+ unsafe {+ emit(+ context,+ property.keyframe_index,+ property.physical_property_id,+ reflected.pointer(),+ );+ };+ }+}+/// Sample one element's animation effects onto its working set's overlay.////// The effects are sampled from the descriptions the host published of them: the style engine@@ -7326,6 +7514,7 @@ fn finish_animation_sample(&environment,length_contexts,&custom_values,+ false,);result.depends_on_viewport_metrics = computed_keyframes.depends_on_viewport_metrics;result.font_metrics_depend_on_viewport_metrics = computed_keyframes.font_metrics_depend_on_viewport_metrics;diff --git a/Libraries/LibWeb/Rust/src/css/style_compute/tests.rs b/Libraries/LibWeb/Rust/src/css/style_compute/tests.rsindex 7e15d593ec7..0cbbaa148be 100644--- a/Libraries/LibWeb/Rust/src/css/style_compute/tests.rs+++ b/Libraries/LibWeb/Rust/src/css/style_compute/tests.rs@@ -867,6 +867,7 @@ fn svg_axis_case(svg: bool, vertical: bool) -> [f64; 3] {&mut results,&mut color_scheme,false,+ false,);}[prop::WIDTH, prop::HEIGHT, prop::MARGIN_LEFT].map(|property| match writer.get(property).unwrap().data() {@@ -999,6 +1000,7 @@ fn font_phase_axis_case(&mut results,&mut color_scheme,false,+ false,);}}diff --git a/Tests/LibWeb/Crash/wpt-import/css/css-animations/CSSAnimation-getKeyframes-crash.html b/Tests/LibWeb/Crash/wpt-import/css/css-animations/CSSAnimation-getKeyframes-crash.htmlnew file mode 100644index 00000000000..72eb5e88195--- /dev/null+++ b/Tests/LibWeb/Crash/wpt-import/css/css-animations/CSSAnimation-getKeyframes-crash.html@@ -0,0 +1,26 @@+<!DOCTYPE html>+<html>+<head>+ <meta charset="utf-8">+ <meta name="viewport" content="width=device-width, initial-scale=1">+ <link rel="help" href="https://crbug.com/1326225">+ <title>Crash test calling getKeyframes on an orphaned element</title>+</head>+<style type="text/css">+ @keyframes anim {+ from { left: 0; }+ }+</style>+<body>+ <div id="container">+ <div id="target">+ </div>+ </div>+</body>+<script type="text/javascript">+ target.style.animation = "anim 0.01s";+ var animation = target.getAnimations()[0];+ container.innerHTML = 1;+ animation.effect.getKeyframes()[0].hasOwnProperty();+</script>+</html>diff --git a/Tests/LibWeb/Text/expected/Animations/css-keyframe-copy-order-and-style.txt b/Tests/LibWeb/Text/expected/Animations/css-keyframe-copy-order-and-style.txtnew file mode 100644index 00000000000..8044b996d0a--- /dev/null+++ b/Tests/LibWeb/Text/expected/Animations/css-keyframe-copy-order-and-style.txt@@ -0,0 +1,6 @@+copy order: 0: 0 (linear); 0.5: 0.5 (ease-in); 0.5: 0.6 (ease-out); 1: 1 (linear)+round trip: accepted+copy after rule edit: 0: 0 (linear); 0.5: 0.5 (ease-in); 0.5: 0.6 (ease-out); 1: 1 (linear)+copy after easing edit: 0: 0 (linear); 0.5: 0.5 (ease-in); 0.5: 0.6 (ease-out); 1: 1 (linear)+source after style flush: 0: 0 (ease-in-out); 0.25: 0.25 (ease-in-out); 0.5: 0.5 (ease-in); 0.5: 0.6 (ease-out); 1: 1 (ease-in-out)+copy after style flush: 0: 0 (ease-in-out); 0.25: 0.25 (ease-in-out); 0.5: 0.5 (ease-in); 0.5: 0.6 (ease-out); 1: 1 (ease-in-out)diff --git a/Tests/LibWeb/Text/expected/Animations/css-keyframe-copy-same-offset.txt b/Tests/LibWeb/Text/expected/Animations/css-keyframe-copy-same-offset.txtnew file mode 100644index 00000000000..73fc52c92b1--- /dev/null+++ b/Tests/LibWeb/Text/expected/Animations/css-keyframe-copy-same-offset.txt@@ -0,0 +1,8 @@+source: 0: 10px, 0; 1: 30px, 1+copy: 0: 10px, 0; 1: 30px, 1+source playback: 15px, 0.25+copy playback: 15px, 0.25+separate easing copy at 25000: 15px, 0+separate easing copy at 75000: 25px, 0.5+separate final copy at 25000: 15px, 0.25+separate final copy at 75000: 25px, 0.75diff --git a/Tests/LibWeb/Text/expected/Animations/css-keyframe-effect-copy.txt b/Tests/LibWeb/Text/expected/Animations/css-keyframe-effect-copy.txtnew file mode 100644index 00000000000..7c6e3795c23--- /dev/null+++ b/Tests/LibWeb/Text/expected/Animations/css-keyframe-effect-copy.txt@@ -0,0 +1,9 @@+source: 0: 20px (ease-in); 1: 40px (ease-in)+copy: 0: 2em (ease-in); 1: 4em (ease-in)+copied custom property: first, last+copy after font change: 0: 2em (ease-in); 1: 4em (ease-in)+source after rule change: 0: 200px (ease-in); 1: 400px (ease-in)+copy after rule change: 0: 2em (ease-in); 1: 4em (ease-in)+copy playback width: 53px+copy after setKeyframes: null: 7px (linear); null: 9px (linear)+copied pseudo-element: ::beforediff --git a/Tests/LibWeb/Text/expected/Animations/css-keyframes-background-container-lengths.txt b/Tests/LibWeb/Text/expected/Animations/css-keyframes-background-container-lengths.txtnew file mode 100644index 00000000000..e633c36194e--- /dev/null+++ b/Tests/LibWeb/Text/expected/Animations/css-keyframes-background-container-lengths.txt@@ -0,0 +1,4 @@+computed: 30px auto+underlying: 30px auto, 60px auto; 10px auto+resized: 40px auto, 80px auto; 10px auto+zoom: 40px auto, 80px auto; 10px autodiff --git a/Tests/LibWeb/Text/expected/Animations/css-keyframes-custom-properties.txt b/Tests/LibWeb/Text/expected/Animations/css-keyframes-custom-properties.txtnew file mode 100644index 00000000000..8094b5ff06a--- /dev/null+++ b/Tests/LibWeb/Text/expected/Animations/css-keyframes-custom-properties.txt@@ -0,0 +1,7 @@+registered: {"offset":0,"easing":"linear","composite":"auto"}; {"offset":1,"easing":"linear","composite":"auto"}+font change: {"offset":0,"easing":"linear","composite":"auto"}; {"offset":1,"easing":"linear","composite":"auto"}+implicit endpoint: {"offset":0,"easing":"linear","composite":"replace"}; {"offset":1,"easing":"linear","composite":"auto"}+changed underlying: {"offset":0,"easing":"linear","composite":"replace"}; {"offset":1,"easing":"linear","composite":"auto"}+zoom: {"offset":0,"easing":"linear","composite":"replace"}; {"offset":1,"easing":"linear","composite":"auto"}+middle: {"offset":0,"easing":"linear","composite":"replace"}; {"offset":0.5,"easing":"ease-in","composite":"auto"}; {"offset":1,"easing":"linear","composite":"replace"}+unregistered: {"offset":0,"easing":"ease-out","composite":"auto"}; {"offset":0,"easing":"linear","composite":"replace"}; {"offset":1,"easing":"linear","composite":"auto"}diff --git a/Tests/LibWeb/Text/expected/Animations/css-keyframes-removed-target.txt b/Tests/LibWeb/Text/expected/Animations/css-keyframes-removed-target.txtnew file mode 100644index 00000000000..c801cee6c4b--- /dev/null+++ b/Tests/LibWeb/Text/expected/Animations/css-keyframes-removed-target.txt@@ -0,0 +1,4 @@+attached: 0: 20px, 0.2; 1: 40px, 0.8+removed: 0: 2em, 0.2; 1: 4em, 0.8+removed after layout: 0: 2em, 0.2; 1: 4em, 0.8+null target: 0: 2em, 0.2; 1: 4em, 0.8diff --git a/Tests/LibWeb/Text/expected/Animations/css-keyframes-underlying-background-list.txt b/Tests/LibWeb/Text/expected/Animations/css-keyframes-underlying-background-list.txtnew file mode 100644index 00000000000..7ae128c0c4f--- /dev/null+++ b/Tests/LibWeb/Text/expected/Animations/css-keyframes-underlying-background-list.txt@@ -0,0 +1,9 @@+inherited list: 30px auto; 50% auto, 6px auto, contain+own list: 20px auto, 60% auto; 50% auto, 6px auto, contain+changed unused layer: 20px auto, 70% auto; 50% auto, 6px auto, contain+ordinary computed layer count: 1+more image layers: 20px auto, 70% auto, 20px auto, 70% auto; 50% auto, 6px auto, contain, 70% auto+inherit after own list: 30px auto; 50% auto, 6px auto, contain+relative lengths under zoom: 20px auto, 31px auto; 50% auto, 6px auto, contain+changed font: 40px auto, 61px auto; 50% auto, 6px auto, contain+shorter explicit list: 40px auto, 61px auto; 5px autodiff --git a/Tests/LibWeb/Text/expected/Animations/css-transition-keyframes-detached-zoom.txt b/Tests/LibWeb/Text/expected/Animations/css-transition-keyframes-detached-zoom.txtnew file mode 100644index 00000000000..d78b324c7c9--- /dev/null+++ b/Tests/LibWeb/Text/expected/Animations/css-transition-keyframes-detached-zoom.txt@@ -0,0 +1,3 @@+original target: 10px, 30px+different target: 10px, 30px+copied transition: 10px, 30pxdiff --git a/Tests/LibWeb/Text/expected/WebAnimations/css-keyframe-reflection.txt b/Tests/LibWeb/Text/expected/WebAnimations/css-keyframe-reflection.txtnew file mode 100644index 00000000000..6f8b84da345--- /dev/null+++ b/Tests/LibWeb/Text/expected/WebAnimations/css-keyframe-reflection.txt@@ -0,0 +1,16 @@+width frames: 20px,100px+fresh width frames: 20px,100px+same object: false+middle: 60px, 0.5+after inspection: 80px, 0.75+pending variable change: 20px,200px+after variable change: 155px, 0.75+important width frames: 20px,200px+important width: 7px+computed lengths: 20px,30px+pending font change: 40px,60px+zoomed lengths: 40px,60px+script lengths: 4em,5em+background layers: auto / 50% auto, 6px auto, contain+partial replace endpoint: 0/replace/0/20px 1/auto/1/100px+partial additive endpoint: 0/replace/0/20px 1/auto/1/100pxdiff --git a/Tests/LibWeb/Text/expected/css/insert-rule-keyframes-starts-animation.txt b/Tests/LibWeb/Text/expected/css/insert-rule-keyframes-starts-animation.txtindex 6e067f74da8..c16bf14dba6 100644--- a/Tests/LibWeb/Text/expected/css/insert-rule-keyframes-starts-animation.txt+++ b/Tests/LibWeb/Text/expected/css/insert-rule-keyframes-starts-animation.txt@@ -1,3 +1,3 @@before: 1after: 1-keyframes: 0+keyframes: 2diff --git a/Tests/LibWeb/Text/expected/css/style-memory/bytes-per-animated-element.txt b/Tests/LibWeb/Text/expected/css/style-memory/bytes-per-animated-element.txtindex 1d81cbc76f3..18a8ed64051 100644--- a/Tests/LibWeb/Text/expected/css/style-memory/bytes-per-animated-element.txt+++ b/Tests/LibWeb/Text/expected/css/style-memory/bytes-per-animated-element.txt@@ -6,7 +6,7 @@ animation: 500 elementssheetSegments: within 0sharedDeclarations: within 0invalidation: within 0- records: within 456+ records: within 464payloads: within 656groupValueFacts: within 0customProperties: within 0@@ -34,7 +34,7 @@ transition: 500 elementssheetSegments: within 0sharedDeclarations: within 0invalidation: within 0- records: within 456+ records: within 464payloads: within 352groupValueFacts: within 0customProperties: within 0diff --git a/Tests/LibWeb/Text/expected/wpt-import/css/css-animations/KeyframeEffect-getKeyframes.tentative.txt b/Tests/LibWeb/Text/expected/wpt-import/css/css-animations/KeyframeEffect-getKeyframes.tentative.txtnew file mode 100644index 00000000000..b97bcd86425--- /dev/null+++ b/Tests/LibWeb/Text/expected/wpt-import/css/css-animations/KeyframeEffect-getKeyframes.tentative.txt@@ -0,0 +1,38 @@+Harness status: OK++Found 32 tests++29 Pass+3 Fail+Pass KeyframeEffect.getKeyframes() returns no frames for various kinds of empty animations+Pass KeyframeEffect.getKeyframes() returns expected frames for a simple animation+Pass KeyframeEffect.getKeyframes() returns frames with expected easing values, when the easing comes from animation-timing-function on the element+Pass KeyframeEffect.getKeyframes() returns frames with expected easing values, when the easing is specified on each keyframe+Pass KeyframeEffect.getKeyframes() returns frames with expected easing values, when the easing is specified on some keyframes+Pass KeyframeEffect.getKeyframes() returns animation-wide easing for var() keyframe easing+Pass KeyframeEffect.getKeyframes() returns frames with expected composite values, when the composite is set on the effect using animation-composition on the element+Pass KeyframeEffect.getKeyframes() returns frames with expected composite values, when the composite is specified on each keyframe+Pass KeyframeEffect.getKeyframes() returns frames with expected composite values, when the composite is specified on some keyframes+Pass KeyframeEffect.getKeyframes() returns expected frames for a simple animation that specifies a single shorthand property+Pass KeyframeEffect.getKeyframes() returns expected frames for an animation with a 0% keyframe and no 100% keyframe+Pass KeyframeEffect.getKeyframes() returns expected frames for an animation with a 100% keyframe and no 0% keyframe+Pass KeyframeEffect.getKeyframes() returns expected frames for an animation with no 0% or 100% keyframe but with a 50% keyframe+Pass KeyframeEffect.getKeyframes() returns expected frames for an animation with a partially complete 100% keyframe (because the !important rule is ignored)+Pass KeyframeEffect.getKeyframes() returns expected frames for an animation with different properties on different keyframes, all with the same easing function+Pass KeyframeEffect.getKeyframes() returns expected frames for an animation with different properties on different keyframes, with a different easing function on each+Pass KeyframeEffect.getKeyframes() returns expected frames for an animation with multiple keyframes for the same time, and all with the same easing function+Pass KeyframeEffect.getKeyframes() returns expected frames for an animation with multiple keyframes for the same time and with different easing functions+Pass KeyframeEffect.getKeyframes() returns expected frames for an animation with multiple keyframes for the same time and with different but equivalent easing functions+Pass KeyframeEffect.getKeyframes() returns expected frames for an animation with multiple keyframes for the same time and with different composite operations+Pass KeyframeEffect.getKeyframes() returns expected frames for an animation with multiple keyframes for the same time and with different easing functions and composite operations+Pass KeyframeEffect.getKeyframes() returns expected frames for overlapping keyframes+Fail KeyframeEffect.getKeyframes() returns expected values for animations with filter properties and missing keyframes+Pass KeyframeEffect.getKeyframes() returns expected values for animation with drop-shadow of filter property+Pass KeyframeEffect.getKeyframes() returns expected values for animations with text-shadow properties and missing keyframes+Pass KeyframeEffect.getKeyframes() returns expected values for animations with background-size properties and missing keyframes+Fail KeyframeEffect.getKeyframes() returns expected values for animations with CSS variables as keyframe values+Pass KeyframeEffect.getKeyframes() returns expected values for animations with CSS variables as keyframe values in a shorthand property+Pass KeyframeEffect.getKeyframes() returns expected values for animations with a CSS variable which is overriden by the value in keyframe+Fail KeyframeEffect.getKeyframes() returns expected values for animations with only custom property in a keyframe+Pass KeyframeEffect.getKeyframes() reflects changes to @keyframes rules+Pass KeyframeEffect.getKeyframes() returns expected values for animations with implicit values and a non-default timingfunction specified for 0% and 100%\ No newline at end of filediff --git a/Tests/LibWeb/Text/expected/wpt-import/css/css-animations/KeyframeEffect-setKeyframes.tentative.txt b/Tests/LibWeb/Text/expected/wpt-import/css/css-animations/KeyframeEffect-setKeyframes.tentative.txtnew file mode 100644index 00000000000..b54742c2b57--- /dev/null+++ b/Tests/LibWeb/Text/expected/wpt-import/css/css-animations/KeyframeEffect-setKeyframes.tentative.txt@@ -0,0 +1,8 @@+Harness status: OK++Found 3 tests++3 Pass+Pass KeyframeEffect.setKeyframes() causes subsequent changes to @keyframes rules to be ignored+Pass KeyframeEffect.setKeyframes() causes subsequent changes to animation-timing-function to be ignored+Pass KeyframeEffect.setKeyframes() should NOT cause subsequent changes to @keyframes rules to be ignored if it threw\ No newline at end of filediff --git a/Tests/LibWeb/Text/expected/wpt-import/css/css-transitions/KeyframeEffect-getKeyframes-width-and-height-transition.tentative.txt b/Tests/LibWeb/Text/expected/wpt-import/css/css-transitions/KeyframeEffect-getKeyframes-width-and-height-transition.tentative.txtnew file mode 100644index 00000000000..1a6deca6cc1--- /dev/null+++ b/Tests/LibWeb/Text/expected/wpt-import/css/css-transitions/KeyframeEffect-getKeyframes-width-and-height-transition.tentative.txt@@ -0,0 +1,7 @@+Harness status: OK++Found 2 tests++2 Pass+Pass getKeyframes() output for a width transition+Pass getKeyframes() output for a height transition\ No newline at end of filediff --git a/Tests/LibWeb/Text/expected/wpt-import/css/css-transitions/KeyframeEffect-getKeyframes.tentative.txt b/Tests/LibWeb/Text/expected/wpt-import/css/css-transitions/KeyframeEffect-getKeyframes.tentative.txtnew file mode 100644index 00000000000..d97c1ba3302--- /dev/null+++ b/Tests/LibWeb/Text/expected/wpt-import/css/css-transitions/KeyframeEffect-getKeyframes.tentative.txt@@ -0,0 +1,10 @@+Harness status: OK++Found 5 tests++5 Pass+Pass KeyframeEffect.getKeyframes() returns expected frames for a simple transition+Pass KeyframeEffect.getKeyframes() returns frames unaffected by a non-default easing function+Pass KeyframeEffect.getKeyframes() returns expected frames for a transition with a CSS variable endpoint+Pass KeyframeEffect.getKeyframes() returns expected frames for a transition after resetting the effect target+Pass KeyframeEffect.getKeyframes() returns expected frames for a custom property transition\ No newline at end of filediff --git a/Tests/LibWeb/Text/expected/wpt-import/css/css-transitions/KeyframeEffect-setKeyframes.tentative.txt b/Tests/LibWeb/Text/expected/wpt-import/css/css-transitions/KeyframeEffect-setKeyframes.tentative.txtnew file mode 100644index 00000000000..3f27a67452b--- /dev/null+++ b/Tests/LibWeb/Text/expected/wpt-import/css/css-transitions/KeyframeEffect-setKeyframes.tentative.txt@@ -0,0 +1,14 @@+Harness status: OK++Found 8 tests++3 Pass+5 Fail+Pass Keyframes set using setKeyframes() are reflected in computed style for a running transition+Pass A transition with replaced keyframes still returns the original transitionProperty+Pass A transition with no keyframes still returns the original transitionProperty+Fail A transition with replaced keyframes animating the same property still exhibits normal reversing behavior.+Fail A transition with replaced keyframes animating a different property still exhibits normal reversing behavior (reversing from the base value).+Fail A transition with replaced keyframes animating nothing still exhibits normal reversing behavior (reversing from the base value).+Fail A transition with replaced keyframes animating nothing on a property being controlled by another modified transition exhibits normal reversing behavior and reverses from the other transition's current value.+Fail A transition with replaced kefyrames and composite 'add' exhibits normal reversing behavior, and the effect is not double counted when calculating the before change style\ No newline at end of filediff --git a/Tests/LibWeb/Text/input/Animations/css-keyframe-copy-order-and-style.html b/Tests/LibWeb/Text/input/Animations/css-keyframe-copy-order-and-style.htmlnew file mode 100644index 00000000000..e3554008606--- /dev/null+++ b/Tests/LibWeb/Text/input/Animations/css-keyframe-copy-order-and-style.html@@ -0,0 +1,47 @@+<!doctype html>+<script src="../include.js"></script>+<style id="rules">+ @keyframes sample {+ to {+ opacity: 1;+ }+ from {+ opacity: 0;+ }+ 50% {+ opacity: 0.5;+ animation-timing-function: ease-in;+ }+ 50% {+ opacity: 0.6;+ animation-timing-function: ease-out;+ }+ }+</style>+<script>+ test(() => {+ const target = document.body.appendChild(document.createElement("div"));+ target.style.animation = "sample 100s linear paused";+ const source = target.getAnimations()[0].effect;+ const describe = effect =>+ effect+ .getKeyframes()+ .map(f => `${f.offset}: ${f.opacity} (${f.easing})`)+ .join("; ");+ const copy = new KeyframeEffect(source);+ println(`copy order: ${describe(copy)}`);+ try {+ copy.setKeyframes(copy.getKeyframes());+ println("round trip: accepted");+ } catch (error) {+ println(`round trip: ${error.name}`);+ }+ document.styleSheets[0].cssRules[0].appendRule("25% { opacity: .25 }");+ println(`copy after rule edit: ${describe(new KeyframeEffect(source))}`);+ target.style.animationTimingFunction = "ease-in-out";+ println(`copy after easing edit: ${describe(new KeyframeEffect(source))}`);+ println(`source after style flush: ${describe(source)}`);+ println(`copy after style flush: ${describe(new KeyframeEffect(source))}`);+ target.remove();+ });+</script>diff --git a/Tests/LibWeb/Text/input/Animations/css-keyframe-copy-same-offset.html b/Tests/LibWeb/Text/input/Animations/css-keyframe-copy-same-offset.htmlnew file mode 100644index 00000000000..dea0f5cc5a6--- /dev/null+++ b/Tests/LibWeb/Text/input/Animations/css-keyframe-copy-same-offset.html@@ -0,0 +1,59 @@+<!doctype html>+<script src="../include.js"></script>+<style>+@keyframes same-offset {+ from { opacity: 0.4; }+ 0% { width: 10px; }+ from { opacity: 0; }+ to { opacity: 1; width: 30px; }+}+@keyframes separate-easings {+ from { opacity: 0; animation-timing-function: steps(2, end); }+ 0% { width: 10px; animation-timing-function: linear; }+ to { opacity: 1; width: 30px; }+}+@keyframes separate-final-easings {+ from { opacity: 0; width: 10px; }+ to { opacity: 1; animation-timing-function: steps(2, end); }+ 100% { width: 30px; animation-timing-function: linear; }+}+</style>+<script>+test(() => {+ const target = document.body.appendChild(document.createElement("div"));+ target.style.cssText = "animation: same-offset 100s linear paused; width: 90px; opacity: 0.9";+ const source = target.getAnimations()[0];+ const copy = new KeyframeEffect(source.effect);+ for (const [name, effect] of [["source", source.effect], ["copy", copy]]) {+ println(`${name}: ${effect.getKeyframes().map(frame => `${frame.offset}: ${frame.width}, ${frame.opacity}`).join("; ")}`);+ }+ source.currentTime = 25000;+ println(`source playback: ${getComputedStyle(target).width}, ${getComputedStyle(target).opacity}`);+ source.cancel();+ const animation = new Animation(copy, document.timeline);+ animation.currentTime = 25000;+ println(`copy playback: ${getComputedStyle(target).width}, ${getComputedStyle(target).opacity}`);+ animation.cancel();+ target.style.animationName = "separate-easings";+ const separateSource = target.getAnimations()[0];+ const separateCopy = new KeyframeEffect(separateSource.effect);+ separateSource.cancel();+ const separateAnimation = new Animation(separateCopy, document.timeline);+ for (const time of [25000, 75000]) {+ separateAnimation.currentTime = time;+ println(`separate easing copy at ${time}: ${getComputedStyle(target).width}, ${getComputedStyle(target).opacity}`);+ }+ separateAnimation.cancel();+ target.style.animationName = "separate-final-easings";+ const finalSource = target.getAnimations()[0];+ const finalCopy = new KeyframeEffect(finalSource.effect);+ finalSource.cancel();+ const finalAnimation = new Animation(finalCopy, document.timeline);+ for (const time of [25000, 75000]) {+ finalAnimation.currentTime = time;+ println(`separate final copy at ${time}: ${getComputedStyle(target).width}, ${getComputedStyle(target).opacity}`);+ }+ finalAnimation.cancel();+ target.remove();+});+</script>diff --git a/Tests/LibWeb/Text/input/Animations/css-keyframe-effect-copy.html b/Tests/LibWeb/Text/input/Animations/css-keyframe-effect-copy.htmlnew file mode 100644index 00000000000..8c356693974--- /dev/null+++ b/Tests/LibWeb/Text/input/Animations/css-keyframe-effect-copy.html@@ -0,0 +1,32 @@+<!doctype html>+<script src="../include.js"></script>+<style id="rules">@keyframes sizes { from { width: 2em; --label: first } to { width: 4em; --label: last } }</style>+<script>+test(() => {+ const target = document.body.appendChild(document.createElement("div"));+ target.style.cssText = "font-size: 10px; animation: sizes 100s ease-in both paused";+ const source = target.getAnimations()[0].effect;+ const copy = new KeyframeEffect(source);+ const frames = effect => effect.getKeyframes().map(({width, easing, offset}) => `${offset}: ${width} (${easing})`).join("; ");+ println(`source: ${frames(source)}`);+ println(`copy: ${frames(copy)}`);+ println(`copied custom property: ${copy.getKeyframes().map(frame => frame["--label"]).join(", ")}`);+ target.style.fontSize = "20px";+ println(`copy after font change: ${frames(copy)}`);+ document.getElementById("rules").textContent = "@keyframes sizes { from { width: 10em } to { width: 20em } }";+ println(`source after rule change: ${frames(source)}`);+ println(`copy after rule change: ${frames(copy)}`);+ const animation = new Animation(copy, document.timeline);+ animation.currentTime = 50000;+ println(`copy playback width: ${Math.round(parseFloat(getComputedStyle(target).width))}px`);+ animation.cancel();+ copy.setKeyframes({ width: ["7px", "9px"] });+ println(`copy after setKeyframes: ${frames(copy)}`);+ document.getElementById("rules").textContent += ".pseudo::before { content: ''; animation: sizes 100s linear paused }";+ target.style.animation = "none";+ target.className = "pseudo";+ const pseudoCopy = new KeyframeEffect(target.getAnimations({ subtree: true })[0].effect);+ println(`copied pseudo-element: ${pseudoCopy.pseudoElement}`);+ target.remove();+});+</script>diff --git a/Tests/LibWeb/Text/input/Animations/css-keyframes-background-container-lengths.html b/Tests/LibWeb/Text/input/Animations/css-keyframes-background-container-lengths.htmlnew file mode 100644index 00000000000..3f7caa855ef--- /dev/null+++ b/Tests/LibWeb/Text/input/Animations/css-keyframes-background-container-lengths.html@@ -0,0 +1,32 @@+<!doctype html>+<script src="../include.js"></script>+<style>+ @keyframes sizes {+ to {+ background-size: 10px auto;+ }+ }+</style>+<script>+ test(() => {+ const container = document.body.appendChild(document.createElement("div"));+ container.style.cssText = "container-type:inline-size;width:300px";+ const target = container.appendChild(document.createElement("div"));+ target.style.cssText = "background-image:linear-gradient(red,blue);background-size:10cqw auto,20cqw auto";+ println(`computed: ${getComputedStyle(target).backgroundSize}`);+ target.style.animation = "sizes 100s linear paused";+ const frames = () =>+ target+ .getAnimations()[0]+ .effect.getKeyframes()+ .map(f => f.backgroundSize)+ .join("; ");+ println(`underlying: ${frames()}`);+ container.style.width = "400px";+ container.getBoundingClientRect();+ println(`resized: ${frames()}`);+ target.style.zoom = "2";+ println(`zoom: ${frames()}`);+ container.remove();+ });+</script>diff --git a/Tests/LibWeb/Text/input/Animations/css-keyframes-custom-properties.html b/Tests/LibWeb/Text/input/Animations/css-keyframes-custom-properties.htmlnew file mode 100644index 00000000000..c4bbe9f0a43--- /dev/null+++ b/Tests/LibWeb/Text/input/Animations/css-keyframes-custom-properties.html@@ -0,0 +1,81 @@+<!doctype html>+<script src="../include.js"></script>+<style>+ @property --distance {+ syntax: "<length>";+ inherits: false;+ initial-value: 3px;+ }+ @property --tint {+ syntax: "<color>";+ inherits: true;+ initial-value: blue;+ }+ @keyframes registered {+ from {+ --distance: 1em;+ --tint: red;+ --plain: first;+ }+ to {+ --distance: 2em;+ --tint: blue;+ --plain: last;+ }+ }+ @keyframes endpoint {+ to {+ --distance: 4em;+ }+ }+ @keyframes middle {+ 50% {+ --distance: 2em;+ animation-timing-function: ease-in;+ }+ }+ @keyframes unregistered {+ from {+ --plain: first;+ animation-timing-function: ease-out;+ }+ to {+ --plain: last;+ }+ }+</style>+<script>+ test(() => {+ const target = document.body.appendChild(document.createElement("div"));+ target.style.cssText = "font-size:10px; --distance:7px; animation:registered 100s linear paused";+ const show = () =>+ target+ .getAnimations()[0]+ .effect.getKeyframes()+ .map(f =>+ JSON.stringify({+ offset: f.offset,+ easing: f.easing,+ composite: f.composite,+ distance: f["--distance"],+ tint: f["--tint"],+ plain: f["--plain"],+ })+ )+ .join("; ");+ println(`registered: ${show()}`);+ target.style.fontSize = "20px";+ println(`font change: ${show()}`);+ target.style.animationName = "endpoint";+ println(`implicit endpoint: ${show()}`);+ target.style.setProperty("--distance", "9px");+ println(`changed underlying: ${show()}`);+ target.style.zoom = "2";+ println(`zoom: ${show()}`);+ for (const name of ["middle", "unregistered"]) {+ target.style.animationName = name;+ println(`${name}: ${show()}`);+ }+ target.remove();+ });+</script>diff --git a/Tests/LibWeb/Text/input/Animations/css-keyframes-removed-target.html b/Tests/LibWeb/Text/input/Animations/css-keyframes-removed-target.htmlnew file mode 100644index 00000000000..282c7a2dd86--- /dev/null+++ b/Tests/LibWeb/Text/input/Animations/css-keyframes-removed-target.html@@ -0,0 +1,23 @@+<!doctype html>+<script src="../include.js"></script>+<style>+@keyframes detached {+ from { opacity: 0.2; width: 2em; }+ to { opacity: 0.8; width: 4em; }+}+</style>+<script>+test(() => {+ const target = document.body.appendChild(document.createElement("div"));+ target.style.cssText = "font-size: 10px; animation: detached 100s linear paused";+ const effect = target.getAnimations()[0].effect;+ const describe = () => effect.getKeyframes().map(frame => `${frame.offset}: ${frame.width}, ${frame.opacity}`).join("; ");+ println(`attached: ${describe()}`);+ target.remove();+ println(`removed: ${describe()}`);+ document.body.offsetWidth;+ println(`removed after layout: ${describe()}`);+ effect.target = null;+ println(`null target: ${describe()}`);+});+</script>diff --git a/Tests/LibWeb/Text/input/Animations/css-keyframes-underlying-background-list.html b/Tests/LibWeb/Text/input/Animations/css-keyframes-underlying-background-list.htmlnew file mode 100644index 00000000000..36336bb11c4--- /dev/null+++ b/Tests/LibWeb/Text/input/Animations/css-keyframes-underlying-background-list.html@@ -0,0 +1,38 @@+<!doctype html>+<script src="../include.js"></script>+<style>+@keyframes sizes { to { background-size: 50% auto, 6px auto, contain } }+.parent { background-size: 30px auto, 40% auto, auto }+.target { background-image: linear-gradient(red, blue); background-size: inherit; animation: sizes 100s linear paused }+</style>+<script>+test(() => {+ const parent = document.body.appendChild(document.createElement("div"));+ parent.className = "parent";+ const target = parent.appendChild(document.createElement("div"));+ target.className = "target";+ const effect = target.getAnimations()[0].effect;+ const frames = () => effect.getKeyframes().map(frame => frame.backgroundSize).join("; ");+ println(`inherited list: ${frames()}`);+ target.style.backgroundSize = "20px auto, 60% auto";+ println(`own list: ${frames()}`);+ target.style.backgroundSize = "20px auto, 70% auto";+ println(`changed unused layer: ${frames()}`);+ println(`ordinary computed layer count: ${getComputedStyle(target).backgroundSize.split(",").length}`);+ target.style.backgroundImage = "none, none, none, none";+ println(`more image layers: ${frames()}`);+ target.style.backgroundImage = "none";+ target.style.backgroundSize = "inherit";+ println(`inherit after own list: ${frames()}`);+ target.style.backgroundSize = "2em auto, calc(3em + 1px) auto";+ target.style.fontSize = "10px";+ target.style.zoom = 2;+ println(`relative lengths under zoom: ${frames()}`);+ target.style.fontSize = "20px";+ println(`changed font: ${frames()}`);+ document.styleSheets[0].deleteRule(0);+ document.styleSheets[0].insertRule("@keyframes sizes { to { background-size: 5px auto } }", 0);+ println(`shorter explicit list: ${frames()}`);+ parent.remove();+});+</script>diff --git a/Tests/LibWeb/Text/input/Animations/css-transition-keyframes-detached-zoom.html b/Tests/LibWeb/Text/input/Animations/css-transition-keyframes-detached-zoom.htmlnew file mode 100644index 00000000000..d4c70f9e2b1--- /dev/null+++ b/Tests/LibWeb/Text/input/Animations/css-transition-keyframes-detached-zoom.html@@ -0,0 +1,24 @@+<!doctype html>+<script src="../include.js"></script>+<script>+test(() => {+ const target = document.body.appendChild(document.createElement("div"));+ target.style.cssText = "zoom: 2; width: 10px; transition: width 100s linear";+ getComputedStyle(target).width;+ target.style.width = "30px";+ const transition = target.getAnimations()[0];+ transition.pause();+ const frames = effect => effect.getKeyframes().map(frame => frame.width).join(", ");+ println(`original target: ${frames(transition.effect)}`);+ transition.effect.target = null;+ const other = document.body.appendChild(document.createElement("div"));+ other.style.zoom = 4;+ transition.effect.target = other;+ println(`different target: ${frames(transition.effect)}`);+ const copy = new KeyframeEffect(transition.effect);+ println(`copied transition: ${frames(copy)}`);+ transition.cancel();+ target.remove();+ other.remove();+});+</script>diff --git a/Tests/LibWeb/Text/input/WebAnimations/css-keyframe-reflection.html b/Tests/LibWeb/Text/input/WebAnimations/css-keyframe-reflection.htmlnew file mode 100644index 00000000000..5ce301aa1d0--- /dev/null+++ b/Tests/LibWeb/Text/input/WebAnimations/css-keyframe-reflection.html@@ -0,0 +1,71 @@+<!doctype html>+<meta charset="utf-8">+<title>CSS keyframe reflection preserves animation state</title>+<script src="../include.js"></script>+<style>+@keyframes grow { from { width: 20px } to { width: var(--end, 100px) } }+@keyframes fade { from { opacity: 0 } to { opacity: 1 } }+@keyframes relative { from { margin-left: 2em } to { margin-left: 3em } }+@keyframes layers { to { background-size: 50%, 6px, contain } }+@keyframes partial {+ from { opacity: 0; animation-composition: replace }+ to { opacity: 1; width: 100px }+}+</style>+<script>+test(() => {+ const target = document.createElement("div");+ document.body.append(target);+ target.style.cssText = "animation: grow 1s linear paused both, fade 1s linear paused both";+ const [grow, fade] = target.getAnimations();+ grow.currentTime = fade.currentTime = 500;+ const effect = grow.effect;+ const first = effect.getKeyframes();+ println(`width frames: ${first.map(frame => frame.width)}`);+ if (first.length)+ first[0].width = "999px";+ const second = effect.getKeyframes();+ println(`fresh width frames: ${second.map(frame => frame.width)}`);+ println(`same object: ${first[0] === second[0]}`);+ println(`middle: ${getComputedStyle(target).width}, ${getComputedStyle(target).opacity}`);+ grow.currentTime = fade.currentTime = 750;+ println(`after inspection: ${getComputedStyle(target).width}, ${getComputedStyle(target).opacity}`);+ target.style.setProperty("--end", "200px");+ println(`pending variable change: ${effect.getKeyframes().map(frame => frame.width)}`);+ println(`after variable change: ${getComputedStyle(target).width}, ${getComputedStyle(target).opacity}`);+ target.style.setProperty("width", "7px", "important");+ println(`important width frames: ${effect.getKeyframes().map(frame => frame.width)}`);+ println(`important width: ${getComputedStyle(target).width}`);+ target.remove();++ const relative = document.createElement("div");+ relative.style.cssText = "font-size: 10px; animation: relative 1s linear paused both";+ document.body.append(relative);+ const relativeEffect = relative.getAnimations()[0].effect;+ println(`computed lengths: ${relativeEffect.getKeyframes().map(frame => frame.marginLeft)}`);+ relative.style.fontSize = "20px";+ println(`pending font change: ${relativeEffect.getKeyframes().map(frame => frame.marginLeft)}`);+ relative.style.zoom = "2";+ println(`zoomed lengths: ${relativeEffect.getKeyframes().map(frame => frame.marginLeft)}`);+ relativeEffect.setKeyframes({ marginLeft: ["4em", "5em"] });+ relative.style.fontSize = "30px";+ println(`script lengths: ${relativeEffect.getKeyframes().map(frame => frame.marginLeft)}`);+ relative.remove();++ const layers = document.createElement("div");+ layers.style.animation = "layers 1s linear paused both";+ document.body.append(layers);+ println(`background layers: ${layers.getAnimations()[0].effect.getKeyframes().map(frame => frame.backgroundSize).join(" / ")}`);+ layers.remove();++ const partial = document.createElement("div");+ partial.style.cssText = "width: 20px; animation: partial 1s linear paused both";+ document.body.append(partial);+ const partialEffect = partial.getAnimations()[0].effect;+ const describe = frames => frames.map(frame => `${frame.offset}/${frame.composite}/${frame.opacity}/${frame.width}`).join(" ");+ println(`partial replace endpoint: ${describe(partialEffect.getKeyframes())}`);+ partial.style.animationComposition = "add";+ println(`partial additive endpoint: ${describe(partialEffect.getKeyframes())}`);+ partial.remove();+});+</script>diff --git a/Tests/LibWeb/Text/input/css/style-memory/bytes-per-animated-element.html b/Tests/LibWeb/Text/input/css/style-memory/bytes-per-animated-element.htmlindex 5ef5141a90c..e0d935ca426 100644--- a/Tests/LibWeb/Text/input/css/style-memory/bytes-per-animated-element.html+++ b/Tests/LibWeb/Text/input/css/style-memory/bytes-per-animated-element.html@@ -49,7 +49,7 @@// - hostMemo: the versions of the effects the host described to the engine.// - styleValues: the animated value of the longhand the payload of its group holds.const animationBudgets = {- records: 456,+ records: 464,payloads: 656,retainedSlots: 36,recordCells: 4,@@ -65,7 +65,7 @@cppInstalledStyles: 8,};const transitionBudgets = {- records: 456,+ records: 464,payloads: 352,retainedSlots: 36,recordCells: 4,diff --git a/Tests/LibWeb/Text/input/wpt-import/css/css-animations/KeyframeEffect-getKeyframes.tentative.html b/Tests/LibWeb/Text/input/wpt-import/css/css-animations/KeyframeEffect-getKeyframes.tentative.htmlnew file mode 100644index 00000000000..243e6e4f803--- /dev/null+++ b/Tests/LibWeb/Text/input/wpt-import/css/css-animations/KeyframeEffect-getKeyframes.tentative.html@@ -0,0 +1,903 @@+<!doctype html>+<meta charset=utf-8>+<title>KeyframeEffect.getKeyframes() for CSS animations</title>+<!-- TODO: Add a more specific link for this once it is specified. -->+<link rel="help" href="https://drafts.csswg.org/css-animations-2/">+<script src="../../resources/testharness.js"></script>+<script src="../../resources/testharnessreport.js"></script>+<script src="support/testcommon.js"></script>+<style>+@keyframes anim-empty { }++@keyframes anim-empty-frames {+ from { }+ to { }+}++@keyframes anim-only-timing {+ from { animation-timing-function: linear; }+ to { }+}++@keyframes anim-keyframe-timing-var {+ from { color: rgb(0, 0, 0); animation-timing-function: var(--kf_ease); }+ to { color: rgb(255, 255, 255); }+}++@keyframes anim-only-non-animatable {+ from { animation-duration: 3s; }+ to { animation-duration: 5s; }+}++@keyframes anim-simple {+ from { color: rgb(0, 0, 0); }+ to { color: rgb(255, 255, 255); }+}++@keyframes anim-simple-three {+ from { color: rgb(0, 0, 0); }+ 50% { color: rgb(0, 0, 255); }+ to { color: rgb(255, 255, 255); }+}++@keyframes anim-simple-timing {+ from { color: rgb(0, 0, 0); animation-timing-function: linear; }+ 50% { color: rgb(0, 0, 255); animation-timing-function: ease-in-out; }+ to { color: rgb(255, 255, 255); animation-timing-function: step-end; }+}++@keyframes anim-simple-timing-some {+ from { color: rgb(0, 0, 0); animation-timing-function: linear; }+ 50% { color: rgb(0, 0, 255); }+ to { color: rgb(255, 255, 255); }+}++@keyframes anim-simple-composite {+ from { color: rgb(0, 0, 0); animation-composition: replace; }+ 50% { color: rgb(0, 0, 255); animation-composition: add; }+ to { color: rgb(255, 255, 255); animation-composition: accumulate; }+}++@keyframes anim-simple-composite-some {+ from { color: rgb(0, 0, 0); animation-composition: add; }+ 50% { color: rgb(0, 0, 255); }+ to { color: rgb(255, 255, 255); }+}++@keyframes anim-simple-shorthand {+ from { margin: 8px; }+ to { margin: 16px; }+}++@keyframes anim-omit-to {+ from { color: rgb(0, 0, 255); }+}++@keyframes anim-omit-from {+ to { color: rgb(0, 0, 255); }+}++@keyframes anim-omit-from-to {+ 50% { color: rgb(0, 0, 255); }+}++@keyframes anim-partially-omit-to {+ from { margin-top: 50px;+ margin-bottom: 100px; }+ to { margin-top: 150px !important; /* ignored */+ margin-bottom: 200px; }+}++@keyframes anim-different-props {+ from { color: rgb(0, 0, 0); margin-top: 8px; }+ 25% { color: rgb(0, 0, 255); }+ 75% { margin-top: 12px; }+ to { color: rgb(255, 255, 255); margin-top: 16px }+}++@keyframes anim-different-props-and-easing {+ from { color: rgb(0, 0, 0); margin-top: 8px; animation-timing-function: linear; }+ 25% { color: rgb(0, 0, 255); animation-timing-function: step-end; }+ 75% { margin-top: 12px; animation-timing-function: ease-in; }+ to { color: rgb(255, 255, 255); margin-top: 16px }+}++@keyframes anim-merge-offset {+ from { color: rgb(0, 0, 0); }+ to { color: rgb(255, 255, 255); }+ from { margin-top: 8px; }+ to { margin-top: 16px; }+}++@keyframes anim-merge-offset-and-easing {+ from { color: rgb(0, 0, 0); animation-timing-function: step-end; }+ to { color: rgb(255, 255, 255); }+ from { margin-top: 8px; animation-timing-function: linear; }+ to { margin-top: 16px; }+ from { font-size: 16px; animation-timing-function: step-end; }+ to { font-size: 32px; }+ from { padding-left: 2px; animation-timing-function: linear; }+ to { padding-left: 4px; }+}++@keyframes anim-no-merge-equiv-easing {+ from { margin-top: 0px; animation-timing-function: steps(1, end); }+ from { margin-right: 0px; animation-timing-function: step-end; }+ from { margin-bottom: 0px; animation-timing-function: steps(1); }+ 50% { margin-top: 10px; animation-timing-function: step-end; }+ 50% { margin-right: 10px; animation-timing-function: step-end; }+ 50% { margin-bottom: 10px; animation-timing-function: step-end; }+ to { margin-top: 20px; margin-right: 20px; margin-bottom: 20px; }+}++@keyframes anim-merge-offset-and-composite {+ from { color: rgb(0, 0, 0); animation-composition: add; }+ to { color: rgb(255, 255, 255); }+ from { margin-top: 8px; animation-composition: accumulate; }+ to { margin-top: 16px; }+ from { font-size: 16px; animation-composition: add; }+ to { font-size: 32px; }+ from { padding-left: 2px; animation-composition: accumulate; }+ to { padding-left: 4px; }+}++@keyframes anim-merge-offset-easing-and-composite {+ from { color: rgb(0, 0, 0); animation-composition: add; }+ to { color: rgb(255, 255, 255); }+ from { margin-top: 8px; animation-composition: accumulate; }+ to { margin-top: 16px; }+ from { font-size: 16px; animation-composition: add; animation-timing-function: linear; }+ to { font-size: 32px; }+ from { padding-left: 2px; animation-composition: accumulate; }+ to { padding-left: 4px; }+}++@keyframes anim-overriding {+ from { padding-top: 50px }+ 50%, from { padding-top: 30px } /* wins: 0% */+ 75%, 85%, 50% { padding-top: 20px } /* wins: 75%, 50% */+ 100%, 85% { padding-top: 70px } /* wins: 100% */+ 85.1% { padding-top: 60px } /* wins: 85.1% */+ 85% { padding-top: 30px } /* wins: 85% */+}++@keyframes anim-filter {+ to { filter: blur(5px) sepia(60%) saturate(30%); }+}++@keyframes anim-filter-drop-shadow {+ from { filter: drop-shadow(10px 10px 10px rgb(0, 255, 0)); }+ to { filter: drop-shadow(50px 30px 10px rgb(255, 0, 0)); }+}++@keyframes anim-text-shadow {+ to { text-shadow: none; }+}++@keyframes anim-background-size {+ to { background-size: 50%, 6px, contain }+}++:root {+ --var-100px: 100px;+ --end-color: rgb(255, 0, 0);+}+@keyframes anim-variables {+ to { transform: translate(var(--var-100px), 0) }+}+@keyframes anim-variables-shorthand {+ to { margin: var(--var-100px) }+}+@keyframes anim-custom-property-in-keyframe {+ to { --end-color: rgb(0, 255, 0); color: var(--end-color) }+}+@keyframes anim-only-custom-property-in-keyframe {+ from { transform: translate(100px, 0) }+ to { --not-used: 200px }+}++@keyframes anim-only-timing-function-for-from-and-to {+ from, to { animation-timing-function: linear }+ 50% { left: 10px }+}++</style>+<body>+<div id="log"></div>+<script>+"use strict";++const getKeyframes = elem => elem.getAnimations()[0].effect.getKeyframes();++// animation-timing-function values to test with, where the value+// is exactly the same as its serialization, sorted by the order+// getKeyframes() will group frames with the same easing function+// together (by nsTimingFunction::Compare).+const kTimingFunctionValues = [+ "ease",+ "linear",+ "ease-in",+ "ease-out",+ "ease-in-out",+ "steps(1, start)",+ "steps(2, start)",+ "steps(1)",+ "steps(2)",+ "cubic-bezier(0, 0, 1, 1)",+ "cubic-bezier(0, 0.25, 0.75, 1)"+];++const kCompositeValues = [+ "replace",+ "add",+ "accumulate"+];++test(t => {+ const div = addDiv(t);++ div.style.animation = 'anim-empty 100s';+ assert_equals(getKeyframes(div).length, 0,+ "number of frames with empty @keyframes");++ div.style.animation = 'anim-empty-frames 100s';+ assert_equals(getKeyframes(div).length, 0,+ "number of frames when @keyframes has empty keyframes");++ div.style.animation = 'anim-only-timing 100s';+ assert_equals(getKeyframes(div).length, 0,+ "number of frames when @keyframes only has keyframes with " ++ "animation-timing-function");++ div.style.animation = 'anim-only-non-animatable 100s';+ assert_equals(getKeyframes(div).length, 0,+ "number of frames when @keyframes only has frames with " ++ "non-animatable properties");+}, 'KeyframeEffect.getKeyframes() returns no frames for various kinds'+ + ' of empty animations');++test(t => {+ const div = addDiv(t);+ div.style.animation = 'anim-simple 100s';++ const frames = getKeyframes(div);++ const expected = [+ { offset: 0, computedOffset: 0, easing: "ease",+ color: "rgb(0, 0, 0)", composite: "auto" },+ { offset: 1, computedOffset: 1, easing: "ease",+ color: "rgb(255, 255, 255)", composite: "auto" },+ ];+ assert_frame_lists_equal(frames, expected);+}, 'KeyframeEffect.getKeyframes() returns expected frames for a simple'+ + ' animation');++test(t => {+ for (const easing of kTimingFunctionValues) {+ const div = addDiv(t);++ div.style.animation = 'anim-simple-three 100s ' + easing;+ const frames = getKeyframes(div);++ assert_equals(frames.length, 3, "number of frames");++ for (let i = 0; i < frames.length; i++) {+ assert_equals(frames[i].easing, easing,+ "value for 'easing' on ComputedKeyframe #" + i);+ }+ }+}, 'KeyframeEffect.getKeyframes() returns frames with expected easing'+ + ' values, when the easing comes from animation-timing-function on the'+ + ' element');++test(t => {+ const div = addDiv(t);++ div.style.animation = 'anim-simple-timing 100s';+ const frames = getKeyframes(div);++ assert_equals(frames.length, 3, "number of frames");+ assert_equals(frames[0].easing, "linear",+ "value of 'easing' on ComputedKeyframe #0");+ assert_equals(frames[1].easing, "ease-in-out",+ "value of 'easing' on ComputedKeyframe #1");+ assert_equals(frames[2].easing, "steps(1)",+ "value of 'easing' on ComputedKeyframe #2");+}, 'KeyframeEffect.getKeyframes() returns frames with expected easing'+ + ' values, when the easing is specified on each keyframe');++test(t => {+ const div = addDiv(t);++ div.style.animation = 'anim-simple-timing-some 100s step-start';+ const frames = getKeyframes(div);++ assert_equals(frames.length, 3, "number of frames");+ assert_equals(frames[0].easing, "linear",+ "value of 'easing' on ComputedKeyframe #0");+ assert_equals(frames[1].easing, "steps(1, start)",+ "value of 'easing' on ComputedKeyframe #1");+ assert_equals(frames[2].easing, "steps(1, start)",+ "value of 'easing' on ComputedKeyframe #2");+}, 'KeyframeEffect.getKeyframes() returns frames with expected easing'+ + ' values, when the easing is specified on some keyframes');++test(t => {+ const div = addDiv(t);+ div.style.setProperty('--kf_ease', 'steps(2, start)');++ // Note: This test matches current interop behavior (Firefox/Safari/Chromium),+ // not necessarily the spec-intended behavior for var() in keyframe easing.+ div.style.animation = 'anim-keyframe-timing-var 100s linear';++ const animation = div.getAnimations()[0];+ assert_equals(animation.effect.getTiming().easing, 'linear',+ "value of 'easing' on effect.getTiming()");++ const frames = getKeyframes(div);+ assert_equals(frames.length, 2, "number of frames");+ assert_equals(frames[0].easing, "linear",+ "value of 'easing' on ComputedKeyframe #0");+ assert_equals(frames[1].easing, "linear",+ "value of 'easing' on ComputedKeyframe #1");+}, 'KeyframeEffect.getKeyframes() returns animation-wide easing for var() keyframe easing');++test(t => {+ for (const composite of kCompositeValues) {+ const div = addDiv(t);++ div.style.animation = 'anim-simple-three 100s';+ div.style.animationComposition = composite;+ const frames = getKeyframes(div);++ assert_equals(frames.length, 3, "number of frames");++ for (let i = 0; i < frames.length; i++) {+ assert_equals(frames[i].composite, "auto",+ "value for 'composite' on ComputedKeyframe #" + i);+ }+ }+}, 'KeyframeEffect.getKeyframes() returns frames with expected composite'+ + ' values, when the composite is set on the effect using animation-composition on the'+ + ' element');++test(t => {+ const div = addDiv(t);++ div.style.animation = 'anim-simple-composite 100s';+ const frames = getKeyframes(div);++ assert_equals(frames.length, 3, "number of frames");+ assert_equals(frames[0].composite, "replace",+ "value of 'composite' on ComputedKeyframe #0");+ assert_equals(frames[1].composite, "add",+ "value of 'composite' on ComputedKeyframe #1");+ assert_equals(frames[2].composite, "accumulate",+ "value of 'composite' on ComputedKeyframe #2");+}, 'KeyframeEffect.getKeyframes() returns frames with expected composite'+ + ' values, when the composite is specified on each keyframe');++test(t => {+ const div = addDiv(t);++ div.style.animation = 'anim-simple-composite-some 100s';+ div.style.animationComposition = 'accumulate';+ const frames = getKeyframes(div);++ assert_equals(frames.length, 3, "number of frames");+ assert_equals(frames[0].composite, "add",+ "value of 'composite' on ComputedKeyframe #0");+ assert_equals(frames[1].composite, "auto",+ "value of 'composite' on ComputedKeyframe #1");+ assert_equals(frames[2].composite, "auto",+ "value of 'composite' on ComputedKeyframe #2");+}, 'KeyframeEffect.getKeyframes() returns frames with expected composite'+ + ' values, when the composite is specified on some keyframes');++test(t => {+ const div = addDiv(t);+ div.style.animation = 'anim-simple-shorthand 100s';++ const frames = getKeyframes(div);++ const expected = [+ { offset: 0, computedOffset: 0, easing: "ease", composite: "auto",+ marginBottom: "8px", marginLeft: "8px",+ marginRight: "8px", marginTop: "8px" },+ { offset: 1, computedOffset: 1, easing: "ease", composite: "auto",+ marginBottom: "16px", marginLeft: "16px",+ marginRight: "16px", marginTop: "16px" },+ ];+ assert_frame_lists_equal(frames, expected);+}, 'KeyframeEffect.getKeyframes() returns expected frames for a simple'+ + ' animation that specifies a single shorthand property');++test(t => {+ const div = addDiv(t);+ div.style.animation = 'anim-omit-to 100s';+ div.style.color = 'rgb(255, 255, 255)';++ const frames = getKeyframes(div);++ // Final keyframe should be replace as per sections 7 and 8 of+ // https://drafts.csswg.org/css-animations-2/#keyframes+ const expected = [+ { offset: 0, computedOffset: 0, easing: "ease", composite: "auto",+ color: "rgb(0, 0, 255)" },+ { offset: 1, computedOffset: 1, easing: "ease", composite: "replace",+ color: "rgb(255, 255, 255)" },+ ];+ assert_frame_lists_equal(frames, expected);+}, 'KeyframeEffect.getKeyframes() returns expected frames for an ' ++ 'animation with a 0% keyframe and no 100% keyframe');++test(t => {+ const div = addDiv(t);+ div.style.animation = 'anim-omit-from 100s';+ div.style.color = 'rgb(255, 255, 255)';++ const frames = getKeyframes(div);++ // Initial keyframe should be replace as per sections 7 and 8 of+ // https://drafts.csswg.org/css-animations-2/#keyframes+ const expected = [+ { offset: 0, computedOffset: 0, easing: "ease", composite: "replace",+ color: "rgb(255, 255, 255)" },+ { offset: 1, computedOffset: 1, easing: "ease", composite: "auto",+ color: "rgb(0, 0, 255)" },+ ];+ assert_frame_lists_equal(frames, expected);+}, 'KeyframeEffect.getKeyframes() returns expected frames for an ' ++ 'animation with a 100% keyframe and no 0% keyframe');++test(t => {+ const div = addDiv(t);+ div.style.animation = 'anim-omit-from-to 100s';+ div.style.color = 'rgb(255, 255, 255)';++ const frames = getKeyframes(div);++ // Initial and final keyframes should be replace as per sections 7 and 8 of+ // https://drafts.csswg.org/css-animations-2/#keyframes+ const expected = [+ { offset: 0, computedOffset: 0, easing: "ease", composite: "replace",+ color: "rgb(255, 255, 255)" },+ { offset: 0.5, computedOffset: 0.5, easing: "ease", composite: "auto",+ color: "rgb(0, 0, 255)" },+ { offset: 1, computedOffset: 1, easing: "ease", composite: "replace",+ color: "rgb(255, 255, 255)" },+ ];+ assert_frame_lists_equal(frames, expected);+}, 'KeyframeEffect.getKeyframes() returns expected frames for an ' ++ 'animation with no 0% or 100% keyframe but with a 50% keyframe');++test(t => {+ const div = addDiv(t);+ div.style.animation = 'anim-partially-omit-to 100s';+ div.style.marginTop = '250px';++ const frames = getKeyframes(div);++ const expected = [+ { offset: 0, computedOffset: 0, easing: "ease", composite: "auto",+ marginTop: '50px', marginBottom: '100px' },+ { offset: 1, computedOffset: 1, easing: "ease", composite: "auto",+ marginTop: '250px', marginBottom: '200px' },+ ];+ assert_frame_lists_equal(frames, expected);+}, 'KeyframeEffect.getKeyframes() returns expected frames for an ' ++ 'animation with a partially complete 100% keyframe (because the ' ++ '!important rule is ignored)');++test(t => {+ const div = addDiv(t);+ div.style.animation = 'anim-different-props 100s';++ const frames = getKeyframes(div);++ const expected = [+ { offset: 0, computedOffset: 0, easing: "ease", composite: "auto",+ color: "rgb(0, 0, 0)", marginTop: "8px" },+ { offset: 0.25, computedOffset: 0.25, easing: "ease", composite: "auto",+ color: "rgb(0, 0, 255)" },+ { offset: 0.75, computedOffset: 0.75, easing: "ease", composite: "auto",+ marginTop: "12px" },+ { offset: 1, computedOffset: 1, easing: "ease", composite: "auto",+ color: "rgb(255, 255, 255)", marginTop: "16px" },+ ];+ assert_frame_lists_equal(frames, expected);+}, 'KeyframeEffect.getKeyframes() returns expected frames for an ' ++ 'animation with different properties on different keyframes, all ' ++ 'with the same easing function');++test(t => {+ const div = addDiv(t);+ div.style.animation = 'anim-different-props-and-easing 100s';++ const frames = getKeyframes(div);++ const expected = [+ { offset: 0, computedOffset: 0, easing: "linear", composite: "auto",+ color: "rgb(0, 0, 0)", marginTop: "8px" },+ { offset: 0.25, computedOffset: 0.25, easing: "steps(1)", composite: "auto",+ color: "rgb(0, 0, 255)" },+ { offset: 0.75, computedOffset: 0.75, easing: "ease-in", composite: "auto",+ marginTop: "12px" },+ { offset: 1, computedOffset: 1, easing: "ease", composite: "auto",+ color: "rgb(255, 255, 255)", marginTop: "16px" },+ ];+ assert_frame_lists_equal(frames, expected);+}, 'KeyframeEffect.getKeyframes() returns expected frames for an ' ++ 'animation with different properties on different keyframes, with ' ++ 'a different easing function on each');++test(t => {+ const div = addDiv(t);+ div.style.animation = 'anim-merge-offset 100s';++ const frames = getKeyframes(div);++ const expected = [+ { offset: 0, computedOffset: 0, easing: "ease", composite: "auto",+ color: "rgb(0, 0, 0)", marginTop: "8px" },+ { offset: 1, computedOffset: 1, easing: "ease", composite: "auto",+ color: "rgb(255, 255, 255)", marginTop: "16px" },+ ];+ assert_frame_lists_equal(frames, expected);+}, 'KeyframeEffect.getKeyframes() returns expected frames for an ' ++ 'animation with multiple keyframes for the same time, and all with ' ++ 'the same easing function');++test(t => {+ const div = addDiv(t);+ div.style.animation = 'anim-merge-offset-and-easing 100s';++ const frames = getKeyframes(div);++ const expected = [+ { offset: 0, computedOffset: 0, easing: "steps(1)", composite: "auto",+ color: "rgb(0, 0, 0)", fontSize: "16px" },+ { offset: 0, computedOffset: 0, easing: "linear", composite: "auto",+ marginTop: "8px", paddingLeft: "2px" },+ { offset: 1, computedOffset: 1, easing: "ease", composite: "auto",+ color: "rgb(255, 255, 255)", fontSize: "32px", marginTop: "16px",+ paddingLeft: "4px" },+ ];+ assert_frame_lists_equal(frames, expected);+}, 'KeyframeEffect.getKeyframes() returns expected frames for an ' ++ 'animation with multiple keyframes for the same time and with ' ++ 'different easing functions');++test(t => {+ const div = addDiv(t);+ div.style.animation = 'anim-no-merge-equiv-easing 100s';++ const frames = getKeyframes(div);++ const expected = [+ { offset: 0, computedOffset: 0, easing: "steps(1)", composite: "auto",+ marginTop: "0px", marginRight: "0px", marginBottom: "0px" },+ { offset: 0.5, computedOffset: 0.5, easing: "steps(1)", composite: "auto",+ marginTop: "10px", marginRight: "10px", marginBottom: "10px" },+ { offset: 1, computedOffset: 1, easing: "ease", composite: "auto",+ marginTop: "20px", marginRight: "20px", marginBottom: "20px" },+ ];+ assert_frame_lists_equal(frames, expected);+}, 'KeyframeEffect.getKeyframes() returns expected frames for an ' ++ 'animation with multiple keyframes for the same time and with ' ++ 'different but equivalent easing functions');++test(t => {+ const div = addDiv(t);+ div.style.animation = 'anim-merge-offset-and-composite 100s';++ const frames = getKeyframes(div);++ const expected = [+ { offset: 0, computedOffset: 0, easing: "ease", composite: "add",+ color: "rgb(0, 0, 0)", fontSize: "16px" },+ { offset: 0, computedOffset: 0, easing: "ease", composite: "accumulate",+ marginTop: "8px", paddingLeft: "2px" },+ { offset: 1, computedOffset: 1, easing: "ease", composite: "auto",+ color: "rgb(255, 255, 255)", fontSize: "32px", marginTop: "16px",+ paddingLeft: "4px" },+ ];+ assert_frame_lists_equal(frames, expected);+}, 'KeyframeEffect.getKeyframes() returns expected frames for an ' ++ 'animation with multiple keyframes for the same time and with ' ++ 'different composite operations');++test(t => {+ const div = addDiv(t);+ div.style.animation = 'anim-merge-offset-easing-and-composite 100s';++ const frames = getKeyframes(div);++ const expected = [+ { offset: 0, computedOffset: 0, easing: "ease", composite: "add",+ color: "rgb(0, 0, 0)" },+ { offset: 0, computedOffset: 0, easing: "ease", composite: "accumulate",+ marginTop: "8px", paddingLeft: "2px" },+ { offset: 0, computedOffset: 0, easing: "linear", composite: "add",+ fontSize: "16px" },+ { offset: 1, computedOffset: 1, easing: "ease", composite: "auto",+ color: "rgb(255, 255, 255)", fontSize: "32px", marginTop: "16px",+ paddingLeft: "4px" },+ ];+ assert_frame_lists_equal(frames, expected);+}, 'KeyframeEffect.getKeyframes() returns expected frames for an ' ++ 'animation with multiple keyframes for the same time and with ' ++ 'different easing functions and composite operations');++test(t => {+ const div = addDiv(t);+ div.style.animation = 'anim-overriding 100s';++ const frames = getKeyframes(div);++ const expected = [+ { offset: 0, computedOffset: 0, easing: "ease", composite: "auto",+ paddingTop: "30px" },+ { offset: 0.5, computedOffset: 0.5, easing: "ease", composite: "auto",+ paddingTop: "20px" },+ { offset: 0.75, computedOffset: 0.75, easing: "ease", composite: "auto",+ paddingTop: "20px" },+ { offset: 0.85, computedOffset: 0.85, easing: "ease", composite: "auto",+ paddingTop: "30px" },+ { offset: 0.851, computedOffset: 0.851, easing: "ease", composite: "auto",+ paddingTop: "60px" },+ { offset: 1, computedOffset: 1, easing: "ease", composite: "auto",+ paddingTop: "70px" },+ ];+ assert_frame_lists_equal(frames, expected);+}, 'KeyframeEffect.getKeyframes() returns expected frames for ' ++ 'overlapping keyframes');++// Gecko-specific test case: We are specifically concerned here that the+// computed value for filter, "none", is correctly represented.++test(t => {+ const div = addDiv(t);+ div.style.animation = 'anim-filter 100s';++ const frames = getKeyframes(div);++ // Initial keyframe should be replace as per sections 7 and 8 of+ // https://drafts.csswg.org/css-animations-2/#keyframes+ const expected = [+ { offset: 0, computedOffset: 0, easing: "ease", composite: "replace",+ filter: "none" },+ { offset: 1, computedOffset: 1, easing: "ease", composite: "auto",+ filter: "blur(5px) sepia(60%) saturate(30%)" },+ ];+ assert_frame_lists_equal(frames, expected);+}, 'KeyframeEffect.getKeyframes() returns expected values for ' ++ 'animations with filter properties and missing keyframes');++test(t => {+ const div = addDiv(t);+ div.style.animation = 'anim-filter-drop-shadow 100s';++ const frames = getKeyframes(div);++ const expected = [+ { offset: 0, computedOffset: 0, easing: "ease", composite: "auto",+ filter: "drop-shadow(rgb(0, 255, 0) 10px 10px 10px)" },+ { offset: 1, computedOffset: 1, easing: "ease", composite: "auto",+ filter: "drop-shadow(rgb(255, 0, 0) 50px 30px 10px)" },+ ];+ assert_frame_lists_equal(frames, expected);+}, 'KeyframeEffect.getKeyframes() returns expected values for ' ++ 'animation with drop-shadow of filter property');++// Gecko-specific test case: We are specifically concerned here that the+// computed value for text-shadow and a "none" specified on a keyframe+// are correctly represented.++test(t => {+ const div = addDiv(t);+ div.style.textShadow = '1px 1px 2px rgb(0, 0, 0), ' ++ '0 0 16px rgb(0, 0, 255), ' ++ '0 0 3.2px rgb(0, 0, 255)';+ div.style.animation = 'anim-text-shadow 100s';++ const frames = getKeyframes(div);++ // Initial keyframe should be replace as per sections 7 and 8 of+ // https://drafts.csswg.org/css-animations-2/#keyframes+ const expected = [+ { offset: 0, computedOffset: 0, easing: "ease", composite: "replace",+ textShadow: "rgb(0, 0, 0) 1px 1px 2px,"+ + " rgb(0, 0, 255) 0px 0px 16px,"+ + " rgb(0, 0, 255) 0px 0px 3.2px" },+ { offset: 1, computedOffset: 1, easing: "ease", composite: "auto",+ textShadow: "none" },+ ];+ assert_frame_lists_equal(frames, expected);+}, 'KeyframeEffect.getKeyframes() returns expected values for ' ++ 'animations with text-shadow properties and missing keyframes');++// Gecko-specific test case: We are specifically concerned here that the+// initial value for background-size and the specified list are correctly+// represented.++test(t => {+ const div = addDiv(t);++ div.style.animation = 'anim-background-size 100s';+ let frames = getKeyframes(div);++ assert_equals(frames.length, 2, "number of frames");++ // Initial keyframe should be replace as per sections 7 and 8 of+ // https://drafts.csswg.org/css-animations-2/#keyframes+ const expected = [+ { offset: 0, computedOffset: 0, easing: "ease", composite: "replace",+ backgroundSize: "auto" },+ { offset: 1, computedOffset: 1, easing: "ease", composite: "auto",+ backgroundSize: "50% auto, 6px auto, contain" },+ ];++ for (let i = 0; i < frames.length; i++) {+ assert_frames_equal(frames[i], expected[i], "ComputedKeyframe #" + i);+ }++ // Test inheriting a background-size value++ expected[0].backgroundSize = div.style.backgroundSize =+ "30px auto, 40% auto, auto";+ frames = getKeyframes(div);++ for (let i = 0; i < frames.length; i++) {+ assert_frames_equal(frames[i], expected[i], "ComputedKeyframe #" + i+ + " after updating current style");+ }+}, 'KeyframeEffect.getKeyframes() returns expected values for ' ++ 'animations with background-size properties and missing keyframes');++test(t => {+ const div = addDiv(t);+ div.style.animation = 'anim-variables 100s';++ const frames = getKeyframes(div);++ // Initial keyframe should be replace as per sections 7 and 8 of+ // https://drafts.csswg.org/css-animations-2/#keyframes+ const expected = [+ { offset: 0, computedOffset: 0, easing: "ease", composite: "replace",+ transform: "none" },+ { offset: 1, computedOffset: 1, easing: "ease", composite: "auto",+ transform: "translate(100px)" },+ ];+ assert_frame_lists_equal(frames, expected);+}, 'KeyframeEffect.getKeyframes() returns expected values for ' ++ 'animations with CSS variables as keyframe values');++test(t => {+ const div = addDiv(t);+ div.style.animation = 'anim-variables-shorthand 100s';++ const frames = getKeyframes(div);++ // Initial keyframe should be replace as per sections 7 and 8 of+ // https://drafts.csswg.org/css-animations-2/#keyframes+ const expected = [+ { offset: 0, computedOffset: 0, easing: "ease", composite: "replace",+ marginBottom: "0px",+ marginLeft: "0px",+ marginRight: "0px",+ marginTop: "0px" },+ { offset: 1, computedOffset: 1, easing: "ease", composite: "auto",+ marginBottom: "100px",+ marginLeft: "100px",+ marginRight: "100px",+ marginTop: "100px" },+ ];+ assert_frame_lists_equal(frames, expected);+}, 'KeyframeEffect.getKeyframes() returns expected values for ' ++ 'animations with CSS variables as keyframe values in a shorthand property');++test(t => {+ const div = addDiv(t);+ div.style.animation = 'anim-custom-property-in-keyframe 100s steps(2, start)';++ const frames = getKeyframes(div);++ // Initial keyframe should be replace as per sections 7 and 8 of+ // https://drafts.csswg.org/css-animations-2/#keyframes+ const expected = [+ { offset: 0, computedOffset: 0, easing: "steps(2, start)", composite: "replace",+ color: "rgb(0, 0, 0)" },+ { offset: 1, computedOffset: 1, easing: "steps(2, start)", composite: "auto",+ color: "rgb(0, 255, 0)" },+ ];+ assert_frame_lists_equal(frames, expected);+}, 'KeyframeEffect.getKeyframes() returns expected values for ' ++ 'animations with a CSS variable which is overriden by the value in keyframe');++test(t => {+ const div = addDiv(t);+ div.style.animation = 'anim-only-custom-property-in-keyframe 100s';++ const frames = getKeyframes(div);++ const expected = [+ { offset: 0, computedOffset: 0, easing: "ease", composite: "auto",+ transform: "translate(100px)" },+ { offset: 1, computedOffset: 1, easing: "ease", composite: "auto",+ transform: "none" },+ ];+ assert_frame_lists_equal(frames, expected);+}, 'KeyframeEffect.getKeyframes() returns expected values for ' ++ 'animations with only custom property in a keyframe');++test(t => {+ const div = addDiv(t);++ // Add custom @keyframes rule+ const stylesheet = document.styleSheets[0];+ const keyframes = '@keyframes anim-custom { to { left: 100px } }';+ const ruleIndex = stylesheet.insertRule(keyframes, 0);+ const keyframesRule = stylesheet.cssRules[ruleIndex];++ t.add_cleanup(function() {+ stylesheet.deleteRule(ruleIndex);+ });++ div.style.animation = 'anim-custom 100s';++ // Sanity check the initial result+ let frames = getKeyframes(div);+ assert_frames_equal(+ frames[frames.length - 1],+ {+ offset: 1,+ computedOffset: 1,+ easing: 'ease',+ composite: 'auto',+ left: '100px',+ },+ 'Keyframes reflect the initial @keyframes rule'+ );++ // Update the @keyframes rule+ keyframesRule.deleteRule(0);+ keyframesRule.appendRule('to { left: 200px }');++ // Check the result from getKeyframes() is updated+ frames = getKeyframes(div);+ assert_frames_equal(+ frames[frames.length - 1],+ {+ offset: 1,+ computedOffset: 1,+ easing: 'ease',+ composite: 'auto',+ left: '200px',+ },+ 'Keyframes reflects the updated @keyframes rule'+ );+}, 'KeyframeEffect.getKeyframes() reflects changes to @keyframes rules');++test(t => {+ const div = addDiv(t);+ div.style.animation = 'anim-only-timing-function-for-from-and-to 100s';++ const frames = getKeyframes(div);++ // Implicit initial and final keyframes should be replace as per sections+ // 7 and 8 of https://drafts.csswg.org/css-animations-2/#keyframes+ const expected = [+ { offset: 0, computedOffset: 0, easing: "linear", composite: "auto" },+ { offset: 0, computedOffset: 0, easing: "ease", composite: "replace", left: "auto" },+ { offset: 0.5, computedOffset: 0.5, easing: "ease", composite: "auto", left: "10px" },+ { offset: 1, computedOffset: 1, easing: "linear", composite: "auto" },+ { offset: 1, computedOffset: 1, easing: "ease", composite: "replace", left: "auto" }+ ];+ assert_frame_lists_equal(frames, expected);+}, 'KeyframeEffect.getKeyframes() returns expected values for ' ++ 'animations with implicit values and a non-default timing' ++ 'function specified for 0% and 100%');++</script>+</body>diff --git a/Tests/LibWeb/Text/input/wpt-import/css/css-animations/KeyframeEffect-setKeyframes.tentative.html b/Tests/LibWeb/Text/input/wpt-import/css/css-animations/KeyframeEffect-setKeyframes.tentative.htmlnew file mode 100644index 00000000000..a346ccfeba7--- /dev/null+++ b/Tests/LibWeb/Text/input/wpt-import/css/css-animations/KeyframeEffect-setKeyframes.tentative.html@@ -0,0 +1,122 @@+<!doctype html>+<meta charset=utf-8>+<title>KeyframeEffect.setKeyframes() for CSS animations</title>+<!-- TODO: Add a more specific link for this once it is specified. -->+<link rel="help" href="https://drafts.csswg.org/css-animations-2/">+<script src="../../resources/testharness.js"></script>+<script src="../../resources/testharnessreport.js"></script>+<script src="support/testcommon.js"></script>+<style>+@keyframes anim-simple {+ from { left: 0px }+ to { left: 100px }+}+</style>+<body>+<div id="log"></div>+<script>+"use strict";++// Note that the sanity check that getKeyframes() normally DOES return the+// updated keyframes is contained in KeyframeEffect-getKeyframes.html.+test(t => {+ const div = addDiv(t);++ // Add custom @keyframes rule+ const stylesheet = document.styleSheets[0];+ const keyframes = '@keyframes anim-custom { to { left: 100px } }';+ const ruleIndex = stylesheet.insertRule(keyframes, 0);+ const keyframesRule = stylesheet.cssRules[ruleIndex];++ t.add_cleanup(function() {+ stylesheet.deleteRule(ruleIndex);+ });++ div.style.animation = 'anim-custom 100s';++ // Update the keyframes via the API+ const animation = div.getAnimations()[0];+ animation.effect.setKeyframes({ left: '200px' });++ // Then update them via style+ keyframesRule.deleteRule(0);+ keyframesRule.appendRule('to { left: 300px }');++ // The result should be the keyframes as set by the API, not via style.+ const frames = animation.effect.getKeyframes();+ assert_frames_equal(+ frames[frames.length - 1],+ {+ offset: null,+ computedOffset: 1,+ easing: 'linear',+ composite: 'auto',+ left: '200px',+ },+ 'Keyframes reflect the value set via setKeyframes'+ );+}, 'KeyframeEffect.setKeyframes() causes subsequent changes to @keyframes'+ + ' rules to be ignored');++test(t => {+ const div = addDiv(t);+ div.style.animation = 'anim-simple 100s';++ const animation = div.getAnimations()[0];+ assert_equals(animation.effect.getKeyframes()[0].easing, 'ease');++ animation.effect.setKeyframes({ left: ['200px', '300px'] });+ assert_equals(animation.effect.getKeyframes()[0].easing, 'linear');++ div.style.animationTimingFunction = 'ease-in';+ getComputedStyle(div).animationTimingFunction;++ assert_equals(+ animation.effect.getKeyframes()[0].easing,+ 'linear',+ 'Easing should be the easing set by the API'+ );+}, 'KeyframeEffect.setKeyframes() causes subsequent changes to'+ + ' animation-timing-function to be ignored');++test(t => {+ const div = addDiv(t);++ const stylesheet = document.styleSheets[0];+ const keyframes = '@keyframes anim-custom { to { left: 100px } }';+ const ruleIndex = stylesheet.insertRule(keyframes, 0);+ const keyframesRule = stylesheet.cssRules[ruleIndex];++ t.add_cleanup(function() {+ stylesheet.deleteRule(ruleIndex);+ });++ div.style.animation = 'anim-custom 100s';++ // Try updating in a way that throws an error+ const animation = div.getAnimations()[0];+ assert_throws_js(TypeError, () => {+ animation.effect.setKeyframes({ left: '200px', offset: 'yer' });+ });++ keyframesRule.deleteRule(0);+ keyframesRule.appendRule('to { left: 300px }');++ // The result should be the keyframes as set via style.+ const frames = animation.effect.getKeyframes();+ assert_frames_equal(+ frames[frames.length - 1],+ {+ offset: 1,+ computedOffset: 1,+ easing: 'ease',+ composite: 'auto',+ left: '300px',+ },+ 'Keyframes reflect the value set via style'+ );+}, 'KeyframeEffect.setKeyframes() should NOT cause subsequent changes to'+ + ' @keyframes rules to be ignored if it threw');++</script>+</body>diff --git a/Tests/LibWeb/Text/input/wpt-import/css/css-transitions/KeyframeEffect-getKeyframes-width-and-height-transition.tentative.html b/Tests/LibWeb/Text/input/wpt-import/css/css-transitions/KeyframeEffect-getKeyframes-width-and-height-transition.tentative.htmlnew file mode 100644index 00000000000..bf82bbd1a9f--- /dev/null+++ b/Tests/LibWeb/Text/input/wpt-import/css/css-transitions/KeyframeEffect-getKeyframes-width-and-height-transition.tentative.html@@ -0,0 +1,43 @@+<!doctype html>+<meta charset=utf-8>+<title>AnimationEffect.getKeyframes() for CSS transitions of the width and height properties</title>+<link rel="help" href="https://drafts.csswg.org/css-transitions-2/#csstransition">+<script src="../../resources/testharness.js"></script>+<script src="../../resources/testharnessreport.js"></script>+<script src="support/helper.js"></script>+<style>++.animated-div {+ width: 100px;+ height: 100px;+}++</style>+<div id="log"></div>+<script>++'use strict';++test(t => {+ const div = addDiv(t, { class: 'animated-div' });+ div.style.transition = 'width 10s';+ getComputedStyle(div).width;+ div.style.width = '200px';++ const keyframes = div.getAnimations()[0].effect.getKeyframes();+ assert_equals(keyframes[0].width, "100px", 'from keyframe value');+ assert_equals(keyframes[1].width, "200px", 'to keyframe value');+}, 'getKeyframes() output for a width transition');++test(t => {+ const div = addDiv(t, { class: 'animated-div' });+ div.style.transition = 'height 10s';+ getComputedStyle(div).height;+ div.style.height = '200px';++ const keyframes = div.getAnimations()[0].effect.getKeyframes();+ assert_equals(keyframes[0].height, "100px", 'from keyframe value');+ assert_equals(keyframes[1].height, "200px", 'to keyframe value');+}, 'getKeyframes() output for a height transition');++</script>diff --git a/Tests/LibWeb/Text/input/wpt-import/css/css-transitions/KeyframeEffect-getKeyframes.tentative.html b/Tests/LibWeb/Text/input/wpt-import/css/css-transitions/KeyframeEffect-getKeyframes.tentative.htmlnew file mode 100644index 00000000000..7f5ae9e1e40--- /dev/null+++ b/Tests/LibWeb/Text/input/wpt-import/css/css-transitions/KeyframeEffect-getKeyframes.tentative.html@@ -0,0 +1,203 @@+<!doctype html>+<meta charset=utf-8>+<title>KeyframeEffect.getKeyframes() for CSS transitions</title>+<!-- TODO: Add a more specific link for this once it is specified. -->+<link rel="help" href="https://drafts.csswg.org/css-transitions-2/#csstransition">+<script src="../../resources/testharness.js"></script>+<script src="../../resources/testharnessreport.js"></script>+<script src="support/helper.js"></script>+<style>+:root {+ --var-100px: 100px;+}+</style>+<div id="log"></div>+<script>+'use strict';++const getKeyframes = e => {+ return e.getAnimations()[0].effect.getKeyframes();+};++const assert_frames_equal = (a, b, name) => {+ assert_equals(+ Object.keys(a).sort().toString(),+ Object.keys(b).sort().toString(),+ `properties on ${name}`+ );+ for (const p in a) {+ assert_equals(a[p], b[p], `value for '${p}' on ${name}`);+ }+};++test(t => {+ const div = addDiv(t);++ div.style.left = '0px';+ getComputedStyle(div).transitionProperty;+ div.style.transition = 'left 100s';+ div.style.left = '100px';++ const frames = getKeyframes(div);++ assert_equals(frames.length, 2, 'number of frames');++ const expected = [+ { offset: 0,+ computedOffset: 0,+ easing: 'linear',+ composite: 'auto',+ left: '0px',+ },+ {+ offset: 1,+ computedOffset: 1,+ easing: 'linear',+ composite: 'auto',+ left: '100px',+ },+ ];++ for (let i = 0; i < frames.length; i++) {+ assert_frames_equal(frames[i], expected[i], `ComputedKeyframe #${i}`);+ }+}, 'KeyframeEffect.getKeyframes() returns expected frames for a simple'+ + ' transition');++test(t => {+ const div = addDiv(t);++ div.style.left = '0px';+ getComputedStyle(div).transitionProperty;+ div.style.transition = 'left 100s steps(2,end)';+ div.style.left = '100px';++ const frames = getKeyframes(div);++ assert_equals(frames.length, 2, 'number of frames');++ const expected = [+ {+ offset: 0,+ computedOffset: 0,+ easing: 'linear',+ composite: 'auto',+ left: '0px',+ },+ {+ offset: 1,+ computedOffset: 1,+ easing: 'linear',+ composite: 'auto',+ left: '100px',+ },+ ];++ for (let i = 0; i < frames.length; i++) {+ assert_frames_equal(frames[i], expected[i], `ComputedKeyframe #${i}`);+ }+}, 'KeyframeEffect.getKeyframes() returns frames unaffected by a non-default easing function');++test(t => {+ const div = addDiv(t);+ div.style.left = '0px';+ getComputedStyle(div).transitionProperty;+ div.style.transition = 'left 100s';+ div.style.left = 'var(--var-100px)';++ const frames = getKeyframes(div);++ // CSS transition endpoints are based on the computed value so we+ // shouldn't see the variable reference+ const expected = [+ {+ offset: 0,+ computedOffset: 0,+ easing: 'linear',+ composite: 'auto',+ left: '0px',+ },+ {+ offset: 1,+ computedOffset: 1,+ easing: 'linear',+ composite: 'auto',+ left: '100px',+ },+ ];+ for (let i = 0; i < frames.length; i++) {+ assert_frames_equal(frames[i], expected[i], `ComputedKeyframe #${i}`);+ }+}, 'KeyframeEffect.getKeyframes() returns expected frames for a'+ + ' transition with a CSS variable endpoint');++test(t => {+ const div = addDiv(t);+ div.style.left = '0px';+ getComputedStyle(div).transitionProperty;+ div.style.transition = 'left 100s';+ div.style.left = '100px';++ // Resetting the effect target before retrieving the keyframes should not+ // affect the computed property values.+ const anim = div.getAnimations()[0];+ anim.effect.target = null;+ const frames = anim.effect.getKeyframes();++ const expected = [+ {+ offset: 0,+ computedOffset: 0,+ easing: 'linear',+ composite: 'auto',+ left: '0px',+ },+ {+ offset: 1,+ computedOffset: 1,+ easing: 'linear',+ composite: 'auto',+ left: '100px',+ },+ ];+ for (let i = 0; i < frames.length; i++) {+ assert_frames_equal(frames[i], expected[i], `ComputedKeyframe #${i}`);+ }+}, 'KeyframeEffect.getKeyframes() returns expected frames for a'+ + ' transition after resetting the effect target');++test(t => {+ const div = addDiv(t);++ div.style.transition = '--foo 100s allow-discrete';+ div.style.setProperty("--foo", "10");+ getComputedStyle(div).getPropertyValue("--foo");+ div.style.setProperty("--foo", "20");++ const frames = getKeyframes(div);++ assert_equals(frames.length, 2, 'number of frames');++ const expected = [+ { offset: 0,+ computedOffset: 0,+ easing: 'linear',+ composite: 'auto',+ "--foo": '10',+ },+ {+ offset: 1,+ computedOffset: 1,+ easing: 'linear',+ composite: 'auto',+ "--foo": '20',+ },+ ];++ for (let i = 0; i < frames.length; i++) {+ assert_frames_equal(frames[i], expected[i], `ComputedKeyframe #${i}`);+ }+}, 'KeyframeEffect.getKeyframes() returns expected frames for a custom'+ + ' property transition');++</script>diff --git a/Tests/LibWeb/Text/input/wpt-import/css/css-transitions/KeyframeEffect-setKeyframes.tentative.html b/Tests/LibWeb/Text/input/wpt-import/css/css-transitions/KeyframeEffect-setKeyframes.tentative.htmlnew file mode 100644index 00000000000..2e65d969345--- /dev/null+++ b/Tests/LibWeb/Text/input/wpt-import/css/css-transitions/KeyframeEffect-setKeyframes.tentative.html@@ -0,0 +1,177 @@+<!doctype html>+<meta charset=utf-8>+<title>KeyframeEffect.setKeyframes() for CSS transitions</title>+<!-- TODO: Add a more specific link for this once it is specified. -->+<link rel="help" href="https://drafts.csswg.org/css-transitions-2/#csstransition">+<script src="../../resources/testharness.js"></script>+<script src="../../resources/testharnessreport.js"></script>+<script src="support/helper.js"></script>+<div id="log"></div>+<script>+'use strict';++test(t => {+ const div = addDiv(t);++ div.style.left = '0px';+ getComputedStyle(div).transitionProperty;+ div.style.transition = 'left 100s';+ div.style.left = '100px';++ const transition = div.getAnimations()[0];+ transition.effect.setKeyframes({ left: ['200px', '300px', '100px'] });++ assert_equals(getComputedStyle(div).left, '200px');+}, 'Keyframes set using setKeyframes() are reflected in computed style for'+ + ' a running transition');++test(t => {+ const div = addDiv(t);++ div.style.left = '0px';+ getComputedStyle(div).transitionProperty;+ div.style.transition = 'left 100s';+ div.style.left = '100px';++ const transition = div.getAnimations()[0];+ transition.effect.setKeyframes({ top: ['0px', '100px', '300px'] });++ assert_equals(transition.transitionProperty, 'left');+}, 'A transition with replaced keyframes still returns the original'+ + ' transitionProperty');++test(t => {+ const div = addDiv(t);++ div.style.left = '0px';+ getComputedStyle(div).transitionProperty;+ div.style.transition = 'left 100s';+ div.style.left = '100px';++ const transition = div.getAnimations()[0];+ transition.effect.setKeyframes({ });++ assert_equals(transition.transitionProperty, 'left');+}, 'A transition with no keyframes still returns the original'+ + ' transitionProperty');++function retarget_test(description, newKeyframes, reversed_start) {+ test(t => {+ const div = addDiv(t);++ div.style.left = '0px';+ getComputedStyle(div).transitionProperty;+ div.style.transition = 'left 100s linear';+ div.style.left = '100px';++ const transition = div.getAnimations()[0];+ transition.currentTime = 50 * MS_PER_SEC;+ transition.effect.setKeyframes(newKeyframes);++ // Reverse transition+ div.style.left = '0px';+ const reversedTransition = div.getAnimations()[0];++ assert_approx_equals(+ reversedTransition.effect.getComputedTiming().activeDuration,+ 50 * MS_PER_SEC, 1,+ "The reversed transition has correctly reduced duration"+ );+ assert_equals(reversedTransition.effect.getKeyframes()[0].left, reversed_start,+ "The reversed transition starts at the expected point");+ }, description);+}++retarget_test("A transition with replaced keyframes animating the same property " ++ "still exhibits normal reversing behavior.",+ {left: ['200px', '300px', '100px']}, '300px');++retarget_test("A transition with replaced keyframes animating a different property " ++ "still exhibits normal reversing behavior (reversing from the base value).",+ {top: ['200px', '300px', '100px']}, '100px');++retarget_test("A transition with replaced keyframes animating nothing " ++ "still exhibits normal reversing behavior (reversing from the base value).",+ {}, '100px');++test(t => {+ const div = addDiv(t);++ // Initialize the style.+ div.style.left = '100px';+ div.style.top = '100px';+ div.style.transition = 'left 100s linear, top 100s linear';+ getComputedStyle(div).left;++ // Start some transitions.+ div.style.left ='200px';+ div.style.top = '200px';+ const transitions = div.getAnimations();++ // Hand control of the left property over to top's transition. The composite+ // ordering of the animations is 'left' then 'top' since the transitions were+ // generated in the same transition generation and follow Unicode ordering.+ assert_equals(transitions[0].transitionProperty, 'left');+ transitions[0].effect.setKeyframes({});+ transitions[1].effect.setKeyframes([+ {left: '100px', top: '100px'},+ {left: '400px', top: '200px'}])+ getComputedStyle(div).left;++ // These updates form a single style change, equivalent to setting times and+ // then setting left.+ transitions[0].currentTime = 50 * MS_PER_SEC;+ div.style.left ='100px';+ transitions[1].currentTime = 60 * MS_PER_SEC;++ // As there was a style change event, the new 'left' transition now has a+ // higher value for the transition generation than the 'top' transition,+ // reversing the order of the transitions returned by getAnimations.+ const reversedTransition = div.getAnimations()[1];+ assert_equals(reversedTransition.transitionProperty, 'left',+ "A reversed transition on left is produced");++ assert_approx_equals(+ reversedTransition.effect.getComputedTiming().activeDuration,+ 50 * MS_PER_SEC, 1,+ "The reversed transition has correctly reduced duration (based on the " ++ "original left transition).");++ assert_equals(reversedTransition.effect.getKeyframes()[0].left, '280px',+ "The reversed transition gets its start value from the other " ++ "transition controlling left");++}, "A transition with replaced keyframes animating nothing on a property " ++ "being controlled by another modified transition exhibits normal " ++ "reversing behavior and reverses from the other transition's current " ++ "value.");++test(t => {+ const div = addDiv(t);++ // Initialize the style.+ div.style.left = '100px';+ div.style.transition = 'left 100s linear';+ getComputedStyle(div).left;++ // Start the transtion.+ div.style.left ='200px';+ const transition = div.getAnimations()[0];++ // Update the keyframes and advance to the midpoint of the animation.+ transition.effect.setKeyframes([+ { offset: 0, left: '-50px', composite: 'add', easing: 'linear'}]);+ transition.currentTime = 50 * MS_PER_SEC;+ assert_equals(getComputedStyle(div).left, '175px',+ 'The computed style is based on the updated keyframes');++ div.style.left = '100px';+ const reversedTransition = div.getAnimations()[0];+ assert_equals(reversedTransition.effect.getKeyframes()[0].left, '175px',+ 'The start value matches the \'before change\' value');++}, 'A transition with replaced kefyrames and composite \'add\' exhibits ' ++ 'normal reversing behavior, and the effect is not double counted when ' ++ 'calculating the before change style');++</script>