mirror of
https://github.com/RGBCube/serenity
synced 2025-07-26 21:17:45 +00:00
LibWeb: Implement the :seeking
pseudo-class
This matches while a media element is seeking.
This commit is contained in:
parent
4df5e24926
commit
7b4ae43b91
7 changed files with 28 additions and 3 deletions
|
@ -503,6 +503,8 @@ Parser::ParseErrorOr<Selector::SimpleSelector> Parser::parse_pseudo_simple_selec
|
|||
return make_pseudo_class_selector(Selector::SimpleSelector::PseudoClass::Type::Paused);
|
||||
if (pseudo_name.equals_ignoring_ascii_case("root"sv))
|
||||
return make_pseudo_class_selector(Selector::SimpleSelector::PseudoClass::Type::Root);
|
||||
if (pseudo_name.equals_ignoring_ascii_case("seeking"sv))
|
||||
return make_pseudo_class_selector(Selector::SimpleSelector::PseudoClass::Type::Seeking);
|
||||
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))
|
||||
|
|
|
@ -233,6 +233,7 @@ ErrorOr<String> Selector::SimpleSelector::serialize() const
|
|||
case Selector::SimpleSelector::PseudoClass::Type::Defined:
|
||||
case Selector::SimpleSelector::PseudoClass::Type::Playing:
|
||||
case Selector::SimpleSelector::PseudoClass::Type::Paused:
|
||||
case Selector::SimpleSelector::PseudoClass::Type::Seeking:
|
||||
// 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)));
|
||||
|
|
|
@ -117,6 +117,7 @@ public:
|
|||
Defined,
|
||||
Playing,
|
||||
Paused,
|
||||
Seeking,
|
||||
};
|
||||
Type type;
|
||||
|
||||
|
@ -310,6 +311,8 @@ constexpr StringView pseudo_class_name(Selector::SimpleSelector::PseudoClass::Ty
|
|||
return "playing"sv;
|
||||
case Selector::SimpleSelector::PseudoClass::Type::Paused:
|
||||
return "paused"sv;
|
||||
case Selector::SimpleSelector::PseudoClass::Type::Seeking:
|
||||
return "seeking"sv;
|
||||
}
|
||||
VERIFY_NOT_REACHED();
|
||||
}
|
||||
|
|
|
@ -389,6 +389,12 @@ static inline bool matches_pseudo_class(CSS::Selector::SimpleSelector::PseudoCla
|
|||
auto const& media_element = static_cast<HTML::HTMLMediaElement const&>(element);
|
||||
return media_element.paused();
|
||||
}
|
||||
case CSS::Selector::SimpleSelector::PseudoClass::Type::Seeking: {
|
||||
if (!is<HTML::HTMLMediaElement>(element))
|
||||
return false;
|
||||
auto const& media_element = static_cast<HTML::HTMLMediaElement const&>(element);
|
||||
return media_element.seeking();
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue