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 "core/dom/Document.h"
27 #include "core/fetch/ResourceClient.h"
28 #include "wtf/HashCountedSet.h"
29
30 namespace WebCore {
31
32 class FrameView;
33 class HTMLBodyElement;
34 class HTMLElement;
35
36 class HTMLDocument : public Document, public ResourceClient {
37 public:
38 static PassRefPtr<HTMLDocument> create(const DocumentInit& initializer = DocumentInit())
39 {
40 return adoptRef(new HTMLDocument(initializer));
41 }
42 virtual ~HTMLDocument();
43
44 const AtomicString& dir();
45 void setDir(const AtomicString&);
46
47 String designMode() const;
48 void setDesignMode(const String&);
49
50 Element* activeElement();
51 bool hasFocus();
52
53 const AtomicString& bgColor() const;
54 void setBgColor(const AtomicString&);
55 const AtomicString& fgColor() const;
56 void setFgColor(const AtomicString&);
57 const AtomicString& alinkColor() const;
58 void setAlinkColor(const AtomicString&);
59 const AtomicString& linkColor() const;
60 void setLinkColor(const AtomicString&);
61 const AtomicString& vlinkColor() const;
62 void setVlinkColor(const AtomicString&);
63
64 void clear();
65
captureEvents()66 void captureEvents() { }
releaseEvents()67 void releaseEvents() { }
68
69 void addNamedItem(const AtomicString& name);
70 void removeNamedItem(const AtomicString& name);
71 bool hasNamedItem(const AtomicString& name);
72
73 void addExtraNamedItem(const AtomicString& name);
74 void removeExtraNamedItem(const AtomicString& name);
75 bool hasExtraNamedItem(const AtomicString& name);
76
77 using Document::write;
78 using Document::writeln;
79 void write(DOMWindow*, const Vector<String>& text);
80 void writeln(DOMWindow*, const Vector<String>& text);
81
82 static bool isCaseSensitiveAttribute(const QualifiedName&);
83
84 virtual PassRefPtr<Document> cloneDocumentWithoutChildren() OVERRIDE FINAL;
85
86 protected:
87 HTMLDocument(const DocumentInit&, DocumentClassFlags extendedDocumentClasses = DefaultDocumentClass);
88
89 private:
90 HTMLBodyElement* htmlBodyElement() const;
91
92 const AtomicString& bodyAttributeValue(const QualifiedName&) const;
93 void setBodyAttribute(const QualifiedName&, const AtomicString&);
94
95 void addItemToMap(HashCountedSet<AtomicString>&, const AtomicString&);
96 void removeItemFromMap(HashCountedSet<AtomicString>&, const AtomicString&);
97
98 HashCountedSet<AtomicString> m_namedItemCounts;
99 HashCountedSet<AtomicString> m_extraNamedItemCounts;
100 };
101
hasNamedItem(const AtomicString & name)102 inline bool HTMLDocument::hasNamedItem(const AtomicString& name)
103 {
104 return m_namedItemCounts.contains(name);
105 }
106
hasExtraNamedItem(const AtomicString & name)107 inline bool HTMLDocument::hasExtraNamedItem(const AtomicString& name)
108 {
109 return m_extraNamedItemCounts.contains(name);
110 }
111
112 DEFINE_DOCUMENT_TYPE_CASTS(HTMLDocument);
113
114 } // namespace WebCore
115
116 #endif // HTMLDocument_h
117