Home | History | Annotate | Download | only in dom
      1 /*
      2  * Copyright (C) 2000 Peter Kelly (pmk (at) post.com)
      3  * Copyright (C) 2006 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 
     22 #ifndef ProcessingInstruction_h
     23 #define ProcessingInstruction_h
     24 
     25 #include "core/dom/CharacterData.h"
     26 #include "core/fetch/ResourceOwner.h"
     27 #include "core/fetch/StyleSheetResource.h"
     28 #include "core/fetch/StyleSheetResourceClient.h"
     29 
     30 namespace WebCore {
     31 
     32 class StyleSheet;
     33 class CSSStyleSheet;
     34 
     35 class ProcessingInstruction FINAL : public CharacterData, private ResourceOwner<StyleSheetResource> {
     36 public:
     37     static PassRefPtr<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     virtual void finishParsingChildren();
     45 
     46     const String& localHref() const { return m_localHref; }
     47     StyleSheet* sheet() const { return m_sheet.get(); }
     48     void setCSSStyleSheet(PassRefPtr<CSSStyleSheet>);
     49 
     50     bool isCSS() const { return m_isCSS; }
     51     bool isXSL() const { return m_isXSL; }
     52 
     53     bool isLoading() const;
     54 
     55 private:
     56     friend class CharacterData;
     57     ProcessingInstruction(Document&, const String& target, const String& data);
     58 
     59     virtual String nodeName() const;
     60     virtual NodeType nodeType() const;
     61     virtual PassRefPtr<Node> cloneNode(bool deep = true);
     62 
     63     virtual InsertionNotificationRequest insertedInto(ContainerNode*) OVERRIDE;
     64     virtual void removedFrom(ContainerNode*) OVERRIDE;
     65 
     66     void checkStyleSheet();
     67     virtual void setCSSStyleSheet(const String& href, const KURL& baseURL, const String& charset, const CSSStyleSheetResource*);
     68     virtual void setXSLStyleSheet(const String& href, const KURL& baseURL, const String& sheet);
     69 
     70     virtual bool sheetLoaded();
     71 
     72     virtual void addSubresourceAttributeURLs(ListHashSet<KURL>&) const;
     73 
     74     void parseStyleSheet(const String& sheet);
     75 
     76     String m_target;
     77     String m_localHref;
     78     String m_title;
     79     String m_media;
     80     RefPtr<StyleSheet> m_sheet;
     81     bool m_loading;
     82     bool m_alternate;
     83     bool m_createdByParser;
     84     bool m_isCSS;
     85     bool m_isXSL;
     86 };
     87 
     88 DEFINE_NODE_TYPE_CASTS(ProcessingInstruction, nodeType() == Node::PROCESSING_INSTRUCTION_NODE);
     89 
     90 } // namespace WebCore
     91 
     92 #endif
     93