Commit graph

40 commits

Author SHA1 Message Date
Shannon Booth
f317debd98 LibWeb: Distinguish omitted and null Animation timeline arguments
When constructing an Animation a null should be distinguished
from nothing being passed at all. This is not achieved by
use of our custom ExplicitNull IDL extended attribute.

Instead use the argument count to determine if the argument is
missing, which is a much more common pattern in the codebase.
2026-04-13 23:30:54 +02:00
Shannon Booth
392e095836 LibWeb: Remove uneeded ExceptionOr for Animation constructor 2026-04-13 23:30:54 +02:00
Shannon Booth
bb0f244667 LibWeb: Remove ShadowRealm HTML integration 2026-04-05 13:57:58 +02:00
Luke Wilde
cfd795f907 LibWeb+IDLGenerators: Support nullable union types 2026-03-25 13:18:15 +00:00
Andreas Kling
706eb0018c LibGC+LibWeb: Mark two GC::Cell functions as MUST_UPCALL
Let's make sure that subclasses always call their base class when
overriding these virtuals:

- void finalize()
- void visit_edges(Visitor&)
2026-02-06 13:50:54 +01:00
Callum Law
fd7006956c LibWeb: Process animations with non-monotonic timelines after finish
With monotonically increasing timelines we know that an animation can
never leave the finished state due to timeline changes because the
timeline cannot re-enter the active interval. This is not the case with
non-monotonically increasing timelines (e.g. scroll based timelines)
where this is possible (e.g. by scrolling backwards)
2026-02-05 16:45:34 +01:00
Callum Law
626caa3af3 LibWeb: Implement auto alignment of animation start times
Nonfunctional change for now since we don't yet have any progress-based
timelines
2026-02-05 16:45:34 +01:00
Callum Law
6df2ebeee1 LibWeb: Update Animation::play_an_animation() to spec
These updates are part of level 2 of the Web Animations spec
2026-02-05 16:45:34 +01:00
Callum Law
ede84a1ddd LibWeb: Update Animation::set_timeline() to spec
This adds functionality introduced in Web Animations Level 2 around
switching between finite and non-finite (i.e. progress and time-based)
timelines

No functional change as we don't yet have any finite timelines
implemented
2026-02-05 16:45:34 +01:00
Callum Law
ebd8f2f3db LibWeb: Implement progress-based validate a CSSNumberish time
Non functional change for now as we are yet to implement any
progress-based timelines
2026-02-05 16:45:34 +01:00
Callum Law
226b1ee46b LibWeb: Support percentage units for Animations::TimeValue
Non functional change for now since we don't yet have any progress-based
timelines which support percentage based time values
2026-02-05 16:45:34 +01:00
Andreas Kling
ade167ed33 LibWeb: Always return task's ID after adding to a queue (or not)
Now that we don't always honor requests to add tasks to a queue, we
can't rely on "last added task" as the place to find the task's ID.
Fortunately we can just get it from the task itself.
2025-12-27 16:40:34 +01:00
Callum Law
781f961c07 LibWeb: Always use timeline time for animation pending task ready time
It is not guaranteed that an animation is ready to run a pending task
when it is scheduled just because it has a timeline, and even if it is,
the current time when scheduling will not necessarily still be correct
when the task is run (e.g. if the timeline changes in the interim).

We had some tests which relied on the previous behavior which have been
updated to await the pending play task

Fixes a crash in the
/web-animations/interfaces/Animatable/animate-no-browsing-context.html
WPT test but it can't be imported since it relies on a python web server
to be running
2025-12-23 14:54:22 +01:00
Callum Law
1bad8e5a78 LibWeb: Update animations regardless of whether timeline time changed
There are times that we want to update an animation regardless of
whether it's timelines time has changed, for example if an animation
associated with a scroll timeline has a pending task we should run that
on the next update regardless of whether the user has scrolled
2025-12-23 14:54:22 +01:00
Callum Law
f235625670 LibWeb: Don't disassociate animations from timeline when target orphaned
An animation with an orphaned owning element should continue to be
ticked by the timeline.

Reverts c8b574e and instead avoids leaking animations by not visiting
`Animation`s from `AnimationTimeline`s.

Fixes a timeout in the imported test
2025-12-23 14:54:22 +01:00
Callum Law
d62e2e39a3 LibWeb: Avoid running microtasks too early when updating animations
There were a bunch of places that we created
`HTML::TemporaryExecutionContext`s when updating animations in order to
resolve various promises, this worked but as part of the destructor it
would perform a microtask checkpoint which would result in us executing
microtasks earlier than intended, this is solved by instead having a
single temporary execution context for the entire animation update
process which we then destruct at the intended time.
2025-12-23 14:54:22 +01:00
Callum Law
d1e8788d43 LibWeb: Account for pending playback rate changes when playing animation
The spec calls for us to use the effective playback rate (i.e. including
any pending updates) when playing an animation.

Fixes a timeout in the newly imported test.
2025-12-23 14:54:22 +01:00
Callum Law
02adacb84c LibWeb: Expose AnimationEffect::{current,start}Time as CSSNumberish 2025-12-12 10:49:18 +00:00
Callum Law
57b7d0bbe5 LibWeb: Expose AnimationPlaybackEvent time values as CSSNumberish 2025-12-12 10:49:18 +00:00
Callum Law
69f05bd45d LibWeb: Store animation time values in abstract type
In level 2 of the web animations spec, times are no longer always
measures in milliseconds, they can also be percents when dealing with
progress-based (i.e. scroll-based) timelines.

We don't actually support percent times yet but this change will make it
easier to implement when we do.
2025-12-12 10:49:18 +00:00
Callum Law
f9df1c4eea LibWeb: Implement distinct specified timing values for AnimationEffect
Web Animations Level 2 disallows setting some `AnimationEffect` timing
values (start delay, end delay, iteration duration) directly and instead
allows authors to set the specified values which are then normalized
into the actual used values taking into account the type of the
associated timeline (i.e. progress- vs time-based)
2025-12-12 10:49:18 +00:00
Sam Atkins
d717dd64b3 LibWeb: Make Animation's owning element an AbstractElement
From the spec:
> The owning element of a transition refers to the element or
  pseudo-element to which the transition-property property was applied
  that generated the animation.

https://drafts.csswg.org/css-transitions-2/#owning-element

Previously we only stored the element.
2025-12-03 13:29:51 +01:00
Callum Law
fbcef936a9 LibWeb: Update style before getting animation play state
Pending style updates can influence this value
2025-11-02 23:54:00 +01:00
Jelle Raaijmakers
84c4eb7aa9 LibWeb: Always update computed properties for finished animations
If an animation got to its finished state before its target's computed
properties could be updated, we would end up with invalid styles. Do not
skip finished animations, but prevent effect invalidation on timeline
updates if the animation is already finished.

This fixes the CI flake on WPT test
`css/css-transitions/inherit-height-transition.html`.
2025-08-26 18:47:57 +02:00
Jelle Raaijmakers
af552856c8 LibWeb: Remove unused TemporaryExecutionContext from Animation
We don't need a temporary execution context to create a promise.
2025-08-26 18:47:57 +02:00
Jelle Raaijmakers
55255586e8 LibWeb: Remove unused include from Animation.cpp 2025-08-26 18:47:57 +02:00
Timothy Flynn
70db474cf0 LibJS+LibWeb: Port interned bytecode strings to UTF-16
This was almost a no-op, except we intern JS exception messages. So the
bulk of this patch is porting exception messages to UTF-16.
2025-08-14 10:27:08 +02:00
Jelle Raaijmakers
aa563706ca LibWeb: Rework AnimationTimeline's monotonically increasing property
Our previous implementation kept track of an AnimationTimeline being
monotonically increasing, by looking at new time values coming in and
setting `m_monotonically_increasing` to `false` whenever a new value
is before the previous known time value.

As far as I can tell, the spec doesn't really ask us to do so: it just
defines 'monotonically increasing' as a property of a timeline, i.e. it
guarantees that returned time values from `::current_time()` are always
greater than or equal to the last returned value.

This fixes a common crash seen when the last render opportunity lies
before the document's origin time, and `::set_current_time()` was
invoked with a negative value. This was especially visible in the
`Text/input/wpt-import/css/cssom/CSSStyleSheet-constructable.html` test.
2025-07-30 14:37:54 +02:00
Andreas Kling
92221f0c57 LibWeb: Apply all animations and transitions before invalidating style
This fixes an issue where only the last KeyframeEffect applied to an
element would actually have an effect on the computed properties.

It was particularly noticeable when animating a shorthand property like
border-width, since only one of the border edges would have its width
actually animate.

By deferring the invalidation until all animations have been processed,
we also reduce the amount of work that gets done on pages with many
animations/transitions per element. Discord is very fond of this for
example.
2025-07-19 11:08:46 -04:00
Aliaksandr Kalenik
62739c30d9 LibWeb: Schedule required invalidations when animation effect is removed
For example, if layout affecting property is animated then once this
animation is removed we need to schduled layout invalidation.
2025-05-28 17:35:59 +01:00
Andreas Kling
a6dfc74e93 LibWeb: Only set prototype once for object with IDL interface
Before this change, we were going through the chain of base classes for
each IDL interface object and having them set the prototype to their
prototype.

Instead of doing that, reorder things so that we set the right prototype
immediately in Foo::initialize(), and then don't bother in all the base
class overrides.

This knocks off a ~1% profile item on Speedometer 3.
2025-04-20 18:43:11 +02:00
Aliaksandr Kalenik
a5e4a51b52 LibWeb: Change animation to schedule repaint only when necessary
Animation should trigger repaint only if it's required by animated style
update.
2025-02-05 14:34:41 +01:00
Timothy Flynn
85b424464a AK+Everywhere: Rename verify_cast to as
Follow-up to fc20e61e72.
2025-01-21 11:34:06 -05:00
Lucas CHOLLET
c39ef2a738 LibWeb/Animations: Don't assume that animations have an effect
I agree that the spec definition of this function isn't super clear
about that, but from "Web Animations 1 - 4.5. Animations"[1]:

An animation is a timing node that binds an animation effect child,
called its associated effect, to a timeline parent so that it runs. Both
of these associations are optional and configurable such that an
animation can have no associated effect or timeline at a given moment.

[1]: https://drafts.csswg.org/web-animations-1/#animations
2024-12-25 17:14:08 +01:00
Lucas CHOLLET
441c1a29ae LibWeb/Animations: Consider CSSTransitions in is_replaceable() 2024-12-25 17:14:08 +01:00
Lucas CHOLLET
c2165fb6b8 LibWeb/Animations: Don't try to associate animations to null timelines
The input to `set_timeline` is user controlled, it can be null.
2024-12-25 17:14:08 +01:00
Glenn Skrzypczak
4bec023b7b LibWeb/Animation: Cancel pending play task on pause
This fixes a bug in `pause()` that canceled the pause task instead
of the play task. This issue prevented the animation from being paused
while a play task is scheduled.
2024-11-25 18:10:24 +01:00
Shannon Booth
f87041bf3a LibGC+Everywhere: Factor out a LibGC from LibJS
Resulting in a massive rename across almost everywhere! Alongside the
namespace change, we now have the following names:

 * JS::NonnullGCPtr -> GC::Ref
 * JS::GCPtr -> GC::Ptr
 * JS::HeapFunction -> GC::Function
 * JS::CellImpl -> GC::Cell
 * JS::Handle -> GC::Root
2024-11-15 14:49:20 +01:00
Shannon Booth
9b79a686eb LibJS+LibWeb: Use realm.create<T> instead of heap.allocate<T>
The main motivation behind this is to remove JS specifics of the Realm
from the implementation of the Heap.

As a side effect of this change, this is a bit nicer to read than the
previous approach, and in my opinion, also makes it a little more clear
that this method is specific to a JavaScript Realm.
2024-11-13 16:51:44 -05:00
Timothy Flynn
93712b24bf Everywhere: Hoist the Libraries folder to the top-level 2024-11-10 12:50:45 +01:00
Renamed from Userland/Libraries/LibWeb/Animations/Animation.cpp (Browse further)