aboutsummaryrefslogtreecommitdiffstats
path: root/components/script/animations.rs
Commit message (Collapse)AuthorAgeFilesLines
* Move `ScriptToConstellationMsg` to `constellation_traits` (#36364)Martin Robinson2025-04-051-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | This is the last big change necessary to create the `constellation_traits` crate. This moves the data structure for messages that originate from the `ScriptThread` and are sent to the `Contellation` to `constellation_traits`, effectively splitting `script_traits` in half. Before, `script_traits` was responsible for exposing the API of both the `ScriptThread` and the `Constellation` to the rest of Servo. - Data structures that are used by `ScriptToConstellationMsg` are moved to `constellation_traits`. The dependency graph looks a bit like this: `script_layout_interface` depends on `script_traits` depends on `constellation_traits` depends on `embedder_traits`. - Data structures that are used in the embedding layer (`UntrustedNodeAddress`, `CompositorHitTestResult`, `TouchEventResult` and `AnimationState`) are moved to embedder_traits, to avoid a dependency cycle between `webrender_traits` and `constellation_traits`. - Types dealing with MessagePorts and serialization are moved to `constellation_traits::message_port`. Testing: This is covered by existing tests as it just moves types around. Signed-off-by: Martin Robinson <mrobinson@igalia.com> Signed-off-by: Martin Robinson <mrobinson@igalia.com>
* constellation: Rename messages sent to the `Constellation` (#36341)Martin Robinson2025-04-041-2/+4
| | | | | | | | | | | | | | | | | | | | Messages that are sent to the `Constellation` have pretty ambiguous names. This change does two renames: - `ConstellationMsg` → `EmbedderToConstellationMessage` - `ScriptMsg` → `ScriptToConstellationMessage` This naming reflects that the `Constellation` stands in between the embedding layer and the script layer and can receive messages from both. Soon both of these message types will live in `constellation_traits`, reflecting the idea that the `_traits` variant for a crate is responsible for exposing the API for that crate. Testing: No new tests are necessary here as this just renames two enums. Signed-off-by: Martin Robinson <mrobinson@igalia.com> Signed-off-by: Martin Robinson <mrobinson@igalia.com>
* Create a `constellation_traits` crate (#36088)Martin Robinson2025-03-221-1/+2
| | | | | | | | | | | | | | This change creates a `constellation_traits` crate. Previously messages to the `Constellation` were in the `compositing_traits` crate, which came about organically. This change moves these to a new crate which also contains data types that are used in both compositing/libservo and script (ie types that cross the process boundary). The idea is similar to `embedding_traits`, but this is meant for types not exposed to the API. This change allows deduplicating `UntrustedNodeAddress`, which previously had two versions to avoid circular dependencies. Signed-off-by: Martin Robinson <mrobinson@igalia.com>
* Update rustfmt to the 2024 style edition (#35764)Simon Wülker2025-03-031-1/+1
| | | | | | | | | | | | | * Use 2024 style edition Signed-off-by: Simon Wülker <simon.wuelker@arcor.de> * Reformat all code Signed-off-by: Simon Wülker <simon.wuelker@arcor.de> --------- Signed-off-by: Simon Wülker <simon.wuelker@arcor.de>
* Implement Event propagation across shadow roots (#34884)Simon Wülker2025-01-221-0/+1
| | | | | | | | | | | | | | | | | * Implement Event.composed flag Signed-off-by: Simon Wülker <simon.wuelker@arcor.de> * Allow composed events to pass shadow boundaries Signed-off-by: Simon Wülker <simon.wuelker@arcor.de> * Update WPT expectations Signed-off-by: Simon Wülker <simon.wuelker@arcor.de> --------- Signed-off-by: Simon Wülker <simon.wuelker@arcor.de>
* script: Feature-gate all crown support. (#35055)Josh Matthews2025-01-181-1/+1
| | | | | | | | | | | | | * script: Feature-gate all crown support. Signed-off-by: Josh Matthews <josh@joshmatthews.net> * script: Use cfg(crown) instead of a cargo feature. Signed-off-by: Josh Matthews <josh@joshmatthews.net> --------- Signed-off-by: Josh Matthews <josh@joshmatthews.net>
* script: Limit public exports. (#34915)Josh Matthews2025-01-101-10/+10
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * script: Restrict reexport visibility of DOM types. Signed-off-by: Josh Matthews <josh@joshmatthews.net> * script: Mass pub->pub(crate) conversion. Signed-off-by: Josh Matthews <josh@joshmatthews.net> * script: Hide existing dead code warnings. Signed-off-by: Josh Matthews <josh@joshmatthews.net> * Formatting. Signed-off-by: Josh Matthews <josh@joshmatthews.net> * Fix clippy warnings. Signed-off-by: Josh Matthews <josh@joshmatthews.net> * Formatting. Signed-off-by: Josh Matthews <josh@joshmatthews.net> * Fix unit tests. Signed-off-by: Josh Matthews <josh@joshmatthews.net> * Fix clippy. Signed-off-by: Josh Matthews <josh@joshmatthews.net> * More formatting. Signed-off-by: Josh Matthews <josh@joshmatthews.net> --------- Signed-off-by: Josh Matthews <josh@joshmatthews.net>
* script: Expose node helpers as `NodeTraits` and give more descriptive names ↵Martin Robinson2025-01-031-2/+2
| | | | | | | | | | | | | (#34832) This puts a few commonly used `Node` helpers into a trait (`NodeTraits`) and gives them more descriptive names and documentation. The renames: - `document_from_node` -> `NodeTraits::owner_document` - `window_from_node` -> `NodeTraits::owner_window` - `stylesheets_owner_from_node<T:` -> `NodeTraits::stylesheet_list_owner` - `containing_shadow_root` -> `NodeTraits::containing_shadow_root` Signed-off-by: Martin Robinson <mrobinson@igalia.com>
* script: Update animations once per-Document during `update_the_rendering()` ↵Martin Robinson2024-12-051-0/+17
| | | | | | | | | | | | | | | | | | (#34489) Before, `update_the_rendering()` would update all animations for all Documents once per-Document. Apart from being generally wrong, the specification says this should be done once per-Document. This theoretically means that `update_the_rendering()` is just doing less work every time it runs. In addition: - Don't redirty animations nodes when running rAF callbacks. They should already be dirty when animations are updated. - Perform a microtask checkpoint while updating animations as dictacted by the specification. - Update comments to reflect the specification text. Signed-off-by: Martin Robinson <mrobinson@igalia.com>
* cangc fixes in several files + event.rs + rtcpeerconnection.rs (#34002)chickenleaf2024-10-251-2/+2
| | | Signed-off-by: L Ashwin B <lashwinib@gmail.com>
* CanGc fixes in components/script/dom (#33843)tanishka2024-10-151-1/+1
| | | Signed-off-by: taniishkaaa <tanishkasingh2004@gmail.com>
* CanGc fixes in focusevent.rs oscillartornode.rs response.rs ↵chickenleaf2024-10-131-2/+3
| | | | | resizeobserversize.rs animationevent.rs (#33827) Signed-off-by: L Ashwin B <lashwinib@gmail.com>
* remove usage of legacy numeric operations in script (#33095)Simon Wülker2024-08-161-1/+1
| | | | | | | These operations are deprecated and might be removed in a future rust version. Clippy is also complaining about them. Signed-off-by: Simon Wülker <simon.wuelker@arcor.de>
* Move non-gfx things out of `gfx_traits` and create a `base` crate (#32296)Martin Robinson2024-05-171-1/+1
| | | | | | | | | | | | | | | | | | | | | | | For a long time, `gfx_traits` has held a lot of things unrelated to graphics and also unrelated to the `gfx` crate (which is mostly about fonts). This is a cleanup which does a few things: 1. Move non `gfx` crate things out of `gfx_traits`. This is important in order to prevent dependency cycles with a different integration between layout, script, and fonts. 2. Rename the `msg` crate to `base`. It didn't really contain anything to do with messages and instead mostly holds ids, which are used across many different crates in Servo. This new crate will hold the *rare* data types that are widely used. Details: - All BackgroundHangMonitor-related things from base to a new `background_hang_monitor_api` crate. - Moved `TraversalDirection` to `script_traits` - Moved `Epoch`-related things from `gfx_traits` to `base`. - Moved `PrintTree` to base. This should be widely useful in Servo. - Moved `WebrenderApi` from `base` to `webrender_traits` and renamed it to `WebRenderFontApi`.
* clippy: Fix mem_replace_with_default warnings (#31921)Oluwatobi Sofela2024-03-281-1/+1
|
* clippy: Fix option_map_unit_fn warnings (#31906)Oluwatobi Sofela2024-03-271-2/+2
|
* clippy: Fix clone-on-copy warnings (#31877)Oluwatobi Sofela2024-03-261-2/+2
|
* Replace script_plugins with a clippy like rustc driver (named crown) (#30508)Samson2023-12-011-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * Remove script_plugins * Use crown instead of script_plugins * crown_is_not_used * Use crown in command base * bootstrap crown * tidy happy * disable sccache * Bring crown in tree * Install crown from tree * fix windows ci * fix warning * fix mac libscript_plugins.dylib is not available anymore * Update components/script/lib.rs Co-authored-by: Martin Robinson <mrobinson@igalia.com> * Update for nightly-2023-03-18 Mostly just based off https://github.com/servo/servo/pull/30630 * Always install crown it's slow only when there is new version * Run crown test with `mach test-unit` * Small fixups; better trace_in_no_trace tests * Better doc * crown in config.toml * Fix tidy for real * no sccache on rustc_wrapper * document rustc overrides * fixup of compiletest * Make a few minor comment adjustments * Fix a typo in python/servo/platform/base.py Co-authored-by: Samson <16504129+sagudev@users.noreply.github.com> * Proper test types * Ignore tidy on crown/tests --------- Co-authored-by: Martin Robinson <mrobinson@igalia.com>
* Strict import formatting (grouping and granularity) (#30325)Samson2023-09-111-13/+15
| | | | | * strict imports formatting * Reformat all imports
* remove `extern crate` (#30311)Samson2023-09-081-0/+1
| | | | | | | | | | | * remove extern crate * Update components/script_plugins/lib.rs Co-authored-by: Martin Robinson <mrobinson@igalia.com> --------- Co-authored-by: Martin Robinson <mrobinson@igalia.com>
* No tracing of nop traceable fields (#29926)Samson2023-08-041-6/+14
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * Add `no_trace` option to JSTraceable derive * NoTrace wrapper * Port some types to no_trace schematics * Fixing my unsafe mistakes (not tracing traceables) * Add docs & safety guards for no_trace Safety guards (trait shenanigans) guarantees safety usage of `no_trace` * Port canvas_traits to no_trace * Port servo_media to no_trace * Port net_traits to no_trace * Port style to no_trace * Port webgpu to no_trace * Port script_traits to no_trace * Port canvas_traits, devtools_traits, embedder_traits, profile_traits to no_trace * unrooted_must_root lint in seperate file * Add trace_in_no_trace_lint as script_plugin * Composable types in must_not_have_traceable * Introduced HashMapTracedValues wrapper * `HashMap<NoTrace<K>,V>`->`HashMapTracedValues<K,V>` * Port rest of servo's types to no_trace * Port html5ever, euclid, mime and http to no_trace * Port remaining externals to no_trace * Port webxr and Arc<Mutex<_>> * Fix spelling in notrace doc
* Fix flakiness in animation testsMartin Robinson2023-05-021-4/+18
| | | | | | | | | | | | | | 1. When updating the animation timeline, ensure that nodes that are animating are marked dirty, if necessary, so any style queries will force an layout flush. 2. Disable the problematic transition test suites, as they are in Gecko. These suites often fail when Servo is so overloaded that it cannot deliver frames fast enough to get more than two samples during the animation lifecycle. Fixes #28334. Fixes #26435. Fixes #21486.
* fix(script): request animation ticks if `Animations::pending_events` is not ↵yvt2023-02-101-8/+24
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | empty Fixes the test case `/_mozilla/css/css-transition-cancel-event .html`, which was failing under a specific circumstance. The observed sequence of events during the failing test run looks like this: 1. Transitions start in `div1` and `div2`. 2. `div1` generates a `transitionend` event. 3. The `transitionend` event handler removes `div2` from DOM, cancelling its ongoing transition. 4. `div2` is supposed to generate a `transitioncancel` event in a timely manner, which it does not. The test fails as a result. What is going on here? Here's a possible explaination: 1. During one invocation of `ScriptThread::handle_msgs`... 2. In step 2, `ScriptThread::update_animations_send_events` -> `Document ::update_for_new_timeline_value` detects the completion of the transition, and in response, pends the `transitionend` event. 3. In step 3, `ScriptThread::update_animations_send_events` -> `Animations::send_pending_events` calls the `transitionend` handler. 4. The `transitionend` event handler removes `div2`, thereby cancelling its ongoing transition and triggering a reflow. 5. Reflow takes place. During this, `Animations::do_post_reflow_update` -> `Animations::handle_canceled_animations` pends the `transitioncancel` event (precursor to step 4). 6. Having discovering that there was no running animation, `Animations:: do_post_reflow_update` calls `self.update_running_animation_presence (_, false)`, which sends `AnimationState::NoAnimationsPresent`. 7. The invocation of `ScriptThread::handle_msgs` ends, and another starts. It blocks waiting for events. 8. Meanwhile, the compositor receives `AnimationState:: NoAnimationsPresent` and stops further generation of animation ticks. 9. With no events to wake it up, the script thread is stuck waiting despite having the pending `transitioncancel` event (step 4). The HTML specification [says][1] that "an event loop must continually run [...] as long as it exists" and does not say it can block if there is nothing to do. Blocking is merely optimization in a user agent implementation. Pending animation-related events must be processed every time a "rendering opportunity" arises unless the user agent has a reason to believe that it "would have no visible effect". Skipping the processing of animation-related events would have visible effect if such events are indeed present. The correct implementation in Servo, therefore, would be to request more animation ticks so that such events are processed in a subsequent tick. [1]: https://html.spec.whatwg.org/multipage/#event-loop-processing-model
* Remove unused arguments from methods.teymour-aldridge2021-02-051-4/+2
|
* Auto merge of #27032 - mrobinson:fractional-iteration, r=jdmbors-servo2020-06-241-4/+8
|\ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | animations: Finish support for fractional iteration counts This change also improves support for creating animations with negative delays, as that is necessary to test support for fractional iteration lengths. Fixes: #14858 <!-- Please describe your changes on the following line: --> --- <!-- Thank you for contributing to Servo! Please replace each `[ ]` by `[X]` when the step is complete, and replace `___` with appropriate data: --> - [x] `./mach build -d` does not report any errors - [x] `./mach test-tidy` does not report any errors - [x] These changes fix #14858 - [x] There are tests for these changes <!-- Also, please make sure that "Allow edits from maintainers" checkbox is checked, so that we can help you if you get stuck somewhere along the way.--> <!-- Pull requests that do not address these steps are welcome, but they will require additional verification as part of the review process. -->
| * animations: Finish support for fractional iteration countsMartin Robinson2020-06-241-4/+8
| | | | | | | | | | | | | | | | | | | | | | | | | | This change also improves support for creating animations with negative delays, as that is necessary to test support for fractional iteration lengths. This change also adjusts existing Servo animation tests which assumed that advancing to the exact moment of the end of the animation would be considered "before the end." With this change, this moment is "after the end." Fixes: #14858
* | Cancel animations for nodes which are removed from the DOMMartin Robinson2020-06-171-0/+21
|/ | | | This includes nodes which are being reparented.
* Add animation and transition support for pseudo-elementsMartin Robinson2020-06-161-8/+18
| | | | | | | | | | This change extends the DocumentAnimationSet to hold animations for pseudo-elements. Since pseudo-elements in Servo are not in the DOM like in Gecko, they need to be handled a bit carefully in stylo. When a pseudo-element has an animation, recascade the style. Finally, this change passes the pseudo-element string properly to animation events. Fixes: #10316
* Add DocumentAnimationSet and AnimationSetKeyMartin Robinson2020-06-151-26/+41
| | | | | | | This will be used in order to hold animations for pseudo elements in the DocumentAnimationSet. Also no longer store the OpaqueNode in the animation and transition data structures. This is already part of the DocumentAnimationSet key.
* Add support for remaining animation and transition eventsMartin Robinson2020-05-261-6/+91
| | | | Fixes #21564.
* Have Animations struct handle rooting nodesMartin Robinson2020-05-261-152/+252
| | | | | | | Instead of having `ScriptThread` handle rooting nodes, do this in `Animations`. This makes it easier to know when it is appropriate to root and unroot nodes instead of relying on a certain order of events. This also allows reducing quite a bit the amount of unsafe code.
* Improve ending of transitionsMartin Robinson2020-05-211-1/+2
| | | | | | | | | | | | | | | | | | | | For legacy reasons, transitions were marked as finished after updating the style. According to the spec, they should be marked as finished when animations are updated and before restyle. This change does that as well as preventing replacement of finished transitions. Having finished transitions survive a full restyle cycle and allowing the replacement of finished transition, could lead to issues were removed from the global list of animating transitions too soon: 1. A transitions finishes 2. Restyle 3. Transitions is marked as finished and events are queued 4. Restyle cancels finished transition and replaces it instead of clearing finished transition 5. Events are sent for the incorrectly canceled transition removing it completely from the list of running transitions due to the extra event.
* Implement animationiteration eventMartin Robinson2020-05-211-2/+29
| | | | | | This event is triggered when an animation iterates. This change also moves iteration out of style calculation to an "update animations" which is the next part of having animation event handling match the HTML spec.
* Remove AnimatedPropertyMartin Robinson2020-05-131-3/+3
| | | | | | | This removes an extra layer of abstraction and allows Servo to share more code with Gecko. In addition, we will need to handle raw `AnimationValue` structs soon in order to fully implement "faster reversing of interrupted transitions."
* Move most animation processing to scriptMartin Robinson2020-05-121-0/+293
This is preparation for sharing this code with layout_2020 and implementing selective off-the-main-thread animations. We still look for nodes not in the flow tree in the layout thread.