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 | #pragma once |
24 | |
25 | #include "Document.h" |
26 | |
27 | namespace WebCore { |
28 | |
29 | class HTMLDocument : public Document { |
30 | WTF_MAKE_ISO_ALLOCATED(HTMLDocument); |
31 | public: |
32 | static Ref<HTMLDocument> create(Frame*, const URL&); |
33 | static Ref<HTMLDocument> createSynthesizedDocument(Frame&, const URL&); |
34 | virtual ~HTMLDocument(); |
35 | |
36 | WEBCORE_EXPORT int width(); |
37 | WEBCORE_EXPORT int height(); |
38 | |
39 | Optional<Variant<RefPtr<WindowProxy>, RefPtr<Element>, RefPtr<HTMLCollection>>> namedItem(const AtomicString&); |
40 | Vector<AtomicString> supportedPropertyNames() const; |
41 | |
42 | Element* documentNamedItem(const AtomicStringImpl& name) const { return m_documentNamedItem.getElementByDocumentNamedItem(name, *this); } |
43 | bool hasDocumentNamedItem(const AtomicStringImpl& name) const { return m_documentNamedItem.contains(name); } |
44 | bool documentNamedItemContainsMultipleElements(const AtomicStringImpl& name) const { return m_documentNamedItem.containsMultiple(name); } |
45 | void addDocumentNamedItem(const AtomicStringImpl&, Element&); |
46 | void removeDocumentNamedItem(const AtomicStringImpl&, Element&); |
47 | |
48 | Element* windowNamedItem(const AtomicStringImpl& name) const { return m_windowNamedItem.getElementByWindowNamedItem(name, *this); } |
49 | bool hasWindowNamedItem(const AtomicStringImpl& name) const { return m_windowNamedItem.contains(name); } |
50 | bool windowNamedItemContainsMultipleElements(const AtomicStringImpl& name) const { return m_windowNamedItem.containsMultiple(name); } |
51 | void addWindowNamedItem(const AtomicStringImpl&, Element&); |
52 | void removeWindowNamedItem(const AtomicStringImpl&, Element&); |
53 | |
54 | static bool isCaseSensitiveAttribute(const QualifiedName&); |
55 | |
56 | protected: |
57 | HTMLDocument(Frame*, const URL&, DocumentClassFlags = 0, unsigned constructionFlags = 0); |
58 | |
59 | private: |
60 | bool isFrameSet() const final; |
61 | Ref<DocumentParser> createParser() override; |
62 | Ref<Document> cloneDocumentWithoutChildren() const final; |
63 | |
64 | TreeScopeOrderedMap m_documentNamedItem; |
65 | TreeScopeOrderedMap m_windowNamedItem; |
66 | }; |
67 | |
68 | inline Ref<HTMLDocument> HTMLDocument::create(Frame* frame, const URL& url) |
69 | { |
70 | return adoptRef(*new HTMLDocument(frame, url, HTMLDocumentClass)); |
71 | } |
72 | |
73 | inline Ref<HTMLDocument> HTMLDocument::createSynthesizedDocument(Frame& frame, const URL& url) |
74 | { |
75 | return adoptRef(*new HTMLDocument(&frame, url, HTMLDocumentClass, Synthesized)); |
76 | } |
77 | |
78 | } // namespace WebCore |
79 | |
80 | SPECIALIZE_TYPE_TRAITS_BEGIN(WebCore::HTMLDocument) |
81 | static bool isType(const WebCore::Document& document) { return document.isHTMLDocument(); } |
82 | static bool isType(const WebCore::Node& node) { return is<WebCore::Document>(node) && isType(downcast<WebCore::Document>(node)); } |
83 | SPECIALIZE_TYPE_TRAITS_END() |
84 | |