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>
|
2024-10-04 13:19:50 +02:00
|
|
|
* Copyright (c) 2022, Andreas Kling <andreas@ladybird.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/Optional.h>
|
2022-08-08 15:32:27 +02:00
|
|
|
#include <LibJS/Runtime/Object.h>
|
2024-01-09 16:05:03 -07:00
|
|
|
#include <LibWeb/Bindings/PlatformObject.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
|
2024-01-09 16:05:03 -07:00
|
|
|
class MediaList final : public Bindings::PlatformObject {
|
|
|
|
WEB_PLATFORM_OBJECT(MediaList, Bindings::PlatformObject);
|
2024-11-15 04:01:23 +13:00
|
|
|
GC_DECLARE_ALLOCATOR(MediaList);
|
2022-04-22 14:10:59 +01:00
|
|
|
|
2021-09-29 12:08:09 +01:00
|
|
|
public:
|
2024-11-15 04:01:23 +13:00
|
|
|
[[nodiscard]] static GC::Ref<MediaList> create(JS::Realm&, Vector<NonnullRefPtr<MediaQuery>>&&);
|
2024-02-24 07:46:59 +00:00
|
|
|
virtual ~MediaList() override = default;
|
2021-09-29 12:08:09 +01:00
|
|
|
|
2023-08-26 17:24:11 +12:00
|
|
|
String media_text() const;
|
|
|
|
void set_media_text(StringView);
|
2021-09-29 12:08:09 +01:00
|
|
|
size_t length() const { return m_media.size(); }
|
2023-08-26 17:24:11 +12:00
|
|
|
Optional<String> item(u32 index) const;
|
|
|
|
void append_medium(StringView);
|
|
|
|
void delete_medium(StringView);
|
2021-09-29 12:08:09 +01:00
|
|
|
|
2024-07-25 18:15:51 +12:00
|
|
|
virtual Optional<JS::Value> item_value(size_t index) const override;
|
2022-08-08 15:32:27 +02:00
|
|
|
|
2025-10-07 00:54:19 +13:00
|
|
|
bool evaluate(DOM::Document const&);
|
2021-10-03 19:39:48 +01:00
|
|
|
bool matches() const;
|
|
|
|
|
2025-03-04 14:50:11 +01:00
|
|
|
void set_associated_style_sheet(GC::Ref<StyleSheet> style_sheet) { m_associated_style_sheet = style_sheet; }
|
|
|
|
|
2021-09-29 12:08:09 +01:00
|
|
|
private:
|
2023-03-06 14:17:01 +01:00
|
|
|
MediaList(JS::Realm&, Vector<NonnullRefPtr<MediaQuery>>&&);
|
2022-08-28 13:42:07 +02:00
|
|
|
|
2023-08-07 08:41:28 +02:00
|
|
|
virtual void initialize(JS::Realm&) override;
|
2025-03-04 14:50:11 +01:00
|
|
|
virtual void visit_edges(Visitor&) override;
|
2023-01-10 06:56:59 -05:00
|
|
|
|
2025-03-04 14:50:11 +01:00
|
|
|
GC::Ptr<StyleSheet> m_associated_style_sheet;
|
2023-03-06 14:17:01 +01:00
|
|
|
Vector<NonnullRefPtr<MediaQuery>> m_media;
|
2021-09-29 12:08:09 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
}
|