mirror of
				https://github.com/RGBCube/serenity
				synced 2025-10-31 03:42:44 +00:00 
			
		
		
		
	 e90752cc21
			
		
	
	
		e90752cc21
		
	
	
	
	
		
			
			This partially implements CSS-Animations-1 (though there are references to CSS-Animations-2). Current limitations: - Multi-selector keyframes are not supported. - Most animation properties are ignored. - Timing functions are not applied. - Non-absolute values are not interpolated unless the target is also of the same non-absolute type (e.g. 10% -> 25%, but not 10% -> 20px). - The JavaScript interface is left as an exercise for the next poor soul looking at this code. With those said, this commit implements: - Interpolation for most common types - Proper keyframe resolution (including the synthetic from-keyframe containing the initial state) - Properly driven animations, and proper style invalidation Co-Authored-By: Andreas Kling <kling@serenityos.org>
		
			
				
	
	
		
			60 lines
		
	
	
	
		
			1.4 KiB
		
	
	
	
		
			C++
		
	
	
	
	
	
			
		
		
	
	
			60 lines
		
	
	
	
		
			1.4 KiB
		
	
	
	
		
			C++
		
	
	
	
	
	
| /*
 | |
|  * Copyright (c) 2021, the SerenityOS developers.
 | |
|  * Copyright (c) 2022, Andreas Kling <kling@serenityos.org>
 | |
|  *
 | |
|  * SPDX-License-Identifier: BSD-2-Clause
 | |
|  */
 | |
| 
 | |
| #pragma once
 | |
| 
 | |
| #include <AK/DeprecatedString.h>
 | |
| #include <LibJS/Heap/GCPtr.h>
 | |
| #include <LibWeb/Bindings/PlatformObject.h>
 | |
| #include <LibWeb/CSS/CSSStyleDeclaration.h>
 | |
| #include <LibWeb/CSS/Selector.h>
 | |
| 
 | |
| namespace Web::CSS {
 | |
| 
 | |
| class CSSRule : public Bindings::PlatformObject {
 | |
|     WEB_PLATFORM_OBJECT(CSSRule, Bindings::PlatformObject);
 | |
| 
 | |
| public:
 | |
|     virtual ~CSSRule() = default;
 | |
| 
 | |
|     // https://drafts.csswg.org/cssom/#dom-cssrule-type
 | |
|     enum class Type : u16 {
 | |
|         Style = 1,
 | |
|         Import = 3,
 | |
|         Media = 4,
 | |
|         FontFace = 5,
 | |
|         Keyframes = 7,
 | |
|         Keyframe = 8,
 | |
|         Supports = 12,
 | |
|     };
 | |
| 
 | |
|     virtual Type type() const = 0;
 | |
| 
 | |
|     DeprecatedString css_text() const;
 | |
|     void set_css_text(StringView);
 | |
| 
 | |
|     CSSRule* parent_rule() { return m_parent_rule.ptr(); }
 | |
|     void set_parent_rule(CSSRule*);
 | |
| 
 | |
|     CSSStyleSheet* parent_style_sheet() { return m_parent_style_sheet.ptr(); }
 | |
|     virtual void set_parent_style_sheet(CSSStyleSheet*);
 | |
| 
 | |
|     template<typename T>
 | |
|     bool fast_is() const = delete;
 | |
| 
 | |
| protected:
 | |
|     explicit CSSRule(JS::Realm&);
 | |
| 
 | |
|     virtual DeprecatedString serialized() const = 0;
 | |
| 
 | |
|     virtual void visit_edges(Cell::Visitor&) override;
 | |
| 
 | |
|     JS::GCPtr<CSSRule> m_parent_rule;
 | |
|     JS::GCPtr<CSSStyleSheet> m_parent_style_sheet;
 | |
| };
 | |
| 
 | |
| }
 |