mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 15:47:45 +00:00
LibWeb: Implement the :muted
pseudo-class
This commit is contained in:
parent
7b4ae43b91
commit
c8a51f232d
6 changed files with 16 additions and 0 deletions
|
@ -493,6 +493,8 @@ Parser::ParseErrorOr<Selector::SimpleSelector> Parser::parse_pseudo_simple_selec
|
|||
return make_pseudo_class_selector(Selector::SimpleSelector::PseudoClass::Type::LastOfType);
|
||||
if (pseudo_name.equals_ignoring_ascii_case("link"sv))
|
||||
return make_pseudo_class_selector(Selector::SimpleSelector::PseudoClass::Type::Link);
|
||||
if (pseudo_name.equals_ignoring_ascii_case("muted"sv))
|
||||
return make_pseudo_class_selector(Selector::SimpleSelector::PseudoClass::Type::Muted);
|
||||
if (pseudo_name.equals_ignoring_ascii_case("only-child"sv))
|
||||
return make_pseudo_class_selector(Selector::SimpleSelector::PseudoClass::Type::OnlyChild);
|
||||
if (pseudo_name.equals_ignoring_ascii_case("only-of-type"sv))
|
||||
|
|
|
@ -234,6 +234,7 @@ ErrorOr<String> Selector::SimpleSelector::serialize() const
|
|||
case Selector::SimpleSelector::PseudoClass::Type::Playing:
|
||||
case Selector::SimpleSelector::PseudoClass::Type::Paused:
|
||||
case Selector::SimpleSelector::PseudoClass::Type::Seeking:
|
||||
case Selector::SimpleSelector::PseudoClass::Type::Muted:
|
||||
// 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)));
|
||||
|
|
|
@ -118,6 +118,7 @@ public:
|
|||
Playing,
|
||||
Paused,
|
||||
Seeking,
|
||||
Muted,
|
||||
};
|
||||
Type type;
|
||||
|
||||
|
@ -313,6 +314,8 @@ constexpr StringView pseudo_class_name(Selector::SimpleSelector::PseudoClass::Ty
|
|||
return "paused"sv;
|
||||
case Selector::SimpleSelector::PseudoClass::Type::Seeking:
|
||||
return "seeking"sv;
|
||||
case Selector::SimpleSelector::PseudoClass::Type::Muted:
|
||||
return "muted"sv;
|
||||
}
|
||||
VERIFY_NOT_REACHED();
|
||||
}
|
||||
|
|
|
@ -395,6 +395,12 @@ static inline bool matches_pseudo_class(CSS::Selector::SimpleSelector::PseudoCla
|
|||
auto const& media_element = static_cast<HTML::HTMLMediaElement const&>(element);
|
||||
return media_element.seeking();
|
||||
}
|
||||
case CSS::Selector::SimpleSelector::PseudoClass::Type::Muted: {
|
||||
if (!is<HTML::HTMLMediaElement>(element))
|
||||
return false;
|
||||
auto const& media_element = static_cast<HTML::HTMLMediaElement const&>(element);
|
||||
return media_element.muted();
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue