1/* 2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org) 3 * (C) 1999 Antti Koivisto (koivisto@kde.org) 4 * Copyright (C) 2004, 2006, 2007, 2008, 2009 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#ifndef HTMLDocument_h 24#define HTMLDocument_h 25 26#include "CachedResourceClient.h" 27#include "Document.h" 28#include <wtf/HashCountedSet.h> 29 30namespace WebCore { 31 32class HTMLDocument : public Document, public CachedResourceClient { 33public: 34 static PassRefPtr<HTMLDocument> create(Frame* frame, const URL& url) 35 { 36 return adoptRef(new HTMLDocument(frame, url, HTMLDocumentClass)); 37 } 38 39 static PassRefPtr<HTMLDocument> createSynthesizedDocument(Frame* frame, const URL& url) 40 { 41 return adoptRef(new HTMLDocument(frame, url, HTMLDocumentClass, Synthesized)); 42 } 43 44 virtual ~HTMLDocument(); 45 46 int width(); 47 int height(); 48 49 String dir(); 50 void setDir(const String&); 51 52 String designMode() const; 53 void setDesignMode(const String&); 54 55 const AtomicString& bgColor() const; 56 void setBgColor(const String&); 57 const AtomicString& fgColor() const; 58 void setFgColor(const String&); 59 const AtomicString& alinkColor() const; 60 void setAlinkColor(const String&); 61 const AtomicString& linkColor() const; 62 void setLinkColor(const String&); 63 const AtomicString& vlinkColor() const; 64 void setVlinkColor(const String&); 65 66 void clear(); 67 68 void captureEvents(); 69 void releaseEvents(); 70 71 Element* documentNamedItem(const AtomicStringImpl& name) const { return m_documentNamedItem.getElementByDocumentNamedItem(name, *this); } 72 bool hasDocumentNamedItem(const AtomicStringImpl& name) const { return m_documentNamedItem.contains(name); } 73 bool documentNamedItemContainsMultipleElements(const AtomicStringImpl& name) const { return m_documentNamedItem.containsMultiple(name); } 74 void addDocumentNamedItem(const AtomicStringImpl&, Element&); 75 void removeDocumentNamedItem(const AtomicStringImpl&, Element&); 76 77 Element* windowNamedItem(const AtomicStringImpl& name) const { return m_windowNamedItem.getElementByWindowNamedItem(name, *this); } 78 bool hasWindowNamedItem(const AtomicStringImpl& name) const { return m_windowNamedItem.contains(name); } 79 bool windowNamedItemContainsMultipleElements(const AtomicStringImpl& name) const { return m_windowNamedItem.containsMultiple(name); } 80 void addWindowNamedItem(const AtomicStringImpl&, Element&); 81 void removeWindowNamedItem(const AtomicStringImpl&, Element&); 82 83 static bool isCaseSensitiveAttribute(const QualifiedName&); 84 85protected: 86 HTMLDocument(Frame*, const URL&, DocumentClassFlags = 0, unsigned constructionFlags = 0); 87 88private: 89 virtual PassRefPtr<Element> createElement(const AtomicString& tagName, ExceptionCode&) override; 90 91 virtual bool isFrameSet() const override; 92 virtual PassRefPtr<DocumentParser> createParser() override; 93 94 virtual PassRefPtr<Document> cloneDocumentWithoutChildren() const override final; 95 96 DocumentOrderedMap m_documentNamedItem; 97 DocumentOrderedMap m_windowNamedItem; 98}; 99 100inline bool isHTMLDocument(const Document& document) { return document.isHTMLDocument(); } 101void isHTMLDocument(const HTMLDocument&); // Catch unnecessary runtime check of type known at compile time. 102 103DOCUMENT_TYPE_CASTS(HTMLDocument) 104 105} // namespace WebCore 106 107#endif // HTMLDocument_h 108