mirror of
				https://github.com/RGBCube/serenity
				synced 2025-10-31 15:42:44 +00:00 
			
		
		
		
	LibWeb: Add CSSStyleSheet.{insert,delete,remove}Rule() APIs
Note that insertRule() is really just a big TODO right now.
This commit is contained in:
		
							parent
							
								
									3a4565beec
								
							
						
					
					
						commit
						30d710a0a2
					
				
					 5 changed files with 73 additions and 2 deletions
				
			
		|  | @ -5,6 +5,7 @@ | |||
|  */ | ||||
| 
 | ||||
| #include <LibWeb/CSS/CSSStyleSheet.h> | ||||
| #include <LibWeb/DOM/ExceptionOr.h> | ||||
| 
 | ||||
| namespace Web::CSS { | ||||
| 
 | ||||
|  | @ -17,4 +18,42 @@ CSSStyleSheet::~CSSStyleSheet() | |||
| { | ||||
| } | ||||
| 
 | ||||
| // https://drafts.csswg.org/cssom/#dom-cssstylesheet-insertrule
 | ||||
| DOM::ExceptionOr<unsigned> CSSStyleSheet::insert_rule(StringView rule, unsigned index) | ||||
| { | ||||
|     // FIXME: 1. If the origin-clean flag is unset, throw a SecurityError exception.
 | ||||
| 
 | ||||
|     // FIXME: 2. If the disallow modification flag is set, throw a NotAllowedError DOMException.
 | ||||
| 
 | ||||
|     // Let parsed rule be the return value of invoking parse a rule with rule.
 | ||||
| 
 | ||||
|     // If parsed rule is a syntax error, return parsed rule.
 | ||||
| 
 | ||||
|     // If parsed rule is an @import rule, and the constructed flag is set, throw a SyntaxError DOMException.
 | ||||
| 
 | ||||
|     // Return the result of invoking insert a CSS rule rule in the CSS rules at index.
 | ||||
| 
 | ||||
|     (void)index; | ||||
|     (void)rule; | ||||
|     TODO(); | ||||
| } | ||||
| 
 | ||||
| // https://drafts.csswg.org/cssom/#dom-cssstylesheet-deleterule
 | ||||
| DOM::ExceptionOr<void> CSSStyleSheet::delete_rule(unsigned index) | ||||
| { | ||||
|     // FIXME: 1. If the origin-clean flag is unset, throw a SecurityError exception.
 | ||||
| 
 | ||||
|     // FIXME: 2. If the disallow modification flag is set, throw a NotAllowedError DOMException.
 | ||||
| 
 | ||||
|     // 3. Remove a CSS rule in the CSS rules at index.
 | ||||
|     return m_rules->remove_a_css_rule(index); | ||||
| } | ||||
| 
 | ||||
| // https://drafts.csswg.org/cssom/#dom-cssstylesheet-removerule
 | ||||
| DOM::ExceptionOr<void> CSSStyleSheet::remove_rule(unsigned index) | ||||
| { | ||||
|     // The removeRule(index) method must run the same steps as deleteRule().
 | ||||
|     return delete_rule(index); | ||||
| } | ||||
| 
 | ||||
| } | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Andreas Kling
						Andreas Kling