ReactOS 0.4.15-dev-7674-gc0b4db1
htmlstyleelem.c
Go to the documentation of this file.
1/*
2 * Copyright 2010 Jacek Caban for CodeWeavers
3 *
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2.1 of the License, or (at your option) any later version.
8 *
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
13 *
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
17 */
18
19#include "mshtml_private.h"
20
21typedef struct {
23
24 IHTMLStyleElement IHTMLStyleElement_iface;
25
27 IHTMLStyleSheet *style_sheet;
29
30static inline HTMLStyleElement *impl_from_IHTMLStyleElement(IHTMLStyleElement *iface)
31{
32 return CONTAINING_RECORD(iface, HTMLStyleElement, IHTMLStyleElement_iface);
33}
34
35static HRESULT WINAPI HTMLStyleElement_QueryInterface(IHTMLStyleElement *iface,
36 REFIID riid, void **ppv)
37{
39
40 return IHTMLDOMNode_QueryInterface(&This->element.node.IHTMLDOMNode_iface, riid, ppv);
41}
42
43static ULONG WINAPI HTMLStyleElement_AddRef(IHTMLStyleElement *iface)
44{
46
47 return IHTMLDOMNode_AddRef(&This->element.node.IHTMLDOMNode_iface);
48}
49
50static ULONG WINAPI HTMLStyleElement_Release(IHTMLStyleElement *iface)
51{
53
54 return IHTMLDOMNode_Release(&This->element.node.IHTMLDOMNode_iface);
55}
56
57static HRESULT WINAPI HTMLStyleElement_GetTypeInfoCount(IHTMLStyleElement *iface, UINT *pctinfo)
58{
60 return IDispatchEx_GetTypeInfoCount(&This->element.node.event_target.dispex.IDispatchEx_iface, pctinfo);
61}
62
63static HRESULT WINAPI HTMLStyleElement_GetTypeInfo(IHTMLStyleElement *iface, UINT iTInfo,
64 LCID lcid, ITypeInfo **ppTInfo)
65{
67 return IDispatchEx_GetTypeInfo(&This->element.node.event_target.dispex.IDispatchEx_iface, iTInfo, lcid,
68 ppTInfo);
69}
70
71static HRESULT WINAPI HTMLStyleElement_GetIDsOfNames(IHTMLStyleElement *iface, REFIID riid,
72 LPOLESTR *rgszNames, UINT cNames, LCID lcid, DISPID *rgDispId)
73{
75 return IDispatchEx_GetIDsOfNames(&This->element.node.event_target.dispex.IDispatchEx_iface, riid, rgszNames,
76 cNames, lcid, rgDispId);
77}
78
79static HRESULT WINAPI HTMLStyleElement_Invoke(IHTMLStyleElement *iface, DISPID dispIdMember,
80 REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS *pDispParams,
81 VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr)
82{
84 return IDispatchEx_Invoke(&This->element.node.event_target.dispex.IDispatchEx_iface, dispIdMember, riid,
85 lcid, wFlags, pDispParams, pVarResult, pExcepInfo, puArgErr);
86}
87
88static HRESULT WINAPI HTMLStyleElement_put_type(IHTMLStyleElement *iface, BSTR v)
89{
91 nsAString type_str;
92 nsresult nsres;
93
94 TRACE("(%p)->(%s)\n", This, debugstr_w(v));
95
96 nsAString_InitDepend(&type_str, v);
97 nsres = nsIDOMHTMLStyleElement_SetType(This->nsstyle, &type_str);
98 nsAString_Finish(&type_str);
99 if(NS_FAILED(nsres)) {
100 ERR("SetType failed: %08x\n", nsres);
101 return E_FAIL;
102 }
103
104 return S_OK;
105}
106
107static HRESULT WINAPI HTMLStyleElement_get_type(IHTMLStyleElement *iface, BSTR *p)
108{
110 nsAString nsstr;
111 nsresult nsres;
112
113 TRACE("(%p)->(%p)\n", This, p);
114
115 nsAString_Init(&nsstr, NULL);
116 nsres = nsIDOMHTMLStyleElement_GetType(This->nsstyle, &nsstr);
117 return return_nsstr(nsres, &nsstr, p);
118}
119
120static HRESULT WINAPI HTMLStyleElement_get_readyState(IHTMLStyleElement *iface, BSTR *p)
121{
123 FIXME("(%p)->(%p)\n", This, p);
124 return E_NOTIMPL;
125}
126
128{
130 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
131 return E_NOTIMPL;
132}
133
135{
137 FIXME("(%p)->(%p)\n", This, p);
138 return E_NOTIMPL;
139}
140
141static HRESULT WINAPI HTMLStyleElement_put_onload(IHTMLStyleElement *iface, VARIANT v)
142{
144 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
145 return E_NOTIMPL;
146}
147
148static HRESULT WINAPI HTMLStyleElement_get_onload(IHTMLStyleElement *iface, VARIANT *p)
149{
151 FIXME("(%p)->(%p)\n", This, p);
152 return E_NOTIMPL;
153}
154
155static HRESULT WINAPI HTMLStyleElement_put_onerror(IHTMLStyleElement *iface, VARIANT v)
156{
158 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
159 return E_NOTIMPL;
160}
161
162static HRESULT WINAPI HTMLStyleElement_get_onerror(IHTMLStyleElement *iface, VARIANT *p)
163{
165 FIXME("(%p)->(%p)\n", This, p);
166 return E_NOTIMPL;
167}
168
169static HRESULT WINAPI HTMLStyleElement_get_styleSheet(IHTMLStyleElement *iface, IHTMLStyleSheet **p)
170{
172
173 TRACE("(%p)->(%p)\n", This, p);
174
175 if(!This->nsstyle)
176 return E_FAIL;
177
178 if(!This->style_sheet) {
180 nsresult nsres;
181
182 nsres = nsIDOMHTMLStyleElement_GetDOMStyleSheet(This->nsstyle, &ss);
183 assert(nsres == NS_OK);
184
185 if(ss) {
186 This->style_sheet = HTMLStyleSheet_Create(ss);
187 nsIDOMStyleSheet_Release(ss);
188 if(!This->style_sheet)
189 return E_OUTOFMEMORY;
190 }
191 }
192
193 if(This->style_sheet)
194 IHTMLStyleSheet_AddRef(This->style_sheet);
195 *p = This->style_sheet;
196 return S_OK;
197}
198
200{
202 FIXME("(%p)->(%x)\n", This, v);
203 return E_NOTIMPL;
204}
205
207{
209 FIXME("(%p)->(%p)\n", This, p);
210 return E_NOTIMPL;
211}
212
213static HRESULT WINAPI HTMLStyleElement_put_media(IHTMLStyleElement *iface, BSTR v)
214{
216 nsAString media_str;
217 nsresult nsres;
218
219 TRACE("(%p)->(%s)\n", This, debugstr_w(v));
220
221 nsAString_InitDepend(&media_str, v);
222 nsres = nsIDOMHTMLStyleElement_SetMedia(This->nsstyle, &media_str);
223 nsAString_Finish(&media_str);
224 if(NS_FAILED(nsres)) {
225 ERR("SetMedia failed: %08x\n", nsres);
226 return E_FAIL;
227 }
228
229 return S_OK;
230}
231
232static HRESULT WINAPI HTMLStyleElement_get_media(IHTMLStyleElement *iface, BSTR *p)
233{
235 nsAString nsstr;
236 nsresult nsres;
237
238 TRACE("(%p)->(%p)\n", This, p);
239
240 nsAString_Init(&nsstr, NULL);
241 nsres = nsIDOMHTMLStyleElement_GetMedia(This->nsstyle, &nsstr);
242 return return_nsstr(nsres, &nsstr, p);
243}
244
245static const IHTMLStyleElementVtbl HTMLStyleElementVtbl = {
267};
268
270{
271 return CONTAINING_RECORD(iface, HTMLStyleElement, element.node);
272}
273
275{
277
279 TRACE("(%p)->(IID_IUnknown %p)\n", This, ppv);
280 *ppv = &This->IHTMLStyleElement_iface;
281 }else if(IsEqualGUID(&IID_IDispatch, riid)) {
282 TRACE("(%p)->(IID_IDispatch %p)\n", This, ppv);
283 *ppv = &This->IHTMLStyleElement_iface;
284 }else if(IsEqualGUID(&IID_IHTMLStyleElement, riid)) {
285 TRACE("(%p)->(IID_IHTMLStyleElement %p)\n", This, ppv);
286 *ppv = &This->IHTMLStyleElement_iface;
287 }else {
288 return HTMLElement_QI(&This->element.node, riid, ppv);
289 }
290
291 IUnknown_AddRef((IUnknown*)*ppv);
292 return S_OK;
293}
294
296{
298
299 if(This->style_sheet) {
300 IHTMLStyleSheet_Release(This->style_sheet);
301 This->style_sheet = NULL;
302 }
303
305}
306
308{
310
311 if(This->nsstyle)
312 note_cc_edge((nsISupports*)This->nsstyle, "This->nsstyle", cb);
313}
314
316{
318
319 if(This->nsstyle) {
320 nsIDOMHTMLStyleElement *nsstyle = This->nsstyle;
321
322 This->nsstyle = NULL;
323 nsIDOMHTMLStyleElement_Release(nsstyle);
324 }
325}
326
334 NULL,
335 NULL,
336 NULL,
337 NULL,
338 NULL,
339 NULL,
340 NULL,
341 NULL,
342 NULL,
345};
346
349 IHTMLStyleElement_tid,
350 0
351};
353 NULL,
354 DispHTMLStyleElement_tid,
355 NULL,
357};
358
360{
362 nsresult nsres;
363
364 ret = heap_alloc_zero(sizeof(*ret));
365 if(!ret)
366 return E_OUTOFMEMORY;
367
368 ret->IHTMLStyleElement_iface.lpVtbl = &HTMLStyleElementVtbl;
369 ret->element.node.vtbl = &HTMLStyleElementImplVtbl;
370
371 HTMLElement_Init(&ret->element, doc, nselem, &HTMLStyleElement_dispex);
372
373 nsres = nsIDOMHTMLElement_QueryInterface(nselem, &IID_nsIDOMHTMLStyleElement, (void**)&ret->nsstyle);
374 assert(nsres == NS_OK);
375
376 *elem = &ret->element;
377 return S_OK;
378}
const GUID IID_IUnknown
#define FIXME(fmt,...)
Definition: debug.h:111
#define ERR(fmt,...)
Definition: debug.h:110
#define E_OUTOFMEMORY
Definition: ddrawi.h:100
#define E_NOTIMPL
Definition: ddrawi.h:99
#define E_FAIL
Definition: ddrawi.h:102
#define NULL
Definition: types.h:112
OLECHAR * BSTR
Definition: compat.h:2293
short VARIANT_BOOL
Definition: compat.h:2290
#define assert(x)
Definition: debug.h:53
unsigned short WORD
Definition: ntddk_ex.h:93
const GLdouble * v
Definition: gl.h:2040
GLfloat GLfloat p
Definition: glext.h:8902
HRESULT HTMLElement_clone(HTMLDOMNode *iface, nsIDOMNode *nsnode, HTMLDOMNode **ret)
Definition: htmlelem.c:3793
void HTMLElement_destructor(HTMLDOMNode *iface)
Definition: htmlelem.c:3764
HRESULT HTMLElement_handle_event(HTMLDOMNode *iface, DWORD eid, nsIDOMEvent *event, BOOL *prevent_default)
Definition: htmlelem.c:3815
const cpc_entry_t HTMLElement_cpc[]
Definition: htmlelem.c:3847
void HTMLElement_Init(HTMLElement *This, HTMLDocumentNode *doc, nsIDOMHTMLElement *nselem, dispex_static_data_t *dispex_data)
Definition: htmlelem.c:4008
HRESULT HTMLElement_get_attr_col(HTMLDOMNode *iface, HTMLAttributeCollection **ac)
Definition: htmlelem.c:4827
HRESULT HTMLElement_QI(HTMLDOMNode *iface, REFIID riid, void **ppv)
Definition: htmlelem.c:3738
static HRESULT WINAPI HTMLStyleElement_get_onload(IHTMLStyleElement *iface, VARIANT *p)
static HRESULT WINAPI HTMLStyleElement_get_onerror(IHTMLStyleElement *iface, VARIANT *p)
static HRESULT HTMLStyleElement_QI(HTMLDOMNode *iface, REFIID riid, void **ppv)
static HRESULT WINAPI HTMLStyleElement_get_media(IHTMLStyleElement *iface, BSTR *p)
static HRESULT WINAPI HTMLStyleElement_get_styleSheet(IHTMLStyleElement *iface, IHTMLStyleSheet **p)
static HRESULT WINAPI HTMLStyleElement_put_onreadystatechange(IHTMLStyleElement *iface, VARIANT v)
static HRESULT WINAPI HTMLStyleElement_get_type(IHTMLStyleElement *iface, BSTR *p)
static const tid_t HTMLStyleElement_iface_tids[]
static dispex_static_data_t HTMLStyleElement_dispex
static HRESULT WINAPI HTMLStyleElement_put_disabled(IHTMLStyleElement *iface, VARIANT_BOOL v)
static HRESULT WINAPI HTMLStyleElement_put_onerror(IHTMLStyleElement *iface, VARIANT v)
static void HTMLStyleElement_unlink(HTMLDOMNode *iface)
static HRESULT WINAPI HTMLStyleElement_put_onload(IHTMLStyleElement *iface, VARIANT v)
static HTMLStyleElement * impl_from_IHTMLStyleElement(IHTMLStyleElement *iface)
Definition: htmlstyleelem.c:30
static HRESULT WINAPI HTMLStyleElement_QueryInterface(IHTMLStyleElement *iface, REFIID riid, void **ppv)
Definition: htmlstyleelem.c:35
static HRESULT WINAPI HTMLStyleElement_get_onreadystatechange(IHTMLStyleElement *iface, VARIANT *p)
static HRESULT WINAPI HTMLStyleElement_put_type(IHTMLStyleElement *iface, BSTR v)
Definition: htmlstyleelem.c:88
static const IHTMLStyleElementVtbl HTMLStyleElementVtbl
static void HTMLStyleElement_traverse(HTMLDOMNode *iface, nsCycleCollectionTraversalCallback *cb)
static const NodeImplVtbl HTMLStyleElementImplVtbl
static ULONG WINAPI HTMLStyleElement_AddRef(IHTMLStyleElement *iface)
Definition: htmlstyleelem.c:43
static HRESULT WINAPI HTMLStyleElement_GetIDsOfNames(IHTMLStyleElement *iface, REFIID riid, LPOLESTR *rgszNames, UINT cNames, LCID lcid, DISPID *rgDispId)
Definition: htmlstyleelem.c:71
static HTMLStyleElement * impl_from_HTMLDOMNode(HTMLDOMNode *iface)
static HRESULT WINAPI HTMLStyleElement_get_readyState(IHTMLStyleElement *iface, BSTR *p)
static HRESULT WINAPI HTMLStyleElement_get_disabled(IHTMLStyleElement *iface, VARIANT_BOOL *p)
HRESULT HTMLStyleElement_Create(HTMLDocumentNode *doc, nsIDOMHTMLElement *nselem, HTMLElement **elem)
static ULONG WINAPI HTMLStyleElement_Release(IHTMLStyleElement *iface)
Definition: htmlstyleelem.c:50
static HRESULT WINAPI HTMLStyleElement_GetTypeInfoCount(IHTMLStyleElement *iface, UINT *pctinfo)
Definition: htmlstyleelem.c:57
static HRESULT WINAPI HTMLStyleElement_Invoke(IHTMLStyleElement *iface, DISPID dispIdMember, REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS *pDispParams, VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr)
Definition: htmlstyleelem.c:79
static HRESULT WINAPI HTMLStyleElement_GetTypeInfo(IHTMLStyleElement *iface, UINT iTInfo, LCID lcid, ITypeInfo **ppTInfo)
Definition: htmlstyleelem.c:63
static void HTMLStyleElement_destructor(HTMLDOMNode *iface)
static HRESULT WINAPI HTMLStyleElement_put_media(IHTMLStyleElement *iface, BSTR v)
IHTMLStyleSheet * HTMLStyleSheet_Create(nsIDOMStyleSheet *nsstylesheet)
#define ss
Definition: i386-dis.c:441
tid_t
Definition: ieframe.h:311
REFIID riid
Definition: atlbase.h:39
REFIID LPVOID * ppv
Definition: atlbase.h:39
#define S_OK
Definition: intsafe.h:52
#define debugstr_w
Definition: kernel32.h:32
static const char * debugstr_variant(const VARIANT *var)
Definition: container.c:46
static HMODULE MODULEINFO DWORD cb
Definition: module.c:33
static size_t elem
Definition: string.c:68
static LPOLESTR
Definition: stg_prop.c:27
static VARIANTARG static DISPID
Definition: ordinal.c:52
#define NS_OK
void nsAString_Finish(nsAString *) DECLSPEC_HIDDEN
Definition: nsembed.c:836
#define HTMLELEMENT_TIDS
void nsAString_InitDepend(nsAString *, const PRUnichar *) DECLSPEC_HIDDEN
Definition: nsembed.c:826
BOOL nsAString_Init(nsAString *, const PRUnichar *) DECLSPEC_HIDDEN
Definition: nsembed.c:817
struct nsCycleCollectionTraversalCallback nsCycleCollectionTraversalCallback
#define NS_FAILED(res)
HRESULT return_nsstr(nsresult, nsAString *, BSTR *) DECLSPEC_HIDDEN
Definition: nsembed.c:841
unsigned int UINT
Definition: ndis.h:50
const GUID IID_IDispatch
#define IsEqualGUID(rguid1, rguid2)
Definition: guiddef.h:147
#define REFIID
Definition: guiddef.h:118
DWORD LCID
Definition: nls.h:13
#define TRACE(s)
Definition: solgame.cpp:4
nsIDOMHTMLStyleElement * nsstyle
Definition: htmlstyleelem.c:26
HTMLElement element
Definition: htmlstyleelem.c:22
IHTMLStyleSheet * style_sheet
Definition: htmlstyleelem.c:27
IHTMLStyleElement IHTMLStyleElement_iface
Definition: htmlstyleelem.c:24
#define CONTAINING_RECORD(address, type, field)
Definition: typedefs.h:260
uint32_t ULONG
Definition: typedefs.h:59
int ret
_In_ DWORD _Out_ _In_ WORD wFlags
Definition: wincon.h:531
#define WINAPI
Definition: msvc.h:6