mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 19:47:44 +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);
|
return make_pseudo_class_selector(Selector::SimpleSelector::PseudoClass::Type::LastOfType);
|
||||||
if (pseudo_name.equals_ignoring_ascii_case("link"sv))
|
if (pseudo_name.equals_ignoring_ascii_case("link"sv))
|
||||||
return make_pseudo_class_selector(Selector::SimpleSelector::PseudoClass::Type::Link);
|
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))
|
if (pseudo_name.equals_ignoring_ascii_case("only-child"sv))
|
||||||
return make_pseudo_class_selector(Selector::SimpleSelector::PseudoClass::Type::OnlyChild);
|
return make_pseudo_class_selector(Selector::SimpleSelector::PseudoClass::Type::OnlyChild);
|
||||||
if (pseudo_name.equals_ignoring_ascii_case("only-of-type"sv))
|
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::Playing:
|
||||||
case Selector::SimpleSelector::PseudoClass::Type::Paused:
|
case Selector::SimpleSelector::PseudoClass::Type::Paused:
|
||||||
case Selector::SimpleSelector::PseudoClass::Type::Seeking:
|
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.
|
// 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(':'));
|
||||||
TRY(s.try_append(pseudo_class_name(pseudo_class.type)));
|
TRY(s.try_append(pseudo_class_name(pseudo_class.type)));
|
||||||
|
|
|
@ -118,6 +118,7 @@ public:
|
||||||
Playing,
|
Playing,
|
||||||
Paused,
|
Paused,
|
||||||
Seeking,
|
Seeking,
|
||||||
|
Muted,
|
||||||
};
|
};
|
||||||
Type type;
|
Type type;
|
||||||
|
|
||||||
|
@ -313,6 +314,8 @@ constexpr StringView pseudo_class_name(Selector::SimpleSelector::PseudoClass::Ty
|
||||||
return "paused"sv;
|
return "paused"sv;
|
||||||
case Selector::SimpleSelector::PseudoClass::Type::Seeking:
|
case Selector::SimpleSelector::PseudoClass::Type::Seeking:
|
||||||
return "seeking"sv;
|
return "seeking"sv;
|
||||||
|
case Selector::SimpleSelector::PseudoClass::Type::Muted:
|
||||||
|
return "muted"sv;
|
||||||
}
|
}
|
||||||
VERIFY_NOT_REACHED();
|
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);
|
auto const& media_element = static_cast<HTML::HTMLMediaElement const&>(element);
|
||||||
return media_element.seeking();
|
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;
|
return false;
|
||||||
|
|
|
@ -551,6 +551,9 @@ void dump_selector(StringBuilder& builder, CSS::Selector const& selector)
|
||||||
case CSS::Selector::SimpleSelector::PseudoClass::Type::Seeking:
|
case CSS::Selector::SimpleSelector::PseudoClass::Type::Seeking:
|
||||||
pseudo_class_description = "Seeking";
|
pseudo_class_description = "Seeking";
|
||||||
break;
|
break;
|
||||||
|
case CSS::Selector::SimpleSelector::PseudoClass::Type::Muted:
|
||||||
|
pseudo_class_description = "Muted";
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
builder.appendff(" pseudo_class={}", pseudo_class_description);
|
builder.appendff(" pseudo_class={}", pseudo_class_description);
|
||||||
|
|
|
@ -414,6 +414,7 @@ void HTMLMediaElement::set_muted(bool muted)
|
||||||
|
|
||||||
m_muted = muted;
|
m_muted = muted;
|
||||||
volume_or_muted_attribute_changed();
|
volume_or_muted_attribute_changed();
|
||||||
|
set_needs_style_update(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://html.spec.whatwg.org/multipage/media.html#user-interface:dom-media-volume-3
|
// https://html.spec.whatwg.org/multipage/media.html#user-interface:dom-media-volume-3
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue