mirror of
				https://github.com/RGBCube/serenity
				synced 2025-10-31 05:42:43 +00:00 
			
		
		
		
	 f4f850aaf2
			
		
	
	
		f4f850aaf2
		
	
	
	
	
		
			
			We already had the CSSRule::Type enum, but the values were not aligned with the CSSOM spec. This patch takes care of that, and then exposes the type of a CSSRule to JavaScript via the "type" attribute.
		
			
				
	
	
		
			49 lines
		
	
	
	
		
			1,001 B
		
	
	
	
		
			C++
		
	
	
	
	
	
			
		
		
	
	
			49 lines
		
	
	
	
		
			1,001 B
		
	
	
	
		
			C++
		
	
	
	
	
	
| /*
 | |
|  * Copyright (c) 2021, the SerenityOS developers.
 | |
|  *
 | |
|  * SPDX-License-Identifier: BSD-2-Clause
 | |
|  */
 | |
| 
 | |
| #pragma once
 | |
| 
 | |
| #include <AK/RefCounted.h>
 | |
| #include <AK/String.h>
 | |
| #include <AK/Weakable.h>
 | |
| #include <LibWeb/Bindings/Wrappable.h>
 | |
| #include <LibWeb/CSS/CSSStyleDeclaration.h>
 | |
| #include <LibWeb/CSS/Selector.h>
 | |
| 
 | |
| namespace Web::CSS {
 | |
| 
 | |
| class CSSRule
 | |
|     : public RefCounted<CSSRule>
 | |
|     , public Bindings::Wrappable
 | |
|     , public Weakable<CSSRule> {
 | |
| public:
 | |
|     using WrapperType = Bindings::CSSRuleWrapper;
 | |
| 
 | |
|     virtual ~CSSRule() = default;
 | |
| 
 | |
|     // https://drafts.csswg.org/cssom/#dom-cssrule-type
 | |
|     enum class Type : u16 {
 | |
|         Style = 1,
 | |
|         Import = 3,
 | |
|         Media = 4,
 | |
|         FontFace = 5,
 | |
|         Supports = 12,
 | |
|     };
 | |
| 
 | |
|     virtual StringView class_name() const = 0;
 | |
|     virtual Type type() const = 0;
 | |
| 
 | |
|     String css_text() const;
 | |
|     void set_css_text(StringView);
 | |
| 
 | |
|     template<typename T>
 | |
|     bool fast_is() const = delete;
 | |
| 
 | |
| protected:
 | |
|     virtual String serialized() const = 0;
 | |
| };
 | |
| 
 | |
| }
 |