2020-06-04 16:06:32 +02:00
|
|
|
/*
|
2021-03-08 11:22:18 +01:00
|
|
|
* Copyright (c) 2020-2021, Andreas Kling <kling@serenityos.org>
|
2020-06-04 16:06:32 +02:00
|
|
|
*
|
2021-04-22 01:24:48 -07:00
|
|
|
* SPDX-License-Identifier: BSD-2-Clause
|
2020-06-04 16:06:32 +02:00
|
|
|
*/
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
2021-03-07 16:14:04 +01:00
|
|
|
#include <AK/NonnullRefPtrVector.h>
|
2020-06-04 16:06:32 +02:00
|
|
|
#include <AK/RefCounted.h>
|
2021-03-08 11:22:18 +01:00
|
|
|
#include <LibWeb/Bindings/Wrappable.h>
|
|
|
|
#include <LibWeb/CSS/CSSStyleSheet.h>
|
2021-03-07 16:14:04 +01:00
|
|
|
#include <LibWeb/Forward.h>
|
2020-06-04 16:06:32 +02:00
|
|
|
|
2020-07-21 16:23:08 +02:00
|
|
|
namespace Web::CSS {
|
2020-06-04 16:06:32 +02:00
|
|
|
|
2021-03-08 11:22:18 +01:00
|
|
|
class StyleSheetList
|
|
|
|
: public RefCounted<StyleSheetList>
|
|
|
|
, public Bindings::Wrappable {
|
2020-06-04 16:06:32 +02:00
|
|
|
public:
|
2021-03-08 11:22:18 +01:00
|
|
|
using WrapperType = Bindings::StyleSheetListWrapper;
|
|
|
|
|
2020-07-26 19:37:56 +02:00
|
|
|
static NonnullRefPtr<StyleSheetList> create(DOM::Document& document)
|
2020-06-04 16:06:32 +02:00
|
|
|
{
|
|
|
|
return adopt(*new StyleSheetList(document));
|
|
|
|
}
|
|
|
|
|
2021-03-08 11:22:18 +01:00
|
|
|
void add_sheet(NonnullRefPtr<CSSStyleSheet>);
|
|
|
|
const NonnullRefPtrVector<CSSStyleSheet>& sheets() const { return m_sheets; }
|
|
|
|
|
|
|
|
RefPtr<CSSStyleSheet> item(size_t index) const
|
|
|
|
{
|
|
|
|
if (index >= m_sheets.size())
|
|
|
|
return {};
|
|
|
|
return m_sheets[index];
|
|
|
|
}
|
2020-06-04 16:06:32 +02:00
|
|
|
|
2021-03-08 11:22:18 +01:00
|
|
|
size_t length() const { return m_sheets.size(); }
|
2020-06-04 16:06:32 +02:00
|
|
|
|
|
|
|
private:
|
2020-07-26 19:37:56 +02:00
|
|
|
explicit StyleSheetList(DOM::Document&);
|
2020-06-04 16:06:32 +02:00
|
|
|
|
2020-07-26 19:37:56 +02:00
|
|
|
DOM::Document& m_document;
|
2021-03-08 11:22:18 +01:00
|
|
|
NonnullRefPtrVector<CSSStyleSheet> m_sheets;
|
2020-06-04 16:06:32 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
}
|
2021-03-08 11:22:18 +01:00
|
|
|
|
|
|
|
namespace Web::Bindings {
|
|
|
|
|
|
|
|
StyleSheetListWrapper* wrap(JS::GlobalObject&, CSS::StyleSheetList&);
|
|
|
|
|
|
|
|
}
|