From 5a9980e1b73c591c1f682cb6142b6fb19cc9012e Mon Sep 17 00:00:00 2001 From: Jacek Caban Date: Fri, 17 Nov 2006 13:05:01 +0100 Subject: [PATCH] mshtml: Store nsIDOMCSSStyleDeclaration in HTMLStyle. --- dlls/mshtml/htmlelem.c | 23 +++++++++++++++++++++-- dlls/mshtml/htmlstyle.c | 7 ++++++- dlls/mshtml/mshtml_private.h | 2 +- dlls/mshtml/nsiface.idl | 30 ++++++++++++++++++++++++++++++ 4 files changed, 58 insertions(+), 4 deletions(-) diff --git a/dlls/mshtml/htmlelem.c b/dlls/mshtml/htmlelem.c index 57419b094ab..37abb518f2b 100644 --- a/dlls/mshtml/htmlelem.c +++ b/dlls/mshtml/htmlelem.c @@ -243,11 +243,30 @@ static HRESULT WINAPI HTMLElement_get_parentElement(IHTMLElement *iface, IHTMLEl static HRESULT WINAPI HTMLElement_get_style(IHTMLElement *iface, IHTMLStyle **p) { HTMLElement *This = HTMLELEM_THIS(iface); + nsIDOMElementCSSInlineStyle *nselemstyle; + nsIDOMCSSStyleDeclaration *nsstyle; + nsresult nsres; TRACE("(%p)->(%p)\n", This, p); - /* FIXME: Store IHTMLStyle instead of creating a new instance in every call. */ - *p = HTMLStyle_Create(); + nsres = nsIDOMHTMLElement_QueryInterface(This->nselem, &IID_nsIDOMElementCSSInlineStyle, + (void**)&nselemstyle); + if(NS_FAILED(nsres)) { + ERR("Coud not get nsIDOMCSSStyleDeclaration interface: %08x\n", nsres); + return E_FAIL; + } + + nsres = nsIDOMElementCSSInlineStyle_GetStyle(nselemstyle, &nsstyle); + nsIDOMElementCSSInlineStyle_Release(nselemstyle); + if(NS_FAILED(nsres)) { + ERR("GetStyle failed: %08x\n", nsres); + return E_FAIL; + } + + /* FIXME: Store style instead of creating a new instance in each call */ + *p = HTMLStyle_Create(nsstyle); + + nsIDOMCSSStyleDeclaration_Release(nsstyle); return S_OK; } diff --git a/dlls/mshtml/htmlstyle.c b/dlls/mshtml/htmlstyle.c index 57000d782ef..9bc03338059 100644 --- a/dlls/mshtml/htmlstyle.c +++ b/dlls/mshtml/htmlstyle.c @@ -40,6 +40,8 @@ typedef struct { const IHTMLStyleVtbl *lpHTMLStyleVtbl; LONG ref; + + nsIDOMCSSStyleDeclaration *nsstyle; } HTMLStyle; #define HTMLSTYLE(x) ((IHTMLStyle*) &(x)->lpHTMLStyleVtbl); @@ -1578,12 +1580,15 @@ static const IHTMLStyleVtbl HTMLStyleVtbl = { HTMLStyle_toString }; -IHTMLStyle *HTMLStyle_Create(void) +IHTMLStyle *HTMLStyle_Create(nsIDOMCSSStyleDeclaration *nsstyle) { HTMLStyle *ret = mshtml_alloc(sizeof(HTMLStyle)); ret->lpHTMLStyleVtbl = &HTMLStyleVtbl; ret->ref = 1; + ret->nsstyle = nsstyle; + + nsIDOMCSSStyleDeclaration_AddRef(nsstyle); return HTMLSTYLE(ret); } diff --git a/dlls/mshtml/mshtml_private.h b/dlls/mshtml/mshtml_private.h index 287d5748451..abc283b393e 100644 --- a/dlls/mshtml/mshtml_private.h +++ b/dlls/mshtml/mshtml_private.h @@ -329,7 +329,7 @@ void set_document_bscallback(HTMLDocument*,BSCallback*); IHlink *Hlink_Create(void); IHTMLSelectionObject *HTMLSelectionObject_Create(nsISelection*); IHTMLTxtRange *HTMLTxtRange_Create(nsISelection*); -IHTMLStyle *HTMLStyle_Create(void); +IHTMLStyle *HTMLStyle_Create(nsIDOMCSSStyleDeclaration*); void HTMLElement_Create(HTMLDOMNode*); void HTMLBodyElement_Create(HTMLElement*); diff --git a/dlls/mshtml/nsiface.idl b/dlls/mshtml/nsiface.idl index 0e59bc94c56..39a9da7b116 100644 --- a/dlls/mshtml/nsiface.idl +++ b/dlls/mshtml/nsiface.idl @@ -110,6 +110,8 @@ typedef nsISupports nsIDOMHTMLCollection; typedef nsISupports nsIDOMRange; typedef nsISupports nsIEditor; typedef nsISupports nsIWebProgressListener; +typedef nsISupports nsIDOMCSSValue; +typedef nsISupports nsIDOMCSSRule; [ object, @@ -375,6 +377,25 @@ interface nsIUploadChannel : nsISupports nsresult GetUploadStream(nsIInputStream **aUploadStream); } +[ + object, + uuid(a6cf90be-15b3-11d2-932e-00805f8add32) +] +interface nsIDOMCSSStyleDeclaration : nsISupports +{ + nsresult GetCssText(nsAString *aCssText); + nsresult SetCssText(const nsAString *aCssText); + nsresult GetPropertyValue(const nsAString *propertyName, nsAString *_retval); + nsresult GetPropertyCSSValue(const nsAString *propertyName, nsIDOMCSSValue **_retval); + nsresult RemoveProperty(const nsAString *propertyName, nsAString *_retval); + nsresult GetPropertyPriority(const nsAString *propertyName, nsAString *_retval); + nsresult SetProperty(const nsAString *propertyName, const nsAString *value, + const nsAString *priority); + nsresult GetLength(PRUint32 *aLength); + nsresult Item(PRUint32 index, nsAString *_retval); + nsresult GetParentRule(nsIDOMCSSRule **aParentRule); +} + [ object, uuid(a6cf907d-15b3-11d2-932e-00805f8add32) @@ -462,6 +483,15 @@ interface nsIDOMElement : nsIDOMNode PRBool *_retval); } +[ + object, + uuid(99715845-95fc-4a56-aa53-214b65c26e22) +] +interface nsIDOMElementCSSInlineStyle : nsISupports +{ + nsresult GetStyle(nsIDOMCSSStyleDeclaration **aStyle); +} + cpp_quote("#undef GetClassName"); [