Commit 0a03ae75 authored by Piotr Caban's avatar Piotr Caban Committed by Alexandre Julliard

mshtml: Populate dynamic properties table in get_dynamic_data.

parent 423c6f94
......@@ -366,11 +366,19 @@ static HRESULT variant_copy(VARIANT *dest, VARIANT *src)
return VariantCopy(dest, src);
}
static inline dispex_dynamic_data_t *get_dynamic_data(DispatchEx *This, BOOL alloc)
static inline dispex_dynamic_data_t *get_dynamic_data(DispatchEx *This)
{
return !alloc || This->dynamic_data
? This->dynamic_data
: (This->dynamic_data = heap_alloc_zero(sizeof(dispex_dynamic_data_t)));
if(This->dynamic_data)
return This->dynamic_data;
This->dynamic_data = heap_alloc_zero(sizeof(dispex_dynamic_data_t));
if(!This->dynamic_data)
return NULL;
if(This->data->vtbl && This->data->vtbl->populate_props)
This->data->vtbl->populate_props(This);
return This->dynamic_data;
}
static HRESULT get_dynamic_prop(DispatchEx *This, const WCHAR *name, DWORD flags, dynamic_prop_t **ret)
......@@ -379,14 +387,9 @@ static HRESULT get_dynamic_prop(DispatchEx *This, const WCHAR *name, DWORD flags
dispex_dynamic_data_t *data;
dynamic_prop_t *prop;
data = get_dynamic_data(This, alloc);
if(!data) {
if(alloc)
return E_OUTOFMEMORY;
TRACE("not found %s\n", debugstr_w(name));
return DISP_E_UNKNOWNNAME;
}
data = get_dynamic_data(This);
if(!data)
return E_OUTOFMEMORY;
for(prop = data->props; prop < data->props+data->prop_cnt; prop++) {
if(flags & fdexNameCaseInsensitive ? !strcmpiW(prop->name, name) : !strcmpW(prop->name, name)) {
......@@ -570,6 +573,7 @@ static HRESULT function_value(DispatchEx *dispex, LCID lcid, WORD flags, DISPPAR
static const dispex_static_data_vtbl_t function_dispex_vtbl = {
function_value,
NULL,
NULL,
NULL
};
......@@ -625,7 +629,7 @@ static HRESULT function_invoke(DispatchEx *This, func_info_t *func, WORD flags,
return S_OK;
}
dynamic_data = get_dynamic_data(This, TRUE);
dynamic_data = get_dynamic_data(This);
if(!dynamic_data)
return E_OUTOFMEMORY;
......
......@@ -2119,7 +2119,8 @@ static HRESULT HTMLDocumentNode_invoke(DispatchEx *dispex, DISPID id, LCID lcid,
static const dispex_static_data_vtbl_t HTMLDocumentNode_dispex_vtbl = {
NULL,
NULL,
HTMLDocumentNode_invoke
HTMLDocumentNode_invoke,
NULL
};
static const NodeImplVtbl HTMLDocumentFragmentImplVtbl = {
......
......@@ -1778,6 +1778,88 @@ static HRESULT HTMLElement_invoke(DispatchEx *dispex, DISPID id, LCID lcid,
return E_NOTIMPL;
}
static HRESULT HTMLElement_populate_props(DispatchEx *dispex)
{
HTMLElement *This = impl_from_DispatchEx(dispex);
nsIDOMNamedNodeMap *attrs;
nsIDOMNode *node;
nsAString nsstr;
const PRUnichar *str;
BSTR name;
VARIANT value;
unsigned i;
PRUint32 len;
DISPID id;
nsresult nsres;
HRESULT hres;
if(!This->nselem)
return S_FALSE;
nsres = nsIDOMHTMLElement_GetAttributes(This->nselem, &attrs);
if(NS_FAILED(nsres))
return E_FAIL;
nsres = nsIDOMNamedNodeMap_GetLength(attrs, &len);
if(NS_FAILED(nsres)) {
nsIDOMNamedNodeMap_Release(attrs);
return E_FAIL;
}
nsAString_Init(&nsstr, NULL);
for(i=0; i<len; i++) {
nsres = nsIDOMNamedNodeMap_Item(attrs, i, &node);
if(NS_FAILED(nsres))
continue;
nsres = nsIDOMNode_GetNodeName(node, &nsstr);
if(NS_FAILED(nsres)) {
nsIDOMNode_Release(node);
continue;
}
nsAString_GetData(&nsstr, &str);
name = SysAllocString(str);
if(!name) {
nsIDOMNode_Release(node);
continue;
}
hres = IDispatchEx_GetDispID(&dispex->IDispatchEx_iface, name, fdexNameCaseInsensitive, &id);
if(hres != DISP_E_UNKNOWNNAME) {
nsIDOMNode_Release(node);
SysFreeString(name);
continue;
}
nsres = nsIDOMNode_GetNodeValue(node, &nsstr);
nsIDOMNode_Release(node);
if(NS_FAILED(nsres)) {
SysFreeString(name);
continue;
}
nsAString_GetData(&nsstr, &str);
V_VT(&value) = VT_BSTR;
if(*str) {
V_BSTR(&value) = SysAllocString(str);
if(!V_BSTR(&value)) {
SysFreeString(name);
continue;
}
} else
V_BSTR(&value) = NULL;
IHTMLElement_setAttribute(&This->IHTMLElement_iface, name, value, 0);
SysFreeString(name);
VariantClear(&value);
}
nsAString_Finish(&nsstr);
nsIDOMNamedNodeMap_Release(attrs);
return S_OK;
}
static const tid_t HTMLElement_iface_tids[] = {
HTMLELEMENT_TIDS,
0
......@@ -1786,7 +1868,8 @@ static const tid_t HTMLElement_iface_tids[] = {
static dispex_static_data_vtbl_t HTMLElement_dispex_vtbl = {
NULL,
HTMLElement_get_dispid,
HTMLElement_invoke
HTMLElement_invoke,
HTMLElement_populate_props
};
static dispex_static_data_t HTMLElement_dispex = {
......@@ -2017,7 +2100,8 @@ static HRESULT HTMLFiltersCollection_invoke(DispatchEx *dispex, DISPID id, LCID
static const dispex_static_data_vtbl_t HTMLFiltersCollection_dispex_vtbl = {
NULL,
HTMLFiltersCollection_get_dispid,
HTMLFiltersCollection_invoke
HTMLFiltersCollection_invoke,
NULL
};
static const tid_t HTMLFiltersCollection_iface_tids[] = {
......
......@@ -470,7 +470,8 @@ static HRESULT HTMLElementCollection_invoke(DispatchEx *dispex, DISPID id, LCID
static const dispex_static_data_vtbl_t HTMLElementColection_dispex_vtbl = {
NULL,
HTMLElementCollection_get_dispid,
HTMLElementCollection_invoke
HTMLElementCollection_invoke,
NULL
};
static const tid_t HTMLElementCollection_iface_tids[] = {
......
......@@ -921,6 +921,7 @@ static const tid_t HTMLImageElementFactory_iface_tids[] = {
static const dispex_static_data_vtbl_t HTMLImageElementFactory_dispex_vtbl = {
HTMLImageElementFactory_value,
NULL,
NULL,
NULL
};
......
......@@ -260,7 +260,8 @@ static HRESULT HTMLDOMChildrenCollection_invoke(DispatchEx *dispex, DISPID id, L
static const dispex_static_data_vtbl_t HTMLDOMChildrenCollection_dispex_vtbl = {
NULL,
HTMLDOMChildrenCollection_get_dispid,
HTMLDOMChildrenCollection_invoke
HTMLDOMChildrenCollection_invoke,
NULL
};
static const tid_t HTMLDOMChildrenCollection_iface_tids[] = {
......
......@@ -3063,6 +3063,7 @@ static HRESULT HTMLStyle_get_dispid(DispatchEx *dispex, BSTR name, DWORD flags,
static const dispex_static_data_vtbl_t HTMLStyle_dispex_vtbl = {
NULL,
HTMLStyle_get_dispid,
NULL,
NULL
};
......
......@@ -2330,7 +2330,8 @@ static HRESULT HTMLWindow_invoke(DispatchEx *dispex, DISPID id, LCID lcid, WORD
static const dispex_static_data_vtbl_t HTMLWindow_dispex_vtbl = {
NULL,
NULL,
HTMLWindow_invoke
HTMLWindow_invoke,
NULL
};
static const tid_t HTMLWindow_iface_tids[] = {
......
......@@ -190,6 +190,7 @@ typedef struct {
HRESULT (*value)(DispatchEx*,LCID,WORD,DISPPARAMS*,VARIANT*,EXCEPINFO*,IServiceProvider*);
HRESULT (*get_dispid)(DispatchEx*,BSTR,DWORD,DISPID*);
HRESULT (*invoke)(DispatchEx*,DISPID,LCID,WORD,DISPPARAMS*,VARIANT*,EXCEPINFO*,IServiceProvider*);
HRESULT (*populate_props)(DispatchEx*);
} dispex_static_data_vtbl_t;
typedef struct {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment