ladybird/Libraries/LibWeb/DOM
Callum Law 8ebdaeab69 LibWeb: Transfer animation ownership to AnimatedBitmapDecodedImageData
Previously animation ownership was a messy split between
`AnimatedBitmapDecodedImageData` and the consumers (i.e.
`ImageStyleValueResource`, `HTMLImageElement`, and `SVGImageElement`)
with `AnimatedBitmapDecodedImageData` owning the frames and a current
frame index, and the consumers owning the rest of the state (e.g. loop
count, timers to drive the animation forward, their own current index).

This had a couple of main issues:
 - While `AnimatedDecodedImageData` partially synchronized animations by
   dropping unexpected advancement notifications, this didn't apply to
   other animation state which meant, for instance, that a later started
   consumer could drive the animation of an earlier one past the max
   loop count (albeit without invalidating the earlier consumer).
 - Multiple consumers didn't share frame timings, meaning animations
   could be up to a full frame out of sync visually.
 - Animations were paused depending on whether there were any consumers,
   this is different to the behavior in other browsers (where they
   continue regardless of whether there are any consumers).
 - It was an overgeneralization of how animations need to work - only
   `AnimatedBitmapDecodedImageData` works with an indexed frame model,
   with animated SVGs (although not yet implemented) relying on their
   internal event loop to be driven forward.

Given the above the new approach implemented in this commit is:
 - The API for `DecodedImageData` is animation system agnostic, only
   exposing `default_frame`, `current_frame`, and `restart_animation`
   methods not reliant on providing a specific frame index.
 - `AnimatedBitmapDecodedImageData` owns its own timer, loop count,
   etc. The animation starts when the first consumer registers and ends
   when the document is hidden or becomes inactive (or completes in the
   case of finite animations).
 - Consumers are invalidated by `AnimatedBitmapDecodedImageData` when
   required.

Tests have been added for:
 - Animations being paused when the document becomes inactive and
   restarted when it becomes active again.
 - Frame timings being synchronized across consumers.
 - Restarts triggered by `HTMLImageElement` applying to all consumers.
 - Processing ending once a non-infinite animation plays to completion.

The tests to ensure animations are cancelled when consumers are removed
(e.g. `animated-background-image-timer-stops-when-hidden.html`) have
been updated to assert the inverse since animation state is now per
resource not per consumer.
2026-06-18 10:44:25 +02:00
..
AbortController.cpp LibWeb: Unify WebIDL C++ type generation 2026-05-23 18:26:12 +02:00
AbortController.h LibWeb: Unify WebIDL C++ type generation 2026-05-23 18:26:12 +02:00
AbortController.idl LibWeb+LibIDL: Remove support for #import directives during parsing 2026-04-24 20:08:29 +02:00
AbortSignal.cpp LibWeb: Unify WebIDL C++ type generation 2026-05-23 18:26:12 +02:00
AbortSignal.h LibWeb: Unify WebIDL C++ type generation 2026-05-23 18:26:12 +02:00
AbortSignal.idl LibWeb+LibIDL: Remove support for #import directives during parsing 2026-04-24 20:08:29 +02:00
AbstractElement.cpp LibWeb: Store custom property names as UTF-16 2026-06-09 11:48:02 +02:00
AbstractElement.h LibWeb: Store custom property names as UTF-16 2026-06-09 11:48:02 +02:00
AbstractRange.cpp LibWeb/Bindings: Emit one bindings header and cpp per IDL 2026-04-21 07:36:13 +02:00
AbstractRange.h LibWeb: Only clear command states and values if range actually changed 2025-01-24 23:53:26 +01:00
AbstractRange.idl LibWeb+LibIDL: Remove support for #import directives during parsing 2026-04-24 20:08:29 +02:00
AccessibilityTreeNode.cpp LibWeb/DOM: Set missing JSON attributes for a11y text nodes 2025-10-20 10:51:19 +01:00
AccessibilityTreeNode.h AK+LibWeb: Reduce recompilation impact of DOM/Node.h 2026-02-11 20:02:28 +01:00
AdoptedStyleSheets.cpp LibWeb: Move adopted stylesheet invalidation into a helper 2026-04-29 15:47:23 +02:00
AdoptedStyleSheets.h LibWeb: Enable EXPLICIT_SYMBOL_EXPORT 2025-08-23 16:04:36 -06:00
AnchorNameMap.cpp LibWeb: Keep track of elements with an anchor-name set 2026-04-01 19:41:46 +01:00
AnchorNameMap.h LibWeb: Keep track of elements with an anchor-name set 2026-04-01 19:41:46 +01:00
Attr.cpp LibGC: Default-construct RootVector from the global heap 2026-05-20 20:37:55 +02:00
Attr.h LibWeb: Remove unnecessary lowercase name property from Attr 2025-11-10 22:55:38 +01:00
Attr.idl LibWeb+LibIDL: Remove support for #import directives during parsing 2026-04-24 20:08:29 +02:00
CaretPosition.cpp LibWeb: Expose document caretPositionFromPoint 2026-05-30 13:50:48 +02:00
CaretPosition.h LibWeb: Expose document caretPositionFromPoint 2026-05-30 13:50:48 +02:00
CaretPosition.idl LibWeb: Expose document caretPositionFromPoint 2026-05-30 13:50:48 +02:00
CDATASection.cpp LibWeb/Bindings: Emit one bindings header and cpp per IDL 2026-04-21 07:36:13 +02:00
CDATASection.h LibWeb+LibUnicode+WebContent: Port DOM:CharacterData to UTF-16 2025-07-24 19:00:20 +02:00
CDATASection.idl LibWeb+LibIDL: Remove support for #import directives during parsing 2026-04-24 20:08:29 +02:00
CharacterData.cpp LibWeb: Invalidate layout tree of parent when replacing CharacterData 2026-06-02 11:09:52 +01:00
CharacterData.h LibWeb: Account text and image storage as external memory 2026-05-07 10:03:09 +02:00
CharacterData.idl LibWeb+LibIDL: Remove support for #import directives during parsing 2026-04-24 20:08:29 +02:00
ChildNode.h LibWeb: Unify WebIDL C++ type generation 2026-05-23 18:26:12 +02:00
ChildNode.idl LibWeb: Remove some outdated #import related FIXMEs 2026-05-03 10:56:45 +02:00
Comment.cpp LibWeb/Bindings: Emit one bindings header and cpp per IDL 2026-04-21 07:36:13 +02:00
Comment.h LibWeb+LibUnicode+WebContent: Port DOM:CharacterData to UTF-16 2025-07-24 19:00:20 +02:00
Comment.idl LibWeb+LibIDL: Remove support for #import directives during parsing 2026-04-24 20:08:29 +02:00
CustomEvent.cpp LibWeb/Bindings: Generate struct definitions from IDL dictionaries 2026-05-09 10:49:49 +02:00
CustomEvent.h LibWeb/Bindings: Generate struct definitions from IDL dictionaries 2026-05-09 10:49:49 +02:00
CustomEvent.idl LibWeb+LibIDL: Remove support for #import directives during parsing 2026-04-24 20:08:29 +02:00
Document.cpp LibWeb: Transfer animation ownership to AnimatedBitmapDecodedImageData 2026-06-18 10:44:25 +02:00
Document.h LibWeb: Transfer animation ownership to AnimatedBitmapDecodedImageData 2026-06-18 10:44:25 +02:00
Document.idl LibWeb: Expose document caretPositionFromPoint 2026-05-30 13:50:48 +02:00
DocumentFragment.cpp LibWeb/Bindings: Emit one bindings header and cpp per IDL 2026-04-21 07:36:13 +02:00
DocumentFragment.h LibWeb: Enable EXPLICIT_SYMBOL_EXPORT 2025-08-23 16:04:36 -06:00
DocumentFragment.idl LibWeb+LibIDL: Remove support for #import directives during parsing 2026-04-24 20:08:29 +02:00
DocumentLoadEventDelayer.cpp LibWeb: Save weak pointer to document in DocumentLoadEventDelayer 2025-12-24 10:19:28 +01:00
DocumentLoadEventDelayer.h LibWeb: Save weak pointer to document in DocumentLoadEventDelayer 2025-12-24 10:19:28 +01:00
DocumentLoading.cpp LibGfx: Split image decoders into a separate library 2026-06-10 11:55:48 +02:00
DocumentLoading.h LibWeb: Connect iframe referrerpolicy to ancestorOrigins 2026-06-11 14:25:27 +01:00
DocumentObserver.cpp LibWeb/DOM: Support changing document to observe in DocumentObserver 2025-06-24 09:56:14 +02:00
DocumentObserver.h LibWeb: Give IDL exposed PlatformObjects an InterfaceName 2026-02-14 20:22:40 +01:00
DocumentOrShadowRoot.h LibWeb/Bindings: Generate struct definitions from IDL dictionaries 2026-05-09 10:49:49 +02:00
DocumentOrShadowRoot.idl LibWeb+LibIDL: Remove support for #import directives during parsing 2026-04-24 20:08:29 +02:00
DocumentType.cpp LibWeb/Bindings: Emit one bindings header and cpp per IDL 2026-04-21 07:36:13 +02:00
DocumentType.h Utilities: Add dump-html-tree 2026-05-17 15:35:56 +02:00
DocumentType.idl LibWeb+LibIDL: Remove support for #import directives during parsing 2026-04-24 20:08:29 +02:00
DOMEventListener.cpp LibGC+Everywhere: Factor out a LibGC from LibJS 2024-11-15 14:49:20 +01:00
DOMEventListener.h LibWeb: Correctly implement event listeners default passive attribute 2024-12-25 14:57:22 +00:00
DOMImplementation.cpp LibWeb/Bindings: Generate struct definitions from IDL dictionaries 2026-05-09 10:49:49 +02:00
DOMImplementation.h LibWeb: Remove Document.h include from DOMParser.h, DOMImplementation.h 2026-02-08 18:51:13 +01:00
DOMImplementation.idl LibWeb+LibIDL: Remove support for #import directives during parsing 2026-04-24 20:08:29 +02:00
DOMTokenList.cpp Meta: Enable exit-time destructor warnings for libraries 2026-06-04 19:20:49 +02:00
DOMTokenList.h LibWeb: Account DOM state as external memory 2026-05-07 10:03:09 +02:00
DOMTokenList.idl Everywhere: Hoist the Libraries folder to the top-level 2024-11-10 12:50:45 +01:00
EditingHostManager.cpp LibWeb: Do not scroll cursor into view on programmatic selection changes 2026-02-17 10:24:00 +01:00
EditingHostManager.h LibWeb: Send InputEvent with right .inputType on insert and delete 2026-01-29 15:08:06 +01:00
Element.cpp LibWeb: Keep pinch zoom out of client rects 2026-06-16 02:03:59 +02:00
Element.h LibWeb: Keep non-subject :has() dependency sticky 2026-06-12 15:13:29 +02:00
Element.idl LibWeb+LibIDL: Remove support for #import directives during parsing 2026-04-24 20:08:29 +02:00
ElementByIdMap.cpp LibWeb: Lazify ElementByIdMap resolution and cache first element 2026-02-21 13:56:00 +01:00
ElementByIdMap.h LibWeb: Lazify ElementByIdMap resolution and cache first element 2026-02-21 13:56:00 +01:00
ElementFactory.cpp LibWeb: Implement scoped custom element registries 2026-03-27 19:49:55 +00:00
ElementFactory.h LibWeb: Implement scoped custom element registries 2026-03-27 19:49:55 +00:00
Event.cpp LibWeb/Bindings: Generate struct definitions from IDL dictionaries 2026-05-09 10:49:49 +02:00
Event.h LibWeb/Bindings: Generate struct definitions from IDL dictionaries 2026-05-09 10:49:49 +02:00
Event.idl LibWeb+LibIDL: Remove support for #import directives during parsing 2026-04-24 20:08:29 +02:00
EventDispatcher.cpp LibWeb: Deal with legacy event types for event dispatch optimization 2026-05-31 19:50:58 +02:00
EventDispatcher.h LibWeb: Implement legacyOutputDidListenersThrowFlag 2024-11-26 14:50:27 +01:00
EventHandler.idl LibWeb+LibIDL: Remove support for #import directives during parsing 2026-04-24 20:08:29 +02:00
EventListener.idl LibWeb+LibIDL: Remove support for #import directives during parsing 2026-04-24 20:08:29 +02:00
EventTarget.cpp LibWeb: Preserve inline handler ordering after parse failure 2026-06-06 19:18:11 +02:00
EventTarget.h LibWeb: Avoid GC::Root churn in wheel listener checks 2026-05-15 17:25:10 +02:00
EventTarget.idl LibWeb+LibIDL: Remove support for #import directives during parsing 2026-04-24 20:08:29 +02:00
FragmentSerializationMode.h AK+LibWeb: Reduce recompilation impact of DOM/Node.h 2026-02-11 20:02:28 +01:00
HoverEventData.h LibWeb: Populate platform mouse event data 2026-05-19 11:22:02 +02:00
HTMLCollection.cpp LibWeb: Fix use-after-free in live-collection filter captures 2026-06-07 22:16:33 +02:00
HTMLCollection.h LibWeb: Implement the required virtual owner_cell() on HTMLCollection 2026-05-14 13:27:56 +01:00
HTMLCollection.idl LibWeb+LibIDL: Remove support for #import directives during parsing 2026-04-24 20:08:29 +02:00
IDLEventListener.cpp LibGC+Everywhere: Factor out a LibGC from LibJS 2024-11-15 14:49:20 +01:00
IDLEventListener.h LibWeb/Bindings: Generate struct definitions from IDL dictionaries 2026-05-09 10:49:49 +02:00
InputEventsTarget.h LibWeb: Send InputEvent with right .inputType on insert and delete 2026-01-29 15:08:06 +01:00
LiveNodeList.cpp LibWeb: Fix use-after-free in live-collection filter captures 2026-06-07 22:16:33 +02:00
LiveNodeList.h LibWeb: Give IDL exposed PlatformObjects an InterfaceName 2026-02-14 20:22:40 +01:00
MutationObserver.cpp LibWeb/Bindings: Generate struct definitions from IDL dictionaries 2026-05-09 10:49:49 +02:00
MutationObserver.h LibWeb/Bindings: Generate struct definitions from IDL dictionaries 2026-05-09 10:49:49 +02:00
MutationObserver.idl LibWeb+LibIDL: Remove support for #import directives during parsing 2026-04-24 20:08:29 +02:00
MutationRecord.cpp LibWeb/Bindings: Emit one bindings header and cpp per IDL 2026-04-21 07:36:13 +02:00
MutationRecord.h LibGC+Everywhere: Factor out a LibGC from LibJS 2024-11-15 14:49:20 +01:00
MutationRecord.idl LibWeb+LibIDL: Remove support for #import directives during parsing 2026-04-24 20:08:29 +02:00
MutationType.cpp Meta: Enable exit-time destructor warnings for libraries 2026-06-04 19:20:49 +02:00
MutationType.h Meta: Enable exit-time destructor warnings for libraries 2026-06-04 19:20:49 +02:00
NamedNodeMap.cpp LibWeb: Stop retaining fragment-parsing documents after adoption 2026-05-21 08:56:41 +02:00
NamedNodeMap.h LibWeb: Stop retaining fragment-parsing documents after adoption 2026-05-21 08:56:41 +02:00
NamedNodeMap.idl LibWeb+LibIDL: Remove support for #import directives during parsing 2026-04-24 20:08:29 +02:00
Node.cpp LibWeb: Clear paintables for continued layout nodes in removed_from 2026-06-14 19:39:15 +09:00
Node.h LibWeb: Add fast_is to SVGTextContentElement 2026-06-18 01:27:28 +02:00
Node.idl LibWeb/DOM: Remove unnecessary LegacyNullToEmptyString usage 2026-06-05 20:23:24 +02:00
NodeFilter.cpp LibWeb/Bindings: Emit one bindings header and cpp per IDL 2026-04-21 07:36:13 +02:00
NodeFilter.h LibWeb/Bindings: Implement callback interface object bindings 2026-03-11 21:16:44 +01:00
NodeFilter.idl LibWeb+LibIDL: Remove support for #import directives during parsing 2026-04-24 20:08:29 +02:00
NodeIterator.cpp LibWeb/Bindings: Emit one bindings header and cpp per IDL 2026-04-21 07:36:13 +02:00
NodeIterator.h LibWeb/Bindings: Implement callback interface object bindings 2026-03-11 21:16:44 +01:00
NodeIterator.idl LibWeb+LibIDL: Remove support for #import directives during parsing 2026-04-24 20:08:29 +02:00
NodeList.cpp LibWeb/Bindings: Emit one bindings header and cpp per IDL 2026-04-21 07:36:13 +02:00
NodeList.h LibWeb: Enable EXPLICIT_SYMBOL_EXPORT 2025-08-23 16:04:36 -06:00
NodeList.idl LibWeb+LibIDL: Remove support for #import directives during parsing 2026-04-24 20:08:29 +02:00
NodeOperations.cpp LibWeb: Unify WebIDL C++ type generation 2026-05-23 18:26:12 +02:00
NodeOperations.h LibWeb: Unify WebIDL C++ type generation 2026-05-23 18:26:12 +02:00
NodeType.h LibWeb: Move DOM::NodeType to its own file 2025-02-19 08:45:51 -05:00
NonDocumentTypeChildNode.h AK+Everywhere: Rename verify_cast to as 2025-01-21 11:34:06 -05:00
ParentNode.cpp LibWeb: Use the id cache for document element get_element_by_id() 2026-06-11 15:28:59 +02:00
ParentNode.h LibWeb: Avoid sibling walks for last-child invalidation 2026-06-08 17:16:18 +02:00
ParentNode.idl LibWeb+LibIDL: Remove support for #import directives during parsing 2026-04-24 20:08:29 +02:00
Position.cpp LibWeb: Make DOM::Position's node mandatory 2025-08-20 12:25:00 +01:00
Position.h AK+LibWeb: Reduce recompilation impact of DOM/Node.h 2026-02-11 20:02:28 +01:00
ProcessingInstruction.cpp LibWeb/Bindings: Emit one bindings header and cpp per IDL 2026-04-21 07:36:13 +02:00
ProcessingInstruction.h LibWeb+LibUnicode+WebContent: Port DOM:CharacterData to UTF-16 2025-07-24 19:00:20 +02:00
ProcessingInstruction.idl LibWeb+LibIDL: Remove support for #import directives during parsing 2026-04-24 20:08:29 +02:00
PseudoElement.cpp LibWeb: Make layout nodes refcounted 2026-06-07 20:52:49 +02:00
PseudoElement.h LibWeb: Make layout nodes refcounted 2026-06-07 20:52:49 +02:00
QualifiedName.cpp Meta: Enable exit-time destructor warnings for libraries 2026-06-04 19:20:49 +02:00
QualifiedName.h LibWeb: Enable EXPLICIT_SYMBOL_EXPORT 2025-08-23 16:04:36 -06:00
Range.cpp LibWeb: Handle Range rects starting after last child 2026-06-08 01:04:08 +02:00
Range.h LibGC+ClangPlugins: Forbid non-trivial destructors in Cell subclasses 2026-01-30 20:57:42 +01:00
Range.idl LibWeb+LibIDL: Remove support for #import directives during parsing 2026-04-24 20:08:29 +02:00
RequestFullscreenError.h LibWeb: Move RequestFullscreenError out of Element.h 2026-03-17 18:58:37 -05:00
SelectionchangeEventDispatching.h LibWeb+LibWebView+UI: Update the selection keyboard on selection changes 2026-05-27 13:33:44 -04:00
ShadowRoot.cpp LibWeb/Bindings: Generate struct definitions from IDL dictionaries 2026-05-09 10:49:49 +02:00
ShadowRoot.h LibWeb/Bindings: Generate struct definitions from IDL dictionaries 2026-05-09 10:49:49 +02:00
ShadowRoot.idl LibWeb: Align declarative shadow root parsing 2026-05-17 15:35:56 +02:00
Slot.cpp LibJS+LibWeb: Use the unified Visitor for Variant-holding members 2026-05-15 08:51:17 +02:00
Slot.h LibWeb: Store slot name as a FlyString 2026-01-31 11:44:20 +01:00
SlotRegistry.cpp LibWeb: Avoid subtree iteration when assigning slottables 2026-01-31 11:44:20 +01:00
SlotRegistry.h LibWeb: Avoid subtree iteration when assigning slottables 2026-01-31 11:44:20 +01:00
Slottable.cpp LibWeb: Move slotted style invalidation into a helper 2026-04-29 15:47:23 +02:00
Slottable.h LibWeb: Avoid dynamic_cast in SlottableMixin::assigned_slot() 2026-02-07 16:43:50 +01:00
Slottable.idl LibWeb: Remove some outdated #import related FIXMEs 2026-05-03 10:56:45 +02:00
StaticNodeList.cpp LibWeb: Account DOM state as external memory 2026-05-07 10:03:09 +02:00
StaticNodeList.h LibWeb: Account DOM state as external memory 2026-05-07 10:03:09 +02:00
StaticRange.cpp LibWeb/Bindings: Generate struct definitions from IDL dictionaries 2026-05-09 10:49:49 +02:00
StaticRange.h LibWeb/Bindings: Generate struct definitions from IDL dictionaries 2026-05-09 10:49:49 +02:00
StaticRange.idl LibWeb+LibIDL: Remove support for #import directives during parsing 2026-04-24 20:08:29 +02:00
StyleElementBase.cpp LibWeb/DOM: Evaluate style media for script blocking 2026-06-04 16:39:54 +01:00
StyleElementBase.h LibWeb: Transfer load delayers when elements are adopted 2026-06-11 00:34:12 +02:00
StyleInvalidationReason.h LibWeb: Invalidate style when form control validity changes 2026-06-08 19:28:37 +02:00
Text.cpp LibWeb/Bindings: Emit one bindings header and cpp per IDL 2026-04-21 07:36:13 +02:00
Text.h LibWeb: Avoid dynamic_cast in SlottableMixin::assigned_slot() 2026-02-07 16:43:50 +01:00
Text.idl LibWeb+LibIDL: Remove support for #import directives during parsing 2026-04-24 20:08:29 +02:00
TreeWalker.cpp LibWeb/Bindings: Emit one bindings header and cpp per IDL 2026-04-21 07:36:13 +02:00
TreeWalker.h LibWeb/Bindings: Implement callback interface object bindings 2026-03-11 21:16:44 +01:00
TreeWalker.idl LibWeb+LibIDL: Remove support for #import directives during parsing 2026-04-24 20:08:29 +02:00
Utils.cpp LibWeb: Replace is<T> + as<T> with as_if<T> 2026-03-10 15:17:51 +01:00
Utils.h Everywhere: Hoist the Libraries folder to the top-level 2024-11-10 12:50:45 +01:00
ViewportClient.h LibWeb: Reduce recompilation impact of DOM/Document.h 2026-02-11 20:02:28 +01:00
XMLDocument.cpp LibWeb/Bindings: Emit one bindings header and cpp per IDL 2026-04-21 07:36:13 +02:00
XMLDocument.h Everywhere: Use URL::about_XXX factory functions 2025-02-15 17:05:55 +00:00
XMLDocument.idl LibWeb+LibIDL: Remove support for #import directives during parsing 2026-04-24 20:08:29 +02:00