зеркало из https://github.com/mozilla/pjs.git
Adding support for backstop style sheets
This commit is contained in:
Родитель
3d7518c01b
Коммит
faa66dfaa7
|
@ -86,6 +86,8 @@ interface nsIChromeRegistry : nsISupports
|
|||
|
||||
void installPackage(in string baseURL, in boolean useProfile);
|
||||
void uninstallPackage(in wstring packageName, in boolean useProfile);
|
||||
|
||||
void getBackstopSheets(out nsISupportsArray styleSheets);
|
||||
};
|
||||
|
||||
|
||||
|
|
|
@ -69,6 +69,7 @@
|
|||
#include "nsINameSpaceManager.h"
|
||||
#include "nsIIOService.h"
|
||||
#include "nsIResProtocolHandler.h"
|
||||
#include "nsLayoutCID.h"
|
||||
|
||||
static char kChromePrefix[] = "chrome://";
|
||||
|
||||
|
@ -76,6 +77,7 @@ static NS_DEFINE_CID(kWindowMediatorCID, NS_WINDOWMEDIATOR_CID);
|
|||
static NS_DEFINE_CID(kRDFServiceCID, NS_RDFSERVICE_CID);
|
||||
static NS_DEFINE_CID(kRDFXMLDataSourceCID, NS_RDFXMLDATASOURCE_CID);
|
||||
static NS_DEFINE_CID(kRDFContainerUtilsCID, NS_RDFCONTAINERUTILS_CID);
|
||||
static NS_DEFINE_CID(kCSSLoaderCID, NS_CSS_LOADER_CID);
|
||||
|
||||
class nsChromeRegistry;
|
||||
|
||||
|
@ -381,6 +383,9 @@ nsChromeRegistry::ConvertChromeURL(nsIURI* aChromeURL)
|
|||
if (NS_SUCCEEDED(rv)) {
|
||||
mInstallInitialized = PR_TRUE;
|
||||
AddToCompositeDataSource(PR_FALSE);
|
||||
|
||||
LoadStyleSheet(getter_AddRefs(mScrollbarSheet), "chrome://global/skin/scrollbars.css");
|
||||
// This must always be the last line of install initialization!
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -393,6 +398,15 @@ nsChromeRegistry::ConvertChromeURL(nsIURI* aChromeURL)
|
|||
mProfileInitialized = PR_TRUE;
|
||||
mChromeDataSource = nsnull;
|
||||
AddToCompositeDataSource(PR_TRUE);
|
||||
|
||||
LoadStyleSheet(getter_AddRefs(mScrollbarSheet), "chrome://global/skin/scrollbars.css");
|
||||
// This must always be the last line of profile initialization!
|
||||
|
||||
nsCAutoString userSheetURL;
|
||||
GetUserSheetURL(userSheetURL);
|
||||
if(!userSheetURL.IsEmpty()) {
|
||||
LoadStyleSheet(getter_AddRefs(mUserSheet), userSheetURL);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1030,6 +1044,9 @@ NS_IMETHODIMP nsChromeRegistry::SetProvider(const nsCAutoString& aProvider,
|
|||
arcs->HasMoreElements(&more);
|
||||
}
|
||||
|
||||
if(aProvider.Equals("skin")){
|
||||
LoadStyleSheet(getter_AddRefs(mScrollbarSheet), "chrome://global/skin/scrollbars.css");
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
@ -1585,6 +1602,51 @@ nsChromeRegistry::AddToCompositeDataSource(PRBool aUseProfile)
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsChromeRegistry::GetBackstopSheets(nsISupportsArray **aResult)
|
||||
{
|
||||
if(mScrollbarSheet || mUserSheet)
|
||||
{
|
||||
NS_NewISupportsArray(aResult);
|
||||
if(mScrollbarSheet)
|
||||
(*aResult)->AppendElement(mScrollbarSheet);
|
||||
|
||||
if(mUserSheet)
|
||||
(*aResult)->AppendElement(mUserSheet);
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
void nsChromeRegistry::LoadStyleSheet(nsICSSStyleSheet** aSheet, const nsCString& aURL)
|
||||
{
|
||||
// Load scrollbar style sheet
|
||||
nsresult rv;
|
||||
|
||||
nsCOMPtr<nsICSSLoader> loader;
|
||||
rv = nsComponentManager::CreateInstance(kCSSLoaderCID,
|
||||
nsnull,
|
||||
NS_GET_IID(nsICSSLoader),
|
||||
getter_AddRefs(loader));
|
||||
if(loader) {
|
||||
nsCOMPtr<nsIURL> url;
|
||||
rv = nsComponentManager::CreateInstance("component://netscape/network/standard-url",
|
||||
nsnull,
|
||||
NS_GET_IID(nsIURL),
|
||||
getter_AddRefs(url));
|
||||
if(url) {
|
||||
url->SetSpec(aURL);
|
||||
PRBool complete;
|
||||
rv = loader->LoadAgentSheet(url, *aSheet, complete,
|
||||
nsnull);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void nsChromeRegistry::GetUserSheetURL(nsCString & aURL)
|
||||
{
|
||||
aURL = mProfileRoot + "user.css";
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
|
||||
nsresult
|
||||
|
|
|
@ -35,6 +35,7 @@ class nsIDOMWindow;
|
|||
class nsIDocument;
|
||||
|
||||
#include "nsIRDFCompositeDataSource.h"
|
||||
#include "nsICSSStyleSheet.h"
|
||||
|
||||
class nsChromeRegistry : public nsIChromeRegistry
|
||||
{
|
||||
|
@ -63,6 +64,9 @@ protected:
|
|||
nsAutoString aProvider,
|
||||
nsIRDFContainer *aContainer,
|
||||
nsIRDFDataSource *aDataSource);
|
||||
|
||||
void LoadStyleSheet(nsICSSStyleSheet** aSheet, const nsCString & aURL);
|
||||
void GetUserSheetURL(nsCString & aURL);
|
||||
|
||||
private:
|
||||
NS_IMETHOD ReallyRemoveOverlayFromDataSource(const PRUnichar *aDocURI, char *aOverlayURI);
|
||||
|
@ -127,4 +131,8 @@ protected:
|
|||
nsCOMPtr<nsIRDFResource> mBaseURL;
|
||||
nsCOMPtr<nsIRDFResource> mPackages;
|
||||
nsCOMPtr<nsIRDFResource> mPackage;
|
||||
|
||||
// Style Sheets
|
||||
nsCOMPtr<nsICSSStyleSheet> mScrollbarSheet;
|
||||
nsCOMPtr<nsICSSStyleSheet> mUserSheet;
|
||||
};
|
||||
|
|
|
@ -86,6 +86,8 @@ interface nsIChromeRegistry : nsISupports
|
|||
|
||||
void installPackage(in string baseURL, in boolean useProfile);
|
||||
void uninstallPackage(in wstring packageName, in boolean useProfile);
|
||||
|
||||
void getBackstopSheets(out nsISupportsArray styleSheets);
|
||||
};
|
||||
|
||||
|
||||
|
|
|
@ -69,6 +69,7 @@
|
|||
#include "nsINameSpaceManager.h"
|
||||
#include "nsIIOService.h"
|
||||
#include "nsIResProtocolHandler.h"
|
||||
#include "nsLayoutCID.h"
|
||||
|
||||
static char kChromePrefix[] = "chrome://";
|
||||
|
||||
|
@ -76,6 +77,7 @@ static NS_DEFINE_CID(kWindowMediatorCID, NS_WINDOWMEDIATOR_CID);
|
|||
static NS_DEFINE_CID(kRDFServiceCID, NS_RDFSERVICE_CID);
|
||||
static NS_DEFINE_CID(kRDFXMLDataSourceCID, NS_RDFXMLDATASOURCE_CID);
|
||||
static NS_DEFINE_CID(kRDFContainerUtilsCID, NS_RDFCONTAINERUTILS_CID);
|
||||
static NS_DEFINE_CID(kCSSLoaderCID, NS_CSS_LOADER_CID);
|
||||
|
||||
class nsChromeRegistry;
|
||||
|
||||
|
@ -381,6 +383,9 @@ nsChromeRegistry::ConvertChromeURL(nsIURI* aChromeURL)
|
|||
if (NS_SUCCEEDED(rv)) {
|
||||
mInstallInitialized = PR_TRUE;
|
||||
AddToCompositeDataSource(PR_FALSE);
|
||||
|
||||
LoadStyleSheet(getter_AddRefs(mScrollbarSheet), "chrome://global/skin/scrollbars.css");
|
||||
// This must always be the last line of install initialization!
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -393,6 +398,15 @@ nsChromeRegistry::ConvertChromeURL(nsIURI* aChromeURL)
|
|||
mProfileInitialized = PR_TRUE;
|
||||
mChromeDataSource = nsnull;
|
||||
AddToCompositeDataSource(PR_TRUE);
|
||||
|
||||
LoadStyleSheet(getter_AddRefs(mScrollbarSheet), "chrome://global/skin/scrollbars.css");
|
||||
// This must always be the last line of profile initialization!
|
||||
|
||||
nsCAutoString userSheetURL;
|
||||
GetUserSheetURL(userSheetURL);
|
||||
if(!userSheetURL.IsEmpty()) {
|
||||
LoadStyleSheet(getter_AddRefs(mUserSheet), userSheetURL);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1030,6 +1044,9 @@ NS_IMETHODIMP nsChromeRegistry::SetProvider(const nsCAutoString& aProvider,
|
|||
arcs->HasMoreElements(&more);
|
||||
}
|
||||
|
||||
if(aProvider.Equals("skin")){
|
||||
LoadStyleSheet(getter_AddRefs(mScrollbarSheet), "chrome://global/skin/scrollbars.css");
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
@ -1585,6 +1602,51 @@ nsChromeRegistry::AddToCompositeDataSource(PRBool aUseProfile)
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsChromeRegistry::GetBackstopSheets(nsISupportsArray **aResult)
|
||||
{
|
||||
if(mScrollbarSheet || mUserSheet)
|
||||
{
|
||||
NS_NewISupportsArray(aResult);
|
||||
if(mScrollbarSheet)
|
||||
(*aResult)->AppendElement(mScrollbarSheet);
|
||||
|
||||
if(mUserSheet)
|
||||
(*aResult)->AppendElement(mUserSheet);
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
void nsChromeRegistry::LoadStyleSheet(nsICSSStyleSheet** aSheet, const nsCString& aURL)
|
||||
{
|
||||
// Load scrollbar style sheet
|
||||
nsresult rv;
|
||||
|
||||
nsCOMPtr<nsICSSLoader> loader;
|
||||
rv = nsComponentManager::CreateInstance(kCSSLoaderCID,
|
||||
nsnull,
|
||||
NS_GET_IID(nsICSSLoader),
|
||||
getter_AddRefs(loader));
|
||||
if(loader) {
|
||||
nsCOMPtr<nsIURL> url;
|
||||
rv = nsComponentManager::CreateInstance("component://netscape/network/standard-url",
|
||||
nsnull,
|
||||
NS_GET_IID(nsIURL),
|
||||
getter_AddRefs(url));
|
||||
if(url) {
|
||||
url->SetSpec(aURL);
|
||||
PRBool complete;
|
||||
rv = loader->LoadAgentSheet(url, *aSheet, complete,
|
||||
nsnull);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void nsChromeRegistry::GetUserSheetURL(nsCString & aURL)
|
||||
{
|
||||
aURL = mProfileRoot + "user.css";
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
|
||||
nsresult
|
||||
|
|
|
@ -35,6 +35,7 @@ class nsIDOMWindow;
|
|||
class nsIDocument;
|
||||
|
||||
#include "nsIRDFCompositeDataSource.h"
|
||||
#include "nsICSSStyleSheet.h"
|
||||
|
||||
class nsChromeRegistry : public nsIChromeRegistry
|
||||
{
|
||||
|
@ -63,6 +64,9 @@ protected:
|
|||
nsAutoString aProvider,
|
||||
nsIRDFContainer *aContainer,
|
||||
nsIRDFDataSource *aDataSource);
|
||||
|
||||
void LoadStyleSheet(nsICSSStyleSheet** aSheet, const nsCString & aURL);
|
||||
void GetUserSheetURL(nsCString & aURL);
|
||||
|
||||
private:
|
||||
NS_IMETHOD ReallyRemoveOverlayFromDataSource(const PRUnichar *aDocURI, char *aOverlayURI);
|
||||
|
@ -127,4 +131,8 @@ protected:
|
|||
nsCOMPtr<nsIRDFResource> mBaseURL;
|
||||
nsCOMPtr<nsIRDFResource> mPackages;
|
||||
nsCOMPtr<nsIRDFResource> mPackage;
|
||||
|
||||
// Style Sheets
|
||||
nsCOMPtr<nsICSSStyleSheet> mScrollbarSheet;
|
||||
nsCOMPtr<nsICSSStyleSheet> mUserSheet;
|
||||
};
|
||||
|
|
|
@ -6,8 +6,6 @@
|
|||
CHANGES REVIEWED BY hyatt@netscape.com.
|
||||
**/
|
||||
|
||||
@import url(chrome://global/skin/scrollbars.css);
|
||||
|
||||
@namespace url(http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul); /* set default namespace to XUL */
|
||||
@namespace html url("http://www.w3.org/TR/REC-html40"); /* namespace for HTML elements */
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче