Fixing nsbeta3+ 49112. Making with(someimageelement) { src=someurl; } work by dynamically defining the 'src' property in nsHTMLImageElement::Resolve() (since src is defined as [noscript] in the IDL). r/a=vidur, r/a=brendan

This commit is contained in:
jst%netscape.com 2000-09-21 02:42:46 +00:00
Родитель e7673eb0e8
Коммит 6e53f5662f
2 изменённых файлов: 42 добавлений и 0 удалений

Просмотреть файл

@ -725,6 +725,27 @@ nsHTMLImageElement::EnumerateProperty(JSContext *aContext, JSObject *aObj)
PRBool
nsHTMLImageElement::Resolve(JSContext *aContext, JSObject *aObj, jsval aID)
{
if (JSVAL_IS_STRING(aID) && mInner.mDOMSlots) {
JSString *str;
str = JSVAL_TO_STRING(aID);
const jschar *chars = ::JS_GetStringChars(str);
const PRUnichar *unichars = NS_REINTERPRET_CAST(const PRUnichar*, chars);
if (!nsCRT::strcmp(unichars, NS_LITERAL_STRING("src").get())) {
// Someone is trying to resolve "src" so we deifine it on the
// object with a JSVAL_VOID value, the real value will be returned
// when the caller calls GetProperty().
::JS_DefineUCProperty(aContext,
(JSObject *)mInner.mDOMSlots->mScriptObject,
chars, ::JS_GetStringLength(str),
JSVAL_VOID, nsnull, nsnull, 0);
return PR_TRUE;
}
}
return mInner.Resolve(aContext, aObj, aID);
}

Просмотреть файл

@ -725,6 +725,27 @@ nsHTMLImageElement::EnumerateProperty(JSContext *aContext, JSObject *aObj)
PRBool
nsHTMLImageElement::Resolve(JSContext *aContext, JSObject *aObj, jsval aID)
{
if (JSVAL_IS_STRING(aID) && mInner.mDOMSlots) {
JSString *str;
str = JSVAL_TO_STRING(aID);
const jschar *chars = ::JS_GetStringChars(str);
const PRUnichar *unichars = NS_REINTERPRET_CAST(const PRUnichar*, chars);
if (!nsCRT::strcmp(unichars, NS_LITERAL_STRING("src").get())) {
// Someone is trying to resolve "src" so we deifine it on the
// object with a JSVAL_VOID value, the real value will be returned
// when the caller calls GetProperty().
::JS_DefineUCProperty(aContext,
(JSObject *)mInner.mDOMSlots->mScriptObject,
chars, ::JS_GetStringLength(str),
JSVAL_VOID, nsnull, nsnull, 0);
return PR_TRUE;
}
}
return mInner.Resolve(aContext, aObj, aID);
}