diff --git a/docs/validation/css-animation-fill-mode-661-242.md b/docs/validation/css-animation-fill-mode-661-242.md new file mode 100644 index 00000000..88491e8b --- /dev/null +++ b/docs/validation/css-animation-fill-mode-661-242.md @@ -0,0 +1,60 @@ +# CSS animation fill-mode source validation + +Issue #661 completes the bounded `animation-fill-mode` behavior for WebScene's +existing single-animation opacity, `rotate()`, and foreground-filter keyframes +under #242. It accepts the first longhand list item and the first shorthand +animation for `none`, `forwards`, `backwards`, and `both`. The CSSOM +`animationFillMode` and `getPropertyValue("animation-fill-mode")` surfaces expose +the configured value without an ABI or AppScene change. + +## Timing and fill contract + +Fill is configuration around an animation timeline, not part of timeline +identity. A fill-only cascade or CSSOM change retains the original start time. +An already-completed supported animation requests at most one host sample to +apply or remove its static boundary value, then returns to zero frame demand. +The existing `animationend` latch is preserved, so this update cannot dispatch a +second terminal event. + +For a positive delay, `backwards` and `both` sample the boundary that starts +iteration zero. `normal` and `alternate` use progress zero; `reverse` and +`alternate-reverse` use progress one. The positive-delay boundary is sampled +directly, without applying the between-keyframe timing function, so +`steps(..., start)` does not jump before the active interval. `none` and +`forwards` expose the underlying property before that interval. A negative delay +has no before phase and enters the active or after phase directly. + +After a finite active interval, `forwards` and `both` use the existing +direction-aware integer or fractional terminal progress for opacity, rotation, +and compatible bounded filters. `none` and `backwards` restore the underlying +value. Rotation now retains an explicit filled override just like filters, while +filled overrides remain excluded from the active-animation frame-demand test. +Removing the animation, changing its identity, navigation, and node teardown +clear the override through the established runtime lifecycle. + +## Bounds and deferred behavior + +- The runtime still configures one animation and the first comma-separated + longhand value. +- Existing keyframe-stop and compatible filter-list limits are unchanged. +- No timer, queue, visual-tree node, selector pass, or per-frame allocation is + added. Host timestamps and visibility/clip frame-demand gates are preserved. +- `animation-play-state`, zero-duration and zero-iteration fill, multiple + animations, translate/scale keyframes, pseudo-element animation, and the Web + Animations API remain deferred. +- Unchanged Code OSS uses `both` for delayed Quick Input, action-widget, and Chat + entry animations. This slice prevents their supported opacity before-phase + flash. Their translate/scale keyframes remain outside the rotate-only bound. + +## Evidence + +- `test_animation_fill_maps_before_after_and_preserves_timeline` covers all four + values, longhand and shorthand metadata, direction and step timing in the + before phase, opacity/rotation/filter terminal paint, fill-only mutation, + exactly-once `animationend`, removal, detach, and settled frame demand. +- `tests/WebPlatformSubset/contracts/css-animation-fill-mode-boundaries.html` + is a bounded WPT-aligned browser contract with the same before, after, live + update, and cleanup boundaries. A dedicated profile selects only that test. +- Under the fast implementation policy, only `git diff --check` is executed in + this slice. Native, browser, package, and unchanged Code OSS acceptance remain + unexecuted. diff --git a/experiments/WebScene.NativeEngine.Probe/native/webscene_css_decoration_values.h b/experiments/WebScene.NativeEngine.Probe/native/webscene_css_decoration_values.h index f9a4fb0b..8e73021b 100644 --- a/experiments/WebScene.NativeEngine.Probe/native/webscene_css_decoration_values.h +++ b/experiments/WebScene.NativeEngine.Probe/native/webscene_css_decoration_values.h @@ -183,6 +183,9 @@ bool apply_decoration_value(dom_node& node,const std::string& name,const std::st return true; } else if (name == "animation-fill-mode") { node.style.mutable_animations().animation_fill_mode_value = value; + decision.classification = "partially-supported"; + decision.semantic_slice = + "first animation; none, forwards, backwards, both"; return true; } else if (property_mask(name) == inline_border && is_inline(inline_border)) { diff --git a/experiments/WebScene.NativeEngine.Probe/native/webscene_css_specified_coverage.h b/experiments/WebScene.NativeEngine.Probe/native/webscene_css_specified_coverage.h index d0a834e5..87ddce54 100644 --- a/experiments/WebScene.NativeEngine.Probe/native/webscene_css_specified_coverage.h +++ b/experiments/WebScene.NativeEngine.Probe/native/webscene_css_specified_coverage.h @@ -43,6 +43,7 @@ inline constexpr auto specified_property_samples = std::to_array(animations.keyframe_direction) << '|' - << animations.opacity_keyframe_fill_forwards << '|' << static_cast(animations.opacity_keyframe_timing_kind) << ',' << animations.opacity_keyframe_step_count << ',' << static_cast(animations.opacity_keyframe_step_position) << '|' diff --git a/experiments/WebScene.NativeEngine.Probe/native/webscene_native_dom.h b/experiments/WebScene.NativeEngine.Probe/native/webscene_native_dom.h index d1cc17bc..96a92897 100644 --- a/experiments/WebScene.NativeEngine.Probe/native/webscene_native_dom.h +++ b/experiments/WebScene.NativeEngine.Probe/native/webscene_native_dom.h @@ -205,6 +205,12 @@ struct node_style final { alternate, alternate_reverse }; + enum class fill_kind : uint8_t { + none, + forwards, + backwards, + both + }; std::string transition_property_value{"all"}; std::string transition_duration_value{"0s"}; std::string transition_delay_value{"0s"}; @@ -233,7 +239,7 @@ struct node_style final { float opacity_keyframe_delay_ms{0}; float opacity_keyframe_iterations{1}; direction_kind keyframe_direction{direction_kind::normal}; - bool opacity_keyframe_fill_forwards{false}; + fill_kind keyframe_fill_mode{fill_kind::none}; float opacity_keyframe_x1{0.25F}; float opacity_keyframe_y1{0.1F}; float opacity_keyframe_x2{0.25F}; @@ -1514,12 +1520,16 @@ struct dom_node final { std::string rotation_keyframe_animation_signature; double rotation_keyframe_animation_started_ms{0}; bool rotation_keyframe_animation_active{false}; + bool rotation_keyframe_animation_filled{false}; std::string filter_keyframe_animation_signature; std::vector filter_keyframes; std::vector filter_keyframe_underlying; double filter_keyframe_animation_started_ms{0}; bool filter_keyframe_animation_active{false}; + bool filter_keyframe_animation_valid{false}; bool filter_keyframe_animation_filled{false}; + node_style::animation_data::fill_kind keyframe_fill_mode{ + node_style::animation_data::fill_kind::none}; bool keyframe_animation_end_event_sent{false}; uint32_t painted_foreground_rgba{0}; uint32_t color_animation_from_rgba{0}; @@ -1865,10 +1875,11 @@ struct dom_node final { : style.background_rgba; } - bool rotation_keyframe_animation_active_value() const noexcept + bool has_painted_rotation_keyframe_override_value() const noexcept { return animation_runtime_state != nullptr - && animation_runtime_state->rotation_keyframe_animation_active; + && (animation_runtime_state->rotation_keyframe_animation_active + || animation_runtime_state->rotation_keyframe_animation_filled); } bool has_painted_filter_override_value() const noexcept diff --git a/experiments/WebScene.NativeEngine.Probe/native/webscene_native_dom_animations.inc b/experiments/WebScene.NativeEngine.Probe/native/webscene_native_dom_animations.inc index bcd7a7f6..8d66fd71 100644 --- a/experiments/WebScene.NativeEngine.Probe/native/webscene_native_dom_animations.inc +++ b/experiments/WebScene.NativeEngine.Probe/native/webscene_native_dom_animations.inc @@ -37,6 +37,18 @@ float terminal_keyframe_progress( const auto iteration = fractional > 0.0 ? whole : std::max(0.0, whole - 1.0); return directed_keyframe_progress(progress, iteration, direction); } + +bool fills_before(node_style::animation_data::fill_kind fill) noexcept +{ + return fill == node_style::animation_data::fill_kind::backwards + || fill == node_style::animation_data::fill_kind::both; +} + +bool fills_after(node_style::animation_data::fill_kind fill) noexcept +{ + return fill == node_style::animation_data::fill_kind::forwards + || fill == node_style::animation_data::fill_kind::both; +} } // namespace void native_document::signal_animation_frame(double timestamp_ms) noexcept @@ -245,6 +257,9 @@ void native_document::update_style_animations(dom_node& node) const auto filter_keyframe_changed = animation.filter_keyframe_animation_signature != node.style.animations().filter_keyframe_animation_signature; + const auto fill_mode_changed = animation.keyframe_fill_mode + != node.style.animations().keyframe_fill_mode; + animation.keyframe_fill_mode = node.style.animations().keyframe_fill_mode; if (opacity_keyframe_changed || rotation_keyframe_changed || filter_keyframe_changed) { animation.keyframe_animation_end_event_sent = false; @@ -266,6 +281,7 @@ void native_document::update_style_animations(dom_node& node) animation.rotation_keyframe_animation_signature = node.style.animations().rotation_keyframe_animation_signature; animation.rotation_keyframe_animation_started_ms = animation_frame_timestamp_ms_; + animation.rotation_keyframe_animation_filled = false; animation.rotation_keyframe_animation_active = !animation.rotation_keyframe_animation_signature.empty() && node.style.animations().rotation_keyframes.size() >= 2U @@ -292,6 +308,7 @@ void native_document::update_style_animations(dom_node& node) node.style.animations().filter_keyframe_animation_signature; animation.filter_keyframe_animation_started_ms = animation_frame_timestamp_ms_; animation.filter_keyframe_animation_active = false; + animation.filter_keyframe_animation_valid = false; animation.filter_keyframe_animation_filled = false; animation.filter_keyframes.clear(); auto valid = !animation.filter_keyframe_animation_signature.empty() @@ -322,10 +339,33 @@ void native_document::update_style_animations(dom_node& node) } } } + animation.filter_keyframe_animation_valid = valid; animation.filter_keyframe_animation_active = valid; animation.painted_filter_functions = animation.filter_keyframe_underlying; } + if (fill_mode_changed) { + if (!opacity_keyframe_changed) { + animation.opacity_keyframe_animation_active = + !animation.opacity_keyframe_animation_signature.empty() + && node.style.animations().opacity_keyframes.size() >= 2U + && node.style.animations().opacity_keyframe_duration_ms > 0 + && node.style.animations().opacity_keyframe_iterations != 0; + } + if (!rotation_keyframe_changed) { + animation.rotation_keyframe_animation_filled = false; + animation.rotation_keyframe_animation_active = + !animation.rotation_keyframe_animation_signature.empty() + && node.style.animations().rotation_keyframes.size() >= 2U + && node.style.animations().opacity_keyframe_duration_ms > 0 + && node.style.animations().opacity_keyframe_iterations != 0; + } + if (!filter_keyframe_changed) { + animation.filter_keyframe_animation_filled = false; + animation.filter_keyframe_animation_active = + animation.filter_keyframe_animation_valid; + } + } if (animation.opacity_animation_active && node.style.animations().transition_property_value == "none") { transition_events_.push_back({node.id,"transitioncancel","opacity", @@ -1013,12 +1053,47 @@ bool native_document::advance_animations() noexcept auto keyframe_animation_completed = false; if (animation.opacity_keyframe_animation_active) { + const auto sample_opacity = [&](float cycle_progress) { + const auto& stops = node.style.animations().opacity_keyframes; + auto right = std::lower_bound( + stops.begin(), stops.end(), cycle_progress, + [](const node_style::opacity_keyframe& stop, float progress) { + return stop.offset < progress; + }); + if (right == stops.begin()) { + animation.painted_opacity = right->opacity; + } else if (right == stops.end()) { + animation.painted_opacity = stops.back().opacity; + } else { + const auto& from = *(right - 1); + const auto span = std::max( + 0.0001F, right->offset - from.offset); + const auto segment_progress = std::clamp( + (cycle_progress - from.offset) / span, 0.0F, 1.0F); + const auto eased = timing_value( + segment_progress, + node.style.animations().opacity_keyframe_x1, + node.style.animations().opacity_keyframe_y1, + node.style.animations().opacity_keyframe_x2, + node.style.animations().opacity_keyframe_y2, + node.style.animations().opacity_keyframe_timing_kind, + node.style.animations().opacity_keyframe_step_count, + node.style.animations().opacity_keyframe_step_position); + animation.painted_opacity = from.opacity + + (right->opacity - from.opacity) * eased; + } + }; const auto elapsed_ms = static_cast( animation_frame_timestamp_ms_ - animation.opacity_keyframe_animation_started_ms - node.style.animations().opacity_keyframe_delay_ms); if (elapsed_ms < 0) { - animation.painted_opacity = node.style.opacity; + if (fills_before(node.style.animations().keyframe_fill_mode)) { + sample_opacity(directed_keyframe_progress( + 0.0F, 0.0, node.style.animations().keyframe_direction)); + } else { + animation.painted_opacity = node.style.opacity; + } advanced = advanced || keyframe_paint_visible; } else { const auto duration = std::max( @@ -1028,38 +1103,8 @@ bool native_document::advance_animations() noexcept const auto total_duration = finite ? duration * std::max(0.0F, iterations) : 0.0F; - const auto sample_opacity = [&](float cycle_progress) { - const auto& stops = node.style.animations().opacity_keyframes; - auto right = std::lower_bound( - stops.begin(), stops.end(), cycle_progress, - [](const node_style::opacity_keyframe& stop, float progress) { - return stop.offset < progress; - }); - if (right == stops.begin()) { - animation.painted_opacity = right->opacity; - } else if (right == stops.end()) { - animation.painted_opacity = stops.back().opacity; - } else { - const auto& from = *(right - 1); - const auto span = std::max( - 0.0001F, right->offset - from.offset); - const auto segment_progress = std::clamp( - (cycle_progress - from.offset) / span, 0.0F, 1.0F); - const auto eased = timing_value( - segment_progress, - node.style.animations().opacity_keyframe_x1, - node.style.animations().opacity_keyframe_y1, - node.style.animations().opacity_keyframe_x2, - node.style.animations().opacity_keyframe_y2, - node.style.animations().opacity_keyframe_timing_kind, - node.style.animations().opacity_keyframe_step_count, - node.style.animations().opacity_keyframe_step_position); - animation.painted_opacity = from.opacity - + (right->opacity - from.opacity) * eased; - } - }; if (finite && elapsed_ms >= total_duration) { - if (node.style.animations().opacity_keyframe_fill_forwards) { + if (fills_after(node.style.animations().keyframe_fill_mode)) { sample_opacity(terminal_keyframe_progress( iterations, node.style.animations().keyframe_direction)); } else { @@ -1078,13 +1123,48 @@ bool native_document::advance_animations() noexcept } if (animation.rotation_keyframe_animation_active) { + const auto sample_rotation = [&](float cycle_progress) { + const auto& stops = node.style.animations().rotation_keyframes; + auto right = std::lower_bound( + stops.begin(), stops.end(), cycle_progress, + [](const node_style::rotation_keyframe& stop, float progress) { + return stop.offset < progress; + }); + if (right == stops.begin()) { + animation.painted_transform_rotate_degrees = right->degrees; + } else if (right == stops.end()) { + animation.painted_transform_rotate_degrees = stops.back().degrees; + } else { + const auto& from = *(right - 1); + const auto span = std::max( + 0.0001F, right->offset - from.offset); + const auto segment_progress = std::clamp( + (cycle_progress - from.offset) / span, 0.0F, 1.0F); + const auto eased = timing_value( + segment_progress, + node.style.animations().opacity_keyframe_x1, + node.style.animations().opacity_keyframe_y1, + node.style.animations().opacity_keyframe_x2, + node.style.animations().opacity_keyframe_y2, + node.style.animations().opacity_keyframe_timing_kind, + node.style.animations().opacity_keyframe_step_count, + node.style.animations().opacity_keyframe_step_position); + animation.painted_transform_rotate_degrees = from.degrees + + (right->degrees - from.degrees) * eased; + } + }; const auto elapsed_ms = static_cast( animation_frame_timestamp_ms_ - animation.rotation_keyframe_animation_started_ms - node.style.animations().opacity_keyframe_delay_ms); if (elapsed_ms < 0) { - animation.painted_transform_rotate_degrees = - node.style.transform_rotate_degrees; + if (fills_before(node.style.animations().keyframe_fill_mode)) { + sample_rotation(directed_keyframe_progress( + 0.0F, 0.0, node.style.animations().keyframe_direction)); + } else { + animation.painted_transform_rotate_degrees = + node.style.transform_rotate_degrees; + } advanced = advanced || keyframe_paint_visible; } else { const auto duration = std::max( @@ -1095,56 +1175,84 @@ bool native_document::advance_animations() noexcept ? duration * std::max(0.0F, iterations) : 0.0F; if (finite && elapsed_ms >= total_duration) { - animation.painted_transform_rotate_degrees = - node.style.transform_rotate_degrees; + if (fills_after(node.style.animations().keyframe_fill_mode)) { + sample_rotation(terminal_keyframe_progress( + iterations, node.style.animations().keyframe_direction)); + animation.rotation_keyframe_animation_filled = true; + } else { + animation.painted_transform_rotate_degrees = + node.style.transform_rotate_degrees; + animation.rotation_keyframe_animation_filled = false; + } animation.rotation_keyframe_animation_active = false; keyframe_animation_completed = true; advanced = advanced || keyframe_paint_visible; } else { - const auto cycle_progress = active_keyframe_progress( + sample_rotation(active_keyframe_progress( elapsed_ms, duration, - node.style.animations().keyframe_direction); - const auto& stops = node.style.animations().rotation_keyframes; - auto right = std::lower_bound( - stops.begin(), stops.end(), cycle_progress, - [](const node_style::rotation_keyframe& stop, float progress) { - return stop.offset < progress; - }); - if (right == stops.begin()) { - animation.painted_transform_rotate_degrees = right->degrees; - } else if (right == stops.end()) { - animation.painted_transform_rotate_degrees = stops.back().degrees; - } else { - const auto& from = *(right - 1); - const auto span = std::max( - 0.0001F, right->offset - from.offset); - const auto segment_progress = std::clamp( - (cycle_progress - from.offset) / span, 0.0F, 1.0F); - const auto eased = timing_value( - segment_progress, - node.style.animations().opacity_keyframe_x1, - node.style.animations().opacity_keyframe_y1, - node.style.animations().opacity_keyframe_x2, - node.style.animations().opacity_keyframe_y2, - node.style.animations().opacity_keyframe_timing_kind, - node.style.animations().opacity_keyframe_step_count, - node.style.animations().opacity_keyframe_step_position); - animation.painted_transform_rotate_degrees = from.degrees - + (right->degrees - from.degrees) * eased; - } + node.style.animations().keyframe_direction)); advanced = advanced || keyframe_paint_visible; } } } if (animation.filter_keyframe_animation_active) { + const auto sample_filter = [&](float cycle_progress) { + const auto& stops = animation.filter_keyframes; + const auto assign_stop = [&](const auto& stop) { + if (stop.authored_none) { + animation.painted_filter_functions.clear(); + } else { + animation.painted_filter_functions = stop.functions; + } + }; + auto right = std::lower_bound( + stops.begin(), stops.end(), cycle_progress, + [](const auto& stop, float progress) { + return stop.offset < progress; + }); + if (right == stops.begin()) { + assign_stop(*right); + } else if (right == stops.end()) { + assign_stop(stops.back()); + } else if (std::abs(cycle_progress - right->offset) < 0.000001F) { + assign_stop(*right); + } else { + const auto& from = *(right - 1); + const auto span = std::max( + 0.0001F, right->offset - from.offset); + const auto segment_progress = std::clamp( + (cycle_progress - from.offset) / span, 0.0F, 1.0F); + const auto eased = timing_value( + segment_progress, + node.style.animations().opacity_keyframe_x1, + node.style.animations().opacity_keyframe_y1, + node.style.animations().opacity_keyframe_x2, + node.style.animations().opacity_keyframe_y2, + node.style.animations().opacity_keyframe_timing_kind, + node.style.animations().opacity_keyframe_step_count, + node.style.animations().opacity_keyframe_step_position); + animation.painted_filter_functions = from.functions; + for (size_t index = 0U; + index < animation.painted_filter_functions.size(); ++index) { + const auto start = from.functions[index].amount; + animation.painted_filter_functions[index].amount = start + + (right->functions[index].amount - start) * eased; + } + } + }; const auto elapsed_ms = static_cast( animation_frame_timestamp_ms_ - animation.filter_keyframe_animation_started_ms - node.style.animations().opacity_keyframe_delay_ms); if (elapsed_ms < 0) { - animation.painted_filter_functions = - animation.filter_keyframe_underlying; + if (fills_before(node.style.animations().keyframe_fill_mode)) { + sample_filter(directed_keyframe_progress( + 0.0F, 0.0, node.style.animations().keyframe_direction)); + } else { + animation.painted_filter_functions = + animation.filter_keyframe_underlying; + } advanced = advanced || keyframe_paint_visible; } else { const auto duration = std::max( @@ -1154,58 +1262,15 @@ bool native_document::advance_animations() noexcept const auto total_duration = finite ? duration * std::max(0.0F, iterations) : 0.0F; - const auto sample_filter = [&](float cycle_progress) { - const auto& stops = animation.filter_keyframes; - const auto assign_stop = [&](const auto& stop) { - if (stop.authored_none) { - animation.painted_filter_functions.clear(); - } else { - animation.painted_filter_functions = stop.functions; - } - }; - auto right = std::lower_bound( - stops.begin(), stops.end(), cycle_progress, - [](const auto& stop, float progress) { - return stop.offset < progress; - }); - if (right == stops.begin()) { - assign_stop(*right); - } else if (right == stops.end()) { - assign_stop(stops.back()); - } else if (std::abs(cycle_progress - right->offset) < 0.000001F) { - assign_stop(*right); - } else { - const auto& from = *(right - 1); - const auto span = std::max( - 0.0001F, right->offset - from.offset); - const auto segment_progress = std::clamp( - (cycle_progress - from.offset) / span, 0.0F, 1.0F); - const auto eased = timing_value( - segment_progress, - node.style.animations().opacity_keyframe_x1, - node.style.animations().opacity_keyframe_y1, - node.style.animations().opacity_keyframe_x2, - node.style.animations().opacity_keyframe_y2, - node.style.animations().opacity_keyframe_timing_kind, - node.style.animations().opacity_keyframe_step_count, - node.style.animations().opacity_keyframe_step_position); - animation.painted_filter_functions = from.functions; - for (size_t index = 0U; - index < animation.painted_filter_functions.size(); ++index) { - const auto start = from.functions[index].amount; - animation.painted_filter_functions[index].amount = start - + (right->functions[index].amount - start) * eased; - } - } - }; if (finite && elapsed_ms >= total_duration) { - if (node.style.animations().opacity_keyframe_fill_forwards) { + if (fills_after(node.style.animations().keyframe_fill_mode)) { sample_filter(terminal_keyframe_progress( iterations, node.style.animations().keyframe_direction)); animation.filter_keyframe_animation_filled = true; } else { animation.painted_filter_functions = animation.filter_keyframe_underlying; + animation.filter_keyframe_animation_filled = false; } animation.filter_keyframe_animation_active = false; keyframe_animation_completed = true; diff --git a/experiments/WebScene.NativeEngine.Probe/native/webscene_v8_runtime_style.inc b/experiments/WebScene.NativeEngine.Probe/native/webscene_v8_runtime_style.inc index ab47a430..b9abd24e 100644 --- a/experiments/WebScene.NativeEngine.Probe/native/webscene_v8_runtime_style.inc +++ b/experiments/WebScene.NativeEngine.Probe/native/webscene_v8_runtime_style.inc @@ -288,6 +288,8 @@ if (!has_authored_transition) node.style.inline_property_mask &= ~inline_transition; } else if (name == "animationDirection" || name == "animation-direction") { node.style.mutable_animations().animation_direction_value = "normal"; + } else if (name == "animationFillMode" || name == "animation-fill-mode") { + node.style.mutable_animations().animation_fill_mode_value = "none"; } else if (name == "animation" || name == "animationName" || name == "animation-name" || name == "animationDuration" || name == "animation-duration" || name == "animationDelay" @@ -301,6 +303,7 @@ animations.animation_timing_function_value = "ease"; animations.animation_iteration_count_value = "1"; animations.animation_direction_value = "normal"; + animations.animation_fill_mode_value = "none"; } else if (name == "opacity") { node.style.opacity = 1; node.style.inline_property_mask &= ~inline_opacity; @@ -1381,7 +1384,7 @@ } else if (name == "transform") { if (node->style.transform_specified || node->transform_animation_active_value() - || node->rotation_keyframe_animation_active_value()) { + || node->has_painted_rotation_keyframe_override_value()) { constexpr double degrees_to_radians = 0.017453292519943295; const auto radians = static_cast( node->painted_transform_rotation_value()) @@ -1432,6 +1435,8 @@ : node->style.animations().transition_delay_value; } else if (name == "transition-timing-function") { value = node->style.animations().transition_timing_function_value; + } else if (name == "animation-fill-mode") { + value = node->style.animations().animation_fill_mode_value; } else if (name == "opacity") { value = serialize_css_number(node->painted_opacity_value()); } else if (name == "color") { @@ -1980,7 +1985,7 @@ } else if (name == "transform") { if (!node->style.transform_specified && !node->transform_animation_active_value() - && !node->rotation_keyframe_animation_active_value()) { + && !node->has_painted_rotation_keyframe_override_value()) { value = "none"; } else { constexpr double degrees_to_radians = 0.017453292519943295; @@ -2040,7 +2045,8 @@ + node->style.animations().animation_timing_function_value + " " + node->style.animations().animation_delay_value + " " + node->style.animations().animation_iteration_count_value + " " - + node->style.animations().animation_direction_value; + + node->style.animations().animation_direction_value + " " + + node->style.animations().animation_fill_mode_value; } else if (name == "animationName" || name == "animation-name") { value = node->style.animations().animation_name_value; } else if (name == "animationDuration" || name == "animation-duration") { @@ -2055,6 +2061,8 @@ value = node->style.animations().animation_iteration_count_value; } else if (name == "animationDirection" || name == "animation-direction") { value = node->style.animations().animation_direction_value; + } else if (name == "animationFillMode" || name == "animation-fill-mode") { + value = node->style.animations().animation_fill_mode_value; } else if (name == "zIndex") { value = node->style.z_index_auto ? "auto" : std::to_string(node->style.z_index); @@ -2566,6 +2574,8 @@ node->style.mutable_animations().animation_iteration_count_value = value; } else if (name == "animationDirection") { node->style.mutable_animations().animation_direction_value = value; + } else if (name == "animationFillMode") { + node->style.mutable_animations().animation_fill_mode_value = value; } else if (name == "opacity") { node->style.opacity = raw_value->IsNullOrUndefined() ? 1.0F diff --git a/experiments/WebScene.NativeEngine.Probe/tests/native_v8_runtime_animation_cssom_tests.inc b/experiments/WebScene.NativeEngine.Probe/tests/native_v8_runtime_animation_cssom_tests.inc index 277b4734..60b0f013 100644 --- a/experiments/WebScene.NativeEngine.Probe/tests/native_v8_runtime_animation_cssom_tests.inc +++ b/experiments/WebScene.NativeEngine.Probe/tests/native_v8_runtime_animation_cssom_tests.inc @@ -701,6 +701,128 @@ void test_animation_direction_maps_cycles_and_terminal_boundaries( engine, false, "detached direction animations retained host-frame demand"); } +void test_animation_fill_maps_before_after_and_preserves_timeline( + webscene_engine* engine) +{ + animation_frame_and_wait(engine, 6000.0, 7100U); + execute_and_wait(engine, R"JS( + (() => { + document.body.innerHTML = ` + +
+
+
`; + globalThis.__fillEndCount = 0; + document.getElementById('backwards').addEventListener( + 'animationend', () => ++globalThis.__fillEndCount); + void document.body.offsetHeight; + })() + )JS", "animation-fill-setup.js"); + + animation_frame_and_wait(engine, 6250.0, 7101U); + const auto before = evaluate(engine, R"JS( + (() => { + const opacity = id => Number(getComputedStyle( + document.getElementById(id)).opacity); + const close = (left, right) => Math.abs(left - right) < .001; + const rotation = getComputedStyle(document.getElementById('rotation')).transform; + const filter = getComputedStyle(document.getElementById('filter')).filter; + const metadata = ['none', 'backwards', 'reverse-both', 'stepped'] + .map(id => getComputedStyle(document.getElementById(id)).animationFillMode); + return JSON.stringify(metadata) + === '["none","backwards, forwards","both","backwards"]' + && close(opacity('none'), .8) && close(opacity('backwards'), 0) + && close(opacity('reverse-both'), 1) && close(opacity('stepped'), 0) + && rotation.startsWith('matrix(') && filter === 'brightness(0.5)'; + })() + )JS", "animation-fill-before.js"); + require(before == "true", + "backwards/both fill did not map direction and timing in the before phase"); + + animation_frame_and_wait(engine, 7500.0, 7102U); + const auto after = evaluate(engine, R"JS( + (() => { + const opacity = id => Number(getComputedStyle( + document.getElementById(id)).opacity); + const close = (left, right) => Math.abs(left - right) < .001; + const transform = getComputedStyle(document.getElementById('rotation')).transform; + const matrix = transform.slice(7, -1).split(',').map(Number); + let angle = Math.atan2(matrix[1], matrix[0]) * 180 / Math.PI; + if (angle < 0) angle += 360; + return close(opacity('none'), .8) && close(opacity('backwards'), .8) + && close(opacity('reverse-both'), 0) && close(angle, 180) + && getComputedStyle(document.getElementById('filter')).filter + === 'brightness(1.5)' + && __fillEndCount === 1; + })() + )JS", "animation-fill-after.js"); + require(after == "true", + "after fill did not retain rotation/filter or restore backwards-only opacity"); + wait_for_animation_frame_demand( + engine, false, "filled animations retained host-frame demand"); + + execute_and_wait(engine, R"JS( + (() => { + document.getElementById('backwards').style.animationFillMode = 'forwards'; + return getComputedStyle(document.getElementById('backwards')).animationFillMode; + })() + )JS", "animation-fill-live-update.js"); + animation_frame_and_wait(engine, 7510.0, 7103U); + const auto live_update = evaluate(engine, R"JS( + Number(getComputedStyle(document.getElementById('backwards')).opacity) === 1 + && __fillEndCount === 1 + )JS", "animation-fill-live-update-result.js"); + require(live_update == "true", + "fill-only CSSOM update restarted the timeline or duplicated animationend"); + wait_for_animation_frame_demand( + engine, false, "fill-only update retained host-frame demand"); + + execute_and_wait(engine, R"JS( + (() => { + const backwards = document.getElementById('backwards'); + backwards.style.animationFillMode = ''; + document.getElementById('rotation').style.animation = 'none'; + document.getElementById('filter').style.animation = 'none'; + return getComputedStyle(backwards).animationFillMode; + })() + )JS", "animation-fill-clear.js"); + animation_frame_and_wait(engine, 7520.0, 7104U); + const auto cleared = evaluate(engine, R"JS( + (() => { + const backwards = document.getElementById('backwards'); + return getComputedStyle(backwards).animationFillMode === 'backwards, forwards' + && Math.abs(Number(getComputedStyle(backwards).opacity) - .8) < .001 + && getComputedStyle(document.getElementById('rotation')).transform === 'none' + && getComputedStyle(document.getElementById('filter')).filter + === 'brightness(2)'; + })() + )JS", "animation-fill-clear-result.js"); + require(cleared == "true", "fill removal left a stale retained override"); + + execute_and_wait(engine, + "document.body.innerHTML = '
fill animations detached
'", + "animation-fill-detach.js"); + wait_for_animation_frame_demand( + engine, false, "detached fill animations retained host-frame demand"); +} + void test_filter_keyframes_use_host_clock_and_retained_paint( webscene_engine* engine) { diff --git a/experiments/WebScene.NativeEngine.Probe/tests/native_v8_runtime_tests.cpp b/experiments/WebScene.NativeEngine.Probe/tests/native_v8_runtime_tests.cpp index 8d61cf73..0ebdb647 100644 --- a/experiments/WebScene.NativeEngine.Probe/tests/native_v8_runtime_tests.cpp +++ b/experiments/WebScene.NativeEngine.Probe/tests/native_v8_runtime_tests.cpp @@ -1138,6 +1138,7 @@ int main() test_filter_keyframes_use_host_clock_and_retained_paint(focused_engine); test_clipped_offscreen_keyframes_do_not_keep_host_frame_clock_alive(focused_engine); test_animation_direction_maps_cycles_and_terminal_boundaries(focused_engine); + test_animation_fill_maps_before_after_and_preserves_timeline(focused_engine); webscene_engine_destroy(focused_engine); return 0; } @@ -1633,6 +1634,7 @@ int main() test_clipped_offscreen_keyframes_do_not_keep_host_frame_clock_alive(engine); test_finite_rotation_keyframe_dispatches_animation_end(engine); test_animation_direction_maps_cycles_and_terminal_boundaries(engine); + test_animation_fill_maps_before_after_and_preserves_timeline(engine); // This regression uses fixed host timestamps beginning at 2700 ms. Give it // a fresh timeline so earlier animation tests cannot make those frames stale. webscene_engine_destroy(engine); diff --git a/tests/WebPlatformSubset/capabilities.json b/tests/WebPlatformSubset/capabilities.json index e0d50a49..4d9bc5e8 100644 --- a/tests/WebPlatformSubset/capabilities.json +++ b/tests/WebPlatformSubset/capabilities.json @@ -97,11 +97,11 @@ }, { "family": "transitions-and-animation", - "required": ["host-frame-driven requestAnimationFrame", "transition longhands and delay", "four-number cubic-bezier timing", "translate, scale, rotate, opacity, foreground color, background color, supported compound filters, left and top interpolation", "background shorthand transition aliasing", "filter none identity interpolation", "logical inset transition aliasing", "intermediate computed style, paint and client geometry", "transition run/start/cancel/end events", "cancellation and reversal", "bounded paint samples", "dense bounded rotation cadence", "native opacity, rotate, and bounded filter keyframes", "native animation shorthand and longhands", "native staggered delay and infinite iteration", "single-animation normal, reverse, alternate, and alternate-reverse direction"], + "required": ["host-frame-driven requestAnimationFrame", "transition longhands and delay", "four-number cubic-bezier timing", "translate, scale, rotate, opacity, foreground color, background color, supported compound filters, left and top interpolation", "background shorthand transition aliasing", "filter none identity interpolation", "logical inset transition aliasing", "intermediate computed style, paint and client geometry", "transition run/start/cancel/end events", "cancellation and reversal", "bounded paint samples", "dense bounded rotation cadence", "native opacity, rotate, and bounded filter keyframes", "native animation shorthand and longhands", "native staggered delay and infinite iteration", "single-animation normal, reverse, alternate, and alternate-reverse direction", "single-animation none, forwards, backwards, and both fill"], "candidate": ["innerHTML transition-longhand retention", "inline transition recascade and per-longhand importance", "computed transition times serialized in seconds", "synthetic click timer task ordering"], "productEvidence": ["calendar segmented-tab underline", "Code OSS Chat and session filter transitions", "Code OSS dictation brightness and incremental Chat blur keyframes", "automatically discovered three-dot loader animation", "automatically discovered rotating spinner", "animated toolbar and dialog state changes", "continuous live-resize chart layout"], - "coverage": ["contracts/segmented-transform-transition.html", "contracts/transform-none-transition.html", "contracts/paint-transitions-temporal.html", "contracts/css-filter-transition-temporal.html", "contracts/css-filter-transition-midpoint.html", "contracts/logical-inset-transition-cadence.html", "contracts/rotation-transition-cadence.html", "contracts/dynamic-transition-style-task-order.html", "contracts/css-opacity-keyframes-temporal.html", "contracts/css-animation-fill-mode-forwards.html", "contracts/css-animation-direction.html", "contracts/css-rotation-keyframes-cadence.html", "contracts/css-filter-keyframes-temporal.html", "contracts/css-filter-keyframes-midpoint.html", "CssTransformTransitionTests", "test_inline_transition_longhands_survive_dynamic_parse_and_recascade", "test_logical_inset_transition_smooths_throttled_pointer_updates", "test_filter_keyframes_use_host_clock_and_retained_paint", "test_animation_direction_maps_cycles_and_terminal_boundaries", "native host-clock transition, retained filter paint, and keyframe regressions", "hosted component automatically discovered temporal checkpoints", "hosted component intermediate viewport-publication gate"], - "gap": "Native is required to pass the bounded transform/opacity/foreground-color/background-color/filter transition slice, including events, cancellation, reversal, authored compound order, identity interpolation, paint, and cadence. Filter transitions and keyframes are limited to the retained blur, brightness, contrast, grayscale, and saturate functions and their existing list/value bounds. Bounded filter keyframes cover Code OSS dictation brightness and incremental Chat blur, including compatible compound order, none identities, finite fill, animationend, retained paint, and host-clock cleanup. The single-animation keyframe slice maps normal, reverse, alternate, and alternate-reverse through negative delays and finite, fractional, or infinite iteration counts before opacity, rotation, and bounded-filter sampling. Identity interpolation from transform:none is part of the neutral forward/reverse contract. The candidate dynamic-style reduction passes Chrome and native and closes Bootstrap Modal's static-backdrop callback guard by retaining inline transition longhands through parser construction and recascade, honoring per-longhand importance, and exposing computed times in seconds. Native also passes candidate opacity and rotate() CSS Animations contracts, while generic discovery proves changing staggered-dot and spinner paint samples. Other animated properties, play state, backwards fill, multiple-animation composition, and the complete Web Animations API are not claimed." + "coverage": ["contracts/segmented-transform-transition.html", "contracts/transform-none-transition.html", "contracts/paint-transitions-temporal.html", "contracts/css-filter-transition-temporal.html", "contracts/css-filter-transition-midpoint.html", "contracts/logical-inset-transition-cadence.html", "contracts/rotation-transition-cadence.html", "contracts/dynamic-transition-style-task-order.html", "contracts/css-opacity-keyframes-temporal.html", "contracts/css-animation-fill-mode-forwards.html", "contracts/css-animation-fill-mode-boundaries.html", "contracts/css-animation-direction.html", "contracts/css-rotation-keyframes-cadence.html", "contracts/css-filter-keyframes-temporal.html", "contracts/css-filter-keyframes-midpoint.html", "CssTransformTransitionTests", "test_inline_transition_longhands_survive_dynamic_parse_and_recascade", "test_logical_inset_transition_smooths_throttled_pointer_updates", "test_filter_keyframes_use_host_clock_and_retained_paint", "test_animation_direction_maps_cycles_and_terminal_boundaries", "test_animation_fill_maps_before_after_and_preserves_timeline", "native host-clock transition, retained filter paint, and keyframe regressions", "hosted component automatically discovered temporal checkpoints", "hosted component intermediate viewport-publication gate"], + "gap": "Native is required to pass the bounded transform/opacity/foreground-color/background-color/filter transition slice, including events, cancellation, reversal, authored compound order, identity interpolation, paint, and cadence. Filter transitions and keyframes are limited to the retained blur, brightness, contrast, grayscale, and saturate functions and their existing list/value bounds. Bounded filter keyframes cover Code OSS dictation brightness and incremental Chat blur, including compatible compound order, none identities, finite fill, animationend, retained paint, and host-clock cleanup. The single-animation keyframe slice maps normal, reverse, alternate, and alternate-reverse through negative delays and finite, fractional, or infinite iteration counts before opacity, rotation, and bounded-filter sampling. For positive-duration, nonzero-count animations, none, forwards, backwards, and both now apply direction-aware fill boundaries to those supported properties without extending frame demand; positive-delay backwards fill samples its boundary without applying the between-keyframe timing function. Identity interpolation from transform:none is part of the neutral forward/reverse contract. The candidate dynamic-style reduction passes Chrome and native and closes Bootstrap Modal's static-backdrop callback guard by retaining inline transition longhands through parser construction and recascade, honoring per-longhand importance, and exposing computed times in seconds. Native also passes candidate opacity and rotate() CSS Animations contracts, while generic discovery proves changing staggered-dot and spinner paint samples. Other animated properties, play state, zero-duration or zero-count fill, multiple-animation composition, and the complete Web Animations API are not claimed." }, { "family": "clipping-and-rounded-borders", diff --git a/tests/WebPlatformSubset/contracts/css-animation-fill-mode-boundaries.html b/tests/WebPlatformSubset/contracts/css-animation-fill-mode-boundaries.html new file mode 100644 index 00000000..2811e1dc --- /dev/null +++ b/tests/WebPlatformSubset/contracts/css-animation-fill-mode-boundaries.html @@ -0,0 +1,103 @@ + + +CSS animation fill maps before and after boundaries without timeline restart + +
+
+
+ diff --git a/tests/WebPlatformSubset/webscene-component-profile.json b/tests/WebPlatformSubset/webscene-component-profile.json index 8106b57a..2aecbd9d 100644 --- a/tests/WebPlatformSubset/webscene-component-profile.json +++ b/tests/WebPlatformSubset/webscene-component-profile.json @@ -1874,6 +1874,13 @@ "evidence": ["spotify-lazy-artwork-fade-retention-regression"], "reason": "Product-neutral reduction of lazy-loaded artwork that fades from opacity zero and relies on animation-fill-mode: forwards. The final keyframe must remain painted after a finite animation completes instead of reverting to the authored hidden opacity." }, + { + "path": "contracts/css-animation-fill-mode-boundaries.html", + "type": "contract", + "capabilities": ["animation-fill-mode-longhand", "animation-fill-mode-shorthand", "backwards-both-fill", "direction-aware-fill-boundaries", "opacity-rotation-filter-fill", "fill-only-timeline-preservation", "settled-frame-demand"], + "evidence": ["css-animation-fill-mode-661-242", "unchanged-code-oss-delayed-entry-animations"], + "reason": "WPT-aligned single-animation reduction for first-list fill metadata, direction-aware before fill with timing functions excluded during positive delay, retained opacity/rotation/filter terminal values, live fill changes that preserve time, and removal cleanup." + }, { "path": "contracts/css-animation-direction.html", "type": "contract", diff --git a/tests/WebPlatformSubset/webscene-css-animation-fill-mode-profile.json b/tests/WebPlatformSubset/webscene-css-animation-fill-mode-profile.json new file mode 100644 index 00000000..15fbb3a8 --- /dev/null +++ b/tests/WebPlatformSubset/webscene-css-animation-fill-mode-profile.json @@ -0,0 +1,29 @@ +{ + "profile": "webscene-css-animation-fill-mode-1", + "wptRevision": "2c705104a295c48053eeddf7fe0170d790a4e853", + "runtime": "v8", + "viewport": { + "width": 800, + "height": 600, + "deviceScaleFactor": 1 + }, + "required": [ + { + "path": "contracts/css-animation-fill-mode-boundaries.html", + "type": "contract", + "capabilities": [ + "animation-fill-mode-longhand", + "animation-fill-mode-shorthand", + "backwards-both-fill", + "direction-aware-fill-boundaries", + "opacity-rotation-filter-fill", + "fill-only-timeline-preservation", + "settled-frame-demand" + ], + "evidence": ["css-animation-fill-mode-661-242"], + "reason": "WPT-aligned CSS Animations reduction for first-list fill metadata, direction-aware before fill with timing functions excluded during positive delay, retained supported-property terminal values, live fill changes that preserve time, and removal cleanup." + } + ], + "harnessBlocked": [], + "excluded": [] +}