From e469c92e382475eabec655ed3da150f8f73fe1cc Mon Sep 17 00:00:00 2001 From: "hyatt%netscape.com" Date: Fri, 19 May 2000 04:48:43 +0000 Subject: [PATCH] fix for making skins script-safe. r=scc git-svn-id: svn://10.0.0.236/trunk@70503 18797224-902f-48f8-a5cc-f745e15eee43 --- mozilla/chrome/public/nsIChromeRegistry.idl | 4 +- mozilla/chrome/src/nsChromeRegistry.cpp | 86 ++++++++++++++++--- mozilla/chrome/src/nsChromeRegistry.h | 3 +- mozilla/content/base/public/nsIContent.h | 2 +- mozilla/content/base/src/nsCommentNode.cpp | 4 +- mozilla/content/base/src/nsDocument.cpp | 12 +-- .../content/base/src/nsDocumentFragment.cpp | 4 +- .../content/base/src/nsGenericDOMDataNode.cpp | 2 +- .../content/base/src/nsGenericDOMDataNode.h | 6 +- mozilla/content/base/src/nsGenericElement.cpp | 27 +++--- mozilla/content/base/src/nsGenericElement.h | 22 ++--- .../html/content/src/nsAttributeContent.cpp | 4 +- .../html/content/src/nsGenericHTMLElement.cpp | 17 ++-- .../html/content/src/nsGenericHTMLElement.h | 3 +- .../html/content/src/nsHTMLAnchorElement.cpp | 4 +- .../html/content/src/nsHTMLBodyElement.cpp | 6 +- .../html/content/src/nsHTMLButtonElement.cpp | 4 +- .../content/src/nsHTMLFieldSetElement.cpp | 4 +- .../html/content/src/nsHTMLImageElement.cpp | 4 +- .../html/content/src/nsHTMLInputElement.cpp | 4 +- .../html/content/src/nsHTMLLabelElement.cpp | 4 +- .../html/content/src/nsHTMLLegendElement.cpp | 4 +- .../html/content/src/nsHTMLMapElement.cpp | 6 +- .../html/content/src/nsHTMLOptionElement.cpp | 2 +- .../html/content/src/nsHTMLSelectElement.cpp | 4 +- .../content/src/nsHTMLTextAreaElement.cpp | 4 +- .../html/content/src/nsHTMLUnknownElement.cpp | 4 +- .../html/document/src/nsHTMLContentSink.cpp | 30 +++---- .../html/document/src/nsImageDocument.cpp | 8 +- mozilla/content/xbl/public/nsIXBLService.h | 1 + mozilla/content/xbl/src/nsXBLBinding.cpp | 27 +++++- mozilla/content/xbl/src/nsXBLService.cpp | 51 +++++++++-- .../content/xml/content/src/nsXMLElement.h | 4 +- .../xml/document/src/nsXMLContentSink.cpp | 10 +-- .../content/xul/content/src/nsXULElement.cpp | 30 ++++--- .../content/xul/content/src/nsXULElement.h | 4 +- .../xul/document/src/nsXULDocument.cpp | 14 +-- .../xul/templates/src/nsXULSortService.cpp | 4 +- .../templates/src/nsXULTemplateBuilder.cpp | 6 +- mozilla/docshell/base/nsDocShell.cpp | 2 +- mozilla/docshell/base/nsWebShell.cpp | 4 +- mozilla/intl/strres/src/nsStringBundle.cpp | 2 + mozilla/layout/base/nsCSSFrameConstructor.cpp | 10 +-- mozilla/layout/base/public/nsIContent.h | 2 +- mozilla/layout/base/src/nsCommentNode.cpp | 4 +- mozilla/layout/base/src/nsDocument.cpp | 12 +-- .../layout/base/src/nsDocumentFragment.cpp | 4 +- .../layout/base/src/nsGenericDOMDataNode.cpp | 2 +- .../layout/base/src/nsGenericDOMDataNode.h | 6 +- mozilla/layout/base/src/nsGenericElement.cpp | 27 +++--- mozilla/layout/base/src/nsGenericElement.h | 22 ++--- .../layout/forms/nsComboboxControlFrame.cpp | 2 +- .../html/content/src/nsAttributeContent.cpp | 4 +- .../html/content/src/nsGenericHTMLElement.cpp | 17 ++-- .../html/content/src/nsGenericHTMLElement.h | 3 +- .../html/content/src/nsHTMLAnchorElement.cpp | 4 +- .../html/content/src/nsHTMLBodyElement.cpp | 6 +- .../html/content/src/nsHTMLButtonElement.cpp | 4 +- .../content/src/nsHTMLFieldSetElement.cpp | 4 +- .../html/content/src/nsHTMLImageElement.cpp | 4 +- .../html/content/src/nsHTMLInputElement.cpp | 4 +- .../html/content/src/nsHTMLLabelElement.cpp | 4 +- .../html/content/src/nsHTMLLegendElement.cpp | 4 +- .../html/content/src/nsHTMLMapElement.cpp | 6 +- .../html/content/src/nsHTMLOptionElement.cpp | 2 +- .../html/content/src/nsHTMLSelectElement.cpp | 4 +- .../content/src/nsHTMLTextAreaElement.cpp | 4 +- .../html/content/src/nsHTMLUnknownElement.cpp | 4 +- .../html/document/src/nsHTMLContentSink.cpp | 30 +++---- .../html/document/src/nsImageDocument.cpp | 8 +- .../html/forms/src/nsComboboxControlFrame.cpp | 2 +- .../html/forms/src/nsGfxTextControlFrame.cpp | 6 +- .../html/style/src/nsCSSFrameConstructor.cpp | 10 +-- mozilla/layout/html/tests/TestAttributes.cpp | 4 +- mozilla/layout/xbl/public/nsIXBLService.h | 1 + mozilla/layout/xbl/src/nsXBLBinding.cpp | 27 +++++- mozilla/layout/xbl/src/nsXBLService.cpp | 51 +++++++++-- mozilla/layout/xml/content/src/nsXMLElement.h | 4 +- .../xml/document/src/nsXMLContentSink.cpp | 10 +-- .../xul/base/src/nsTreeRowGroupFrame.cpp | 2 +- .../rdf/chrome/public/nsIChromeRegistry.idl | 4 +- mozilla/rdf/chrome/src/nsChromeRegistry.cpp | 86 ++++++++++++++++--- mozilla/rdf/chrome/src/nsChromeRegistry.h | 3 +- mozilla/rdf/content/src/nsXULDocument.cpp | 14 +-- mozilla/rdf/content/src/nsXULElement.cpp | 30 ++++--- mozilla/rdf/content/src/nsXULElement.h | 4 +- mozilla/rdf/content/src/nsXULSortService.cpp | 4 +- .../rdf/content/src/nsXULTemplateBuilder.cpp | 6 +- mozilla/webshell/src/nsWebShell.cpp | 4 +- mozilla/xpinstall/src/nsRegisterItem.cpp | 2 +- mozilla/xpinstall/src/nsSoftwareUpdateRun.cpp | 2 +- 91 files changed, 597 insertions(+), 333 deletions(-) diff --git a/mozilla/chrome/public/nsIChromeRegistry.idl b/mozilla/chrome/public/nsIChromeRegistry.idl index 42592797e7a..b21cb16cdc2 100644 --- a/mozilla/chrome/public/nsIChromeRegistry.idl +++ b/mozilla/chrome/public/nsIChromeRegistry.idl @@ -79,7 +79,7 @@ interface nsIChromeRegistry : nsISupports void deselectLocaleForPackage(in wstring localeName, in wstring packageName, in boolean useProfile); /* Installation APIs */ - void installSkin(in string baseURL, in boolean useProfile); + void installSkin(in string baseURL, in boolean useProfile, in boolean allowScripts); void uninstallSkin(in wstring skinName, in boolean useProfile); void installLocale(in string baseURL, in boolean useProfile); @@ -90,6 +90,8 @@ interface nsIChromeRegistry : nsISupports void getBackstopSheets(out nsISupportsArray styleSheets); + boolean allowScriptsForSkin(in nsIURI url); + void checkForNewChrome(); }; diff --git a/mozilla/chrome/src/nsChromeRegistry.cpp b/mozilla/chrome/src/nsChromeRegistry.cpp index c25fcc655f6..9d3ac02870f 100644 --- a/mozilla/chrome/src/nsChromeRegistry.cpp +++ b/mozilla/chrome/src/nsChromeRegistry.cpp @@ -94,6 +94,7 @@ DEFINE_RDF_VOCAB(CHROME_URI, CHROME, packages); DEFINE_RDF_VOCAB(CHROME_URI, CHROME, package); DEFINE_RDF_VOCAB(CHROME_URI, CHROME, name); DEFINE_RDF_VOCAB(CHROME_URI, CHROME, locType); +DEFINE_RDF_VOCAB(CHROME_URI, CHROME, allowScripts); //////////////////////////////////////////////////////////////////////////////// @@ -242,6 +243,9 @@ nsChromeRegistry::nsChromeRegistry() rv = mRDFService->GetResource(kURICHROME_locType, getter_AddRefs(mLocType)); NS_ASSERTION(NS_SUCCEEDED(rv), "unable to get RDF resource"); + + rv = mRDFService->GetResource(kURICHROME_allowScripts, getter_AddRefs(mAllowScripts)); + NS_ASSERTION(NS_SUCCEEDED(rv), "unable to get RDF resource"); } } @@ -1439,7 +1443,8 @@ NS_IMETHODIMP nsChromeRegistry::SelectProviderForPackage(const nsCString& aProvi NS_IMETHODIMP nsChromeRegistry::InstallProvider(const nsCString& aProviderType, const nsCString& aBaseURL, - PRBool aUseProfile, PRBool aRemove) + PRBool aUseProfile, PRBool aAllowScripts, + PRBool aRemove) { // XXX don't allow local chrome overrides of install chrome! @@ -1494,6 +1499,12 @@ NS_IMETHODIMP nsChromeRegistry::InstallProvider(const nsCString& aProviderType, nsCOMPtr baseLiteral; mRDFService->GetLiteral(unistr.GetUnicode(), getter_AddRefs(baseLiteral)); + // Get the literal for our script access. + nsAutoString scriptstr; + scriptstr.AssignWithConversion("false"); + nsCOMPtr scriptLiteral; + mRDFService->GetLiteral(scriptstr.GetUnicode(), getter_AddRefs(scriptLiteral)); + // Build the prefix string. Only resources with this prefix string will have their // assertions copied. nsCAutoString prefix = "urn:mozilla:"; @@ -1619,8 +1630,10 @@ NS_IMETHODIMP nsChromeRegistry::InstallProvider(const nsCString& aProviderType, if (arc == mPackages) { // We are the main entry for a skin/locale. - // Set up our loctype + // Set up our loctype and our script access nsChromeRegistry::UpdateArc(installSource, resource, mLocType, locLiteral, aRemove); + if (aProviderType.Equals(nsCAutoString("skin")) && !aAllowScripts) + nsChromeRegistry::UpdateArc(installSource, resource, mAllowScripts, scriptLiteral, aRemove); } nsCOMPtr newTarget; @@ -1646,40 +1659,40 @@ NS_IMETHODIMP nsChromeRegistry::InstallProvider(const nsCString& aProviderType, return NS_OK; } -NS_IMETHODIMP nsChromeRegistry::InstallSkin(const char* aBaseURL, PRBool aUseProfile) +NS_IMETHODIMP nsChromeRegistry::InstallSkin(const char* aBaseURL, PRBool aUseProfile, PRBool aAllowScripts) { nsCAutoString provider("skin"); - return InstallProvider(provider, aBaseURL, aUseProfile, PR_FALSE); + return InstallProvider(provider, aBaseURL, aUseProfile, aAllowScripts, PR_FALSE); } NS_IMETHODIMP nsChromeRegistry::InstallLocale(const char* aBaseURL, PRBool aUseProfile) { nsCAutoString provider("locale"); - return InstallProvider(provider, aBaseURL, aUseProfile, PR_FALSE); + return InstallProvider(provider, aBaseURL, aUseProfile, PR_TRUE, PR_FALSE); } NS_IMETHODIMP nsChromeRegistry::InstallPackage(const char* aBaseURL, PRBool aUseProfile) { nsCAutoString provider("package"); - return InstallProvider(provider, aBaseURL, aUseProfile, PR_FALSE); + return InstallProvider(provider, aBaseURL, aUseProfile, PR_TRUE, PR_FALSE); } NS_IMETHODIMP nsChromeRegistry::UninstallSkin(const PRUnichar* aSkinName, PRBool aUseProfile) { nsCAutoString provider("skin"); - return InstallProvider(provider, "", aUseProfile, PR_TRUE); + return InstallProvider(provider, "", aUseProfile, PR_TRUE, PR_TRUE); } NS_IMETHODIMP nsChromeRegistry::UninstallLocale(const PRUnichar* aLocaleName, PRBool aUseProfile) { nsCAutoString provider("locale"); - return InstallProvider(provider, "", aUseProfile, PR_TRUE); + return InstallProvider(provider, "", aUseProfile, PR_TRUE, PR_TRUE); } NS_IMETHODIMP nsChromeRegistry::UninstallPackage(const PRUnichar* aPackageName, PRBool aUseProfile) { nsCAutoString provider("package"); - return InstallProvider(provider, "", aUseProfile, PR_TRUE); + return InstallProvider(provider, "", aUseProfile, PR_TRUE, PR_TRUE); } NS_IMETHODIMP @@ -1945,6 +1958,59 @@ void nsChromeRegistry::GetUserSheetURL(nsCString & aURL) aURL.Append("user.css"); } +NS_IMETHODIMP nsChromeRegistry::AllowScriptsForSkin(nsIURI* aChromeURI, PRBool *aResult) +{ + *aResult = PR_TRUE; + + // split the url + nsCAutoString package, provider, file; + nsresult rv; + rv = SplitURL(aChromeURI, package, provider, file); + if (NS_FAILED(rv)) return NS_OK; + + // verify it's a skin url + if (!provider.Equals("skin")) + return NS_OK; + + // XXX could factor this with selectproviderforpackage + // get the selected skin resource for the package + nsCOMPtr selectedProvider; + + nsCAutoString resourceStr("urn:mozilla:package:"); + resourceStr += package; + + // Obtain the resource. + nsCOMPtr resource; + rv = GetResource(resourceStr, getter_AddRefs(resource)); + if (NS_FAILED(rv)) { + NS_ERROR("Unable to obtain the package resource."); + return rv; + } + + if (NS_FAILED(rv = mChromeDataSource->GetTarget(resource, mSelectedSkin, PR_TRUE, getter_AddRefs(selectedProvider)))) + return NS_OK; + + if (!selectedProvider) + FindProvider(package, provider, mSelectedSkin, getter_AddRefs(selectedProvider)); + if (!selectedProvider) + return NS_OK; + + resource = do_QueryInterface(selectedProvider); + if (!resource) + return NS_OK; + + // get its script access + nsCAutoString scriptAccess; + nsChromeRegistry::FollowArc(mChromeDataSource, + scriptAccess, + resource, + mAllowScripts); + if (!scriptAccess.IsEmpty()) + *aResult = PR_FALSE; + + return NS_OK; +} + NS_IMETHODIMP nsChromeRegistry::CheckForNewChrome() { @@ -2057,7 +2123,7 @@ nsChromeRegistry::ProcessNewChromeBuffer(char *aBuffer, PRInt32 aLength) { // process the line if (skin.Equals(chromeType)) - InstallSkin(chromeURL, isProfile); + InstallSkin(chromeURL, isProfile, PR_FALSE); else if (content.Equals(chromeType)) InstallPackage(chromeURL, isProfile); else if (locale.Equals(chromeType)) diff --git a/mozilla/chrome/src/nsChromeRegistry.h b/mozilla/chrome/src/nsChromeRegistry.h index 8a779a1a568..e0adf6cfc65 100644 --- a/mozilla/chrome/src/nsChromeRegistry.h +++ b/mozilla/chrome/src/nsChromeRegistry.h @@ -125,7 +125,7 @@ private: NS_IMETHOD InstallProvider(const nsCString& aProviderType, const nsCString& aBaseURL, - PRBool aUseProfile, PRBool aRemove); + PRBool aUseProfile, PRBool aAllowScripts, PRBool aRemove); void ProcessNewChromeBuffer(char *aBuffer, PRInt32 aLength); @@ -150,6 +150,7 @@ protected: nsCOMPtr mPackage; nsCOMPtr mName; nsCOMPtr mLocType; + nsCOMPtr mAllowScripts; // Style Sheets nsCOMPtr mScrollbarSheet; diff --git a/mozilla/content/base/public/nsIContent.h b/mozilla/content/base/public/nsIContent.h index a9ed5dd8f7a..f59fdfcdd47 100644 --- a/mozilla/content/base/public/nsIContent.h +++ b/mozilla/content/base/public/nsIContent.h @@ -55,7 +55,7 @@ public: NS_IMETHOD GetDocument(nsIDocument*& aResult) const = 0; - NS_IMETHOD SetDocument(nsIDocument* aDocument, PRBool aDeep) = 0; + NS_IMETHOD SetDocument(nsIDocument* aDocument, PRBool aDeep, PRBool aCompileEventHandlers) = 0; NS_IMETHOD GetParent(nsIContent*& aResult) const = 0; diff --git a/mozilla/content/base/src/nsCommentNode.cpp b/mozilla/content/base/src/nsCommentNode.cpp index 865afbb3115..662ef929597 100644 --- a/mozilla/content/base/src/nsCommentNode.cpp +++ b/mozilla/content/base/src/nsCommentNode.cpp @@ -65,8 +65,8 @@ public: NS_IMETHOD GetDocument(nsIDocument*& aResult) const { return mInner.GetDocument(aResult); } - NS_IMETHOD SetDocument(nsIDocument* aDocument, PRBool aDeep) { - return mInner.SetDocument(aDocument, aDeep); + NS_IMETHOD SetDocument(nsIDocument* aDocument, PRBool aDeep, PRBool aCompileEventHandlers) { + return mInner.SetDocument(aDocument, aDeep, aCompileEventHandlers); } NS_IMETHOD GetParent(nsIContent*& aResult) const { return mInner.GetParent(aResult); diff --git a/mozilla/content/base/src/nsDocument.cpp b/mozilla/content/base/src/nsDocument.cpp index a4c4dbc9597..ee59bd93792 100644 --- a/mozilla/content/base/src/nsDocument.cpp +++ b/mozilla/content/base/src/nsDocument.cpp @@ -816,7 +816,7 @@ nsDocument::Reset(nsIChannel* aChannel, nsILoadGroup* aLoadGroup) if (nsnull != mRootContent) { // Ensure that document is nsnull to allow validity checks on content - mRootContent->SetDocument(nsnull, PR_TRUE); + mRootContent->SetDocument(nsnull, PR_TRUE, PR_TRUE); ContentRemoved(nsnull, mRootContent, 0); NS_IF_RELEASE(mRootContent); } @@ -1477,7 +1477,7 @@ nsDocument::SetScriptGlobalObject(nsIScriptGlobalObject *aScriptGlobalObject) // actually set the script context owner to null so that the // content elements can remove references to their script objects. if ((nsnull == aScriptGlobalObject) && (nsnull != mRootContent)) { - mRootContent->SetDocument(nsnull, PR_TRUE); + mRootContent->SetDocument(nsnull, PR_TRUE, PR_TRUE); } mScriptGlobalObject = aScriptGlobalObject; @@ -2444,7 +2444,7 @@ nsDocument::InsertBefore(nsIDOMNode* aNewChild, nsIDOMNode* aRefChild, nsIDOMNod } if (NS_OK == result) { - content->SetDocument(this, PR_TRUE); + content->SetDocument(this, PR_TRUE, PR_TRUE); *aReturn = aNewChild; NS_ADDREF(aNewChild); } @@ -2515,8 +2515,8 @@ nsDocument::ReplaceChild(nsIDOMNode* aNewChild, nsIDOMNode* aOldChild, nsIDOMNod } if (NS_OK == result) { - content->SetDocument(this, PR_TRUE); - refContent->SetDocument(nsnull, PR_TRUE); + content->SetDocument(this, PR_TRUE, PR_TRUE); + refContent->SetDocument(nsnull, PR_TRUE, PR_TRUE); *aReturn = aNewChild; NS_ADDREF(aNewChild); } @@ -2567,7 +2567,7 @@ nsDocument::RemoveChild(nsIDOMNode* aOldChild, nsIDOMNode** aReturn) } if (NS_OK == result) { - content->SetDocument(nsnull, PR_TRUE); + content->SetDocument(nsnull, PR_TRUE, PR_TRUE); *aReturn = aOldChild; } else { diff --git a/mozilla/content/base/src/nsDocumentFragment.cpp b/mozilla/content/base/src/nsDocumentFragment.cpp index 8e39b0f5216..874e5be003c 100644 --- a/mozilla/content/base/src/nsDocumentFragment.cpp +++ b/mozilla/content/base/src/nsDocumentFragment.cpp @@ -121,8 +121,8 @@ public: } NS_IMETHOD GetDocument(nsIDocument*& aResult) const { return mInner.GetDocument(aResult); } - NS_IMETHOD SetDocument(nsIDocument* aDocument, PRBool aDeep) - { return mInner.SetDocument(aDocument, aDeep); } + NS_IMETHOD SetDocument(nsIDocument* aDocument, PRBool aDeep, PRBool aCompileEventHandlers) + { return mInner.SetDocument(aDocument, aDeep, aCompileEventHandlers); } NS_IMETHOD GetParent(nsIContent*& aResult) const { aResult = nsnull; diff --git a/mozilla/content/base/src/nsGenericDOMDataNode.cpp b/mozilla/content/base/src/nsGenericDOMDataNode.cpp index cab355b678c..1851c7c0e2d 100644 --- a/mozilla/content/base/src/nsGenericDOMDataNode.cpp +++ b/mozilla/content/base/src/nsGenericDOMDataNode.cpp @@ -688,7 +688,7 @@ nsGenericDOMDataNode::GetDocument(nsIDocument*& aResult) const nsresult -nsGenericDOMDataNode::SetDocument(nsIDocument* aDocument, PRBool aDeep) +nsGenericDOMDataNode::SetDocument(nsIDocument* aDocument, PRBool aDeep, PRBool aCompileEventHandlers) { // If we were part of a document, make sure we get rid of the // script context reference to our script object so that our diff --git a/mozilla/content/base/src/nsGenericDOMDataNode.h b/mozilla/content/base/src/nsGenericDOMDataNode.h index 581f58a5a0c..ac4301a2d27 100644 --- a/mozilla/content/base/src/nsGenericDOMDataNode.h +++ b/mozilla/content/base/src/nsGenericDOMDataNode.h @@ -147,7 +147,7 @@ struct nsGenericDOMDataNode { // Implementation for nsIContent nsresult GetDocument(nsIDocument*& aResult) const; - nsresult SetDocument(nsIDocument* aDocument, PRBool aDeep); + nsresult SetDocument(nsIDocument* aDocument, PRBool aDeep, PRBool aCompileEventHandlers); nsresult GetParent(nsIContent*& aResult) const; nsresult SetParent(nsIContent* aParent); nsresult IsSynthetic(PRBool& aResult) { @@ -442,8 +442,8 @@ struct nsGenericDOMDataNode { NS_IMETHOD GetDocument(nsIDocument*& aResult) const { \ return _g.GetDocument(aResult); \ } \ - NS_IMETHOD SetDocument(nsIDocument* aDocument, PRBool aDeep) { \ - return _g.SetDocument(aDocument, aDeep); \ + NS_IMETHOD SetDocument(nsIDocument* aDocument, PRBool aDeep, PRBool aCompileEventHandlers) { \ + return _g.SetDocument(aDocument, aDeep, aCompileEventHandlers); \ } \ NS_IMETHOD GetParent(nsIContent*& aResult) const { \ return _g.GetParent(aResult); \ diff --git a/mozilla/content/base/src/nsGenericElement.cpp b/mozilla/content/base/src/nsGenericElement.cpp index aa8573e5685..932a02df8ab 100644 --- a/mozilla/content/base/src/nsGenericElement.cpp +++ b/mozilla/content/base/src/nsGenericElement.cpp @@ -1154,7 +1154,8 @@ nsGenericElement::GetDocument(nsIDocument*& aResult) const void nsGenericElement::SetDocumentInChildrenOf(nsIContent* aContent, - nsIDocument* aDocument) + nsIDocument* aDocument, + PRBool aCompileEventHandlers) { PRInt32 i, n; aContent->ChildCount(n); @@ -1162,14 +1163,14 @@ nsGenericElement::SetDocumentInChildrenOf(nsIContent* aContent, nsIContent* child; aContent->ChildAt(i, child); if (nsnull != child) { - child->SetDocument(aDocument, PR_TRUE); + child->SetDocument(aDocument, PR_TRUE, aCompileEventHandlers); NS_RELEASE(child); } } } nsresult -nsGenericElement::SetDocument(nsIDocument* aDocument, PRBool aDeep) +nsGenericElement::SetDocument(nsIDocument* aDocument, PRBool aDeep, PRBool aCompileEventHandlers) { if (aDocument != mDocument) { // If we were part of a document, make sure we get rid of the @@ -1226,7 +1227,7 @@ nsGenericElement::SetDocument(nsIDocument* aDocument, PRBool aDeep) } if (PR_TRUE == aDeep) { - SetDocumentInChildrenOf(mContent, aDocument); + SetDocumentInChildrenOf(mContent, aDocument, aCompileEventHandlers); } return NS_OK; @@ -1863,7 +1864,7 @@ nsGenericElement::doInsertBefore(nsIDOMNode* aNewChild, return res; } - childContent->SetDocument(mDocument, PR_TRUE); + childContent->SetDocument(mDocument, PR_TRUE, PR_TRUE); // Insert the child and increment the insertion position res = mContent->InsertChildAt(childContent, refPos++, PR_TRUE); @@ -1928,7 +1929,7 @@ nsGenericElement::doInsertBefore(nsIDOMNode* aNewChild, } } - newContent->SetDocument(mDocument, PR_TRUE); + newContent->SetDocument(mDocument, PR_TRUE, PR_TRUE); res = mContent->InsertChildAt(newContent, refPos, PR_TRUE); @@ -2056,7 +2057,7 @@ nsGenericElement::doReplaceChild(nsIDOMNode* aNewChild, return res; } - childContent->SetDocument(document, PR_TRUE); + childContent->SetDocument(document, PR_TRUE, PR_TRUE); // Insert the child and increment the insertion position if (i) { @@ -2117,7 +2118,7 @@ nsGenericElement::doReplaceChild(nsIDOMNode* aNewChild, } } - newContent->SetDocument(document, PR_TRUE); + newContent->SetDocument(document, PR_TRUE, PR_TRUE); res = mContent->ReplaceChildAt(newContent, oldPos, PR_TRUE); @@ -2817,7 +2818,7 @@ nsGenericContainerElement::InsertChildAt(nsIContent* aKid, aKid->SetParent(mContent); nsRange::OwnerChildInserted(mContent, aIndex); if (nsnull != doc) { - aKid->SetDocument(doc, PR_FALSE); + aKid->SetDocument(doc, PR_FALSE, PR_TRUE); if (aNotify) { doc->ContentInserted(mContent, aKid, aIndex); } @@ -2846,12 +2847,12 @@ nsGenericContainerElement::ReplaceChildAt(nsIContent* aKid, NS_ADDREF(aKid); aKid->SetParent(mContent); if (nsnull != doc) { - aKid->SetDocument(doc, PR_FALSE); + aKid->SetDocument(doc, PR_FALSE, PR_TRUE); if (aNotify) { doc->ContentReplaced(mContent, oldKid, aKid, aIndex); } } - oldKid->SetDocument(nsnull, PR_TRUE); + oldKid->SetDocument(nsnull, PR_TRUE, PR_TRUE); oldKid->SetParent(nsnull); NS_RELEASE(oldKid); } @@ -2875,7 +2876,7 @@ nsGenericContainerElement::AppendChildTo(nsIContent* aKid, PRBool aNotify) aKid->SetParent(mContent); // ranges don't need adjustment since new child is at end of list if (nsnull != doc) { - aKid->SetDocument(doc, PR_FALSE); + aKid->SetDocument(doc, PR_FALSE, PR_TRUE); if (aNotify) { doc->ContentAppended(mContent, mChildren.Count() - 1); } @@ -2903,7 +2904,7 @@ nsGenericContainerElement::RemoveChildAt(PRInt32 aIndex, PRBool aNotify) doc->ContentRemoved(mContent, oldKid, aIndex); } } - oldKid->SetDocument(nsnull, PR_TRUE); + oldKid->SetDocument(nsnull, PR_TRUE, PR_TRUE); oldKid->SetParent(nsnull); NS_RELEASE(oldKid); if (aNotify && (nsnull != doc)) { diff --git a/mozilla/content/base/src/nsGenericElement.h b/mozilla/content/base/src/nsGenericElement.h index d2173d8764e..d6e192a1608 100644 --- a/mozilla/content/base/src/nsGenericElement.h +++ b/mozilla/content/base/src/nsGenericElement.h @@ -179,7 +179,7 @@ public: // Implementation for nsIContent nsresult GetDocument(nsIDocument*& aResult) const; - nsresult SetDocument(nsIDocument* aDocument, PRBool aDeep); + nsresult SetDocument(nsIDocument* aDocument, PRBool aDeep, PRBool aCompileEventHandlers); nsresult GetParent(nsIContent*& aResult) const; nsresult SetParent(nsIContent* aParent); nsresult IsSynthetic(PRBool& aResult) { @@ -260,7 +260,7 @@ public: nsIContent* aSecond); static void SetDocumentInChildrenOf(nsIContent* aContent, - nsIDocument* aDocument); + nsIDocument* aDocument, PRBool aCompileEventHandlers); static nsresult GetScriptObjectFactory(nsIDOMScriptObjectFactory **aFactory); @@ -557,8 +557,8 @@ public: NS_IMETHOD GetDocument(nsIDocument*& aResult) const { \ return _g.GetDocument(aResult); \ } \ - NS_IMETHOD SetDocument(nsIDocument* aDocument, PRBool aDeep) { \ - return _g.SetDocument(aDocument, aDeep); \ + NS_IMETHOD SetDocument(nsIDocument* aDocument, PRBool aDeep, PRBool aCompileEventHandlers) { \ + return _g.SetDocument(aDocument, aDeep, aCompileEventHandlers); \ } \ NS_IMETHOD GetParent(nsIContent*& aResult) const { \ return _g.GetParent(aResult); \ @@ -686,8 +686,8 @@ public: NS_IMETHOD GetDocument(nsIDocument*& aResult) const { \ return _g.GetDocument(aResult); \ } \ - NS_IMETHOD SetDocument(nsIDocument* aDocument, PRBool aDeep) { \ - return _g.SetDocument(aDocument, aDeep); \ + NS_IMETHOD SetDocument(nsIDocument* aDocument, PRBool aDeep, PRBool aCompileEventHandlers) { \ + return _g.SetDocument(aDocument, aDeep, aCompileEventHandlers); \ } \ NS_IMETHOD GetParent(nsIContent*& aResult) const { \ return _g.GetParent(aResult); \ @@ -813,7 +813,7 @@ public: NS_IMETHOD GetDocument(nsIDocument*& aResult) const { \ return _g.GetDocument(aResult); \ } \ - NS_IMETHOD SetDocument(nsIDocument* aDocument, PRBool aDeep); \ + NS_IMETHOD SetDocument(nsIDocument* aDocument, PRBool aDeep, PRBool aCompileEventHandlers); \ NS_IMETHOD GetParent(nsIContent*& aResult) const { \ return _g.GetParent(aResult); \ } \ @@ -940,7 +940,7 @@ public: NS_IMETHOD GetDocument(nsIDocument*& aResult) const { \ return _g.GetDocument(aResult); \ } \ - NS_IMETHOD SetDocument(nsIDocument* aDocument, PRBool aDeep); \ + NS_IMETHOD SetDocument(nsIDocument* aDocument, PRBool aDeep, PRBool aCompileEventHandlers); \ NS_IMETHOD GetParent(nsIContent*& aResult) const { \ return _g.GetParent(aResult); \ } \ @@ -1065,8 +1065,8 @@ public: NS_IMETHOD GetDocument(nsIDocument*& aResult) const { \ return _g.GetDocument(aResult); \ } \ - NS_IMETHOD SetDocument(nsIDocument* aDocument, PRBool aDeep) { \ - return _g.SetDocument(aDocument, aDeep); \ + NS_IMETHOD SetDocument(nsIDocument* aDocument, PRBool aDeep, PRBool aCompileEventHandlers) { \ + return _g.SetDocument(aDocument, aDeep, aCompileEventHandlers); \ } \ NS_IMETHOD GetParent(nsIContent*& aResult) const { \ return _g.GetParent(aResult); \ @@ -1190,7 +1190,7 @@ public: NS_IMETHOD GetDocument(nsIDocument*& aResult) const { \ return _g.GetDocument(aResult); \ } \ - NS_IMETHOD SetDocument(nsIDocument* aDocument, PRBool aDeep); \ + NS_IMETHOD SetDocument(nsIDocument* aDocument, PRBool aDeep, PRBool aCompileEventHandlers); \ NS_IMETHOD GetParent(nsIContent*& aResult) const { \ return _g.GetParent(aResult); \ } \ diff --git a/mozilla/content/html/content/src/nsAttributeContent.cpp b/mozilla/content/html/content/src/nsAttributeContent.cpp index 0ed92723ad9..991850db536 100644 --- a/mozilla/content/html/content/src/nsAttributeContent.cpp +++ b/mozilla/content/html/content/src/nsAttributeContent.cpp @@ -88,7 +88,7 @@ public: // Implementation for nsIContent NS_IMETHOD GetDocument(nsIDocument*& aResult) const; - NS_IMETHOD SetDocument(nsIDocument* aDocument, PRBool aDeep); + NS_IMETHOD SetDocument(nsIDocument* aDocument, PRBool aDeep, PRBool aCompileEventHandlers); NS_IMETHOD GetParent(nsIContent*& aResult) const; NS_IMETHOD SetParent(nsIContent* aParent); @@ -359,7 +359,7 @@ nsAttributeContent::GetDocument(nsIDocument*& aResult) const nsresult -nsAttributeContent::SetDocument(nsIDocument* aDocument, PRBool aDeep) +nsAttributeContent::SetDocument(nsIDocument* aDocument, PRBool aDeep, PRBool aCompileEventHandlers) { mDocument = aDocument; //NS_IF_ADDREF(mDocument); diff --git a/mozilla/content/html/content/src/nsGenericHTMLElement.cpp b/mozilla/content/html/content/src/nsGenericHTMLElement.cpp index 95f5489c261..8497346aac0 100644 --- a/mozilla/content/html/content/src/nsGenericHTMLElement.cpp +++ b/mozilla/content/html/content/src/nsGenericHTMLElement.cpp @@ -915,14 +915,14 @@ nsGenericHTMLElement::InNavQuirksMode(nsIDocument* aDoc) } nsresult -nsGenericHTMLElement::SetDocument(nsIDocument* aDocument, PRBool aDeep) +nsGenericHTMLElement::SetDocument(nsIDocument* aDocument, PRBool aDeep, PRBool aCompileEventHandlers) { PRBool doNothing = PR_FALSE; if (aDocument == mDocument) { doNothing = PR_TRUE; // short circuit useless work } - nsresult result = nsGenericElement::SetDocument(aDocument, aDeep); + nsresult result = nsGenericElement::SetDocument(aDocument, aDeep, aCompileEventHandlers); if (NS_OK != result) { return result; } @@ -1022,6 +1022,7 @@ nsGenericHTMLElement::SetParentForFormControls(nsIContent* aParent, nsresult nsGenericHTMLElement::SetDocumentForFormControls(nsIDocument* aDocument, PRBool aDeep, + PRBool aCompileEventHandlers, nsIFormControl* aControl, nsIForm* aForm) { @@ -1038,7 +1039,7 @@ nsGenericHTMLElement::SetDocumentForFormControls(nsIDocument* aDocument, } if (NS_SUCCEEDED(result)) { - result = SetDocument(aDocument, aDeep); + result = SetDocument(aDocument, aDeep, aCompileEventHandlers); } return result; @@ -3343,7 +3344,7 @@ nsGenericHTMLContainerElement::InsertChildAt(nsIContent* aKid, aKid->SetParent(mContent); nsRange::OwnerChildInserted(mContent, aIndex); if (nsnull != doc) { - aKid->SetDocument(doc, PR_FALSE); + aKid->SetDocument(doc, PR_FALSE, PR_TRUE); if (aNotify) { doc->ContentInserted(mContent, aKid, aIndex); } @@ -3372,12 +3373,12 @@ nsGenericHTMLContainerElement::ReplaceChildAt(nsIContent* aKid, NS_ADDREF(aKid); aKid->SetParent(mContent); if (nsnull != doc) { - aKid->SetDocument(doc, PR_FALSE); + aKid->SetDocument(doc, PR_FALSE, PR_TRUE); if (aNotify) { doc->ContentReplaced(mContent, oldKid, aKid, aIndex); } } - oldKid->SetDocument(nsnull, PR_TRUE); + oldKid->SetDocument(nsnull, PR_TRUE, PR_TRUE); oldKid->SetParent(nsnull); NS_RELEASE(oldKid); } @@ -3401,7 +3402,7 @@ nsGenericHTMLContainerElement::AppendChildTo(nsIContent* aKid, PRBool aNotify) aKid->SetParent(mContent); // ranges don't need adjustment since new child is at end of list if (nsnull != doc) { - aKid->SetDocument(doc, PR_FALSE); + aKid->SetDocument(doc, PR_FALSE, PR_TRUE); if (aNotify) { doc->ContentAppended(mContent, mChildren.Count() - 1); } @@ -3429,7 +3430,7 @@ nsGenericHTMLContainerElement::RemoveChildAt(PRInt32 aIndex, PRBool aNotify) doc->ContentRemoved(mContent, oldKid, aIndex); } } - oldKid->SetDocument(nsnull, PR_TRUE); + oldKid->SetDocument(nsnull, PR_TRUE, PR_TRUE); oldKid->SetParent(nsnull); NS_RELEASE(oldKid); } diff --git a/mozilla/content/html/content/src/nsGenericHTMLElement.h b/mozilla/content/html/content/src/nsGenericHTMLElement.h index a7806cca332..b69799fde1a 100644 --- a/mozilla/content/html/content/src/nsGenericHTMLElement.h +++ b/mozilla/content/html/content/src/nsGenericHTMLElement.h @@ -107,7 +107,7 @@ public: // Implementation for nsIContent nsresult GetNameSpaceID(PRInt32& aNameSpaceID) const; - nsresult SetDocument(nsIDocument* aDocument, PRBool aDeep); + nsresult SetDocument(nsIDocument* aDocument, PRBool aDeep, PRBool aCompileEventHandlers); nsresult ParseAttributeString(const nsString& aStr, nsIAtom*& aName, PRInt32& aNameSpaceID); @@ -131,6 +131,7 @@ public: nsIForm* aForm); nsresult SetDocumentForFormControls(nsIDocument* aDocument, PRBool aDeep, + PRBool aCompileEventHandlers, nsIFormControl* aControl, nsIForm* aForm); nsresult HandleDOMEventForAnchors(nsIPresContext* aPresContext, diff --git a/mozilla/content/html/content/src/nsHTMLAnchorElement.cpp b/mozilla/content/html/content/src/nsHTMLAnchorElement.cpp index dbc220450f2..82cb7f10599 100644 --- a/mozilla/content/html/content/src/nsHTMLAnchorElement.cpp +++ b/mozilla/content/html/content/src/nsHTMLAnchorElement.cpp @@ -233,7 +233,7 @@ nsresult nsHTMLAnchorElement::RegUnRegAccessKey(PRBool aDoReg) } NS_IMETHODIMP -nsHTMLAnchorElement::SetDocument(nsIDocument* aDocument, PRBool aDeep) +nsHTMLAnchorElement::SetDocument(nsIDocument* aDocument, PRBool aDeep, PRBool aCompileEventHandlers) { // The document gets set to null before it is destroyed, // so we unregister the the access key here (if it has one) @@ -242,7 +242,7 @@ nsHTMLAnchorElement::SetDocument(nsIDocument* aDocument, PRBool aDeep) RegUnRegAccessKey(PR_FALSE); } - nsresult res = mInner.SetDocument(aDocument, aDeep); + nsresult res = mInner.SetDocument(aDocument, aDeep, aCompileEventHandlers); // Register the access key here (if it has one) // if the document isn't null diff --git a/mozilla/content/html/content/src/nsHTMLBodyElement.cpp b/mozilla/content/html/content/src/nsHTMLBodyElement.cpp index 994dd2150a0..a2c3e8a56fd 100644 --- a/mozilla/content/html/content/src/nsHTMLBodyElement.cpp +++ b/mozilla/content/html/content/src/nsHTMLBodyElement.cpp @@ -125,7 +125,7 @@ public: nsBodyInner(); virtual ~nsBodyInner(); - nsresult SetDocument(nsIDocument* aDocument, PRBool aDeep); + nsresult SetDocument(nsIDocument* aDocument, PRBool aDeep, PRBool aCompileEventHandlers); BodyRule* mContentStyleRule; BodyFixupRule* mInlineStyleRule; @@ -153,7 +153,7 @@ nsBodyInner::~nsBodyInner() } } -nsresult nsBodyInner::SetDocument(nsIDocument* aDocument, PRBool aDeep) +nsresult nsBodyInner::SetDocument(nsIDocument* aDocument, PRBool aDeep, PRBool aCompileEventHandlers) { if (nsnull != mContentStyleRule) { mContentStyleRule->mPart = nsnull; @@ -165,7 +165,7 @@ nsresult nsBodyInner::SetDocument(nsIDocument* aDocument, PRBool aDeep) mInlineStyleRule->mSheet = nsnull; NS_RELEASE(mInlineStyleRule); // destroy old style rule since the sheet will probably change } - return nsGenericHTMLContainerElement::SetDocument(aDocument, aDeep); + return nsGenericHTMLContainerElement::SetDocument(aDocument, aDeep, aCompileEventHandlers); } //---------------------------------------------------------------------- diff --git a/mozilla/content/html/content/src/nsHTMLButtonElement.cpp b/mozilla/content/html/content/src/nsHTMLButtonElement.cpp index cd169201567..3e0cd3d1bc9 100644 --- a/mozilla/content/html/content/src/nsHTMLButtonElement.cpp +++ b/mozilla/content/html/content/src/nsHTMLButtonElement.cpp @@ -283,9 +283,9 @@ nsHTMLButtonElement::SetParent(nsIContent* aParent) } NS_IMETHODIMP -nsHTMLButtonElement::SetDocument(nsIDocument* aDocument, PRBool aDeep) +nsHTMLButtonElement::SetDocument(nsIDocument* aDocument, PRBool aDeep, PRBool aCompileEventHandlers) { - return mInner.SetDocumentForFormControls(aDocument, aDeep, this, mForm); + return mInner.SetDocumentForFormControls(aDocument, aDeep, aCompileEventHandlers, this, mForm); } NS_IMETHODIMP diff --git a/mozilla/content/html/content/src/nsHTMLFieldSetElement.cpp b/mozilla/content/html/content/src/nsHTMLFieldSetElement.cpp index a37840b8287..a07bba83c96 100644 --- a/mozilla/content/html/content/src/nsHTMLFieldSetElement.cpp +++ b/mozilla/content/html/content/src/nsHTMLFieldSetElement.cpp @@ -176,9 +176,9 @@ nsHTMLFieldSetElement::SetParent(nsIContent* aParent) } NS_IMETHODIMP -nsHTMLFieldSetElement::SetDocument(nsIDocument* aDocument, PRBool aDeep) +nsHTMLFieldSetElement::SetDocument(nsIDocument* aDocument, PRBool aDeep, PRBool aCompileEventHandlers) { - return mInner.SetDocumentForFormControls(aDocument, aDeep, this, mForm); + return mInner.SetDocumentForFormControls(aDocument, aDeep, aCompileEventHandlers, this, mForm); } NS_IMETHODIMP diff --git a/mozilla/content/html/content/src/nsHTMLImageElement.cpp b/mozilla/content/html/content/src/nsHTMLImageElement.cpp index 160ad1c483f..143a892fe36 100644 --- a/mozilla/content/html/content/src/nsHTMLImageElement.cpp +++ b/mozilla/content/html/content/src/nsHTMLImageElement.cpp @@ -702,13 +702,13 @@ nsHTMLImageElement::Initialize(JSContext* aContext, NS_IMETHODIMP nsHTMLImageElement::SetDocument(nsIDocument* aDocument, - PRBool aDeep) + PRBool aDeep, PRBool aCompileEventHandlers) { // If we've been added to the document, we can get rid of // our owner document reference so as to avoid a circular // reference. NS_IF_RELEASE(mOwnerDocument); - return mInner.SetDocument(aDocument, aDeep); + return mInner.SetDocument(aDocument, aDeep, aCompileEventHandlers); } NS_IMETHODIMP diff --git a/mozilla/content/html/content/src/nsHTMLInputElement.cpp b/mozilla/content/html/content/src/nsHTMLInputElement.cpp index b649646d5dc..7a37ea1f362 100644 --- a/mozilla/content/html/content/src/nsHTMLInputElement.cpp +++ b/mozilla/content/html/content/src/nsHTMLInputElement.cpp @@ -306,9 +306,9 @@ nsHTMLInputElement::SetParent(nsIContent* aParent) } NS_IMETHODIMP -nsHTMLInputElement::SetDocument(nsIDocument* aDocument, PRBool aDeep) +nsHTMLInputElement::SetDocument(nsIDocument* aDocument, PRBool aDeep, PRBool aCompileEventHandlers) { - return mInner.SetDocumentForFormControls(aDocument, aDeep, this, mForm); + return mInner.SetDocumentForFormControls(aDocument, aDeep, aCompileEventHandlers, this, mForm); } NS_IMETHODIMP diff --git a/mozilla/content/html/content/src/nsHTMLLabelElement.cpp b/mozilla/content/html/content/src/nsHTMLLabelElement.cpp index 31a5f89f254..fbb588f6240 100644 --- a/mozilla/content/html/content/src/nsHTMLLabelElement.cpp +++ b/mozilla/content/html/content/src/nsHTMLLabelElement.cpp @@ -257,9 +257,9 @@ nsHTMLLabelElement::SetParent(nsIContent* aParent) } NS_IMETHODIMP -nsHTMLLabelElement::SetDocument(nsIDocument* aDocument, PRBool aDeep) +nsHTMLLabelElement::SetDocument(nsIDocument* aDocument, PRBool aDeep, PRBool aCompileEventHandlers) { - return mInner.SetDocumentForFormControls(aDocument, aDeep, this, mForm); + return mInner.SetDocumentForFormControls(aDocument, aDeep, aCompileEventHandlers, this, mForm); } NS_IMETHODIMP diff --git a/mozilla/content/html/content/src/nsHTMLLegendElement.cpp b/mozilla/content/html/content/src/nsHTMLLegendElement.cpp index 210489bd9f2..612ba35f5c8 100644 --- a/mozilla/content/html/content/src/nsHTMLLegendElement.cpp +++ b/mozilla/content/html/content/src/nsHTMLLegendElement.cpp @@ -158,9 +158,9 @@ nsHTMLLegendElement::SetParent(nsIContent* aParent) } NS_IMETHODIMP -nsHTMLLegendElement::SetDocument(nsIDocument* aDocument, PRBool aDeep) +nsHTMLLegendElement::SetDocument(nsIDocument* aDocument, PRBool aDeep, PRBool aCompileEventHandlers) { - return mInner.SetDocumentForFormControls(aDocument, aDeep, this, mForm); + return mInner.SetDocumentForFormControls(aDocument, aDeep, aCompileEventHandlers, this, mForm); } NS_IMETHODIMP diff --git a/mozilla/content/html/content/src/nsHTMLMapElement.cpp b/mozilla/content/html/content/src/nsHTMLMapElement.cpp index 567b0465ac8..a3bf793c61c 100644 --- a/mozilla/content/html/content/src/nsHTMLMapElement.cpp +++ b/mozilla/content/html/content/src/nsHTMLMapElement.cpp @@ -70,7 +70,7 @@ public: NS_IMETHOD GetDocument(nsIDocument*& aResult) const { return mInner.GetDocument(aResult); } - NS_IMETHOD SetDocument(nsIDocument* aDocument, PRBool aDeep); + NS_IMETHOD SetDocument(nsIDocument* aDocument, PRBool aDeep, PRBool aCompileEventHandlers); NS_IMETHOD GetParent(nsIContent*& aResult) const { return mInner.GetParent(aResult); } @@ -254,7 +254,7 @@ nsHTMLMapElement::QueryInterface(REFNSIID aIID, void** aInstancePtr) } NS_IMETHODIMP -nsHTMLMapElement::SetDocument(nsIDocument* aDocument, PRBool aDeep) +nsHTMLMapElement::SetDocument(nsIDocument* aDocument, PRBool aDeep, PRBool aCompileEventHandlers) { nsresult rv; @@ -268,7 +268,7 @@ nsHTMLMapElement::SetDocument(nsIDocument* aDocument, PRBool aDeep) } } - rv = mInner.SetDocument(aDocument, aDeep); + rv = mInner.SetDocument(aDocument, aDeep, aCompileEventHandlers); if (NS_SUCCEEDED(rv) && (nsnull != aDocument)) { nsCOMPtr htmlDoc; diff --git a/mozilla/content/html/content/src/nsHTMLOptionElement.cpp b/mozilla/content/html/content/src/nsHTMLOptionElement.cpp index dd7902dd130..4eefc716dcb 100644 --- a/mozilla/content/html/content/src/nsHTMLOptionElement.cpp +++ b/mozilla/content/html/content/src/nsHTMLOptionElement.cpp @@ -577,7 +577,7 @@ nsHTMLOptionElement::SetText(const nsString& aText) nsIDocument * doc; result = GetDocument(doc); if (NS_SUCCEEDED(result)) { - text->SetDocument(doc, PR_FALSE); + text->SetDocument(doc, PR_FALSE, PR_TRUE); NS_IF_RELEASE(doc); } } diff --git a/mozilla/content/html/content/src/nsHTMLSelectElement.cpp b/mozilla/content/html/content/src/nsHTMLSelectElement.cpp index 504b1f008ce..9cdacea9a9f 100644 --- a/mozilla/content/html/content/src/nsHTMLSelectElement.cpp +++ b/mozilla/content/html/content/src/nsHTMLSelectElement.cpp @@ -343,9 +343,9 @@ nsHTMLSelectElement::SetParent(nsIContent* aParent) } NS_IMETHODIMP -nsHTMLSelectElement::SetDocument(nsIDocument* aDocument, PRBool aDeep) +nsHTMLSelectElement::SetDocument(nsIDocument* aDocument, PRBool aDeep, PRBool aCompileEventHandlers) { - return mInner.SetDocumentForFormControls(aDocument, aDeep, this, mForm); + return mInner.SetDocumentForFormControls(aDocument, aDeep, aCompileEventHandlers, this, mForm); } NS_IMETHODIMP diff --git a/mozilla/content/html/content/src/nsHTMLTextAreaElement.cpp b/mozilla/content/html/content/src/nsHTMLTextAreaElement.cpp index 95dcc1d63e1..784f5b9150e 100644 --- a/mozilla/content/html/content/src/nsHTMLTextAreaElement.cpp +++ b/mozilla/content/html/content/src/nsHTMLTextAreaElement.cpp @@ -216,9 +216,9 @@ nsHTMLTextAreaElement::SetParent(nsIContent* aParent) } NS_IMETHODIMP -nsHTMLTextAreaElement::SetDocument(nsIDocument* aDocument, PRBool aDeep) +nsHTMLTextAreaElement::SetDocument(nsIDocument* aDocument, PRBool aDeep, PRBool aCompileEventHandlers) { - return mInner.SetDocumentForFormControls(aDocument, aDeep, this, mForm); + return mInner.SetDocumentForFormControls(aDocument, aDeep, aCompileEventHandlers, this, mForm); } NS_IMETHODIMP diff --git a/mozilla/content/html/content/src/nsHTMLUnknownElement.cpp b/mozilla/content/html/content/src/nsHTMLUnknownElement.cpp index 79fe4af081c..52fa9116b33 100644 --- a/mozilla/content/html/content/src/nsHTMLUnknownElement.cpp +++ b/mozilla/content/html/content/src/nsHTMLUnknownElement.cpp @@ -67,8 +67,8 @@ public: NS_IMETHOD GetDocument(nsIDocument*& aResult) const { return mInner.GetDocument(aResult); } - NS_IMETHOD SetDocument(nsIDocument* aDocument, PRBool aDeep) { - return mInner.SetDocument(aDocument, aDeep); + NS_IMETHOD SetDocument(nsIDocument* aDocument, PRBool aDeep, PRBool aCompileEventHandlers) { + return mInner.SetDocument(aDocument, aDeep, aCompileEventHandlers); } NS_IMETHOD GetParent(nsIContent*& aResult) const { return mInner.GetParent(aResult); diff --git a/mozilla/content/html/document/src/nsHTMLContentSink.cpp b/mozilla/content/html/document/src/nsHTMLContentSink.cpp index 4887a47d9a8..d7772a646ea 100644 --- a/mozilla/content/html/document/src/nsHTMLContentSink.cpp +++ b/mozilla/content/html/document/src/nsHTMLContentSink.cpp @@ -1257,7 +1257,7 @@ SinkContext::OpenContainer(const nsIParserNode& aNode) mStack[mStackPos].mFlags = 0; mStack[mStackPos].mNumFlushed = 0; mStack[mStackPos].mInsertionPoint = -1; - content->SetDocument(mSink->mDocument, PR_FALSE); + content->SetDocument(mSink->mDocument, PR_FALSE, PR_TRUE); nsCOMPtr scriptGlobalObject; mSink->mDocument->GetScriptGlobalObject(getter_AddRefs(scriptGlobalObject)); @@ -1461,7 +1461,7 @@ SetDocumentInChildrenOf(nsIContent* aContent, nsIContent* child; aContent->ChildAt(i, child); if (nsnull != child) { - child->SetDocument(aDocument, PR_TRUE); + child->SetDocument(aDocument, PR_TRUE, PR_TRUE); NS_RELEASE(child); } } @@ -1602,7 +1602,7 @@ SinkContext::AddLeaf(const nsIParserNode& aNode) } // Set the content's document - content->SetDocument(mSink->mDocument, PR_FALSE); + content->SetDocument(mSink->mDocument, PR_FALSE, PR_TRUE); rv = mSink->AddAttributes(aNode, content); if (NS_OK != rv) { @@ -1706,7 +1706,7 @@ SinkContext::AddComment(const nsIParserNode& aNode) domComment->AppendData(aNode.GetText()); NS_RELEASE(domComment); - comment->SetDocument(mSink->mDocument, PR_FALSE); + comment->SetDocument(mSink->mDocument, PR_FALSE, PR_TRUE); nsIHTMLContent* parent; if ((nsnull == mSink->mBody) && (nsnull != mSink->mHead)) { @@ -1969,7 +1969,7 @@ SinkContext::FlushText(PRBool* aDidFlush, PRBool aReleaseLast) rv = NS_NewTextNode(&content); if (NS_OK == rv) { // Set the content's document - content->SetDocument(mSink->mDocument, PR_FALSE); + content->SetDocument(mSink->mDocument, PR_FALSE, PR_TRUE); // Set the text in the text node nsITextContent* text = nsnull; @@ -2206,7 +2206,7 @@ HTMLContentSink::Init(nsIDocument* aDoc, MOZ_TIMER_STOP(mWatch); return rv; } - mRoot->SetDocument(mDocument, PR_FALSE); + mRoot->SetDocument(mDocument, PR_FALSE, PR_TRUE); mDocument->SetRootContent(mRoot); // Make head part @@ -2548,7 +2548,7 @@ HTMLContentSink::SetTitle(const nsString& aValue) NS_RELEASE(tc); } it->AppendChildTo(text, PR_FALSE); - text->SetDocument(mDocument, PR_FALSE); + text->SetDocument(mDocument, PR_FALSE, PR_TRUE); NS_RELEASE(text); } mHead->AppendChildTo(it, PR_FALSE); @@ -3351,7 +3351,7 @@ HTMLContentSink::ProcessAREATag(const nsIParserNode& aNode) } // Set the content's document and attributes - area->SetDocument(mDocument, PR_FALSE); + area->SetDocument(mDocument, PR_FALSE, PR_TRUE); rv = AddAttributes(aNode, area); if (NS_FAILED(rv)) { NS_RELEASE(area); @@ -3434,7 +3434,7 @@ HTMLContentSink::ProcessBASETag(const nsIParserNode& aNode) // Add in the attributes and add the style content object to the // head container. - element->SetDocument(mDocument, PR_FALSE); + element->SetDocument(mDocument, PR_FALSE, PR_TRUE); result = AddAttributes(aNode, element); if (NS_SUCCEEDED(result)) { parent->AppendChildTo(element, PR_FALSE); @@ -3794,7 +3794,7 @@ HTMLContentSink::ProcessLINKTag(const nsIParserNode& aNode) // Add in the attributes and add the style content object to the // head container. - element->SetDocument(mDocument, PR_FALSE); + element->SetDocument(mDocument, PR_FALSE, PR_TRUE); result = AddAttributes(aNode, element); if (NS_FAILED(result)) { NS_RELEASE(element); @@ -3912,7 +3912,7 @@ HTMLContentSink::ProcessMETATag(const nsIParserNode& aNode) if (NS_OK == rv) { // Add in the attributes and add the meta content object to the // head container. - it->SetDocument(mDocument, PR_FALSE); + it->SetDocument(mDocument, PR_FALSE, PR_TRUE); rv = AddAttributes(aNode, it); if (NS_OK != rv) { NS_RELEASE(it); @@ -4544,7 +4544,7 @@ HTMLContentSink::ProcessSCRIPTTag(const nsIParserNode& aNode) // Add in the attributes and add the style content object to the // head container. - element->SetDocument(mDocument, PR_FALSE); + element->SetDocument(mDocument, PR_FALSE, PR_TRUE); rv = AddAttributes(aNode, element); if (NS_FAILED(rv)) { NS_RELEASE(element); @@ -4579,7 +4579,7 @@ HTMLContentSink::ProcessSCRIPTTag(const nsIParserNode& aNode) NS_RELEASE(tc); } element->AppendChildTo(text, PR_FALSE); - text->SetDocument(mDocument, PR_FALSE); + text->SetDocument(mDocument, PR_FALSE, PR_TRUE); NS_RELEASE(text); } } @@ -4677,7 +4677,7 @@ HTMLContentSink::ProcessSTYLETag(const nsIParserNode& aNode) // Add in the attributes and add the style content object to the // head container. - element->SetDocument(mDocument, PR_FALSE); + element->SetDocument(mDocument, PR_FALSE, PR_TRUE); rv = AddAttributes(aNode, element); if (NS_FAILED(rv)) { NS_RELEASE(element); @@ -4750,7 +4750,7 @@ HTMLContentSink::ProcessSTYLETag(const nsIParserNode& aNode) NS_RELEASE(tc); } element->AppendChildTo(text, PR_FALSE); - text->SetDocument(mDocument, PR_FALSE); + text->SetDocument(mDocument, PR_FALSE, PR_TRUE); NS_RELEASE(text); } diff --git a/mozilla/content/html/document/src/nsImageDocument.cpp b/mozilla/content/html/document/src/nsImageDocument.cpp index cd9b7a71843..fb699e620b3 100644 --- a/mozilla/content/html/document/src/nsImageDocument.cpp +++ b/mozilla/content/html/document/src/nsImageDocument.cpp @@ -261,7 +261,7 @@ nsImageDocument::CreateSyntheticDocument() if (NS_OK != rv) { return rv; } - root->SetDocument(this, PR_FALSE); + root->SetDocument(this, PR_FALSE, PR_TRUE); SetRootContent(root); rv = mNodeInfoManager->GetNodeInfo(nsHTMLAtoms::body, nsnull, @@ -274,7 +274,7 @@ nsImageDocument::CreateSyntheticDocument() if (NS_OK != rv) { return rv; } - body->SetDocument(this, PR_FALSE); + body->SetDocument(this, PR_FALSE, PR_TRUE); rv = mNodeInfoManager->GetNodeInfo(nsHTMLAtoms::p, nsnull, kNameSpaceID_None, *getter_AddRefs(nodeInfo)); @@ -285,7 +285,7 @@ nsImageDocument::CreateSyntheticDocument() if (NS_OK != rv) { return rv; } - center->SetDocument(this, PR_FALSE); + center->SetDocument(this, PR_FALSE, PR_TRUE); rv = mNodeInfoManager->GetNodeInfo(nsHTMLAtoms::img, nsnull, kNameSpaceID_None, @@ -297,7 +297,7 @@ nsImageDocument::CreateSyntheticDocument() if (NS_OK != rv) { return rv; } - image->SetDocument(this, PR_FALSE); + image->SetDocument(this, PR_FALSE, PR_TRUE); char* src; mDocumentURL->GetSpec(&src); diff --git a/mozilla/content/xbl/public/nsIXBLService.h b/mozilla/content/xbl/public/nsIXBLService.h index 6a4881bd86e..1496b565a2a 100644 --- a/mozilla/content/xbl/public/nsIXBLService.h +++ b/mozilla/content/xbl/public/nsIXBLService.h @@ -63,6 +63,7 @@ public: // Retrieves our base class (e.g., tells us what type of frame and content node to build) NS_IMETHOD ResolveTag(nsIContent* aContent, nsIAtom** aResult) = 0; + NS_IMETHOD AllowScripts(nsIContent* aContent, PRBool* aAllowScripts) = 0; }; #endif // nsIXBLService_h__ diff --git a/mozilla/content/xbl/src/nsXBLBinding.cpp b/mozilla/content/xbl/src/nsXBLBinding.cpp index 307d4af4318..22c33b3273f 100644 --- a/mozilla/content/xbl/src/nsXBLBinding.cpp +++ b/mozilla/content/xbl/src/nsXBLBinding.cpp @@ -39,6 +39,7 @@ #include "nsIContent.h" #include "nsIDocument.h" #include "nsIXMLContent.h" +#include "nsIXULContent.h" #include "nsIXMLContentSink.h" #include "nsLayoutCID.h" #include "nsXMLDocument.h" @@ -48,6 +49,7 @@ #include "nsINameSpace.h" #include "nsJSUtils.h" #include "nsIJSRuntimeService.h" +#include "nsIXBLService.h" // Event listeners #include "nsIEventListenerManager.h" @@ -167,6 +169,8 @@ public: NS_IMETHOD AddScriptEventListener(nsIContent* aElement, nsIAtom* aName, const nsString& aValue, REFNSIID aIID); + PRBool AllowScripts(); + static nsresult GetTextData(nsIContent *aParent, nsString& aResult); // Static members @@ -428,8 +432,9 @@ nsXBLBinding::SetAnonymousContent(nsIContent* aParent) // element's document. nsCOMPtr doc; mBoundElement->GetDocument(*getter_AddRefs(doc)); - mContent->SetDocument(doc, PR_TRUE); + mContent->SetDocument(doc, PR_TRUE, AllowScripts()); + // (2) The children's parent back pointer should not be to this synthetic root // but should instead point to the bound element. PRInt32 childCount; @@ -583,7 +588,7 @@ nsXBLBinding::InstallEventHandlers(nsIContent* aBoundElement) nsCOMPtr handlers; GetImmediateChild(kHandlersAtom, getter_AddRefs(handlers)); - if (handlers) { + if (handlers && AllowScripts()) { // Now walk the handlers and add event listeners to the bound // element. PRInt32 childCount; @@ -669,7 +674,7 @@ nsXBLBinding::InstallProperties(nsIContent* aBoundElement) nsCOMPtr interfaceElement; GetImmediateChild(kInterfaceAtom, getter_AddRefs(interfaceElement)); - if (interfaceElement) { + if (interfaceElement && AllowScripts()) { // Get our bound element's script context. nsresult rv; nsCOMPtr document; @@ -1055,7 +1060,7 @@ nsXBLBinding::ChangeDocument(nsIDocument* aOldDocument, nsIDocument* aNewDocumen nsCOMPtr anonymous; GetAnonymousContent(getter_AddRefs(anonymous)); if (anonymous) - anonymous->SetDocument(aNewDocument, PR_TRUE); + anonymous->SetDocument(aNewDocument, PR_TRUE, AllowScripts()); } return NS_OK; @@ -1459,6 +1464,20 @@ nsXBLBinding::GetTextData(nsIContent *aParent, nsString& aResult) return NS_OK; } +PRBool +nsXBLBinding::AllowScripts() +{ + nsresult rv; + nsCOMPtr xblService(do_GetService("component://netscape/xbl", &rv)); + if (xblService) { + PRBool allowScripts; + xblService->AllowScripts(mBinding, &allowScripts); + return allowScripts; + } + + return PR_FALSE; +} + // Creation Routine /////////////////////////////////////////////////////////////////////// nsresult diff --git a/mozilla/content/xbl/src/nsXBLService.cpp b/mozilla/content/xbl/src/nsXBLService.cpp index 95d93b40d94..a4ee72e12db 100644 --- a/mozilla/content/xbl/src/nsXBLService.cpp +++ b/mozilla/content/xbl/src/nsXBLService.cpp @@ -46,11 +46,13 @@ #include "nsITextContent.h" #include "nsIXBLBinding.h" +#include "nsIChromeRegistry.h" // Static IIDs/CIDs. Try to minimize these. static NS_DEFINE_CID(kNameSpaceManagerCID, NS_NAMESPACEMANAGER_CID); static NS_DEFINE_CID(kXMLDocumentCID, NS_XMLDOCUMENT_CID); static NS_DEFINE_CID(kParserCID, NS_PARSER_IID); // XXX What's up with this??? +static NS_DEFINE_CID(kChromeRegistryCID, NS_CHROMEREGISTRY_CID); // nsProxyStream // A helper class used for synchronous parsing of URLs. @@ -130,6 +132,8 @@ class nsXBLService: public nsIXBLService // Gets the object's base class type. NS_IMETHOD ResolveTag(nsIContent* aContent, nsIAtom** aResult); + NS_IMETHOD AllowScripts(nsIContent* aContent, PRBool* aAllowScripts); + public: nsXBLService(); virtual ~nsXBLService(); @@ -152,7 +156,7 @@ protected: static nsSupportsHashtable* mBindingTable; // This is a table of all the bindings files // we have loaded // during this session. - static nsSupportsHashtable* mProtoClassTable; // Every binding with methods/properties has a protoclass. + static nsSupportsHashtable* mScriptAccessTable; // Can the doc's bindings access scripts static nsINameSpaceManager* gNameSpaceManager; // Used to register the XBL namespace static PRInt32 kNameSpaceID_XBL; // Convenient cached XBL namespace. @@ -170,7 +174,7 @@ protected: // Static member variable initialization PRUint32 nsXBLService::gRefCnt = 0; nsSupportsHashtable* nsXBLService::mBindingTable = nsnull; -nsSupportsHashtable* nsXBLService::mProtoClassTable = nsnull; +nsSupportsHashtable* nsXBLService::mScriptAccessTable = nsnull; nsINameSpaceManager* nsXBLService::gNameSpaceManager = nsnull; @@ -191,7 +195,7 @@ nsXBLService::nsXBLService(void) if (gRefCnt == 1) { // Create our binding table. mBindingTable = new nsSupportsHashtable(); - mProtoClassTable = new nsSupportsHashtable(); + mScriptAccessTable = new nsSupportsHashtable(); // Register the XBL namespace. nsresult rv = nsComponentManager::CreateInstance(kNameSpaceManagerCID, @@ -221,7 +225,7 @@ nsXBLService::~nsXBLService(void) gRefCnt--; if (gRefCnt == 0) { delete mBindingTable; - delete mProtoClassTable; + delete mScriptAccessTable; NS_IF_RELEASE(gNameSpaceManager); @@ -358,6 +362,8 @@ nsXBLService::FlushBindingDocuments() { delete mBindingTable; mBindingTable = new nsSupportsHashtable(); + delete mScriptAccessTable; + mScriptAccessTable = new nsSupportsHashtable(); return NS_OK; } @@ -378,6 +384,25 @@ nsXBLService::ResolveTag(nsIContent* aContent, nsIAtom** aResult) return NS_OK; } +NS_IMETHODIMP +nsXBLService::AllowScripts(nsIContent* aContent, PRBool* aAllowScripts) +{ + nsAutoString uri; + aContent->GetAttribute(kNameSpaceID_None, kURIAtom, uri); + + PRInt32 indx = uri.RFindChar('#'); + if (indx >= 0) + uri.Truncate(indx); + + nsStringKey key(uri); + nsCOMPtr document; + document = dont_AddRef(NS_STATIC_CAST(nsIDocument*, mScriptAccessTable->Get(&key))); + + *aAllowScripts = !document; + + return NS_OK; +} + // Internal helper methods //////////////////////////////////////////////////////////////// NS_IMETHODIMP nsXBLService::GetBinding(const nsCString& aURLStr, nsIXBLBinding** aResult) @@ -421,8 +446,11 @@ NS_IMETHODIMP nsXBLService::GetBinding(const nsCString& aURLStr, nsIXBLBinding** // If no ref is specified just use this. if ((bindingName.IsEmpty()) || (bindingName == value)) { - child->SetAttribute(kNameSpaceID_None, kURIAtom, NS_ConvertASCIItoUCS2(aURLStr.GetBuffer(), aURLStr.Length()), PR_FALSE); - + nsAutoString url; + child->GetAttribute(kNameSpaceID_None, kURIAtom, url); + if (url.IsEmpty()) + child->SetAttribute(kNameSpaceID_None, kURIAtom, NS_ConvertASCIItoUCS2(aURLStr.GetBuffer(), aURLStr.Length()), PR_FALSE); + // Make a new binding NS_NewXBLBinding(aResult); @@ -457,6 +485,8 @@ NS_IMETHODIMP nsXBLService::GetBinding(const nsCString& aURLStr, nsIXBLBinding** NS_IMETHODIMP nsXBLService::GetBindingDocument(const nsCString& aURLStr, nsIDocument** aResult) { + nsresult rv; + *aResult = nsnull; // We've got a file. Check our key binding file cache. @@ -465,7 +495,6 @@ nsXBLService::GetBindingDocument(const nsCString& aURLStr, nsIDocument** aResult document = dont_AddRef(NS_STATIC_CAST(nsIDocument*, mBindingTable->Get(&key))); if (!document) { - nsCOMPtr uri; nsComponentManager::CreateInstance("component://netscape/network/standard-url", nsnull, @@ -477,6 +506,14 @@ nsXBLService::GetBindingDocument(const nsCString& aURLStr, nsIDocument** aResult if (document) { // Put the key binding doc into our table. mBindingTable->Put(&key, document); + + nsCOMPtr reg(do_GetService(kChromeRegistryCID, &rv)); + if (NS_SUCCEEDED(rv) && reg) { + PRBool allow; + reg->AllowScriptsForSkin(uri, &allow); + if (!allow) + mScriptAccessTable->Put(&key, document); + } } else return NS_ERROR_FAILURE; } diff --git a/mozilla/content/xml/content/src/nsXMLElement.h b/mozilla/content/xml/content/src/nsXMLElement.h index d2c2bb2d569..1861c783555 100644 --- a/mozilla/content/xml/content/src/nsXMLElement.h +++ b/mozilla/content/xml/content/src/nsXMLElement.h @@ -63,8 +63,8 @@ public: NS_IMETHOD GetDocument(nsIDocument*& aResult) const { return mInner.GetDocument(aResult); } - NS_IMETHOD SetDocument(nsIDocument* aDocument, PRBool aDeep) { - return mInner.SetDocument(aDocument, aDeep); + NS_IMETHOD SetDocument(nsIDocument* aDocument, PRBool aDeep, PRBool aCompileEventHandlers) { + return mInner.SetDocument(aDocument, aDeep, aCompileEventHandlers); } NS_IMETHOD GetParent(nsIContent*& aResult) const { return mInner.GetParent(aResult); diff --git a/mozilla/content/xml/document/src/nsXMLContentSink.cpp b/mozilla/content/xml/document/src/nsXMLContentSink.cpp index c8fa73bb96a..882454665a5 100644 --- a/mozilla/content/xml/document/src/nsXMLContentSink.cpp +++ b/mozilla/content/xml/document/src/nsXMLContentSink.cpp @@ -755,7 +755,7 @@ nsXMLContentSink::OpenContainer(const nsIParserNode& aNode) PRInt32 id; mDocument->GetAndIncrementContentID(&id); content->SetContentID(id); - content->SetDocument(mDocument, PR_FALSE); + content->SetDocument(mDocument, PR_FALSE, PR_TRUE); // Set the attributes on the new content element result = AddAttributes(aNode, content, isHTML); @@ -940,7 +940,7 @@ nsXMLContentSink::AddComment(const nsIParserNode& aNode) domComment->AppendData(text); NS_RELEASE(domComment); - comment->SetDocument(mDocument, PR_FALSE); + comment->SetDocument(mDocument, PR_FALSE, PR_TRUE); result = AddContentAsLeaf(comment); } NS_RELEASE(comment); @@ -967,7 +967,7 @@ nsXMLContentSink::AddCDATASection(const nsIParserNode& aNode) domCDATA->AppendData(text); NS_RELEASE(domCDATA); - cdata->SetDocument(mDocument, PR_FALSE); + cdata->SetDocument(mDocument, PR_FALSE, PR_TRUE); result = AddContentAsLeaf(cdata); } NS_RELEASE(cdata); @@ -1267,7 +1267,7 @@ nsXMLContentSink::AddProcessingInstruction(const nsIParserNode& aNode) ParseProcessingInstruction(text, target, data); result = NS_NewXMLProcessingInstruction(&node, target, data); if (NS_OK == result) { - node->SetDocument(mDocument, PR_FALSE); + node->SetDocument(mDocument, PR_FALSE, PR_TRUE); result = AddContentAsLeaf(node); } @@ -1327,7 +1327,7 @@ nsXMLContentSink::FlushText(PRBool aCreateTextNode, PRBool* aDidFlush) rv = NS_NewTextNode(&content); if (NS_OK == rv) { // Set the content's document - content->SetDocument(mDocument, PR_FALSE); + content->SetDocument(mDocument, PR_FALSE, PR_TRUE); // Set the text in the text node static NS_DEFINE_IID(kITextContentIID, NS_ITEXT_CONTENT_IID); diff --git a/mozilla/content/xul/content/src/nsXULElement.cpp b/mozilla/content/xul/content/src/nsXULElement.cpp index 7684768cd17..b36d95345ce 100644 --- a/mozilla/content/xul/content/src/nsXULElement.cpp +++ b/mozilla/content/xul/content/src/nsXULElement.cpp @@ -1182,7 +1182,7 @@ nsXULElement::InsertBefore(nsIDOMNode* aNewChild, nsIDOMNode* aRefChild, nsIDOMN // done now. We do it -before- inserting into the content // model, because some frames assume that the document // will have been set. - rv = newcontent->SetDocument(mDocument, PR_TRUE); + rv = newcontent->SetDocument(mDocument, PR_TRUE, PR_TRUE); if (NS_FAILED(rv)) return rv; rv = InsertChildAt(newcontent, pos, PR_TRUE); @@ -1201,7 +1201,7 @@ nsXULElement::InsertBefore(nsIDOMNode* aNewChild, nsIDOMNode* aRefChild, nsIDOMN // now. We do it -before- appending to the content model, // because some frames assume that they can get to the // document right away. - rv = newcontent->SetDocument(mDocument, PR_TRUE); + rv = newcontent->SetDocument(mDocument, PR_TRUE, PR_TRUE); if (NS_FAILED(rv)) return rv; rv = AppendChildTo(newcontent, PR_TRUE); @@ -1246,7 +1246,7 @@ nsXULElement::ReplaceChild(nsIDOMNode* aNewChild, nsIDOMNode* aOldChild, nsIDOMN // is done now. We do it -before- replacing the nodein // the content model, because some frames assume that // the document will have been set. - rv = newelement->SetDocument(mDocument, PR_TRUE); + rv = newelement->SetDocument(mDocument, PR_TRUE, PR_TRUE); if (NS_FAILED(rv)) return rv; rv = ReplaceChildAt(newelement, pos, PR_TRUE); @@ -2403,9 +2403,9 @@ nsXULElement::GetDocument(nsIDocument*& aResult) const NS_IF_ADDREF(aResult); return NS_OK; } - + NS_IMETHODIMP -nsXULElement::SetDocument(nsIDocument* aDocument, PRBool aDeep) +nsXULElement::SetDocument(nsIDocument* aDocument, PRBool aDeep, PRBool aCompileEventHandlers) { nsresult rv; @@ -2476,9 +2476,11 @@ nsXULElement::SetDocument(nsIDocument* aDocument, PRBool aDeep) PRBool reset = PR_FALSE; if (nameSpaceID == kNameSpaceID_None) { - nsIID iid; - rv = gXULUtils->GetEventHandlerIID(attr, &iid, &reset); - if (NS_FAILED(rv)) return rv; + if (aCompileEventHandlers) { + nsIID iid; + rv = gXULUtils->GetEventHandlerIID(attr, &iid, &reset); + if (NS_FAILED(rv)) return rv; + } if (! reset) { if ((attr.get() == kPopupAtom) || @@ -2520,7 +2522,7 @@ nsXULElement::SetDocument(nsIDocument* aDocument, PRBool aDeep) if (! child) continue; - child->SetDocument(aDocument, aDeep); + child->SetDocument(aDocument, aDeep, aCompileEventHandlers); } } @@ -2625,7 +2627,7 @@ nsXULElement::InsertChildAt(nsIContent* aKid, PRInt32 aIndex, PRBool aNotify) //nsRange::OwnerChildInserted(this, aIndex); // N.B. that this is "shallow"! - aKid->SetDocument(mDocument, PR_FALSE); + aKid->SetDocument(mDocument, PR_FALSE, PR_TRUE); if (aNotify && mDocument) { mDocument->ContentInserted(NS_STATIC_CAST(nsIStyledContent*, this), aKid, aIndex); @@ -2668,7 +2670,7 @@ nsXULElement::ReplaceChildAt(nsIContent* aKid, PRInt32 aIndex, PRBool aNotify) // N.B. that we only do a "shallow" SetDocument() // here. Callers beware! - aKid->SetDocument(mDocument, PR_FALSE); + aKid->SetDocument(mDocument, PR_FALSE, PR_TRUE); if (aNotify && mDocument) { mDocument->ContentReplaced(NS_STATIC_CAST(nsIStyledContent*, this), oldKid, aKid, aIndex); @@ -2676,7 +2678,7 @@ nsXULElement::ReplaceChildAt(nsIContent* aKid, PRInt32 aIndex, PRBool aNotify) // This will cause the script object to be unrooted for each // element in the subtree. - oldKid->SetDocument(nsnull, PR_TRUE); + oldKid->SetDocument(nsnull, PR_TRUE, PR_TRUE); // We've got no mo' parent. oldKid->SetParent(nsnull); @@ -2704,7 +2706,7 @@ nsXULElement::AppendChildTo(nsIContent* aKid, PRBool aNotify) // ranges don't need adjustment since new child is at end of list // N.B. that this is only "shallow". Callers beware! - aKid->SetDocument(mDocument, PR_FALSE); + aKid->SetDocument(mDocument, PR_FALSE, PR_TRUE); if (aNotify && mDocument) { PRUint32 cnt; @@ -2813,7 +2815,7 @@ nsXULElement::RemoveChildAt(PRInt32 aIndex, PRBool aNotify) // This will cause the script object to be unrooted for each // element in the subtree. - oldKid->SetDocument(nsnull, PR_TRUE); + oldKid->SetDocument(nsnull, PR_TRUE, PR_TRUE); // We've got no mo' parent. oldKid->SetParent(nsnull); diff --git a/mozilla/content/xul/content/src/nsXULElement.h b/mozilla/content/xul/content/src/nsXULElement.h index bfe93a92298..8251da950ae 100644 --- a/mozilla/content/xul/content/src/nsXULElement.h +++ b/mozilla/content/xul/content/src/nsXULElement.h @@ -376,7 +376,7 @@ public: // nsIContent (from nsIStyledContent) NS_IMETHOD GetDocument(nsIDocument*& aResult) const; - NS_IMETHOD SetDocument(nsIDocument* aDocument, PRBool aDeep); + NS_IMETHOD SetDocument(nsIDocument* aDocument, PRBool aDeep, PRBool aCompileEventHandlers); NS_IMETHOD GetParent(nsIContent*& aResult) const; NS_IMETHOD SetParent(nsIContent* aParent); NS_IMETHOD CanContainChildren(PRBool& aResult) const; @@ -449,7 +449,7 @@ public: NS_IMETHOD ForceElementToOwnResource(PRBool aForce); NS_IMETHOD InitTemplateRoot(nsIRDFCompositeDataSource* aDatabase, nsIXULTemplateBuilder* aBuilder); - + // nsIDOMNode (from nsIDOMElement) NS_DECL_IDOMNODE diff --git a/mozilla/content/xul/document/src/nsXULDocument.cpp b/mozilla/content/xul/document/src/nsXULDocument.cpp index d1d411d6454..5b213332c0b 100644 --- a/mozilla/content/xul/document/src/nsXULDocument.cpp +++ b/mozilla/content/xul/document/src/nsXULDocument.cpp @@ -1016,11 +1016,11 @@ void nsXULDocument::SetRootContent(nsIContent* aRoot) { if (mRootContent) { - mRootContent->SetDocument(nsnull, PR_TRUE); + mRootContent->SetDocument(nsnull, PR_TRUE, PR_TRUE); } mRootContent = aRoot; if (mRootContent) { - mRootContent->SetDocument(this, PR_TRUE); + mRootContent->SetDocument(this, PR_TRUE, PR_TRUE); } } @@ -1299,7 +1299,7 @@ nsXULDocument::SetScriptGlobalObject(nsIScriptGlobalObject* aScriptGlobalObject) // that the content elements can remove references to their // script objects. if (mRootContent) - mRootContent->SetDocument(nsnull, PR_TRUE); + mRootContent->SetDocument(nsnull, PR_TRUE, PR_TRUE); // Break circular reference for the case where the currently // focused window is ourself. @@ -2157,7 +2157,7 @@ nsXULDocument::SetForm(nsIDOMHTMLFormElement* aForm) // Set the document. nsCOMPtr formContent = do_QueryInterface(aForm); - formContent->SetDocument(this, PR_TRUE); + formContent->SetDocument(this, PR_TRUE, PR_TRUE); // Forms are containers, and as such take up a bit of space. // Set a style attribute to keep the hidden form from showing up. @@ -5357,7 +5357,7 @@ nsXULDocument::CreateElement(nsXULPrototypeElement* aPrototype, nsIContent** aRe if (! result) return NS_ERROR_UNEXPECTED; - rv = result->SetDocument(this, PR_FALSE); + rv = result->SetDocument(this, PR_FALSE, PR_TRUE); if (NS_FAILED(rv)) return rv; rv = AddAttributes(aPrototype, result); @@ -5394,7 +5394,7 @@ nsXULDocument::CreateElement(nsXULPrototypeElement* aPrototype, nsIContent** aRe if (! result) return NS_ERROR_UNEXPECTED; - rv = result->SetDocument(this, PR_FALSE); + rv = result->SetDocument(this, PR_FALSE, PR_TRUE); if (NS_FAILED(rv)) return rv; rv = AddAttributes(aPrototype, result); @@ -6131,7 +6131,7 @@ nsXULDocument::InsertElement(nsIContent* aParent, nsIContent* aChild) NS_ASSERTION(doc != nsnull, "merging into null document"); - rv = aChild->SetDocument(doc, PR_TRUE); + rv = aChild->SetDocument(doc, PR_TRUE, PR_TRUE); if (NS_FAILED(rv)) return rv; return NS_OK; diff --git a/mozilla/content/xul/templates/src/nsXULSortService.cpp b/mozilla/content/xul/templates/src/nsXULSortService.cpp index 56c769813ac..19973a4e379 100644 --- a/mozilla/content/xul/templates/src/nsXULSortService.cpp +++ b/mozilla/content/xul/templates/src/nsXULSortService.cpp @@ -1856,7 +1856,7 @@ XULSortServiceImpl::SortTreeChildren(nsIContent *container, sortPtr sortInfo) // Because InsertChildAt() only does a // "shallow" SetDocument(), we need to do a // "deep" one now... - kid->SetDocument(doc, PR_TRUE); + kid->SetDocument(doc, PR_TRUE, PR_TRUE); container->InsertChildAt(kid, childPos++, PR_FALSE); @@ -2371,7 +2371,7 @@ XULSortServiceImpl::DoSort(nsIDOMNode* node, const nsString& sortResource, // only does a shallow one. nsCOMPtr doc; treeParent->GetDocument(*getter_AddRefs(doc)); - treeBody->SetDocument(doc, PR_TRUE); + treeBody->SetDocument(doc, PR_TRUE, PR_TRUE); if (NS_FAILED(rv = treeParent->AppendChildTo(treeBody, PR_TRUE))) return(rv); diff --git a/mozilla/content/xul/templates/src/nsXULTemplateBuilder.cpp b/mozilla/content/xul/templates/src/nsXULTemplateBuilder.cpp index c0136b10d56..a8bb325858f 100644 --- a/mozilla/content/xul/templates/src/nsXULTemplateBuilder.cpp +++ b/mozilla/content/xul/templates/src/nsXULTemplateBuilder.cpp @@ -5540,7 +5540,7 @@ nsXULTemplateBuilder::RemoveMember(nsIContent* aContainerElement, // Set its document to null so that it'll get knocked out of // the XUL doc's resource-to-element map. - rv = child->SetDocument(nsnull, PR_TRUE); + rv = child->SetDocument(nsnull, PR_TRUE, PR_TRUE); if (NS_FAILED(rv)) return rv; // Remove from the content support map. @@ -5969,7 +5969,7 @@ nsXULTemplateBuilder::RemoveGeneratedContent(nsIContent* aElement) rv = aElement->RemoveChildAt(count, PR_TRUE); NS_ASSERTION(NS_SUCCEEDED(rv), "error removing child"); - rv = child->SetDocument(nsnull, PR_TRUE); + rv = child->SetDocument(nsnull, PR_TRUE, PR_TRUE); if (NS_FAILED(rv)) return rv; // Remove this and any children from the content support map. @@ -6168,7 +6168,7 @@ nsXULTemplateBuilder::CreateElement(PRInt32 aNameSpaceID, formControl->SetForm(form); } - rv = result->SetDocument(doc, PR_FALSE); + rv = result->SetDocument(doc, PR_FALSE, PR_TRUE); NS_ASSERTION(NS_SUCCEEDED(rv), "unable to set element's document"); if (NS_FAILED(rv)) return rv; diff --git a/mozilla/docshell/base/nsDocShell.cpp b/mozilla/docshell/base/nsDocShell.cpp index 186453d70c1..fe0dbede237 100644 --- a/mozilla/docshell/base/nsDocShell.cpp +++ b/mozilla/docshell/base/nsDocShell.cpp @@ -301,7 +301,7 @@ nsDocShell::SetDocument(nsIDOMDocument *aDOMDoc, nsIDOMElement *aRootNode) // (5) hook up the document and its content nsCOMPtr rootContent = do_QueryInterface(aRootNode); NS_ENSURE_TRUE(doc, NS_ERROR_OUT_OF_MEMORY); - NS_ENSURE_SUCCESS(rootContent->SetDocument(doc, PR_FALSE), NS_ERROR_FAILURE); + NS_ENSURE_SUCCESS(rootContent->SetDocument(doc, PR_FALSE, PR_TRUE), NS_ERROR_FAILURE); doc->SetRootContent(rootContent); // (6) reflow the document diff --git a/mozilla/docshell/base/nsWebShell.cpp b/mozilla/docshell/base/nsWebShell.cpp index 2961d5faacf..4ccf8bf6e4c 100644 --- a/mozilla/docshell/base/nsWebShell.cpp +++ b/mozilla/docshell/base/nsWebShell.cpp @@ -1683,9 +1683,9 @@ NS_IMETHODIMP nsWebShell::SetDocument(nsIDOMDocument *aDOMDoc, // (5) hook up the document and its content nsCOMPtr rootContent = do_QueryInterface(aRootNode); if (!doc) { return NS_ERROR_OUT_OF_MEMORY; } - NS_ENSURE_SUCCESS(rootContent->SetDocument(doc, PR_FALSE), NS_ERROR_FAILURE); + NS_ENSURE_SUCCESS(rootContent->SetDocument(doc, PR_FALSE, PR_TRUE), NS_ERROR_FAILURE); doc->SetRootContent(rootContent); - rootContent->SetDocument(doc, PR_TRUE); + rootContent->SetDocument(doc, PR_TRUE, PR_TRUE); // (6) reflow the document PRInt32 i; diff --git a/mozilla/intl/strres/src/nsStringBundle.cpp b/mozilla/intl/strres/src/nsStringBundle.cpp index 6fd477eac34..c3eb56f719f 100644 --- a/mozilla/intl/strres/src/nsStringBundle.cpp +++ b/mozilla/intl/strres/src/nsStringBundle.cpp @@ -142,6 +142,8 @@ nsStringBundle::GetStringFromID(PRInt32 aID, nsString& aResult) nsresult nsStringBundle::GetStringFromName(const nsString& aName, nsString& aResult) { + if (!mProps) + return NS_OK; NS_ENSURE_TRUE(mProps, NS_ERROR_FAILURE); nsresult ret = mProps->GetStringProperty(aName, aResult); #ifdef DEBUG_tao_ diff --git a/mozilla/layout/base/nsCSSFrameConstructor.cpp b/mozilla/layout/base/nsCSSFrameConstructor.cpp index 3db76f13900..6e1c6f63d76 100644 --- a/mozilla/layout/base/nsCSSFrameConstructor.cpp +++ b/mozilla/layout/base/nsCSSFrameConstructor.cpp @@ -1129,7 +1129,7 @@ nsCSSFrameConstructor::CreateGeneratedFrameFor(nsIPresContext* aPresContex // Set aContent as the parent content and set the document object. This // way event handling works imageContent->SetParent(aContent); - imageContent->SetDocument(aDocument, PR_TRUE); + imageContent->SetDocument(aDocument, PR_TRUE, PR_TRUE); // Create an image frame and initialize it nsIFrame* imageFrame; @@ -1180,7 +1180,7 @@ nsCSSFrameConstructor::CreateGeneratedFrameFor(nsIPresContext* aPresContex // Set aContent as the parent content and set the document object. This // way event handling works content->SetParent(aContent); - content->SetDocument(aDocument, PR_TRUE); + content->SetDocument(aDocument, PR_TRUE, PR_TRUE); // Create a text frame and initialize it NS_NewTextFrame(shell, &textFrame); @@ -1250,7 +1250,7 @@ nsCSSFrameConstructor::CreateGeneratedFrameFor(nsIPresContext* aPresContex // Set aContent as the parent content and set the document object. This // way event handling works textContent->SetParent(aContent); - textContent->SetDocument(aDocument, PR_TRUE); + textContent->SetDocument(aDocument, PR_TRUE, PR_TRUE); // Create a text frame and initialize it NS_NewTextFrame(shell, &textFrame); @@ -5237,7 +5237,7 @@ nsCSSFrameConstructor::CreateAnonymousFrames(nsIPresShell* aPresShell, nsCOMPtr content(do_QueryInterface(node)); content->SetParent(aParent); - content->SetDocument(aDocument, PR_TRUE); + content->SetDocument(aDocument, PR_TRUE, PR_TRUE); nsIFrame * newFrame = nsnull; nsresult rv = creator->CreateFrameFor(aPresContext, content, &newFrame); @@ -9784,7 +9784,7 @@ nsCSSFrameConstructor::ConstructAlternateImageFrame(nsIPresShell* aPresShell, nsCOMPtr document; aContent->GetDocument(*getter_AddRefs(document)); altTextContent->SetParent(aContent); - altTextContent->SetDocument(document, PR_TRUE); + altTextContent->SetDocument(document, PR_TRUE, PR_TRUE); // Create either an inline frame, block frame, or area frame nsIFrame* containerFrame; diff --git a/mozilla/layout/base/public/nsIContent.h b/mozilla/layout/base/public/nsIContent.h index a9ed5dd8f7a..f59fdfcdd47 100644 --- a/mozilla/layout/base/public/nsIContent.h +++ b/mozilla/layout/base/public/nsIContent.h @@ -55,7 +55,7 @@ public: NS_IMETHOD GetDocument(nsIDocument*& aResult) const = 0; - NS_IMETHOD SetDocument(nsIDocument* aDocument, PRBool aDeep) = 0; + NS_IMETHOD SetDocument(nsIDocument* aDocument, PRBool aDeep, PRBool aCompileEventHandlers) = 0; NS_IMETHOD GetParent(nsIContent*& aResult) const = 0; diff --git a/mozilla/layout/base/src/nsCommentNode.cpp b/mozilla/layout/base/src/nsCommentNode.cpp index 865afbb3115..662ef929597 100644 --- a/mozilla/layout/base/src/nsCommentNode.cpp +++ b/mozilla/layout/base/src/nsCommentNode.cpp @@ -65,8 +65,8 @@ public: NS_IMETHOD GetDocument(nsIDocument*& aResult) const { return mInner.GetDocument(aResult); } - NS_IMETHOD SetDocument(nsIDocument* aDocument, PRBool aDeep) { - return mInner.SetDocument(aDocument, aDeep); + NS_IMETHOD SetDocument(nsIDocument* aDocument, PRBool aDeep, PRBool aCompileEventHandlers) { + return mInner.SetDocument(aDocument, aDeep, aCompileEventHandlers); } NS_IMETHOD GetParent(nsIContent*& aResult) const { return mInner.GetParent(aResult); diff --git a/mozilla/layout/base/src/nsDocument.cpp b/mozilla/layout/base/src/nsDocument.cpp index a4c4dbc9597..ee59bd93792 100644 --- a/mozilla/layout/base/src/nsDocument.cpp +++ b/mozilla/layout/base/src/nsDocument.cpp @@ -816,7 +816,7 @@ nsDocument::Reset(nsIChannel* aChannel, nsILoadGroup* aLoadGroup) if (nsnull != mRootContent) { // Ensure that document is nsnull to allow validity checks on content - mRootContent->SetDocument(nsnull, PR_TRUE); + mRootContent->SetDocument(nsnull, PR_TRUE, PR_TRUE); ContentRemoved(nsnull, mRootContent, 0); NS_IF_RELEASE(mRootContent); } @@ -1477,7 +1477,7 @@ nsDocument::SetScriptGlobalObject(nsIScriptGlobalObject *aScriptGlobalObject) // actually set the script context owner to null so that the // content elements can remove references to their script objects. if ((nsnull == aScriptGlobalObject) && (nsnull != mRootContent)) { - mRootContent->SetDocument(nsnull, PR_TRUE); + mRootContent->SetDocument(nsnull, PR_TRUE, PR_TRUE); } mScriptGlobalObject = aScriptGlobalObject; @@ -2444,7 +2444,7 @@ nsDocument::InsertBefore(nsIDOMNode* aNewChild, nsIDOMNode* aRefChild, nsIDOMNod } if (NS_OK == result) { - content->SetDocument(this, PR_TRUE); + content->SetDocument(this, PR_TRUE, PR_TRUE); *aReturn = aNewChild; NS_ADDREF(aNewChild); } @@ -2515,8 +2515,8 @@ nsDocument::ReplaceChild(nsIDOMNode* aNewChild, nsIDOMNode* aOldChild, nsIDOMNod } if (NS_OK == result) { - content->SetDocument(this, PR_TRUE); - refContent->SetDocument(nsnull, PR_TRUE); + content->SetDocument(this, PR_TRUE, PR_TRUE); + refContent->SetDocument(nsnull, PR_TRUE, PR_TRUE); *aReturn = aNewChild; NS_ADDREF(aNewChild); } @@ -2567,7 +2567,7 @@ nsDocument::RemoveChild(nsIDOMNode* aOldChild, nsIDOMNode** aReturn) } if (NS_OK == result) { - content->SetDocument(nsnull, PR_TRUE); + content->SetDocument(nsnull, PR_TRUE, PR_TRUE); *aReturn = aOldChild; } else { diff --git a/mozilla/layout/base/src/nsDocumentFragment.cpp b/mozilla/layout/base/src/nsDocumentFragment.cpp index 8e39b0f5216..874e5be003c 100644 --- a/mozilla/layout/base/src/nsDocumentFragment.cpp +++ b/mozilla/layout/base/src/nsDocumentFragment.cpp @@ -121,8 +121,8 @@ public: } NS_IMETHOD GetDocument(nsIDocument*& aResult) const { return mInner.GetDocument(aResult); } - NS_IMETHOD SetDocument(nsIDocument* aDocument, PRBool aDeep) - { return mInner.SetDocument(aDocument, aDeep); } + NS_IMETHOD SetDocument(nsIDocument* aDocument, PRBool aDeep, PRBool aCompileEventHandlers) + { return mInner.SetDocument(aDocument, aDeep, aCompileEventHandlers); } NS_IMETHOD GetParent(nsIContent*& aResult) const { aResult = nsnull; diff --git a/mozilla/layout/base/src/nsGenericDOMDataNode.cpp b/mozilla/layout/base/src/nsGenericDOMDataNode.cpp index cab355b678c..1851c7c0e2d 100644 --- a/mozilla/layout/base/src/nsGenericDOMDataNode.cpp +++ b/mozilla/layout/base/src/nsGenericDOMDataNode.cpp @@ -688,7 +688,7 @@ nsGenericDOMDataNode::GetDocument(nsIDocument*& aResult) const nsresult -nsGenericDOMDataNode::SetDocument(nsIDocument* aDocument, PRBool aDeep) +nsGenericDOMDataNode::SetDocument(nsIDocument* aDocument, PRBool aDeep, PRBool aCompileEventHandlers) { // If we were part of a document, make sure we get rid of the // script context reference to our script object so that our diff --git a/mozilla/layout/base/src/nsGenericDOMDataNode.h b/mozilla/layout/base/src/nsGenericDOMDataNode.h index 581f58a5a0c..ac4301a2d27 100644 --- a/mozilla/layout/base/src/nsGenericDOMDataNode.h +++ b/mozilla/layout/base/src/nsGenericDOMDataNode.h @@ -147,7 +147,7 @@ struct nsGenericDOMDataNode { // Implementation for nsIContent nsresult GetDocument(nsIDocument*& aResult) const; - nsresult SetDocument(nsIDocument* aDocument, PRBool aDeep); + nsresult SetDocument(nsIDocument* aDocument, PRBool aDeep, PRBool aCompileEventHandlers); nsresult GetParent(nsIContent*& aResult) const; nsresult SetParent(nsIContent* aParent); nsresult IsSynthetic(PRBool& aResult) { @@ -442,8 +442,8 @@ struct nsGenericDOMDataNode { NS_IMETHOD GetDocument(nsIDocument*& aResult) const { \ return _g.GetDocument(aResult); \ } \ - NS_IMETHOD SetDocument(nsIDocument* aDocument, PRBool aDeep) { \ - return _g.SetDocument(aDocument, aDeep); \ + NS_IMETHOD SetDocument(nsIDocument* aDocument, PRBool aDeep, PRBool aCompileEventHandlers) { \ + return _g.SetDocument(aDocument, aDeep, aCompileEventHandlers); \ } \ NS_IMETHOD GetParent(nsIContent*& aResult) const { \ return _g.GetParent(aResult); \ diff --git a/mozilla/layout/base/src/nsGenericElement.cpp b/mozilla/layout/base/src/nsGenericElement.cpp index aa8573e5685..932a02df8ab 100644 --- a/mozilla/layout/base/src/nsGenericElement.cpp +++ b/mozilla/layout/base/src/nsGenericElement.cpp @@ -1154,7 +1154,8 @@ nsGenericElement::GetDocument(nsIDocument*& aResult) const void nsGenericElement::SetDocumentInChildrenOf(nsIContent* aContent, - nsIDocument* aDocument) + nsIDocument* aDocument, + PRBool aCompileEventHandlers) { PRInt32 i, n; aContent->ChildCount(n); @@ -1162,14 +1163,14 @@ nsGenericElement::SetDocumentInChildrenOf(nsIContent* aContent, nsIContent* child; aContent->ChildAt(i, child); if (nsnull != child) { - child->SetDocument(aDocument, PR_TRUE); + child->SetDocument(aDocument, PR_TRUE, aCompileEventHandlers); NS_RELEASE(child); } } } nsresult -nsGenericElement::SetDocument(nsIDocument* aDocument, PRBool aDeep) +nsGenericElement::SetDocument(nsIDocument* aDocument, PRBool aDeep, PRBool aCompileEventHandlers) { if (aDocument != mDocument) { // If we were part of a document, make sure we get rid of the @@ -1226,7 +1227,7 @@ nsGenericElement::SetDocument(nsIDocument* aDocument, PRBool aDeep) } if (PR_TRUE == aDeep) { - SetDocumentInChildrenOf(mContent, aDocument); + SetDocumentInChildrenOf(mContent, aDocument, aCompileEventHandlers); } return NS_OK; @@ -1863,7 +1864,7 @@ nsGenericElement::doInsertBefore(nsIDOMNode* aNewChild, return res; } - childContent->SetDocument(mDocument, PR_TRUE); + childContent->SetDocument(mDocument, PR_TRUE, PR_TRUE); // Insert the child and increment the insertion position res = mContent->InsertChildAt(childContent, refPos++, PR_TRUE); @@ -1928,7 +1929,7 @@ nsGenericElement::doInsertBefore(nsIDOMNode* aNewChild, } } - newContent->SetDocument(mDocument, PR_TRUE); + newContent->SetDocument(mDocument, PR_TRUE, PR_TRUE); res = mContent->InsertChildAt(newContent, refPos, PR_TRUE); @@ -2056,7 +2057,7 @@ nsGenericElement::doReplaceChild(nsIDOMNode* aNewChild, return res; } - childContent->SetDocument(document, PR_TRUE); + childContent->SetDocument(document, PR_TRUE, PR_TRUE); // Insert the child and increment the insertion position if (i) { @@ -2117,7 +2118,7 @@ nsGenericElement::doReplaceChild(nsIDOMNode* aNewChild, } } - newContent->SetDocument(document, PR_TRUE); + newContent->SetDocument(document, PR_TRUE, PR_TRUE); res = mContent->ReplaceChildAt(newContent, oldPos, PR_TRUE); @@ -2817,7 +2818,7 @@ nsGenericContainerElement::InsertChildAt(nsIContent* aKid, aKid->SetParent(mContent); nsRange::OwnerChildInserted(mContent, aIndex); if (nsnull != doc) { - aKid->SetDocument(doc, PR_FALSE); + aKid->SetDocument(doc, PR_FALSE, PR_TRUE); if (aNotify) { doc->ContentInserted(mContent, aKid, aIndex); } @@ -2846,12 +2847,12 @@ nsGenericContainerElement::ReplaceChildAt(nsIContent* aKid, NS_ADDREF(aKid); aKid->SetParent(mContent); if (nsnull != doc) { - aKid->SetDocument(doc, PR_FALSE); + aKid->SetDocument(doc, PR_FALSE, PR_TRUE); if (aNotify) { doc->ContentReplaced(mContent, oldKid, aKid, aIndex); } } - oldKid->SetDocument(nsnull, PR_TRUE); + oldKid->SetDocument(nsnull, PR_TRUE, PR_TRUE); oldKid->SetParent(nsnull); NS_RELEASE(oldKid); } @@ -2875,7 +2876,7 @@ nsGenericContainerElement::AppendChildTo(nsIContent* aKid, PRBool aNotify) aKid->SetParent(mContent); // ranges don't need adjustment since new child is at end of list if (nsnull != doc) { - aKid->SetDocument(doc, PR_FALSE); + aKid->SetDocument(doc, PR_FALSE, PR_TRUE); if (aNotify) { doc->ContentAppended(mContent, mChildren.Count() - 1); } @@ -2903,7 +2904,7 @@ nsGenericContainerElement::RemoveChildAt(PRInt32 aIndex, PRBool aNotify) doc->ContentRemoved(mContent, oldKid, aIndex); } } - oldKid->SetDocument(nsnull, PR_TRUE); + oldKid->SetDocument(nsnull, PR_TRUE, PR_TRUE); oldKid->SetParent(nsnull); NS_RELEASE(oldKid); if (aNotify && (nsnull != doc)) { diff --git a/mozilla/layout/base/src/nsGenericElement.h b/mozilla/layout/base/src/nsGenericElement.h index d2173d8764e..d6e192a1608 100644 --- a/mozilla/layout/base/src/nsGenericElement.h +++ b/mozilla/layout/base/src/nsGenericElement.h @@ -179,7 +179,7 @@ public: // Implementation for nsIContent nsresult GetDocument(nsIDocument*& aResult) const; - nsresult SetDocument(nsIDocument* aDocument, PRBool aDeep); + nsresult SetDocument(nsIDocument* aDocument, PRBool aDeep, PRBool aCompileEventHandlers); nsresult GetParent(nsIContent*& aResult) const; nsresult SetParent(nsIContent* aParent); nsresult IsSynthetic(PRBool& aResult) { @@ -260,7 +260,7 @@ public: nsIContent* aSecond); static void SetDocumentInChildrenOf(nsIContent* aContent, - nsIDocument* aDocument); + nsIDocument* aDocument, PRBool aCompileEventHandlers); static nsresult GetScriptObjectFactory(nsIDOMScriptObjectFactory **aFactory); @@ -557,8 +557,8 @@ public: NS_IMETHOD GetDocument(nsIDocument*& aResult) const { \ return _g.GetDocument(aResult); \ } \ - NS_IMETHOD SetDocument(nsIDocument* aDocument, PRBool aDeep) { \ - return _g.SetDocument(aDocument, aDeep); \ + NS_IMETHOD SetDocument(nsIDocument* aDocument, PRBool aDeep, PRBool aCompileEventHandlers) { \ + return _g.SetDocument(aDocument, aDeep, aCompileEventHandlers); \ } \ NS_IMETHOD GetParent(nsIContent*& aResult) const { \ return _g.GetParent(aResult); \ @@ -686,8 +686,8 @@ public: NS_IMETHOD GetDocument(nsIDocument*& aResult) const { \ return _g.GetDocument(aResult); \ } \ - NS_IMETHOD SetDocument(nsIDocument* aDocument, PRBool aDeep) { \ - return _g.SetDocument(aDocument, aDeep); \ + NS_IMETHOD SetDocument(nsIDocument* aDocument, PRBool aDeep, PRBool aCompileEventHandlers) { \ + return _g.SetDocument(aDocument, aDeep, aCompileEventHandlers); \ } \ NS_IMETHOD GetParent(nsIContent*& aResult) const { \ return _g.GetParent(aResult); \ @@ -813,7 +813,7 @@ public: NS_IMETHOD GetDocument(nsIDocument*& aResult) const { \ return _g.GetDocument(aResult); \ } \ - NS_IMETHOD SetDocument(nsIDocument* aDocument, PRBool aDeep); \ + NS_IMETHOD SetDocument(nsIDocument* aDocument, PRBool aDeep, PRBool aCompileEventHandlers); \ NS_IMETHOD GetParent(nsIContent*& aResult) const { \ return _g.GetParent(aResult); \ } \ @@ -940,7 +940,7 @@ public: NS_IMETHOD GetDocument(nsIDocument*& aResult) const { \ return _g.GetDocument(aResult); \ } \ - NS_IMETHOD SetDocument(nsIDocument* aDocument, PRBool aDeep); \ + NS_IMETHOD SetDocument(nsIDocument* aDocument, PRBool aDeep, PRBool aCompileEventHandlers); \ NS_IMETHOD GetParent(nsIContent*& aResult) const { \ return _g.GetParent(aResult); \ } \ @@ -1065,8 +1065,8 @@ public: NS_IMETHOD GetDocument(nsIDocument*& aResult) const { \ return _g.GetDocument(aResult); \ } \ - NS_IMETHOD SetDocument(nsIDocument* aDocument, PRBool aDeep) { \ - return _g.SetDocument(aDocument, aDeep); \ + NS_IMETHOD SetDocument(nsIDocument* aDocument, PRBool aDeep, PRBool aCompileEventHandlers) { \ + return _g.SetDocument(aDocument, aDeep, aCompileEventHandlers); \ } \ NS_IMETHOD GetParent(nsIContent*& aResult) const { \ return _g.GetParent(aResult); \ @@ -1190,7 +1190,7 @@ public: NS_IMETHOD GetDocument(nsIDocument*& aResult) const { \ return _g.GetDocument(aResult); \ } \ - NS_IMETHOD SetDocument(nsIDocument* aDocument, PRBool aDeep); \ + NS_IMETHOD SetDocument(nsIDocument* aDocument, PRBool aDeep, PRBool aCompileEventHandlers); \ NS_IMETHOD GetParent(nsIContent*& aResult) const { \ return _g.GetParent(aResult); \ } \ diff --git a/mozilla/layout/forms/nsComboboxControlFrame.cpp b/mozilla/layout/forms/nsComboboxControlFrame.cpp index 76849fe393b..9695d574773 100644 --- a/mozilla/layout/forms/nsComboboxControlFrame.cpp +++ b/mozilla/layout/forms/nsComboboxControlFrame.cpp @@ -2165,7 +2165,7 @@ nsComboboxControlFrame::CreateAnonymousContent(nsIPresContext* aPresContext, nsCOMPtr doc; mContent->GetDocument(*getter_AddRefs(doc)); /* - labelContent->SetDocument(doc, PR_FALSE); + labelContent->SetDocument(doc, PR_FALSE, PR_TRUE); mContent->AppendChildTo(labelContent, PR_FALSE); */ diff --git a/mozilla/layout/html/content/src/nsAttributeContent.cpp b/mozilla/layout/html/content/src/nsAttributeContent.cpp index 0ed92723ad9..991850db536 100644 --- a/mozilla/layout/html/content/src/nsAttributeContent.cpp +++ b/mozilla/layout/html/content/src/nsAttributeContent.cpp @@ -88,7 +88,7 @@ public: // Implementation for nsIContent NS_IMETHOD GetDocument(nsIDocument*& aResult) const; - NS_IMETHOD SetDocument(nsIDocument* aDocument, PRBool aDeep); + NS_IMETHOD SetDocument(nsIDocument* aDocument, PRBool aDeep, PRBool aCompileEventHandlers); NS_IMETHOD GetParent(nsIContent*& aResult) const; NS_IMETHOD SetParent(nsIContent* aParent); @@ -359,7 +359,7 @@ nsAttributeContent::GetDocument(nsIDocument*& aResult) const nsresult -nsAttributeContent::SetDocument(nsIDocument* aDocument, PRBool aDeep) +nsAttributeContent::SetDocument(nsIDocument* aDocument, PRBool aDeep, PRBool aCompileEventHandlers) { mDocument = aDocument; //NS_IF_ADDREF(mDocument); diff --git a/mozilla/layout/html/content/src/nsGenericHTMLElement.cpp b/mozilla/layout/html/content/src/nsGenericHTMLElement.cpp index 95f5489c261..8497346aac0 100644 --- a/mozilla/layout/html/content/src/nsGenericHTMLElement.cpp +++ b/mozilla/layout/html/content/src/nsGenericHTMLElement.cpp @@ -915,14 +915,14 @@ nsGenericHTMLElement::InNavQuirksMode(nsIDocument* aDoc) } nsresult -nsGenericHTMLElement::SetDocument(nsIDocument* aDocument, PRBool aDeep) +nsGenericHTMLElement::SetDocument(nsIDocument* aDocument, PRBool aDeep, PRBool aCompileEventHandlers) { PRBool doNothing = PR_FALSE; if (aDocument == mDocument) { doNothing = PR_TRUE; // short circuit useless work } - nsresult result = nsGenericElement::SetDocument(aDocument, aDeep); + nsresult result = nsGenericElement::SetDocument(aDocument, aDeep, aCompileEventHandlers); if (NS_OK != result) { return result; } @@ -1022,6 +1022,7 @@ nsGenericHTMLElement::SetParentForFormControls(nsIContent* aParent, nsresult nsGenericHTMLElement::SetDocumentForFormControls(nsIDocument* aDocument, PRBool aDeep, + PRBool aCompileEventHandlers, nsIFormControl* aControl, nsIForm* aForm) { @@ -1038,7 +1039,7 @@ nsGenericHTMLElement::SetDocumentForFormControls(nsIDocument* aDocument, } if (NS_SUCCEEDED(result)) { - result = SetDocument(aDocument, aDeep); + result = SetDocument(aDocument, aDeep, aCompileEventHandlers); } return result; @@ -3343,7 +3344,7 @@ nsGenericHTMLContainerElement::InsertChildAt(nsIContent* aKid, aKid->SetParent(mContent); nsRange::OwnerChildInserted(mContent, aIndex); if (nsnull != doc) { - aKid->SetDocument(doc, PR_FALSE); + aKid->SetDocument(doc, PR_FALSE, PR_TRUE); if (aNotify) { doc->ContentInserted(mContent, aKid, aIndex); } @@ -3372,12 +3373,12 @@ nsGenericHTMLContainerElement::ReplaceChildAt(nsIContent* aKid, NS_ADDREF(aKid); aKid->SetParent(mContent); if (nsnull != doc) { - aKid->SetDocument(doc, PR_FALSE); + aKid->SetDocument(doc, PR_FALSE, PR_TRUE); if (aNotify) { doc->ContentReplaced(mContent, oldKid, aKid, aIndex); } } - oldKid->SetDocument(nsnull, PR_TRUE); + oldKid->SetDocument(nsnull, PR_TRUE, PR_TRUE); oldKid->SetParent(nsnull); NS_RELEASE(oldKid); } @@ -3401,7 +3402,7 @@ nsGenericHTMLContainerElement::AppendChildTo(nsIContent* aKid, PRBool aNotify) aKid->SetParent(mContent); // ranges don't need adjustment since new child is at end of list if (nsnull != doc) { - aKid->SetDocument(doc, PR_FALSE); + aKid->SetDocument(doc, PR_FALSE, PR_TRUE); if (aNotify) { doc->ContentAppended(mContent, mChildren.Count() - 1); } @@ -3429,7 +3430,7 @@ nsGenericHTMLContainerElement::RemoveChildAt(PRInt32 aIndex, PRBool aNotify) doc->ContentRemoved(mContent, oldKid, aIndex); } } - oldKid->SetDocument(nsnull, PR_TRUE); + oldKid->SetDocument(nsnull, PR_TRUE, PR_TRUE); oldKid->SetParent(nsnull); NS_RELEASE(oldKid); } diff --git a/mozilla/layout/html/content/src/nsGenericHTMLElement.h b/mozilla/layout/html/content/src/nsGenericHTMLElement.h index a7806cca332..b69799fde1a 100644 --- a/mozilla/layout/html/content/src/nsGenericHTMLElement.h +++ b/mozilla/layout/html/content/src/nsGenericHTMLElement.h @@ -107,7 +107,7 @@ public: // Implementation for nsIContent nsresult GetNameSpaceID(PRInt32& aNameSpaceID) const; - nsresult SetDocument(nsIDocument* aDocument, PRBool aDeep); + nsresult SetDocument(nsIDocument* aDocument, PRBool aDeep, PRBool aCompileEventHandlers); nsresult ParseAttributeString(const nsString& aStr, nsIAtom*& aName, PRInt32& aNameSpaceID); @@ -131,6 +131,7 @@ public: nsIForm* aForm); nsresult SetDocumentForFormControls(nsIDocument* aDocument, PRBool aDeep, + PRBool aCompileEventHandlers, nsIFormControl* aControl, nsIForm* aForm); nsresult HandleDOMEventForAnchors(nsIPresContext* aPresContext, diff --git a/mozilla/layout/html/content/src/nsHTMLAnchorElement.cpp b/mozilla/layout/html/content/src/nsHTMLAnchorElement.cpp index dbc220450f2..82cb7f10599 100644 --- a/mozilla/layout/html/content/src/nsHTMLAnchorElement.cpp +++ b/mozilla/layout/html/content/src/nsHTMLAnchorElement.cpp @@ -233,7 +233,7 @@ nsresult nsHTMLAnchorElement::RegUnRegAccessKey(PRBool aDoReg) } NS_IMETHODIMP -nsHTMLAnchorElement::SetDocument(nsIDocument* aDocument, PRBool aDeep) +nsHTMLAnchorElement::SetDocument(nsIDocument* aDocument, PRBool aDeep, PRBool aCompileEventHandlers) { // The document gets set to null before it is destroyed, // so we unregister the the access key here (if it has one) @@ -242,7 +242,7 @@ nsHTMLAnchorElement::SetDocument(nsIDocument* aDocument, PRBool aDeep) RegUnRegAccessKey(PR_FALSE); } - nsresult res = mInner.SetDocument(aDocument, aDeep); + nsresult res = mInner.SetDocument(aDocument, aDeep, aCompileEventHandlers); // Register the access key here (if it has one) // if the document isn't null diff --git a/mozilla/layout/html/content/src/nsHTMLBodyElement.cpp b/mozilla/layout/html/content/src/nsHTMLBodyElement.cpp index 994dd2150a0..a2c3e8a56fd 100644 --- a/mozilla/layout/html/content/src/nsHTMLBodyElement.cpp +++ b/mozilla/layout/html/content/src/nsHTMLBodyElement.cpp @@ -125,7 +125,7 @@ public: nsBodyInner(); virtual ~nsBodyInner(); - nsresult SetDocument(nsIDocument* aDocument, PRBool aDeep); + nsresult SetDocument(nsIDocument* aDocument, PRBool aDeep, PRBool aCompileEventHandlers); BodyRule* mContentStyleRule; BodyFixupRule* mInlineStyleRule; @@ -153,7 +153,7 @@ nsBodyInner::~nsBodyInner() } } -nsresult nsBodyInner::SetDocument(nsIDocument* aDocument, PRBool aDeep) +nsresult nsBodyInner::SetDocument(nsIDocument* aDocument, PRBool aDeep, PRBool aCompileEventHandlers) { if (nsnull != mContentStyleRule) { mContentStyleRule->mPart = nsnull; @@ -165,7 +165,7 @@ nsresult nsBodyInner::SetDocument(nsIDocument* aDocument, PRBool aDeep) mInlineStyleRule->mSheet = nsnull; NS_RELEASE(mInlineStyleRule); // destroy old style rule since the sheet will probably change } - return nsGenericHTMLContainerElement::SetDocument(aDocument, aDeep); + return nsGenericHTMLContainerElement::SetDocument(aDocument, aDeep, aCompileEventHandlers); } //---------------------------------------------------------------------- diff --git a/mozilla/layout/html/content/src/nsHTMLButtonElement.cpp b/mozilla/layout/html/content/src/nsHTMLButtonElement.cpp index cd169201567..3e0cd3d1bc9 100644 --- a/mozilla/layout/html/content/src/nsHTMLButtonElement.cpp +++ b/mozilla/layout/html/content/src/nsHTMLButtonElement.cpp @@ -283,9 +283,9 @@ nsHTMLButtonElement::SetParent(nsIContent* aParent) } NS_IMETHODIMP -nsHTMLButtonElement::SetDocument(nsIDocument* aDocument, PRBool aDeep) +nsHTMLButtonElement::SetDocument(nsIDocument* aDocument, PRBool aDeep, PRBool aCompileEventHandlers) { - return mInner.SetDocumentForFormControls(aDocument, aDeep, this, mForm); + return mInner.SetDocumentForFormControls(aDocument, aDeep, aCompileEventHandlers, this, mForm); } NS_IMETHODIMP diff --git a/mozilla/layout/html/content/src/nsHTMLFieldSetElement.cpp b/mozilla/layout/html/content/src/nsHTMLFieldSetElement.cpp index a37840b8287..a07bba83c96 100644 --- a/mozilla/layout/html/content/src/nsHTMLFieldSetElement.cpp +++ b/mozilla/layout/html/content/src/nsHTMLFieldSetElement.cpp @@ -176,9 +176,9 @@ nsHTMLFieldSetElement::SetParent(nsIContent* aParent) } NS_IMETHODIMP -nsHTMLFieldSetElement::SetDocument(nsIDocument* aDocument, PRBool aDeep) +nsHTMLFieldSetElement::SetDocument(nsIDocument* aDocument, PRBool aDeep, PRBool aCompileEventHandlers) { - return mInner.SetDocumentForFormControls(aDocument, aDeep, this, mForm); + return mInner.SetDocumentForFormControls(aDocument, aDeep, aCompileEventHandlers, this, mForm); } NS_IMETHODIMP diff --git a/mozilla/layout/html/content/src/nsHTMLImageElement.cpp b/mozilla/layout/html/content/src/nsHTMLImageElement.cpp index 160ad1c483f..143a892fe36 100644 --- a/mozilla/layout/html/content/src/nsHTMLImageElement.cpp +++ b/mozilla/layout/html/content/src/nsHTMLImageElement.cpp @@ -702,13 +702,13 @@ nsHTMLImageElement::Initialize(JSContext* aContext, NS_IMETHODIMP nsHTMLImageElement::SetDocument(nsIDocument* aDocument, - PRBool aDeep) + PRBool aDeep, PRBool aCompileEventHandlers) { // If we've been added to the document, we can get rid of // our owner document reference so as to avoid a circular // reference. NS_IF_RELEASE(mOwnerDocument); - return mInner.SetDocument(aDocument, aDeep); + return mInner.SetDocument(aDocument, aDeep, aCompileEventHandlers); } NS_IMETHODIMP diff --git a/mozilla/layout/html/content/src/nsHTMLInputElement.cpp b/mozilla/layout/html/content/src/nsHTMLInputElement.cpp index b649646d5dc..7a37ea1f362 100644 --- a/mozilla/layout/html/content/src/nsHTMLInputElement.cpp +++ b/mozilla/layout/html/content/src/nsHTMLInputElement.cpp @@ -306,9 +306,9 @@ nsHTMLInputElement::SetParent(nsIContent* aParent) } NS_IMETHODIMP -nsHTMLInputElement::SetDocument(nsIDocument* aDocument, PRBool aDeep) +nsHTMLInputElement::SetDocument(nsIDocument* aDocument, PRBool aDeep, PRBool aCompileEventHandlers) { - return mInner.SetDocumentForFormControls(aDocument, aDeep, this, mForm); + return mInner.SetDocumentForFormControls(aDocument, aDeep, aCompileEventHandlers, this, mForm); } NS_IMETHODIMP diff --git a/mozilla/layout/html/content/src/nsHTMLLabelElement.cpp b/mozilla/layout/html/content/src/nsHTMLLabelElement.cpp index 31a5f89f254..fbb588f6240 100644 --- a/mozilla/layout/html/content/src/nsHTMLLabelElement.cpp +++ b/mozilla/layout/html/content/src/nsHTMLLabelElement.cpp @@ -257,9 +257,9 @@ nsHTMLLabelElement::SetParent(nsIContent* aParent) } NS_IMETHODIMP -nsHTMLLabelElement::SetDocument(nsIDocument* aDocument, PRBool aDeep) +nsHTMLLabelElement::SetDocument(nsIDocument* aDocument, PRBool aDeep, PRBool aCompileEventHandlers) { - return mInner.SetDocumentForFormControls(aDocument, aDeep, this, mForm); + return mInner.SetDocumentForFormControls(aDocument, aDeep, aCompileEventHandlers, this, mForm); } NS_IMETHODIMP diff --git a/mozilla/layout/html/content/src/nsHTMLLegendElement.cpp b/mozilla/layout/html/content/src/nsHTMLLegendElement.cpp index 210489bd9f2..612ba35f5c8 100644 --- a/mozilla/layout/html/content/src/nsHTMLLegendElement.cpp +++ b/mozilla/layout/html/content/src/nsHTMLLegendElement.cpp @@ -158,9 +158,9 @@ nsHTMLLegendElement::SetParent(nsIContent* aParent) } NS_IMETHODIMP -nsHTMLLegendElement::SetDocument(nsIDocument* aDocument, PRBool aDeep) +nsHTMLLegendElement::SetDocument(nsIDocument* aDocument, PRBool aDeep, PRBool aCompileEventHandlers) { - return mInner.SetDocumentForFormControls(aDocument, aDeep, this, mForm); + return mInner.SetDocumentForFormControls(aDocument, aDeep, aCompileEventHandlers, this, mForm); } NS_IMETHODIMP diff --git a/mozilla/layout/html/content/src/nsHTMLMapElement.cpp b/mozilla/layout/html/content/src/nsHTMLMapElement.cpp index 567b0465ac8..a3bf793c61c 100644 --- a/mozilla/layout/html/content/src/nsHTMLMapElement.cpp +++ b/mozilla/layout/html/content/src/nsHTMLMapElement.cpp @@ -70,7 +70,7 @@ public: NS_IMETHOD GetDocument(nsIDocument*& aResult) const { return mInner.GetDocument(aResult); } - NS_IMETHOD SetDocument(nsIDocument* aDocument, PRBool aDeep); + NS_IMETHOD SetDocument(nsIDocument* aDocument, PRBool aDeep, PRBool aCompileEventHandlers); NS_IMETHOD GetParent(nsIContent*& aResult) const { return mInner.GetParent(aResult); } @@ -254,7 +254,7 @@ nsHTMLMapElement::QueryInterface(REFNSIID aIID, void** aInstancePtr) } NS_IMETHODIMP -nsHTMLMapElement::SetDocument(nsIDocument* aDocument, PRBool aDeep) +nsHTMLMapElement::SetDocument(nsIDocument* aDocument, PRBool aDeep, PRBool aCompileEventHandlers) { nsresult rv; @@ -268,7 +268,7 @@ nsHTMLMapElement::SetDocument(nsIDocument* aDocument, PRBool aDeep) } } - rv = mInner.SetDocument(aDocument, aDeep); + rv = mInner.SetDocument(aDocument, aDeep, aCompileEventHandlers); if (NS_SUCCEEDED(rv) && (nsnull != aDocument)) { nsCOMPtr htmlDoc; diff --git a/mozilla/layout/html/content/src/nsHTMLOptionElement.cpp b/mozilla/layout/html/content/src/nsHTMLOptionElement.cpp index dd7902dd130..4eefc716dcb 100644 --- a/mozilla/layout/html/content/src/nsHTMLOptionElement.cpp +++ b/mozilla/layout/html/content/src/nsHTMLOptionElement.cpp @@ -577,7 +577,7 @@ nsHTMLOptionElement::SetText(const nsString& aText) nsIDocument * doc; result = GetDocument(doc); if (NS_SUCCEEDED(result)) { - text->SetDocument(doc, PR_FALSE); + text->SetDocument(doc, PR_FALSE, PR_TRUE); NS_IF_RELEASE(doc); } } diff --git a/mozilla/layout/html/content/src/nsHTMLSelectElement.cpp b/mozilla/layout/html/content/src/nsHTMLSelectElement.cpp index 504b1f008ce..9cdacea9a9f 100644 --- a/mozilla/layout/html/content/src/nsHTMLSelectElement.cpp +++ b/mozilla/layout/html/content/src/nsHTMLSelectElement.cpp @@ -343,9 +343,9 @@ nsHTMLSelectElement::SetParent(nsIContent* aParent) } NS_IMETHODIMP -nsHTMLSelectElement::SetDocument(nsIDocument* aDocument, PRBool aDeep) +nsHTMLSelectElement::SetDocument(nsIDocument* aDocument, PRBool aDeep, PRBool aCompileEventHandlers) { - return mInner.SetDocumentForFormControls(aDocument, aDeep, this, mForm); + return mInner.SetDocumentForFormControls(aDocument, aDeep, aCompileEventHandlers, this, mForm); } NS_IMETHODIMP diff --git a/mozilla/layout/html/content/src/nsHTMLTextAreaElement.cpp b/mozilla/layout/html/content/src/nsHTMLTextAreaElement.cpp index 95dcc1d63e1..784f5b9150e 100644 --- a/mozilla/layout/html/content/src/nsHTMLTextAreaElement.cpp +++ b/mozilla/layout/html/content/src/nsHTMLTextAreaElement.cpp @@ -216,9 +216,9 @@ nsHTMLTextAreaElement::SetParent(nsIContent* aParent) } NS_IMETHODIMP -nsHTMLTextAreaElement::SetDocument(nsIDocument* aDocument, PRBool aDeep) +nsHTMLTextAreaElement::SetDocument(nsIDocument* aDocument, PRBool aDeep, PRBool aCompileEventHandlers) { - return mInner.SetDocumentForFormControls(aDocument, aDeep, this, mForm); + return mInner.SetDocumentForFormControls(aDocument, aDeep, aCompileEventHandlers, this, mForm); } NS_IMETHODIMP diff --git a/mozilla/layout/html/content/src/nsHTMLUnknownElement.cpp b/mozilla/layout/html/content/src/nsHTMLUnknownElement.cpp index 79fe4af081c..52fa9116b33 100644 --- a/mozilla/layout/html/content/src/nsHTMLUnknownElement.cpp +++ b/mozilla/layout/html/content/src/nsHTMLUnknownElement.cpp @@ -67,8 +67,8 @@ public: NS_IMETHOD GetDocument(nsIDocument*& aResult) const { return mInner.GetDocument(aResult); } - NS_IMETHOD SetDocument(nsIDocument* aDocument, PRBool aDeep) { - return mInner.SetDocument(aDocument, aDeep); + NS_IMETHOD SetDocument(nsIDocument* aDocument, PRBool aDeep, PRBool aCompileEventHandlers) { + return mInner.SetDocument(aDocument, aDeep, aCompileEventHandlers); } NS_IMETHOD GetParent(nsIContent*& aResult) const { return mInner.GetParent(aResult); diff --git a/mozilla/layout/html/document/src/nsHTMLContentSink.cpp b/mozilla/layout/html/document/src/nsHTMLContentSink.cpp index 4887a47d9a8..d7772a646ea 100644 --- a/mozilla/layout/html/document/src/nsHTMLContentSink.cpp +++ b/mozilla/layout/html/document/src/nsHTMLContentSink.cpp @@ -1257,7 +1257,7 @@ SinkContext::OpenContainer(const nsIParserNode& aNode) mStack[mStackPos].mFlags = 0; mStack[mStackPos].mNumFlushed = 0; mStack[mStackPos].mInsertionPoint = -1; - content->SetDocument(mSink->mDocument, PR_FALSE); + content->SetDocument(mSink->mDocument, PR_FALSE, PR_TRUE); nsCOMPtr scriptGlobalObject; mSink->mDocument->GetScriptGlobalObject(getter_AddRefs(scriptGlobalObject)); @@ -1461,7 +1461,7 @@ SetDocumentInChildrenOf(nsIContent* aContent, nsIContent* child; aContent->ChildAt(i, child); if (nsnull != child) { - child->SetDocument(aDocument, PR_TRUE); + child->SetDocument(aDocument, PR_TRUE, PR_TRUE); NS_RELEASE(child); } } @@ -1602,7 +1602,7 @@ SinkContext::AddLeaf(const nsIParserNode& aNode) } // Set the content's document - content->SetDocument(mSink->mDocument, PR_FALSE); + content->SetDocument(mSink->mDocument, PR_FALSE, PR_TRUE); rv = mSink->AddAttributes(aNode, content); if (NS_OK != rv) { @@ -1706,7 +1706,7 @@ SinkContext::AddComment(const nsIParserNode& aNode) domComment->AppendData(aNode.GetText()); NS_RELEASE(domComment); - comment->SetDocument(mSink->mDocument, PR_FALSE); + comment->SetDocument(mSink->mDocument, PR_FALSE, PR_TRUE); nsIHTMLContent* parent; if ((nsnull == mSink->mBody) && (nsnull != mSink->mHead)) { @@ -1969,7 +1969,7 @@ SinkContext::FlushText(PRBool* aDidFlush, PRBool aReleaseLast) rv = NS_NewTextNode(&content); if (NS_OK == rv) { // Set the content's document - content->SetDocument(mSink->mDocument, PR_FALSE); + content->SetDocument(mSink->mDocument, PR_FALSE, PR_TRUE); // Set the text in the text node nsITextContent* text = nsnull; @@ -2206,7 +2206,7 @@ HTMLContentSink::Init(nsIDocument* aDoc, MOZ_TIMER_STOP(mWatch); return rv; } - mRoot->SetDocument(mDocument, PR_FALSE); + mRoot->SetDocument(mDocument, PR_FALSE, PR_TRUE); mDocument->SetRootContent(mRoot); // Make head part @@ -2548,7 +2548,7 @@ HTMLContentSink::SetTitle(const nsString& aValue) NS_RELEASE(tc); } it->AppendChildTo(text, PR_FALSE); - text->SetDocument(mDocument, PR_FALSE); + text->SetDocument(mDocument, PR_FALSE, PR_TRUE); NS_RELEASE(text); } mHead->AppendChildTo(it, PR_FALSE); @@ -3351,7 +3351,7 @@ HTMLContentSink::ProcessAREATag(const nsIParserNode& aNode) } // Set the content's document and attributes - area->SetDocument(mDocument, PR_FALSE); + area->SetDocument(mDocument, PR_FALSE, PR_TRUE); rv = AddAttributes(aNode, area); if (NS_FAILED(rv)) { NS_RELEASE(area); @@ -3434,7 +3434,7 @@ HTMLContentSink::ProcessBASETag(const nsIParserNode& aNode) // Add in the attributes and add the style content object to the // head container. - element->SetDocument(mDocument, PR_FALSE); + element->SetDocument(mDocument, PR_FALSE, PR_TRUE); result = AddAttributes(aNode, element); if (NS_SUCCEEDED(result)) { parent->AppendChildTo(element, PR_FALSE); @@ -3794,7 +3794,7 @@ HTMLContentSink::ProcessLINKTag(const nsIParserNode& aNode) // Add in the attributes and add the style content object to the // head container. - element->SetDocument(mDocument, PR_FALSE); + element->SetDocument(mDocument, PR_FALSE, PR_TRUE); result = AddAttributes(aNode, element); if (NS_FAILED(result)) { NS_RELEASE(element); @@ -3912,7 +3912,7 @@ HTMLContentSink::ProcessMETATag(const nsIParserNode& aNode) if (NS_OK == rv) { // Add in the attributes and add the meta content object to the // head container. - it->SetDocument(mDocument, PR_FALSE); + it->SetDocument(mDocument, PR_FALSE, PR_TRUE); rv = AddAttributes(aNode, it); if (NS_OK != rv) { NS_RELEASE(it); @@ -4544,7 +4544,7 @@ HTMLContentSink::ProcessSCRIPTTag(const nsIParserNode& aNode) // Add in the attributes and add the style content object to the // head container. - element->SetDocument(mDocument, PR_FALSE); + element->SetDocument(mDocument, PR_FALSE, PR_TRUE); rv = AddAttributes(aNode, element); if (NS_FAILED(rv)) { NS_RELEASE(element); @@ -4579,7 +4579,7 @@ HTMLContentSink::ProcessSCRIPTTag(const nsIParserNode& aNode) NS_RELEASE(tc); } element->AppendChildTo(text, PR_FALSE); - text->SetDocument(mDocument, PR_FALSE); + text->SetDocument(mDocument, PR_FALSE, PR_TRUE); NS_RELEASE(text); } } @@ -4677,7 +4677,7 @@ HTMLContentSink::ProcessSTYLETag(const nsIParserNode& aNode) // Add in the attributes and add the style content object to the // head container. - element->SetDocument(mDocument, PR_FALSE); + element->SetDocument(mDocument, PR_FALSE, PR_TRUE); rv = AddAttributes(aNode, element); if (NS_FAILED(rv)) { NS_RELEASE(element); @@ -4750,7 +4750,7 @@ HTMLContentSink::ProcessSTYLETag(const nsIParserNode& aNode) NS_RELEASE(tc); } element->AppendChildTo(text, PR_FALSE); - text->SetDocument(mDocument, PR_FALSE); + text->SetDocument(mDocument, PR_FALSE, PR_TRUE); NS_RELEASE(text); } diff --git a/mozilla/layout/html/document/src/nsImageDocument.cpp b/mozilla/layout/html/document/src/nsImageDocument.cpp index cd9b7a71843..fb699e620b3 100644 --- a/mozilla/layout/html/document/src/nsImageDocument.cpp +++ b/mozilla/layout/html/document/src/nsImageDocument.cpp @@ -261,7 +261,7 @@ nsImageDocument::CreateSyntheticDocument() if (NS_OK != rv) { return rv; } - root->SetDocument(this, PR_FALSE); + root->SetDocument(this, PR_FALSE, PR_TRUE); SetRootContent(root); rv = mNodeInfoManager->GetNodeInfo(nsHTMLAtoms::body, nsnull, @@ -274,7 +274,7 @@ nsImageDocument::CreateSyntheticDocument() if (NS_OK != rv) { return rv; } - body->SetDocument(this, PR_FALSE); + body->SetDocument(this, PR_FALSE, PR_TRUE); rv = mNodeInfoManager->GetNodeInfo(nsHTMLAtoms::p, nsnull, kNameSpaceID_None, *getter_AddRefs(nodeInfo)); @@ -285,7 +285,7 @@ nsImageDocument::CreateSyntheticDocument() if (NS_OK != rv) { return rv; } - center->SetDocument(this, PR_FALSE); + center->SetDocument(this, PR_FALSE, PR_TRUE); rv = mNodeInfoManager->GetNodeInfo(nsHTMLAtoms::img, nsnull, kNameSpaceID_None, @@ -297,7 +297,7 @@ nsImageDocument::CreateSyntheticDocument() if (NS_OK != rv) { return rv; } - image->SetDocument(this, PR_FALSE); + image->SetDocument(this, PR_FALSE, PR_TRUE); char* src; mDocumentURL->GetSpec(&src); diff --git a/mozilla/layout/html/forms/src/nsComboboxControlFrame.cpp b/mozilla/layout/html/forms/src/nsComboboxControlFrame.cpp index 76849fe393b..9695d574773 100644 --- a/mozilla/layout/html/forms/src/nsComboboxControlFrame.cpp +++ b/mozilla/layout/html/forms/src/nsComboboxControlFrame.cpp @@ -2165,7 +2165,7 @@ nsComboboxControlFrame::CreateAnonymousContent(nsIPresContext* aPresContext, nsCOMPtr doc; mContent->GetDocument(*getter_AddRefs(doc)); /* - labelContent->SetDocument(doc, PR_FALSE); + labelContent->SetDocument(doc, PR_FALSE, PR_TRUE); mContent->AppendChildTo(labelContent, PR_FALSE); */ diff --git a/mozilla/layout/html/forms/src/nsGfxTextControlFrame.cpp b/mozilla/layout/html/forms/src/nsGfxTextControlFrame.cpp index 088e96b1d96..1b7d032a99e 100644 --- a/mozilla/layout/html/forms/src/nsGfxTextControlFrame.cpp +++ b/mozilla/layout/html/forms/src/nsGfxTextControlFrame.cpp @@ -1409,7 +1409,7 @@ nsGfxTextControlFrame::CreateSubDoc(nsRect *aSizeOfSubdocContainer) rv = NS_NewHTMLHeadElement(getter_AddRefs(headElement), nodeInfo); if (NS_FAILED(rv)) { return rv; } if (!headElement) { return NS_ERROR_NULL_POINTER; } - headElement->SetDocument(doc, PR_FALSE); + headElement->SetDocument(doc, PR_FALSE, PR_TRUE); // create the body nimgr->GetNodeInfo(nsHTMLAtoms::body, nsnull, kNameSpaceID_None, @@ -1418,7 +1418,7 @@ nsGfxTextControlFrame::CreateSubDoc(nsRect *aSizeOfSubdocContainer) rv = NS_NewHTMLBodyElement(getter_AddRefs(bodyElement), nodeInfo); if (NS_FAILED(rv)) { return rv; } if (!bodyElement) { return NS_ERROR_NULL_POINTER; } - bodyElement->SetDocument(doc, PR_FALSE); + bodyElement->SetDocument(doc, PR_FALSE, PR_TRUE); // put the head and body into the root rv = htmlElement->AppendChildTo(headElement, PR_FALSE); if (NS_FAILED(rv)) { return rv; } @@ -2577,7 +2577,7 @@ nsGfxTextControlFrame::Reflow(nsIPresContext* aPresContext, if (!content) { return NS_ERROR_NULL_POINTER; } nsIDocument* doc; mContent->GetDocument(doc); - content->SetDocument(doc, PR_FALSE); + content->SetDocument(doc, PR_FALSE, PR_TRUE); NS_RELEASE(doc); mContent->AppendChildTo(content, PR_FALSE); diff --git a/mozilla/layout/html/style/src/nsCSSFrameConstructor.cpp b/mozilla/layout/html/style/src/nsCSSFrameConstructor.cpp index 3db76f13900..6e1c6f63d76 100644 --- a/mozilla/layout/html/style/src/nsCSSFrameConstructor.cpp +++ b/mozilla/layout/html/style/src/nsCSSFrameConstructor.cpp @@ -1129,7 +1129,7 @@ nsCSSFrameConstructor::CreateGeneratedFrameFor(nsIPresContext* aPresContex // Set aContent as the parent content and set the document object. This // way event handling works imageContent->SetParent(aContent); - imageContent->SetDocument(aDocument, PR_TRUE); + imageContent->SetDocument(aDocument, PR_TRUE, PR_TRUE); // Create an image frame and initialize it nsIFrame* imageFrame; @@ -1180,7 +1180,7 @@ nsCSSFrameConstructor::CreateGeneratedFrameFor(nsIPresContext* aPresContex // Set aContent as the parent content and set the document object. This // way event handling works content->SetParent(aContent); - content->SetDocument(aDocument, PR_TRUE); + content->SetDocument(aDocument, PR_TRUE, PR_TRUE); // Create a text frame and initialize it NS_NewTextFrame(shell, &textFrame); @@ -1250,7 +1250,7 @@ nsCSSFrameConstructor::CreateGeneratedFrameFor(nsIPresContext* aPresContex // Set aContent as the parent content and set the document object. This // way event handling works textContent->SetParent(aContent); - textContent->SetDocument(aDocument, PR_TRUE); + textContent->SetDocument(aDocument, PR_TRUE, PR_TRUE); // Create a text frame and initialize it NS_NewTextFrame(shell, &textFrame); @@ -5237,7 +5237,7 @@ nsCSSFrameConstructor::CreateAnonymousFrames(nsIPresShell* aPresShell, nsCOMPtr content(do_QueryInterface(node)); content->SetParent(aParent); - content->SetDocument(aDocument, PR_TRUE); + content->SetDocument(aDocument, PR_TRUE, PR_TRUE); nsIFrame * newFrame = nsnull; nsresult rv = creator->CreateFrameFor(aPresContext, content, &newFrame); @@ -9784,7 +9784,7 @@ nsCSSFrameConstructor::ConstructAlternateImageFrame(nsIPresShell* aPresShell, nsCOMPtr document; aContent->GetDocument(*getter_AddRefs(document)); altTextContent->SetParent(aContent); - altTextContent->SetDocument(document, PR_TRUE); + altTextContent->SetDocument(document, PR_TRUE, PR_TRUE); // Create either an inline frame, block frame, or area frame nsIFrame* containerFrame; diff --git a/mozilla/layout/html/tests/TestAttributes.cpp b/mozilla/layout/html/tests/TestAttributes.cpp index 565f72f33d9..b3c9b1fecdb 100644 --- a/mozilla/layout/html/tests/TestAttributes.cpp +++ b/mozilla/layout/html/tests/TestAttributes.cpp @@ -264,7 +264,7 @@ int main(int argc, char** argv) PRBool canHaveKids; text->CanContainChildren(canHaveKids); NS_ASSERTION(!canHaveKids,""); - text->SetDocument(myDoc, PR_FALSE); + text->SetDocument(myDoc, PR_FALSE, PR_TRUE); #if 0 // Query ITextContent interface @@ -300,7 +300,7 @@ int main(int argc, char** argv) } container->CanContainChildren(canHaveKids); NS_ASSERTION(canHaveKids,""); - container->SetDocument(myDoc, PR_FALSE); + container->SetDocument(myDoc, PR_FALSE, PR_TRUE); container->AppendChildTo(text, PR_FALSE); PRInt32 nk; diff --git a/mozilla/layout/xbl/public/nsIXBLService.h b/mozilla/layout/xbl/public/nsIXBLService.h index 6a4881bd86e..1496b565a2a 100644 --- a/mozilla/layout/xbl/public/nsIXBLService.h +++ b/mozilla/layout/xbl/public/nsIXBLService.h @@ -63,6 +63,7 @@ public: // Retrieves our base class (e.g., tells us what type of frame and content node to build) NS_IMETHOD ResolveTag(nsIContent* aContent, nsIAtom** aResult) = 0; + NS_IMETHOD AllowScripts(nsIContent* aContent, PRBool* aAllowScripts) = 0; }; #endif // nsIXBLService_h__ diff --git a/mozilla/layout/xbl/src/nsXBLBinding.cpp b/mozilla/layout/xbl/src/nsXBLBinding.cpp index 307d4af4318..22c33b3273f 100644 --- a/mozilla/layout/xbl/src/nsXBLBinding.cpp +++ b/mozilla/layout/xbl/src/nsXBLBinding.cpp @@ -39,6 +39,7 @@ #include "nsIContent.h" #include "nsIDocument.h" #include "nsIXMLContent.h" +#include "nsIXULContent.h" #include "nsIXMLContentSink.h" #include "nsLayoutCID.h" #include "nsXMLDocument.h" @@ -48,6 +49,7 @@ #include "nsINameSpace.h" #include "nsJSUtils.h" #include "nsIJSRuntimeService.h" +#include "nsIXBLService.h" // Event listeners #include "nsIEventListenerManager.h" @@ -167,6 +169,8 @@ public: NS_IMETHOD AddScriptEventListener(nsIContent* aElement, nsIAtom* aName, const nsString& aValue, REFNSIID aIID); + PRBool AllowScripts(); + static nsresult GetTextData(nsIContent *aParent, nsString& aResult); // Static members @@ -428,8 +432,9 @@ nsXBLBinding::SetAnonymousContent(nsIContent* aParent) // element's document. nsCOMPtr doc; mBoundElement->GetDocument(*getter_AddRefs(doc)); - mContent->SetDocument(doc, PR_TRUE); + mContent->SetDocument(doc, PR_TRUE, AllowScripts()); + // (2) The children's parent back pointer should not be to this synthetic root // but should instead point to the bound element. PRInt32 childCount; @@ -583,7 +588,7 @@ nsXBLBinding::InstallEventHandlers(nsIContent* aBoundElement) nsCOMPtr handlers; GetImmediateChild(kHandlersAtom, getter_AddRefs(handlers)); - if (handlers) { + if (handlers && AllowScripts()) { // Now walk the handlers and add event listeners to the bound // element. PRInt32 childCount; @@ -669,7 +674,7 @@ nsXBLBinding::InstallProperties(nsIContent* aBoundElement) nsCOMPtr interfaceElement; GetImmediateChild(kInterfaceAtom, getter_AddRefs(interfaceElement)); - if (interfaceElement) { + if (interfaceElement && AllowScripts()) { // Get our bound element's script context. nsresult rv; nsCOMPtr document; @@ -1055,7 +1060,7 @@ nsXBLBinding::ChangeDocument(nsIDocument* aOldDocument, nsIDocument* aNewDocumen nsCOMPtr anonymous; GetAnonymousContent(getter_AddRefs(anonymous)); if (anonymous) - anonymous->SetDocument(aNewDocument, PR_TRUE); + anonymous->SetDocument(aNewDocument, PR_TRUE, AllowScripts()); } return NS_OK; @@ -1459,6 +1464,20 @@ nsXBLBinding::GetTextData(nsIContent *aParent, nsString& aResult) return NS_OK; } +PRBool +nsXBLBinding::AllowScripts() +{ + nsresult rv; + nsCOMPtr xblService(do_GetService("component://netscape/xbl", &rv)); + if (xblService) { + PRBool allowScripts; + xblService->AllowScripts(mBinding, &allowScripts); + return allowScripts; + } + + return PR_FALSE; +} + // Creation Routine /////////////////////////////////////////////////////////////////////// nsresult diff --git a/mozilla/layout/xbl/src/nsXBLService.cpp b/mozilla/layout/xbl/src/nsXBLService.cpp index 95d93b40d94..a4ee72e12db 100644 --- a/mozilla/layout/xbl/src/nsXBLService.cpp +++ b/mozilla/layout/xbl/src/nsXBLService.cpp @@ -46,11 +46,13 @@ #include "nsITextContent.h" #include "nsIXBLBinding.h" +#include "nsIChromeRegistry.h" // Static IIDs/CIDs. Try to minimize these. static NS_DEFINE_CID(kNameSpaceManagerCID, NS_NAMESPACEMANAGER_CID); static NS_DEFINE_CID(kXMLDocumentCID, NS_XMLDOCUMENT_CID); static NS_DEFINE_CID(kParserCID, NS_PARSER_IID); // XXX What's up with this??? +static NS_DEFINE_CID(kChromeRegistryCID, NS_CHROMEREGISTRY_CID); // nsProxyStream // A helper class used for synchronous parsing of URLs. @@ -130,6 +132,8 @@ class nsXBLService: public nsIXBLService // Gets the object's base class type. NS_IMETHOD ResolveTag(nsIContent* aContent, nsIAtom** aResult); + NS_IMETHOD AllowScripts(nsIContent* aContent, PRBool* aAllowScripts); + public: nsXBLService(); virtual ~nsXBLService(); @@ -152,7 +156,7 @@ protected: static nsSupportsHashtable* mBindingTable; // This is a table of all the bindings files // we have loaded // during this session. - static nsSupportsHashtable* mProtoClassTable; // Every binding with methods/properties has a protoclass. + static nsSupportsHashtable* mScriptAccessTable; // Can the doc's bindings access scripts static nsINameSpaceManager* gNameSpaceManager; // Used to register the XBL namespace static PRInt32 kNameSpaceID_XBL; // Convenient cached XBL namespace. @@ -170,7 +174,7 @@ protected: // Static member variable initialization PRUint32 nsXBLService::gRefCnt = 0; nsSupportsHashtable* nsXBLService::mBindingTable = nsnull; -nsSupportsHashtable* nsXBLService::mProtoClassTable = nsnull; +nsSupportsHashtable* nsXBLService::mScriptAccessTable = nsnull; nsINameSpaceManager* nsXBLService::gNameSpaceManager = nsnull; @@ -191,7 +195,7 @@ nsXBLService::nsXBLService(void) if (gRefCnt == 1) { // Create our binding table. mBindingTable = new nsSupportsHashtable(); - mProtoClassTable = new nsSupportsHashtable(); + mScriptAccessTable = new nsSupportsHashtable(); // Register the XBL namespace. nsresult rv = nsComponentManager::CreateInstance(kNameSpaceManagerCID, @@ -221,7 +225,7 @@ nsXBLService::~nsXBLService(void) gRefCnt--; if (gRefCnt == 0) { delete mBindingTable; - delete mProtoClassTable; + delete mScriptAccessTable; NS_IF_RELEASE(gNameSpaceManager); @@ -358,6 +362,8 @@ nsXBLService::FlushBindingDocuments() { delete mBindingTable; mBindingTable = new nsSupportsHashtable(); + delete mScriptAccessTable; + mScriptAccessTable = new nsSupportsHashtable(); return NS_OK; } @@ -378,6 +384,25 @@ nsXBLService::ResolveTag(nsIContent* aContent, nsIAtom** aResult) return NS_OK; } +NS_IMETHODIMP +nsXBLService::AllowScripts(nsIContent* aContent, PRBool* aAllowScripts) +{ + nsAutoString uri; + aContent->GetAttribute(kNameSpaceID_None, kURIAtom, uri); + + PRInt32 indx = uri.RFindChar('#'); + if (indx >= 0) + uri.Truncate(indx); + + nsStringKey key(uri); + nsCOMPtr document; + document = dont_AddRef(NS_STATIC_CAST(nsIDocument*, mScriptAccessTable->Get(&key))); + + *aAllowScripts = !document; + + return NS_OK; +} + // Internal helper methods //////////////////////////////////////////////////////////////// NS_IMETHODIMP nsXBLService::GetBinding(const nsCString& aURLStr, nsIXBLBinding** aResult) @@ -421,8 +446,11 @@ NS_IMETHODIMP nsXBLService::GetBinding(const nsCString& aURLStr, nsIXBLBinding** // If no ref is specified just use this. if ((bindingName.IsEmpty()) || (bindingName == value)) { - child->SetAttribute(kNameSpaceID_None, kURIAtom, NS_ConvertASCIItoUCS2(aURLStr.GetBuffer(), aURLStr.Length()), PR_FALSE); - + nsAutoString url; + child->GetAttribute(kNameSpaceID_None, kURIAtom, url); + if (url.IsEmpty()) + child->SetAttribute(kNameSpaceID_None, kURIAtom, NS_ConvertASCIItoUCS2(aURLStr.GetBuffer(), aURLStr.Length()), PR_FALSE); + // Make a new binding NS_NewXBLBinding(aResult); @@ -457,6 +485,8 @@ NS_IMETHODIMP nsXBLService::GetBinding(const nsCString& aURLStr, nsIXBLBinding** NS_IMETHODIMP nsXBLService::GetBindingDocument(const nsCString& aURLStr, nsIDocument** aResult) { + nsresult rv; + *aResult = nsnull; // We've got a file. Check our key binding file cache. @@ -465,7 +495,6 @@ nsXBLService::GetBindingDocument(const nsCString& aURLStr, nsIDocument** aResult document = dont_AddRef(NS_STATIC_CAST(nsIDocument*, mBindingTable->Get(&key))); if (!document) { - nsCOMPtr uri; nsComponentManager::CreateInstance("component://netscape/network/standard-url", nsnull, @@ -477,6 +506,14 @@ nsXBLService::GetBindingDocument(const nsCString& aURLStr, nsIDocument** aResult if (document) { // Put the key binding doc into our table. mBindingTable->Put(&key, document); + + nsCOMPtr reg(do_GetService(kChromeRegistryCID, &rv)); + if (NS_SUCCEEDED(rv) && reg) { + PRBool allow; + reg->AllowScriptsForSkin(uri, &allow); + if (!allow) + mScriptAccessTable->Put(&key, document); + } } else return NS_ERROR_FAILURE; } diff --git a/mozilla/layout/xml/content/src/nsXMLElement.h b/mozilla/layout/xml/content/src/nsXMLElement.h index d2c2bb2d569..1861c783555 100644 --- a/mozilla/layout/xml/content/src/nsXMLElement.h +++ b/mozilla/layout/xml/content/src/nsXMLElement.h @@ -63,8 +63,8 @@ public: NS_IMETHOD GetDocument(nsIDocument*& aResult) const { return mInner.GetDocument(aResult); } - NS_IMETHOD SetDocument(nsIDocument* aDocument, PRBool aDeep) { - return mInner.SetDocument(aDocument, aDeep); + NS_IMETHOD SetDocument(nsIDocument* aDocument, PRBool aDeep, PRBool aCompileEventHandlers) { + return mInner.SetDocument(aDocument, aDeep, aCompileEventHandlers); } NS_IMETHOD GetParent(nsIContent*& aResult) const { return mInner.GetParent(aResult); diff --git a/mozilla/layout/xml/document/src/nsXMLContentSink.cpp b/mozilla/layout/xml/document/src/nsXMLContentSink.cpp index c8fa73bb96a..882454665a5 100644 --- a/mozilla/layout/xml/document/src/nsXMLContentSink.cpp +++ b/mozilla/layout/xml/document/src/nsXMLContentSink.cpp @@ -755,7 +755,7 @@ nsXMLContentSink::OpenContainer(const nsIParserNode& aNode) PRInt32 id; mDocument->GetAndIncrementContentID(&id); content->SetContentID(id); - content->SetDocument(mDocument, PR_FALSE); + content->SetDocument(mDocument, PR_FALSE, PR_TRUE); // Set the attributes on the new content element result = AddAttributes(aNode, content, isHTML); @@ -940,7 +940,7 @@ nsXMLContentSink::AddComment(const nsIParserNode& aNode) domComment->AppendData(text); NS_RELEASE(domComment); - comment->SetDocument(mDocument, PR_FALSE); + comment->SetDocument(mDocument, PR_FALSE, PR_TRUE); result = AddContentAsLeaf(comment); } NS_RELEASE(comment); @@ -967,7 +967,7 @@ nsXMLContentSink::AddCDATASection(const nsIParserNode& aNode) domCDATA->AppendData(text); NS_RELEASE(domCDATA); - cdata->SetDocument(mDocument, PR_FALSE); + cdata->SetDocument(mDocument, PR_FALSE, PR_TRUE); result = AddContentAsLeaf(cdata); } NS_RELEASE(cdata); @@ -1267,7 +1267,7 @@ nsXMLContentSink::AddProcessingInstruction(const nsIParserNode& aNode) ParseProcessingInstruction(text, target, data); result = NS_NewXMLProcessingInstruction(&node, target, data); if (NS_OK == result) { - node->SetDocument(mDocument, PR_FALSE); + node->SetDocument(mDocument, PR_FALSE, PR_TRUE); result = AddContentAsLeaf(node); } @@ -1327,7 +1327,7 @@ nsXMLContentSink::FlushText(PRBool aCreateTextNode, PRBool* aDidFlush) rv = NS_NewTextNode(&content); if (NS_OK == rv) { // Set the content's document - content->SetDocument(mDocument, PR_FALSE); + content->SetDocument(mDocument, PR_FALSE, PR_TRUE); // Set the text in the text node static NS_DEFINE_IID(kITextContentIID, NS_ITEXT_CONTENT_IID); diff --git a/mozilla/layout/xul/base/src/nsTreeRowGroupFrame.cpp b/mozilla/layout/xul/base/src/nsTreeRowGroupFrame.cpp index 70d0b490731..516f4b3523b 100644 --- a/mozilla/layout/xul/base/src/nsTreeRowGroupFrame.cpp +++ b/mozilla/layout/xul/base/src/nsTreeRowGroupFrame.cpp @@ -1683,7 +1683,7 @@ void nsTreeRowGroupFrame::CreateScrollbar(nsIPresContext* aPresContext) document->CreateElement(NS_ConvertASCIItoUCS2("scrollbar"),getter_AddRefs(node)); nsCOMPtr content = do_QueryInterface(node); - content->SetDocument(idocument, PR_FALSE); + content->SetDocument(idocument, PR_FALSE, PR_TRUE); content->SetParent(mContent); nsCOMPtr xulContent = do_QueryInterface(content); diff --git a/mozilla/rdf/chrome/public/nsIChromeRegistry.idl b/mozilla/rdf/chrome/public/nsIChromeRegistry.idl index 42592797e7a..b21cb16cdc2 100644 --- a/mozilla/rdf/chrome/public/nsIChromeRegistry.idl +++ b/mozilla/rdf/chrome/public/nsIChromeRegistry.idl @@ -79,7 +79,7 @@ interface nsIChromeRegistry : nsISupports void deselectLocaleForPackage(in wstring localeName, in wstring packageName, in boolean useProfile); /* Installation APIs */ - void installSkin(in string baseURL, in boolean useProfile); + void installSkin(in string baseURL, in boolean useProfile, in boolean allowScripts); void uninstallSkin(in wstring skinName, in boolean useProfile); void installLocale(in string baseURL, in boolean useProfile); @@ -90,6 +90,8 @@ interface nsIChromeRegistry : nsISupports void getBackstopSheets(out nsISupportsArray styleSheets); + boolean allowScriptsForSkin(in nsIURI url); + void checkForNewChrome(); }; diff --git a/mozilla/rdf/chrome/src/nsChromeRegistry.cpp b/mozilla/rdf/chrome/src/nsChromeRegistry.cpp index c25fcc655f6..9d3ac02870f 100644 --- a/mozilla/rdf/chrome/src/nsChromeRegistry.cpp +++ b/mozilla/rdf/chrome/src/nsChromeRegistry.cpp @@ -94,6 +94,7 @@ DEFINE_RDF_VOCAB(CHROME_URI, CHROME, packages); DEFINE_RDF_VOCAB(CHROME_URI, CHROME, package); DEFINE_RDF_VOCAB(CHROME_URI, CHROME, name); DEFINE_RDF_VOCAB(CHROME_URI, CHROME, locType); +DEFINE_RDF_VOCAB(CHROME_URI, CHROME, allowScripts); //////////////////////////////////////////////////////////////////////////////// @@ -242,6 +243,9 @@ nsChromeRegistry::nsChromeRegistry() rv = mRDFService->GetResource(kURICHROME_locType, getter_AddRefs(mLocType)); NS_ASSERTION(NS_SUCCEEDED(rv), "unable to get RDF resource"); + + rv = mRDFService->GetResource(kURICHROME_allowScripts, getter_AddRefs(mAllowScripts)); + NS_ASSERTION(NS_SUCCEEDED(rv), "unable to get RDF resource"); } } @@ -1439,7 +1443,8 @@ NS_IMETHODIMP nsChromeRegistry::SelectProviderForPackage(const nsCString& aProvi NS_IMETHODIMP nsChromeRegistry::InstallProvider(const nsCString& aProviderType, const nsCString& aBaseURL, - PRBool aUseProfile, PRBool aRemove) + PRBool aUseProfile, PRBool aAllowScripts, + PRBool aRemove) { // XXX don't allow local chrome overrides of install chrome! @@ -1494,6 +1499,12 @@ NS_IMETHODIMP nsChromeRegistry::InstallProvider(const nsCString& aProviderType, nsCOMPtr baseLiteral; mRDFService->GetLiteral(unistr.GetUnicode(), getter_AddRefs(baseLiteral)); + // Get the literal for our script access. + nsAutoString scriptstr; + scriptstr.AssignWithConversion("false"); + nsCOMPtr scriptLiteral; + mRDFService->GetLiteral(scriptstr.GetUnicode(), getter_AddRefs(scriptLiteral)); + // Build the prefix string. Only resources with this prefix string will have their // assertions copied. nsCAutoString prefix = "urn:mozilla:"; @@ -1619,8 +1630,10 @@ NS_IMETHODIMP nsChromeRegistry::InstallProvider(const nsCString& aProviderType, if (arc == mPackages) { // We are the main entry for a skin/locale. - // Set up our loctype + // Set up our loctype and our script access nsChromeRegistry::UpdateArc(installSource, resource, mLocType, locLiteral, aRemove); + if (aProviderType.Equals(nsCAutoString("skin")) && !aAllowScripts) + nsChromeRegistry::UpdateArc(installSource, resource, mAllowScripts, scriptLiteral, aRemove); } nsCOMPtr newTarget; @@ -1646,40 +1659,40 @@ NS_IMETHODIMP nsChromeRegistry::InstallProvider(const nsCString& aProviderType, return NS_OK; } -NS_IMETHODIMP nsChromeRegistry::InstallSkin(const char* aBaseURL, PRBool aUseProfile) +NS_IMETHODIMP nsChromeRegistry::InstallSkin(const char* aBaseURL, PRBool aUseProfile, PRBool aAllowScripts) { nsCAutoString provider("skin"); - return InstallProvider(provider, aBaseURL, aUseProfile, PR_FALSE); + return InstallProvider(provider, aBaseURL, aUseProfile, aAllowScripts, PR_FALSE); } NS_IMETHODIMP nsChromeRegistry::InstallLocale(const char* aBaseURL, PRBool aUseProfile) { nsCAutoString provider("locale"); - return InstallProvider(provider, aBaseURL, aUseProfile, PR_FALSE); + return InstallProvider(provider, aBaseURL, aUseProfile, PR_TRUE, PR_FALSE); } NS_IMETHODIMP nsChromeRegistry::InstallPackage(const char* aBaseURL, PRBool aUseProfile) { nsCAutoString provider("package"); - return InstallProvider(provider, aBaseURL, aUseProfile, PR_FALSE); + return InstallProvider(provider, aBaseURL, aUseProfile, PR_TRUE, PR_FALSE); } NS_IMETHODIMP nsChromeRegistry::UninstallSkin(const PRUnichar* aSkinName, PRBool aUseProfile) { nsCAutoString provider("skin"); - return InstallProvider(provider, "", aUseProfile, PR_TRUE); + return InstallProvider(provider, "", aUseProfile, PR_TRUE, PR_TRUE); } NS_IMETHODIMP nsChromeRegistry::UninstallLocale(const PRUnichar* aLocaleName, PRBool aUseProfile) { nsCAutoString provider("locale"); - return InstallProvider(provider, "", aUseProfile, PR_TRUE); + return InstallProvider(provider, "", aUseProfile, PR_TRUE, PR_TRUE); } NS_IMETHODIMP nsChromeRegistry::UninstallPackage(const PRUnichar* aPackageName, PRBool aUseProfile) { nsCAutoString provider("package"); - return InstallProvider(provider, "", aUseProfile, PR_TRUE); + return InstallProvider(provider, "", aUseProfile, PR_TRUE, PR_TRUE); } NS_IMETHODIMP @@ -1945,6 +1958,59 @@ void nsChromeRegistry::GetUserSheetURL(nsCString & aURL) aURL.Append("user.css"); } +NS_IMETHODIMP nsChromeRegistry::AllowScriptsForSkin(nsIURI* aChromeURI, PRBool *aResult) +{ + *aResult = PR_TRUE; + + // split the url + nsCAutoString package, provider, file; + nsresult rv; + rv = SplitURL(aChromeURI, package, provider, file); + if (NS_FAILED(rv)) return NS_OK; + + // verify it's a skin url + if (!provider.Equals("skin")) + return NS_OK; + + // XXX could factor this with selectproviderforpackage + // get the selected skin resource for the package + nsCOMPtr selectedProvider; + + nsCAutoString resourceStr("urn:mozilla:package:"); + resourceStr += package; + + // Obtain the resource. + nsCOMPtr resource; + rv = GetResource(resourceStr, getter_AddRefs(resource)); + if (NS_FAILED(rv)) { + NS_ERROR("Unable to obtain the package resource."); + return rv; + } + + if (NS_FAILED(rv = mChromeDataSource->GetTarget(resource, mSelectedSkin, PR_TRUE, getter_AddRefs(selectedProvider)))) + return NS_OK; + + if (!selectedProvider) + FindProvider(package, provider, mSelectedSkin, getter_AddRefs(selectedProvider)); + if (!selectedProvider) + return NS_OK; + + resource = do_QueryInterface(selectedProvider); + if (!resource) + return NS_OK; + + // get its script access + nsCAutoString scriptAccess; + nsChromeRegistry::FollowArc(mChromeDataSource, + scriptAccess, + resource, + mAllowScripts); + if (!scriptAccess.IsEmpty()) + *aResult = PR_FALSE; + + return NS_OK; +} + NS_IMETHODIMP nsChromeRegistry::CheckForNewChrome() { @@ -2057,7 +2123,7 @@ nsChromeRegistry::ProcessNewChromeBuffer(char *aBuffer, PRInt32 aLength) { // process the line if (skin.Equals(chromeType)) - InstallSkin(chromeURL, isProfile); + InstallSkin(chromeURL, isProfile, PR_FALSE); else if (content.Equals(chromeType)) InstallPackage(chromeURL, isProfile); else if (locale.Equals(chromeType)) diff --git a/mozilla/rdf/chrome/src/nsChromeRegistry.h b/mozilla/rdf/chrome/src/nsChromeRegistry.h index 8a779a1a568..e0adf6cfc65 100644 --- a/mozilla/rdf/chrome/src/nsChromeRegistry.h +++ b/mozilla/rdf/chrome/src/nsChromeRegistry.h @@ -125,7 +125,7 @@ private: NS_IMETHOD InstallProvider(const nsCString& aProviderType, const nsCString& aBaseURL, - PRBool aUseProfile, PRBool aRemove); + PRBool aUseProfile, PRBool aAllowScripts, PRBool aRemove); void ProcessNewChromeBuffer(char *aBuffer, PRInt32 aLength); @@ -150,6 +150,7 @@ protected: nsCOMPtr mPackage; nsCOMPtr mName; nsCOMPtr mLocType; + nsCOMPtr mAllowScripts; // Style Sheets nsCOMPtr mScrollbarSheet; diff --git a/mozilla/rdf/content/src/nsXULDocument.cpp b/mozilla/rdf/content/src/nsXULDocument.cpp index d1d411d6454..5b213332c0b 100644 --- a/mozilla/rdf/content/src/nsXULDocument.cpp +++ b/mozilla/rdf/content/src/nsXULDocument.cpp @@ -1016,11 +1016,11 @@ void nsXULDocument::SetRootContent(nsIContent* aRoot) { if (mRootContent) { - mRootContent->SetDocument(nsnull, PR_TRUE); + mRootContent->SetDocument(nsnull, PR_TRUE, PR_TRUE); } mRootContent = aRoot; if (mRootContent) { - mRootContent->SetDocument(this, PR_TRUE); + mRootContent->SetDocument(this, PR_TRUE, PR_TRUE); } } @@ -1299,7 +1299,7 @@ nsXULDocument::SetScriptGlobalObject(nsIScriptGlobalObject* aScriptGlobalObject) // that the content elements can remove references to their // script objects. if (mRootContent) - mRootContent->SetDocument(nsnull, PR_TRUE); + mRootContent->SetDocument(nsnull, PR_TRUE, PR_TRUE); // Break circular reference for the case where the currently // focused window is ourself. @@ -2157,7 +2157,7 @@ nsXULDocument::SetForm(nsIDOMHTMLFormElement* aForm) // Set the document. nsCOMPtr formContent = do_QueryInterface(aForm); - formContent->SetDocument(this, PR_TRUE); + formContent->SetDocument(this, PR_TRUE, PR_TRUE); // Forms are containers, and as such take up a bit of space. // Set a style attribute to keep the hidden form from showing up. @@ -5357,7 +5357,7 @@ nsXULDocument::CreateElement(nsXULPrototypeElement* aPrototype, nsIContent** aRe if (! result) return NS_ERROR_UNEXPECTED; - rv = result->SetDocument(this, PR_FALSE); + rv = result->SetDocument(this, PR_FALSE, PR_TRUE); if (NS_FAILED(rv)) return rv; rv = AddAttributes(aPrototype, result); @@ -5394,7 +5394,7 @@ nsXULDocument::CreateElement(nsXULPrototypeElement* aPrototype, nsIContent** aRe if (! result) return NS_ERROR_UNEXPECTED; - rv = result->SetDocument(this, PR_FALSE); + rv = result->SetDocument(this, PR_FALSE, PR_TRUE); if (NS_FAILED(rv)) return rv; rv = AddAttributes(aPrototype, result); @@ -6131,7 +6131,7 @@ nsXULDocument::InsertElement(nsIContent* aParent, nsIContent* aChild) NS_ASSERTION(doc != nsnull, "merging into null document"); - rv = aChild->SetDocument(doc, PR_TRUE); + rv = aChild->SetDocument(doc, PR_TRUE, PR_TRUE); if (NS_FAILED(rv)) return rv; return NS_OK; diff --git a/mozilla/rdf/content/src/nsXULElement.cpp b/mozilla/rdf/content/src/nsXULElement.cpp index 7684768cd17..b36d95345ce 100644 --- a/mozilla/rdf/content/src/nsXULElement.cpp +++ b/mozilla/rdf/content/src/nsXULElement.cpp @@ -1182,7 +1182,7 @@ nsXULElement::InsertBefore(nsIDOMNode* aNewChild, nsIDOMNode* aRefChild, nsIDOMN // done now. We do it -before- inserting into the content // model, because some frames assume that the document // will have been set. - rv = newcontent->SetDocument(mDocument, PR_TRUE); + rv = newcontent->SetDocument(mDocument, PR_TRUE, PR_TRUE); if (NS_FAILED(rv)) return rv; rv = InsertChildAt(newcontent, pos, PR_TRUE); @@ -1201,7 +1201,7 @@ nsXULElement::InsertBefore(nsIDOMNode* aNewChild, nsIDOMNode* aRefChild, nsIDOMN // now. We do it -before- appending to the content model, // because some frames assume that they can get to the // document right away. - rv = newcontent->SetDocument(mDocument, PR_TRUE); + rv = newcontent->SetDocument(mDocument, PR_TRUE, PR_TRUE); if (NS_FAILED(rv)) return rv; rv = AppendChildTo(newcontent, PR_TRUE); @@ -1246,7 +1246,7 @@ nsXULElement::ReplaceChild(nsIDOMNode* aNewChild, nsIDOMNode* aOldChild, nsIDOMN // is done now. We do it -before- replacing the nodein // the content model, because some frames assume that // the document will have been set. - rv = newelement->SetDocument(mDocument, PR_TRUE); + rv = newelement->SetDocument(mDocument, PR_TRUE, PR_TRUE); if (NS_FAILED(rv)) return rv; rv = ReplaceChildAt(newelement, pos, PR_TRUE); @@ -2403,9 +2403,9 @@ nsXULElement::GetDocument(nsIDocument*& aResult) const NS_IF_ADDREF(aResult); return NS_OK; } - + NS_IMETHODIMP -nsXULElement::SetDocument(nsIDocument* aDocument, PRBool aDeep) +nsXULElement::SetDocument(nsIDocument* aDocument, PRBool aDeep, PRBool aCompileEventHandlers) { nsresult rv; @@ -2476,9 +2476,11 @@ nsXULElement::SetDocument(nsIDocument* aDocument, PRBool aDeep) PRBool reset = PR_FALSE; if (nameSpaceID == kNameSpaceID_None) { - nsIID iid; - rv = gXULUtils->GetEventHandlerIID(attr, &iid, &reset); - if (NS_FAILED(rv)) return rv; + if (aCompileEventHandlers) { + nsIID iid; + rv = gXULUtils->GetEventHandlerIID(attr, &iid, &reset); + if (NS_FAILED(rv)) return rv; + } if (! reset) { if ((attr.get() == kPopupAtom) || @@ -2520,7 +2522,7 @@ nsXULElement::SetDocument(nsIDocument* aDocument, PRBool aDeep) if (! child) continue; - child->SetDocument(aDocument, aDeep); + child->SetDocument(aDocument, aDeep, aCompileEventHandlers); } } @@ -2625,7 +2627,7 @@ nsXULElement::InsertChildAt(nsIContent* aKid, PRInt32 aIndex, PRBool aNotify) //nsRange::OwnerChildInserted(this, aIndex); // N.B. that this is "shallow"! - aKid->SetDocument(mDocument, PR_FALSE); + aKid->SetDocument(mDocument, PR_FALSE, PR_TRUE); if (aNotify && mDocument) { mDocument->ContentInserted(NS_STATIC_CAST(nsIStyledContent*, this), aKid, aIndex); @@ -2668,7 +2670,7 @@ nsXULElement::ReplaceChildAt(nsIContent* aKid, PRInt32 aIndex, PRBool aNotify) // N.B. that we only do a "shallow" SetDocument() // here. Callers beware! - aKid->SetDocument(mDocument, PR_FALSE); + aKid->SetDocument(mDocument, PR_FALSE, PR_TRUE); if (aNotify && mDocument) { mDocument->ContentReplaced(NS_STATIC_CAST(nsIStyledContent*, this), oldKid, aKid, aIndex); @@ -2676,7 +2678,7 @@ nsXULElement::ReplaceChildAt(nsIContent* aKid, PRInt32 aIndex, PRBool aNotify) // This will cause the script object to be unrooted for each // element in the subtree. - oldKid->SetDocument(nsnull, PR_TRUE); + oldKid->SetDocument(nsnull, PR_TRUE, PR_TRUE); // We've got no mo' parent. oldKid->SetParent(nsnull); @@ -2704,7 +2706,7 @@ nsXULElement::AppendChildTo(nsIContent* aKid, PRBool aNotify) // ranges don't need adjustment since new child is at end of list // N.B. that this is only "shallow". Callers beware! - aKid->SetDocument(mDocument, PR_FALSE); + aKid->SetDocument(mDocument, PR_FALSE, PR_TRUE); if (aNotify && mDocument) { PRUint32 cnt; @@ -2813,7 +2815,7 @@ nsXULElement::RemoveChildAt(PRInt32 aIndex, PRBool aNotify) // This will cause the script object to be unrooted for each // element in the subtree. - oldKid->SetDocument(nsnull, PR_TRUE); + oldKid->SetDocument(nsnull, PR_TRUE, PR_TRUE); // We've got no mo' parent. oldKid->SetParent(nsnull); diff --git a/mozilla/rdf/content/src/nsXULElement.h b/mozilla/rdf/content/src/nsXULElement.h index bfe93a92298..8251da950ae 100644 --- a/mozilla/rdf/content/src/nsXULElement.h +++ b/mozilla/rdf/content/src/nsXULElement.h @@ -376,7 +376,7 @@ public: // nsIContent (from nsIStyledContent) NS_IMETHOD GetDocument(nsIDocument*& aResult) const; - NS_IMETHOD SetDocument(nsIDocument* aDocument, PRBool aDeep); + NS_IMETHOD SetDocument(nsIDocument* aDocument, PRBool aDeep, PRBool aCompileEventHandlers); NS_IMETHOD GetParent(nsIContent*& aResult) const; NS_IMETHOD SetParent(nsIContent* aParent); NS_IMETHOD CanContainChildren(PRBool& aResult) const; @@ -449,7 +449,7 @@ public: NS_IMETHOD ForceElementToOwnResource(PRBool aForce); NS_IMETHOD InitTemplateRoot(nsIRDFCompositeDataSource* aDatabase, nsIXULTemplateBuilder* aBuilder); - + // nsIDOMNode (from nsIDOMElement) NS_DECL_IDOMNODE diff --git a/mozilla/rdf/content/src/nsXULSortService.cpp b/mozilla/rdf/content/src/nsXULSortService.cpp index 56c769813ac..19973a4e379 100644 --- a/mozilla/rdf/content/src/nsXULSortService.cpp +++ b/mozilla/rdf/content/src/nsXULSortService.cpp @@ -1856,7 +1856,7 @@ XULSortServiceImpl::SortTreeChildren(nsIContent *container, sortPtr sortInfo) // Because InsertChildAt() only does a // "shallow" SetDocument(), we need to do a // "deep" one now... - kid->SetDocument(doc, PR_TRUE); + kid->SetDocument(doc, PR_TRUE, PR_TRUE); container->InsertChildAt(kid, childPos++, PR_FALSE); @@ -2371,7 +2371,7 @@ XULSortServiceImpl::DoSort(nsIDOMNode* node, const nsString& sortResource, // only does a shallow one. nsCOMPtr doc; treeParent->GetDocument(*getter_AddRefs(doc)); - treeBody->SetDocument(doc, PR_TRUE); + treeBody->SetDocument(doc, PR_TRUE, PR_TRUE); if (NS_FAILED(rv = treeParent->AppendChildTo(treeBody, PR_TRUE))) return(rv); diff --git a/mozilla/rdf/content/src/nsXULTemplateBuilder.cpp b/mozilla/rdf/content/src/nsXULTemplateBuilder.cpp index c0136b10d56..a8bb325858f 100644 --- a/mozilla/rdf/content/src/nsXULTemplateBuilder.cpp +++ b/mozilla/rdf/content/src/nsXULTemplateBuilder.cpp @@ -5540,7 +5540,7 @@ nsXULTemplateBuilder::RemoveMember(nsIContent* aContainerElement, // Set its document to null so that it'll get knocked out of // the XUL doc's resource-to-element map. - rv = child->SetDocument(nsnull, PR_TRUE); + rv = child->SetDocument(nsnull, PR_TRUE, PR_TRUE); if (NS_FAILED(rv)) return rv; // Remove from the content support map. @@ -5969,7 +5969,7 @@ nsXULTemplateBuilder::RemoveGeneratedContent(nsIContent* aElement) rv = aElement->RemoveChildAt(count, PR_TRUE); NS_ASSERTION(NS_SUCCEEDED(rv), "error removing child"); - rv = child->SetDocument(nsnull, PR_TRUE); + rv = child->SetDocument(nsnull, PR_TRUE, PR_TRUE); if (NS_FAILED(rv)) return rv; // Remove this and any children from the content support map. @@ -6168,7 +6168,7 @@ nsXULTemplateBuilder::CreateElement(PRInt32 aNameSpaceID, formControl->SetForm(form); } - rv = result->SetDocument(doc, PR_FALSE); + rv = result->SetDocument(doc, PR_FALSE, PR_TRUE); NS_ASSERTION(NS_SUCCEEDED(rv), "unable to set element's document"); if (NS_FAILED(rv)) return rv; diff --git a/mozilla/webshell/src/nsWebShell.cpp b/mozilla/webshell/src/nsWebShell.cpp index 2961d5faacf..4ccf8bf6e4c 100644 --- a/mozilla/webshell/src/nsWebShell.cpp +++ b/mozilla/webshell/src/nsWebShell.cpp @@ -1683,9 +1683,9 @@ NS_IMETHODIMP nsWebShell::SetDocument(nsIDOMDocument *aDOMDoc, // (5) hook up the document and its content nsCOMPtr rootContent = do_QueryInterface(aRootNode); if (!doc) { return NS_ERROR_OUT_OF_MEMORY; } - NS_ENSURE_SUCCESS(rootContent->SetDocument(doc, PR_FALSE), NS_ERROR_FAILURE); + NS_ENSURE_SUCCESS(rootContent->SetDocument(doc, PR_FALSE, PR_TRUE), NS_ERROR_FAILURE); doc->SetRootContent(rootContent); - rootContent->SetDocument(doc, PR_TRUE); + rootContent->SetDocument(doc, PR_TRUE, PR_TRUE); // (6) reflow the document PRInt32 i; diff --git a/mozilla/xpinstall/src/nsRegisterItem.cpp b/mozilla/xpinstall/src/nsRegisterItem.cpp index 60b39db99c5..237625fa93e 100644 --- a/mozilla/xpinstall/src/nsRegisterItem.cpp +++ b/mozilla/xpinstall/src/nsRegisterItem.cpp @@ -107,7 +107,7 @@ PRInt32 nsRegisterItem::Complete() if ( reg && !(mChromeType & CHROME_DELAYED) ) { if (mChromeType & CHROME_SKIN) - rv = reg->InstallSkin(mURL.GetBuffer(), isProfile); + rv = reg->InstallSkin(mURL.GetBuffer(), isProfile, PR_FALSE); if (mChromeType & CHROME_LOCALE) rv = reg->InstallLocale(mURL.GetBuffer(), isProfile); diff --git a/mozilla/xpinstall/src/nsSoftwareUpdateRun.cpp b/mozilla/xpinstall/src/nsSoftwareUpdateRun.cpp index 6514b4e2593..a62cf6ff10b 100644 --- a/mozilla/xpinstall/src/nsSoftwareUpdateRun.cpp +++ b/mozilla/xpinstall/src/nsSoftwareUpdateRun.cpp @@ -556,7 +556,7 @@ extern "C" void RunChromeInstallOnThread(void *data) if ( isSkin ) { - rv = reg->InstallSkin(spec.GetBuffer(), PR_TRUE); + rv = reg->InstallSkin(spec.GetBuffer(), PR_TRUE, PR_FALSE); if (NS_SUCCEEDED(rv) && selected) { rv = reg->SelectSkin(info->GetArguments(), PR_TRUE);