diff --git a/dlls/mshtml/htmlcurstyle.c b/dlls/mshtml/htmlcurstyle.c index 45680877632..ffce224c08b 100644 --- a/dlls/mshtml/htmlcurstyle.c +++ b/dlls/mshtml/htmlcurstyle.c @@ -37,6 +37,8 @@ typedef struct { const IHTMLCurrentStyleVtbl *lpIHTMLCurrentStyleVtbl; LONG ref; + + nsIDOMCSSStyleDeclaration *nsstyle; } HTMLCurrentStyle; #define HTMLCURSTYLE(x) ((IHTMLCurrentStyle*) &(x)->lpIHTMLCurrentStyleVtbl) @@ -85,8 +87,11 @@ static ULONG WINAPI HTMLCurrentStyle_Release(IHTMLCurrentStyle *iface) TRACE("(%p) ref=%d\n", This, ref); - if(!ref) + if(!ref) { + if(This->nsstyle) + nsIDOMCSSStyleDeclaration_Release(This->nsstyle); heap_free(This); + } return ref; } @@ -875,16 +880,62 @@ static dispex_static_data_t HTMLCurrentStyle_dispex = { HTMLCurrentStyle_iface_tids }; -HRESULT HTMLCurrentStyle_Create(IHTMLCurrentStyle **p) +HRESULT HTMLCurrentStyle_Create(HTMLElement *elem, IHTMLCurrentStyle **p) { + nsIDOMCSSStyleDeclaration *nsstyle; + nsIDOMDocumentView *nsdocview; + nsIDOMAbstractView *nsview; + nsIDOMViewCSS *nsviewcss; + nsIDOMDocument *nsdoc; + nsAString nsempty_str; HTMLCurrentStyle *ret; + nsresult nsres; + + nsres = nsIWebNavigation_GetDocument(elem->node.doc->nscontainer->navigation, &nsdoc); + if(NS_FAILED(nsres)) { + ERR("GetDocument failed: %08x\n", nsres); + return E_FAIL; + } + + nsres = nsIDOMDocument_QueryInterface(nsdoc, &IID_nsIDOMDocumentView, (void**)&nsdocview); + nsIDOMDocument_Release(nsdoc); + if(NS_FAILED(nsres)) { + ERR("Could not get nsIDOMDocumentView: %08x\n", nsres); + return E_FAIL; + } + + nsres = nsIDOMDocumentView_GetDefaultView(nsdocview, &nsview); + nsIDOMDocumentView_Release(nsdocview); + if(NS_FAILED(nsres)) { + ERR("GetDefaultView failed: %08x\n", nsres); + return E_FAIL; + } + + nsres = nsIDOMAbstractView_QueryInterface(nsview, &IID_nsIDOMViewCSS, (void**)&nsviewcss); + nsIDOMAbstractView_Release(nsview); + if(NS_FAILED(nsres)) { + ERR("Could not get nsIDOMViewCSS: %08x\n", nsres); + return E_FAIL; + } + + nsAString_Init(&nsempty_str, NULL); + nsres = nsIDOMViewCSS_GetComputedStyle(nsviewcss, (nsIDOMElement*)elem->nselem, &nsempty_str, &nsstyle); + nsIDOMViewCSS_Release(nsviewcss); + nsAString_Finish(&nsempty_str); + if(NS_FAILED(nsres)) { + ERR("GetComputedStyle failed: %08x\n", nsres); + return E_FAIL; + } ret = heap_alloc_zero(sizeof(HTMLCurrentStyle)); - if(!ret) + if(!ret) { + nsIDOMCSSStyleDeclaration_Release(nsstyle); return E_OUTOFMEMORY; + } ret->lpIHTMLCurrentStyleVtbl = &HTMLCurrentStyleVtbl; ret->ref = 1; + ret->nsstyle = nsstyle; init_dispex(&ret->dispex, (IUnknown*)HTMLCURSTYLE(ret), &HTMLCurrentStyle_dispex); diff --git a/dlls/mshtml/htmlelem2.c b/dlls/mshtml/htmlelem2.c index 36676c675eb..14650863acb 100644 --- a/dlls/mshtml/htmlelem2.c +++ b/dlls/mshtml/htmlelem2.c @@ -321,7 +321,7 @@ static HRESULT WINAPI HTMLElement2_get_currentStyle(IHTMLElement2 *iface, IHTMLC TRACE("(%p)->(%p)\n", This, p); - return HTMLCurrentStyle_Create(p); + return HTMLCurrentStyle_Create(This, p); } static HRESULT WINAPI HTMLElement2_put_onpropertychange(IHTMLElement2 *iface, VARIANT v) diff --git a/dlls/mshtml/mshtml_private.h b/dlls/mshtml/mshtml_private.h index 4df7efe1743..626cb8b99f7 100644 --- a/dlls/mshtml/mshtml_private.h +++ b/dlls/mshtml/mshtml_private.h @@ -474,7 +474,7 @@ void HTMLDocument_Window_Init(HTMLDocument*); void HTMLDocument_Service_Init(HTMLDocument*); void HTMLDocument_Hlink_Init(HTMLDocument*); -HRESULT HTMLCurrentStyle_Create(IHTMLCurrentStyle**); +HRESULT HTMLCurrentStyle_Create(HTMLElement*,IHTMLCurrentStyle**); void ConnectionPoint_Init(ConnectionPoint*,ConnectionPointContainer*,REFIID); void ConnectionPointContainer_Init(ConnectionPointContainer*,IUnknown*); diff --git a/dlls/mshtml/nsiface.idl b/dlls/mshtml/nsiface.idl index bedac821595..93e25f11cbe 100644 --- a/dlls/mshtml/nsiface.idl +++ b/dlls/mshtml/nsiface.idl @@ -82,6 +82,7 @@ interface nsIEditorObserver; interface nsIEditActionListener; interface nsIDocumentStateListener; interface nsIDOMCSSStyleSheet; +interface nsIDOMDocumentView; interface IMoniker; @@ -100,7 +101,6 @@ interface nsISupports /* Currently we don't need a full declaration of these interfaces */ typedef nsISupports nsISHistory; typedef nsISupports nsIWidget; -typedef nsISupports nsIDOMAbstractView; typedef nsISupports nsIHttpHeaderVisitor; typedef nsISupports nsIDOMBarProp; typedef nsISupports nsIDOMWindowCollection; @@ -885,6 +885,28 @@ interface nsIDOMDocumentFragment : nsIDOMNode { } +[ + object, + uuid(f51ebade-8b1a-11d3-aae7-0010830123b4), + local + /* FROZEN */ +] +interface nsIDOMAbstractView : nsISupports +{ + nsresult GetDocument(nsIDOMDocumentView **aDocument); +} + +[ + object, + uuid(0b9341f3-95d4-4fa4-adcd-e119e0db2889), + local + /* NOT_FROZEN */ +] +interface nsIDOMViewCSS : nsIDOMAbstractView +{ + nsresult GetComputedStyle(nsIDOMElement *elt, const nsAString *pseudoElt, nsIDOMCSSStyleDeclaration **_retval); +} + [ object, uuid(a6cf9075-15b3-11d2-932e-00805f8add32), @@ -1001,6 +1023,17 @@ interface nsIDOMDocumentStyle : nsISupports nsresult GetStyleSheets(nsIDOMStyleSheetList **aStyleSheets); } +[ + object, + uuid(1acdb2ba-1dd2-11b2-95bc-9542495d2569), + local + /* FROZEN */ +] +interface nsIDOMDocumentView : nsISupports +{ + nsresult GetDefaultView(nsIDOMAbstractView **aDefaultView); +} + [ object, uuid(a6cf90ce-15b3-11d2-932e-00805f8add32),