diff --git a/Userland/Libraries/LibWeb/CSS/Parser/Parser.cpp b/Userland/Libraries/LibWeb/CSS/Parser/Parser.cpp index 88bb4cb062..2921b1506e 100644 --- a/Userland/Libraries/LibWeb/CSS/Parser/Parser.cpp +++ b/Userland/Libraries/LibWeb/CSS/Parser/Parser.cpp @@ -503,6 +503,8 @@ Parser::ParseErrorOr 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)) diff --git a/Userland/Libraries/LibWeb/CSS/Selector.cpp b/Userland/Libraries/LibWeb/CSS/Selector.cpp index a55e71b054..f93e15fcfc 100644 --- a/Userland/Libraries/LibWeb/CSS/Selector.cpp +++ b/Userland/Libraries/LibWeb/CSS/Selector.cpp @@ -233,6 +233,7 @@ ErrorOr 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))); diff --git a/Userland/Libraries/LibWeb/CSS/Selector.h b/Userland/Libraries/LibWeb/CSS/Selector.h index 42af93c276..24480aaaf4 100644 --- a/Userland/Libraries/LibWeb/CSS/Selector.h +++ b/Userland/Libraries/LibWeb/CSS/Selector.h @@ -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(); } diff --git a/Userland/Libraries/LibWeb/CSS/SelectorEngine.cpp b/Userland/Libraries/LibWeb/CSS/SelectorEngine.cpp index d563329a23..b1bdef287c 100644 --- a/Userland/Libraries/LibWeb/CSS/SelectorEngine.cpp +++ b/Userland/Libraries/LibWeb/CSS/SelectorEngine.cpp @@ -389,6 +389,12 @@ static inline bool matches_pseudo_class(CSS::Selector::SimpleSelector::PseudoCla auto const& media_element = static_cast(element); return media_element.paused(); } + case CSS::Selector::SimpleSelector::PseudoClass::Type::Seeking: { + if (!is(element)) + return false; + auto const& media_element = static_cast(element); + return media_element.seeking(); + } } return false; diff --git a/Userland/Libraries/LibWeb/Dump.cpp b/Userland/Libraries/LibWeb/Dump.cpp index 06f16950bf..964be79d48 100644 --- a/Userland/Libraries/LibWeb/Dump.cpp +++ b/Userland/Libraries/LibWeb/Dump.cpp @@ -548,6 +548,9 @@ void dump_selector(StringBuilder& builder, CSS::Selector const& selector) case CSS::Selector::SimpleSelector::PseudoClass::Type::Paused: pseudo_class_description = "Paused"; break; + case CSS::Selector::SimpleSelector::PseudoClass::Type::Seeking: + pseudo_class_description = "Seeking"; + break; } builder.appendff(" pseudo_class={}", pseudo_class_description); diff --git a/Userland/Libraries/LibWeb/HTML/HTMLMediaElement.cpp b/Userland/Libraries/LibWeb/HTML/HTMLMediaElement.cpp index e61421cf2a..f4731db1e3 100644 --- a/Userland/Libraries/LibWeb/HTML/HTMLMediaElement.cpp +++ b/Userland/Libraries/LibWeb/HTML/HTMLMediaElement.cpp @@ -212,6 +212,14 @@ WebIDL::ExceptionOr HTMLMediaElement::can_play_type return Bindings::CanPlayTypeResult::Empty; } +void HTMLMediaElement::set_seeking(bool seeking) +{ + if (m_seeking == seeking) + return; + m_seeking = seeking; + set_needs_style_update(true); +} + // https://html.spec.whatwg.org/multipage/media.html#dom-media-load WebIDL::ExceptionOr HTMLMediaElement::load() { @@ -505,7 +513,8 @@ WebIDL::ExceptionOr HTMLMediaElement::load_element() } // 7. If seeking is true, set it to false. - m_seeking = false; + if (seeking()) + set_seeking(false); // 8. Set the current playback position to 0. m_current_playback_position = 0; @@ -1490,7 +1499,7 @@ void HTMLMediaElement::seek_element(double playback_position, MediaSeekMode seek } // 4. Set the seeking IDL attribute to true. - m_seeking = true; + set_seeking(true); // FIXME: 5. If the seek was in response to a DOM method call or setting of an IDL attribute, then continue the script. The // remainder of these steps must be run in parallel. With the exception of the steps marked with ⌛, they could be @@ -1534,7 +1543,7 @@ void HTMLMediaElement::seek_element(double playback_position, MediaSeekMode seek // synchronous section are marked with ⌛.) // 14. ⌛ Set the seeking IDL attribute to false. - m_seeking = false; + set_seeking(false); // 15. ⌛ Run the time marches on steps. time_marches_on(TimeMarchesOnReason::Other); diff --git a/Userland/Libraries/LibWeb/HTML/HTMLMediaElement.h b/Userland/Libraries/LibWeb/HTML/HTMLMediaElement.h index 5fb4a1765f..9ec120b502 100644 --- a/Userland/Libraries/LibWeb/HTML/HTMLMediaElement.h +++ b/Userland/Libraries/LibWeb/HTML/HTMLMediaElement.h @@ -70,6 +70,7 @@ public: ReadyState ready_state() const { return m_ready_state; } bool seeking() const { return m_seeking; } + void set_seeking(bool); WebIDL::ExceptionOr load();