2021-09-29 14:08:09 +03:00
|
|
|
/*
|
2022-04-22 16:10:59 +03:00
|
|
|
* Copyright (c) 2021-2022, Sam Atkins <atkinssj@serenityos.org>
|
2022-08-08 16:32:27 +03:00
|
|
|
* Copyright (c) 2022, Andreas Kling <kling@serenityos.org>
|
2023-02-28 03:05:39 +03:00
|
|
|
* Copyright (c) 2023, Luke Wilde <lukew@serenityos.org>
|
2021-09-29 14:08:09 +03:00
|
|
|
*
|
|
|
|
* SPDX-License-Identifier: BSD-2-Clause
|
|
|
|
*/
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include <AK/Optional.h>
|
2022-08-08 16:32:27 +03:00
|
|
|
#include <LibJS/Runtime/Object.h>
|
2024-01-10 02:05:03 +03:00
|
|
|
#include <LibWeb/Bindings/PlatformObject.h>
|
2021-09-29 14:08:09 +03:00
|
|
|
#include <LibWeb/CSS/MediaQuery.h>
|
|
|
|
|
|
|
|
namespace Web::CSS {
|
|
|
|
|
|
|
|
// https://www.w3.org/TR/cssom-1/#the-medialist-interface
|
2024-01-10 02:05:03 +03:00
|
|
|
class MediaList final : public Bindings::PlatformObject {
|
|
|
|
WEB_PLATFORM_OBJECT(MediaList, Bindings::PlatformObject);
|
2023-11-19 21:47:52 +03:00
|
|
|
JS_DECLARE_ALLOCATOR(MediaList);
|
2022-04-22 16:10:59 +03:00
|
|
|
|
2021-09-29 14:08:09 +03:00
|
|
|
public:
|
2023-08-13 14:05:26 +03:00
|
|
|
[[nodiscard]] static JS::NonnullGCPtr<MediaList> create(JS::Realm&, Vector<NonnullRefPtr<MediaQuery>>&&);
|
2024-02-24 10:46:59 +03:00
|
|
|
virtual ~MediaList() override = default;
|
2021-09-29 14:08:09 +03:00
|
|
|
|
2023-08-26 08:24:11 +03:00
|
|
|
String media_text() const;
|
|
|
|
void set_media_text(StringView);
|
2021-09-29 14:08:09 +03:00
|
|
|
size_t length() const { return m_media.size(); }
|
2023-08-26 08:24:11 +03:00
|
|
|
Optional<String> item(u32 index) const;
|
|
|
|
void append_medium(StringView);
|
|
|
|
void delete_medium(StringView);
|
2021-09-29 14:08:09 +03:00
|
|
|
|
2022-08-08 16:32:27 +03:00
|
|
|
virtual bool is_supported_property_index(u32 index) const override;
|
2023-02-28 03:05:39 +03:00
|
|
|
virtual WebIDL::ExceptionOr<JS::Value> item_value(size_t index) const override;
|
2022-08-08 16:32:27 +03:00
|
|
|
|
2022-03-08 01:08:26 +03:00
|
|
|
bool evaluate(HTML::Window const&);
|
2021-10-03 21:39:48 +03:00
|
|
|
bool matches() const;
|
|
|
|
|
2021-09-29 14:08:09 +03:00
|
|
|
private:
|
2023-03-06 16:17:01 +03:00
|
|
|
MediaList(JS::Realm&, Vector<NonnullRefPtr<MediaQuery>>&&);
|
2022-08-28 14:42:07 +03:00
|
|
|
|
2023-08-07 09:41:28 +03:00
|
|
|
virtual void initialize(JS::Realm&) override;
|
2023-01-10 14:56:59 +03:00
|
|
|
|
2023-03-06 16:17:01 +03:00
|
|
|
Vector<NonnullRefPtr<MediaQuery>> m_media;
|
2021-09-29 14:08:09 +03:00
|
|
|
};
|
|
|
|
|
|
|
|
}
|