blob: 0376d8cdb56d95272a65e7062c7b29daa0fe2a50 [file] [log] [blame]
darinb9481ed2006-03-20 02:57:59 +00001/*
darinb9481ed2006-03-20 02:57:59 +00002 * Copyright (C) 1999 Lars Knoll (knoll@kde.org)
3 * (C) 1999 Antti Koivisto (koivisto@kde.org)
weinig@apple.com53c5fa72009-07-14 04:00:01 +00004 * Copyright (C) 2004, 2006, 2007, 2008, 2009 Apple Inc. All rights reserved.
darinb9481ed2006-03-20 02:57:59 +00005 *
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
ddkilzerc8eccec2007-09-26 02:29:57 +000018 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
19 * Boston, MA 02110-1301, USA.
darinb9481ed2006-03-20 02:57:59 +000020 *
21 */
22
darinb3547a32006-09-06 04:40:44 +000023#ifndef HTMLDocument_h
24#define HTMLDocument_h
darinb9481ed2006-03-20 02:57:59 +000025
darine775cf72006-07-09 22:48:56 +000026#include "CachedResourceClient.h"
darinb9481ed2006-03-20 02:57:59 +000027#include "Document.h"
weinig@apple.com53c5fa72009-07-14 04:00:01 +000028#include <wtf/HashCountedSet.h>
barraclough@apple.combbb3cd42010-08-10 17:45:41 +000029#include <wtf/text/AtomicStringHash.h>
darinb9481ed2006-03-20 02:57:59 +000030
darinb9481ed2006-03-20 02:57:59 +000031namespace WebCore {
32
33class FrameView;
34class HTMLElement;
35
darin8207db42007-02-20 18:18:39 +000036class HTMLDocument : public Document, public CachedResourceClient {
darinb9481ed2006-03-20 02:57:59 +000037public:
commit-queue@webkit.orga0e4c972010-09-11 08:59:57 +000038 static PassRefPtr<HTMLDocument> create(Frame* frame, const KURL& url, const KURL& baseURL = KURL())
weinig@apple.com3feb4c32008-06-15 21:53:29 +000039 {
commit-queue@webkit.orga0e4c972010-09-11 08:59:57 +000040 return adoptRef(new HTMLDocument(frame, url, baseURL));
weinig@apple.com3feb4c32008-06-15 21:53:29 +000041 }
darin8207db42007-02-20 18:18:39 +000042 virtual ~HTMLDocument();
darinb9481ed2006-03-20 02:57:59 +000043
weinig2b7b7ff2007-09-17 00:09:27 +000044 int width();
45 int height();
weinig661a37f2007-05-23 23:00:20 +000046
47 String dir();
48 void setDir(const String&);
49
50 String designMode() const;
51 void setDesignMode(const String&);
52
hyatt@apple.comce8ee2a2010-08-27 20:29:34 +000053 virtual void setCompatibilityModeFromDoctype();
oliverdc20d022007-10-12 15:24:07 +000054
adele@apple.com15717c52008-03-07 01:30:28 +000055 Element* activeElement();
56 bool hasFocus();
57
weinig661a37f2007-05-23 23:00:20 +000058 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
darin@apple.coma3c493e2008-03-18 13:47:47 +000069 void clear();
70
weinig661a37f2007-05-23 23:00:20 +000071 void captureEvents();
72 void releaseEvents();
73
darin@apple.coma3c493e2008-03-18 13:47:47 +000074 void addNamedItem(const AtomicString& name);
75 void removeNamedItem(const AtomicString& name);
76 bool hasNamedItem(AtomicStringImpl* name);
darinb9481ed2006-03-20 02:57:59 +000077
darin@apple.coma3c493e2008-03-18 13:47:47 +000078 void addExtraNamedItem(const AtomicString& name);
79 void removeExtraNamedItem(const AtomicString& name);
80 bool hasExtraNamedItem(AtomicStringImpl* name);
darinb9481ed2006-03-20 02:57:59 +000081
weinig@apple.com3feb4c32008-06-15 21:53:29 +000082protected:
commit-queue@webkit.orga0e4c972010-09-11 08:59:57 +000083 HTMLDocument(Frame* frame, const KURL& url, const KURL& baseURL = KURL());
hyatt@apple.com42583072008-02-20 22:47:57 +000084
85private:
darin@apple.com7e131b62009-08-15 06:25:49 +000086 virtual PassRefPtr<Element> createElement(const AtomicString& tagName, ExceptionCode&);
87
zecke@webkit.org073ea4c2009-02-04 13:37:52 +000088 virtual bool isFrameSet() const;
eric@webkit.org0cea84c2010-08-19 19:32:02 +000089 virtual PassRefPtr<DocumentParser> createParser();
weinig@apple.com3feb4c32008-06-15 21:53:29 +000090
eric@webkit.org0df8b7e2010-05-27 12:01:01 +000091 void addItemToMap(HashCountedSet<AtomicStringImpl*>&, const AtomicString&);
92 void removeItemFromMap(HashCountedSet<AtomicStringImpl*>&, const AtomicString&);
93
weinig@apple.com53c5fa72009-07-14 04:00:01 +000094 HashCountedSet<AtomicStringImpl*> m_namedItemCounts;
95 HashCountedSet<AtomicStringImpl*> m_extraNamedItemCounts;
darinb9481ed2006-03-20 02:57:59 +000096};
97
darin@apple.coma3c493e2008-03-18 13:47:47 +000098inline bool HTMLDocument::hasNamedItem(AtomicStringImpl* name)
99{
100 ASSERT(name);
101 return m_namedItemCounts.contains(name);
102}
103
104inline bool HTMLDocument::hasExtraNamedItem(AtomicStringImpl* name)
105{
106 ASSERT(name);
107 return m_extraNamedItemCounts.contains(name);
108}
109
weinig@apple.com53c5fa72009-07-14 04:00:01 +0000110} // namespace WebCore
darinb9481ed2006-03-20 02:57:59 +0000111
weinig@apple.com53c5fa72009-07-14 04:00:01 +0000112#endif // HTMLDocument_h