mirror of
				https://github.com/RGBCube/serenity
				synced 2025-10-31 04:12:43 +00:00 
			
		
		
		
	LibHTML: Add Selector::specificity(), which returns a Specificity object.
This commit is contained in:
		
							parent
							
								
									b729b5fc64
								
							
						
					
					
						commit
						9a7dc06567
					
				
					 3 changed files with 68 additions and 1 deletions
				
			
		
							
								
								
									
										34
									
								
								LibHTML/CSS/Specificity.h
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										34
									
								
								LibHTML/CSS/Specificity.h
									
										
									
									
									
										Normal file
									
								
							|  | @ -0,0 +1,34 @@ | |||
| #pragma once | ||||
| 
 | ||||
| class Specificity { | ||||
| public: | ||||
|     Specificity(unsigned ids, unsigned classes, unsigned tag_names) | ||||
|         : m_ids(ids) | ||||
|         , m_classes(classes) | ||||
|         , m_tag_names(tag_names) | ||||
|     { | ||||
|     } | ||||
| 
 | ||||
|     unsigned ids() const { return m_ids; } | ||||
|     unsigned classes() const { return m_classes; } | ||||
|     unsigned tag_names() const { return m_tag_names; } | ||||
| 
 | ||||
|     bool operator<(const Specificity& other) const | ||||
|     { | ||||
|         return m_ids < other.m_ids | ||||
|             || m_classes < other.m_classes | ||||
|             || m_tag_names < other.m_tag_names; | ||||
|     } | ||||
| 
 | ||||
|     bool operator==(const Specificity& other) const | ||||
|     { | ||||
|         return m_ids == other.m_ids | ||||
|             || m_classes < other.m_classes | ||||
|             || m_tag_names < other.m_tag_names; | ||||
|     } | ||||
| 
 | ||||
| private: | ||||
|     unsigned m_ids { 0 }; | ||||
|     unsigned m_classes { 0 }; | ||||
|     unsigned m_tag_names { 0 }; | ||||
| }; | ||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Andreas Kling
						Andreas Kling