fix for making skins script-safe. r=scc

This commit is contained in:
hyatt%netscape.com 2000-05-19 04:48:43 +00:00
Родитель 5873c77a22
Коммит 5bed7dc4bd
91 изменённых файлов: 597 добавлений и 333 удалений

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

@ -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();
};

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

@ -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<nsIRDFLiteral> baseLiteral;
mRDFService->GetLiteral(unistr.GetUnicode(), getter_AddRefs(baseLiteral));
// Get the literal for our script access.
nsAutoString scriptstr;
scriptstr.AssignWithConversion("false");
nsCOMPtr<nsIRDFLiteral> 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<nsIRDFNode> 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<nsIRDFNode> selectedProvider;
nsCAutoString resourceStr("urn:mozilla:package:");
resourceStr += package;
// Obtain the resource.
nsCOMPtr<nsIRDFResource> 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))

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

@ -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<nsIRDFResource> mPackage;
nsCOMPtr<nsIRDFResource> mName;
nsCOMPtr<nsIRDFResource> mLocType;
nsCOMPtr<nsIRDFResource> mAllowScripts;
// Style Sheets
nsCOMPtr<nsICSSStyleSheet> mScrollbarSheet;

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

@ -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;

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

@ -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);

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

@ -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 {

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

@ -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;

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

@ -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

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

@ -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); \

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

@ -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)) {

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

@ -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); \
} \

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

@ -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);

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

@ -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);
}

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

@ -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,

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

@ -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

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

@ -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);
}
//----------------------------------------------------------------------

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

@ -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

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

@ -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

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

@ -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

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

@ -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

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

@ -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

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

@ -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

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

@ -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<nsIHTMLDocument> htmlDoc;

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

@ -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);
}
}

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

@ -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

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

@ -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

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

@ -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);

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

@ -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<nsIScriptGlobalObject> 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);
}

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

@ -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);

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

@ -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__

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

@ -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,7 +432,8 @@ nsXBLBinding::SetAnonymousContent(nsIContent* aParent)
// element's document.
nsCOMPtr<nsIDocument> 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.
@ -583,7 +588,7 @@ nsXBLBinding::InstallEventHandlers(nsIContent* aBoundElement)
nsCOMPtr<nsIContent> 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<nsIContent> interfaceElement;
GetImmediateChild(kInterfaceAtom, getter_AddRefs(interfaceElement));
if (interfaceElement) {
if (interfaceElement && AllowScripts()) {
// Get our bound element's script context.
nsresult rv;
nsCOMPtr<nsIDocument> document;
@ -1055,7 +1060,7 @@ nsXBLBinding::ChangeDocument(nsIDocument* aOldDocument, nsIDocument* aNewDocumen
nsCOMPtr<nsIContent> 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<nsIXBLService> xblService(do_GetService("component://netscape/xbl", &rv));
if (xblService) {
PRBool allowScripts;
xblService->AllowScripts(mBinding, &allowScripts);
return allowScripts;
}
return PR_FALSE;
}
// Creation Routine ///////////////////////////////////////////////////////////////////////
nsresult

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

@ -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<nsIDocument> 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,6 +446,9 @@ NS_IMETHODIMP nsXBLService::GetBinding(const nsCString& aURLStr, nsIXBLBinding**
// If no ref is specified just use this.
if ((bindingName.IsEmpty()) || (bindingName == value)) {
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
@ -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<nsIURL> 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<nsIChromeRegistry> 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;
}

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

@ -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);

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

@ -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);

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

@ -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);
@ -2405,7 +2405,7 @@ nsXULElement::GetDocument(nsIDocument*& aResult) const
}
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) {
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);

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

@ -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;

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

@ -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<nsIContent> 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;

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

@ -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<nsIDocument> 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);

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

@ -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;

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

@ -301,7 +301,7 @@ nsDocShell::SetDocument(nsIDOMDocument *aDOMDoc, nsIDOMElement *aRootNode)
// (5) hook up the document and its content
nsCOMPtr<nsIContent> 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

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

@ -1683,9 +1683,9 @@ NS_IMETHODIMP nsWebShell::SetDocument(nsIDOMDocument *aDOMDoc,
// (5) hook up the document and its content
nsCOMPtr<nsIContent> 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;

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

@ -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_

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

@ -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<nsIContent> 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<nsIDocument> 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;

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

@ -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;

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

@ -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);

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

@ -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 {

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

@ -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;

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

@ -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

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

@ -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); \

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

@ -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)) {

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

@ -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); \
} \

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

@ -2165,7 +2165,7 @@ nsComboboxControlFrame::CreateAnonymousContent(nsIPresContext* aPresContext,
nsCOMPtr<nsIDocument> doc;
mContent->GetDocument(*getter_AddRefs(doc));
/*
labelContent->SetDocument(doc, PR_FALSE);
labelContent->SetDocument(doc, PR_FALSE, PR_TRUE);
mContent->AppendChildTo(labelContent, PR_FALSE);
*/

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

@ -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);

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

@ -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);
}

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

@ -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,

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

@ -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

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

@ -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);
}
//----------------------------------------------------------------------

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

@ -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

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

@ -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

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

@ -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

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

@ -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

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

@ -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

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

@ -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

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

@ -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<nsIHTMLDocument> htmlDoc;

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

@ -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);
}
}

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

@ -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

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

@ -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

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

@ -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);

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

@ -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<nsIScriptGlobalObject> 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);
}

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

@ -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);

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

@ -2165,7 +2165,7 @@ nsComboboxControlFrame::CreateAnonymousContent(nsIPresContext* aPresContext,
nsCOMPtr<nsIDocument> doc;
mContent->GetDocument(*getter_AddRefs(doc));
/*
labelContent->SetDocument(doc, PR_FALSE);
labelContent->SetDocument(doc, PR_FALSE, PR_TRUE);
mContent->AppendChildTo(labelContent, PR_FALSE);
*/

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

@ -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);

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

@ -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<nsIContent> 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<nsIDocument> 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;

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

@ -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;

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

@ -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__

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

@ -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,7 +432,8 @@ nsXBLBinding::SetAnonymousContent(nsIContent* aParent)
// element's document.
nsCOMPtr<nsIDocument> 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.
@ -583,7 +588,7 @@ nsXBLBinding::InstallEventHandlers(nsIContent* aBoundElement)
nsCOMPtr<nsIContent> 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<nsIContent> interfaceElement;
GetImmediateChild(kInterfaceAtom, getter_AddRefs(interfaceElement));
if (interfaceElement) {
if (interfaceElement && AllowScripts()) {
// Get our bound element's script context.
nsresult rv;
nsCOMPtr<nsIDocument> document;
@ -1055,7 +1060,7 @@ nsXBLBinding::ChangeDocument(nsIDocument* aOldDocument, nsIDocument* aNewDocumen
nsCOMPtr<nsIContent> 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<nsIXBLService> xblService(do_GetService("component://netscape/xbl", &rv));
if (xblService) {
PRBool allowScripts;
xblService->AllowScripts(mBinding, &allowScripts);
return allowScripts;
}
return PR_FALSE;
}
// Creation Routine ///////////////////////////////////////////////////////////////////////
nsresult

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

@ -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<nsIDocument> 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,6 +446,9 @@ NS_IMETHODIMP nsXBLService::GetBinding(const nsCString& aURLStr, nsIXBLBinding**
// If no ref is specified just use this.
if ((bindingName.IsEmpty()) || (bindingName == value)) {
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
@ -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<nsIURL> 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<nsIChromeRegistry> 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;
}

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

@ -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);

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

@ -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);

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

@ -1683,7 +1683,7 @@ void nsTreeRowGroupFrame::CreateScrollbar(nsIPresContext* aPresContext)
document->CreateElement(NS_ConvertASCIItoUCS2("scrollbar"),getter_AddRefs(node));
nsCOMPtr<nsIContent> content = do_QueryInterface(node);
content->SetDocument(idocument, PR_FALSE);
content->SetDocument(idocument, PR_FALSE, PR_TRUE);
content->SetParent(mContent);
nsCOMPtr<nsIXULContent> xulContent = do_QueryInterface(content);

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

@ -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();
};

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

@ -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<nsIRDFLiteral> baseLiteral;
mRDFService->GetLiteral(unistr.GetUnicode(), getter_AddRefs(baseLiteral));
// Get the literal for our script access.
nsAutoString scriptstr;
scriptstr.AssignWithConversion("false");
nsCOMPtr<nsIRDFLiteral> 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<nsIRDFNode> 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<nsIRDFNode> selectedProvider;
nsCAutoString resourceStr("urn:mozilla:package:");
resourceStr += package;
// Obtain the resource.
nsCOMPtr<nsIRDFResource> 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))

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

@ -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<nsIRDFResource> mPackage;
nsCOMPtr<nsIRDFResource> mName;
nsCOMPtr<nsIRDFResource> mLocType;
nsCOMPtr<nsIRDFResource> mAllowScripts;
// Style Sheets
nsCOMPtr<nsICSSStyleSheet> mScrollbarSheet;

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

@ -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<nsIContent> 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;

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

@ -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);
@ -2405,7 +2405,7 @@ nsXULElement::GetDocument(nsIDocument*& aResult) const
}
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) {
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);

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

@ -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;

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

@ -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<nsIDocument> 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);

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

@ -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;

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

@ -1683,9 +1683,9 @@ NS_IMETHODIMP nsWebShell::SetDocument(nsIDOMDocument *aDOMDoc,
// (5) hook up the document and its content
nsCOMPtr<nsIContent> 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;

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

@ -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);

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

@ -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);