mirror of
				https://github.com/RGBCube/serenity
				synced 2025-10-31 10:42:45 +00:00 
			
		
		
		
	LibHTML: Parse the :link and :hover CSS pseudo-classes
We don't actually do anything with these yet, but now the values will be there for the selector engine to look at when it feels ready. :^)
This commit is contained in:
		
							parent
							
								
									e4015ab7cc
								
							
						
					
					
						commit
						605a225b53
					
				
					 2 changed files with 22 additions and 4 deletions
				
			
		|  | @ -15,6 +15,13 @@ public: | |||
|         }; | ||||
|         Type type { Type::Invalid }; | ||||
| 
 | ||||
|         enum class PseudoClass { | ||||
|             None, | ||||
|             Link, | ||||
|             Hover, | ||||
|         }; | ||||
|         PseudoClass pseudo_class { PseudoClass::None }; | ||||
| 
 | ||||
|         enum class Relation { | ||||
|             None, | ||||
|             ImmediateChild, | ||||
|  |  | |||
|  | @ -197,7 +197,7 @@ public: | |||
|             buffer.append(consume_one()); | ||||
| 
 | ||||
|         PARSE_ASSERT(!buffer.is_null()); | ||||
|         Selector::Component component { type, relation, String::copy(buffer) }; | ||||
|         Selector::Component component { type, Selector::Component::PseudoClass::None, relation, String::copy(buffer) }; | ||||
|         buffer.clear(); | ||||
| 
 | ||||
|         if (peek() == '[') { | ||||
|  | @ -209,12 +209,23 @@ public: | |||
|         } | ||||
| 
 | ||||
|         if (peek() == ':') { | ||||
|             // FIXME: Implement pseudo stuff.
 | ||||
|             // FIXME: Implement pseudo elements.
 | ||||
|             [[maybe_unused]] bool is_pseudo_element = false; | ||||
|             consume_one(); | ||||
|             if (peek() == ':') | ||||
|             if (peek() == ':') { | ||||
|                 is_pseudo_element = true; | ||||
|                 consume_one(); | ||||
|             } | ||||
|             while (is_valid_selector_char(peek())) | ||||
|                 consume_one(); | ||||
|                 buffer.append(consume_one()); | ||||
| 
 | ||||
|             auto pseudo_name = String::copy(buffer); | ||||
|             buffer.clear(); | ||||
| 
 | ||||
|             if (pseudo_name == "link") | ||||
|                 component.pseudo_class = Selector::Component::PseudoClass::Link; | ||||
|             else if (pseudo_name == "hover") | ||||
|                 component.pseudo_class = Selector::Component::PseudoClass::Hover; | ||||
|         } | ||||
| 
 | ||||
|         return component; | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Andreas Kling
						Andreas Kling