2010-11-12 12:31:24 +01:00
|
|
|
/*
|
|
|
|
* 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>
|
2012-06-28 11:19:51 +02:00
|
|
|
#include <assert.h>
|
2010-11-12 12:31:24 +01:00
|
|
|
|
|
|
|
#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;
|
|
|
|
|
2011-01-04 01:59:26 +01:00
|
|
|
IHTMLStyleElement IHTMLStyleElement_iface;
|
2010-12-17 03:39:24 +01:00
|
|
|
|
|
|
|
nsIDOMHTMLStyleElement *nsstyle;
|
2010-11-12 12:31:24 +01:00
|
|
|
} HTMLStyleElement;
|
|
|
|
|
2011-01-04 01:59:26 +01:00
|
|
|
static inline HTMLStyleElement *impl_from_IHTMLStyleElement(IHTMLStyleElement *iface)
|
|
|
|
{
|
|
|
|
return CONTAINING_RECORD(iface, HTMLStyleElement, IHTMLStyleElement_iface);
|
|
|
|
}
|
2010-11-12 12:31:24 +01:00
|
|
|
|
|
|
|
static HRESULT WINAPI HTMLStyleElement_QueryInterface(IHTMLStyleElement *iface,
|
|
|
|
REFIID riid, void **ppv)
|
|
|
|
{
|
2011-01-04 01:59:26 +01:00
|
|
|
HTMLStyleElement *This = impl_from_IHTMLStyleElement(iface);
|
2010-11-12 12:31:24 +01:00
|
|
|
|
2010-12-30 01:39:16 +01:00
|
|
|
return IHTMLDOMNode_QueryInterface(&This->element.node.IHTMLDOMNode_iface, riid, ppv);
|
2010-11-12 12:31:24 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
static ULONG WINAPI HTMLStyleElement_AddRef(IHTMLStyleElement *iface)
|
|
|
|
{
|
2011-01-04 01:59:26 +01:00
|
|
|
HTMLStyleElement *This = impl_from_IHTMLStyleElement(iface);
|
2010-11-12 12:31:24 +01:00
|
|
|
|
2010-12-30 01:39:16 +01:00
|
|
|
return IHTMLDOMNode_AddRef(&This->element.node.IHTMLDOMNode_iface);
|
2010-11-12 12:31:24 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
static ULONG WINAPI HTMLStyleElement_Release(IHTMLStyleElement *iface)
|
|
|
|
{
|
2011-01-04 01:59:26 +01:00
|
|
|
HTMLStyleElement *This = impl_from_IHTMLStyleElement(iface);
|
2010-11-12 12:31:24 +01:00
|
|
|
|
2010-12-30 01:39:16 +01:00
|
|
|
return IHTMLDOMNode_Release(&This->element.node.IHTMLDOMNode_iface);
|
2010-11-12 12:31:24 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI HTMLStyleElement_GetTypeInfoCount(IHTMLStyleElement *iface, UINT *pctinfo)
|
|
|
|
{
|
2011-01-04 01:59:26 +01:00
|
|
|
HTMLStyleElement *This = impl_from_IHTMLStyleElement(iface);
|
2010-12-31 11:07:33 +01:00
|
|
|
return IDispatchEx_GetTypeInfoCount(&This->element.node.dispex.IDispatchEx_iface, pctinfo);
|
2010-11-12 12:31:24 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI HTMLStyleElement_GetTypeInfo(IHTMLStyleElement *iface, UINT iTInfo,
|
|
|
|
LCID lcid, ITypeInfo **ppTInfo)
|
|
|
|
{
|
2011-01-04 01:59:26 +01:00
|
|
|
HTMLStyleElement *This = impl_from_IHTMLStyleElement(iface);
|
2010-12-31 11:07:33 +01:00
|
|
|
return IDispatchEx_GetTypeInfo(&This->element.node.dispex.IDispatchEx_iface, iTInfo, lcid,
|
|
|
|
ppTInfo);
|
2010-11-12 12:31:24 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI HTMLStyleElement_GetIDsOfNames(IHTMLStyleElement *iface, REFIID riid,
|
|
|
|
LPOLESTR *rgszNames, UINT cNames, LCID lcid, DISPID *rgDispId)
|
|
|
|
{
|
2011-01-04 01:59:26 +01:00
|
|
|
HTMLStyleElement *This = impl_from_IHTMLStyleElement(iface);
|
2010-12-31 11:07:33 +01:00
|
|
|
return IDispatchEx_GetIDsOfNames(&This->element.node.dispex.IDispatchEx_iface, riid, rgszNames,
|
|
|
|
cNames, lcid, rgDispId);
|
2010-11-12 12:31:24 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI HTMLStyleElement_Invoke(IHTMLStyleElement *iface, DISPID dispIdMember,
|
|
|
|
REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS *pDispParams,
|
|
|
|
VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr)
|
|
|
|
{
|
2011-01-04 01:59:26 +01:00
|
|
|
HTMLStyleElement *This = impl_from_IHTMLStyleElement(iface);
|
2010-12-31 11:07:33 +01:00
|
|
|
return IDispatchEx_Invoke(&This->element.node.dispex.IDispatchEx_iface, dispIdMember, riid,
|
|
|
|
lcid, wFlags, pDispParams, pVarResult, pExcepInfo, puArgErr);
|
2010-11-12 12:31:24 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI HTMLStyleElement_put_type(IHTMLStyleElement *iface, BSTR v)
|
|
|
|
{
|
2011-01-04 01:59:26 +01:00
|
|
|
HTMLStyleElement *This = impl_from_IHTMLStyleElement(iface);
|
2010-12-17 03:39:36 +01:00
|
|
|
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;
|
2010-11-12 12:31:24 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI HTMLStyleElement_get_type(IHTMLStyleElement *iface, BSTR *p)
|
|
|
|
{
|
2011-01-04 01:59:26 +01:00
|
|
|
HTMLStyleElement *This = impl_from_IHTMLStyleElement(iface);
|
2010-12-17 03:39:36 +01:00
|
|
|
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);
|
2010-11-12 12:31:24 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI HTMLStyleElement_get_readyState(IHTMLStyleElement *iface, BSTR *p)
|
|
|
|
{
|
2011-01-04 01:59:26 +01:00
|
|
|
HTMLStyleElement *This = impl_from_IHTMLStyleElement(iface);
|
2010-11-12 12:31:24 +01:00
|
|
|
FIXME("(%p)->(%p)\n", This, p);
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI HTMLStyleElement_put_onreadystatechange(IHTMLStyleElement *iface, VARIANT v)
|
|
|
|
{
|
2011-01-04 01:59:26 +01:00
|
|
|
HTMLStyleElement *This = impl_from_IHTMLStyleElement(iface);
|
2010-11-12 12:31:24 +01:00
|
|
|
FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI HTMLStyleElement_get_onreadystatechange(IHTMLStyleElement *iface, VARIANT *p)
|
|
|
|
{
|
2011-01-04 01:59:26 +01:00
|
|
|
HTMLStyleElement *This = impl_from_IHTMLStyleElement(iface);
|
2010-11-12 12:31:24 +01:00
|
|
|
FIXME("(%p)->(%p)\n", This, p);
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI HTMLStyleElement_put_onload(IHTMLStyleElement *iface, VARIANT v)
|
|
|
|
{
|
2011-01-04 01:59:26 +01:00
|
|
|
HTMLStyleElement *This = impl_from_IHTMLStyleElement(iface);
|
2010-11-12 12:31:24 +01:00
|
|
|
FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI HTMLStyleElement_get_onload(IHTMLStyleElement *iface, VARIANT *p)
|
|
|
|
{
|
2011-01-04 01:59:26 +01:00
|
|
|
HTMLStyleElement *This = impl_from_IHTMLStyleElement(iface);
|
2010-11-12 12:31:24 +01:00
|
|
|
FIXME("(%p)->(%p)\n", This, p);
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI HTMLStyleElement_put_onerror(IHTMLStyleElement *iface, VARIANT v)
|
|
|
|
{
|
2011-01-04 01:59:26 +01:00
|
|
|
HTMLStyleElement *This = impl_from_IHTMLStyleElement(iface);
|
2010-11-12 12:31:24 +01:00
|
|
|
FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI HTMLStyleElement_get_onerror(IHTMLStyleElement *iface, VARIANT *p)
|
|
|
|
{
|
2011-01-04 01:59:26 +01:00
|
|
|
HTMLStyleElement *This = impl_from_IHTMLStyleElement(iface);
|
2010-11-12 12:31:24 +01:00
|
|
|
FIXME("(%p)->(%p)\n", This, p);
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI HTMLStyleElement_get_styleSheet(IHTMLStyleElement *iface, IHTMLStyleSheet **p)
|
|
|
|
{
|
2011-01-04 01:59:26 +01:00
|
|
|
HTMLStyleElement *This = impl_from_IHTMLStyleElement(iface);
|
2010-11-12 12:31:24 +01:00
|
|
|
FIXME("(%p)->(%p)\n", This, p);
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI HTMLStyleElement_put_disabled(IHTMLStyleElement *iface, VARIANT_BOOL v)
|
|
|
|
{
|
2011-01-04 01:59:26 +01:00
|
|
|
HTMLStyleElement *This = impl_from_IHTMLStyleElement(iface);
|
2010-11-12 12:31:24 +01:00
|
|
|
FIXME("(%p)->(%x)\n", This, v);
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI HTMLStyleElement_get_disabled(IHTMLStyleElement *iface, VARIANT_BOOL *p)
|
|
|
|
{
|
2011-01-04 01:59:26 +01:00
|
|
|
HTMLStyleElement *This = impl_from_IHTMLStyleElement(iface);
|
2010-11-12 12:31:24 +01:00
|
|
|
FIXME("(%p)->(%p)\n", This, p);
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI HTMLStyleElement_put_media(IHTMLStyleElement *iface, BSTR v)
|
|
|
|
{
|
2011-01-04 01:59:26 +01:00
|
|
|
HTMLStyleElement *This = impl_from_IHTMLStyleElement(iface);
|
2010-12-17 03:39:24 +01:00
|
|
|
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;
|
2010-11-12 12:31:24 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI HTMLStyleElement_get_media(IHTMLStyleElement *iface, BSTR *p)
|
|
|
|
{
|
2011-01-04 01:59:26 +01:00
|
|
|
HTMLStyleElement *This = impl_from_IHTMLStyleElement(iface);
|
2010-12-17 03:39:24 +01:00
|
|
|
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);
|
2010-11-12 12:31:24 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
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
|
|
|
|
};
|
|
|
|
|
2010-12-27 20:13:09 +01:00
|
|
|
static inline HTMLStyleElement *impl_from_HTMLDOMNode(HTMLDOMNode *iface)
|
|
|
|
{
|
|
|
|
return CONTAINING_RECORD(iface, HTMLStyleElement, element.node);
|
|
|
|
}
|
2010-11-12 12:31:24 +01:00
|
|
|
|
|
|
|
static HRESULT HTMLStyleElement_QI(HTMLDOMNode *iface, REFIID riid, void **ppv)
|
|
|
|
{
|
2010-12-27 20:13:09 +01:00
|
|
|
HTMLStyleElement *This = impl_from_HTMLDOMNode(iface);
|
2010-11-12 12:31:24 +01:00
|
|
|
|
|
|
|
if(IsEqualGUID(&IID_IUnknown, riid)) {
|
|
|
|
TRACE("(%p)->(IID_IUnknown %p)\n", This, ppv);
|
2011-01-04 01:59:26 +01:00
|
|
|
*ppv = &This->IHTMLStyleElement_iface;
|
2010-11-12 12:31:24 +01:00
|
|
|
}else if(IsEqualGUID(&IID_IDispatch, riid)) {
|
|
|
|
TRACE("(%p)->(IID_IDispatch %p)\n", This, ppv);
|
2011-01-04 01:59:26 +01:00
|
|
|
*ppv = &This->IHTMLStyleElement_iface;
|
2010-11-12 12:31:24 +01:00
|
|
|
}else if(IsEqualGUID(&IID_IHTMLStyleElement, riid)) {
|
|
|
|
TRACE("(%p)->(IID_IHTMLStyleElement %p)\n", This, ppv);
|
2011-01-04 01:59:26 +01:00
|
|
|
*ppv = &This->IHTMLStyleElement_iface;
|
2010-11-12 12:31:24 +01:00
|
|
|
}else {
|
|
|
|
return HTMLElement_QI(&This->element.node, riid, ppv);
|
|
|
|
}
|
|
|
|
|
|
|
|
IUnknown_AddRef((IUnknown*)*ppv);
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
static const NodeImplVtbl HTMLStyleElementImplVtbl = {
|
|
|
|
HTMLStyleElement_QI,
|
2012-06-28 11:19:51 +02:00
|
|
|
HTMLElement_destructor,
|
2011-08-25 15:23:35 +02:00
|
|
|
HTMLElement_clone,
|
|
|
|
HTMLElement_get_attr_col
|
2010-11-12 12:31:24 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
static const tid_t HTMLStyleElement_iface_tids[] = {
|
|
|
|
HTMLELEMENT_TIDS,
|
|
|
|
IHTMLStyleElement_tid,
|
|
|
|
0
|
|
|
|
};
|
|
|
|
static dispex_static_data_t HTMLStyleElement_dispex = {
|
|
|
|
NULL,
|
|
|
|
DispHTMLStyleElement_tid,
|
|
|
|
NULL,
|
|
|
|
HTMLStyleElement_iface_tids
|
|
|
|
};
|
|
|
|
|
2010-12-01 22:43:14 +01:00
|
|
|
HRESULT HTMLStyleElement_Create(HTMLDocumentNode *doc, nsIDOMHTMLElement *nselem, HTMLElement **elem)
|
2010-11-12 12:31:24 +01:00
|
|
|
{
|
2010-12-01 22:43:14 +01:00
|
|
|
HTMLStyleElement *ret;
|
2010-12-17 03:39:24 +01:00
|
|
|
nsresult nsres;
|
2010-12-01 22:43:14 +01:00
|
|
|
|
|
|
|
ret = heap_alloc_zero(sizeof(*ret));
|
|
|
|
if(!ret)
|
|
|
|
return E_OUTOFMEMORY;
|
2010-11-12 12:31:24 +01:00
|
|
|
|
2011-01-04 01:59:26 +01:00
|
|
|
ret->IHTMLStyleElement_iface.lpVtbl = &HTMLStyleElementVtbl;
|
2010-11-12 12:31:24 +01:00
|
|
|
ret->element.node.vtbl = &HTMLStyleElementImplVtbl;
|
|
|
|
|
2012-06-28 11:19:51 +02:00
|
|
|
HTMLElement_Init(&ret->element, doc, nselem, &HTMLStyleElement_dispex);
|
|
|
|
|
2010-12-17 03:39:24 +01:00
|
|
|
nsres = nsIDOMHTMLElement_QueryInterface(nselem, &IID_nsIDOMHTMLStyleElement, (void**)&ret->nsstyle);
|
|
|
|
|
2012-06-28 11:19:51 +02:00
|
|
|
/* Share nsstyle reference with nsnode */
|
|
|
|
assert(nsres == NS_OK && (nsIDOMNode*)ret->nsstyle == ret->element.node.nsnode);
|
|
|
|
nsIDOMNode_Release(ret->element.node.nsnode);
|
|
|
|
|
2010-12-01 22:43:14 +01:00
|
|
|
*elem = &ret->element;
|
|
|
|
return S_OK;
|
2010-11-12 12:31:24 +01:00
|
|
|
}
|