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
31namespace WebCore {
32
33class FrameView;
34class HTMLElement;
35
36class HTMLDocument : public Document, public CachedResourceClient {
37public:
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    Element* activeElement();
54    bool hasFocus();
55
56    String bgColor();
57    void setBgColor(const String&);
58    String fgColor();
59    void setFgColor(const String&);
60    String alinkColor();
61    void setAlinkColor(const String&);
62    String linkColor();
63    void setLinkColor(const String&);
64    String vlinkColor();
65    void setVlinkColor(const String&);
66
67    void clear();
68
69    void captureEvents();
70    void releaseEvents();
71
72    DocumentOrderedMap& documentNamedItemMap() { return m_documentNamedItem; }
73    DocumentOrderedMap& windowNamedItemMap() { return m_windowNamedItem; }
74
75    static bool isCaseSensitiveAttribute(const QualifiedName&);
76
77protected:
78    HTMLDocument(Frame*, const KURL&, DocumentClassFlags = 0);
79
80private:
81    virtual PassRefPtr<Element> createElement(const AtomicString& tagName, ExceptionCode&);
82
83    virtual bool isFrameSet() const;
84    virtual PassRefPtr<DocumentParser> createParser();
85
86    DocumentOrderedMap m_documentNamedItem;
87    DocumentOrderedMap m_windowNamedItem;
88};
89
90inline HTMLDocument* toHTMLDocument(Document* document)
91{
92    ASSERT_WITH_SECURITY_IMPLICATION(!document || document->isHTMLDocument());
93    return static_cast<HTMLDocument*>(document);
94}
95
96inline const HTMLDocument* toHTMLDocument(const Document* document)
97{
98    ASSERT_WITH_SECURITY_IMPLICATION(!document || document->isHTMLDocument());
99    return static_cast<const HTMLDocument*>(document);
100}
101
102// This will catch anyone doing an unnecessary cast.
103void toHTMLDocument(const HTMLDocument*);
104
105} // namespace WebCore
106
107#endif // HTMLDocument_h
108