1 /*
2 * Copyright (C) 2009 Google Inc. All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
6 * met:
7 *
8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above
11 * copyright notice, this list of conditions and the following disclaimer
12 * in the documentation and/or other materials provided with the
13 * distribution.
14 * * Neither the name of Google Inc. nor the names of its
15 * contributors may be used to endorse or promote products derived from
16 * this software without specific prior written permission.
17 *
18 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
19 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
20 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
21 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
22 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
23 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 */
30
31 #include "config.h"
32 #include "WebDocument.h"
33
34 #include "AXObjectCache.h"
35 #include "Document.h"
36 #include "DocumentType.h"
37 #include "Element.h"
38 #include "HTMLAllCollection.h"
39 #include "HTMLBodyElement.h"
40 #include "HTMLCollection.h"
41 #include "HTMLElement.h"
42 #include "HTMLHeadElement.h"
43 #include "NodeList.h"
44
45 #include "WebAccessibilityObject.h"
46 #include "WebDocumentType.h"
47 #include "WebElement.h"
48 #include "WebFrameImpl.h"
49 #include "WebNodeCollection.h"
50 #include "WebNodeList.h"
51 #include "WebURL.h"
52
53 #include <wtf/PassRefPtr.h>
54
55 using namespace WebCore;
56
57 namespace WebKit {
58
frame() const59 WebFrame* WebDocument::frame() const
60 {
61 return WebFrameImpl::fromFrame(constUnwrap<Document>()->frame());
62 }
63
isHTMLDocument() const64 bool WebDocument::isHTMLDocument() const
65 {
66 return constUnwrap<Document>()->isHTMLDocument();
67 }
68
isXHTMLDocument() const69 bool WebDocument::isXHTMLDocument() const
70 {
71 return constUnwrap<Document>()->isXHTMLDocument();
72 }
73
isPluginDocument() const74 bool WebDocument::isPluginDocument() const
75 {
76 return constUnwrap<Document>()->isPluginDocument();
77 }
78
baseURL() const79 WebURL WebDocument::baseURL() const
80 {
81 return constUnwrap<Document>()->baseURL();
82 }
83
firstPartyForCookies() const84 WebURL WebDocument::firstPartyForCookies() const
85 {
86 return constUnwrap<Document>()->firstPartyForCookies();
87 }
88
documentElement() const89 WebElement WebDocument::documentElement() const
90 {
91 return WebElement(constUnwrap<Document>()->documentElement());
92 }
93
body() const94 WebElement WebDocument::body() const
95 {
96 return WebElement(constUnwrap<Document>()->body());
97 }
98
head()99 WebElement WebDocument::head()
100 {
101 return WebElement(unwrap<Document>()->head());
102 }
103
title() const104 WebString WebDocument::title() const
105 {
106 return WebString(constUnwrap<Document>()->title());
107 }
108
all()109 WebNodeCollection WebDocument::all()
110 {
111 return WebNodeCollection(unwrap<Document>()->all());
112 }
113
completeURL(const WebString & partialURL) const114 WebURL WebDocument::completeURL(const WebString& partialURL) const
115 {
116 return constUnwrap<Document>()->completeURL(partialURL);
117 }
118
getElementById(const WebString & id) const119 WebElement WebDocument::getElementById(const WebString& id) const
120 {
121 return WebElement(constUnwrap<Document>()->getElementById(id));
122 }
123
focusedNode() const124 WebNode WebDocument::focusedNode() const
125 {
126 return WebNode(constUnwrap<Document>()->focusedNode());
127 }
128
doctype() const129 WebDocumentType WebDocument::doctype() const
130 {
131 return WebDocumentType(constUnwrap<Document>()->doctype());
132 }
133
accessibilityObject() const134 WebAccessibilityObject WebDocument::accessibilityObject() const
135 {
136 const Document* document = constUnwrap<Document>();
137 return WebAccessibilityObject(
138 document->axObjectCache()->getOrCreate(document->renderer()));
139 }
140
WebDocument(const PassRefPtr<Document> & elem)141 WebDocument::WebDocument(const PassRefPtr<Document>& elem)
142 : WebNode(elem)
143 {
144 }
145
operator =(const PassRefPtr<Document> & elem)146 WebDocument& WebDocument::operator=(const PassRefPtr<Document>& elem)
147 {
148 m_private = elem;
149 return *this;
150 }
151
operator PassRefPtr<Document>() const152 WebDocument::operator PassRefPtr<Document>() const
153 {
154 return static_cast<Document*>(m_private.get());
155 }
156
157 } // namespace WebKit
158