mshtml: Store filter in HTMLElement object.

This commit is contained in:
Jacek Caban 2012-03-16 12:17:50 +01:00 committed by Alexandre Julliard
parent 7a320e5ca4
commit 348338257b
4 changed files with 26 additions and 11 deletions

View File

@ -507,7 +507,7 @@ static HRESULT WINAPI HTMLElement_get_style(IHTMLElement *iface, IHTMLStyle **p)
return E_FAIL;
}
hres = HTMLStyle_Create(nsstyle, &This->style);
hres = HTMLStyle_Create(This, nsstyle, &This->style);
nsIDOMCSSStyleDeclaration_Release(nsstyle);
if(FAILED(hres))
return hres;
@ -1648,8 +1648,10 @@ void HTMLElement_destructor(HTMLDOMNode *iface)
if(This->nselem)
nsIDOMHTMLElement_Release(This->nselem);
if(This->style)
if(This->style) {
This->style->elem = NULL;
IHTMLStyle_Release(&This->style->IHTMLStyle_iface);
}
if(This->attrs) {
HTMLDOMAttribute *attr;
@ -1660,6 +1662,8 @@ void HTMLElement_destructor(HTMLDOMNode *iface)
IHTMLAttributeCollection_Release(&This->attrs->IHTMLAttributeCollection_iface);
}
heap_free(This->filter);
HTMLDOMNode_destructor(&This->node);
}

View File

@ -694,7 +694,6 @@ static ULONG WINAPI HTMLStyle_Release(IHTMLStyle *iface)
if(!ref) {
if(This->nsstyle)
nsIDOMCSSStyleDeclaration_Release(This->nsstyle);
heap_free(This->filter);
release_dispex(&This->dispex);
heap_free(This);
}
@ -2597,7 +2596,7 @@ static void set_opacity(HTMLStyle *This, const WCHAR *val)
static void update_filter(HTMLStyle *This)
{
const WCHAR *ptr = This->filter, *ptr2;
const WCHAR *ptr = This->elem->filter, *ptr2;
static const WCHAR alphaW[] = {'a','l','p','h','a'};
@ -2683,14 +2682,19 @@ static HRESULT WINAPI HTMLStyle_put_filter(IHTMLStyle *iface, BSTR v)
TRACE("(%p)->(%s)\n", This, debugstr_w(v));
if(!This->elem) {
FIXME("Element already destroyed\n");
return E_UNEXPECTED;
}
if(v) {
new_filter = heap_strdupW(v);
if(!new_filter)
return E_OUTOFMEMORY;
}
heap_free(This->filter);
This->filter = new_filter;
heap_free(This->elem->filter);
This->elem->filter = new_filter;
update_filter(This);
return S_OK;
@ -2702,8 +2706,13 @@ static HRESULT WINAPI HTMLStyle_get_filter(IHTMLStyle *iface, BSTR *p)
TRACE("(%p)->(%p)\n", This, p);
if(This->filter) {
*p = SysAllocString(This->filter);
if(!This->elem) {
FIXME("Element already destroyed\n");
return E_UNEXPECTED;
}
if(This->elem->filter) {
*p = SysAllocString(This->elem->filter);
if(!*p)
return E_OUTOFMEMORY;
}else {
@ -3038,7 +3047,7 @@ static dispex_static_data_t HTMLStyle_dispex = {
HTMLStyle_iface_tids
};
HRESULT HTMLStyle_Create(nsIDOMCSSStyleDeclaration *nsstyle, HTMLStyle **ret)
HRESULT HTMLStyle_Create(HTMLElement *elem, nsIDOMCSSStyleDeclaration *nsstyle, HTMLStyle **ret)
{
HTMLStyle *style;
@ -3049,6 +3058,7 @@ HRESULT HTMLStyle_Create(nsIDOMCSSStyleDeclaration *nsstyle, HTMLStyle **ret)
style->IHTMLStyle_iface.lpVtbl = &HTMLStyleVtbl;
style->ref = 1;
style->nsstyle = nsstyle;
style->elem = elem;
HTMLStyle2_Init(style);
HTMLStyle3_Init(style);

View File

@ -28,7 +28,7 @@ struct HTMLStyle {
LONG ref;
nsIDOMCSSStyleDeclaration *nsstyle;
WCHAR *filter;
HTMLElement *elem;
};
/* NOTE: Make sure to keep in sync with style_tbl in htmlstyle.c */

View File

@ -556,6 +556,7 @@ typedef struct {
nsIDOMHTMLElement *nselem;
HTMLStyle *style;
HTMLAttributeCollection *attrs;
WCHAR *filter;
} HTMLElement;
#define HTMLELEMENT_TIDS \
@ -722,7 +723,7 @@ void set_ready_state(HTMLWindow*,READYSTATE) DECLSPEC_HIDDEN;
HRESULT HTMLSelectionObject_Create(HTMLDocumentNode*,nsISelection*,IHTMLSelectionObject**) DECLSPEC_HIDDEN;
HRESULT HTMLTxtRange_Create(HTMLDocumentNode*,nsIDOMRange*,IHTMLTxtRange**) DECLSPEC_HIDDEN;
HRESULT HTMLStyle_Create(nsIDOMCSSStyleDeclaration*,HTMLStyle**) DECLSPEC_HIDDEN;
HRESULT HTMLStyle_Create(HTMLElement*,nsIDOMCSSStyleDeclaration*,HTMLStyle**) DECLSPEC_HIDDEN;
IHTMLStyleSheet *HTMLStyleSheet_Create(nsIDOMStyleSheet*) DECLSPEC_HIDDEN;
IHTMLStyleSheetsCollection *HTMLStyleSheetsCollection_Create(nsIDOMStyleSheetList*) DECLSPEC_HIDDEN;