mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 20:57:35 +00:00
LibWeb: Port MediaQueryListEvent to new String
This commit is contained in:
parent
97947fdffa
commit
d0f904dd4c
4 changed files with 11 additions and 10 deletions
|
@ -10,13 +10,13 @@
|
|||
|
||||
namespace Web::CSS {
|
||||
|
||||
WebIDL::ExceptionOr<JS::NonnullGCPtr<MediaQueryListEvent>> MediaQueryListEvent::construct_impl(JS::Realm& realm, DeprecatedFlyString const& event_name, MediaQueryListEventInit const& event_init)
|
||||
WebIDL::ExceptionOr<JS::NonnullGCPtr<MediaQueryListEvent>> MediaQueryListEvent::construct_impl(JS::Realm& realm, FlyString const& event_name, MediaQueryListEventInit const& event_init)
|
||||
{
|
||||
return MUST_OR_THROW_OOM(realm.heap().allocate<MediaQueryListEvent>(realm, realm, event_name, event_init));
|
||||
}
|
||||
|
||||
MediaQueryListEvent::MediaQueryListEvent(JS::Realm& realm, DeprecatedFlyString const& event_name, MediaQueryListEventInit const& event_init)
|
||||
: DOM::Event(realm, event_name, event_init)
|
||||
MediaQueryListEvent::MediaQueryListEvent(JS::Realm& realm, FlyString const& event_name, MediaQueryListEventInit const& event_init)
|
||||
: DOM::Event(realm, event_name.to_deprecated_fly_string(), event_init)
|
||||
, m_media(event_init.media)
|
||||
, m_matches(event_init.matches)
|
||||
{
|
||||
|
|
|
@ -6,12 +6,13 @@
|
|||
|
||||
#pragma once
|
||||
|
||||
#include <AK/FlyString.h>
|
||||
#include <LibWeb/DOM/Event.h>
|
||||
|
||||
namespace Web::CSS {
|
||||
|
||||
struct MediaQueryListEventInit : public DOM::EventInit {
|
||||
DeprecatedString media { "" };
|
||||
String media;
|
||||
bool matches { false };
|
||||
};
|
||||
|
||||
|
@ -19,19 +20,19 @@ class MediaQueryListEvent final : public DOM::Event {
|
|||
WEB_PLATFORM_OBJECT(MediaQueryListEvent, DOM::Event);
|
||||
|
||||
public:
|
||||
static WebIDL::ExceptionOr<JS::NonnullGCPtr<MediaQueryListEvent>> construct_impl(JS::Realm&, DeprecatedFlyString const& event_name, MediaQueryListEventInit const& event_init = {});
|
||||
static WebIDL::ExceptionOr<JS::NonnullGCPtr<MediaQueryListEvent>> construct_impl(JS::Realm&, FlyString const& event_name, MediaQueryListEventInit const& event_init = {});
|
||||
|
||||
virtual ~MediaQueryListEvent() override;
|
||||
|
||||
DeprecatedString const& media() const { return m_media; }
|
||||
String const& media() const { return m_media; }
|
||||
bool matches() const { return m_matches; }
|
||||
|
||||
private:
|
||||
MediaQueryListEvent(JS::Realm&, DeprecatedFlyString const& event_name, MediaQueryListEventInit const& event_init);
|
||||
MediaQueryListEvent(JS::Realm&, FlyString const& event_name, MediaQueryListEventInit const& event_init);
|
||||
|
||||
virtual JS::ThrowCompletionOr<void> initialize(JS::Realm&) override;
|
||||
|
||||
DeprecatedString m_media;
|
||||
String m_media;
|
||||
bool m_matches;
|
||||
};
|
||||
}
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
#import <DOM/Event.idl>
|
||||
|
||||
// https://w3c.github.io/csswg-drafts/cssom-view-1/#mediaquerylistevent
|
||||
[Exposed=Window]
|
||||
[Exposed=Window, UseNewAKString]
|
||||
interface MediaQueryListEvent : Event {
|
||||
constructor(CSSOMString type, optional MediaQueryListEventInit eventInitDict = {});
|
||||
|
||||
|
|
|
@ -1801,7 +1801,7 @@ void Document::evaluate_media_queries_and_report_changes()
|
|||
|
||||
if (did_match != now_matches) {
|
||||
CSS::MediaQueryListEventInit init;
|
||||
init.media = media_query_list->media();
|
||||
init.media = String::from_deprecated_string(media_query_list->media()).release_value_but_fixme_should_propagate_errors();
|
||||
init.matches = now_matches;
|
||||
auto event = CSS::MediaQueryListEvent::create(realm(), HTML::EventNames::change, init).release_value_but_fixme_should_propagate_errors();
|
||||
event->set_is_trusted(true);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue