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 #include <wtf/text/AtomicStringHash.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,const KURL & url)38 static PassRefPtr<HTMLDocument> create(Frame* frame, const KURL& url)
39 {
40 return adoptRef(new HTMLDocument(frame, url));
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 virtual void setCompatibilityModeFromDoctype();
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 void addNamedItem(const AtomicString& name);
75 void removeNamedItem(const AtomicString& name);
76 bool hasNamedItem(AtomicStringImpl* name);
77
78 void addExtraNamedItem(const AtomicString& name);
79 void removeExtraNamedItem(const AtomicString& name);
80 bool hasExtraNamedItem(AtomicStringImpl* name);
81
82 protected:
83 HTMLDocument(Frame*, const KURL&);
84
85 private:
86 virtual PassRefPtr<Element> createElement(const AtomicString& tagName, ExceptionCode&);
87
88 virtual bool isFrameSet() const;
89 virtual PassRefPtr<DocumentParser> createParser();
90
91 void addItemToMap(HashCountedSet<AtomicStringImpl*>&, const AtomicString&);
92 void removeItemFromMap(HashCountedSet<AtomicStringImpl*>&, const AtomicString&);
93
94 HashCountedSet<AtomicStringImpl*> m_namedItemCounts;
95 HashCountedSet<AtomicStringImpl*> m_extraNamedItemCounts;
96 };
97
hasNamedItem(AtomicStringImpl * name)98 inline bool HTMLDocument::hasNamedItem(AtomicStringImpl* name)
99 {
100 ASSERT(name);
101 return m_namedItemCounts.contains(name);
102 }
103
hasExtraNamedItem(AtomicStringImpl * name)104 inline bool HTMLDocument::hasExtraNamedItem(AtomicStringImpl* name)
105 {
106 ASSERT(name);
107 return m_extraNamedItemCounts.contains(name);
108 }
109
110 } // namespace WebCore
111
112 #endif // HTMLDocument_h
113