diff --git a/content/xul/document/src/nsXULDocument.cpp b/content/xul/document/src/nsXULDocument.cpp index 84fa6f1e1cc..bd32995962d 100644 --- a/content/xul/document/src/nsXULDocument.cpp +++ b/content/xul/document/src/nsXULDocument.cpp @@ -176,6 +176,7 @@ PRInt32 nsXULDocument::gRefCnt = 0; nsIAtom* nsXULDocument::kAttributeAtom; nsIAtom* nsXULDocument::kCommandUpdaterAtom; +nsIAtom* nsXULDocument::kContextAtom; nsIAtom* nsXULDocument::kDataSourcesAtom; nsIAtom* nsXULDocument::kElementAtom; nsIAtom* nsXULDocument::kIdAtom; @@ -185,9 +186,12 @@ nsIAtom* nsXULDocument::kOpenAtom; nsIAtom* nsXULDocument::kOverlayAtom; nsIAtom* nsXULDocument::kPersistAtom; nsIAtom* nsXULDocument::kPositionAtom; +nsIAtom* nsXULDocument::kPopupAtom; nsIAtom* nsXULDocument::kRefAtom; nsIAtom* nsXULDocument::kRuleAtom; +nsIAtom* nsXULDocument::kStyleAtom; nsIAtom* nsXULDocument::kTemplateAtom; +nsIAtom* nsXULDocument::kTooltipAtom; nsIAtom* nsXULDocument::kCoalesceAtom; nsIAtom* nsXULDocument::kAllowNegativesAtom; @@ -474,6 +478,7 @@ nsXULDocument::~nsXULDocument() if (--gRefCnt == 0) { NS_IF_RELEASE(kAttributeAtom); NS_IF_RELEASE(kCommandUpdaterAtom); + NS_IF_RELEASE(kContextAtom); NS_IF_RELEASE(kDataSourcesAtom); NS_IF_RELEASE(kElementAtom); NS_IF_RELEASE(kIdAtom); @@ -483,9 +488,12 @@ nsXULDocument::~nsXULDocument() NS_IF_RELEASE(kOverlayAtom); NS_IF_RELEASE(kPersistAtom); NS_IF_RELEASE(kPositionAtom); + NS_IF_RELEASE(kPopupAtom); NS_IF_RELEASE(kRefAtom); NS_IF_RELEASE(kRuleAtom); + NS_IF_RELEASE(kStyleAtom); NS_IF_RELEASE(kTemplateAtom); + NS_IF_RELEASE(kTooltipAtom); NS_IF_RELEASE(kCoalesceAtom); NS_IF_RELEASE(kAllowNegativesAtom); @@ -2782,7 +2790,46 @@ nsXULDocument::AddSubtreeToDocument(nsIContent* aElement) if (NS_FAILED(rv)) return rv; } - // 4. Recurse to children. + // 4. See if we've got any 'special' attributes that are + // document-specific, and need extra work to be done. + { + PRInt32 count; + aElement->GetAttributeCount(count); + + for (PRInt32 i = 0; i < count; ++i) { + PRInt32 nameSpaceID; + nsCOMPtr attr; + aElement->GetAttributeNameAt(i, nameSpaceID, *getter_AddRefs(attr)); + + PRBool reset = PR_FALSE; + + if (nameSpaceID == kNameSpaceID_None) { + nsIID iid; + rv = gXULUtils->GetEventHandlerIID(attr, &iid, &reset); + if (NS_FAILED(rv)) return rv; + + if (! reset) { + if ((attr.get() == kPopupAtom) || + (attr.get() == kTooltipAtom) || + (attr.get() == kContextAtom) || + (attr.get() == kStyleAtom)) { + reset = PR_TRUE; + } + } + } + + if (reset) { + nsAutoString value; + rv = aElement->GetAttribute(nameSpaceID, attr, value); + if (NS_FAILED(rv)) return rv; + + rv = aElement->SetAttribute(nameSpaceID, attr, value, PR_FALSE); + if (NS_FAILED(rv)) return rv; + } + } + } + + // 5. Recurse to children. PRInt32 count; nsCOMPtr xulcontent = do_QueryInterface(aElement); rv = xulcontent ? xulcontent->PeekChildCount(count) : aElement->ChildCount(count); @@ -3427,6 +3474,7 @@ nsXULDocument::Init() if (gRefCnt++ == 0) { kAttributeAtom = NS_NewAtom("attribute"); kCommandUpdaterAtom = NS_NewAtom("commandupdater"); + kContextAtom = NS_NewAtom("context"); kDataSourcesAtom = NS_NewAtom("datasources"); kElementAtom = NS_NewAtom("element"); kIdAtom = NS_NewAtom("id"); @@ -3435,10 +3483,13 @@ nsXULDocument::Init() kOpenAtom = NS_NewAtom("open"); kOverlayAtom = NS_NewAtom("overlay"); kPersistAtom = NS_NewAtom("persist"); + kPopupAtom = NS_NewAtom("popup"); kPositionAtom = NS_NewAtom("position"); kRefAtom = NS_NewAtom("ref"); kRuleAtom = NS_NewAtom("rule"); + kStyleAtom = NS_NewAtom("style"); kTemplateAtom = NS_NewAtom("template"); + kTooltipAtom = NS_NewAtom("tooltip"); kCoalesceAtom = NS_NewAtom("coalesceduplicatearcs"); kAllowNegativesAtom = NS_NewAtom("allownegativeassertions"); diff --git a/content/xul/document/src/nsXULDocument.h b/content/xul/document/src/nsXULDocument.h index 2d6fe3d53f2..473deb7ae69 100644 --- a/content/xul/document/src/nsXULDocument.h +++ b/content/xul/document/src/nsXULDocument.h @@ -462,6 +462,7 @@ protected: static nsIAtom* kAttributeAtom; static nsIAtom* kCommandUpdaterAtom; + static nsIAtom* kContextAtom; static nsIAtom* kDataSourcesAtom; static nsIAtom* kElementAtom; static nsIAtom* kIdAtom; @@ -470,10 +471,13 @@ protected: static nsIAtom* kOpenAtom; static nsIAtom* kOverlayAtom; static nsIAtom* kPersistAtom; + static nsIAtom* kPopupAtom; static nsIAtom* kPositionAtom; static nsIAtom* kRefAtom; static nsIAtom* kRuleAtom; + static nsIAtom* kStyleAtom; static nsIAtom* kTemplateAtom; + static nsIAtom* kTooltipAtom; static nsIAtom* kCoalesceAtom; static nsIAtom* kAllowNegativesAtom; diff --git a/rdf/content/src/nsXULDocument.cpp b/rdf/content/src/nsXULDocument.cpp index 84fa6f1e1cc..bd32995962d 100644 --- a/rdf/content/src/nsXULDocument.cpp +++ b/rdf/content/src/nsXULDocument.cpp @@ -176,6 +176,7 @@ PRInt32 nsXULDocument::gRefCnt = 0; nsIAtom* nsXULDocument::kAttributeAtom; nsIAtom* nsXULDocument::kCommandUpdaterAtom; +nsIAtom* nsXULDocument::kContextAtom; nsIAtom* nsXULDocument::kDataSourcesAtom; nsIAtom* nsXULDocument::kElementAtom; nsIAtom* nsXULDocument::kIdAtom; @@ -185,9 +186,12 @@ nsIAtom* nsXULDocument::kOpenAtom; nsIAtom* nsXULDocument::kOverlayAtom; nsIAtom* nsXULDocument::kPersistAtom; nsIAtom* nsXULDocument::kPositionAtom; +nsIAtom* nsXULDocument::kPopupAtom; nsIAtom* nsXULDocument::kRefAtom; nsIAtom* nsXULDocument::kRuleAtom; +nsIAtom* nsXULDocument::kStyleAtom; nsIAtom* nsXULDocument::kTemplateAtom; +nsIAtom* nsXULDocument::kTooltipAtom; nsIAtom* nsXULDocument::kCoalesceAtom; nsIAtom* nsXULDocument::kAllowNegativesAtom; @@ -474,6 +478,7 @@ nsXULDocument::~nsXULDocument() if (--gRefCnt == 0) { NS_IF_RELEASE(kAttributeAtom); NS_IF_RELEASE(kCommandUpdaterAtom); + NS_IF_RELEASE(kContextAtom); NS_IF_RELEASE(kDataSourcesAtom); NS_IF_RELEASE(kElementAtom); NS_IF_RELEASE(kIdAtom); @@ -483,9 +488,12 @@ nsXULDocument::~nsXULDocument() NS_IF_RELEASE(kOverlayAtom); NS_IF_RELEASE(kPersistAtom); NS_IF_RELEASE(kPositionAtom); + NS_IF_RELEASE(kPopupAtom); NS_IF_RELEASE(kRefAtom); NS_IF_RELEASE(kRuleAtom); + NS_IF_RELEASE(kStyleAtom); NS_IF_RELEASE(kTemplateAtom); + NS_IF_RELEASE(kTooltipAtom); NS_IF_RELEASE(kCoalesceAtom); NS_IF_RELEASE(kAllowNegativesAtom); @@ -2782,7 +2790,46 @@ nsXULDocument::AddSubtreeToDocument(nsIContent* aElement) if (NS_FAILED(rv)) return rv; } - // 4. Recurse to children. + // 4. See if we've got any 'special' attributes that are + // document-specific, and need extra work to be done. + { + PRInt32 count; + aElement->GetAttributeCount(count); + + for (PRInt32 i = 0; i < count; ++i) { + PRInt32 nameSpaceID; + nsCOMPtr attr; + aElement->GetAttributeNameAt(i, nameSpaceID, *getter_AddRefs(attr)); + + PRBool reset = PR_FALSE; + + if (nameSpaceID == kNameSpaceID_None) { + nsIID iid; + rv = gXULUtils->GetEventHandlerIID(attr, &iid, &reset); + if (NS_FAILED(rv)) return rv; + + if (! reset) { + if ((attr.get() == kPopupAtom) || + (attr.get() == kTooltipAtom) || + (attr.get() == kContextAtom) || + (attr.get() == kStyleAtom)) { + reset = PR_TRUE; + } + } + } + + if (reset) { + nsAutoString value; + rv = aElement->GetAttribute(nameSpaceID, attr, value); + if (NS_FAILED(rv)) return rv; + + rv = aElement->SetAttribute(nameSpaceID, attr, value, PR_FALSE); + if (NS_FAILED(rv)) return rv; + } + } + } + + // 5. Recurse to children. PRInt32 count; nsCOMPtr xulcontent = do_QueryInterface(aElement); rv = xulcontent ? xulcontent->PeekChildCount(count) : aElement->ChildCount(count); @@ -3427,6 +3474,7 @@ nsXULDocument::Init() if (gRefCnt++ == 0) { kAttributeAtom = NS_NewAtom("attribute"); kCommandUpdaterAtom = NS_NewAtom("commandupdater"); + kContextAtom = NS_NewAtom("context"); kDataSourcesAtom = NS_NewAtom("datasources"); kElementAtom = NS_NewAtom("element"); kIdAtom = NS_NewAtom("id"); @@ -3435,10 +3483,13 @@ nsXULDocument::Init() kOpenAtom = NS_NewAtom("open"); kOverlayAtom = NS_NewAtom("overlay"); kPersistAtom = NS_NewAtom("persist"); + kPopupAtom = NS_NewAtom("popup"); kPositionAtom = NS_NewAtom("position"); kRefAtom = NS_NewAtom("ref"); kRuleAtom = NS_NewAtom("rule"); + kStyleAtom = NS_NewAtom("style"); kTemplateAtom = NS_NewAtom("template"); + kTooltipAtom = NS_NewAtom("tooltip"); kCoalesceAtom = NS_NewAtom("coalesceduplicatearcs"); kAllowNegativesAtom = NS_NewAtom("allownegativeassertions"); diff --git a/rdf/content/src/nsXULDocument.h b/rdf/content/src/nsXULDocument.h index 2d6fe3d53f2..473deb7ae69 100644 --- a/rdf/content/src/nsXULDocument.h +++ b/rdf/content/src/nsXULDocument.h @@ -462,6 +462,7 @@ protected: static nsIAtom* kAttributeAtom; static nsIAtom* kCommandUpdaterAtom; + static nsIAtom* kContextAtom; static nsIAtom* kDataSourcesAtom; static nsIAtom* kElementAtom; static nsIAtom* kIdAtom; @@ -470,10 +471,13 @@ protected: static nsIAtom* kOpenAtom; static nsIAtom* kOverlayAtom; static nsIAtom* kPersistAtom; + static nsIAtom* kPopupAtom; static nsIAtom* kPositionAtom; static nsIAtom* kRefAtom; static nsIAtom* kRuleAtom; + static nsIAtom* kStyleAtom; static nsIAtom* kTemplateAtom; + static nsIAtom* kTooltipAtom; static nsIAtom* kCoalesceAtom; static nsIAtom* kAllowNegativesAtom;