Move parseFontFaceDescriptor to CSSPropertyParser.cpp
[chromium-blink-merge.git] / third_party / WebKit / Source / core / dom / ProcessingInstruction.h
blob419100f5440b22c947aaac7440d9a993881e7bb5
1 /*
2 * Copyright (C) 2000 Peter Kelly (pmk@post.com)
3 * Copyright (C) 2006 Apple Inc. All rights reserved.
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.
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.
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.
22 #ifndef ProcessingInstruction_h
23 #define ProcessingInstruction_h
25 #include "core/dom/CharacterData.h"
26 #include "core/fetch/ResourceOwner.h"
27 #include "core/fetch/StyleSheetResource.h"
28 #include "core/fetch/StyleSheetResourceClient.h"
30 namespace blink {
32 class StyleSheet;
33 class CSSStyleSheet;
34 class EventListener;
36 class ProcessingInstruction final : public CharacterData, private ResourceOwner<StyleSheetResource> {
37 DEFINE_WRAPPERTYPEINFO();
38 public:
39 static PassRefPtrWillBeRawPtr<ProcessingInstruction> create(Document&, const String& target, const String& data);
40 ~ProcessingInstruction() override;
41 DECLARE_VIRTUAL_TRACE();
43 const String& target() const { return m_target; }
45 void setCreatedByParser(bool createdByParser) { m_createdByParser = createdByParser; }
47 const String& localHref() const { return m_localHref; }
48 StyleSheet* sheet() const { return m_sheet.get(); }
50 bool isCSS() const { return m_isCSS; }
51 bool isXSL() const { return m_isXSL; }
53 void didAttributeChanged();
54 bool isLoading() const;
56 // For XSLT
57 class DetachableEventListener : public WillBeGarbageCollectedMixin {
58 public:
59 virtual ~DetachableEventListener() { }
60 virtual EventListener* toEventListener() = 0;
61 // Detach event listener from its processing instruction.
62 virtual void detach() = 0;
64 DEFINE_INLINE_VIRTUAL_TRACE() { }
66 #if !ENABLE(OILPAN)
67 void ref() { refDetachableEventListener(); }
68 void deref() { derefDetachableEventListener(); }
70 private:
71 virtual void refDetachableEventListener() = 0;
72 virtual void derefDetachableEventListener() = 0;
73 #endif
76 void setEventListenerForXSLT(PassRefPtrWillBeRawPtr<DetachableEventListener> listener) { m_listenerForXSLT = listener; }
77 EventListener* eventListenerForXSLT();
78 void clearEventListenerForXSLT();
80 private:
81 ProcessingInstruction(Document&, const String& target, const String& data);
83 String nodeName() const override;
84 NodeType nodeType() const override;
85 PassRefPtrWillBeRawPtr<Node> cloneNode(bool deep = true) override;
87 InsertionNotificationRequest insertedInto(ContainerNode*) override;
88 void removedFrom(ContainerNode*) override;
90 bool checkStyleSheet(String& href, String& charset);
91 void process(const String& href, const String& charset);
93 void setCSSStyleSheet(const String& href, const KURL& baseURL, const String& charset, const CSSStyleSheetResource*) override;
94 void setXSLStyleSheet(const String& href, const KURL& baseURL, const String& sheet) override;
96 bool sheetLoaded() override;
98 void parseStyleSheet(const String& sheet);
99 void clearSheet();
101 String m_target;
102 String m_localHref;
103 String m_title;
104 String m_media;
105 RefPtrWillBeMember<StyleSheet> m_sheet;
106 bool m_loading;
107 bool m_alternate;
108 bool m_createdByParser;
109 bool m_isCSS;
110 bool m_isXSL;
112 RefPtrWillBeMember<DetachableEventListener> m_listenerForXSLT;
115 DEFINE_NODE_TYPE_CASTS(ProcessingInstruction, nodeType() == Node::PROCESSING_INSTRUCTION_NODE);
117 inline bool isXSLStyleSheet(const Node& node)
119 return node.nodeType() == Node::PROCESSING_INSTRUCTION_NODE && toProcessingInstruction(node).isXSL();
122 } // namespace blink
124 #endif // ProcessingInstruction_h