2021-09-29 12:08:09 +01:00
|
|
|
/*
|
2022-04-22 14:10:59 +01:00
|
|
|
* Copyright (c) 2021-2022, Sam Atkins <atkinssj@serenityos.org>
|
2022-08-08 15:32:27 +02:00
|
|
|
* Copyright (c) 2022, Andreas Kling <kling@serenityos.org>
|
2023-02-28 00:05:39 +00:00
|
|
|
* Copyright (c) 2023, Luke Wilde <lukew@serenityos.org>
|
2021-09-29 12:08:09 +01:00
|
|
|
*
|
|
|
|
|
* SPDX-License-Identifier: BSD-2-Clause
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
|
|
|
|
|
#include <AK/NonnullRefPtrVector.h>
|
|
|
|
|
#include <AK/Optional.h>
|
2022-08-08 15:32:27 +02:00
|
|
|
#include <LibJS/Runtime/Object.h>
|
|
|
|
|
#include <LibWeb/Bindings/LegacyPlatformObject.h>
|
2021-09-29 12:08:09 +01:00
|
|
|
#include <LibWeb/CSS/MediaQuery.h>
|
|
|
|
|
|
|
|
|
|
namespace Web::CSS {
|
|
|
|
|
|
|
|
|
|
// https://www.w3.org/TR/cssom-1/#the-medialist-interface
|
2022-08-08 15:32:27 +02:00
|
|
|
class MediaList final : public Bindings::LegacyPlatformObject {
|
2022-08-28 13:42:07 +02:00
|
|
|
WEB_PLATFORM_OBJECT(MediaList, Bindings::LegacyPlatformObject);
|
2022-04-22 14:10:59 +01:00
|
|
|
|
2021-09-29 12:08:09 +01:00
|
|
|
public:
|
2023-02-13 10:50:45 +01:00
|
|
|
static WebIDL::ExceptionOr<JS::NonnullGCPtr<MediaList>> create(JS::Realm&, NonnullRefPtrVector<MediaQuery>&& media);
|
2022-03-14 13:21:51 -06:00
|
|
|
~MediaList() = default;
|
2021-09-29 12:08:09 +01:00
|
|
|
|
2022-12-04 18:02:33 +00:00
|
|
|
DeprecatedString media_text() const;
|
|
|
|
|
void set_media_text(DeprecatedString const&);
|
2021-09-29 12:08:09 +01:00
|
|
|
size_t length() const { return m_media.size(); }
|
2022-12-04 18:02:33 +00:00
|
|
|
DeprecatedString item(u32 index) const;
|
|
|
|
|
void append_medium(DeprecatedString);
|
|
|
|
|
void delete_medium(DeprecatedString);
|
2021-09-29 12:08:09 +01:00
|
|
|
|
2022-08-08 15:32:27 +02:00
|
|
|
virtual bool is_supported_property_index(u32 index) const override;
|
2023-02-28 00:05:39 +00:00
|
|
|
virtual WebIDL::ExceptionOr<JS::Value> item_value(size_t index) const override;
|
2022-08-08 15:32:27 +02:00
|
|
|
|
2022-03-07 23:08:26 +01:00
|
|
|
bool evaluate(HTML::Window const&);
|
2021-10-03 19:39:48 +01:00
|
|
|
bool matches() const;
|
|
|
|
|
|
2021-09-29 12:08:09 +01:00
|
|
|
private:
|
2022-09-24 16:34:04 -06:00
|
|
|
MediaList(JS::Realm&, NonnullRefPtrVector<MediaQuery>&&);
|
2022-08-28 13:42:07 +02:00
|
|
|
|
2023-01-28 12:33:35 -05:00
|
|
|
virtual JS::ThrowCompletionOr<void> initialize(JS::Realm&) override;
|
2023-01-10 06:56:59 -05:00
|
|
|
|
2023-02-28 00:05:39 +00:00
|
|
|
// ^Bindings::LegacyPlatformObject
|
|
|
|
|
virtual bool supports_indexed_properties() const override { return true; }
|
|
|
|
|
virtual bool supports_named_properties() const override { return false; }
|
|
|
|
|
virtual bool has_indexed_property_setter() const override { return false; }
|
|
|
|
|
virtual bool has_named_property_setter() const override { return false; }
|
|
|
|
|
virtual bool has_named_property_deleter() const override { return false; }
|
|
|
|
|
virtual bool has_legacy_override_built_ins_interface_extended_attribute() const override { return false; }
|
|
|
|
|
virtual bool has_legacy_unenumerable_named_properties_interface_extended_attribute() const override { return false; }
|
|
|
|
|
virtual bool has_global_interface_extended_attribute() const override { return false; }
|
|
|
|
|
virtual bool indexed_property_setter_has_identifier() const override { return false; }
|
|
|
|
|
virtual bool named_property_setter_has_identifier() const override { return false; }
|
|
|
|
|
virtual bool named_property_deleter_has_identifier() const override { return false; }
|
|
|
|
|
|
2021-09-29 12:08:09 +01:00
|
|
|
NonnullRefPtrVector<MediaQuery> m_media;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
}
|