2020-06-04 11:06:32 -03:00
|
|
|
/*
|
2022-08-07 08:29:49 -03:00
|
|
|
* Copyright (c) 2020-2022, Andreas Kling <kling@serenityos.org>
|
2020-06-04 11:06:32 -03:00
|
|
|
*
|
2021-04-22 05:24:48 -03:00
|
|
|
* SPDX-License-Identifier: BSD-2-Clause
|
2020-06-04 11:06:32 -03:00
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
|
2022-08-07 08:29:49 -03:00
|
|
|
#include <LibWeb/Bindings/LegacyPlatformObject.h>
|
2021-03-08 07:22:18 -03:00
|
|
|
#include <LibWeb/CSS/CSSStyleSheet.h>
|
2020-06-04 11:06:32 -03:00
|
|
|
|
2020-07-21 11:23:08 -03:00
|
|
|
namespace Web::CSS {
|
2020-06-04 11:06:32 -03:00
|
|
|
|
2022-08-07 08:29:49 -03:00
|
|
|
class StyleSheetList : public Bindings::LegacyPlatformObject {
|
2022-08-28 08:42:07 -03:00
|
|
|
WEB_PLATFORM_OBJECT(StyleSheetList, Bindings::LegacyPlatformObject);
|
2021-03-08 07:22:18 -03:00
|
|
|
|
2022-08-07 08:29:49 -03:00
|
|
|
public:
|
|
|
|
|
static StyleSheetList* create(DOM::Document& document);
|
2020-06-04 11:06:32 -03:00
|
|
|
|
2022-08-07 08:14:54 -03:00
|
|
|
void add_sheet(CSSStyleSheet&);
|
2021-09-29 18:46:16 -03:00
|
|
|
void remove_sheet(CSSStyleSheet&);
|
|
|
|
|
|
2022-09-09 06:08:56 -03:00
|
|
|
Vector<JS::NonnullGCPtr<CSSStyleSheet>> const& sheets() const { return m_sheets; }
|
|
|
|
|
Vector<JS::NonnullGCPtr<CSSStyleSheet>>& sheets() { return m_sheets; }
|
2021-03-08 07:22:18 -03:00
|
|
|
|
2022-08-07 08:14:54 -03:00
|
|
|
CSSStyleSheet* item(size_t index) const
|
2021-03-08 07:22:18 -03:00
|
|
|
{
|
|
|
|
|
if (index >= m_sheets.size())
|
|
|
|
|
return {};
|
2022-09-09 06:08:56 -03:00
|
|
|
return const_cast<CSSStyleSheet*>(m_sheets[index].ptr());
|
2021-03-08 07:22:18 -03:00
|
|
|
}
|
2020-06-04 11:06:32 -03:00
|
|
|
|
2021-03-08 07:22:18 -03:00
|
|
|
size_t length() const { return m_sheets.size(); }
|
2020-06-04 11:06:32 -03:00
|
|
|
|
2022-08-07 08:29:49 -03:00
|
|
|
virtual bool is_supported_property_index(u32 index) const override;
|
|
|
|
|
virtual JS::Value item_value(size_t index) const override;
|
2021-09-29 09:03:09 -03:00
|
|
|
|
2022-03-09 15:57:15 -03:00
|
|
|
DOM::Document& document() { return m_document; }
|
|
|
|
|
DOM::Document const& document() const { return m_document; }
|
|
|
|
|
|
2020-06-04 11:06:32 -03:00
|
|
|
private:
|
2022-08-28 08:42:07 -03:00
|
|
|
explicit StyleSheetList(DOM::Document&);
|
|
|
|
|
|
2022-08-07 08:29:49 -03:00
|
|
|
virtual void visit_edges(Cell::Visitor&) override;
|
2020-06-04 11:06:32 -03:00
|
|
|
|
2022-09-09 06:08:56 -03:00
|
|
|
void sort_sheets();
|
|
|
|
|
|
2020-07-26 14:37:56 -03:00
|
|
|
DOM::Document& m_document;
|
2022-09-09 06:08:56 -03:00
|
|
|
Vector<JS::NonnullGCPtr<CSSStyleSheet>> m_sheets;
|
2020-06-04 11:06:32 -03:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
}
|