diff --git a/content/xul/content/src/nsXULElement.cpp b/content/xul/content/src/nsXULElement.cpp index d87bc1ba9881..6f3357805596 100644 --- a/content/xul/content/src/nsXULElement.cpp +++ b/content/xul/content/src/nsXULElement.cpp @@ -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; + } } } } diff --git a/content/xul/content/src/nsXULElement.h b/content/xul/content/src/nsXULElement.h index 5474034abed6..fd628c4afd91 100644 --- a/content/xul/content/src/nsXULElement.h +++ b/content/xul/content/src/nsXULElement.h @@ -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); diff --git a/content/xul/document/src/nsXULDocument.cpp b/content/xul/document/src/nsXULDocument.cpp index 0962c85be787..b9892f8ced4a 100644 --- a/content/xul/document/src/nsXULDocument.cpp +++ b/content/xul/document/src/nsXULDocument.cpp @@ -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 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); diff --git a/rdf/content/src/nsXULDocument.cpp b/rdf/content/src/nsXULDocument.cpp index 0962c85be787..b9892f8ced4a 100644 --- a/rdf/content/src/nsXULDocument.cpp +++ b/rdf/content/src/nsXULDocument.cpp @@ -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 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); diff --git a/rdf/content/src/nsXULElement.cpp b/rdf/content/src/nsXULElement.cpp index d87bc1ba9881..6f3357805596 100644 --- a/rdf/content/src/nsXULElement.cpp +++ b/rdf/content/src/nsXULElement.cpp @@ -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; + } } } } diff --git a/rdf/content/src/nsXULElement.h b/rdf/content/src/nsXULElement.h index 5474034abed6..fd628c4afd91 100644 --- a/rdf/content/src/nsXULElement.h +++ b/rdf/content/src/nsXULElement.h @@ -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);