From 7fc9129b1e0c9a3287410997f589eef84806281c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Wies=C5=82aw=20=C5=A0olt=C3=A9s?= Date: Sat, 19 Sep 2026 16:37:07 +0200 Subject: [PATCH] Animate translate and scale keyframes (#675) --- ...-animation-transform-components-675-242.md | 59 +++++ .../native/webscene_css_state.h | 2 + .../native/webscene_css_transitions.h | 233 ++++++++++++++++-- .../native/webscene_native_dom.h | 18 ++ .../native/webscene_native_dom_animations.inc | 93 +++++++ .../native/webscene_native_dom_metrics.inc | 4 + .../native/webscene_v8_runtime.cpp | 8 + .../webscene_v8_runtime_css_cascade.inc | 3 + .../webscene_v8_runtime_css_parsing.inc | 87 +------ .../native/webscene_v8_runtime_lifecycle.inc | 4 + ...ative_v8_runtime_animation_cssom_tests.inc | 109 ++++++++ .../tests/native_v8_runtime_tests.cpp | 2 + tests/NativeWeb/css_service.cpp | 18 +- tests/WebPlatformSubset/capabilities.json | 6 +- ...ss-animation-transform-components-ref.html | 19 ++ .../css-animation-transform-components.html | 34 +++ .../webscene-component-profile.json | 8 + ...nimation-transform-components-profile.json | 29 +++ 18 files changed, 626 insertions(+), 110 deletions(-) create mode 100644 docs/validation/css-animation-transform-components-675-242.md create mode 100644 tests/WebPlatformSubset/contracts/css-animation-transform-components-ref.html create mode 100644 tests/WebPlatformSubset/contracts/css-animation-transform-components.html create mode 100644 tests/WebPlatformSubset/webscene-css-animation-transform-components-profile.json diff --git a/docs/validation/css-animation-transform-components-675-242.md b/docs/validation/css-animation-transform-components-675-242.md new file mode 100644 index 00000000..326101ce --- /dev/null +++ b/docs/validation/css-animation-transform-components-675-242.md @@ -0,0 +1,59 @@ +# CSS animation transform-component source validation + +Issue #675 extends WebScene's retained eight-track CSS animation runtime under +#242 with bounded two-dimensional translate and scale keyframe components. A +valid supported `transform` keyframe compiles once into one replace-composed +tuple: x/y translation, x/y scale, and rotation. Animation-list order remains +the composition order, so the last contributing track replaces the whole +supported transform tuple deterministically. + +## Grammar and retained representation + +The accepted keyframe grammar is `none` or a list containing at most five +non-duplicated `translate`, `translateX`, `translateY`, `scale`, `scaleX`, +`scaleY`, and `rotate` functions. Translation accepts finite `px`, percentage, +or unitless-zero operands. Scale accepts finite numbers. Rotation retains the +existing finite zero, degree, radian, and turn forms. Commas or CSS whitespace +separate the two-argument translate and scale forms. Unsupported functions, +duplicate components, malformed operands, nested functions, non-finite values, +and transform text over 1,024 bytes do not create a transform animation track. + +Each valid declaration emits aligned translation, scale, and rotation stops; +an omitted component uses its identity. This preserves CSS replace composition +inside a track and between the runtime's maximum eight coordinated tracks. +Stops, timing metadata, and signatures are retained during cascade. Sampling +does no string parsing, selector matching, cascade, or visual-tree mutation. + +## Timeline, geometry, and lifecycle + +Translate and scale consume the same resolved progress as opacity, rotation, +and filters, including delay, negative delay, direction, finite, fractional, +infinite, and zero iteration counts, fill, pause/resume, and zero duration. +Translation uses the retained linear pixel/percentage representation and enters +the existing transform geometry invalidation path. Scale and rotation remain +paint-only. The scene, hit testing, computed transform matrix, and client +geometry all consume the same sampled tuple. + +Identity mutation resets only the changed track. Removal, detach, navigation, +and teardown discard its retained tuple. A completed filled tuple stays static +without host-frame demand. At most eight tracks and their bounded stop vectors +are scanned per host frame; there is no per-frame parsing, cascade, allocation +of transform stops, or visual-tree reconstruction. + +## Evidence and deferred scope + +`test_transform_keyframes_compose_retained_geometry_and_paint` covers pixel and +percentage translation, one- and two-axis scale, rotation composition, a +paused negative-delay midpoint, list-order replacement, reverse zero-time fill, +computed matrices, client geometry, retained scene scale/rotation commands, +identity mutation, removal, detach, and settled frame demand. The dedicated +browser reftest is a WPT-aligned midpoint pixel and geometry oracle against an +equivalent static transform. + +Arbitrary ordered transform-list matrix multiplication, 3D transforms, nested +`calc()` or custom-property operands inside keyframes, additive animation +composition, individual `translate`/`scale` properties, more than eight live +tracks, expanded animation events, and Web Animations API objects remain +deferred. Under the fast implementation policy, only `git diff --check` is +executed. Native, browser, package, and unchanged Code OSS acceptance remain +unexecuted. diff --git a/experiments/WebScene.NativeEngine.Probe/native/webscene_css_state.h b/experiments/WebScene.NativeEngine.Probe/native/webscene_css_state.h index 795fbe03..5ccdb45a 100644 --- a/experiments/WebScene.NativeEngine.Probe/native/webscene_css_state.h +++ b/experiments/WebScene.NativeEngine.Probe/native/webscene_css_state.h @@ -253,6 +253,8 @@ struct compiled_css_selector final { struct css_opacity_keyframes final { std::vector opacity_stops; + std::vector translation_stops; + std::vector scale_stops; std::vector rotation_stops; std::vector filter_stops; }; diff --git a/experiments/WebScene.NativeEngine.Probe/native/webscene_css_transitions.h b/experiments/WebScene.NativeEngine.Probe/native/webscene_css_transitions.h index a48f3def..d185c97b 100644 --- a/experiments/WebScene.NativeEngine.Probe/native/webscene_css_transitions.h +++ b/experiments/WebScene.NativeEngine.Probe/native/webscene_css_transitions.h @@ -1,5 +1,6 @@ #pragma once #include "webscene_css_box_values.h" +#include #include #include #include @@ -25,6 +26,178 @@ inline std::optional css_time_ms(std::string_view text) { inline bool is_css_time(std::string_view value) { return css_time_ms(value).has_value(); } inline float parse_css_time_ms(std::string value) { return css_time_ms(value).value_or(0); } +struct parsed_keyframe_transform final { + css_length translate_x{0, length_unit::pixels}; + css_length translate_y{0, length_unit::pixels}; + float scale_x{1}; + float scale_y{1}; + float rotate_degrees{0}; +}; + +inline std::optional finite_css_number(std::string_view text) +{ + text = trim_css_view(text); + if (text.empty() || text.size() > 64U) return std::nullopt; + const std::string value{text}; + char* end = nullptr; + const auto number = std::strtof(value.c_str(), &end); + if (end != value.c_str() + value.size() || !std::isfinite(number)) { + return std::nullopt; + } + return number; +} + +inline std::optional keyframe_translation_length(std::string_view text) +{ + text = trim_css_view(text); + if (text.empty() || text.size() > 64U) return std::nullopt; + auto lower = ascii_lower(std::string(text)); + if (lower.ends_with('%')) { + const auto number = finite_css_number( + std::string_view(lower).substr(0U, lower.size() - 1U)); + return number.has_value() + ? std::optional{css_length{*number, length_unit::percent}} + : std::nullopt; + } + if (lower.ends_with("px")) { + const auto number = finite_css_number( + std::string_view(lower).substr(0U, lower.size() - 2U)); + return number.has_value() + ? std::optional{css_length{*number, length_unit::pixels}} + : std::nullopt; + } + const auto zero = finite_css_number(lower); + return zero.has_value() && *zero == 0.0F + ? std::optional{css_length{0, length_unit::pixels}} + : std::nullopt; +} + +inline std::optional keyframe_rotation_angle(std::string_view text) +{ + text = trim_css_view(text); + if (text.empty() || text.size() > 64U) return std::nullopt; + auto lower = ascii_lower(std::string(text)); + auto multiplier = 1.0F; + if (lower.ends_with("deg")) lower.resize(lower.size() - 3U); + else if (lower.ends_with("turn")) { + lower.resize(lower.size() - 4U); + multiplier = 360.0F; + } else if (lower.ends_with("rad")) { + lower.resize(lower.size() - 3U); + multiplier = 57.29577951308232F; + } else { + const auto zero = finite_css_number(lower); + return zero.has_value() && *zero == 0.0F ? zero : std::nullopt; + } + const auto number = finite_css_number(lower); + if (!number.has_value() || !std::isfinite(*number * multiplier)) { + return std::nullopt; + } + return *number * multiplier; +} + +inline std::optional parse_keyframe_transform( + std::string value) +{ + value = ascii_lower(trim_value(std::move(value))); + if (value == "none") return parsed_keyframe_transform{}; + if (value.empty() || value.size() > 1024U) return std::nullopt; + parsed_keyframe_transform result; + bool translated_x = false; + bool translated_y = false; + bool scaled_x = false; + bool scaled_y = false; + bool rotated = false; + size_t cursor = 0U; + size_t function_count = 0U; + while (cursor < value.size()) { + while (cursor < value.size() + && std::isspace(static_cast(value[cursor]))) ++cursor; + if (cursor == value.size()) break; + const auto name_begin = cursor; + while (cursor < value.size() + && std::isalpha(static_cast(value[cursor]))) ++cursor; + if (cursor == name_begin || cursor >= value.size() || value[cursor] != '(') { + return std::nullopt; + } + const auto name = value.substr(name_begin, cursor - name_begin); + const auto argument_begin = ++cursor; + auto depth = 1U; + while (cursor < value.size() && depth != 0U) { + if (value[cursor] == '(') ++depth; + else if (value[cursor] == ')') --depth; + ++cursor; + } + if (depth != 0U || ++function_count > 5U) return std::nullopt; + const auto argument_end = cursor - 1U; + if (value.find('(', argument_begin) < argument_end) return std::nullopt; + auto arguments = split_css_component_list( + std::string_view(value).substr( + argument_begin, argument_end - argument_begin), ','); + if (arguments.size() == 1U) { + auto first = trim_value(arguments.front()); + const auto separator = first.find_first_of(" \t\r\n"); + if (separator != std::string::npos) { + auto second_begin = first.find_first_not_of(" \t\r\n", separator); + if (second_begin == std::string::npos + || first.find_first_of(" \t\r\n", second_begin) + != std::string::npos) return std::nullopt; + arguments = { + first.substr(0U, separator), first.substr(second_begin)}; + } + } + const auto translation = [&](size_t index) { + return index < arguments.size() + ? keyframe_translation_length(arguments[index]) : std::nullopt; + }; + const auto scale = [&](size_t index) { + return index < arguments.size() + ? finite_css_number(arguments[index]) : std::nullopt; + }; + if (name == "translate" && (arguments.size() == 1U || arguments.size() == 2U) + && !translated_x && !translated_y) { + const auto x = translation(0U); + const auto y = arguments.size() == 2U + ? translation(1U) + : std::optional{css_length{0, length_unit::pixels}}; + if (!x.has_value() || !y.has_value()) return std::nullopt; + result.translate_x = *x; result.translate_y = *y; + translated_x = translated_y = true; + } else if (name == "translatex" && arguments.size() == 1U && !translated_x) { + const auto x = translation(0U); + if (!x.has_value()) return std::nullopt; + result.translate_x = *x; translated_x = true; + } else if (name == "translatey" && arguments.size() == 1U && !translated_y) { + const auto y = translation(0U); + if (!y.has_value()) return std::nullopt; + result.translate_y = *y; translated_y = true; + } else if (name == "scale" && (arguments.size() == 1U || arguments.size() == 2U) + && !scaled_x && !scaled_y) { + const auto x = scale(0U); + const auto y = arguments.size() == 2U ? scale(1U) : x; + if (!x.has_value() || !y.has_value()) return std::nullopt; + result.scale_x = *x; result.scale_y = *y; + scaled_x = scaled_y = true; + } else if (name == "scalex" && arguments.size() == 1U && !scaled_x) { + const auto x = scale(0U); + if (!x.has_value()) return std::nullopt; + result.scale_x = *x; scaled_x = true; + } else if (name == "scaley" && arguments.size() == 1U && !scaled_y) { + const auto y = scale(0U); + if (!y.has_value()) return std::nullopt; + result.scale_y = *y; scaled_y = true; + } else if (name == "rotate" && arguments.size() == 1U && !rotated) { + const auto angle = keyframe_rotation_angle(arguments.front()); + if (!angle.has_value()) return std::nullopt; + result.rotate_degrees = *angle; rotated = true; + } else { + return std::nullopt; + } + } + return function_count == 0U + ? std::nullopt : std::optional{result}; +} + inline void parse_transition_timing( const std::string& value, node_style::transition_timing& timing) @@ -424,11 +597,15 @@ inline void configure_keyframes(node_style& style, const auto definition = definitions.find(normalized_name); if (normalized_name != "none" && definition != definitions.end()) { track.opacity_keyframes = definition->second.opacity_stops; + track.translation_keyframes = definition->second.translation_stops; + track.scale_keyframes = definition->second.scale_stops; track.rotation_keyframes = definition->second.rotation_stops; track.filter_keyframes = definition->second.filter_stops; } const auto has_supported_effect = track.opacity_keyframes.size() >= 2U + || track.translation_keyframes.size() >= 2U + || track.scale_keyframes.size() >= 2U || track.rotation_keyframes.size() >= 2U || track.filter_keyframes.size() >= 2U; if (has_supported_effect) { @@ -442,6 +619,15 @@ inline void configure_keyframes(node_style& style, << track.x1 << ',' << track.y1 << ',' << track.x2 << ',' << track.y2; for (const auto& stop : track.opacity_keyframes) signature << "|o" << stop.offset << ':' << stop.opacity; + for (const auto& stop : track.translation_keyframes) { + signature << "|t" << stop.offset << ':' + << stop.x.value << ',' << static_cast(stop.x.unit) + << ',' << stop.x.pixel_offset << ':' + << stop.y.value << ',' << static_cast(stop.y.unit) + << ',' << stop.y.pixel_offset; + } + for (const auto& stop : track.scale_keyframes) + signature << "|s" << stop.offset << ':' << stop.x << ',' << stop.y; for (const auto& stop : track.rotation_keyframes) signature << "|r" << stop.offset << ':' << stop.degrees; for (const auto& stop : track.filter_keyframes) @@ -469,26 +655,9 @@ inline void append_keyframe( declarations.begin(), declarations.end(), [](const auto& declaration) { return declaration.name == "filter"; }); - const auto rotation_degrees = [&]() -> std::optional { - if (transform == declarations.end()) return std::nullopt; - auto value = ascii_lower(trim_value(transform->value)); - const auto rotate = value.find("rotate("); - if (rotate == std::string::npos) return std::nullopt; - const auto close = value.find(')', rotate + 7U); - if (close == std::string::npos) return std::nullopt; - auto angle = trim_value(value.substr(rotate + 7U, close - rotate - 7U)); - auto multiplier = 1.0F; - if (angle.ends_with("turn")) { - angle.resize(angle.size() - 4U); - multiplier = 360.0F; - } else if (angle.ends_with("deg")) { - angle.resize(angle.size() - 3U); - } else if (angle.ends_with("rad")) { - angle.resize(angle.size() - 3U); - multiplier = 57.29577951308232F; - } else return std::nullopt; - return std::strtof(angle.c_str(), nullptr) * multiplier; - }(); + const auto transform_value = transform == declarations.end() + ? std::optional{} + : parse_keyframe_transform(transform->value); for (auto component : split_css_component_list(selector, ',')) { component = ascii_lower(trim_value(std::move(component))); float offset = -1; @@ -504,8 +673,13 @@ inline void append_keyframe( offset, std::clamp(std::strtof(opacity->value.c_str(), nullptr), 0.0F, 1.0F)}); } - if (rotation_degrees.has_value()) { - definition.rotation_stops.push_back({offset, *rotation_degrees}); + if (transform_value.has_value()) { + definition.translation_stops.push_back({ + offset, transform_value->translate_x, transform_value->translate_y}); + definition.scale_stops.push_back({ + offset, transform_value->scale_x, transform_value->scale_y}); + definition.rotation_stops.push_back({ + offset, transform_value->rotate_degrees}); } if (filter != declarations.end()) { definition.filter_stops.push_back({offset, filter->value}); @@ -535,13 +709,28 @@ inline void finish_keyframes( stops = std::move(unique); }; normalize(definition.opacity_stops); + normalize(definition.translation_stops); + normalize(definition.scale_stops); normalize(definition.rotation_stops); normalize(definition.filter_stops); if (definition.rotation_stops.size() == 1U && definition.rotation_stops.front().offset > 0) { definition.rotation_stops.insert(definition.rotation_stops.begin(), {0, 0}); } + if (definition.translation_stops.size() == 1U + && definition.translation_stops.front().offset > 0) { + definition.translation_stops.insert( + definition.translation_stops.begin(), + {0, {0, length_unit::pixels}, {0, length_unit::pixels}}); + } + if (definition.scale_stops.size() == 1U + && definition.scale_stops.front().offset > 0) { + definition.scale_stops.insert( + definition.scale_stops.begin(), {0, 1, 1}); + } if (definition.opacity_stops.size() >= 2U + || definition.translation_stops.size() >= 2U + || definition.scale_stops.size() >= 2U || definition.rotation_stops.size() >= 2U || definition.filter_stops.size() >= 2U) { definitions[ascii_lower(trim_value(std::move(name)))] = diff --git a/experiments/WebScene.NativeEngine.Probe/native/webscene_native_dom.h b/experiments/WebScene.NativeEngine.Probe/native/webscene_native_dom.h index 4f511eab..9d9baf3b 100644 --- a/experiments/WebScene.NativeEngine.Probe/native/webscene_native_dom.h +++ b/experiments/WebScene.NativeEngine.Probe/native/webscene_native_dom.h @@ -173,6 +173,16 @@ struct node_style final { float offset{0}; float degrees{0}; }; + struct translation_keyframe final { + float offset{0}; + css_length x{}; + css_length y{}; + }; + struct scale_keyframe final { + float offset{0}; + float x{1}; + float y{1}; + }; struct filter_keyframe final { float offset{0}; std::string value; @@ -239,6 +249,8 @@ struct node_style final { std::string name; std::string signature; std::vector opacity_keyframes; + std::vector translation_keyframes; + std::vector scale_keyframes; std::vector rotation_keyframes; std::vector filter_keyframes; float duration_ms{0}; @@ -1468,6 +1480,10 @@ struct dom_node final { double started_ms{0}; double paused_at_ms{0}; float painted_opacity{1}; + css_length painted_translation_x{}; + css_length painted_translation_y{}; + float painted_scale_x{1}; + float painted_scale_y{1}; float painted_rotation_degrees{0}; node_style::animation_data::fill_kind fill_mode{ node_style::animation_data::fill_kind::none}; @@ -1543,6 +1559,8 @@ struct dom_node final { bool opacity_animation_start_event_sent{false}; std::vector keyframe_animations; bool keyframe_opacity_override{false}; + bool keyframe_translation_override{false}; + bool keyframe_scale_override{false}; bool keyframe_rotation_override{false}; bool keyframe_filter_override{false}; uint32_t painted_foreground_rgba{0}; 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 77624042..f635cd80 100644 --- a/experiments/WebScene.NativeEngine.Probe/native/webscene_native_dom_animations.inc +++ b/experiments/WebScene.NativeEngine.Probe/native/webscene_native_dom_animations.inc @@ -331,6 +331,10 @@ void native_document::update_style_animations(dom_node& node) runtime.filter_underlying.clear(); runtime.painted_filter_functions.clear(); runtime.painted_opacity = node.style.opacity; + runtime.painted_translation_x = node.style.transform_translate_x; + runtime.painted_translation_y = node.style.transform_translate_y; + runtime.painted_scale_x = node.style.transform_scale_x; + runtime.painted_scale_y = node.style.transform_scale_y; runtime.painted_rotation_degrees = node.style.transform_rotate_degrees; if (!configured.filter_keyframes.empty()) { auto valid = configured.filter_keyframes.size() >= 2U; @@ -361,6 +365,8 @@ void native_document::update_style_animations(dom_node& node) } runtime.filter_valid = valid; if (configured.opacity_keyframes.size() < 2U + && configured.translation_keyframes.size() < 2U + && configured.scale_keyframes.size() < 2U && configured.rotation_keyframes.size() < 2U && !valid) { runtime.active = false; } @@ -1084,14 +1090,24 @@ bool native_document::advance_animations() noexcept const auto previous_opacity_override = animation.keyframe_opacity_override; + const auto previous_translation_override = + animation.keyframe_translation_override; + const auto previous_scale_override = + animation.keyframe_scale_override; const auto previous_rotation_override = animation.keyframe_rotation_override; const auto previous_filter_override = animation.keyframe_filter_override; animation.keyframe_opacity_override = false; + animation.keyframe_translation_override = false; + animation.keyframe_scale_override = false; animation.keyframe_rotation_override = false; animation.keyframe_filter_override = false; auto winning_opacity = node.style.opacity; + auto winning_translation_x = node.style.transform_translate_x; + auto winning_translation_y = node.style.transform_translate_y; + auto winning_scale_x = node.style.transform_scale_x; + auto winning_scale_y = node.style.transform_scale_y; auto winning_rotation = node.style.transform_rotate_degrees; const std::vector* winning_filter = nullptr; const std::vector* filter_underlying = nullptr; @@ -1181,6 +1197,60 @@ bool native_document::advance_animations() noexcept winning_opacity = runtime.painted_opacity; animation.keyframe_opacity_override = true; } + if (contributes && configured.translation_keyframes.size() >= 2U) { + const auto& stops = configured.translation_keyframes; + auto right = std::lower_bound( + stops.begin(), stops.end(), progress, + [](const node_style::translation_keyframe& stop, float value) { + return stop.offset < value; + }); + if (right == stops.begin()) { + runtime.painted_translation_x = right->x; + runtime.painted_translation_y = right->y; + } else if (right == stops.end()) { + runtime.painted_translation_x = stops.back().x; + runtime.painted_translation_y = stops.back().y; + } else { + const auto& from = *(right - 1); + const auto span = std::max(0.0001F, right->offset - from.offset); + const auto local = std::clamp( + (progress - from.offset) / span, 0.0F, 1.0F); + const auto eased = eased_segment(local); + runtime.painted_translation_x = interpolate_length( + from.x, right->x, eased); + runtime.painted_translation_y = interpolate_length( + from.y, right->y, eased); + } + winning_translation_x = runtime.painted_translation_x; + winning_translation_y = runtime.painted_translation_y; + animation.keyframe_translation_override = true; + } + if (contributes && configured.scale_keyframes.size() >= 2U) { + const auto& stops = configured.scale_keyframes; + auto right = std::lower_bound( + stops.begin(), stops.end(), progress, + [](const node_style::scale_keyframe& stop, float value) { + return stop.offset < value; + }); + if (right == stops.begin()) { + runtime.painted_scale_x = right->x; + runtime.painted_scale_y = right->y; + } else if (right == stops.end()) { + runtime.painted_scale_x = stops.back().x; + runtime.painted_scale_y = stops.back().y; + } else { + const auto& from = *(right - 1); + const auto span = std::max(0.0001F, right->offset - from.offset); + const auto local = std::clamp( + (progress - from.offset) / span, 0.0F, 1.0F); + const auto eased = eased_segment(local); + runtime.painted_scale_x = from.x + (right->x - from.x) * eased; + runtime.painted_scale_y = from.y + (right->y - from.y) * eased; + } + winning_scale_x = runtime.painted_scale_x; + winning_scale_y = runtime.painted_scale_y; + animation.keyframe_scale_override = true; + } if (contributes && configured.rotation_keyframes.size() >= 2U) { const auto& stops = configured.rotation_keyframes; auto right = std::lower_bound( @@ -1261,6 +1331,29 @@ bool native_document::advance_animations() noexcept } else if (previous_opacity_override) { animation.painted_opacity = node.style.opacity; } + const auto previous_translation_x = animation.painted_transform_translate_x; + const auto previous_translation_y = animation.painted_transform_translate_y; + if (animation.keyframe_translation_override) { + animation.painted_transform_translate_x = winning_translation_x; + animation.painted_transform_translate_y = winning_translation_y; + } else if (previous_translation_override) { + animation.painted_transform_translate_x = node.style.transform_translate_x; + animation.painted_transform_translate_y = node.style.transform_translate_y; + } + if (animation.keyframe_translation_override || previous_translation_override) { + layout_changed = layout_changed + || !length_equal( + previous_translation_x, animation.painted_transform_translate_x) + || !length_equal( + previous_translation_y, animation.painted_transform_translate_y); + } + if (animation.keyframe_scale_override) { + animation.painted_transform_scale_x = winning_scale_x; + animation.painted_transform_scale_y = winning_scale_y; + } else if (previous_scale_override) { + animation.painted_transform_scale_x = node.style.transform_scale_x; + animation.painted_transform_scale_y = node.style.transform_scale_y; + } if (animation.keyframe_rotation_override) { animation.painted_transform_rotate_degrees = winning_rotation; } else if (previous_rotation_override) { diff --git a/experiments/WebScene.NativeEngine.Probe/native/webscene_native_dom_metrics.inc b/experiments/WebScene.NativeEngine.Probe/native/webscene_native_dom_metrics.inc index 5e318337..41b4a3c4 100644 --- a/experiments/WebScene.NativeEngine.Probe/native/webscene_native_dom_metrics.inc +++ b/experiments/WebScene.NativeEngine.Probe/native/webscene_native_dom_metrics.inc @@ -223,6 +223,10 @@ native_document::allocation_metrics native_document::read_allocation_metrics() c string_bytes(track.name) + string_bytes(track.signature) + track.opacity_keyframes.capacity() * sizeof(node_style::opacity_keyframe) + + track.translation_keyframes.capacity() + * sizeof(node_style::translation_keyframe) + + track.scale_keyframes.capacity() + * sizeof(node_style::scale_keyframe) + track.rotation_keyframes.capacity() * sizeof(node_style::rotation_keyframe) + track.filter_keyframes.capacity() diff --git a/experiments/WebScene.NativeEngine.Probe/native/webscene_v8_runtime.cpp b/experiments/WebScene.NativeEngine.Probe/native/webscene_v8_runtime.cpp index 93c7f2f3..c21903c3 100644 --- a/experiments/WebScene.NativeEngine.Probe/native/webscene_v8_runtime.cpp +++ b/experiments/WebScene.NativeEngine.Probe/native/webscene_v8_runtime.cpp @@ -8898,6 +8898,10 @@ v8_dom_runtime::memory_metrics v8_dom_runtime::read_memory_metrics() const noexc + sizeof(decltype(impl_->opacity_keyframes)::value_type) + keyframes.opacity_stops.capacity() * sizeof(node_style::opacity_keyframe) + + keyframes.translation_stops.capacity() + * sizeof(node_style::translation_keyframe) + + keyframes.scale_stops.capacity() + * sizeof(node_style::scale_keyframe) + keyframes.rotation_stops.capacity() * sizeof(node_style::rotation_keyframe) + keyframes.filter_stops.capacity() @@ -8913,6 +8917,10 @@ v8_dom_runtime::memory_metrics v8_dom_runtime::read_memory_metrics() const noexc + sizeof(decltype(cascade.opacity_keyframes)::value_type) + keyframes.opacity_stops.capacity() * sizeof(node_style::opacity_keyframe) + + keyframes.translation_stops.capacity() + * sizeof(node_style::translation_keyframe) + + keyframes.scale_stops.capacity() + * sizeof(node_style::scale_keyframe) + keyframes.rotation_stops.capacity() * sizeof(node_style::rotation_keyframe) + keyframes.filter_stops.capacity() diff --git a/experiments/WebScene.NativeEngine.Probe/native/webscene_v8_runtime_css_cascade.inc b/experiments/WebScene.NativeEngine.Probe/native/webscene_v8_runtime_css_cascade.inc index b9ae0126..bf3d892c 100644 --- a/experiments/WebScene.NativeEngine.Probe/native/webscene_v8_runtime_css_cascade.inc +++ b/experiments/WebScene.NativeEngine.Probe/native/webscene_v8_runtime_css_cascade.inc @@ -150,6 +150,9 @@ for (const auto& track : node.style.animations().keyframe_animations) { if (track.opacity_keyframes.size() >= 2U) record_composition("css-opacity-keyframe-animation",node.id); + if (track.translation_keyframes.size() >= 2U + || track.scale_keyframes.size() >= 2U) + record_composition("css-transform-keyframe-animation",node.id); if (track.rotation_keyframes.size() >= 2U) record_composition("css-rotation-keyframe-animation",node.id); if (track.filter_keyframes.size() >= 2U) diff --git a/experiments/WebScene.NativeEngine.Probe/native/webscene_v8_runtime_css_parsing.inc b/experiments/WebScene.NativeEngine.Probe/native/webscene_v8_runtime_css_parsing.inc index 6efc9f9a..0a1ced4d 100644 --- a/experiments/WebScene.NativeEngine.Probe/native/webscene_v8_runtime_css_parsing.inc +++ b/experiments/WebScene.NativeEngine.Probe/native/webscene_v8_runtime_css_parsing.inc @@ -1088,92 +1088,11 @@ std::string_view(css).substr(cursor, open - cursor)); const auto declarations = parse_css_declarations( std::string_view(css).substr(open + 1U, close - open - 1U)); - const auto opacity = std::find_if( - declarations.begin(), declarations.end(), [](const auto& declaration) { - return declaration.name == "opacity"; - }); - const auto transform = std::find_if( - declarations.begin(), declarations.end(), [](const auto& declaration) { - return declaration.name == "transform"; - }); - const auto filter = std::find_if( - declarations.begin(), declarations.end(), [](const auto& declaration) { - return declaration.name == "filter"; - }); - const auto rotation_degrees = [&]() -> std::optional { - if (transform == declarations.end()) return std::nullopt; - auto value = lower_html_name(trim_css(transform->value)); - const auto rotate = value.find("rotate("); - if (rotate == std::string::npos) return std::nullopt; - const auto close = value.find(')', rotate + 7U); - if (close == std::string::npos) return std::nullopt; - auto angle = trim_css(value.substr(rotate + 7U, close - rotate - 7U)); - auto multiplier = 1.0F; - if (angle.ends_with("turn")) { - angle.resize(angle.size() - 4U); - multiplier = 360.0F; - } else if (angle.ends_with("deg")) { - angle.resize(angle.size() - 3U); - } else if (angle.ends_with("rad")) { - angle.resize(angle.size() - 3U); - multiplier = 57.29577951308232F; - } else return std::nullopt; - return std::strtof(angle.c_str(), nullptr) * multiplier; - }(); - for (auto component : split_css_component_list(selector, ',')) { - component = lower_html_name(trim_css(std::move(component))); - float offset = -1; - if (component == "from") offset = 0; - else if (component == "to") offset = 1; - else if (component.ends_with('%')) { - component.pop_back(); - offset = std::strtof(component.c_str(), nullptr) / 100.0F; - } - if (offset < 0 || offset > 1) continue; - if (opacity != declarations.end()) { - definition.opacity_stops.push_back({ - offset, - std::clamp(std::strtof(opacity->value.c_str(), nullptr), 0.0F, 1.0F)}); - } - if (rotation_degrees.has_value()) { - definition.rotation_stops.push_back({offset, *rotation_degrees}); - } - if (filter != declarations.end()) { - definition.filter_stops.push_back({offset, filter->value}); - } - } + css::append_keyframe(definition, selector, declarations); cursor = close + 1U; } - const auto normalize = [](auto& stops) { - std::stable_sort( - stops.begin(), stops.end(), - [](const auto& left, const auto& right) { return left.offset < right.offset; }); - using stop_type = typename std::decay_t::value_type; - std::vector unique; - for (const auto& stop : stops) { - if (!unique.empty() - && std::abs(unique.back().offset - stop.offset) < 0.0001F) { - unique.back() = stop; - } else { - unique.push_back(stop); - } - } - stops = std::move(unique); - }; - normalize(definition.opacity_stops); - normalize(definition.rotation_stops); - normalize(definition.filter_stops); - if (definition.rotation_stops.size() == 1U - && definition.rotation_stops.front().offset > 0) { - definition.rotation_stops.insert( - definition.rotation_stops.begin(), {0, 0}); - } - if (definition.opacity_stops.size() >= 2U - || definition.rotation_stops.size() >= 2U - || definition.filter_stops.size() >= 2U) { - opacity_keyframes[lower_html_name(trim_css(std::move(name)))] = - std::move(definition); - } + css::finish_keyframes( + opacity_keyframes, trim_css(std::move(name)), std::move(definition)); } void append_parsed_css_style_rule( diff --git a/experiments/WebScene.NativeEngine.Probe/native/webscene_v8_runtime_lifecycle.inc b/experiments/WebScene.NativeEngine.Probe/native/webscene_v8_runtime_lifecycle.inc index 9370d6fb..f8d8f680 100644 --- a/experiments/WebScene.NativeEngine.Probe/native/webscene_v8_runtime_lifecycle.inc +++ b/experiments/WebScene.NativeEngine.Probe/native/webscene_v8_runtime_lifecycle.inc @@ -1192,6 +1192,8 @@ for (auto& [name, keyframes] : opacity_keyframes) { static_cast(name); keyframes.opacity_stops.shrink_to_fit(); + keyframes.translation_stops.shrink_to_fit(); + keyframes.scale_stops.shrink_to_fit(); keyframes.rotation_stops.shrink_to_fit(); keyframes.filter_stops.shrink_to_fit(); for (auto& stop : keyframes.filter_stops) { @@ -1222,6 +1224,8 @@ for (auto& [name, keyframes] : cascade.opacity_keyframes) { static_cast(name); keyframes.opacity_stops.shrink_to_fit(); + keyframes.translation_stops.shrink_to_fit(); + keyframes.scale_stops.shrink_to_fit(); keyframes.rotation_stops.shrink_to_fit(); keyframes.filter_stops.shrink_to_fit(); for (auto& stop : keyframes.filter_stops) { 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 8d413feb..85d96b23 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 @@ -1196,6 +1196,115 @@ void test_zero_time_animation_tracks_settle_without_frame_demand( engine, false, "detached zero-time animations retained frame demand"); } +void test_transform_keyframes_compose_retained_geometry_and_paint( + webscene_engine* engine) +{ + animation_frame_and_wait(engine, 12500.0, 7140U); + execute_and_wait(engine, R"JS( + (() => { + document.body.innerHTML = ` + +
+
`; + void document.body.offsetHeight; + })() + )JS", "transform-keyframes-setup.js"); + + animation_frame_and_wait(engine, 13000.0, 7141U); + const auto midpoint = evaluate(engine, R"JS( + (() => { + const matrix = id => getComputedStyle(document.getElementById(id)).transform + .slice(7, -1).split(',').map(Number); + const close = (left, right) => Math.abs(left - right) < .001; + const active = matrix('active'); + const paused = matrix('paused'); + const replace = matrix('replace'); + const instant = matrix('instant'); + const rect = document.getElementById('active').getBoundingClientRect(); + return active.length === 6 && close(active[0], 0) + && close(active[1], 1.5) && close(active[2], -.75) + && close(active[3], 0) && close(active[4], 20) && close(active[5], 10) + && paused.every((value, index) => close(value, active[index])) + && close(replace[0], 3) && close(replace[1], 0) + && close(replace[2], 0) && close(replace[3], 1) + && close(replace[4], 8) && close(replace[5], 0) + && close(instant[0], 1) && close(instant[3], 1) + && close(instant[4], 0) && close(instant[5], 0) + && close(rect.width, 30) && close(rect.height, 60); + })() + )JS", "transform-keyframes-midpoint.js"); + require(midpoint == "true", + "translate/scale keyframes missed retained tuple composition or geometry"); + + webscene_engine_request_scene_checkpoint(engine); + auto retained_scale = false; + auto retained_rotation = false; + for (auto attempt = 0; attempt < 100 && (!retained_scale || !retained_rotation); + ++attempt) { + const auto* scene = webscene_engine_acquire_latest_scene(engine); + if (scene != nullptr) { + if (scene->header.consumed_input_sequence >= 7141U) { + for (uint32_t index = 0U; index < scene->header.command_count; ++index) { + const auto& command = scene->commands[index]; + retained_scale = retained_scale || (command.kind == 15U + && std::abs(command.width - 1.5F) < 0.001F + && std::abs(command.height - .75F) < 0.001F); + retained_rotation = retained_rotation || (command.kind == 19U + && std::abs(command.stroke_width - 90.0F) < 0.001F); + } + } + webscene_scene_acknowledge(scene); + webscene_scene_release(scene); + } + if (!retained_scale || !retained_rotation) { + std::this_thread::sleep_for(std::chrono::milliseconds(2)); + } + } + require(retained_scale && retained_rotation, + "translate/scale/rotation midpoint did not reach retained scene paint"); + + animation_frame_and_wait(engine, 13500.0, 7142U); + wait_for_animation_frame_demand( + engine, false, "filled transform keyframes retained host-frame demand"); + execute_and_wait(engine, R"JS( + (() => { + const active = document.getElementById('active'); + active.style.animationName = 'none'; + document.getElementById('paused').remove(); + document.getElementById('replace').style.animation = 'none'; + })() + )JS", "transform-keyframes-cleanup.js"); + animation_frame_and_wait(engine, 13500.0, 7143U); + const auto cleaned = evaluate(engine, R"JS( + (() => getComputedStyle(document.getElementById('active')).transform === 'none' + && getComputedStyle(document.getElementById('replace')).transform === 'none')() + )JS", "transform-keyframes-cleanup-result.js"); + require(cleaned == "true", + "transform animation identity mutation retained a stale tuple"); + execute_and_wait(engine, + "document.body.innerHTML = '
transform animations detached
'", + "transform-keyframes-detach.js"); + wait_for_animation_frame_demand( + engine, false, "detached transform keyframes retained 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 6479c542..2d91ad9a 100644 --- a/experiments/WebScene.NativeEngine.Probe/tests/native_v8_runtime_tests.cpp +++ b/experiments/WebScene.NativeEngine.Probe/tests/native_v8_runtime_tests.cpp @@ -1142,6 +1142,7 @@ int main() test_animation_play_state_holds_and_resumes_host_time(focused_engine); test_multiple_animation_lists_coordinate_bounded_tracks(focused_engine); test_zero_time_animation_tracks_settle_without_frame_demand(focused_engine); + test_transform_keyframes_compose_retained_geometry_and_paint(focused_engine); webscene_engine_destroy(focused_engine); return 0; } @@ -1641,6 +1642,7 @@ int main() test_animation_play_state_holds_and_resumes_host_time(engine); test_multiple_animation_lists_coordinate_bounded_tracks(engine); test_zero_time_animation_tracks_settle_without_frame_demand(engine); + test_transform_keyframes_compose_retained_geometry_and_paint(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/NativeWeb/css_service.cpp b/tests/NativeWeb/css_service.cpp index 8c3a41fe..8750cd7c 100644 --- a/tests/NativeWeb/css_service.cpp +++ b/tests/NativeWeb/css_service.cpp @@ -675,7 +675,23 @@ int main(int argc,char** argv) { webscene_native::css::finish_keyframes(parsed_keyframes,"spin",std::move(rotation_definition)); if(parsed_keyframes["spin"].rotation_stops.size()!=2 || parsed_keyframes["spin"].rotation_stops[0].degrees!=0 || - parsed_keyframes["spin"].rotation_stops[1].degrees!=180) return 70; + parsed_keyframes["spin"].rotation_stops[1].degrees!=180 || + parsed_keyframes["spin"].translation_stops.size()!=2 || + parsed_keyframes["spin"].scale_stops.size()!=2) return 70; + webscene_native::css::css_opacity_keyframes transform_definition; + webscene_native::css::append_keyframe(transform_definition,"from",{{"transform", + "translate(0, 25%) scale(1, 2) rotate(0)",false}}); + webscene_native::css::append_keyframe(transform_definition,"to",{{"transform", + "translate(40px, 50%) scale(2, .5) rotate(1turn)",false}}); + webscene_native::css::finish_keyframes(parsed_keyframes,"motion",std::move(transform_definition)); + const auto& motion=parsed_keyframes["motion"]; + if(motion.translation_stops.size()!=2 || motion.scale_stops.size()!=2 || + motion.rotation_stops.size()!=2 || + motion.translation_stops[1].x.unit!=webscene_native::length_unit::pixels || + motion.translation_stops[1].x.value!=40 || + motion.translation_stops[1].y.unit!=webscene_native::length_unit::percent || + motion.translation_stops[1].y.value!=50 || motion.scale_stops[1].x!=2 || + motion.scale_stops[1].y!=.5f || motion.rotation_stops[1].degrees!=360) return 70; webscene_native::css::rule_payload_cache payload_cache; std::mutex payload_mutex; const auto payload_for=[&](const std::string& selector,const std::string& color) { diff --git a/tests/WebPlatformSubset/capabilities.json b/tests/WebPlatformSubset/capabilities.json index 6557d358..b291d7fb 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", "single-animation none, forwards, backwards, and both fill", "single-animation running and paused play state", "bounded comma-separated animation lists", "zero-duration and zero-iteration-count animation phases"], + "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, translate, scale, 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", "single-animation running and paused play state", "bounded comma-separated animation lists", "zero-duration and zero-iteration-count animation phases"], "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-fill-mode-boundaries.html", "contracts/css-animation-direction.html", "contracts/css-animation-play-state.html", "contracts/css-animation-multiple-lists.html", "contracts/css-animation-zero-time.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", "test_animation_play_state_holds_and_resumes_host_time", "test_multiple_animation_lists_coordinate_bounded_tracks", "test_zero_time_animation_tracks_settle_without_frame_demand", "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 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. Running and paused play state now hold and resume the same bounded host-clock timeline, including delay, direction, fill, supported-property paint, exactly-once completion, and zero paused frame demand. Up to eight comma-separated animations coordinate repeated longhand lists with independent clocks, fill, pause, ordered completion, and last-contributing replace composition for the supported properties. Zero duration or zero iteration count now resolves a zero active duration with directed before/after fill, bounded positive or negative delay, ordered exactly-once completion, same-update mutation settlement, and no sustained frame demand. 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, animation start/iteration/cancel event expansion, additive animation composition, more than eight live tracks per element, 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-animation-play-state.html", "contracts/css-animation-multiple-lists.html", "contracts/css-animation-zero-time.html", "contracts/css-animation-transform-components.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", "test_animation_play_state_holds_and_resumes_host_time", "test_multiple_animation_lists_coordinate_bounded_tracks", "test_zero_time_animation_tracks_settle_without_frame_demand", "test_transform_keyframes_compose_retained_geometry_and_paint", "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 keyframe slice maps normal, reverse, alternate, and alternate-reverse through negative delays and finite, fractional, infinite, or zero iteration counts before opacity, bounded two-dimensional translate/scale/rotation, and bounded-filter sampling. Transform keyframes accept finite px/percentage translation, numeric scale, and the existing rotation grammar; compile each declaration into a replace-composed retained tuple, and publish its computed matrix, geometry, and scene paint without frame-time parsing. For positive-duration, nonzero-count animations, none, forwards, backwards, and both 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. Running and paused play state now hold and resume the same bounded host-clock timeline, including delay, direction, fill, supported-property paint, exactly-once completion, and zero paused frame demand. Up to eight comma-separated animations coordinate repeated longhand lists with independent clocks, fill, pause, ordered completion, and last-contributing replace composition for the supported properties. Zero duration or zero iteration count resolves a zero active duration with directed before/after fill, bounded positive or negative delay, ordered exactly-once completion, same-update mutation settlement, and no sustained frame demand. 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. Arbitrary transform-list matrix multiplication, 3D and additive animation composition, other animated properties, animation start/iteration/cancel event expansion, more than eight live tracks per element, and the complete Web Animations API are not claimed." }, { "family": "clipping-and-rounded-borders", diff --git a/tests/WebPlatformSubset/contracts/css-animation-transform-components-ref.html b/tests/WebPlatformSubset/contracts/css-animation-transform-components-ref.html new file mode 100644 index 00000000..11754dca --- /dev/null +++ b/tests/WebPlatformSubset/contracts/css-animation-transform-components-ref.html @@ -0,0 +1,19 @@ + + +Translate scale and rotation keyframe midpoint reference + +
+
diff --git a/tests/WebPlatformSubset/contracts/css-animation-transform-components.html b/tests/WebPlatformSubset/contracts/css-animation-transform-components.html new file mode 100644 index 00000000..8dfefcae --- /dev/null +++ b/tests/WebPlatformSubset/contracts/css-animation-transform-components.html @@ -0,0 +1,34 @@ + + +Translate scale and rotation keyframes retain their midpoint pixels + + +
+
+ diff --git a/tests/WebPlatformSubset/webscene-component-profile.json b/tests/WebPlatformSubset/webscene-component-profile.json index 65694ee5..d8cbdd7a 100644 --- a/tests/WebPlatformSubset/webscene-component-profile.json +++ b/tests/WebPlatformSubset/webscene-component-profile.json @@ -1909,6 +1909,14 @@ "evidence": ["css-animation-zero-time-674-242"], "reason": "WPT-aligned bounded reduction for zero active duration, directed opacity/rotation/filter fill, delayed and paused phases, ordered completion, CSSOM mutation, cleanup, and settled scheduling." }, + { + "path": "contracts/css-animation-transform-components.html", + "type": "reftest", + "reference": "contracts/css-animation-transform-components-ref.html", + "capabilities": ["translate-keyframes", "scale-keyframes", "length-and-percentage-translation", "transform-replace-composition", "retained-transform-geometry", "transform-midpoint-pixels"], + "evidence": ["css-animation-transform-components-675-242"], + "reason": "WPT-aligned bounded pixel and geometry reduction for a stable paused midpoint composed from retained translate, scale, and rotation keyframe components." + }, { "path": "contracts/css-filter-keyframes-temporal.html", "type": "contract", diff --git a/tests/WebPlatformSubset/webscene-css-animation-transform-components-profile.json b/tests/WebPlatformSubset/webscene-css-animation-transform-components-profile.json new file mode 100644 index 00000000..35f565c7 --- /dev/null +++ b/tests/WebPlatformSubset/webscene-css-animation-transform-components-profile.json @@ -0,0 +1,29 @@ +{ + "profile": "webscene-css-animation-transform-components-1", + "wptRevision": "2c705104a295c48053eeddf7fe0170d790a4e853", + "runtime": "v8", + "viewport": { + "width": 800, + "height": 600, + "deviceScaleFactor": 1 + }, + "required": [ + { + "path": "contracts/css-animation-transform-components.html", + "type": "reftest", + "reference": "contracts/css-animation-transform-components-ref.html", + "capabilities": [ + "translate-keyframes", + "scale-keyframes", + "length-and-percentage-translation", + "transform-replace-composition", + "retained-transform-geometry", + "transform-midpoint-pixels" + ], + "evidence": ["css-animation-transform-components-675-242"], + "reason": "WPT-aligned bounded pixel and geometry reduction for a stable paused midpoint composed from retained translate, scale, and rotation keyframe components." + } + ], + "harnessBlocked": [], + "excluded": [] +}