1 | /* |
2 | * Copyright (C) 1999 Lars Knoll (knoll@kde.org) |
3 | * (C) 1999 Antti Koivisto (koivisto@kde.org) |
4 | * Copyright (C) 2003, 2010, 2013 Apple Inc. ALl rights reserved. |
5 | * |
6 | * This library is free software; you can redistribute it and/or |
7 | * modify it under the terms of the GNU Library General Public |
8 | * License as published by the Free Software Foundation; either |
9 | * version 2 of the License, or (at your option) any later version. |
10 | * |
11 | * This library is distributed in the hope that it will be useful, |
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
14 | * Library General Public License for more details. |
15 | * |
16 | * You should have received a copy of the GNU Library General Public License |
17 | * along with this library; see the file COPYING.LIB. If not, write to |
18 | * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, |
19 | * Boston, MA 02110-1301, USA. |
20 | * |
21 | */ |
22 | |
23 | #pragma once |
24 | |
25 | #include "HTMLElement.h" |
26 | #include "InlineStyleSheetOwner.h" |
27 | |
28 | namespace WebCore { |
29 | |
30 | class HTMLStyleElement; |
31 | class StyleSheet; |
32 | |
33 | template<typename T> class EventSender; |
34 | |
35 | using StyleEventSender = EventSender<HTMLStyleElement>; |
36 | |
37 | class HTMLStyleElement final : public HTMLElement { |
38 | WTF_MAKE_ISO_ALLOCATED(HTMLStyleElement); |
39 | public: |
40 | static Ref<HTMLStyleElement> create(Document&); |
41 | static Ref<HTMLStyleElement> create(const QualifiedName&, Document&, bool createdByParser); |
42 | virtual ~HTMLStyleElement(); |
43 | |
44 | CSSStyleSheet* sheet() const { return m_styleSheetOwner.sheet(); } |
45 | |
46 | WEBCORE_EXPORT bool disabled() const; |
47 | WEBCORE_EXPORT void setDisabled(bool); |
48 | |
49 | void dispatchPendingEvent(StyleEventSender*); |
50 | static void dispatchPendingLoadEvents(); |
51 | |
52 | void finishParsingChildren() final; |
53 | |
54 | private: |
55 | HTMLStyleElement(const QualifiedName&, Document&, bool createdByParser); |
56 | |
57 | void parseAttribute(const QualifiedName&, const AtomicString&) final; |
58 | InsertedIntoAncestorResult insertedIntoAncestor(InsertionType, ContainerNode&) final; |
59 | void removedFromAncestor(RemovalType, ContainerNode&) final; |
60 | void childrenChanged(const ChildChange&) final; |
61 | |
62 | bool isLoading() const { return m_styleSheetOwner.isLoading(); } |
63 | bool sheetLoaded() final { return m_styleSheetOwner.sheetLoaded(*this); } |
64 | void notifyLoadedSheetAndAllCriticalSubresources(bool errorOccurred) final; |
65 | void startLoadingDynamicSheet() final { m_styleSheetOwner.startLoadingDynamicSheet(*this); } |
66 | |
67 | void addSubresourceAttributeURLs(ListHashSet<URL>&) const final; |
68 | |
69 | InlineStyleSheetOwner m_styleSheetOwner; |
70 | bool m_firedLoad { false }; |
71 | bool m_loadedSheet { false }; |
72 | }; |
73 | |
74 | } //namespace |
75 | |