Bug 676054 - part2: Provide AUTHOR_SHEET type for registering with nsIStyleSheetService. r=bz

This commit is contained in:
Gabor Krizsanits
2012-10-16 21:45:50 +02:00
parent afbd2a2c0d
commit 2766760a79
9 changed files with 131 additions and 9 deletions

View File

@@ -880,8 +880,10 @@ PresShell::Init(nsIDocument* aDocument,
if (os) {
os->AddObserver(this, "agent-sheet-added", false);
os->AddObserver(this, "user-sheet-added", false);
os->AddObserver(this, "author-sheet-added", false);
os->AddObserver(this, "agent-sheet-removed", false);
os->AddObserver(this, "user-sheet-removed", false);
os->AddObserver(this, "author-sheet-removed", false);
#ifdef MOZ_XUL
os->AddObserver(this, "chrome-flush-skin-caches", false);
#endif
@@ -970,8 +972,10 @@ PresShell::Destroy()
if (os) {
os->RemoveObserver(this, "agent-sheet-added");
os->RemoveObserver(this, "user-sheet-added");
os->RemoveObserver(this, "author-sheet-added");
os->RemoveObserver(this, "agent-sheet-removed");
os->RemoveObserver(this, "user-sheet-removed");
os->RemoveObserver(this, "author-sheet-removed");
#ifdef MOZ_XUL
os->RemoveObserver(this, "chrome-flush-skin-caches");
#endif
@@ -1510,6 +1514,18 @@ PresShell::AddAgentSheet(nsISupports* aSheet)
ReconstructStyleData();
}
void
PresShell::AddAuthorSheet(nsISupports* aSheet)
{
nsCOMPtr<nsIStyleSheet> sheet = do_QueryInterface(aSheet);
if (!sheet) {
return;
}
mStyleSet->AppendStyleSheet(nsStyleSet::eDocSheet, sheet);
ReconstructStyleData();
}
void
PresShell::RemoveSheet(nsStyleSet::sheetType aType, nsISupports* aSheet)
{
@@ -7752,6 +7768,11 @@ PresShell::Observe(nsISupports* aSubject,
return NS_OK;
}
if (!nsCRT::strcmp(aTopic, "author-sheet-added") && mStyleSet) {
AddAuthorSheet(aSubject);
return NS_OK;
}
if (!nsCRT::strcmp(aTopic, "agent-sheet-removed") && mStyleSet) {
RemoveSheet(nsStyleSet::eAgentSheet, aSubject);
return NS_OK;
@@ -7762,6 +7783,11 @@ PresShell::Observe(nsISupports* aSubject,
return NS_OK;
}
if (!nsCRT::strcmp(aTopic, "author-sheet-removed") && mStyleSet) {
RemoveSheet(nsStyleSet::eDocSheet, aSubject);
return NS_OK;
}
NS_WARNING("unrecognized topic in PresShell::Observe");
return NS_ERROR_FAILURE;
}