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 "AtomicStringHash.h"
27 #include "CachedResourceClient.h"
28 #include "Document.h"
29 #include <wtf/HashCountedSet.h>
30
31 namespace WebCore {
32
33 class FrameView;
34 class HTMLElement;
35
36 class HTMLDocument : public Document, public CachedResourceClient {
37 public:
create(Frame * frame)38 static PassRefPtr<HTMLDocument> create(Frame* frame)
39 {
40 return new HTMLDocument(frame);
41 }
42 virtual ~HTMLDocument();
43
44 int width();
45 int height();
46
47 String dir();
48 void setDir(const String&);
49
50 String designMode() const;
51 void setDesignMode(const String&);
52
53 String compatMode() const;
54
55 Element* activeElement();
56 bool hasFocus();
57
58 String bgColor();
59 void setBgColor(const String&);
60 String fgColor();
61 void setFgColor(const String&);
62 String alinkColor();
63 void setAlinkColor(const String&);
64 String linkColor();
65 void setLinkColor(const String&);
66 String vlinkColor();
67 void setVlinkColor(const String&);
68
69 void clear();
70
71 void captureEvents();
72 void releaseEvents();
73
74 virtual bool childAllowed(Node*);
75
76 virtual PassRefPtr<Element> createElement(const AtomicString& tagName, ExceptionCode&);
77
78 void addNamedItem(const AtomicString& name);
79 void removeNamedItem(const AtomicString& name);
80 bool hasNamedItem(AtomicStringImpl* name);
81
82 void addExtraNamedItem(const AtomicString& name);
83 void removeExtraNamedItem(const AtomicString& name);
84 bool hasExtraNamedItem(AtomicStringImpl* name);
85
86 protected:
87 HTMLDocument(Frame*);
88
89 private:
isHTMLDocument()90 virtual bool isHTMLDocument() const { return true; }
91 virtual bool isFrameSet() const;
92 virtual Tokenizer* createTokenizer();
93 virtual void determineParseMode();
94
95 HashCountedSet<AtomicStringImpl*> m_namedItemCounts;
96 HashCountedSet<AtomicStringImpl*> m_extraNamedItemCounts;
97 };
98
hasNamedItem(AtomicStringImpl * name)99 inline bool HTMLDocument::hasNamedItem(AtomicStringImpl* name)
100 {
101 ASSERT(name);
102 return m_namedItemCounts.contains(name);
103 }
104
hasExtraNamedItem(AtomicStringImpl * name)105 inline bool HTMLDocument::hasExtraNamedItem(AtomicStringImpl* name)
106 {
107 ASSERT(name);
108 return m_extraNamedItemCounts.contains(name);
109 }
110
111 } // namespace WebCore
112
113 #endif // HTMLDocument_h
114