Bug 17955. Don't unnecessarily add script event listeners to temporary nodes used for overlay hookup. r=hyatt, a=chofmann

This commit is contained in:
waterson%netscape.com 1999-11-04 19:43:43 +00:00
Родитель 0b5d621294
Коммит 1d630564b4
6 изменённых файлов: 54 добавлений и 48 удалений

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

@ -371,6 +371,7 @@ nsXULElement::~nsXULElement()
nsresult
nsXULElement::Create(nsXULPrototypeElement* aPrototype,
nsIDocument* aDocument,
PRBool aIsScriptable,
nsIContent** aResult)
{
// Create an nsXULElement from a prototype
@ -401,30 +402,32 @@ nsXULElement::Create(nsXULPrototypeElement* aPrototype,
element->mPrototype = aPrototype;
element->mDocument = aDocument;
// Check each attribute on the prototype to see if we need to do
// any additional processing and hookup that would otherwise be
// done 'automagically' by SetAttribute().
for (PRInt32 i = 0; i < aPrototype->mNumAttributes; ++i) {
nsXULPrototypeAttribute* attr = &(aPrototype->mAttributes[i]);
if (aIsScriptable) {
// Check each attribute on the prototype to see if we need to do
// any additional processing and hookup that would otherwise be
// done 'automagically' by SetAttribute().
for (PRInt32 i = 0; i < aPrototype->mNumAttributes; ++i) {
nsXULPrototypeAttribute* attr = &(aPrototype->mAttributes[i]);
if (attr->mNameSpaceID == kNameSpaceID_None) {
// Check for an event handler
nsIID iid;
PRBool found;
rv = gXULUtils->GetEventHandlerIID(attr->mName, &iid, &found);
if (NS_FAILED(rv)) return rv;
if (found) {
rv = element->AddScriptEventListener(attr->mName, attr->mValue, iid);
if (attr->mNameSpaceID == kNameSpaceID_None) {
// Check for an event handler
nsIID iid;
PRBool found;
rv = gXULUtils->GetEventHandlerIID(attr->mName, &iid, &found);
if (NS_FAILED(rv)) return rv;
}
// Check for popup attributes
if ((attr->mName.get() == kPopupAtom) ||
(attr->mName.get() == kTooltipAtom) ||
(attr->mName.get() == kContextAtom)) {
rv = element->AddPopupListener(attr->mName);
if (NS_FAILED(rv)) return rv;
if (found) {
rv = element->AddScriptEventListener(attr->mName, attr->mValue, iid);
if (NS_FAILED(rv)) return rv;
}
// Check for popup attributes
if ((attr->mName.get() == kPopupAtom) ||
(attr->mName.get() == kTooltipAtom) ||
(attr->mName.get() == kContextAtom)) {
rv = element->AddPopupListener(attr->mName);
if (NS_FAILED(rv)) return rv;
}
}
}
}

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

@ -276,7 +276,7 @@ protected:
public:
static nsresult
Create(nsXULPrototypeElement* aPrototype, nsIDocument* aDocument, nsIContent** aResult);
Create(nsXULPrototypeElement* aPrototype, nsIDocument* aDocument, PRBool aIsScriptable, nsIContent** aResult);
static nsresult
Create(PRInt32 aNameSpaceID, nsIAtom* aTag, nsIContent** aResult);

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

@ -4721,7 +4721,7 @@ nsXULDocument::CreateElement(nsXULPrototypeElement* aPrototype, nsIContent** aRe
else {
// If it's a XUL element, it'll be lightweight until somebody
// monkeys with it.
rv = nsXULElement::Create(aPrototype, this, getter_AddRefs(result));
rv = nsXULElement::Create(aPrototype, this, PR_TRUE, getter_AddRefs(result));
if (NS_FAILED(rv)) return rv;
// We also need to pay special attention to the keyset tag to set up a listener
@ -4763,7 +4763,7 @@ nsXULDocument::CreateOverlayElement(nsXULPrototypeElement* aPrototype, nsIConten
// element. I'd use an XML element, but it gets its knickers in a
// knot with DOM ranges when you try to remove its children.
nsCOMPtr<nsIContent> element;
rv = nsXULElement::Create(aPrototype, this, getter_AddRefs(element));
rv = nsXULElement::Create(aPrototype, this, PR_FALSE, getter_AddRefs(element));
if (NS_FAILED(rv)) return rv;
OverlayForwardReference* fwdref = new OverlayForwardReference(element);

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

@ -4721,7 +4721,7 @@ nsXULDocument::CreateElement(nsXULPrototypeElement* aPrototype, nsIContent** aRe
else {
// If it's a XUL element, it'll be lightweight until somebody
// monkeys with it.
rv = nsXULElement::Create(aPrototype, this, getter_AddRefs(result));
rv = nsXULElement::Create(aPrototype, this, PR_TRUE, getter_AddRefs(result));
if (NS_FAILED(rv)) return rv;
// We also need to pay special attention to the keyset tag to set up a listener
@ -4763,7 +4763,7 @@ nsXULDocument::CreateOverlayElement(nsXULPrototypeElement* aPrototype, nsIConten
// element. I'd use an XML element, but it gets its knickers in a
// knot with DOM ranges when you try to remove its children.
nsCOMPtr<nsIContent> element;
rv = nsXULElement::Create(aPrototype, this, getter_AddRefs(element));
rv = nsXULElement::Create(aPrototype, this, PR_FALSE, getter_AddRefs(element));
if (NS_FAILED(rv)) return rv;
OverlayForwardReference* fwdref = new OverlayForwardReference(element);

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

@ -371,6 +371,7 @@ nsXULElement::~nsXULElement()
nsresult
nsXULElement::Create(nsXULPrototypeElement* aPrototype,
nsIDocument* aDocument,
PRBool aIsScriptable,
nsIContent** aResult)
{
// Create an nsXULElement from a prototype
@ -401,30 +402,32 @@ nsXULElement::Create(nsXULPrototypeElement* aPrototype,
element->mPrototype = aPrototype;
element->mDocument = aDocument;
// Check each attribute on the prototype to see if we need to do
// any additional processing and hookup that would otherwise be
// done 'automagically' by SetAttribute().
for (PRInt32 i = 0; i < aPrototype->mNumAttributes; ++i) {
nsXULPrototypeAttribute* attr = &(aPrototype->mAttributes[i]);
if (aIsScriptable) {
// Check each attribute on the prototype to see if we need to do
// any additional processing and hookup that would otherwise be
// done 'automagically' by SetAttribute().
for (PRInt32 i = 0; i < aPrototype->mNumAttributes; ++i) {
nsXULPrototypeAttribute* attr = &(aPrototype->mAttributes[i]);
if (attr->mNameSpaceID == kNameSpaceID_None) {
// Check for an event handler
nsIID iid;
PRBool found;
rv = gXULUtils->GetEventHandlerIID(attr->mName, &iid, &found);
if (NS_FAILED(rv)) return rv;
if (found) {
rv = element->AddScriptEventListener(attr->mName, attr->mValue, iid);
if (attr->mNameSpaceID == kNameSpaceID_None) {
// Check for an event handler
nsIID iid;
PRBool found;
rv = gXULUtils->GetEventHandlerIID(attr->mName, &iid, &found);
if (NS_FAILED(rv)) return rv;
}
// Check for popup attributes
if ((attr->mName.get() == kPopupAtom) ||
(attr->mName.get() == kTooltipAtom) ||
(attr->mName.get() == kContextAtom)) {
rv = element->AddPopupListener(attr->mName);
if (NS_FAILED(rv)) return rv;
if (found) {
rv = element->AddScriptEventListener(attr->mName, attr->mValue, iid);
if (NS_FAILED(rv)) return rv;
}
// Check for popup attributes
if ((attr->mName.get() == kPopupAtom) ||
(attr->mName.get() == kTooltipAtom) ||
(attr->mName.get() == kContextAtom)) {
rv = element->AddPopupListener(attr->mName);
if (NS_FAILED(rv)) return rv;
}
}
}
}

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

@ -276,7 +276,7 @@ protected:
public:
static nsresult
Create(nsXULPrototypeElement* aPrototype, nsIDocument* aDocument, nsIContent** aResult);
Create(nsXULPrototypeElement* aPrototype, nsIDocument* aDocument, PRBool aIsScriptable, nsIContent** aResult);
static nsresult
Create(PRInt32 aNameSpaceID, nsIAtom* aTag, nsIContent** aResult);