Added support for shadowing of element pseudo-variables.

This commit is contained in:
Jacek Caban 2012-04-17 12:10:48 +02:00 committed by Alexandre Julliard
parent 34b41084a1
commit d987690212
4 changed files with 55 additions and 13 deletions

View File

@ -480,6 +480,19 @@ HRESULT dispex_get_dprop_ref(DispatchEx *This, const WCHAR *name, BOOL alloc, VA
return S_OK;
}
HRESULT dispex_get_dynid(DispatchEx *This, const WCHAR *name, DISPID *id)
{
dynamic_prop_t *prop;
HRESULT hres;
hres = get_dynamic_prop(This, name, fdexNameEnsure, &prop);
if(FAILED(hres))
return hres;
*id = DISPID_DYNPROP_0 + (prop - This->dynamic_data->props);
return S_OK;
}
static HRESULT dispex_value(DispatchEx *This, LCID lcid, WORD flags, DISPPARAMS *params,
VARIANT *res, EXCEPINFO *ei, IServiceProvider *caller)
{

View File

@ -2461,7 +2461,9 @@ static HRESULT HTMLWindow_invoke(DispatchEx *dispex, DISPID id, LCID lcid, WORD
IDispatch_Release(disp);
break;
}
case GLOBAL_ELEMENTVAR: {
case GLOBAL_ELEMENTVAR:
switch(flags) {
case DISPATCH_PROPERTYGET: {
IHTMLElement *elem;
hres = IHTMLDocument3_getElementById(&This->doc->basedoc.IHTMLDocument3_iface,
@ -2474,8 +2476,25 @@ static HRESULT HTMLWindow_invoke(DispatchEx *dispex, DISPID id, LCID lcid, WORD
V_VT(res) = VT_DISPATCH;
V_DISPATCH(res) = (IDispatch*)elem;
break;
return S_OK;
}
case DISPATCH_PROPERTYPUT: {
DISPID dispex_id;
hres = dispex_get_dynid(&This->dispex, prop->name, &dispex_id);
if(FAILED(hres))
return hres;
prop->type = GLOBAL_DISPEXVAR;
prop->id = dispex_id;
return IDispatchEx_InvokeEx(&This->dispex.IDispatchEx_iface, dispex_id, 0, flags, params, res, ei, caller);
}
default:
FIXME("Not suppoted flags: %x\n", flags);
return E_NOTIMPL;
}
case GLOBAL_DISPEXVAR:
return IDispatchEx_InvokeEx(&This->dispex.IDispatchEx_iface, prop->id, 0, flags, params, res, ei, caller);
default:
ERR("invalid type %d\n", prop->type);
hres = DISP_E_MEMBERNOTFOUND;

View File

@ -229,6 +229,7 @@ BOOL dispex_query_interface(DispatchEx*,REFIID,void**) DECLSPEC_HIDDEN;
HRESULT dispex_get_dprop_ref(DispatchEx*,const WCHAR*,BOOL,VARIANT**) DECLSPEC_HIDDEN;
HRESULT get_dispids(tid_t,DWORD*,DISPID**) DECLSPEC_HIDDEN;
HRESULT remove_prop(DispatchEx*,BSTR,VARIANT_BOOL*) DECLSPEC_HIDDEN;
HRESULT dispex_get_dynid(DispatchEx*,const WCHAR*,DISPID*) DECLSPEC_HIDDEN;
void release_typelib(void) DECLSPEC_HIDDEN;
HRESULT get_htmldoc_classinfo(ITypeInfo **typeinfo) DECLSPEC_HIDDEN;
@ -248,7 +249,8 @@ typedef struct ScriptHost ScriptHost;
typedef enum {
GLOBAL_SCRIPTVAR,
GLOBAL_ELEMENTVAR
GLOBAL_ELEMENTVAR,
GLOBAL_DISPEXVAR
} global_prop_type_t;
typedef struct {

View File

@ -60,6 +60,14 @@ function test_document_name_as_index() {
var e = document.getElementById("formid");
ok(!!e, "e is null");
ok(!("formid" in document), "formid is in document");
document.body.innerHTML = '<form name="formname"></form>';
ok("formname" in window, "formname' is not in window");
ok(typeof(window.formname) === "object", "typeof(window.formname) = " + typeof(window.formname));
window.formname = 1;
ok(window.formname === 1, "window.formname = " + window.formname);
formname = 2;
ok(window.formname === 2, "window.formname = " + window.formname);
}
function test_remove_style_attribute() {