mirror of
				https://github.com/RGBCube/serenity
				synced 2025-10-31 05:32:44 +00:00 
			
		
		
		
	LibWeb: Implement the :target selector pseudo-class
				
					
				
			We don't yet set the Document's target element in most cases, so this does not function very well. But that will improve once we *do* set it, which involves a more complete Navigables implementation.
This commit is contained in:
		
							parent
							
								
									8bd3b74e3a
								
							
						
					
					
						commit
						a9620d8784
					
				
					 5 changed files with 11 additions and 0 deletions
				
			
		|  | @ -587,6 +587,8 @@ Parser::ParseErrorOr<Selector::SimpleSelector> Parser::parse_pseudo_simple_selec | |||
|             return make_pseudo_class_selector(Selector::SimpleSelector::PseudoClass::Type::Seeking); | ||||
|         if (pseudo_name.equals_ignoring_ascii_case("stalled"sv)) | ||||
|             return make_pseudo_class_selector(Selector::SimpleSelector::PseudoClass::Type::Stalled); | ||||
|         if (pseudo_name.equals_ignoring_ascii_case("target"sv)) | ||||
|             return make_pseudo_class_selector(Selector::SimpleSelector::PseudoClass::Type::Target); | ||||
|         if (pseudo_name.equals_ignoring_ascii_case("host"sv)) | ||||
|             return make_pseudo_class_selector(Selector::SimpleSelector::PseudoClass::Type::Host); | ||||
|         if (pseudo_name.equals_ignoring_ascii_case("visited"sv)) | ||||
|  |  | |||
|  | @ -258,6 +258,7 @@ ErrorOr<String> Selector::SimpleSelector::serialize() const | |||
|         case Selector::SimpleSelector::PseudoClass::Type::VolumeLocked: | ||||
|         case Selector::SimpleSelector::PseudoClass::Type::Buffering: | ||||
|         case Selector::SimpleSelector::PseudoClass::Type::Stalled: | ||||
|         case Selector::SimpleSelector::PseudoClass::Type::Target: | ||||
|             // If the pseudo-class does not accept arguments append ":" (U+003A), followed by the name of the pseudo-class, to s.
 | ||||
|             TRY(s.try_append(':')); | ||||
|             TRY(s.try_append(pseudo_class_name(pseudo_class.type))); | ||||
|  |  | |||
|  | @ -123,6 +123,7 @@ public: | |||
|                 VolumeLocked, | ||||
|                 Buffering, | ||||
|                 Stalled, | ||||
|                 Target, | ||||
|             }; | ||||
|             Type type; | ||||
| 
 | ||||
|  | @ -344,6 +345,8 @@ constexpr StringView pseudo_class_name(Selector::SimpleSelector::PseudoClass::Ty | |||
|         return "buffering"sv; | ||||
|     case Selector::SimpleSelector::PseudoClass::Type::Stalled: | ||||
|         return "stalled"sv; | ||||
|     case Selector::SimpleSelector::PseudoClass::Type::Target: | ||||
|         return "target"sv; | ||||
|     } | ||||
|     VERIFY_NOT_REACHED(); | ||||
| } | ||||
|  |  | |||
|  | @ -425,6 +425,8 @@ static inline bool matches_pseudo_class(CSS::Selector::SimpleSelector::PseudoCla | |||
|         auto const& media_element = static_cast<HTML::HTMLMediaElement const&>(element); | ||||
|         return media_element.stalled(); | ||||
|     } | ||||
|     case CSS::Selector::SimpleSelector::PseudoClass::Type::Target: | ||||
|         return element.is_target(); | ||||
|     } | ||||
| 
 | ||||
|     return false; | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Sam Atkins
						Sam Atkins