mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-05-29 06:22:53 +00:00
To prepare for introducing a CSS::URL type, we need to qualify any use of LibURL as `::URL::foo` instead of `URL::foo` so the compiler doesn't get confused. Many of these uses will be replaced, but I don't want to mix this in with what will likely already be a large change.
64 lines
2.3 KiB
C++
64 lines
2.3 KiB
C++
/*
|
|
* Copyright (c) 2020-2024, Andreas Kling <andreas@ladybird.org>
|
|
* Copyright (c) 2023, Luke Wilde <lukew@serenityos.org>
|
|
*
|
|
* SPDX-License-Identifier: BSD-2-Clause
|
|
*/
|
|
|
|
#pragma once
|
|
|
|
#include <LibWeb/Bindings/PlatformObject.h>
|
|
#include <LibWeb/CSS/CSSStyleSheet.h>
|
|
|
|
namespace Web::CSS {
|
|
|
|
class StyleSheetList final : public Bindings::PlatformObject {
|
|
WEB_PLATFORM_OBJECT(StyleSheetList, Bindings::PlatformObject);
|
|
GC_DECLARE_ALLOCATOR(StyleSheetList);
|
|
|
|
public:
|
|
[[nodiscard]] static GC::Ref<StyleSheetList> create(GC::Ref<DOM::Node> document_or_shadow_root);
|
|
|
|
void add_a_css_style_sheet(CSS::CSSStyleSheet&);
|
|
void remove_a_css_style_sheet(CSS::CSSStyleSheet&);
|
|
void create_a_css_style_sheet(String type, DOM::Element* owner_node, String media, String title, bool alternate, bool origin_clean, Optional<::URL::URL> location, CSS::CSSStyleSheet* parent_style_sheet, CSS::CSSRule* owner_rule, CSS::CSSStyleSheet&);
|
|
|
|
Vector<GC::Ref<CSSStyleSheet>> const& sheets() const { return m_sheets; }
|
|
Vector<GC::Ref<CSSStyleSheet>>& sheets() { return m_sheets; }
|
|
|
|
CSSStyleSheet* item(size_t index) const
|
|
{
|
|
if (index >= m_sheets.size())
|
|
return {};
|
|
return const_cast<CSSStyleSheet*>(m_sheets[index].ptr());
|
|
}
|
|
|
|
size_t length() const { return m_sheets.size(); }
|
|
|
|
virtual Optional<JS::Value> item_value(size_t index) const override;
|
|
|
|
[[nodiscard]] DOM::Document& document();
|
|
[[nodiscard]] DOM::Document const& document() const;
|
|
|
|
[[nodiscard]] DOM::Node& document_or_shadow_root() { return m_document_or_shadow_root; }
|
|
[[nodiscard]] DOM::Node const& document_or_shadow_root() const { return m_document_or_shadow_root; }
|
|
|
|
private:
|
|
explicit StyleSheetList(GC::Ref<DOM::Node> document_or_shadow_root);
|
|
|
|
virtual void initialize(JS::Realm&) override;
|
|
virtual void visit_edges(Cell::Visitor&) override;
|
|
|
|
void add_sheet(CSSStyleSheet&);
|
|
void remove_sheet(CSSStyleSheet&);
|
|
|
|
GC::Ref<DOM::Node> m_document_or_shadow_root;
|
|
Vector<GC::Ref<CSSStyleSheet>> m_sheets;
|
|
|
|
// https://www.w3.org/TR/cssom/#preferred-css-style-sheet-set-name
|
|
String m_preferred_css_style_sheet_set_name;
|
|
// https://www.w3.org/TR/cssom/#last-css-style-sheet-set-name
|
|
Optional<String> m_last_css_style_sheet_set_name;
|
|
};
|
|
|
|
}
|