| 1 | /* |
| 2 | * Copyright (C) 2000 Peter Kelly (pmk@post.com) |
| 3 | * Copyright (C) 2006-2018 Apple Inc. All rights reserved. |
| 4 | * Copyright (C) 2013 Samsung Electronics. 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 "CachedResourceHandle.h" |
| 26 | #include "CachedStyleSheetClient.h" |
| 27 | #include "CharacterData.h" |
| 28 | |
| 29 | namespace WebCore { |
| 30 | |
| 31 | class StyleSheet; |
| 32 | class CSSStyleSheet; |
| 33 | |
| 34 | class ProcessingInstruction final : public CharacterData, private CachedStyleSheetClient { |
| 35 | WTF_MAKE_ISO_ALLOCATED(ProcessingInstruction); |
| 36 | public: |
| 37 | static Ref<ProcessingInstruction> create(Document&, const String& target, const String& data); |
| 38 | virtual ~ProcessingInstruction(); |
| 39 | |
| 40 | const String& target() const { return m_target; } |
| 41 | |
| 42 | void setCreatedByParser(bool createdByParser) { m_createdByParser = createdByParser; } |
| 43 | |
| 44 | void finishParsingChildren() override; |
| 45 | |
| 46 | const String& localHref() const { return m_localHref; } |
| 47 | StyleSheet* sheet() const { return m_sheet.get(); } |
| 48 | |
| 49 | bool isCSS() const { return m_isCSS; } |
| 50 | #if ENABLE(XSLT) |
| 51 | bool isXSL() const { return m_isXSL; } |
| 52 | #endif |
| 53 | |
| 54 | private: |
| 55 | friend class CharacterData; |
| 56 | ProcessingInstruction(Document&, const String& target, const String& data); |
| 57 | |
| 58 | String nodeName() const override; |
| 59 | NodeType nodeType() const override; |
| 60 | Ref<Node> cloneNodeInternal(Document&, CloningOperation) override; |
| 61 | |
| 62 | InsertedIntoAncestorResult insertedIntoAncestor(InsertionType, ContainerNode&) override; |
| 63 | void didFinishInsertingNode() override; |
| 64 | void removedFromAncestor(RemovalType, ContainerNode&) override; |
| 65 | |
| 66 | void checkStyleSheet(); |
| 67 | void setCSSStyleSheet(const String& href, const URL& baseURL, const String& charset, const CachedCSSStyleSheet*) override; |
| 68 | #if ENABLE(XSLT) |
| 69 | void setXSLStyleSheet(const String& href, const URL& baseURL, const String& sheet) override; |
| 70 | #endif |
| 71 | |
| 72 | bool isLoading() const; |
| 73 | bool sheetLoaded() override; |
| 74 | |
| 75 | void addSubresourceAttributeURLs(ListHashSet<URL>&) const override; |
| 76 | |
| 77 | void parseStyleSheet(const String& sheet); |
| 78 | |
| 79 | String m_target; |
| 80 | String m_localHref; |
| 81 | String m_title; |
| 82 | String m_media; |
| 83 | CachedResourceHandle<CachedResource> m_cachedSheet { nullptr }; |
| 84 | RefPtr<StyleSheet> m_sheet; |
| 85 | bool m_loading { false }; |
| 86 | bool m_alternate { false }; |
| 87 | bool m_createdByParser { false }; |
| 88 | bool m_isCSS { false }; |
| 89 | #if ENABLE(XSLT) |
| 90 | bool m_isXSL { false }; |
| 91 | #endif |
| 92 | bool m_isHandlingBeforeLoad { false }; |
| 93 | }; |
| 94 | |
| 95 | } // namespace WebCore |
| 96 | |
| 97 | SPECIALIZE_TYPE_TRAITS_BEGIN(WebCore::ProcessingInstruction) |
| 98 | static bool isType(const WebCore::Node& node) { return node.nodeType() == WebCore::Node::PROCESSING_INSTRUCTION_NODE; } |
| 99 | SPECIALIZE_TYPE_TRAITS_END() |
| 100 | |