43220. r=ben
This commit is contained in:
Родитель
d23cc4538f
Коммит
1a375f2282
|
@ -92,6 +92,7 @@ interface nsIChromeRegistry : nsISupports
|
|||
void uninstallPackage(in wstring packageName, in boolean useProfile);
|
||||
|
||||
void getBackstopSheets(out nsISupportsArray styleSheets);
|
||||
void getUserSheets(in boolean useChromeSheets, out nsISupportsArray styleSheets);
|
||||
|
||||
boolean allowScriptsForSkin(in nsIURI url);
|
||||
|
||||
|
|
|
@ -472,12 +472,18 @@ nsChromeRegistry::ConvertChromeURL(nsIURI* aChromeURL, char** aResult)
|
|||
// This must always be the last line of profile initialization!
|
||||
|
||||
nsCAutoString userSheetURL;
|
||||
rv = GetUserSheetURL(userSheetURL);
|
||||
rv = GetUserSheetURL(PR_TRUE, userSheetURL);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
if(!userSheetURL.IsEmpty()) {
|
||||
(void)LoadStyleSheet(getter_AddRefs(mUserSheet), userSheetURL);
|
||||
(void)LoadStyleSheet(getter_AddRefs(mUserChromeSheet), userSheetURL);
|
||||
// it's ok to not have a user.css file
|
||||
}
|
||||
rv = GetUserSheetURL(PR_FALSE, userSheetURL);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
if(!userSheetURL.IsEmpty()) {
|
||||
(void)LoadStyleSheet(getter_AddRefs(mUserContentSheet), userSheetURL);
|
||||
// it's ok not to have a userContent.css or userChrome.css file
|
||||
}
|
||||
}
|
||||
else if (!mInstallInitialized) {
|
||||
// Load the installed search path for skins, content, and locales
|
||||
|
@ -2256,7 +2262,7 @@ nsChromeRegistry::GetBackstopSheets(nsISupportsArray **aResult)
|
|||
if (NS_FAILED(rv)) return rv;
|
||||
}
|
||||
|
||||
if(mScrollbarSheet || mUserSheet)
|
||||
if(mScrollbarSheet)
|
||||
{
|
||||
rv = NS_NewISupportsArray(aResult);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
@ -2264,9 +2270,26 @@ nsChromeRegistry::GetBackstopSheets(nsISupportsArray **aResult)
|
|||
rv = (*aResult)->AppendElement(mScrollbarSheet) ? NS_OK : NS_ERROR_FAILURE;
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
}
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsChromeRegistry::GetUserSheets(PRBool aIsChrome, nsISupportsArray **aResult)
|
||||
{
|
||||
nsresult rv;
|
||||
|
||||
if((aIsChrome && mUserChromeSheet) || (!aIsChrome && mUserContentSheet))
|
||||
{
|
||||
rv = NS_NewISupportsArray(aResult);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
if(aIsChrome && mUserChromeSheet) {
|
||||
rv = (*aResult)->AppendElement(mUserChromeSheet) ? NS_OK : NS_ERROR_FAILURE;
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
}
|
||||
|
||||
if(mUserSheet) {
|
||||
rv = (*aResult)->AppendElement(mUserSheet) ? NS_OK : NS_ERROR_FAILURE;
|
||||
if(!aIsChrome && mUserContentSheet) {
|
||||
rv = (*aResult)->AppendElement(mUserContentSheet) ? NS_OK : NS_ERROR_FAILURE;
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
}
|
||||
}
|
||||
|
@ -2305,12 +2328,14 @@ nsresult nsChromeRegistry::LoadStyleSheetWithURL(nsIURI* aURL, nsICSSStyleSheet*
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult nsChromeRegistry::GetUserSheetURL(nsCString & aURL)
|
||||
nsresult nsChromeRegistry::GetUserSheetURL(PRBool aIsChrome, nsCString & aURL)
|
||||
{
|
||||
aURL = mProfileRoot;
|
||||
aURL.Append("user.css");
|
||||
return NS_OK;
|
||||
if (aIsChrome)
|
||||
aURL.Append("userChrome.css");
|
||||
else aURL.Append("userContent.css");
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsChromeRegistry::AllowScriptsForSkin(nsIURI* aChromeURI, PRBool *aResult)
|
||||
|
|
|
@ -74,7 +74,7 @@ protected:
|
|||
nsresult LoadStyleSheet(nsICSSStyleSheet** aSheet, const nsCString & aURL);
|
||||
nsresult LoadStyleSheetWithURL(nsIURI* aURL, nsICSSStyleSheet** aSheet);
|
||||
|
||||
nsresult GetUserSheetURL(nsCString & aURL);
|
||||
nsresult GetUserSheetURL(PRBool aIsChrome, nsCString & aURL);
|
||||
|
||||
private:
|
||||
NS_IMETHOD LoadDataSource(const nsCString &aFileName, nsIRDFDataSource **aResult,
|
||||
|
@ -157,5 +157,6 @@ protected:
|
|||
|
||||
// Style Sheets
|
||||
nsCOMPtr<nsICSSStyleSheet> mScrollbarSheet;
|
||||
nsCOMPtr<nsICSSStyleSheet> mUserSheet;
|
||||
nsCOMPtr<nsICSSStyleSheet> mUserChromeSheet;
|
||||
nsCOMPtr<nsICSSStyleSheet> mUserContentSheet;
|
||||
};
|
||||
|
|
|
@ -995,6 +995,25 @@ DocumentViewerImpl::CreateStyleSet(nsIDocument* aDocument,
|
|||
(*aStyleSet)->AppendBackstopStyleSheet(sheet);
|
||||
}
|
||||
}
|
||||
|
||||
// Now handle the user sheets.
|
||||
nsCOMPtr<nsIDocShellTreeItem> docShell(do_QueryInterface(mContainer));
|
||||
PRInt32 shellType;
|
||||
docShell->GetItemType(&shellType);
|
||||
PRBool isChrome = (shellType == nsIDocShellTreeItem::typeChrome);
|
||||
sheets = nsnull;
|
||||
chromeRegistry->GetUserSheets(isChrome, getter_AddRefs(sheets));
|
||||
if(sheets){
|
||||
nsCOMPtr<nsICSSStyleSheet> sheet;
|
||||
PRUint32 count;
|
||||
sheets->Count(&count);
|
||||
for(PRUint32 i=0; i<count; i++) {
|
||||
sheets->GetElementAt(i, getter_AddRefs(sheet));
|
||||
// XXX For now, append as backstop until we figure out something
|
||||
// better to do.
|
||||
(*aStyleSet)->AppendBackstopStyleSheet(sheet);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (mUAStyleSheet) {
|
||||
|
|
|
@ -995,6 +995,25 @@ DocumentViewerImpl::CreateStyleSet(nsIDocument* aDocument,
|
|||
(*aStyleSet)->AppendBackstopStyleSheet(sheet);
|
||||
}
|
||||
}
|
||||
|
||||
// Now handle the user sheets.
|
||||
nsCOMPtr<nsIDocShellTreeItem> docShell(do_QueryInterface(mContainer));
|
||||
PRInt32 shellType;
|
||||
docShell->GetItemType(&shellType);
|
||||
PRBool isChrome = (shellType == nsIDocShellTreeItem::typeChrome);
|
||||
sheets = nsnull;
|
||||
chromeRegistry->GetUserSheets(isChrome, getter_AddRefs(sheets));
|
||||
if(sheets){
|
||||
nsCOMPtr<nsICSSStyleSheet> sheet;
|
||||
PRUint32 count;
|
||||
sheets->Count(&count);
|
||||
for(PRUint32 i=0; i<count; i++) {
|
||||
sheets->GetElementAt(i, getter_AddRefs(sheet));
|
||||
// XXX For now, append as backstop until we figure out something
|
||||
// better to do.
|
||||
(*aStyleSet)->AppendBackstopStyleSheet(sheet);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (mUAStyleSheet) {
|
||||
|
|
|
@ -995,6 +995,25 @@ DocumentViewerImpl::CreateStyleSet(nsIDocument* aDocument,
|
|||
(*aStyleSet)->AppendBackstopStyleSheet(sheet);
|
||||
}
|
||||
}
|
||||
|
||||
// Now handle the user sheets.
|
||||
nsCOMPtr<nsIDocShellTreeItem> docShell(do_QueryInterface(mContainer));
|
||||
PRInt32 shellType;
|
||||
docShell->GetItemType(&shellType);
|
||||
PRBool isChrome = (shellType == nsIDocShellTreeItem::typeChrome);
|
||||
sheets = nsnull;
|
||||
chromeRegistry->GetUserSheets(isChrome, getter_AddRefs(sheets));
|
||||
if(sheets){
|
||||
nsCOMPtr<nsICSSStyleSheet> sheet;
|
||||
PRUint32 count;
|
||||
sheets->Count(&count);
|
||||
for(PRUint32 i=0; i<count; i++) {
|
||||
sheets->GetElementAt(i, getter_AddRefs(sheet));
|
||||
// XXX For now, append as backstop until we figure out something
|
||||
// better to do.
|
||||
(*aStyleSet)->AppendBackstopStyleSheet(sheet);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (mUAStyleSheet) {
|
||||
|
|
|
@ -92,6 +92,7 @@ interface nsIChromeRegistry : nsISupports
|
|||
void uninstallPackage(in wstring packageName, in boolean useProfile);
|
||||
|
||||
void getBackstopSheets(out nsISupportsArray styleSheets);
|
||||
void getUserSheets(in boolean useChromeSheets, out nsISupportsArray styleSheets);
|
||||
|
||||
boolean allowScriptsForSkin(in nsIURI url);
|
||||
|
||||
|
|
|
@ -472,12 +472,18 @@ nsChromeRegistry::ConvertChromeURL(nsIURI* aChromeURL, char** aResult)
|
|||
// This must always be the last line of profile initialization!
|
||||
|
||||
nsCAutoString userSheetURL;
|
||||
rv = GetUserSheetURL(userSheetURL);
|
||||
rv = GetUserSheetURL(PR_TRUE, userSheetURL);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
if(!userSheetURL.IsEmpty()) {
|
||||
(void)LoadStyleSheet(getter_AddRefs(mUserSheet), userSheetURL);
|
||||
(void)LoadStyleSheet(getter_AddRefs(mUserChromeSheet), userSheetURL);
|
||||
// it's ok to not have a user.css file
|
||||
}
|
||||
rv = GetUserSheetURL(PR_FALSE, userSheetURL);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
if(!userSheetURL.IsEmpty()) {
|
||||
(void)LoadStyleSheet(getter_AddRefs(mUserContentSheet), userSheetURL);
|
||||
// it's ok not to have a userContent.css or userChrome.css file
|
||||
}
|
||||
}
|
||||
else if (!mInstallInitialized) {
|
||||
// Load the installed search path for skins, content, and locales
|
||||
|
@ -2256,7 +2262,7 @@ nsChromeRegistry::GetBackstopSheets(nsISupportsArray **aResult)
|
|||
if (NS_FAILED(rv)) return rv;
|
||||
}
|
||||
|
||||
if(mScrollbarSheet || mUserSheet)
|
||||
if(mScrollbarSheet)
|
||||
{
|
||||
rv = NS_NewISupportsArray(aResult);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
@ -2264,9 +2270,26 @@ nsChromeRegistry::GetBackstopSheets(nsISupportsArray **aResult)
|
|||
rv = (*aResult)->AppendElement(mScrollbarSheet) ? NS_OK : NS_ERROR_FAILURE;
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
}
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsChromeRegistry::GetUserSheets(PRBool aIsChrome, nsISupportsArray **aResult)
|
||||
{
|
||||
nsresult rv;
|
||||
|
||||
if((aIsChrome && mUserChromeSheet) || (!aIsChrome && mUserContentSheet))
|
||||
{
|
||||
rv = NS_NewISupportsArray(aResult);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
if(aIsChrome && mUserChromeSheet) {
|
||||
rv = (*aResult)->AppendElement(mUserChromeSheet) ? NS_OK : NS_ERROR_FAILURE;
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
}
|
||||
|
||||
if(mUserSheet) {
|
||||
rv = (*aResult)->AppendElement(mUserSheet) ? NS_OK : NS_ERROR_FAILURE;
|
||||
if(!aIsChrome && mUserContentSheet) {
|
||||
rv = (*aResult)->AppendElement(mUserContentSheet) ? NS_OK : NS_ERROR_FAILURE;
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
}
|
||||
}
|
||||
|
@ -2305,12 +2328,14 @@ nsresult nsChromeRegistry::LoadStyleSheetWithURL(nsIURI* aURL, nsICSSStyleSheet*
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult nsChromeRegistry::GetUserSheetURL(nsCString & aURL)
|
||||
nsresult nsChromeRegistry::GetUserSheetURL(PRBool aIsChrome, nsCString & aURL)
|
||||
{
|
||||
aURL = mProfileRoot;
|
||||
aURL.Append("user.css");
|
||||
return NS_OK;
|
||||
if (aIsChrome)
|
||||
aURL.Append("userChrome.css");
|
||||
else aURL.Append("userContent.css");
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsChromeRegistry::AllowScriptsForSkin(nsIURI* aChromeURI, PRBool *aResult)
|
||||
|
|
|
@ -74,7 +74,7 @@ protected:
|
|||
nsresult LoadStyleSheet(nsICSSStyleSheet** aSheet, const nsCString & aURL);
|
||||
nsresult LoadStyleSheetWithURL(nsIURI* aURL, nsICSSStyleSheet** aSheet);
|
||||
|
||||
nsresult GetUserSheetURL(nsCString & aURL);
|
||||
nsresult GetUserSheetURL(PRBool aIsChrome, nsCString & aURL);
|
||||
|
||||
private:
|
||||
NS_IMETHOD LoadDataSource(const nsCString &aFileName, nsIRDFDataSource **aResult,
|
||||
|
@ -157,5 +157,6 @@ protected:
|
|||
|
||||
// Style Sheets
|
||||
nsCOMPtr<nsICSSStyleSheet> mScrollbarSheet;
|
||||
nsCOMPtr<nsICSSStyleSheet> mUserSheet;
|
||||
nsCOMPtr<nsICSSStyleSheet> mUserChromeSheet;
|
||||
nsCOMPtr<nsICSSStyleSheet> mUserContentSheet;
|
||||
};
|
||||
|
|
Загрузка…
Ссылка в новой задаче