Module: wine Branch: master Commit: ebd918eb485d98f962276cfe75f765275a34cb6b URL: http://source.winehq.org/git/wine.git/?a=commit;h=ebd918eb485d98f962276cfe75...
Author: Jacek Caban jacek@codeweavers.com Date: Wed Sep 19 13:09:35 2007 +0200
mshtml: Added get_styleSheets implementation.
---
dlls/mshtml/htmldoc.c | 36 +++++++++- dlls/mshtml/htmlstylesheet.c | 152 +++++++++++++++++++++++++++++++++++++++++- dlls/mshtml/mshtml_private.h | 1 + dlls/mshtml/nsiface.idl | 22 ++++++ 4 files changed, 207 insertions(+), 4 deletions(-)
diff --git a/dlls/mshtml/htmldoc.c b/dlls/mshtml/htmldoc.c index 5e9f0ff..5ef1e13 100644 --- a/dlls/mshtml/htmldoc.c +++ b/dlls/mshtml/htmldoc.c @@ -951,10 +951,40 @@ static HRESULT WINAPI HTMLDocument_get_parentWindow(IHTMLDocument2 *iface, IHTML }
static HRESULT WINAPI HTMLDocument_get_styleSheets(IHTMLDocument2 *iface, - IHTMLStyleSheetsCollection **p) + IHTMLStyleSheetsCollection **p) { - FIXME("(%p)->(%p)\n", iface, p); - return E_NOTIMPL; + HTMLDocument *This = HTMLDOC_THIS(iface); + nsIDOMStyleSheetList *nsstylelist; + nsIDOMDocumentStyle *nsdocstyle; + nsIDOMDocument *nsdoc; + nsresult nsres; + + TRACE("(%p)->(%p)\n", This, p); + + *p = NULL; + + if(!This->nscontainer) + return S_OK; + + nsres = nsIWebNavigation_GetDocument(This->nscontainer->navigation, &nsdoc); + if(NS_FAILED(nsres)) { + ERR("GetDocument failed: %08x\n", nsres); + return S_OK; + } + + if(NS_FAILED(nsres) || !nsdoc) + return S_OK; + + nsIDOMDocument_QueryInterface(nsdoc, &IID_nsIDOMDocumentStyle, (void**)&nsdocstyle); + nsIDOMDocument_Release(nsdoc); + + nsIDOMDocumentStyle_GetStyleSheets(nsdocstyle, &nsstylelist); + nsIDOMDocumentStyle_Release(nsdocstyle); + + *p = HTMLStyleSheetsCollection_Create(nsstylelist); + nsIDOMDocumentStyle_Release(nsstylelist); + + return S_OK; }
static HRESULT WINAPI HTMLDocument_put_onbeforeupdate(IHTMLDocument2 *iface, VARIANT v) diff --git a/dlls/mshtml/htmlstylesheet.c b/dlls/mshtml/htmlstylesheet.c index 0f0ef12..00a71f6 100644 --- a/dlls/mshtml/htmlstylesheet.c +++ b/dlls/mshtml/htmlstylesheet.c @@ -41,7 +41,157 @@ typedef struct { LONG ref; } HTMLStyleSheet;
-#define HTMLSTYLESHEET(x) ((IHTMLStyleSheet*) &(x)->lpHTMLStyleSheetVtbl); +typedef struct { + const IHTMLStyleSheetsCollectionVtbl *lpHTMLStyleSheetsCollectionVtbl; + + LONG ref; + + nsIDOMStyleSheetList *nslist; +} HTMLStyleSheetsCollection; + +#define HTMLSTYLESHEET(x) ((IHTMLStyleSheet*) &(x)->lpHTMLStyleSheetVtbl); +#define HTMLSTYLESHEETSCOL(x) ((IHTMLStyleSheetsCollection*) &(x)->lpHTMLStyleSheetsCollectionVtbl); + +#define HTMLSTYLESHEETSCOL_THIS(iface) \ + DEFINE_THIS(HTMLStyleSheetsCollection, HTMLStyleSheetsCollection, iface) + +static HRESULT WINAPI HTMLStyleSheetsCollection_QueryInterface(IHTMLStyleSheetsCollection *iface, + REFIID riid, void **ppv) +{ + HTMLStyleSheetsCollection *This = HTMLSTYLESHEETSCOL_THIS(iface); + + *ppv = NULL; + + if(IsEqualGUID(&IID_IUnknown, riid)) { + TRACE("(%p)->(IID_IUnknown %p)\n", This, ppv); + *ppv = HTMLSTYLESHEETSCOL(This); + }else if(IsEqualGUID(&IID_IDispatch, riid)) { + TRACE("(%p)->(IID_IDispatch %p)\n", This, ppv); + *ppv = HTMLSTYLESHEETSCOL(This); + }else if(IsEqualGUID(&IID_IHTMLStyleSheetsCollection, riid)) { + TRACE("(%p)->(IID_IHTMLStyleSheetsCollection %p)\n", This, ppv); + *ppv = HTMLSTYLESHEETSCOL(This); + } + + if(*ppv) { + IUnknown_AddRef((IUnknown*)*ppv); + return S_OK; + } + + WARN("unsupported %s\n", debugstr_guid(riid)); + return E_NOINTERFACE; +} + +static ULONG WINAPI HTMLStyleSheetsCollection_AddRef(IHTMLStyleSheetsCollection *iface) +{ + HTMLStyleSheetsCollection *This = HTMLSTYLESHEETSCOL_THIS(iface); + LONG ref = InterlockedIncrement(&This->ref); + + TRACE("(%p) ref=%d\n", This, ref); + + return ref; +} + +static ULONG WINAPI HTMLStyleSheetsCollection_Release(IHTMLStyleSheetsCollection *iface) +{ + HTMLStyleSheetsCollection *This = HTMLSTYLESHEETSCOL_THIS(iface); + LONG ref = InterlockedDecrement(&This->ref); + + TRACE("(%p) ref=%d\n", This, ref); + + if(!ref) + mshtml_free(This); + + return ref; +} + +static HRESULT WINAPI HTMLStyleSheetsCollection_GetTypeInfoCount(IHTMLStyleSheetsCollection *iface, + UINT *pctinfo) +{ + HTMLStyleSheetsCollection *This = HTMLSTYLESHEETSCOL_THIS(iface); + FIXME("(%p)->(%p)\n", This, pctinfo); + return E_NOTIMPL; +} + +static HRESULT WINAPI HTMLStyleSheetsCollection_GetTypeInfo(IHTMLStyleSheetsCollection *iface, + UINT iTInfo, LCID lcid, ITypeInfo **ppTInfo) +{ + HTMLStyleSheetsCollection *This = HTMLSTYLESHEETSCOL_THIS(iface); + FIXME("(%p)->(%u %u %p)\n", This, iTInfo, lcid, ppTInfo); + return E_NOTIMPL; +} + +static HRESULT WINAPI HTMLStyleSheetsCollection_GetIDsOfNames(IHTMLStyleSheetsCollection *iface, + REFIID riid, LPOLESTR *rgszNames, UINT cNames, LCID lcid, DISPID *rgDispId) +{ + HTMLStyleSheetsCollection *This = HTMLSTYLESHEETSCOL_THIS(iface); + FIXME("(%p)->(%s %p %u %u %p)\n", This, debugstr_guid(riid), rgszNames, cNames, + lcid, rgDispId); + return E_NOTIMPL; +} + +static HRESULT WINAPI HTMLStyleSheetsCollection_Invoke(IHTMLStyleSheetsCollection *iface, + DISPID dispIdMember, REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS *pDispParams, + VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr) +{ + HTMLStyleSheetsCollection *This = HTMLSTYLESHEETSCOL_THIS(iface); + FIXME("(%p)->(%d %s %d %d %p %p %p %p)\n", This, dispIdMember, debugstr_guid(riid), + lcid, wFlags, pDispParams, pVarResult, pExcepInfo, puArgErr); + return E_NOTIMPL; +} + +static HRESULT WINAPI HTMLStyleSheetsCollection_get_length(IHTMLStyleSheetsCollection *iface, + long *p) +{ + HTMLStyleSheetsCollection *This = HTMLSTYLESHEETSCOL_THIS(iface); + FIXME("(%p)->(%p)\n", This, p); + return E_NOTIMPL; +} + +static HRESULT WINAPI HTMLStyleSheetsCollection_get__newEnum(IHTMLStyleSheetsCollection *iface, + IUnknown **p) +{ + HTMLStyleSheetsCollection *This = HTMLSTYLESHEETSCOL_THIS(iface); + FIXME("(%p)->(%p)\n", This, p); + return E_NOTIMPL; +} + +static HRESULT WINAPI HTMLStyleSheetsCollection_item(IHTMLStyleSheetsCollection *iface, + VARIANT *pvarIndex, VARIANT *pvarResult) +{ + HTMLStyleSheetsCollection *This = HTMLSTYLESHEETSCOL_THIS(iface); + FIXME("(%p)->(%p %p)\n", This, pvarIndex, pvarResult); + return E_NOTIMPL; +} + +#undef HTMLSTYLESHEETSCOL_THIS + +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 +}; + +IHTMLStyleSheetsCollection *HTMLStyleSheetsCollection_Create(nsIDOMStyleSheetList *nslist) +{ + HTMLStyleSheetsCollection *ret = mshtml_alloc(sizeof(HTMLStyleSheetsCollection)); + + ret->lpHTMLStyleSheetsCollectionVtbl = &HTMLStyleSheetsCollectionVtbl; + ret->ref = 1; + + if(nslist) + nsIDOMStyleSheetList_AddRef(nslist); + ret->nslist = nslist; + + return HTMLSTYLESHEETSCOL(ret); +}
#define HTMLSTYLESHEET_THIS(iface) DEFINE_THIS(HTMLStyleSheet, HTMLStyleSheet, iface)
diff --git a/dlls/mshtml/mshtml_private.h b/dlls/mshtml/mshtml_private.h index e560ef1..b07476f 100644 --- a/dlls/mshtml/mshtml_private.h +++ b/dlls/mshtml/mshtml_private.h @@ -406,6 +406,7 @@ IHTMLSelectionObject *HTMLSelectionObject_Create(HTMLDocument*,nsISelection*); IHTMLTxtRange *HTMLTxtRange_Create(HTMLDocument*,nsIDOMRange*); IHTMLStyle *HTMLStyle_Create(nsIDOMCSSStyleDeclaration*); IHTMLStyleSheet *HTMLStyleSheet_Create(void); +IHTMLStyleSheetsCollection *HTMLStyleSheetsCollection_Create(nsIDOMStyleSheetList*);
void detach_selection(HTMLDocument*); void detach_ranges(HTMLDocument*); diff --git a/dlls/mshtml/nsiface.idl b/dlls/mshtml/nsiface.idl index 4a3347d..c79b17e 100644 --- a/dlls/mshtml/nsiface.idl +++ b/dlls/mshtml/nsiface.idl @@ -123,6 +123,7 @@ typedef nsISupports nsIPrincipal; typedef nsISupports nsIAtom; typedef nsISupports nsISupportsArray; typedef nsISupports nsIContentFilter; +typedef nsISupports nsIDOMStyleSheet;
[ object, @@ -571,6 +572,17 @@ interface nsIDOMCSSStyleDeclaration : nsISupports
[ object, + uuid(a6cf9081-15b3-11d2-932e-00805f8add32) + /* FROZEN */ +] +interface nsIDOMStyleSheetList : nsISupports +{ + nsresult GetLength(PRUint32 *aLength); + nsresult Item(PRUint32 index, nsIDOMStyleSheet **_retval); +} + +[ + object, uuid(a6cf907d-15b3-11d2-932e-00805f8add32) /* FROZEN */ ] @@ -824,6 +836,16 @@ interface nsIDOMHTMLDocument : nsIDOMDocument
[ object, + uuid(3d9f4973-dd2e-48f5-b5f7-2634e09eadd9) + /* FROZEN */ +] +interface nsIDOMDocumentStyle : nsISupports +{ + nsresult GetStyleSheets(nsIDOMStyleSheetList **aStyleSheets); +} + +[ + object, uuid(a6cf90ce-15b3-11d2-932e-00805f8add32) /* FROZEN */ ]