2006-11-17 13:08:09 +01:00
|
|
|
/*
|
|
|
|
* Copyright 2006 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>
|
|
|
|
|
|
|
|
#define COBJMACROS
|
|
|
|
|
|
|
|
#include "windef.h"
|
|
|
|
#include "winbase.h"
|
|
|
|
#include "winuser.h"
|
|
|
|
#include "ole2.h"
|
|
|
|
|
|
|
|
#include "wine/debug.h"
|
|
|
|
|
|
|
|
#include "mshtml_private.h"
|
|
|
|
|
|
|
|
WINE_DEFAULT_DEBUG_CHANNEL(mshtml);
|
|
|
|
|
2009-02-02 11:18:46 +01:00
|
|
|
struct HTMLStyleSheet {
|
2013-08-19 12:12:11 +02:00
|
|
|
DispatchEx dispex;
|
2011-01-04 01:50:04 +01:00
|
|
|
IHTMLStyleSheet IHTMLStyleSheet_iface;
|
2021-04-07 00:24:13 +02:00
|
|
|
IHTMLStyleSheet4 IHTMLStyleSheet4_iface;
|
2007-11-25 19:08:40 +01:00
|
|
|
|
2006-11-17 13:08:09 +01:00
|
|
|
LONG ref;
|
2007-11-25 19:08:40 +01:00
|
|
|
|
|
|
|
nsIDOMCSSStyleSheet *nsstylesheet;
|
2009-02-02 11:18:46 +01:00
|
|
|
};
|
2006-11-17 13:08:09 +01:00
|
|
|
|
2009-02-02 11:18:46 +01:00
|
|
|
struct HTMLStyleSheetsCollection {
|
2010-11-08 12:48:44 +01:00
|
|
|
DispatchEx dispex;
|
2011-01-04 01:50:04 +01:00
|
|
|
IHTMLStyleSheetsCollection IHTMLStyleSheetsCollection_iface;
|
2007-09-19 13:09:35 +02:00
|
|
|
|
|
|
|
LONG ref;
|
|
|
|
|
|
|
|
nsIDOMStyleSheetList *nslist;
|
2009-02-02 11:18:46 +01:00
|
|
|
};
|
2007-09-19 13:09:35 +02:00
|
|
|
|
2009-08-05 11:44:25 +02:00
|
|
|
struct HTMLStyleSheetRulesCollection {
|
2014-05-09 14:05:21 +02:00
|
|
|
DispatchEx dispex;
|
2011-01-04 01:50:04 +01:00
|
|
|
IHTMLStyleSheetRulesCollection IHTMLStyleSheetRulesCollection_iface;
|
2007-12-06 12:22:30 +01:00
|
|
|
|
|
|
|
LONG ref;
|
|
|
|
|
|
|
|
nsIDOMCSSRuleList *nslist;
|
2009-08-05 11:44:25 +02:00
|
|
|
};
|
2007-12-06 12:22:30 +01:00
|
|
|
|
2019-05-07 14:45:11 +02:00
|
|
|
struct HTMLStyleSheetRule {
|
|
|
|
DispatchEx dispex;
|
|
|
|
IHTMLStyleSheetRule IHTMLStyleSheetRule_iface;
|
|
|
|
|
|
|
|
LONG ref;
|
|
|
|
|
|
|
|
nsIDOMCSSRule *nsstylesheetrule;
|
|
|
|
};
|
|
|
|
|
|
|
|
static inline HTMLStyleSheetRule *impl_from_IHTMLStyleSheetRule(IHTMLStyleSheetRule *iface)
|
|
|
|
{
|
|
|
|
return CONTAINING_RECORD(iface, HTMLStyleSheetRule, IHTMLStyleSheetRule_iface);
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI HTMLStyleSheetRule_QueryInterface(IHTMLStyleSheetRule *iface,
|
|
|
|
REFIID riid, void **ppv)
|
|
|
|
{
|
|
|
|
HTMLStyleSheetRule *This = impl_from_IHTMLStyleSheetRule(iface);
|
|
|
|
|
|
|
|
TRACE("(%p)->(%s %p)\n", This, debugstr_mshtml_guid(riid), ppv);
|
|
|
|
|
|
|
|
if (IsEqualGUID(&IID_IUnknown, riid))
|
|
|
|
*ppv = &This->IHTMLStyleSheetRule_iface;
|
|
|
|
else if (IsEqualGUID(&IID_IHTMLStyleSheetRule, riid))
|
|
|
|
*ppv = &This->IHTMLStyleSheetRule_iface;
|
|
|
|
else if (dispex_query_interface(&This->dispex, riid, ppv))
|
|
|
|
return *ppv ? S_OK : E_NOINTERFACE;
|
|
|
|
else
|
|
|
|
{
|
|
|
|
*ppv = NULL;
|
|
|
|
FIXME("(%p)->(%s %p)\n", This, debugstr_mshtml_guid(riid), ppv);
|
|
|
|
return E_NOINTERFACE;
|
|
|
|
}
|
|
|
|
|
|
|
|
IUnknown_AddRef((IUnknown *)*ppv);
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
static ULONG WINAPI HTMLStyleSheetRule_AddRef(IHTMLStyleSheetRule *iface)
|
|
|
|
{
|
|
|
|
HTMLStyleSheetRule *This = impl_from_IHTMLStyleSheetRule(iface);
|
|
|
|
LONG ref = InterlockedIncrement(&This->ref);
|
|
|
|
|
|
|
|
TRACE("(%p) ref=%d\n", This, ref);
|
|
|
|
|
|
|
|
return ref;
|
|
|
|
}
|
|
|
|
|
|
|
|
static ULONG WINAPI HTMLStyleSheetRule_Release(IHTMLStyleSheetRule *iface)
|
|
|
|
{
|
|
|
|
HTMLStyleSheetRule *This = impl_from_IHTMLStyleSheetRule(iface);
|
|
|
|
LONG ref = InterlockedDecrement(&This->ref);
|
|
|
|
|
|
|
|
TRACE("(%p) ref=%d\n", This, ref);
|
|
|
|
|
|
|
|
if(!ref) {
|
|
|
|
release_dispex(&This->dispex);
|
|
|
|
if(This->nsstylesheetrule)
|
|
|
|
nsIDOMCSSRule_Release(This->nsstylesheetrule);
|
|
|
|
heap_free(This);
|
|
|
|
}
|
|
|
|
|
|
|
|
return ref;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI HTMLStyleSheetRule_GetTypeInfoCount(
|
|
|
|
IHTMLStyleSheetRule *iface, UINT *pctinfo)
|
|
|
|
{
|
|
|
|
HTMLStyleSheetRule *This = impl_from_IHTMLStyleSheetRule(iface);
|
|
|
|
return IDispatchEx_GetTypeInfoCount(&This->dispex.IDispatchEx_iface, pctinfo);
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI HTMLStyleSheetRule_GetTypeInfo(IHTMLStyleSheetRule *iface,
|
|
|
|
UINT iTInfo, LCID lcid, ITypeInfo **ppTInfo)
|
|
|
|
{
|
|
|
|
HTMLStyleSheetRule *This = impl_from_IHTMLStyleSheetRule(iface);
|
|
|
|
return IDispatchEx_GetTypeInfo(&This->dispex.IDispatchEx_iface, iTInfo, lcid, ppTInfo);
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI HTMLStyleSheetRule_GetIDsOfNames(IHTMLStyleSheetRule *iface,
|
|
|
|
REFIID riid, LPOLESTR *rgszNames, UINT cNames, LCID lcid, DISPID *rgDispId)
|
|
|
|
{
|
|
|
|
HTMLStyleSheetRule *This = impl_from_IHTMLStyleSheetRule(iface);
|
|
|
|
return IDispatchEx_GetIDsOfNames(&This->dispex.IDispatchEx_iface, riid, rgszNames, cNames,
|
|
|
|
lcid, rgDispId);
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI HTMLStyleSheetRule_Invoke(IHTMLStyleSheetRule *iface,
|
|
|
|
DISPID dispIdMember, REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS *pDispParams,
|
|
|
|
VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr)
|
|
|
|
{
|
|
|
|
HTMLStyleSheetRule *This = impl_from_IHTMLStyleSheetRule(iface);
|
|
|
|
return IDispatchEx_Invoke(&This->dispex.IDispatchEx_iface, dispIdMember, riid, lcid, wFlags,
|
|
|
|
pDispParams, pVarResult, pExcepInfo, puArgErr);
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI HTMLStyleSheetRule_put_selectorText(IHTMLStyleSheetRule *iface, BSTR v)
|
|
|
|
{
|
|
|
|
HTMLStyleSheetRule *This = impl_from_IHTMLStyleSheetRule(iface);
|
|
|
|
FIXME("(%p)->(%s)\n", This, debugstr_w(v));
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI HTMLStyleSheetRule_get_selectorText(IHTMLStyleSheetRule *iface, BSTR *p)
|
|
|
|
{
|
|
|
|
HTMLStyleSheetRule *This = impl_from_IHTMLStyleSheetRule(iface);
|
|
|
|
FIXME("(%p)->(%p)\n", This, p);
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI HTMLStyleSheetRule_get_style(IHTMLStyleSheetRule *iface, IHTMLRuleStyle **p)
|
|
|
|
{
|
|
|
|
HTMLStyleSheetRule *This = impl_from_IHTMLStyleSheetRule(iface);
|
|
|
|
FIXME("(%p)->(%p)\n", This, p);
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI HTMLStyleSheetRule_get_readOnly(IHTMLStyleSheetRule *iface, VARIANT_BOOL *p)
|
|
|
|
{
|
|
|
|
HTMLStyleSheetRule *This = impl_from_IHTMLStyleSheetRule(iface);
|
|
|
|
FIXME("(%p)->(%p)\n", This, p);
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static const IHTMLStyleSheetRuleVtbl HTMLStyleSheetRuleVtbl = {
|
|
|
|
HTMLStyleSheetRule_QueryInterface,
|
|
|
|
HTMLStyleSheetRule_AddRef,
|
|
|
|
HTMLStyleSheetRule_Release,
|
|
|
|
HTMLStyleSheetRule_GetTypeInfoCount,
|
|
|
|
HTMLStyleSheetRule_GetTypeInfo,
|
|
|
|
HTMLStyleSheetRule_GetIDsOfNames,
|
|
|
|
HTMLStyleSheetRule_Invoke,
|
|
|
|
HTMLStyleSheetRule_put_selectorText,
|
|
|
|
HTMLStyleSheetRule_get_selectorText,
|
|
|
|
HTMLStyleSheetRule_get_style,
|
|
|
|
HTMLStyleSheetRule_get_readOnly
|
|
|
|
};
|
|
|
|
|
|
|
|
static const tid_t HTMLStyleSheetRule_iface_tids[] = {
|
|
|
|
IHTMLStyleSheetRule_tid,
|
|
|
|
0
|
|
|
|
};
|
|
|
|
static dispex_static_data_t HTMLStyleSheetRule_dispex = {
|
2021-10-06 17:11:31 +02:00
|
|
|
L"CSSStyleRule",
|
2019-05-07 14:45:11 +02:00
|
|
|
NULL,
|
|
|
|
DispHTMLStyleSheetRule_tid,
|
|
|
|
HTMLStyleSheetRule_iface_tids
|
|
|
|
};
|
|
|
|
|
2021-03-15 16:18:31 +01:00
|
|
|
static HRESULT create_style_sheet_rule(nsIDOMCSSRule *nsstylesheetrule, compat_mode_t compat_mode,
|
|
|
|
IHTMLStyleSheetRule **ret)
|
2019-05-07 14:45:11 +02:00
|
|
|
{
|
2021-03-15 16:18:31 +01:00
|
|
|
HTMLStyleSheetRule *rule;
|
2019-05-07 14:45:11 +02:00
|
|
|
nsresult nsres;
|
|
|
|
|
2021-03-15 16:18:31 +01:00
|
|
|
if(!(rule = heap_alloc(sizeof(*rule))))
|
|
|
|
return E_OUTOFMEMORY;
|
2019-05-07 14:45:11 +02:00
|
|
|
|
2021-03-15 16:18:31 +01:00
|
|
|
rule->IHTMLStyleSheetRule_iface.lpVtbl = &HTMLStyleSheetRuleVtbl;
|
|
|
|
rule->ref = 1;
|
|
|
|
rule->nsstylesheetrule = NULL;
|
2019-05-07 14:45:11 +02:00
|
|
|
|
2021-03-16 19:57:45 +01:00
|
|
|
init_dispatch(&rule->dispex, (IUnknown *)&rule->IHTMLStyleSheetRule_iface, &HTMLStyleSheetRule_dispex,
|
|
|
|
compat_mode);
|
2019-05-07 14:45:11 +02:00
|
|
|
|
|
|
|
if (nsstylesheetrule)
|
|
|
|
{
|
|
|
|
nsres = nsIDOMCSSRule_QueryInterface(nsstylesheetrule, &IID_nsIDOMCSSRule,
|
2021-03-15 16:18:31 +01:00
|
|
|
(void **)&rule->nsstylesheetrule);
|
2019-05-07 14:45:11 +02:00
|
|
|
if (NS_FAILED(nsres))
|
|
|
|
ERR("Could not get nsIDOMCSSRule interface: %08x\n", nsres);
|
|
|
|
}
|
|
|
|
|
2021-03-15 16:18:31 +01:00
|
|
|
*ret = &rule->IHTMLStyleSheetRule_iface;
|
|
|
|
return S_OK;
|
2019-05-07 14:45:11 +02:00
|
|
|
}
|
|
|
|
|
2011-01-04 01:50:04 +01:00
|
|
|
static inline HTMLStyleSheetRulesCollection *impl_from_IHTMLStyleSheetRulesCollection(IHTMLStyleSheetRulesCollection *iface)
|
|
|
|
{
|
|
|
|
return CONTAINING_RECORD(iface, HTMLStyleSheetRulesCollection, IHTMLStyleSheetRulesCollection_iface);
|
|
|
|
}
|
2007-12-06 12:22:30 +01:00
|
|
|
|
|
|
|
static HRESULT WINAPI HTMLStyleSheetRulesCollection_QueryInterface(IHTMLStyleSheetRulesCollection *iface,
|
|
|
|
REFIID riid, void **ppv)
|
|
|
|
{
|
2011-01-04 01:50:04 +01:00
|
|
|
HTMLStyleSheetRulesCollection *This = impl_from_IHTMLStyleSheetRulesCollection(iface);
|
2007-12-06 12:22:30 +01:00
|
|
|
|
2014-05-13 18:56:30 +02:00
|
|
|
TRACE("(%p)->(%s %p)\n", This, debugstr_mshtml_guid(riid), ppv);
|
|
|
|
|
2007-12-06 12:22:30 +01:00
|
|
|
if(IsEqualGUID(&IID_IUnknown, riid)) {
|
2011-01-04 01:50:04 +01:00
|
|
|
*ppv = &This->IHTMLStyleSheetRulesCollection_iface;
|
2007-12-06 12:22:30 +01:00
|
|
|
}else if(IsEqualGUID(&IID_IHTMLStyleSheetRulesCollection, riid)) {
|
2011-01-04 01:50:04 +01:00
|
|
|
*ppv = &This->IHTMLStyleSheetRulesCollection_iface;
|
2014-05-09 14:05:21 +02:00
|
|
|
}else if(dispex_query_interface(&This->dispex, riid, ppv)) {
|
|
|
|
return *ppv ? S_OK : E_NOINTERFACE;
|
|
|
|
}else {
|
|
|
|
*ppv = NULL;
|
2014-05-13 18:56:30 +02:00
|
|
|
FIXME("(%p)->(%s %p)\n", This, debugstr_mshtml_guid(riid), ppv);
|
2014-05-09 14:05:21 +02:00
|
|
|
return E_NOINTERFACE;
|
2007-12-06 12:22:30 +01:00
|
|
|
}
|
|
|
|
|
2014-05-09 14:05:21 +02:00
|
|
|
IUnknown_AddRef((IUnknown*)*ppv);
|
|
|
|
return S_OK;
|
2007-12-06 12:22:30 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
static ULONG WINAPI HTMLStyleSheetRulesCollection_AddRef(IHTMLStyleSheetRulesCollection *iface)
|
|
|
|
{
|
2011-01-04 01:50:04 +01:00
|
|
|
HTMLStyleSheetRulesCollection *This = impl_from_IHTMLStyleSheetRulesCollection(iface);
|
2007-12-06 12:22:30 +01:00
|
|
|
LONG ref = InterlockedIncrement(&This->ref);
|
|
|
|
|
|
|
|
TRACE("(%p) ref=%d\n", This, ref);
|
|
|
|
|
|
|
|
return ref;
|
|
|
|
}
|
|
|
|
|
|
|
|
static ULONG WINAPI HTMLStyleSheetRulesCollection_Release(IHTMLStyleSheetRulesCollection *iface)
|
|
|
|
{
|
2011-01-04 01:50:04 +01:00
|
|
|
HTMLStyleSheetRulesCollection *This = impl_from_IHTMLStyleSheetRulesCollection(iface);
|
2007-12-06 12:22:30 +01:00
|
|
|
LONG ref = InterlockedDecrement(&This->ref);
|
|
|
|
|
|
|
|
TRACE("(%p) ref=%d\n", This, ref);
|
|
|
|
|
|
|
|
if(!ref) {
|
2014-05-09 14:05:21 +02:00
|
|
|
release_dispex(&This->dispex);
|
2007-12-06 12:22:30 +01:00
|
|
|
if(This->nslist)
|
|
|
|
nsIDOMCSSRuleList_Release(This->nslist);
|
|
|
|
heap_free(This);
|
|
|
|
}
|
|
|
|
|
|
|
|
return ref;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI HTMLStyleSheetRulesCollection_GetTypeInfoCount(
|
|
|
|
IHTMLStyleSheetRulesCollection *iface, UINT *pctinfo)
|
|
|
|
{
|
2011-01-04 01:50:04 +01:00
|
|
|
HTMLStyleSheetRulesCollection *This = impl_from_IHTMLStyleSheetRulesCollection(iface);
|
2014-05-09 14:05:21 +02:00
|
|
|
return IDispatchEx_GetTypeInfoCount(&This->dispex.IDispatchEx_iface, pctinfo);
|
2007-12-06 12:22:30 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI HTMLStyleSheetRulesCollection_GetTypeInfo(IHTMLStyleSheetRulesCollection *iface,
|
|
|
|
UINT iTInfo, LCID lcid, ITypeInfo **ppTInfo)
|
|
|
|
{
|
2011-01-04 01:50:04 +01:00
|
|
|
HTMLStyleSheetRulesCollection *This = impl_from_IHTMLStyleSheetRulesCollection(iface);
|
2014-05-09 14:05:21 +02:00
|
|
|
return IDispatchEx_GetTypeInfo(&This->dispex.IDispatchEx_iface, iTInfo, lcid, ppTInfo);
|
2007-12-06 12:22:30 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI HTMLStyleSheetRulesCollection_GetIDsOfNames(IHTMLStyleSheetRulesCollection *iface,
|
|
|
|
REFIID riid, LPOLESTR *rgszNames, UINT cNames, LCID lcid, DISPID *rgDispId)
|
|
|
|
{
|
2011-01-04 01:50:04 +01:00
|
|
|
HTMLStyleSheetRulesCollection *This = impl_from_IHTMLStyleSheetRulesCollection(iface);
|
2014-05-09 14:05:21 +02:00
|
|
|
return IDispatchEx_GetIDsOfNames(&This->dispex.IDispatchEx_iface, riid, rgszNames, cNames,
|
|
|
|
lcid, rgDispId);
|
2007-12-06 12:22:30 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI HTMLStyleSheetRulesCollection_Invoke(IHTMLStyleSheetRulesCollection *iface,
|
|
|
|
DISPID dispIdMember, REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS *pDispParams,
|
|
|
|
VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr)
|
|
|
|
{
|
2011-01-04 01:50:04 +01:00
|
|
|
HTMLStyleSheetRulesCollection *This = impl_from_IHTMLStyleSheetRulesCollection(iface);
|
2014-05-09 14:05:21 +02:00
|
|
|
return IDispatchEx_Invoke(&This->dispex.IDispatchEx_iface, dispIdMember, riid, lcid, wFlags,
|
|
|
|
pDispParams, pVarResult, pExcepInfo, puArgErr);
|
2007-12-06 12:22:30 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI HTMLStyleSheetRulesCollection_get_length(IHTMLStyleSheetRulesCollection *iface,
|
2009-03-12 01:43:31 +01:00
|
|
|
LONG *p)
|
2007-12-06 12:22:30 +01:00
|
|
|
{
|
2011-01-04 01:50:04 +01:00
|
|
|
HTMLStyleSheetRulesCollection *This = impl_from_IHTMLStyleSheetRulesCollection(iface);
|
2013-01-23 18:44:42 +01:00
|
|
|
UINT32 len = 0;
|
2007-12-06 12:22:44 +01:00
|
|
|
|
|
|
|
TRACE("(%p)->(%p)\n", This, p);
|
|
|
|
|
|
|
|
if(This->nslist) {
|
|
|
|
nsresult nsres;
|
|
|
|
|
|
|
|
nsres = nsIDOMCSSRuleList_GetLength(This->nslist, &len);
|
|
|
|
if(NS_FAILED(nsres))
|
|
|
|
ERR("GetLength failed: %08x\n", nsres);
|
|
|
|
}
|
|
|
|
|
|
|
|
*p = len;
|
|
|
|
return S_OK;
|
2007-12-06 12:22:30 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI HTMLStyleSheetRulesCollection_item(IHTMLStyleSheetRulesCollection *iface,
|
2021-03-15 16:18:31 +01:00
|
|
|
LONG index, IHTMLStyleSheetRule **p)
|
2007-12-06 12:22:30 +01:00
|
|
|
{
|
2011-01-04 01:50:04 +01:00
|
|
|
HTMLStyleSheetRulesCollection *This = impl_from_IHTMLStyleSheetRulesCollection(iface);
|
2019-05-07 14:45:11 +02:00
|
|
|
nsIDOMCSSRule *nsstylesheetrule;
|
|
|
|
nsresult nsres;
|
2021-10-25 15:30:29 +02:00
|
|
|
HRESULT hres;
|
2019-05-07 14:45:11 +02:00
|
|
|
|
2021-03-15 16:18:31 +01:00
|
|
|
TRACE("(%p)->(%d %p)\n", This, index, p);
|
2019-05-07 14:45:11 +02:00
|
|
|
|
|
|
|
nsres = nsIDOMCSSRuleList_Item(This->nslist, index, &nsstylesheetrule);
|
|
|
|
if(NS_FAILED(nsres))
|
|
|
|
return map_nsresult(nsres);
|
|
|
|
if(!nsstylesheetrule)
|
|
|
|
return E_INVALIDARG;
|
|
|
|
|
2021-10-25 15:30:29 +02:00
|
|
|
hres = create_style_sheet_rule(nsstylesheetrule, dispex_compat_mode(&This->dispex), p);
|
|
|
|
nsIDOMCSSRule_Release(nsstylesheetrule);
|
|
|
|
return hres;
|
2007-12-06 12:22:30 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
static const IHTMLStyleSheetRulesCollectionVtbl HTMLStyleSheetRulesCollectionVtbl = {
|
|
|
|
HTMLStyleSheetRulesCollection_QueryInterface,
|
|
|
|
HTMLStyleSheetRulesCollection_AddRef,
|
|
|
|
HTMLStyleSheetRulesCollection_Release,
|
|
|
|
HTMLStyleSheetRulesCollection_GetTypeInfoCount,
|
|
|
|
HTMLStyleSheetRulesCollection_GetTypeInfo,
|
|
|
|
HTMLStyleSheetRulesCollection_GetIDsOfNames,
|
|
|
|
HTMLStyleSheetRulesCollection_Invoke,
|
|
|
|
HTMLStyleSheetRulesCollection_get_length,
|
|
|
|
HTMLStyleSheetRulesCollection_item
|
|
|
|
};
|
|
|
|
|
2014-05-09 14:05:21 +02:00
|
|
|
static const tid_t HTMLStyleSheetRulesCollection_iface_tids[] = {
|
|
|
|
IHTMLStyleSheetRulesCollection_tid,
|
|
|
|
0
|
|
|
|
};
|
|
|
|
static dispex_static_data_t HTMLStyleSheetRulesCollection_dispex = {
|
2021-10-06 17:11:31 +02:00
|
|
|
L"MSCSSRuleList",
|
2014-05-09 14:05:21 +02:00
|
|
|
NULL,
|
|
|
|
DispHTMLStyleSheetRulesCollection_tid,
|
|
|
|
HTMLStyleSheetRulesCollection_iface_tids
|
|
|
|
};
|
|
|
|
|
2021-03-15 16:18:39 +01:00
|
|
|
static HRESULT create_style_sheet_rules_collection(nsIDOMCSSRuleList *nslist, compat_mode_t compat_mode,
|
|
|
|
IHTMLStyleSheetRulesCollection **ret)
|
2007-12-06 12:22:30 +01:00
|
|
|
{
|
2021-03-15 16:18:39 +01:00
|
|
|
HTMLStyleSheetRulesCollection *collection;
|
2007-12-06 12:22:30 +01:00
|
|
|
|
2021-03-15 16:18:39 +01:00
|
|
|
if(!(collection = heap_alloc(sizeof(*collection))))
|
|
|
|
return E_OUTOFMEMORY;
|
|
|
|
|
|
|
|
collection->IHTMLStyleSheetRulesCollection_iface.lpVtbl = &HTMLStyleSheetRulesCollectionVtbl;
|
|
|
|
collection->ref = 1;
|
|
|
|
collection->nslist = nslist;
|
2007-12-06 12:22:30 +01:00
|
|
|
|
2021-03-16 19:57:45 +01:00
|
|
|
init_dispatch(&collection->dispex, (IUnknown*)&collection->IHTMLStyleSheetRulesCollection_iface,
|
|
|
|
&HTMLStyleSheetRulesCollection_dispex, compat_mode);
|
2014-05-09 14:05:21 +02:00
|
|
|
|
2007-12-06 12:22:30 +01:00
|
|
|
if(nslist)
|
|
|
|
nsIDOMCSSRuleList_AddRef(nslist);
|
|
|
|
|
2021-03-15 16:18:39 +01:00
|
|
|
*ret = &collection->IHTMLStyleSheetRulesCollection_iface;
|
|
|
|
return S_OK;
|
2007-12-06 12:22:30 +01:00
|
|
|
}
|
2007-09-19 13:09:35 +02:00
|
|
|
|
2011-01-04 01:50:04 +01:00
|
|
|
static inline HTMLStyleSheetsCollection *impl_from_IHTMLStyleSheetsCollection(IHTMLStyleSheetsCollection *iface)
|
|
|
|
{
|
|
|
|
return CONTAINING_RECORD(iface, HTMLStyleSheetsCollection, IHTMLStyleSheetsCollection_iface);
|
|
|
|
}
|
2007-09-19 13:09:35 +02:00
|
|
|
|
|
|
|
static HRESULT WINAPI HTMLStyleSheetsCollection_QueryInterface(IHTMLStyleSheetsCollection *iface,
|
|
|
|
REFIID riid, void **ppv)
|
|
|
|
{
|
2011-01-04 01:50:04 +01:00
|
|
|
HTMLStyleSheetsCollection *This = impl_from_IHTMLStyleSheetsCollection(iface);
|
2007-09-19 13:09:35 +02:00
|
|
|
|
2014-05-13 18:56:30 +02:00
|
|
|
TRACE("(%p)->(%s %p)\n", This, debugstr_mshtml_guid(riid), ppv);
|
2007-09-19 13:09:35 +02:00
|
|
|
|
|
|
|
if(IsEqualGUID(&IID_IUnknown, riid)) {
|
2011-01-04 01:50:04 +01:00
|
|
|
*ppv = &This->IHTMLStyleSheetsCollection_iface;
|
2007-09-19 13:09:35 +02:00
|
|
|
}else if(IsEqualGUID(&IID_IDispatch, riid)) {
|
2011-01-04 01:50:04 +01:00
|
|
|
*ppv = &This->IHTMLStyleSheetsCollection_iface;
|
2007-09-19 13:09:35 +02:00
|
|
|
}else if(IsEqualGUID(&IID_IHTMLStyleSheetsCollection, riid)) {
|
2011-01-04 01:50:04 +01:00
|
|
|
*ppv = &This->IHTMLStyleSheetsCollection_iface;
|
2010-11-08 12:48:44 +01:00
|
|
|
}else if(dispex_query_interface(&This->dispex, riid, ppv)) {
|
|
|
|
return *ppv ? S_OK : E_NOINTERFACE;
|
2014-05-13 18:56:30 +02:00
|
|
|
}else {
|
|
|
|
*ppv = NULL;
|
|
|
|
WARN("unsupported %s\n", debugstr_mshtml_guid(riid));
|
|
|
|
return E_NOINTERFACE;
|
2007-09-19 13:09:35 +02:00
|
|
|
}
|
|
|
|
|
2014-05-13 18:56:30 +02:00
|
|
|
IUnknown_AddRef((IUnknown*)*ppv);
|
|
|
|
return S_OK;
|
2007-09-19 13:09:35 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static ULONG WINAPI HTMLStyleSheetsCollection_AddRef(IHTMLStyleSheetsCollection *iface)
|
|
|
|
{
|
2011-01-04 01:50:04 +01:00
|
|
|
HTMLStyleSheetsCollection *This = impl_from_IHTMLStyleSheetsCollection(iface);
|
2007-09-19 13:09:35 +02:00
|
|
|
LONG ref = InterlockedIncrement(&This->ref);
|
|
|
|
|
|
|
|
TRACE("(%p) ref=%d\n", This, ref);
|
|
|
|
|
|
|
|
return ref;
|
|
|
|
}
|
|
|
|
|
|
|
|
static ULONG WINAPI HTMLStyleSheetsCollection_Release(IHTMLStyleSheetsCollection *iface)
|
|
|
|
{
|
2011-01-04 01:50:04 +01:00
|
|
|
HTMLStyleSheetsCollection *This = impl_from_IHTMLStyleSheetsCollection(iface);
|
2007-09-19 13:09:35 +02:00
|
|
|
LONG ref = InterlockedDecrement(&This->ref);
|
|
|
|
|
|
|
|
TRACE("(%p) ref=%d\n", This, ref);
|
|
|
|
|
2007-12-06 12:22:55 +01:00
|
|
|
if(!ref) {
|
2014-05-09 13:29:21 +02:00
|
|
|
release_dispex(&This->dispex);
|
2007-12-06 12:22:55 +01:00
|
|
|
if(This->nslist)
|
|
|
|
nsIDOMStyleSheetList_Release(This->nslist);
|
2007-12-05 21:52:31 +01:00
|
|
|
heap_free(This);
|
2007-12-06 12:22:55 +01:00
|
|
|
}
|
2007-09-19 13:09:35 +02:00
|
|
|
|
|
|
|
return ref;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI HTMLStyleSheetsCollection_GetTypeInfoCount(IHTMLStyleSheetsCollection *iface,
|
|
|
|
UINT *pctinfo)
|
|
|
|
{
|
2011-01-04 01:50:04 +01:00
|
|
|
HTMLStyleSheetsCollection *This = impl_from_IHTMLStyleSheetsCollection(iface);
|
2010-12-31 11:07:33 +01:00
|
|
|
return IDispatchEx_GetTypeInfoCount(&This->dispex.IDispatchEx_iface, pctinfo);
|
2007-09-19 13:09:35 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI HTMLStyleSheetsCollection_GetTypeInfo(IHTMLStyleSheetsCollection *iface,
|
|
|
|
UINT iTInfo, LCID lcid, ITypeInfo **ppTInfo)
|
|
|
|
{
|
2011-01-04 01:50:04 +01:00
|
|
|
HTMLStyleSheetsCollection *This = impl_from_IHTMLStyleSheetsCollection(iface);
|
2010-12-31 11:07:33 +01:00
|
|
|
return IDispatchEx_GetTypeInfo(&This->dispex.IDispatchEx_iface, iTInfo, lcid, ppTInfo);
|
2007-09-19 13:09:35 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI HTMLStyleSheetsCollection_GetIDsOfNames(IHTMLStyleSheetsCollection *iface,
|
|
|
|
REFIID riid, LPOLESTR *rgszNames, UINT cNames, LCID lcid, DISPID *rgDispId)
|
|
|
|
{
|
2011-01-04 01:50:04 +01:00
|
|
|
HTMLStyleSheetsCollection *This = impl_from_IHTMLStyleSheetsCollection(iface);
|
2010-12-31 11:07:33 +01:00
|
|
|
return IDispatchEx_GetIDsOfNames(&This->dispex.IDispatchEx_iface, riid, rgszNames, cNames,
|
|
|
|
lcid, rgDispId);
|
2007-09-19 13:09:35 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI HTMLStyleSheetsCollection_Invoke(IHTMLStyleSheetsCollection *iface,
|
|
|
|
DISPID dispIdMember, REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS *pDispParams,
|
|
|
|
VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr)
|
|
|
|
{
|
2011-01-04 01:50:04 +01:00
|
|
|
HTMLStyleSheetsCollection *This = impl_from_IHTMLStyleSheetsCollection(iface);
|
2010-12-31 11:07:33 +01:00
|
|
|
return IDispatchEx_Invoke(&This->dispex.IDispatchEx_iface, dispIdMember, riid, lcid,
|
2010-11-08 12:48:44 +01:00
|
|
|
wFlags, pDispParams, pVarResult, pExcepInfo, puArgErr);
|
2007-09-19 13:09:35 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI HTMLStyleSheetsCollection_get_length(IHTMLStyleSheetsCollection *iface,
|
2009-03-12 01:43:31 +01:00
|
|
|
LONG *p)
|
2007-09-19 13:09:35 +02:00
|
|
|
{
|
2011-01-04 01:50:04 +01:00
|
|
|
HTMLStyleSheetsCollection *This = impl_from_IHTMLStyleSheetsCollection(iface);
|
2013-01-23 18:44:42 +01:00
|
|
|
UINT32 len = 0;
|
2007-09-19 13:10:02 +02:00
|
|
|
|
|
|
|
TRACE("(%p)->(%p)\n", This, p);
|
|
|
|
|
|
|
|
if(This->nslist)
|
|
|
|
nsIDOMStyleSheetList_GetLength(This->nslist, &len);
|
|
|
|
|
|
|
|
*p = len;
|
|
|
|
return S_OK;
|
2007-09-19 13:09:35 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI HTMLStyleSheetsCollection_get__newEnum(IHTMLStyleSheetsCollection *iface,
|
|
|
|
IUnknown **p)
|
|
|
|
{
|
2011-01-04 01:50:04 +01:00
|
|
|
HTMLStyleSheetsCollection *This = impl_from_IHTMLStyleSheetsCollection(iface);
|
2007-09-19 13:09:35 +02:00
|
|
|
FIXME("(%p)->(%p)\n", This, p);
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI HTMLStyleSheetsCollection_item(IHTMLStyleSheetsCollection *iface,
|
|
|
|
VARIANT *pvarIndex, VARIANT *pvarResult)
|
|
|
|
{
|
2011-01-04 01:50:04 +01:00
|
|
|
HTMLStyleSheetsCollection *This = impl_from_IHTMLStyleSheetsCollection(iface);
|
2007-11-25 19:09:20 +01:00
|
|
|
|
2012-03-28 14:27:20 +02:00
|
|
|
TRACE("(%p)->(%s %p)\n", This, debugstr_variant(pvarIndex), pvarResult);
|
2007-11-25 19:09:20 +01:00
|
|
|
|
|
|
|
switch(V_VT(pvarIndex)) {
|
|
|
|
case VT_I4: {
|
|
|
|
nsIDOMStyleSheet *nsstylesheet;
|
2021-03-15 16:18:13 +01:00
|
|
|
IHTMLStyleSheet *stylesheet;
|
2007-11-25 19:09:20 +01:00
|
|
|
nsresult nsres;
|
2021-03-15 16:18:13 +01:00
|
|
|
HRESULT hres;
|
2007-11-25 19:09:20 +01:00
|
|
|
|
|
|
|
TRACE("index=%d\n", V_I4(pvarIndex));
|
|
|
|
|
|
|
|
nsres = nsIDOMStyleSheetList_Item(This->nslist, V_I4(pvarIndex), &nsstylesheet);
|
|
|
|
if(NS_FAILED(nsres) || !nsstylesheet) {
|
|
|
|
WARN("Item failed: %08x\n", nsres);
|
|
|
|
V_VT(pvarResult) = VT_EMPTY;
|
|
|
|
return E_INVALIDARG;
|
|
|
|
}
|
|
|
|
|
2021-03-15 16:18:13 +01:00
|
|
|
hres = create_style_sheet(nsstylesheet, dispex_compat_mode(&This->dispex), &stylesheet);
|
2021-10-25 15:30:28 +02:00
|
|
|
nsIDOMStyleSheet_Release(nsstylesheet);
|
2021-03-15 16:18:13 +01:00
|
|
|
if(FAILED(hres))
|
|
|
|
return hres;
|
2007-11-25 19:09:20 +01:00
|
|
|
|
2021-03-15 16:18:13 +01:00
|
|
|
V_VT(pvarResult) = VT_DISPATCH;
|
|
|
|
V_DISPATCH(pvarResult) = (IDispatch*)stylesheet;
|
2007-11-25 19:09:20 +01:00
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
case VT_BSTR:
|
|
|
|
FIXME("id=%s not implemented\n", debugstr_w(V_BSTR(pvarResult)));
|
|
|
|
return E_NOTIMPL;
|
|
|
|
|
|
|
|
default:
|
2012-03-28 14:27:20 +02:00
|
|
|
WARN("Invalid index %s\n", debugstr_variant(pvarIndex));
|
2007-11-25 19:09:20 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
return E_INVALIDARG;
|
2007-09-19 13:09:35 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static const IHTMLStyleSheetsCollectionVtbl HTMLStyleSheetsCollectionVtbl = {
|
|
|
|
HTMLStyleSheetsCollection_QueryInterface,
|
|
|
|
HTMLStyleSheetsCollection_AddRef,
|
|
|
|
HTMLStyleSheetsCollection_Release,
|
|
|
|
HTMLStyleSheetsCollection_GetTypeInfoCount,
|
|
|
|
HTMLStyleSheetsCollection_GetTypeInfo,
|
|
|
|
HTMLStyleSheetsCollection_GetIDsOfNames,
|
|
|
|
HTMLStyleSheetsCollection_Invoke,
|
|
|
|
HTMLStyleSheetsCollection_get_length,
|
|
|
|
HTMLStyleSheetsCollection_get__newEnum,
|
|
|
|
HTMLStyleSheetsCollection_item
|
|
|
|
};
|
|
|
|
|
2021-12-03 14:57:35 +01:00
|
|
|
static inline HTMLStyleSheetsCollection *HTMLStyleSheetsCollection_from_DispatchEx(DispatchEx *iface)
|
|
|
|
{
|
|
|
|
return CONTAINING_RECORD(iface, HTMLStyleSheetsCollection, dispex);
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT HTMLStyleSheetsCollection_get_dispid(DispatchEx *dispex, BSTR name, DWORD flags, DISPID *dispid)
|
|
|
|
{
|
|
|
|
HTMLStyleSheetsCollection *This = HTMLStyleSheetsCollection_from_DispatchEx(dispex);
|
|
|
|
UINT32 len = 0;
|
|
|
|
DWORD idx = 0;
|
|
|
|
WCHAR *ptr;
|
|
|
|
|
|
|
|
for(ptr = name; *ptr && is_digit(*ptr); ptr++)
|
|
|
|
idx = idx*10 + (*ptr-'0');
|
|
|
|
if(*ptr)
|
|
|
|
return DISP_E_UNKNOWNNAME;
|
|
|
|
|
|
|
|
nsIDOMStyleSheetList_GetLength(This->nslist, &len);
|
|
|
|
if(idx >= len)
|
|
|
|
return DISP_E_UNKNOWNNAME;
|
|
|
|
|
|
|
|
*dispid = MSHTML_DISPID_CUSTOM_MIN + idx;
|
|
|
|
TRACE("ret %x\n", *dispid);
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT HTMLStyleSheetsCollection_invoke(DispatchEx *dispex, DISPID id, LCID lcid, WORD flags, DISPPARAMS *params,
|
|
|
|
VARIANT *res, EXCEPINFO *ei, IServiceProvider *caller)
|
|
|
|
{
|
|
|
|
HTMLStyleSheetsCollection *This = HTMLStyleSheetsCollection_from_DispatchEx(dispex);
|
|
|
|
|
|
|
|
TRACE("(%p)->(%x %x %x %p %p %p %p)\n", This, id, lcid, flags, params, res, ei, caller);
|
|
|
|
|
|
|
|
switch(flags) {
|
|
|
|
case DISPATCH_PROPERTYGET: {
|
|
|
|
nsIDOMStyleSheet *nsstylesheet;
|
|
|
|
IHTMLStyleSheet *stylesheet;
|
|
|
|
nsresult nsres;
|
|
|
|
HRESULT hres;
|
|
|
|
|
|
|
|
nsres = nsIDOMStyleSheetList_Item(This->nslist, id - MSHTML_DISPID_CUSTOM_MIN, &nsstylesheet);
|
|
|
|
if(NS_FAILED(nsres))
|
|
|
|
return DISP_E_MEMBERNOTFOUND;
|
|
|
|
if(!nsstylesheet) {
|
|
|
|
V_VT(res) = VT_EMPTY;
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
hres = create_style_sheet(nsstylesheet, dispex_compat_mode(&This->dispex), &stylesheet);
|
|
|
|
nsIDOMStyleSheet_Release(nsstylesheet);
|
|
|
|
if(FAILED(hres))
|
|
|
|
return hres;
|
|
|
|
|
|
|
|
V_VT(res) = VT_DISPATCH;
|
|
|
|
V_DISPATCH(res) = (IDispatch*)stylesheet;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
default:
|
|
|
|
FIXME("unimplemented flags %x\n", flags);
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
static const dispex_static_data_vtbl_t HTMLStyleSheetsCollection_dispex_vtbl = {
|
|
|
|
NULL,
|
|
|
|
HTMLStyleSheetsCollection_get_dispid,
|
|
|
|
HTMLStyleSheetsCollection_invoke
|
|
|
|
};
|
2010-11-08 12:48:44 +01:00
|
|
|
static const tid_t HTMLStyleSheetsCollection_iface_tids[] = {
|
|
|
|
IHTMLStyleSheetsCollection_tid,
|
|
|
|
0
|
|
|
|
};
|
|
|
|
static dispex_static_data_t HTMLStyleSheetsCollection_dispex = {
|
2021-10-06 17:11:31 +02:00
|
|
|
L"StyleSheetList",
|
2021-12-03 14:57:35 +01:00
|
|
|
&HTMLStyleSheetsCollection_dispex_vtbl,
|
2010-11-08 12:48:44 +01:00
|
|
|
DispHTMLStyleSheetsCollection_tid,
|
|
|
|
HTMLStyleSheetsCollection_iface_tids
|
|
|
|
};
|
|
|
|
|
2021-03-15 16:18:24 +01:00
|
|
|
HRESULT create_style_sheet_collection(nsIDOMStyleSheetList *nslist, compat_mode_t compat_mode,
|
|
|
|
IHTMLStyleSheetsCollection **ret)
|
2007-09-19 13:09:35 +02:00
|
|
|
{
|
2021-03-15 16:18:24 +01:00
|
|
|
HTMLStyleSheetsCollection *collection;
|
2007-09-19 13:09:35 +02:00
|
|
|
|
2021-03-15 16:18:24 +01:00
|
|
|
if(!(collection = heap_alloc(sizeof(HTMLStyleSheetsCollection))))
|
|
|
|
return E_OUTOFMEMORY;
|
|
|
|
|
|
|
|
collection->IHTMLStyleSheetsCollection_iface.lpVtbl = &HTMLStyleSheetsCollectionVtbl;
|
|
|
|
collection->ref = 1;
|
2007-09-19 13:09:35 +02:00
|
|
|
|
|
|
|
if(nslist)
|
|
|
|
nsIDOMStyleSheetList_AddRef(nslist);
|
2021-03-15 16:18:24 +01:00
|
|
|
collection->nslist = nslist;
|
2007-09-19 13:09:35 +02:00
|
|
|
|
2021-03-16 19:57:45 +01:00
|
|
|
init_dispatch(&collection->dispex, (IUnknown*)&collection->IHTMLStyleSheetsCollection_iface,
|
|
|
|
&HTMLStyleSheetsCollection_dispex, compat_mode);
|
2010-11-08 12:48:44 +01:00
|
|
|
|
2021-03-15 16:18:24 +01:00
|
|
|
*ret = &collection->IHTMLStyleSheetsCollection_iface;
|
|
|
|
return S_OK;
|
2007-09-19 13:09:35 +02:00
|
|
|
}
|
2006-11-17 13:08:09 +01:00
|
|
|
|
2011-01-04 01:50:04 +01:00
|
|
|
static inline HTMLStyleSheet *impl_from_IHTMLStyleSheet(IHTMLStyleSheet *iface)
|
|
|
|
{
|
|
|
|
return CONTAINING_RECORD(iface, HTMLStyleSheet, IHTMLStyleSheet_iface);
|
|
|
|
}
|
2006-11-17 13:08:09 +01:00
|
|
|
|
|
|
|
static HRESULT WINAPI HTMLStyleSheet_QueryInterface(IHTMLStyleSheet *iface, REFIID riid, void **ppv)
|
|
|
|
{
|
2011-01-04 01:50:04 +01:00
|
|
|
HTMLStyleSheet *This = impl_from_IHTMLStyleSheet(iface);
|
2006-11-17 13:08:09 +01:00
|
|
|
|
2014-05-13 18:56:30 +02:00
|
|
|
TRACE("(%p)->(%s %p)\n", This, debugstr_mshtml_guid(riid), ppv);
|
2006-11-17 13:08:09 +01:00
|
|
|
|
|
|
|
if(IsEqualGUID(&IID_IUnknown, riid)) {
|
2011-01-04 01:50:04 +01:00
|
|
|
*ppv = &This->IHTMLStyleSheet_iface;
|
2006-11-17 13:08:09 +01:00
|
|
|
}else if(IsEqualGUID(&IID_IDispatch, riid)) {
|
2011-01-04 01:50:04 +01:00
|
|
|
*ppv = &This->IHTMLStyleSheet_iface;
|
2006-11-17 13:08:09 +01:00
|
|
|
}else if(IsEqualGUID(&IID_IHTMLStyleSheet, riid)) {
|
2011-01-04 01:50:04 +01:00
|
|
|
*ppv = &This->IHTMLStyleSheet_iface;
|
2021-04-07 00:24:13 +02:00
|
|
|
}else if(IsEqualGUID(&IID_IHTMLStyleSheet4, riid)) {
|
|
|
|
*ppv = &This->IHTMLStyleSheet4_iface;
|
2013-08-19 12:12:11 +02:00
|
|
|
}else if(dispex_query_interface(&This->dispex, riid, ppv)) {
|
|
|
|
return *ppv ? S_OK : E_NOINTERFACE;
|
2014-05-13 18:56:30 +02:00
|
|
|
}else {
|
|
|
|
*ppv = NULL;
|
|
|
|
WARN("unsupported %s\n", debugstr_mshtml_guid(riid));
|
|
|
|
return E_NOINTERFACE;
|
2006-11-17 13:08:09 +01:00
|
|
|
}
|
|
|
|
|
2014-05-13 18:56:30 +02:00
|
|
|
IUnknown_AddRef((IUnknown*)*ppv);
|
|
|
|
return S_OK;
|
2006-11-17 13:08:09 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
static ULONG WINAPI HTMLStyleSheet_AddRef(IHTMLStyleSheet *iface)
|
|
|
|
{
|
2011-01-04 01:50:04 +01:00
|
|
|
HTMLStyleSheet *This = impl_from_IHTMLStyleSheet(iface);
|
2006-11-17 13:08:09 +01:00
|
|
|
LONG ref = InterlockedIncrement(&This->ref);
|
|
|
|
|
|
|
|
TRACE("(%p) ref=%d\n", This, ref);
|
|
|
|
|
|
|
|
return ref;
|
|
|
|
}
|
|
|
|
|
|
|
|
static ULONG WINAPI HTMLStyleSheet_Release(IHTMLStyleSheet *iface)
|
|
|
|
{
|
2011-01-04 01:50:04 +01:00
|
|
|
HTMLStyleSheet *This = impl_from_IHTMLStyleSheet(iface);
|
2006-11-17 13:08:09 +01:00
|
|
|
LONG ref = InterlockedDecrement(&This->ref);
|
|
|
|
|
|
|
|
TRACE("(%p) ref=%d\n", This, ref);
|
|
|
|
|
2014-05-09 13:29:21 +02:00
|
|
|
if(!ref) {
|
|
|
|
release_dispex(&This->dispex);
|
|
|
|
if(This->nsstylesheet)
|
|
|
|
nsIDOMCSSStyleSheet_Release(This->nsstylesheet);
|
2007-12-05 21:52:31 +01:00
|
|
|
heap_free(This);
|
2014-05-09 13:29:21 +02:00
|
|
|
}
|
2006-11-17 13:08:09 +01:00
|
|
|
|
|
|
|
return ref;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI HTMLStyleSheet_GetTypeInfoCount(IHTMLStyleSheet *iface, UINT *pctinfo)
|
|
|
|
{
|
2011-01-04 01:50:04 +01:00
|
|
|
HTMLStyleSheet *This = impl_from_IHTMLStyleSheet(iface);
|
2013-08-19 12:12:11 +02:00
|
|
|
TRACE("(%p)->(%p)\n", This, pctinfo);
|
|
|
|
return IDispatchEx_GetTypeInfoCount(&This->dispex.IDispatchEx_iface, pctinfo);
|
2006-11-17 13:08:09 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI HTMLStyleSheet_GetTypeInfo(IHTMLStyleSheet *iface, UINT iTInfo,
|
|
|
|
LCID lcid, ITypeInfo **ppTInfo)
|
|
|
|
{
|
2011-01-04 01:50:04 +01:00
|
|
|
HTMLStyleSheet *This = impl_from_IHTMLStyleSheet(iface);
|
2013-08-19 12:12:11 +02:00
|
|
|
return IDispatchEx_GetTypeInfo(&This->dispex.IDispatchEx_iface, iTInfo, lcid, ppTInfo);
|
2006-11-17 13:08:09 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI HTMLStyleSheet_GetIDsOfNames(IHTMLStyleSheet *iface, REFIID riid,
|
|
|
|
LPOLESTR *rgszNames, UINT cNames,
|
|
|
|
LCID lcid, DISPID *rgDispId)
|
|
|
|
{
|
2011-01-04 01:50:04 +01:00
|
|
|
HTMLStyleSheet *This = impl_from_IHTMLStyleSheet(iface);
|
2013-08-19 12:12:11 +02:00
|
|
|
return IDispatchEx_GetIDsOfNames(&This->dispex.IDispatchEx_iface, riid, rgszNames, cNames, lcid, rgDispId);
|
2006-11-17 13:08:09 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI HTMLStyleSheet_Invoke(IHTMLStyleSheet *iface, DISPID dispIdMember,
|
|
|
|
REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS *pDispParams,
|
|
|
|
VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr)
|
|
|
|
{
|
2011-01-04 01:50:04 +01:00
|
|
|
HTMLStyleSheet *This = impl_from_IHTMLStyleSheet(iface);
|
2013-08-19 12:12:11 +02:00
|
|
|
return IDispatchEx_Invoke(&This->dispex.IDispatchEx_iface, dispIdMember, riid, lcid, wFlags, pDispParams,
|
|
|
|
pVarResult, pExcepInfo, puArgErr);
|
2006-11-17 13:08:09 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI HTMLStyleSheet_put_title(IHTMLStyleSheet *iface, BSTR v)
|
|
|
|
{
|
2011-01-04 01:50:04 +01:00
|
|
|
HTMLStyleSheet *This = impl_from_IHTMLStyleSheet(iface);
|
2006-11-17 13:08:09 +01:00
|
|
|
FIXME("(%p)->(%s)\n", This, debugstr_w(v));
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI HTMLStyleSheet_get_title(IHTMLStyleSheet *iface, BSTR *p)
|
|
|
|
{
|
2011-01-04 01:50:04 +01:00
|
|
|
HTMLStyleSheet *This = impl_from_IHTMLStyleSheet(iface);
|
2006-11-17 13:08:09 +01:00
|
|
|
FIXME("(%p)->(%p)\n", This, p);
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI HTMLStyleSheet_get_parentStyleSheet(IHTMLStyleSheet *iface,
|
|
|
|
IHTMLStyleSheet **p)
|
|
|
|
{
|
2011-01-04 01:50:04 +01:00
|
|
|
HTMLStyleSheet *This = impl_from_IHTMLStyleSheet(iface);
|
2006-11-17 13:08:09 +01:00
|
|
|
FIXME("(%p)->(%p)\n", This, p);
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI HTMLStyleSheet_get_owningElement(IHTMLStyleSheet *iface, IHTMLElement **p)
|
|
|
|
{
|
2011-01-04 01:50:04 +01:00
|
|
|
HTMLStyleSheet *This = impl_from_IHTMLStyleSheet(iface);
|
2006-11-17 13:08:09 +01:00
|
|
|
FIXME("(%p)->(%p)\n", This, p);
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI HTMLStyleSheet_put_disabled(IHTMLStyleSheet *iface, VARIANT_BOOL v)
|
|
|
|
{
|
2011-01-04 01:50:04 +01:00
|
|
|
HTMLStyleSheet *This = impl_from_IHTMLStyleSheet(iface);
|
2006-11-17 13:08:09 +01:00
|
|
|
FIXME("(%p)->(%x)\n", This, v);
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI HTMLStyleSheet_get_disabled(IHTMLStyleSheet *iface, VARIANT_BOOL *p)
|
|
|
|
{
|
2011-01-04 01:50:04 +01:00
|
|
|
HTMLStyleSheet *This = impl_from_IHTMLStyleSheet(iface);
|
2006-11-17 13:08:09 +01:00
|
|
|
FIXME("(%p)->(%p)\n", This, p);
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI HTMLStyleSheet_get_readOnly(IHTMLStyleSheet *iface, VARIANT_BOOL *p)
|
|
|
|
{
|
2011-01-04 01:50:04 +01:00
|
|
|
HTMLStyleSheet *This = impl_from_IHTMLStyleSheet(iface);
|
2006-11-17 13:08:09 +01:00
|
|
|
FIXME("(%p)->(%p)\n", This, p);
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI HTMLStyleSheet_get_imports(IHTMLStyleSheet *iface,
|
|
|
|
IHTMLStyleSheetsCollection **p)
|
|
|
|
{
|
2011-01-04 01:50:04 +01:00
|
|
|
HTMLStyleSheet *This = impl_from_IHTMLStyleSheet(iface);
|
2006-11-17 13:08:09 +01:00
|
|
|
FIXME("(%p)->(%p)\n", This, p);
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI HTMLStyleSheet_put_href(IHTMLStyleSheet *iface, BSTR v)
|
|
|
|
{
|
2011-01-04 01:50:04 +01:00
|
|
|
HTMLStyleSheet *This = impl_from_IHTMLStyleSheet(iface);
|
2006-11-17 13:08:09 +01:00
|
|
|
FIXME("(%p)->(%s)\n", This, debugstr_w(v));
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI HTMLStyleSheet_get_href(IHTMLStyleSheet *iface, BSTR *p)
|
|
|
|
{
|
2011-01-04 01:50:04 +01:00
|
|
|
HTMLStyleSheet *This = impl_from_IHTMLStyleSheet(iface);
|
2014-02-09 14:55:16 +01:00
|
|
|
nsAString href_str;
|
|
|
|
nsresult nsres;
|
|
|
|
|
|
|
|
TRACE("(%p)->(%p)\n", This, p);
|
|
|
|
|
|
|
|
nsAString_Init(&href_str, NULL);
|
|
|
|
nsres = nsIDOMCSSStyleSheet_GetHref(This->nsstylesheet, &href_str);
|
|
|
|
return return_nsstr(nsres, &href_str, p);
|
2006-11-17 13:08:09 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI HTMLStyleSheet_get_type(IHTMLStyleSheet *iface, BSTR *p)
|
|
|
|
{
|
2011-01-04 01:50:04 +01:00
|
|
|
HTMLStyleSheet *This = impl_from_IHTMLStyleSheet(iface);
|
2006-11-17 13:08:09 +01:00
|
|
|
FIXME("(%p)->(%p)\n", This, p);
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI HTMLStyleSheet_get_id(IHTMLStyleSheet *iface, BSTR *p)
|
|
|
|
{
|
2011-01-04 01:50:04 +01:00
|
|
|
HTMLStyleSheet *This = impl_from_IHTMLStyleSheet(iface);
|
2006-11-17 13:08:09 +01:00
|
|
|
FIXME("(%p)->(%p)\n", This, p);
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI HTMLStyleSheet_addImport(IHTMLStyleSheet *iface, BSTR bstrURL,
|
2009-03-12 01:43:31 +01:00
|
|
|
LONG lIndex, LONG *plIndex)
|
2006-11-17 13:08:09 +01:00
|
|
|
{
|
2011-01-04 01:50:04 +01:00
|
|
|
HTMLStyleSheet *This = impl_from_IHTMLStyleSheet(iface);
|
2009-03-12 01:43:31 +01:00
|
|
|
FIXME("(%p)->(%s %d %p)\n", This, debugstr_w(bstrURL), lIndex, plIndex);
|
2006-11-17 13:08:09 +01:00
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI HTMLStyleSheet_addRule(IHTMLStyleSheet *iface, BSTR bstrSelector,
|
2009-03-12 01:43:31 +01:00
|
|
|
BSTR bstrStyle, LONG lIndex, LONG *plIndex)
|
2006-11-17 13:08:09 +01:00
|
|
|
{
|
2011-01-04 01:50:04 +01:00
|
|
|
HTMLStyleSheet *This = impl_from_IHTMLStyleSheet(iface);
|
2021-10-01 15:12:46 +02:00
|
|
|
const WCHAR format[] = L"%s {%s}";
|
|
|
|
nsIDOMCSSRuleList *nslist = NULL;
|
|
|
|
UINT32 length, new_index;
|
|
|
|
nsAString nsstr;
|
|
|
|
nsresult nsres;
|
|
|
|
WCHAR *rule;
|
|
|
|
size_t len;
|
|
|
|
|
|
|
|
TRACE("(%p)->(%s %s %d %p)\n", This, debugstr_w(bstrSelector), debugstr_w(bstrStyle),
|
2006-11-17 13:08:09 +01:00
|
|
|
lIndex, plIndex);
|
2021-10-01 15:12:46 +02:00
|
|
|
|
|
|
|
if(!bstrSelector || !bstrStyle || !bstrSelector[0] || !bstrStyle[0])
|
|
|
|
return E_INVALIDARG;
|
|
|
|
|
|
|
|
nsres = nsIDOMCSSStyleSheet_GetCssRules(This->nsstylesheet, &nslist);
|
|
|
|
if(NS_FAILED(nsres))
|
|
|
|
return E_FAIL;
|
|
|
|
nsIDOMCSSRuleList_GetLength(nslist, &length);
|
|
|
|
|
|
|
|
if(lIndex > length)
|
|
|
|
lIndex = length;
|
|
|
|
|
|
|
|
len = ARRAY_SIZE(format) - 4 /* %s twice */ + wcslen(bstrSelector) + wcslen(bstrStyle);
|
|
|
|
if(!(rule = heap_alloc(len * sizeof(WCHAR))))
|
|
|
|
return E_OUTOFMEMORY;
|
|
|
|
swprintf(rule, len, format, bstrSelector, bstrStyle);
|
|
|
|
|
|
|
|
nsAString_InitDepend(&nsstr, rule);
|
|
|
|
nsres = nsIDOMCSSStyleSheet_InsertRule(This->nsstylesheet, &nsstr, lIndex, &new_index);
|
|
|
|
if(NS_FAILED(nsres)) WARN("failed: %08x\n", nsres);
|
|
|
|
nsAString_Finish(&nsstr);
|
|
|
|
heap_free(rule);
|
|
|
|
|
|
|
|
*plIndex = new_index;
|
|
|
|
return map_nsresult(nsres);
|
2006-11-17 13:08:09 +01:00
|
|
|
}
|
|
|
|
|
2009-03-12 01:43:31 +01:00
|
|
|
static HRESULT WINAPI HTMLStyleSheet_removeImport(IHTMLStyleSheet *iface, LONG lIndex)
|
2006-11-17 13:08:09 +01:00
|
|
|
{
|
2011-01-04 01:50:04 +01:00
|
|
|
HTMLStyleSheet *This = impl_from_IHTMLStyleSheet(iface);
|
2009-03-12 01:43:31 +01:00
|
|
|
FIXME("(%p)->(%d)\n", This, lIndex);
|
2006-11-17 13:08:09 +01:00
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
2009-03-12 01:43:31 +01:00
|
|
|
static HRESULT WINAPI HTMLStyleSheet_removeRule(IHTMLStyleSheet *iface, LONG lIndex)
|
2006-11-17 13:08:09 +01:00
|
|
|
{
|
2011-01-04 01:50:04 +01:00
|
|
|
HTMLStyleSheet *This = impl_from_IHTMLStyleSheet(iface);
|
2009-03-12 01:43:31 +01:00
|
|
|
FIXME("(%p)->(%d)\n", This, lIndex);
|
2006-11-17 13:08:09 +01:00
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI HTMLStyleSheet_put_media(IHTMLStyleSheet *iface, BSTR v)
|
|
|
|
{
|
2011-01-04 01:50:04 +01:00
|
|
|
HTMLStyleSheet *This = impl_from_IHTMLStyleSheet(iface);
|
2006-11-17 13:08:09 +01:00
|
|
|
FIXME("(%p)->(%s)\n", This, debugstr_w(v));
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI HTMLStyleSheet_get_media(IHTMLStyleSheet *iface, BSTR *p)
|
|
|
|
{
|
2011-01-04 01:50:04 +01:00
|
|
|
HTMLStyleSheet *This = impl_from_IHTMLStyleSheet(iface);
|
2006-11-17 13:08:09 +01:00
|
|
|
FIXME("(%p)->(%p)\n", This, p);
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI HTMLStyleSheet_put_cssText(IHTMLStyleSheet *iface, BSTR v)
|
|
|
|
{
|
2011-01-04 01:50:04 +01:00
|
|
|
HTMLStyleSheet *This = impl_from_IHTMLStyleSheet(iface);
|
2014-11-18 15:03:01 +01:00
|
|
|
nsresult nsres;
|
|
|
|
|
|
|
|
TRACE("(%p)->(%s)\n", This, debugstr_w(v));
|
|
|
|
|
|
|
|
do {
|
|
|
|
nsres = nsIDOMCSSStyleSheet_DeleteRule(This->nsstylesheet, 0);
|
|
|
|
}while(NS_SUCCEEDED(nsres));
|
|
|
|
|
|
|
|
if(v && *v) {
|
|
|
|
nsAString nsstr;
|
|
|
|
UINT32 idx;
|
|
|
|
|
|
|
|
/* FIXME: This won't work for multiple rules in the string. */
|
|
|
|
nsAString_InitDepend(&nsstr, v);
|
|
|
|
nsres = nsIDOMCSSStyleSheet_InsertRule(This->nsstylesheet, &nsstr, 0, &idx);
|
|
|
|
nsAString_Finish(&nsstr);
|
|
|
|
if(NS_FAILED(nsres)) {
|
|
|
|
FIXME("InsertRule failed for string %s. Probably multiple rules passed.\n", debugstr_w(v));
|
|
|
|
return E_FAIL;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return S_OK;
|
2006-11-17 13:08:09 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI HTMLStyleSheet_get_cssText(IHTMLStyleSheet *iface, BSTR *p)
|
|
|
|
{
|
2011-01-04 01:50:04 +01:00
|
|
|
HTMLStyleSheet *This = impl_from_IHTMLStyleSheet(iface);
|
2014-11-18 15:03:01 +01:00
|
|
|
nsIDOMCSSRuleList *nslist = NULL;
|
|
|
|
nsIDOMCSSRule *nsrule;
|
|
|
|
nsAString nsstr;
|
|
|
|
UINT32 len;
|
|
|
|
nsresult nsres;
|
|
|
|
|
|
|
|
TRACE("(%p)->(%p)\n", This, p);
|
|
|
|
|
|
|
|
nsres = nsIDOMCSSStyleSheet_GetCssRules(This->nsstylesheet, &nslist);
|
|
|
|
if(NS_FAILED(nsres)) {
|
|
|
|
ERR("GetCssRules failed: %08x\n", nsres);
|
|
|
|
return E_FAIL;
|
|
|
|
}
|
|
|
|
|
|
|
|
nsres = nsIDOMCSSRuleList_GetLength(nslist, &len);
|
|
|
|
assert(nsres == NS_OK);
|
|
|
|
|
|
|
|
if(len) {
|
|
|
|
nsres = nsIDOMCSSRuleList_Item(nslist, 0, &nsrule);
|
|
|
|
if(NS_FAILED(nsres))
|
|
|
|
ERR("Item failed: %08x\n", nsres);
|
|
|
|
}
|
|
|
|
|
|
|
|
nsIDOMCSSRuleList_Release(nslist);
|
|
|
|
if(NS_FAILED(nsres))
|
|
|
|
return E_FAIL;
|
|
|
|
|
|
|
|
if(!len) {
|
|
|
|
*p = NULL;
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
nsAString_Init(&nsstr, NULL);
|
|
|
|
nsres = nsIDOMCSSRule_GetCssText(nsrule, &nsstr);
|
|
|
|
nsIDOMCSSRule_Release(nsrule);
|
|
|
|
return return_nsstr(nsres, &nsstr, p);
|
2006-11-17 13:08:09 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI HTMLStyleSheet_get_rules(IHTMLStyleSheet *iface,
|
|
|
|
IHTMLStyleSheetRulesCollection **p)
|
|
|
|
{
|
2011-01-04 01:50:04 +01:00
|
|
|
HTMLStyleSheet *This = impl_from_IHTMLStyleSheet(iface);
|
2007-12-06 12:22:30 +01:00
|
|
|
nsIDOMCSSRuleList *nslist = NULL;
|
|
|
|
nsresult nsres;
|
2021-03-15 16:18:39 +01:00
|
|
|
HRESULT hres;
|
2007-12-06 12:22:30 +01:00
|
|
|
|
|
|
|
TRACE("(%p)->(%p)\n", This, p);
|
|
|
|
|
|
|
|
nsres = nsIDOMCSSStyleSheet_GetCssRules(This->nsstylesheet, &nslist);
|
2014-11-13 11:22:35 +01:00
|
|
|
if(NS_FAILED(nsres)) {
|
|
|
|
ERR("GetCssRules failed: %08x\n", nsres);
|
|
|
|
return E_FAIL;
|
|
|
|
}
|
2007-12-06 12:22:30 +01:00
|
|
|
|
2021-03-15 16:18:39 +01:00
|
|
|
hres = create_style_sheet_rules_collection(nslist, dispex_compat_mode(&This->dispex), p);
|
|
|
|
nsIDOMCSSRuleList_Release(nslist);
|
|
|
|
return hres;
|
2006-11-17 13:08:09 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
static const IHTMLStyleSheetVtbl HTMLStyleSheetVtbl = {
|
|
|
|
HTMLStyleSheet_QueryInterface,
|
|
|
|
HTMLStyleSheet_AddRef,
|
|
|
|
HTMLStyleSheet_Release,
|
|
|
|
HTMLStyleSheet_GetTypeInfoCount,
|
|
|
|
HTMLStyleSheet_GetTypeInfo,
|
|
|
|
HTMLStyleSheet_GetIDsOfNames,
|
|
|
|
HTMLStyleSheet_Invoke,
|
|
|
|
HTMLStyleSheet_put_title,
|
|
|
|
HTMLStyleSheet_get_title,
|
|
|
|
HTMLStyleSheet_get_parentStyleSheet,
|
|
|
|
HTMLStyleSheet_get_owningElement,
|
|
|
|
HTMLStyleSheet_put_disabled,
|
|
|
|
HTMLStyleSheet_get_disabled,
|
|
|
|
HTMLStyleSheet_get_readOnly,
|
|
|
|
HTMLStyleSheet_get_imports,
|
|
|
|
HTMLStyleSheet_put_href,
|
|
|
|
HTMLStyleSheet_get_href,
|
|
|
|
HTMLStyleSheet_get_type,
|
|
|
|
HTMLStyleSheet_get_id,
|
|
|
|
HTMLStyleSheet_addImport,
|
|
|
|
HTMLStyleSheet_addRule,
|
|
|
|
HTMLStyleSheet_removeImport,
|
|
|
|
HTMLStyleSheet_removeRule,
|
|
|
|
HTMLStyleSheet_put_media,
|
|
|
|
HTMLStyleSheet_get_media,
|
|
|
|
HTMLStyleSheet_put_cssText,
|
|
|
|
HTMLStyleSheet_get_cssText,
|
|
|
|
HTMLStyleSheet_get_rules
|
|
|
|
};
|
|
|
|
|
2021-04-07 00:24:13 +02:00
|
|
|
static inline HTMLStyleSheet *impl_from_IHTMLStyleSheet4(IHTMLStyleSheet4 *iface)
|
|
|
|
{
|
|
|
|
return CONTAINING_RECORD(iface, HTMLStyleSheet, IHTMLStyleSheet4_iface);
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI HTMLStyleSheet4_QueryInterface(IHTMLStyleSheet4 *iface, REFIID riid, void **ppv)
|
|
|
|
{
|
|
|
|
HTMLStyleSheet *This = impl_from_IHTMLStyleSheet4(iface);
|
|
|
|
return IHTMLStyleSheet_QueryInterface(&This->IHTMLStyleSheet_iface, riid, ppv);
|
|
|
|
}
|
|
|
|
|
|
|
|
static ULONG WINAPI HTMLStyleSheet4_AddRef(IHTMLStyleSheet4 *iface)
|
|
|
|
{
|
|
|
|
HTMLStyleSheet *This = impl_from_IHTMLStyleSheet4(iface);
|
|
|
|
return IHTMLStyleSheet_AddRef(&This->IHTMLStyleSheet_iface);
|
|
|
|
}
|
|
|
|
|
|
|
|
static ULONG WINAPI HTMLStyleSheet4_Release(IHTMLStyleSheet4 *iface)
|
|
|
|
{
|
|
|
|
HTMLStyleSheet *This = impl_from_IHTMLStyleSheet4(iface);
|
|
|
|
return IHTMLStyleSheet_Release(&This->IHTMLStyleSheet_iface);
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI HTMLStyleSheet4_GetTypeInfoCount(IHTMLStyleSheet4 *iface, UINT *pctinfo)
|
|
|
|
{
|
|
|
|
HTMLStyleSheet *This = impl_from_IHTMLStyleSheet4(iface);
|
|
|
|
TRACE("(%p)->(%p)\n", This, pctinfo);
|
|
|
|
return IDispatchEx_GetTypeInfoCount(&This->dispex.IDispatchEx_iface, pctinfo);
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI HTMLStyleSheet4_GetTypeInfo(IHTMLStyleSheet4 *iface, UINT iTInfo,
|
|
|
|
LCID lcid, ITypeInfo **ppTInfo)
|
|
|
|
{
|
|
|
|
HTMLStyleSheet *This = impl_from_IHTMLStyleSheet4(iface);
|
|
|
|
return IDispatchEx_GetTypeInfo(&This->dispex.IDispatchEx_iface, iTInfo, lcid, ppTInfo);
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI HTMLStyleSheet4_GetIDsOfNames(IHTMLStyleSheet4 *iface, REFIID riid,
|
|
|
|
LPOLESTR *rgszNames, UINT cNames,
|
|
|
|
LCID lcid, DISPID *rgDispId)
|
|
|
|
{
|
|
|
|
HTMLStyleSheet *This = impl_from_IHTMLStyleSheet4(iface);
|
|
|
|
return IDispatchEx_GetIDsOfNames(&This->dispex.IDispatchEx_iface, riid, rgszNames, cNames, lcid, rgDispId);
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI HTMLStyleSheet4_Invoke(IHTMLStyleSheet4 *iface, DISPID dispIdMember,
|
|
|
|
REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS *pDispParams,
|
|
|
|
VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr)
|
|
|
|
{
|
|
|
|
HTMLStyleSheet *This = impl_from_IHTMLStyleSheet4(iface);
|
|
|
|
return IDispatchEx_Invoke(&This->dispex.IDispatchEx_iface, dispIdMember, riid, lcid, wFlags, pDispParams,
|
|
|
|
pVarResult, pExcepInfo, puArgErr);
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI HTMLStyleSheet4_get_type(IHTMLStyleSheet4 *iface, BSTR *p)
|
|
|
|
{
|
|
|
|
HTMLStyleSheet *This = impl_from_IHTMLStyleSheet4(iface);
|
|
|
|
TRACE("(%p)->(%p)\n", This, p);
|
|
|
|
return IHTMLStyleSheet_get_type(&This->IHTMLStyleSheet_iface, p);
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI HTMLStyleSheet4_get_href(IHTMLStyleSheet4 *iface, VARIANT *p)
|
|
|
|
{
|
|
|
|
HTMLStyleSheet *This = impl_from_IHTMLStyleSheet4(iface);
|
|
|
|
nsAString href_str;
|
|
|
|
nsresult nsres;
|
|
|
|
|
|
|
|
TRACE("(%p)->(%p)\n", This, p);
|
|
|
|
|
|
|
|
nsAString_Init(&href_str, NULL);
|
|
|
|
nsres = nsIDOMCSSStyleSheet_GetHref(This->nsstylesheet, &href_str);
|
|
|
|
return return_nsstr_variant(nsres, &href_str, 0, p);
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI HTMLStyleSheet4_get_title(IHTMLStyleSheet4 *iface, BSTR *p)
|
|
|
|
{
|
|
|
|
HTMLStyleSheet *This = impl_from_IHTMLStyleSheet4(iface);
|
|
|
|
FIXME("(%p)->(%p)\n", This, p);
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI HTMLStyleSheet4_get_ownerNode(IHTMLStyleSheet4 *iface, IHTMLElement **p)
|
|
|
|
{
|
|
|
|
HTMLStyleSheet *This = impl_from_IHTMLStyleSheet4(iface);
|
|
|
|
FIXME("(%p)->(%p)\n", This, p);
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI HTMLStyleSheet4_get_ownerRule(IHTMLStyleSheet4 *iface, IHTMLCSSRule **p)
|
|
|
|
{
|
|
|
|
HTMLStyleSheet *This = impl_from_IHTMLStyleSheet4(iface);
|
|
|
|
FIXME("(%p)->(%p)\n", This, p);
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI HTMLStyleSheet4_get_cssRules(IHTMLStyleSheet4 *iface, IHTMLStyleSheetRulesCollection **p)
|
|
|
|
{
|
|
|
|
HTMLStyleSheet *This = impl_from_IHTMLStyleSheet4(iface);
|
|
|
|
TRACE("(%p)->(%p)\n", This, p);
|
|
|
|
return IHTMLStyleSheet_get_rules(&This->IHTMLStyleSheet_iface, p);
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI HTMLStyleSheet4_get_media(IHTMLStyleSheet4 *iface, VARIANT *p)
|
|
|
|
{
|
|
|
|
HTMLStyleSheet *This = impl_from_IHTMLStyleSheet4(iface);
|
|
|
|
FIXME("(%p)->(%p)\n", This, p);
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
2021-04-07 00:24:23 +02:00
|
|
|
static HRESULT WINAPI HTMLStyleSheet4_insertRule(IHTMLStyleSheet4 *iface, BSTR rule, LONG index, LONG *p)
|
2021-04-07 00:24:13 +02:00
|
|
|
{
|
|
|
|
HTMLStyleSheet *This = impl_from_IHTMLStyleSheet4(iface);
|
2021-04-07 00:24:23 +02:00
|
|
|
UINT32 new_index = 0;
|
|
|
|
nsAString nsstr;
|
|
|
|
nsresult nsres;
|
|
|
|
|
|
|
|
TRACE("(%p)->(%s %d %p)\n", This, debugstr_w(rule), index, p);
|
|
|
|
|
|
|
|
nsAString_InitDepend(&nsstr, rule);
|
|
|
|
nsres = nsIDOMCSSStyleSheet_InsertRule(This->nsstylesheet, &nsstr, index, &new_index);
|
|
|
|
if(NS_FAILED(nsres)) WARN("failed: %08x\n", nsres);
|
|
|
|
nsAString_Finish(&nsstr);
|
|
|
|
*p = new_index;
|
|
|
|
return map_nsresult(nsres);
|
2021-04-07 00:24:13 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI HTMLStyleSheet4_deleteRule(IHTMLStyleSheet4 *iface, LONG index)
|
|
|
|
{
|
|
|
|
HTMLStyleSheet *This = impl_from_IHTMLStyleSheet4(iface);
|
|
|
|
FIXME("(%p)->(%d)\n", This, index);
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static const IHTMLStyleSheet4Vtbl HTMLStyleSheet4Vtbl = {
|
|
|
|
HTMLStyleSheet4_QueryInterface,
|
|
|
|
HTMLStyleSheet4_AddRef,
|
|
|
|
HTMLStyleSheet4_Release,
|
|
|
|
HTMLStyleSheet4_GetTypeInfoCount,
|
|
|
|
HTMLStyleSheet4_GetTypeInfo,
|
|
|
|
HTMLStyleSheet4_GetIDsOfNames,
|
|
|
|
HTMLStyleSheet4_Invoke,
|
|
|
|
HTMLStyleSheet4_get_type,
|
|
|
|
HTMLStyleSheet4_get_href,
|
|
|
|
HTMLStyleSheet4_get_title,
|
|
|
|
HTMLStyleSheet4_get_ownerNode,
|
|
|
|
HTMLStyleSheet4_get_ownerRule,
|
|
|
|
HTMLStyleSheet4_get_cssRules,
|
|
|
|
HTMLStyleSheet4_get_media,
|
|
|
|
HTMLStyleSheet4_insertRule,
|
|
|
|
HTMLStyleSheet4_deleteRule,
|
|
|
|
};
|
|
|
|
|
2021-04-07 00:24:30 +02:00
|
|
|
static void HTMLStyleSheet_init_dispex_info(dispex_data_t *info, compat_mode_t mode)
|
|
|
|
{
|
|
|
|
if(mode >= COMPAT_MODE_IE9)
|
|
|
|
dispex_info_add_interface(info, IHTMLStyleSheet4_tid, NULL);
|
|
|
|
}
|
|
|
|
|
2013-08-19 12:12:11 +02:00
|
|
|
static const tid_t HTMLStyleSheet_iface_tids[] = {
|
|
|
|
IHTMLStyleSheet_tid,
|
|
|
|
0
|
|
|
|
};
|
|
|
|
static dispex_static_data_t HTMLStyleSheet_dispex = {
|
2021-10-06 17:11:31 +02:00
|
|
|
L"CSSStyleSheet",
|
2013-08-19 12:12:11 +02:00
|
|
|
NULL,
|
|
|
|
DispHTMLStyleSheet_tid,
|
2021-04-07 00:24:30 +02:00
|
|
|
HTMLStyleSheet_iface_tids,
|
|
|
|
HTMLStyleSheet_init_dispex_info
|
2013-08-19 12:12:11 +02:00
|
|
|
};
|
|
|
|
|
2021-03-15 16:18:13 +01:00
|
|
|
HRESULT create_style_sheet(nsIDOMStyleSheet *nsstylesheet, compat_mode_t compat_mode, IHTMLStyleSheet **ret)
|
2006-11-17 13:08:09 +01:00
|
|
|
{
|
2021-03-15 16:18:13 +01:00
|
|
|
HTMLStyleSheet *style_sheet;
|
2007-11-25 19:08:40 +01:00
|
|
|
nsresult nsres;
|
2006-11-17 13:08:09 +01:00
|
|
|
|
2021-03-15 16:18:13 +01:00
|
|
|
if(!(style_sheet = heap_alloc(sizeof(HTMLStyleSheet))))
|
|
|
|
return E_OUTOFMEMORY;
|
2007-11-25 19:08:40 +01:00
|
|
|
|
2021-03-15 16:18:13 +01:00
|
|
|
style_sheet->IHTMLStyleSheet_iface.lpVtbl = &HTMLStyleSheetVtbl;
|
2021-04-07 00:24:13 +02:00
|
|
|
style_sheet->IHTMLStyleSheet4_iface.lpVtbl = &HTMLStyleSheet4Vtbl;
|
2021-03-15 16:18:13 +01:00
|
|
|
style_sheet->ref = 1;
|
|
|
|
style_sheet->nsstylesheet = NULL;
|
|
|
|
|
2021-03-16 19:57:45 +01:00
|
|
|
init_dispatch(&style_sheet->dispex, (IUnknown*)&style_sheet->IHTMLStyleSheet_iface,
|
|
|
|
&HTMLStyleSheet_dispex, compat_mode);
|
2013-08-19 12:12:11 +02:00
|
|
|
|
2007-11-25 19:08:40 +01:00
|
|
|
if(nsstylesheet) {
|
|
|
|
nsres = nsIDOMStyleSheet_QueryInterface(nsstylesheet, &IID_nsIDOMCSSStyleSheet,
|
2021-03-15 16:18:13 +01:00
|
|
|
(void**)&style_sheet->nsstylesheet);
|
2007-11-25 19:08:40 +01:00
|
|
|
if(NS_FAILED(nsres))
|
|
|
|
ERR("Could not get nsICSSStyleSheet interface: %08x\n", nsres);
|
|
|
|
}
|
2006-11-17 13:08:09 +01:00
|
|
|
|
2021-03-15 16:18:13 +01:00
|
|
|
*ret = &style_sheet->IHTMLStyleSheet_iface;
|
|
|
|
return S_OK;
|
2006-11-17 13:08:09 +01:00
|
|
|
}
|