1/*
2 * (C) 1999-2003 Lars Knoll (knoll@kde.org)
3 * Copyright (C) 2004, 2006, 2007 Apple Inc. All rights reserved.
4 *
5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Library General Public
7 * License as published by the Free Software Foundation; either
8 * version 2 of the License, or (at your option) any later version.
9 *
10 * This library is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * Library General Public License for more details.
14 *
15 * You should have received a copy of the GNU Library General Public License
16 * along with this library; see the file COPYING.LIB. If not, write to
17 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
18 * Boston, MA 02110-1301, USA.
19 */
20
21#pragma once
22
23#include <wtf/Forward.h>
24#include <wtf/RefCounted.h>
25#include <wtf/Vector.h>
26#include <wtf/WeakPtr.h>
27
28namespace WebCore {
29
30class Document;
31class HTMLStyleElement;
32class Node;
33class ShadowRoot;
34class StyleSheet;
35class CSSStyleSheet;
36
37class StyleSheetList final : public RefCounted<StyleSheetList> {
38public:
39 static Ref<StyleSheetList> create(Document& document) { return adoptRef(*new StyleSheetList(document)); }
40 static Ref<StyleSheetList> create(ShadowRoot& shadowRoot) { return adoptRef(*new StyleSheetList(shadowRoot)); }
41 WEBCORE_EXPORT ~StyleSheetList();
42
43 WEBCORE_EXPORT unsigned length() const;
44 WEBCORE_EXPORT StyleSheet* item(unsigned index);
45
46 CSSStyleSheet* namedItem(const AtomString&) const;
47 Vector<AtomString> supportedPropertyNames();
48
49 Node* ownerNode() const;
50
51 void detach();
52
53private:
54 StyleSheetList(Document&);
55 StyleSheetList(ShadowRoot&);
56 const Vector<RefPtr<StyleSheet>>& styleSheets() const;
57
58 WeakPtr<Document> m_document;
59 ShadowRoot* m_shadowRoot { nullptr };
60 Vector<RefPtr<StyleSheet>> m_detachedStyleSheets;
61};
62
63} // namespace WebCore
64