| 
									
										
										
										
											2022-05-05 20:08:29 +01:00
										 |  |  | /*
 | 
					
						
							|  |  |  |  * Copyright (c) 2022, the SerenityOS developers. | 
					
						
							| 
									
										
										
										
											2024-08-04 16:36:50 +02:00
										 |  |  |  * Copyright (c) 2024, Andreas Kling <andreas@ladybird.org> | 
					
						
							| 
									
										
										
										
											2024-10-30 20:13:31 -04:00
										 |  |  |  * Copyright (c) 2024, Tim Flynn <trflynn89@ladybird.org> | 
					
						
							| 
									
										
										
										
											2022-05-05 20:08:29 +01:00
										 |  |  |  * | 
					
						
							|  |  |  |  * SPDX-License-Identifier: BSD-2-Clause | 
					
						
							|  |  |  |  */ | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #pragma once
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-02-25 10:42:45 -07:00
										 |  |  | #include <AK/HashMap.h>
 | 
					
						
							| 
									
										
										
										
											2024-11-15 04:01:23 +13:00
										 |  |  | #include <LibGC/Function.h>
 | 
					
						
							|  |  |  | #include <LibGC/Ptr.h>
 | 
					
						
							| 
									
										
										
										
											2024-11-14 20:22:33 +13:00
										 |  |  | #include <LibJS/Heap/Cell.h>
 | 
					
						
							| 
									
										
										
										
											2024-08-04 16:36:50 +02:00
										 |  |  | #include <LibWeb/WebIDL/Types.h>
 | 
					
						
							| 
									
										
										
										
											2022-05-05 20:08:29 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  | namespace Web::HTML { | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-10-30 20:13:31 -04:00
										 |  |  | class AnimationFrameCallbackDriver final : public JS::Cell { | 
					
						
							| 
									
										
										
										
											2024-11-15 04:01:23 +13:00
										 |  |  |     GC_CELL(AnimationFrameCallbackDriver, JS::Cell); | 
					
						
							|  |  |  |     GC_DECLARE_ALLOCATOR(AnimationFrameCallbackDriver); | 
					
						
							| 
									
										
										
										
											2024-10-30 20:13:31 -04:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-11-15 04:01:23 +13:00
										 |  |  |     using Callback = GC::Ref<GC::Function<void(double)>>; | 
					
						
							| 
									
										
										
										
											2024-10-30 20:13:31 -04:00
										 |  |  | 
 | 
					
						
							|  |  |  | public: | 
					
						
							|  |  |  |     [[nodiscard]] WebIDL::UnsignedLong add(Callback handler); | 
					
						
							|  |  |  |     bool remove(WebIDL::UnsignedLong); | 
					
						
							|  |  |  |     bool has_callbacks() const; | 
					
						
							|  |  |  |     void run(double now); | 
					
						
							| 
									
										
										
										
											2022-05-05 20:08:29 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  | private: | 
					
						
							| 
									
										
										
										
											2024-10-30 20:13:31 -04:00
										 |  |  |     virtual void visit_edges(Cell::Visitor&) override; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-08-04 16:36:50 +02:00
										 |  |  |     // https://html.spec.whatwg.org/multipage/imagebitmap-and-animations.html#animation-frame-callback-identifier
 | 
					
						
							|  |  |  |     WebIDL::UnsignedLong m_animation_frame_callback_identifier { 0 }; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     OrderedHashMap<WebIDL::UnsignedLong, Callback> m_callbacks; | 
					
						
							| 
									
										
										
										
											2024-10-31 10:05:44 -04:00
										 |  |  |     OrderedHashMap<WebIDL::UnsignedLong, Callback> m_executing_callbacks; | 
					
						
							| 
									
										
										
										
											2022-05-05 20:08:29 +01:00
										 |  |  | }; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | } |