1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
/*
* Copyright 2010 Jacek Caban for CodeWeavers
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
*/
#include <stdarg.h>
#include <assert.h>
#define COBJMACROS
#include "windef.h"
#include "winbase.h"
#include "winuser.h"
#include "winreg.h"
#include "ole2.h"
#include "wine/debug.h"
#include "mshtml_private.h"
WINE_DEFAULT_DEBUG_CHANNEL(mshtml);
typedef struct {
HTMLElement element;
IHTMLStyleElement IHTMLStyleElement_iface;
nsIDOMHTMLStyleElement *nsstyle;
IHTMLStyleSheet *style_sheet;
} HTMLStyleElement;
static inline HTMLStyleElement *impl_from_IHTMLStyleElement(IHTMLStyleElement *iface)
{
return CONTAINING_RECORD(iface, HTMLStyleElement, IHTMLStyleElement_iface);
}
static HRESULT WINAPI HTMLStyleElement_QueryInterface(IHTMLStyleElement *iface,
REFIID riid, void **ppv)
{
HTMLStyleElement *This = impl_from_IHTMLStyleElement(iface);
return IHTMLDOMNode_QueryInterface(&This->element.node.IHTMLDOMNode_iface, riid, ppv);
}
static ULONG WINAPI HTMLStyleElement_AddRef(IHTMLStyleElement *iface)
{
HTMLStyleElement *This = impl_from_IHTMLStyleElement(iface);
return IHTMLDOMNode_AddRef(&This->element.node.IHTMLDOMNode_iface);
}
static ULONG WINAPI HTMLStyleElement_Release(IHTMLStyleElement *iface)
{
HTMLStyleElement *This = impl_from_IHTMLStyleElement(iface);
return IHTMLDOMNode_Release(&This->element.node.IHTMLDOMNode_iface);
}
static HRESULT WINAPI HTMLStyleElement_GetTypeInfoCount(IHTMLStyleElement *iface, UINT *pctinfo)
{
HTMLStyleElement *This = impl_from_IHTMLStyleElement(iface);
return IDispatchEx_GetTypeInfoCount(&This->element.node.event_target.dispex.IDispatchEx_iface, pctinfo);
}
static HRESULT WINAPI HTMLStyleElement_GetTypeInfo(IHTMLStyleElement *iface, UINT iTInfo,
LCID lcid, ITypeInfo **ppTInfo)
{
HTMLStyleElement *This = impl_from_IHTMLStyleElement(iface);
return IDispatchEx_GetTypeInfo(&This->element.node.event_target.dispex.IDispatchEx_iface, iTInfo, lcid,
ppTInfo);
}
static HRESULT WINAPI HTMLStyleElement_GetIDsOfNames(IHTMLStyleElement *iface, REFIID riid,
LPOLESTR *rgszNames, UINT cNames, LCID lcid, DISPID *rgDispId)
{
HTMLStyleElement *This = impl_from_IHTMLStyleElement(iface);
return IDispatchEx_GetIDsOfNames(&This->element.node.event_target.dispex.IDispatchEx_iface, riid, rgszNames,
cNames, lcid, rgDispId);
}
static HRESULT WINAPI HTMLStyleElement_Invoke(IHTMLStyleElement *iface, DISPID dispIdMember,
REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS *pDispParams,
VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr)
{
HTMLStyleElement *This = impl_from_IHTMLStyleElement(iface);
return IDispatchEx_Invoke(&This->element.node.event_target.dispex.IDispatchEx_iface, dispIdMember, riid,
lcid, wFlags, pDispParams, pVarResult, pExcepInfo, puArgErr);
}
static HRESULT WINAPI HTMLStyleElement_put_type(IHTMLStyleElement *iface, BSTR v)
{
HTMLStyleElement *This = impl_from_IHTMLStyleElement(iface);
nsAString type_str;
nsresult nsres;
TRACE("(%p)->(%s)\n", This, debugstr_w(v));
nsAString_InitDepend(&type_str, v);
nsres = nsIDOMHTMLStyleElement_SetType(This->nsstyle, &type_str);
nsAString_Finish(&type_str);
if(NS_FAILED(nsres)) {
ERR("SetType failed: %08x\n", nsres);
return E_FAIL;
}
return S_OK;
}
static HRESULT WINAPI HTMLStyleElement_get_type(IHTMLStyleElement *iface, BSTR *p)
{
HTMLStyleElement *This = impl_from_IHTMLStyleElement(iface);
nsAString nsstr;
nsresult nsres;
TRACE("(%p)->(%p)\n", This, p);
nsAString_Init(&nsstr, NULL);
nsres = nsIDOMHTMLStyleElement_GetType(This->nsstyle, &nsstr);
return return_nsstr(nsres, &nsstr, p);
}
static HRESULT WINAPI HTMLStyleElement_get_readyState(IHTMLStyleElement *iface, BSTR *p)
{
HTMLStyleElement *This = impl_from_IHTMLStyleElement(iface);
FIXME("(%p)->(%p)\n", This, p);
return E_NOTIMPL;
}
static HRESULT WINAPI HTMLStyleElement_put_onreadystatechange(IHTMLStyleElement *iface, VARIANT v)
{
HTMLStyleElement *This = impl_from_IHTMLStyleElement(iface);
FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
return E_NOTIMPL;
}
static HRESULT WINAPI HTMLStyleElement_get_onreadystatechange(IHTMLStyleElement *iface, VARIANT *p)
{
HTMLStyleElement *This = impl_from_IHTMLStyleElement(iface);
FIXME("(%p)->(%p)\n", This, p);
return E_NOTIMPL;
}
static HRESULT WINAPI HTMLStyleElement_put_onload(IHTMLStyleElement *iface, VARIANT v)
{
HTMLStyleElement *This = impl_from_IHTMLStyleElement(iface);
FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
return E_NOTIMPL;
}
static HRESULT WINAPI HTMLStyleElement_get_onload(IHTMLStyleElement *iface, VARIANT *p)
{
HTMLStyleElement *This = impl_from_IHTMLStyleElement(iface);
FIXME("(%p)->(%p)\n", This, p);
return E_NOTIMPL;
}
static HRESULT WINAPI HTMLStyleElement_put_onerror(IHTMLStyleElement *iface, VARIANT v)
{
HTMLStyleElement *This = impl_from_IHTMLStyleElement(iface);
FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
return E_NOTIMPL;
}
static HRESULT WINAPI HTMLStyleElement_get_onerror(IHTMLStyleElement *iface, VARIANT *p)
{
HTMLStyleElement *This = impl_from_IHTMLStyleElement(iface);
FIXME("(%p)->(%p)\n", This, p);
return E_NOTIMPL;
}
static HRESULT WINAPI HTMLStyleElement_get_styleSheet(IHTMLStyleElement *iface, IHTMLStyleSheet **p)
{
HTMLStyleElement *This = impl_from_IHTMLStyleElement(iface);
TRACE("(%p)->(%p)\n", This, p);
if(!This->nsstyle)
return E_FAIL;
if(!This->style_sheet) {
nsIDOMStyleSheet *ss;
nsresult nsres;
nsres = nsIDOMHTMLStyleElement_GetDOMStyleSheet(This->nsstyle, &ss);
assert(nsres == NS_OK);
if(ss) {
This->style_sheet = HTMLStyleSheet_Create(ss);
nsIDOMStyleSheet_Release(ss);
if(!This->style_sheet)
return E_OUTOFMEMORY;
}
}
if(This->style_sheet)
IHTMLStyleSheet_AddRef(This->style_sheet);
*p = This->style_sheet;
return S_OK;
}
static HRESULT WINAPI HTMLStyleElement_put_disabled(IHTMLStyleElement *iface, VARIANT_BOOL v)
{
HTMLStyleElement *This = impl_from_IHTMLStyleElement(iface);
FIXME("(%p)->(%x)\n", This, v);
return E_NOTIMPL;
}
static HRESULT WINAPI HTMLStyleElement_get_disabled(IHTMLStyleElement *iface, VARIANT_BOOL *p)
{
HTMLStyleElement *This = impl_from_IHTMLStyleElement(iface);
FIXME("(%p)->(%p)\n", This, p);
return E_NOTIMPL;
}
static HRESULT WINAPI HTMLStyleElement_put_media(IHTMLStyleElement *iface, BSTR v)
{
HTMLStyleElement *This = impl_from_IHTMLStyleElement(iface);
nsAString media_str;
nsresult nsres;
TRACE("(%p)->(%s)\n", This, debugstr_w(v));
nsAString_InitDepend(&media_str, v);
nsres = nsIDOMHTMLStyleElement_SetMedia(This->nsstyle, &media_str);
nsAString_Finish(&media_str);
if(NS_FAILED(nsres)) {
ERR("SetMedia failed: %08x\n", nsres);
return E_FAIL;
}
return S_OK;
}
static HRESULT WINAPI HTMLStyleElement_get_media(IHTMLStyleElement *iface, BSTR *p)
{
HTMLStyleElement *This = impl_from_IHTMLStyleElement(iface);
nsAString nsstr;
nsresult nsres;
TRACE("(%p)->(%p)\n", This, p);
nsAString_Init(&nsstr, NULL);
nsres = nsIDOMHTMLStyleElement_GetMedia(This->nsstyle, &nsstr);
return return_nsstr(nsres, &nsstr, p);
}
static const IHTMLStyleElementVtbl HTMLStyleElementVtbl = {
HTMLStyleElement_QueryInterface,
HTMLStyleElement_AddRef,
HTMLStyleElement_Release,
HTMLStyleElement_GetTypeInfoCount,
HTMLStyleElement_GetTypeInfo,
HTMLStyleElement_GetIDsOfNames,
HTMLStyleElement_Invoke,
HTMLStyleElement_put_type,
HTMLStyleElement_get_type,
HTMLStyleElement_get_readyState,
HTMLStyleElement_put_onreadystatechange,
HTMLStyleElement_get_onreadystatechange,
HTMLStyleElement_put_onload,
HTMLStyleElement_get_onload,
HTMLStyleElement_put_onerror,
HTMLStyleElement_get_onerror,
HTMLStyleElement_get_styleSheet,
HTMLStyleElement_put_disabled,
HTMLStyleElement_get_disabled,
HTMLStyleElement_put_media,
HTMLStyleElement_get_media
};
static inline HTMLStyleElement *impl_from_HTMLDOMNode(HTMLDOMNode *iface)
{
return CONTAINING_RECORD(iface, HTMLStyleElement, element.node);
}
static HRESULT HTMLStyleElement_QI(HTMLDOMNode *iface, REFIID riid, void **ppv)
{
HTMLStyleElement *This = impl_from_HTMLDOMNode(iface);
if(IsEqualGUID(&IID_IUnknown, riid)) {
TRACE("(%p)->(IID_IUnknown %p)\n", This, ppv);
*ppv = &This->IHTMLStyleElement_iface;
}else if(IsEqualGUID(&IID_IDispatch, riid)) {
TRACE("(%p)->(IID_IDispatch %p)\n", This, ppv);
*ppv = &This->IHTMLStyleElement_iface;
}else if(IsEqualGUID(&IID_IHTMLStyleElement, riid)) {
TRACE("(%p)->(IID_IHTMLStyleElement %p)\n", This, ppv);
*ppv = &This->IHTMLStyleElement_iface;
}else {
return HTMLElement_QI(&This->element.node, riid, ppv);
}
IUnknown_AddRef((IUnknown*)*ppv);
return S_OK;
}
static void HTMLStyleElement_destructor(HTMLDOMNode *iface)
{
HTMLStyleElement *This = impl_from_HTMLDOMNode(iface);
if(This->style_sheet) {
IHTMLStyleSheet_Release(This->style_sheet);
This->style_sheet = NULL;
}
HTMLElement_destructor(iface);
}
static void HTMLStyleElement_traverse(HTMLDOMNode *iface, nsCycleCollectionTraversalCallback *cb)
{
HTMLStyleElement *This = impl_from_HTMLDOMNode(iface);
if(This->nsstyle)
note_cc_edge((nsISupports*)This->nsstyle, "This->nsstyle", cb);
}
static void HTMLStyleElement_unlink(HTMLDOMNode *iface)
{
HTMLStyleElement *This = impl_from_HTMLDOMNode(iface);
if(This->nsstyle) {
nsIDOMHTMLStyleElement *nsstyle = This->nsstyle;
This->nsstyle = NULL;
nsIDOMHTMLStyleElement_Release(nsstyle);
}
}
static const NodeImplVtbl HTMLStyleElementImplVtbl = {
HTMLStyleElement_QI,
HTMLStyleElement_destructor,
HTMLElement_cpc,
HTMLElement_clone,
HTMLElement_handle_event,
HTMLElement_get_attr_col,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
HTMLStyleElement_traverse,
HTMLStyleElement_unlink
};
static const tid_t HTMLStyleElement_iface_tids[] = {
HTMLELEMENT_TIDS,
IHTMLStyleElement_tid,
0
};
static dispex_static_data_t HTMLStyleElement_dispex = {
NULL,
DispHTMLStyleElement_tid,
HTMLStyleElement_iface_tids,
HTMLElement_init_dispex_info
};
HRESULT HTMLStyleElement_Create(HTMLDocumentNode *doc, nsIDOMHTMLElement *nselem, HTMLElement **elem)
{
HTMLStyleElement *ret;
nsresult nsres;
ret = heap_alloc_zero(sizeof(*ret));
if(!ret)
return E_OUTOFMEMORY;
ret->IHTMLStyleElement_iface.lpVtbl = &HTMLStyleElementVtbl;
ret->element.node.vtbl = &HTMLStyleElementImplVtbl;
HTMLElement_Init(&ret->element, doc, nselem, &HTMLStyleElement_dispex);
nsres = nsIDOMHTMLElement_QueryInterface(nselem, &IID_nsIDOMHTMLStyleElement, (void**)&ret->nsstyle);
assert(nsres == NS_OK);
*elem = &ret->element;
return S_OK;
}