|
1 /* |
|
2 * Copyright (C) 2006, 2007 Apple, 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 |
|
6 * are met: |
|
7 * 1. Redistributions of source code must retain the above copyright |
|
8 * notice, this list of conditions and the following disclaimer. |
|
9 * 2. Redistributions in binary form must reproduce the above copyright |
|
10 * notice, this list of conditions and the following disclaimer in the |
|
11 * documentation and/or other materials provided with the distribution. |
|
12 * |
|
13 * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY |
|
14 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
|
15 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR |
|
16 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR |
|
17 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, |
|
18 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, |
|
19 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR |
|
20 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY |
|
21 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
|
22 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
|
23 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
|
24 */ |
|
25 |
|
26 #include "config.h" |
|
27 #include "WebKitDLL.h" |
|
28 #include "WebHTMLRepresentation.h" |
|
29 |
|
30 #include "DOMCore.h" |
|
31 #include "WebFrame.h" |
|
32 #include "WebKitStatisticsPrivate.h" |
|
33 #pragma warning(push, 0) |
|
34 #include <WebCore/HTMLInputElement.h> |
|
35 #pragma warning(pop) |
|
36 |
|
37 using namespace WebCore; |
|
38 |
|
39 // WebHTMLRepresentation ------------------------------------------------------ |
|
40 |
|
41 WebHTMLRepresentation::WebHTMLRepresentation() |
|
42 : m_refCount(0) |
|
43 , m_frame(0) |
|
44 { |
|
45 WebHTMLRepresentationCount++; |
|
46 gClassCount++; |
|
47 } |
|
48 |
|
49 WebHTMLRepresentation::~WebHTMLRepresentation() |
|
50 { |
|
51 if (m_frame) { |
|
52 m_frame->Release(); |
|
53 m_frame = 0; |
|
54 } |
|
55 |
|
56 WebHTMLRepresentationCount--; |
|
57 gClassCount--; |
|
58 } |
|
59 |
|
60 WebHTMLRepresentation* WebHTMLRepresentation::createInstance(WebFrame* frame) |
|
61 { |
|
62 WebHTMLRepresentation* instance = new WebHTMLRepresentation(); |
|
63 instance->m_frame = frame; |
|
64 frame->AddRef(); |
|
65 instance->AddRef(); |
|
66 return instance; |
|
67 } |
|
68 |
|
69 // IUnknown ------------------------------------------------------------------- |
|
70 |
|
71 HRESULT STDMETHODCALLTYPE WebHTMLRepresentation::QueryInterface(REFIID riid, void** ppvObject) |
|
72 { |
|
73 *ppvObject = 0; |
|
74 if (IsEqualGUID(riid, IID_IUnknown)) |
|
75 *ppvObject = static_cast<IWebHTMLRepresentation*>(this); |
|
76 else if (IsEqualGUID(riid, IID_IWebHTMLRepresentation)) |
|
77 *ppvObject = static_cast<IWebHTMLRepresentation*>(this); |
|
78 else if (IsEqualGUID(riid, IID_IWebDocumentRepresentation)) |
|
79 *ppvObject = static_cast<IWebDocumentRepresentation*>(this); |
|
80 else |
|
81 return E_NOINTERFACE; |
|
82 |
|
83 AddRef(); |
|
84 return S_OK; |
|
85 } |
|
86 |
|
87 ULONG STDMETHODCALLTYPE WebHTMLRepresentation::AddRef(void) |
|
88 { |
|
89 return ++m_refCount; |
|
90 } |
|
91 |
|
92 ULONG STDMETHODCALLTYPE WebHTMLRepresentation::Release(void) |
|
93 { |
|
94 ULONG newRef = --m_refCount; |
|
95 if (!newRef) |
|
96 delete(this); |
|
97 |
|
98 return newRef; |
|
99 } |
|
100 |
|
101 // IWebHTMLRepresentation -------------------------------------------------------------------- |
|
102 |
|
103 HRESULT STDMETHODCALLTYPE WebHTMLRepresentation::supportedMIMETypes( |
|
104 /* [out][in] */ BSTR* /*types*/, |
|
105 /* [out][in] */ int* /*cTypes*/) |
|
106 { |
|
107 ASSERT_NOT_REACHED(); |
|
108 return E_NOTIMPL; |
|
109 } |
|
110 |
|
111 HRESULT STDMETHODCALLTYPE WebHTMLRepresentation::supportedNonImageMIMETypes( |
|
112 /* [out][in] */ BSTR* /*types*/, |
|
113 /* [out][in] */ int* /*cTypes*/) |
|
114 { |
|
115 ASSERT_NOT_REACHED(); |
|
116 return E_NOTIMPL; |
|
117 } |
|
118 |
|
119 HRESULT STDMETHODCALLTYPE WebHTMLRepresentation::supportedImageMIMETypes( |
|
120 /* [out][in] */ BSTR* /*types*/, |
|
121 /* [out][in] */ int* /*cTypes*/) |
|
122 { |
|
123 ASSERT_NOT_REACHED(); |
|
124 return E_NOTIMPL; |
|
125 } |
|
126 |
|
127 HRESULT STDMETHODCALLTYPE WebHTMLRepresentation::attributedStringFromDOMNodes( |
|
128 /* [in] */ IDOMNode* /*startNode*/, |
|
129 /* [in] */ int /*startOffset*/, |
|
130 /* [in] */ IDOMNode* /*endNode*/, |
|
131 /* [in] */ int /*endOffset*/, |
|
132 /* [retval][out] */ IDataObject** /*attributedString*/) |
|
133 { |
|
134 ASSERT_NOT_REACHED(); |
|
135 return E_NOTIMPL; |
|
136 } |
|
137 |
|
138 HRESULT STDMETHODCALLTYPE WebHTMLRepresentation::elementWithName( |
|
139 /* [in] */ BSTR name, |
|
140 /* [in] */ IDOMElement* form, |
|
141 /* [retval][out] */ IDOMElement** element) |
|
142 { |
|
143 if (!m_frame) |
|
144 return E_FAIL; |
|
145 |
|
146 return m_frame->elementWithName(name, form, element); |
|
147 } |
|
148 |
|
149 HRESULT STDMETHODCALLTYPE WebHTMLRepresentation::elementDoesAutoComplete( |
|
150 /* [in] */ IDOMElement* element, |
|
151 /* [retval][out] */ BOOL* result) |
|
152 { |
|
153 bool doesAutoComplete; |
|
154 HRESULT hr = m_frame->elementDoesAutoComplete(element, &doesAutoComplete); |
|
155 *result = doesAutoComplete ? TRUE : FALSE; |
|
156 return hr; |
|
157 } |
|
158 |
|
159 HRESULT STDMETHODCALLTYPE WebHTMLRepresentation::elementIsPassword( |
|
160 /* [in] */ IDOMElement* element, |
|
161 /* [retval][out] */ BOOL* result) |
|
162 { |
|
163 bool isPassword; |
|
164 HRESULT hr = m_frame->elementIsPassword(element, &isPassword); |
|
165 *result = isPassword ? TRUE : FALSE; |
|
166 return hr; |
|
167 } |
|
168 |
|
169 HRESULT STDMETHODCALLTYPE WebHTMLRepresentation::formForElement( |
|
170 /* [in] */ IDOMElement* element, |
|
171 /* [retval][out] */ IDOMElement** form) |
|
172 { |
|
173 if (!m_frame) |
|
174 return E_FAIL; |
|
175 |
|
176 return m_frame->formForElement(element, form); |
|
177 } |
|
178 |
|
179 HRESULT STDMETHODCALLTYPE WebHTMLRepresentation::currentForm( |
|
180 /* [retval][out] */ IDOMElement** form) |
|
181 { |
|
182 if (!m_frame) |
|
183 return E_FAIL; |
|
184 |
|
185 return m_frame->currentForm(form); |
|
186 } |
|
187 |
|
188 HRESULT STDMETHODCALLTYPE WebHTMLRepresentation::controlsInForm( |
|
189 /* [in] */ IDOMElement* form, |
|
190 /* [out][in] */ IDOMElement** controls, |
|
191 /* [out][in] */ int* cControls) |
|
192 { |
|
193 return m_frame->controlsInForm(form, controls, cControls); |
|
194 } |
|
195 |
|
196 HRESULT STDMETHODCALLTYPE WebHTMLRepresentation::searchForLabels( |
|
197 /* [size_is][in] */ BSTR* labels, |
|
198 /* [in] */ int cLabels, |
|
199 /* [in] */ IDOMElement* beforeElement, |
|
200 /* [retval][out] */ BSTR* result) |
|
201 { |
|
202 return m_frame->searchForLabelsBeforeElement(labels, cLabels, beforeElement, result); |
|
203 } |
|
204 |
|
205 HRESULT STDMETHODCALLTYPE WebHTMLRepresentation::matchLabels( |
|
206 /* [size_is][in] */ BSTR* labels, |
|
207 /* [in] */ int cLabels, |
|
208 /* [in] */ IDOMElement* againstElement, |
|
209 /* [retval][out] */ BSTR* result) |
|
210 { |
|
211 return m_frame->matchLabelsAgainstElement(labels, cLabels, againstElement, result); |
|
212 } |
|
213 |
|
214 // IWebDocumentRepresentation ---------------------------------------------------------------- |
|
215 |
|
216 HRESULT STDMETHODCALLTYPE WebHTMLRepresentation::setDataSource( |
|
217 /* [in] */ IWebDataSource* /*dataSource*/) |
|
218 { |
|
219 ASSERT_NOT_REACHED(); |
|
220 return E_NOTIMPL; |
|
221 } |
|
222 |
|
223 HRESULT STDMETHODCALLTYPE WebHTMLRepresentation::receivedData( |
|
224 /* [in] */ IStream* /*data*/, |
|
225 /* [in] */ IWebDataSource* /*dataSource*/) |
|
226 { |
|
227 ASSERT_NOT_REACHED(); |
|
228 return E_NOTIMPL; |
|
229 } |
|
230 |
|
231 HRESULT STDMETHODCALLTYPE WebHTMLRepresentation::receivedError( |
|
232 /* [in] */ IWebError* /*error*/, |
|
233 /* [in] */ IWebDataSource* /*dataSource*/) |
|
234 { |
|
235 ASSERT_NOT_REACHED(); |
|
236 return E_NOTIMPL; |
|
237 } |
|
238 |
|
239 HRESULT STDMETHODCALLTYPE WebHTMLRepresentation::finishedLoadingWithDataSource( |
|
240 /* [in] */ IWebDataSource* /*dataSource*/) |
|
241 { |
|
242 ASSERT_NOT_REACHED(); |
|
243 return E_NOTIMPL; |
|
244 } |
|
245 |
|
246 HRESULT STDMETHODCALLTYPE WebHTMLRepresentation::canProvideDocumentSource( |
|
247 /* [retval][out] */ BOOL* result) |
|
248 { |
|
249 bool canProvideSource; |
|
250 HRESULT hr = this->m_frame->canProvideDocumentSource(&canProvideSource); |
|
251 *result = canProvideSource ? TRUE : FALSE; |
|
252 return hr; |
|
253 } |
|
254 |
|
255 HRESULT STDMETHODCALLTYPE WebHTMLRepresentation::documentSource( |
|
256 /* [retval][out] */ BSTR* /*source*/) |
|
257 { |
|
258 ASSERT_NOT_REACHED(); |
|
259 return E_NOTIMPL; |
|
260 } |
|
261 |
|
262 HRESULT STDMETHODCALLTYPE WebHTMLRepresentation::title( |
|
263 /* [retval][out] */ BSTR* /*docTitle*/) |
|
264 { |
|
265 ASSERT_NOT_REACHED(); |
|
266 return E_NOTIMPL; |
|
267 } |