ReactOS  0.4.15-dev-1201-gb2cf5a4
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 
21 typedef struct {
23 
24  IHTMLStyleElement IHTMLStyleElement_iface;
25 
27  IHTMLStyleSheet *style_sheet;
29 
30 static inline HTMLStyleElement *impl_from_IHTMLStyleElement(IHTMLStyleElement *iface)
31 {
32  return CONTAINING_RECORD(iface, HTMLStyleElement, IHTMLStyleElement_iface);
33 }
34 
35 static 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 
43 static ULONG WINAPI HTMLStyleElement_AddRef(IHTMLStyleElement *iface)
44 {
46 
47  return IHTMLDOMNode_AddRef(&This->element.node.IHTMLDOMNode_iface);
48 }
49 
50 static ULONG WINAPI HTMLStyleElement_Release(IHTMLStyleElement *iface)
51 {
53 
54  return IHTMLDOMNode_Release(&This->element.node.IHTMLDOMNode_iface);
55 }
56 
57 static HRESULT WINAPI HTMLStyleElement_GetTypeInfoCount(IHTMLStyleElement *iface, UINT *pctinfo)
58 {
60  return IDispatchEx_GetTypeInfoCount(&This->element.node.event_target.dispex.IDispatchEx_iface, pctinfo);
61 }
62 
63 static 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 
71 static 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 
79 static 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 
88 static 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 
107 static 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 
120 static 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 
141 static 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 
148 static HRESULT WINAPI HTMLStyleElement_get_onload(IHTMLStyleElement *iface, VARIANT *p)
149 {
151  FIXME("(%p)->(%p)\n", This, p);
152  return E_NOTIMPL;
153 }
154 
155 static 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 
162 static HRESULT WINAPI HTMLStyleElement_get_onerror(IHTMLStyleElement *iface, VARIANT *p)
163 {
165  FIXME("(%p)->(%p)\n", This, p);
166  return E_NOTIMPL;
167 }
168 
169 static 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 
199 static HRESULT WINAPI HTMLStyleElement_put_disabled(IHTMLStyleElement *iface, VARIANT_BOOL v)
200 {
202  FIXME("(%p)->(%x)\n", This, v);
203  return E_NOTIMPL;
204 }
205 
206 static HRESULT WINAPI HTMLStyleElement_get_disabled(IHTMLStyleElement *iface, VARIANT_BOOL *p)
207 {
209  FIXME("(%p)->(%p)\n", This, p);
210  return E_NOTIMPL;
211 }
212 
213 static 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 
232 static 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 
245 static const IHTMLStyleElementVtbl HTMLStyleElementVtbl = {
267 };
268 
270 {
271  return CONTAINING_RECORD(iface, HTMLStyleElement, element.node);
272 }
273 
275 {
277 
278  if(IsEqualGUID(&IID_IUnknown, riid)) {
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 
304  HTMLElement_destructor(iface);
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 }
static HTMLStyleElement * impl_from_IHTMLStyleElement(IHTMLStyleElement *iface)
Definition: htmlstyleelem.c:30
static const tid_t HTMLStyleElement_iface_tids[]
#define REFIID
Definition: guiddef.h:118
static ULONG WINAPI HTMLStyleElement_AddRef(IHTMLStyleElement *iface)
Definition: htmlstyleelem.c:43
HTMLElement element
Definition: htmlstyleelem.c:22
static const NodeImplVtbl HTMLStyleElementImplVtbl
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
REFIID riid
Definition: precomp.h:44
tid_t
Definition: ieframe.h:311
static HRESULT HTMLStyleElement_QI(HTMLDOMNode *iface, REFIID riid, void **ppv)
HRESULT HTMLElement_get_attr_col(HTMLDOMNode *iface, HTMLAttributeCollection **ac)
Definition: htmlelem.c:4827
REFIID LPVOID * ppv
Definition: atlbase.h:39
HRESULT HTMLElement_QI(HTMLDOMNode *iface, REFIID riid, void **ppv)
Definition: htmlelem.c:3738
#define assert(x)
Definition: debug.h:53
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_put_media(IHTMLStyleElement *iface, BSTR v)
DWORD LCID
Definition: nls.h:13
OLECHAR * BSTR
Definition: compat.h:2152
static LPOLESTR
Definition: stg_prop.c:27
#define E_FAIL
Definition: ddrawi.h:102
static HRESULT WINAPI HTMLStyleElement_put_onreadystatechange(IHTMLStyleElement *iface, VARIANT v)
short VARIANT_BOOL
Definition: compat.h:2149
static HRESULT WINAPI HTMLStyleElement_GetTypeInfoCount(IHTMLStyleElement *iface, UINT *pctinfo)
Definition: htmlstyleelem.c:57
#define NS_OK
#define HTMLELEMENT_TIDS
#define E_OUTOFMEMORY
Definition: ddrawi.h:100
#define debugstr_w
Definition: kernel32.h:32
static size_t elem
Definition: string.c:68
#define FIXME(fmt,...)
Definition: debug.h:111
smooth NULL
Definition: ftsmooth.c:416
HRESULT HTMLStyleElement_Create(HTMLDocumentNode *doc, nsIDOMHTMLElement *nselem, HTMLElement **elem)
static HRESULT WINAPI HTMLStyleElement_put_type(IHTMLStyleElement *iface, BSTR v)
Definition: htmlstyleelem.c:88
static HRESULT WINAPI HTMLStyleElement_get_media(IHTMLStyleElement *iface, BSTR *p)
static HRESULT WINAPI HTMLStyleElement_GetTypeInfo(IHTMLStyleElement *iface, UINT iTInfo, LCID lcid, ITypeInfo **ppTInfo)
Definition: htmlstyleelem.c:63
PFLT_MESSAGE_WAITER_QUEUE CONTAINING_RECORD(Csq, DEVICE_EXTENSION, IrpQueue)) -> WaiterQ.mLock) _IRQL_raises_(DISPATCH_LEVEL) VOID NTAPI FltpAcquireMessageWaiterLock(_In_ PIO_CSQ Csq, _Out_ PKIRQL Irql)
Definition: Messaging.c:560
static HRESULT WINAPI HTMLStyleElement_get_disabled(IHTMLStyleElement *iface, VARIANT_BOOL *p)
#define NS_FAILED(res)
HRESULT return_nsstr(nsresult, nsAString *, BSTR *) DECLSPEC_HIDDEN
Definition: nsembed.c:841
#define TRACE(s)
Definition: solgame.cpp:4
static const IHTMLStyleElementVtbl HTMLStyleElementVtbl
static HRESULT WINAPI HTMLStyleElement_get_onreadystatechange(IHTMLStyleElement *iface, VARIANT *p)
static ULONG WINAPI HTMLStyleElement_Release(IHTMLStyleElement *iface)
Definition: htmlstyleelem.c:50
LONG HRESULT
Definition: typedefs.h:79
IHTMLStyleSheet * HTMLStyleSheet_Create(nsIDOMStyleSheet *nsstylesheet)
const GUID IID_IUnknown
#define WINAPI
Definition: msvc.h:6
unsigned short WORD
Definition: ntddk_ex.h:93
void HTMLElement_destructor(HTMLDOMNode *iface)
Definition: htmlelem.c:3764
static void HTMLStyleElement_traverse(HTMLDOMNode *iface, nsCycleCollectionTraversalCallback *cb)
const GUID IID_IDispatch
static void HTMLStyleElement_unlink(HTMLDOMNode *iface)
int ret
static HRESULT WINAPI HTMLStyleElement_get_type(IHTMLStyleElement *iface, BSTR *p)
IHTMLStyleElement IHTMLStyleElement_iface
Definition: htmlstyleelem.c:24
void HTMLElement_Init(HTMLElement *This, HTMLDocumentNode *doc, nsIDOMHTMLElement *nselem, dispex_static_data_t *dispex_data)
Definition: htmlelem.c:4008
static void HTMLStyleElement_destructor(HTMLDOMNode *iface)
_In_ DWORD _Out_ _In_ WORD wFlags
Definition: wincon.h:534
#define ERR(fmt,...)
Definition: debug.h:110
static HRESULT WINAPI HTMLStyleElement_GetIDsOfNames(IHTMLStyleElement *iface, REFIID riid, LPOLESTR *rgszNames, UINT cNames, LCID lcid, DISPID *rgDispId)
Definition: htmlstyleelem.c:71
HRESULT HTMLElement_clone(HTMLDOMNode *iface, nsIDOMNode *nsnode, HTMLDOMNode **ret)
Definition: htmlelem.c:3793
static HRESULT WINAPI HTMLStyleElement_put_onerror(IHTMLStyleElement *iface, VARIANT v)
struct stdole::EXCEPINFO EXCEPINFO
static const char * debugstr_variant(const VARIANT *var)
Definition: container.c:46
static HRESULT WINAPI HTMLStyleElement_get_onerror(IHTMLStyleElement *iface, VARIANT *p)
#define S_OK
Definition: intsafe.h:51
static VARIANTARG static DISPID
Definition: ordinal.c:49
static HRESULT WINAPI HTMLStyleElement_get_onload(IHTMLStyleElement *iface, VARIANT *p)
const GLdouble * v
Definition: gl.h:2040
static HTMLStyleElement * impl_from_HTMLDOMNode(HTMLDOMNode *iface)
struct nsCycleCollectionTraversalCallback nsCycleCollectionTraversalCallback
IHTMLStyleSheet * style_sheet
Definition: htmlstyleelem.c:27
#define E_NOTIMPL
Definition: ddrawi.h:99
static HRESULT WINAPI HTMLStyleElement_put_disabled(IHTMLStyleElement *iface, VARIANT_BOOL v)
void nsAString_InitDepend(nsAString *, const PRUnichar *) DECLSPEC_HIDDEN
Definition: nsembed.c:826
unsigned int UINT
Definition: ndis.h:50
BOOL WINAPI IsEqualGUID(REFGUID rguid1, REFGUID rguid2)
Definition: compobj.c:4112
static HRESULT WINAPI HTMLStyleElement_get_styleSheet(IHTMLStyleElement *iface, IHTMLStyleSheet **p)
static HRESULT WINAPI HTMLStyleElement_put_onload(IHTMLStyleElement *iface, VARIANT v)
BOOL nsAString_Init(nsAString *, const PRUnichar *) DECLSPEC_HIDDEN
Definition: nsembed.c:817
static HRESULT WINAPI HTMLStyleElement_QueryInterface(IHTMLStyleElement *iface, REFIID riid, void **ppv)
Definition: htmlstyleelem.c:35
void nsAString_Finish(nsAString *) DECLSPEC_HIDDEN
Definition: nsembed.c:836
static HMODULE MODULEINFO DWORD cb
Definition: module.c:32
static dispex_static_data_t HTMLStyleElement_dispex
struct stdole::DISPPARAMS DISPPARAMS
HRESULT nsresult
Definition: nsiface.idl:39
unsigned int ULONG
Definition: retypes.h:1
GLfloat GLfloat p
Definition: glext.h:8902
#define ss
Definition: i386-dis.c:432
static HRESULT WINAPI HTMLStyleElement_get_readyState(IHTMLStyleElement *iface, BSTR *p)
nsIDOMHTMLStyleElement * nsstyle
Definition: htmlstyleelem.c:26