зеркало из https://github.com/mozilla/pjs.git
More skin goodness. r=gimpy
This commit is contained in:
Родитель
030dabc043
Коммит
ce7a5655c1
|
@ -23,23 +23,28 @@
|
||||||
#include "nsISupports.idl"
|
#include "nsISupports.idl"
|
||||||
#include "nsIURL.idl"
|
#include "nsIURL.idl"
|
||||||
#include "nsIEnumerator.idl"
|
#include "nsIEnumerator.idl"
|
||||||
|
#include "nsISupportsArray.idl"
|
||||||
|
|
||||||
[scriptable, uuid(D8C7D8A1-E84C-11d2-BF87-00105A1B0627)]
|
[scriptable, uuid(D8C7D8A1-E84C-11d2-BF87-00105A1B0627)]
|
||||||
interface nsIChromeRegistry : nsISupports
|
interface nsIChromeRegistry : nsISupports
|
||||||
{
|
{
|
||||||
void convertChromeURL(in nsIURI aChromeURL);
|
void convertChromeURL(in nsIURI aChromeURL);
|
||||||
nsISimpleEnumerator getOverlays(in nsIURI aChromeURL);
|
nsISimpleEnumerator getOverlays(in nsIURI aChromeURL);
|
||||||
|
|
||||||
void reloadChrome();
|
void reloadChrome();
|
||||||
void refreshSkins();
|
void refreshSkins();
|
||||||
|
|
||||||
void applyTheme(in wstring themeFileName);
|
void applyTheme(in wstring themeName);
|
||||||
|
|
||||||
void setSkin(in wstring skinFileName, in wstring packageName);
|
void setSkin(in wstring skinName, in wstring packageName);
|
||||||
void setLocale(in wstring localeFileName, in wstring packageName);
|
void setLocale(in wstring localeName, in wstring packageName);
|
||||||
|
|
||||||
void setDefaultSkin(in wstring skinFileName, in wstring packageName);
|
void setDefaultSkin(in wstring skinName, in wstring packageName);
|
||||||
void setDefaultLocale(in wstring localeFileName, in wstring packageName);
|
void setDefaultLocale(in wstring localeName, in wstring packageName);
|
||||||
|
|
||||||
|
readonly attribute nsISupportsArray skins;
|
||||||
|
readonly attribute nsISupportsArray packages;
|
||||||
|
readonly attribute nsISupportsArray locales;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -42,7 +42,10 @@
|
||||||
#include "nsNetUtil.h"
|
#include "nsNetUtil.h"
|
||||||
#include "nsFileLocations.h"
|
#include "nsFileLocations.h"
|
||||||
#include "nsIFileLocator.h"
|
#include "nsIFileLocator.h"
|
||||||
|
#include "nsPIDOMWindow.h"
|
||||||
#include "nsIDOMWindow.h"
|
#include "nsIDOMWindow.h"
|
||||||
|
#include "nsIDOMWindowCollection.h"
|
||||||
|
#include "nsIDOMLocation.h"
|
||||||
#include "nsIWindowMediator.h"
|
#include "nsIWindowMediator.h"
|
||||||
#include "nsIDocument.h"
|
#include "nsIDocument.h"
|
||||||
#include "nsIDOMDocument.h"
|
#include "nsIDOMDocument.h"
|
||||||
|
@ -56,6 +59,8 @@
|
||||||
#include "nsISupportsArray.h"
|
#include "nsISupportsArray.h"
|
||||||
#include "nsICSSLoader.h"
|
#include "nsICSSLoader.h"
|
||||||
#include "nsIDocumentObserver.h"
|
#include "nsIDocumentObserver.h"
|
||||||
|
#include "nsIXULDocument.h"
|
||||||
|
#include "nsINameSpaceManager.h"
|
||||||
|
|
||||||
static NS_DEFINE_CID(kWindowMediatorCID, NS_WINDOWMEDIATOR_CID);
|
static NS_DEFINE_CID(kWindowMediatorCID, NS_WINDOWMEDIATOR_CID);
|
||||||
static NS_DEFINE_CID(kRDFServiceCID, NS_RDFSERVICE_CID);
|
static NS_DEFINE_CID(kRDFServiceCID, NS_RDFSERVICE_CID);
|
||||||
|
@ -199,8 +204,6 @@ protected:
|
||||||
nsIRDFContainer *aContainer,
|
nsIRDFContainer *aContainer,
|
||||||
nsIRDFDataSource *aDataSource);
|
nsIRDFDataSource *aDataSource);
|
||||||
|
|
||||||
static void RemoveStyleSheet(nsIStyleSheet* aSheet, nsIDocument* aDocument);
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
NS_IMETHOD ReallyRemoveOverlayFromDataSource(const PRUnichar *aDocURI, char *aOverlayURI);
|
NS_IMETHOD ReallyRemoveOverlayFromDataSource(const PRUnichar *aDocURI, char *aOverlayURI);
|
||||||
NS_IMETHOD LoadDataSource(const nsCAutoString &aFileName, nsIRDFDataSource **aResult,
|
NS_IMETHOD LoadDataSource(const nsCAutoString &aFileName, nsIRDFDataSource **aResult,
|
||||||
|
@ -210,6 +213,9 @@ private:
|
||||||
NS_IMETHOD GetProfileRoot(nsCAutoString& aFileURL);
|
NS_IMETHOD GetProfileRoot(nsCAutoString& aFileURL);
|
||||||
|
|
||||||
NS_IMETHOD RefreshWindow(nsIDOMWindow* aWindow);
|
NS_IMETHOD RefreshWindow(nsIDOMWindow* aWindow);
|
||||||
|
|
||||||
|
NS_IMETHOD ProcessStyleSheet(nsIURL* aURL, nsICSSLoader* aLoader, nsIDocument* aDocument);
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
PRUint32 nsChromeRegistry::gRefCnt ;
|
PRUint32 nsChromeRegistry::gRefCnt ;
|
||||||
|
@ -777,8 +783,6 @@ void BreakProviderAndRemainingFromPath(const char* i_path, char** o_provider, ch
|
||||||
|
|
||||||
NS_IMETHODIMP nsChromeRegistry::RefreshSkins()
|
NS_IMETHODIMP nsChromeRegistry::RefreshSkins()
|
||||||
{
|
{
|
||||||
printf("Refreshing skins!\n");
|
|
||||||
|
|
||||||
nsresult rv;
|
nsresult rv;
|
||||||
|
|
||||||
// Flush the style sheet cache completely.
|
// Flush the style sheet cache completely.
|
||||||
|
@ -788,21 +792,16 @@ NS_IMETHODIMP nsChromeRegistry::RefreshSkins()
|
||||||
xulCache->Flush();
|
xulCache->Flush();
|
||||||
}
|
}
|
||||||
|
|
||||||
printf("Trying to obtain the window mediator.\n");
|
|
||||||
|
|
||||||
// Get the window mediator
|
// Get the window mediator
|
||||||
NS_WITH_SERVICE(nsIWindowMediator, windowMediator, kWindowMediatorCID, &rv);
|
NS_WITH_SERVICE(nsIWindowMediator, windowMediator, kWindowMediatorCID, &rv);
|
||||||
if (NS_SUCCEEDED(rv)) {
|
if (NS_SUCCEEDED(rv)) {
|
||||||
nsCOMPtr<nsISimpleEnumerator> windowEnumerator;
|
nsCOMPtr<nsISimpleEnumerator> windowEnumerator;
|
||||||
|
|
||||||
printf("Trying to enumerate...\n");
|
|
||||||
|
|
||||||
if (NS_SUCCEEDED(windowMediator->GetEnumerator(nsnull, getter_AddRefs(windowEnumerator)))) {
|
if (NS_SUCCEEDED(windowMediator->GetEnumerator(nsnull, getter_AddRefs(windowEnumerator)))) {
|
||||||
// Get each dom window
|
// Get each dom window
|
||||||
PRBool more;
|
PRBool more;
|
||||||
windowEnumerator->HasMoreElements(&more);
|
windowEnumerator->HasMoreElements(&more);
|
||||||
while (more) {
|
while (more) {
|
||||||
printf("Have something that might be a window.\n");
|
|
||||||
nsCOMPtr<nsISupports> protoWindow;
|
nsCOMPtr<nsISupports> protoWindow;
|
||||||
rv = windowEnumerator->GetNext(getter_AddRefs(protoWindow));
|
rv = windowEnumerator->GetNext(getter_AddRefs(protoWindow));
|
||||||
if (NS_SUCCEEDED(rv) && protoWindow) {
|
if (NS_SUCCEEDED(rv) && protoWindow) {
|
||||||
|
@ -820,99 +819,106 @@ NS_IMETHODIMP nsChromeRegistry::RefreshSkins()
|
||||||
|
|
||||||
NS_IMETHODIMP nsChromeRegistry::RefreshWindow(nsIDOMWindow* aWindow)
|
NS_IMETHODIMP nsChromeRegistry::RefreshWindow(nsIDOMWindow* aWindow)
|
||||||
{
|
{
|
||||||
printf("Refreshing Window!\n");
|
|
||||||
|
|
||||||
nsresult rv;
|
|
||||||
|
|
||||||
// Get the XUL cache.
|
|
||||||
NS_WITH_SERVICE(nsIXULPrototypeCache, xulCache, "components://netscape/rdf/xul-prototype-cache", &rv);
|
|
||||||
|
|
||||||
// Get the DOM document.
|
// Get the DOM document.
|
||||||
nsCOMPtr<nsIDOMDocument> domDocument;
|
nsCOMPtr<nsIDOMDocument> domDocument;
|
||||||
aWindow->GetDocument(getter_AddRefs(domDocument));
|
aWindow->GetDocument(getter_AddRefs(domDocument));
|
||||||
if (!domDocument)
|
if (!domDocument)
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
|
|
||||||
nsCOMPtr<nsIDocument> document = do_QueryInterface(domDocument);
|
nsCOMPtr<nsIDocument> document = do_QueryInterface(domDocument);
|
||||||
if (!document)
|
if (!document)
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
|
|
||||||
nsCOMPtr<nsIHTMLContentContainer> container = do_QueryInterface(document);
|
nsCOMPtr<nsIXULDocument> xulDoc = do_QueryInterface(domDocument);
|
||||||
nsCOMPtr<nsICSSLoader> cssLoader;
|
if (xulDoc) {
|
||||||
container->GetCSSLoader(*getter_AddRefs(cssLoader));
|
|
||||||
|
nsCOMPtr<nsIHTMLContentContainer> container = do_QueryInterface(document);
|
||||||
|
nsCOMPtr<nsICSSLoader> cssLoader;
|
||||||
|
container->GetCSSLoader(*getter_AddRefs(cssLoader));
|
||||||
|
|
||||||
// Build an array of nsIURIs of style sheets we need to load.
|
// Build an array of nsIURIs of style sheets we need to load.
|
||||||
nsCOMPtr<nsISupportsArray> urls;
|
nsCOMPtr<nsISupportsArray> urls;
|
||||||
NS_NewISupportsArray(getter_AddRefs(urls));
|
NS_NewISupportsArray(getter_AddRefs(urls));
|
||||||
|
|
||||||
PRInt32 count = document->GetNumberOfStyleSheets();
|
PRInt32 count = document->GetNumberOfStyleSheets();
|
||||||
|
|
||||||
// Iterate over the style sheets.
|
// Iterate over the style sheets.
|
||||||
for (PRInt32 i = 0; i < count; i++) {
|
for (PRInt32 i = 0; i < count; i++) {
|
||||||
// Get the style sheet
|
// Get the style sheet
|
||||||
nsCOMPtr<nsIStyleSheet> styleSheet = getter_AddRefs(document->GetStyleSheetAt(i));
|
nsCOMPtr<nsIStyleSheet> styleSheet = getter_AddRefs(document->GetStyleSheetAt(i));
|
||||||
|
|
||||||
// Make sure we aren't the special style sheets that never change. We
|
// Make sure we aren't the special style sheets that never change. We
|
||||||
// want to skip those.
|
// want to skip those.
|
||||||
nsCOMPtr<nsIHTMLStyleSheet> attrSheet;
|
nsCOMPtr<nsIHTMLStyleSheet> attrSheet;
|
||||||
container->GetAttributeStyleSheet(getter_AddRefs(attrSheet));
|
container->GetAttributeStyleSheet(getter_AddRefs(attrSheet));
|
||||||
|
|
||||||
nsCOMPtr<nsIHTMLCSSStyleSheet> inlineSheet;
|
nsCOMPtr<nsIHTMLCSSStyleSheet> inlineSheet;
|
||||||
container->GetInlineStyleSheet(getter_AddRefs(inlineSheet));
|
container->GetInlineStyleSheet(getter_AddRefs(inlineSheet));
|
||||||
|
|
||||||
nsCOMPtr<nsIStyleSheet> attr = do_QueryInterface(attrSheet);
|
nsCOMPtr<nsIStyleSheet> attr = do_QueryInterface(attrSheet);
|
||||||
nsCOMPtr<nsIStyleSheet> inl = do_QueryInterface(inlineSheet);
|
nsCOMPtr<nsIStyleSheet> inl = do_QueryInterface(inlineSheet);
|
||||||
if ((attr.get() != styleSheet.get()) &&
|
if ((attr.get() != styleSheet.get()) &&
|
||||||
(inl.get() != styleSheet.get())) {
|
(inl.get() != styleSheet.get())) {
|
||||||
// Get the URI and add it to our array.
|
// Get the URI and add it to our array.
|
||||||
nsCOMPtr<nsIURI> uri;
|
nsCOMPtr<nsIURI> uri;
|
||||||
styleSheet->GetURL(*getter_AddRefs(uri));
|
styleSheet->GetURL(*getter_AddRefs(uri));
|
||||||
urls->AppendElement(uri);
|
urls->AppendElement(uri);
|
||||||
|
|
||||||
// Remove the sheet.
|
// Remove the sheet.
|
||||||
count--;
|
count--;
|
||||||
i--;
|
i--;
|
||||||
RemoveStyleSheet(styleSheet, document);
|
document->RemoveStyleSheet(styleSheet);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Iterate over the URL array and kick off an asynchronous load of the
|
// Iterate over the URL array and kick off an asynchronous load of the
|
||||||
// sheets for our doc.
|
// sheets for our doc.
|
||||||
PRUint32 urlCount;
|
PRUint32 urlCount;
|
||||||
urls->Count(&urlCount);
|
urls->Count(&urlCount);
|
||||||
for (PRUint32 j = 0; j < urlCount; j++) {
|
for (PRUint32 j = 0; j < urlCount; j++) {
|
||||||
nsCOMPtr<nsISupports> supports = getter_AddRefs(urls->ElementAt(j));
|
nsCOMPtr<nsISupports> supports = getter_AddRefs(urls->ElementAt(j));
|
||||||
nsCOMPtr<nsIURL> url = do_QueryInterface(supports);
|
nsCOMPtr<nsIURL> url = do_QueryInterface(supports);
|
||||||
|
ProcessStyleSheet(url, cssLoader, document);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Get our frames object
|
// Get our frames object
|
||||||
|
nsCOMPtr<nsIDOMWindowCollection> frames;
|
||||||
|
aWindow->GetFrames(getter_AddRefs(frames));
|
||||||
|
if (!frames)
|
||||||
|
return NS_OK;
|
||||||
|
|
||||||
// Walk the frames
|
// Walk the frames
|
||||||
/*for ( ; ;) {
|
PRUint32 length;
|
||||||
|
frames->GetLength(&length);
|
||||||
|
for (PRUint32 i = 0; i < length; i++) {
|
||||||
// For each frame, recur.
|
// For each frame, recur.
|
||||||
}*/
|
nsCOMPtr<nsIDOMWindow> childWindow;
|
||||||
|
frames->Item(i, getter_AddRefs(childWindow));
|
||||||
|
if (childWindow)
|
||||||
|
RefreshWindow(childWindow);
|
||||||
|
}
|
||||||
|
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
void nsChromeRegistry::RemoveStyleSheet(nsIStyleSheet* aSheet, nsIDocument* aDocument)
|
NS_IMETHODIMP
|
||||||
|
nsChromeRegistry::ProcessStyleSheet(nsIURL* aURL, nsICSSLoader* aLoader, nsIDocument* aDocument)
|
||||||
{
|
{
|
||||||
PRInt32 count = aDocument->GetNumberOfShells();
|
PRBool doneLoading;
|
||||||
for (PRInt32 i = 0; i < count; i++) {
|
nsresult rv = aLoader->LoadStyleLink(nsnull, // anElement
|
||||||
nsCOMPtr<nsIPresShell> shell = getter_AddRefs(aDocument->GetShellAt(i));
|
aURL,
|
||||||
|
"", // aTitle
|
||||||
|
"", // aMedia
|
||||||
|
kNameSpaceID_Unknown,
|
||||||
|
aDocument->GetNumberOfStyleSheets(),
|
||||||
|
nsnull,
|
||||||
|
doneLoading); // Ignore doneLoading. Don't care.
|
||||||
|
|
||||||
nsCOMPtr<nsIStyleSet> set;
|
return rv;
|
||||||
shell->GetStyleSet(getter_AddRefs(set));
|
|
||||||
if (set) {
|
|
||||||
set->RemoveDocStyleSheet(aSheet);
|
|
||||||
nsCOMPtr<nsIDocumentObserver> obs = do_QueryInterface(shell);
|
|
||||||
if (obs)
|
|
||||||
obs->StyleSheetRemoved(aDocument, aSheet);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
NS_IMETHODIMP nsChromeRegistry::ApplyTheme(const PRUnichar *themeFileName)
|
NS_IMETHODIMP nsChromeRegistry::ApplyTheme(const PRUnichar *themeFileName)
|
||||||
{
|
{
|
||||||
nsCAutoString chromeFile = "resource:/chrome/themes.rdf";
|
nsCAutoString chromeFile = "resource:/chrome/themes.rdf";
|
||||||
|
@ -1219,5 +1225,60 @@ nsChromeRegistry::GetProfileRoot(nsCAutoString& aFileURL)
|
||||||
NS_IMETHODIMP
|
NS_IMETHODIMP
|
||||||
nsChromeRegistry::ReloadChrome()
|
nsChromeRegistry::ReloadChrome()
|
||||||
{
|
{
|
||||||
|
// Do a reload of all top level windows.
|
||||||
|
nsresult rv;
|
||||||
|
|
||||||
|
// Flush the cache completely.
|
||||||
|
NS_WITH_SERVICE(nsIXULPrototypeCache, xulCache, "components://netscape/rdf/xul-prototype-cache", &rv);
|
||||||
|
if (NS_SUCCEEDED(rv) && xulCache) {
|
||||||
|
xulCache->Flush();
|
||||||
|
}
|
||||||
|
|
||||||
|
// Get the window mediator
|
||||||
|
NS_WITH_SERVICE(nsIWindowMediator, windowMediator, kWindowMediatorCID, &rv);
|
||||||
|
if (NS_SUCCEEDED(rv)) {
|
||||||
|
nsCOMPtr<nsISimpleEnumerator> windowEnumerator;
|
||||||
|
|
||||||
|
if (NS_SUCCEEDED(windowMediator->GetEnumerator(nsnull, getter_AddRefs(windowEnumerator)))) {
|
||||||
|
// Get each dom window
|
||||||
|
PRBool more;
|
||||||
|
windowEnumerator->HasMoreElements(&more);
|
||||||
|
while (more) {
|
||||||
|
nsCOMPtr<nsISupports> protoWindow;
|
||||||
|
rv = windowEnumerator->GetNext(getter_AddRefs(protoWindow));
|
||||||
|
if (NS_SUCCEEDED(rv) && protoWindow) {
|
||||||
|
nsCOMPtr<nsPIDOMWindow> domWindow = do_QueryInterface(protoWindow);
|
||||||
|
if (domWindow) {
|
||||||
|
nsCOMPtr<nsIDOMLocation> location;
|
||||||
|
domWindow->GetLocation(getter_AddRefs(location));
|
||||||
|
if (location)
|
||||||
|
location->Reload(PR_FALSE);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
windowEnumerator->HasMoreElements(&more);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return NS_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
NS_IMETHODIMP
|
||||||
|
nsChromeRegistry::GetSkins(nsISupportsArray** aResult)
|
||||||
|
{
|
||||||
|
// XXX Fill in.
|
||||||
|
return NS_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
NS_IMETHODIMP
|
||||||
|
nsChromeRegistry::GetPackages(nsISupportsArray** aResult)
|
||||||
|
{
|
||||||
|
// XXX Fill in.
|
||||||
|
return NS_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
NS_IMETHODIMP
|
||||||
|
nsChromeRegistry::GetLocales(nsISupportsArray** aResult)
|
||||||
|
{
|
||||||
|
// XXX Fill in.
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
}
|
}
|
||||||
|
|
|
@ -27,7 +27,7 @@
|
||||||
#include "nsISupports.h"
|
#include "nsISupports.h"
|
||||||
#include "nsString.h"
|
#include "nsString.h"
|
||||||
#include "nsIScriptContext.h"
|
#include "nsIScriptContext.h"
|
||||||
|
#include "nsIDOMLocation.h"
|
||||||
|
|
||||||
#define NS_PIDOMWINDOW_IID \
|
#define NS_PIDOMWINDOW_IID \
|
||||||
{ 0x3aa80781, 0x7e6a, 0x11d3, { 0xbf, 0x87, 0x0, 0x10, 0x5a, 0x1b, 0x6, 0x27 } }
|
{ 0x3aa80781, 0x7e6a, 0x11d3, { 0xbf, 0x87, 0x0, 0x10, 0x5a, 0x1b, 0x6, 0x27 } }
|
||||||
|
@ -38,6 +38,8 @@ public:
|
||||||
static const nsIID& GetIID() { static nsIID iid = NS_PIDOMWINDOW_IID; return iid; }
|
static const nsIID& GetIID() { static nsIID iid = NS_PIDOMWINDOW_IID; return iid; }
|
||||||
|
|
||||||
NS_IMETHOD GetPrivateParent(nsPIDOMWindow** aResult)=0;
|
NS_IMETHOD GetPrivateParent(nsPIDOMWindow** aResult)=0;
|
||||||
|
|
||||||
|
NS_IMETHOD GetLocation(nsIDOMLocation** aLocation) = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // nsPIDOMWindow_h__
|
#endif // nsPIDOMWindow_h__
|
||||||
|
|
|
@ -23,23 +23,28 @@
|
||||||
#include "nsISupports.idl"
|
#include "nsISupports.idl"
|
||||||
#include "nsIURL.idl"
|
#include "nsIURL.idl"
|
||||||
#include "nsIEnumerator.idl"
|
#include "nsIEnumerator.idl"
|
||||||
|
#include "nsISupportsArray.idl"
|
||||||
|
|
||||||
[scriptable, uuid(D8C7D8A1-E84C-11d2-BF87-00105A1B0627)]
|
[scriptable, uuid(D8C7D8A1-E84C-11d2-BF87-00105A1B0627)]
|
||||||
interface nsIChromeRegistry : nsISupports
|
interface nsIChromeRegistry : nsISupports
|
||||||
{
|
{
|
||||||
void convertChromeURL(in nsIURI aChromeURL);
|
void convertChromeURL(in nsIURI aChromeURL);
|
||||||
nsISimpleEnumerator getOverlays(in nsIURI aChromeURL);
|
nsISimpleEnumerator getOverlays(in nsIURI aChromeURL);
|
||||||
|
|
||||||
void reloadChrome();
|
void reloadChrome();
|
||||||
void refreshSkins();
|
void refreshSkins();
|
||||||
|
|
||||||
void applyTheme(in wstring themeFileName);
|
void applyTheme(in wstring themeName);
|
||||||
|
|
||||||
void setSkin(in wstring skinFileName, in wstring packageName);
|
void setSkin(in wstring skinName, in wstring packageName);
|
||||||
void setLocale(in wstring localeFileName, in wstring packageName);
|
void setLocale(in wstring localeName, in wstring packageName);
|
||||||
|
|
||||||
void setDefaultSkin(in wstring skinFileName, in wstring packageName);
|
void setDefaultSkin(in wstring skinName, in wstring packageName);
|
||||||
void setDefaultLocale(in wstring localeFileName, in wstring packageName);
|
void setDefaultLocale(in wstring localeName, in wstring packageName);
|
||||||
|
|
||||||
|
readonly attribute nsISupportsArray skins;
|
||||||
|
readonly attribute nsISupportsArray packages;
|
||||||
|
readonly attribute nsISupportsArray locales;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -42,7 +42,10 @@
|
||||||
#include "nsNetUtil.h"
|
#include "nsNetUtil.h"
|
||||||
#include "nsFileLocations.h"
|
#include "nsFileLocations.h"
|
||||||
#include "nsIFileLocator.h"
|
#include "nsIFileLocator.h"
|
||||||
|
#include "nsPIDOMWindow.h"
|
||||||
#include "nsIDOMWindow.h"
|
#include "nsIDOMWindow.h"
|
||||||
|
#include "nsIDOMWindowCollection.h"
|
||||||
|
#include "nsIDOMLocation.h"
|
||||||
#include "nsIWindowMediator.h"
|
#include "nsIWindowMediator.h"
|
||||||
#include "nsIDocument.h"
|
#include "nsIDocument.h"
|
||||||
#include "nsIDOMDocument.h"
|
#include "nsIDOMDocument.h"
|
||||||
|
@ -56,6 +59,8 @@
|
||||||
#include "nsISupportsArray.h"
|
#include "nsISupportsArray.h"
|
||||||
#include "nsICSSLoader.h"
|
#include "nsICSSLoader.h"
|
||||||
#include "nsIDocumentObserver.h"
|
#include "nsIDocumentObserver.h"
|
||||||
|
#include "nsIXULDocument.h"
|
||||||
|
#include "nsINameSpaceManager.h"
|
||||||
|
|
||||||
static NS_DEFINE_CID(kWindowMediatorCID, NS_WINDOWMEDIATOR_CID);
|
static NS_DEFINE_CID(kWindowMediatorCID, NS_WINDOWMEDIATOR_CID);
|
||||||
static NS_DEFINE_CID(kRDFServiceCID, NS_RDFSERVICE_CID);
|
static NS_DEFINE_CID(kRDFServiceCID, NS_RDFSERVICE_CID);
|
||||||
|
@ -199,8 +204,6 @@ protected:
|
||||||
nsIRDFContainer *aContainer,
|
nsIRDFContainer *aContainer,
|
||||||
nsIRDFDataSource *aDataSource);
|
nsIRDFDataSource *aDataSource);
|
||||||
|
|
||||||
static void RemoveStyleSheet(nsIStyleSheet* aSheet, nsIDocument* aDocument);
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
NS_IMETHOD ReallyRemoveOverlayFromDataSource(const PRUnichar *aDocURI, char *aOverlayURI);
|
NS_IMETHOD ReallyRemoveOverlayFromDataSource(const PRUnichar *aDocURI, char *aOverlayURI);
|
||||||
NS_IMETHOD LoadDataSource(const nsCAutoString &aFileName, nsIRDFDataSource **aResult,
|
NS_IMETHOD LoadDataSource(const nsCAutoString &aFileName, nsIRDFDataSource **aResult,
|
||||||
|
@ -210,6 +213,9 @@ private:
|
||||||
NS_IMETHOD GetProfileRoot(nsCAutoString& aFileURL);
|
NS_IMETHOD GetProfileRoot(nsCAutoString& aFileURL);
|
||||||
|
|
||||||
NS_IMETHOD RefreshWindow(nsIDOMWindow* aWindow);
|
NS_IMETHOD RefreshWindow(nsIDOMWindow* aWindow);
|
||||||
|
|
||||||
|
NS_IMETHOD ProcessStyleSheet(nsIURL* aURL, nsICSSLoader* aLoader, nsIDocument* aDocument);
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
PRUint32 nsChromeRegistry::gRefCnt ;
|
PRUint32 nsChromeRegistry::gRefCnt ;
|
||||||
|
@ -777,8 +783,6 @@ void BreakProviderAndRemainingFromPath(const char* i_path, char** o_provider, ch
|
||||||
|
|
||||||
NS_IMETHODIMP nsChromeRegistry::RefreshSkins()
|
NS_IMETHODIMP nsChromeRegistry::RefreshSkins()
|
||||||
{
|
{
|
||||||
printf("Refreshing skins!\n");
|
|
||||||
|
|
||||||
nsresult rv;
|
nsresult rv;
|
||||||
|
|
||||||
// Flush the style sheet cache completely.
|
// Flush the style sheet cache completely.
|
||||||
|
@ -788,21 +792,16 @@ NS_IMETHODIMP nsChromeRegistry::RefreshSkins()
|
||||||
xulCache->Flush();
|
xulCache->Flush();
|
||||||
}
|
}
|
||||||
|
|
||||||
printf("Trying to obtain the window mediator.\n");
|
|
||||||
|
|
||||||
// Get the window mediator
|
// Get the window mediator
|
||||||
NS_WITH_SERVICE(nsIWindowMediator, windowMediator, kWindowMediatorCID, &rv);
|
NS_WITH_SERVICE(nsIWindowMediator, windowMediator, kWindowMediatorCID, &rv);
|
||||||
if (NS_SUCCEEDED(rv)) {
|
if (NS_SUCCEEDED(rv)) {
|
||||||
nsCOMPtr<nsISimpleEnumerator> windowEnumerator;
|
nsCOMPtr<nsISimpleEnumerator> windowEnumerator;
|
||||||
|
|
||||||
printf("Trying to enumerate...\n");
|
|
||||||
|
|
||||||
if (NS_SUCCEEDED(windowMediator->GetEnumerator(nsnull, getter_AddRefs(windowEnumerator)))) {
|
if (NS_SUCCEEDED(windowMediator->GetEnumerator(nsnull, getter_AddRefs(windowEnumerator)))) {
|
||||||
// Get each dom window
|
// Get each dom window
|
||||||
PRBool more;
|
PRBool more;
|
||||||
windowEnumerator->HasMoreElements(&more);
|
windowEnumerator->HasMoreElements(&more);
|
||||||
while (more) {
|
while (more) {
|
||||||
printf("Have something that might be a window.\n");
|
|
||||||
nsCOMPtr<nsISupports> protoWindow;
|
nsCOMPtr<nsISupports> protoWindow;
|
||||||
rv = windowEnumerator->GetNext(getter_AddRefs(protoWindow));
|
rv = windowEnumerator->GetNext(getter_AddRefs(protoWindow));
|
||||||
if (NS_SUCCEEDED(rv) && protoWindow) {
|
if (NS_SUCCEEDED(rv) && protoWindow) {
|
||||||
|
@ -820,99 +819,106 @@ NS_IMETHODIMP nsChromeRegistry::RefreshSkins()
|
||||||
|
|
||||||
NS_IMETHODIMP nsChromeRegistry::RefreshWindow(nsIDOMWindow* aWindow)
|
NS_IMETHODIMP nsChromeRegistry::RefreshWindow(nsIDOMWindow* aWindow)
|
||||||
{
|
{
|
||||||
printf("Refreshing Window!\n");
|
|
||||||
|
|
||||||
nsresult rv;
|
|
||||||
|
|
||||||
// Get the XUL cache.
|
|
||||||
NS_WITH_SERVICE(nsIXULPrototypeCache, xulCache, "components://netscape/rdf/xul-prototype-cache", &rv);
|
|
||||||
|
|
||||||
// Get the DOM document.
|
// Get the DOM document.
|
||||||
nsCOMPtr<nsIDOMDocument> domDocument;
|
nsCOMPtr<nsIDOMDocument> domDocument;
|
||||||
aWindow->GetDocument(getter_AddRefs(domDocument));
|
aWindow->GetDocument(getter_AddRefs(domDocument));
|
||||||
if (!domDocument)
|
if (!domDocument)
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
|
|
||||||
nsCOMPtr<nsIDocument> document = do_QueryInterface(domDocument);
|
nsCOMPtr<nsIDocument> document = do_QueryInterface(domDocument);
|
||||||
if (!document)
|
if (!document)
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
|
|
||||||
nsCOMPtr<nsIHTMLContentContainer> container = do_QueryInterface(document);
|
nsCOMPtr<nsIXULDocument> xulDoc = do_QueryInterface(domDocument);
|
||||||
nsCOMPtr<nsICSSLoader> cssLoader;
|
if (xulDoc) {
|
||||||
container->GetCSSLoader(*getter_AddRefs(cssLoader));
|
|
||||||
|
nsCOMPtr<nsIHTMLContentContainer> container = do_QueryInterface(document);
|
||||||
|
nsCOMPtr<nsICSSLoader> cssLoader;
|
||||||
|
container->GetCSSLoader(*getter_AddRefs(cssLoader));
|
||||||
|
|
||||||
// Build an array of nsIURIs of style sheets we need to load.
|
// Build an array of nsIURIs of style sheets we need to load.
|
||||||
nsCOMPtr<nsISupportsArray> urls;
|
nsCOMPtr<nsISupportsArray> urls;
|
||||||
NS_NewISupportsArray(getter_AddRefs(urls));
|
NS_NewISupportsArray(getter_AddRefs(urls));
|
||||||
|
|
||||||
PRInt32 count = document->GetNumberOfStyleSheets();
|
PRInt32 count = document->GetNumberOfStyleSheets();
|
||||||
|
|
||||||
// Iterate over the style sheets.
|
// Iterate over the style sheets.
|
||||||
for (PRInt32 i = 0; i < count; i++) {
|
for (PRInt32 i = 0; i < count; i++) {
|
||||||
// Get the style sheet
|
// Get the style sheet
|
||||||
nsCOMPtr<nsIStyleSheet> styleSheet = getter_AddRefs(document->GetStyleSheetAt(i));
|
nsCOMPtr<nsIStyleSheet> styleSheet = getter_AddRefs(document->GetStyleSheetAt(i));
|
||||||
|
|
||||||
// Make sure we aren't the special style sheets that never change. We
|
// Make sure we aren't the special style sheets that never change. We
|
||||||
// want to skip those.
|
// want to skip those.
|
||||||
nsCOMPtr<nsIHTMLStyleSheet> attrSheet;
|
nsCOMPtr<nsIHTMLStyleSheet> attrSheet;
|
||||||
container->GetAttributeStyleSheet(getter_AddRefs(attrSheet));
|
container->GetAttributeStyleSheet(getter_AddRefs(attrSheet));
|
||||||
|
|
||||||
nsCOMPtr<nsIHTMLCSSStyleSheet> inlineSheet;
|
nsCOMPtr<nsIHTMLCSSStyleSheet> inlineSheet;
|
||||||
container->GetInlineStyleSheet(getter_AddRefs(inlineSheet));
|
container->GetInlineStyleSheet(getter_AddRefs(inlineSheet));
|
||||||
|
|
||||||
nsCOMPtr<nsIStyleSheet> attr = do_QueryInterface(attrSheet);
|
nsCOMPtr<nsIStyleSheet> attr = do_QueryInterface(attrSheet);
|
||||||
nsCOMPtr<nsIStyleSheet> inl = do_QueryInterface(inlineSheet);
|
nsCOMPtr<nsIStyleSheet> inl = do_QueryInterface(inlineSheet);
|
||||||
if ((attr.get() != styleSheet.get()) &&
|
if ((attr.get() != styleSheet.get()) &&
|
||||||
(inl.get() != styleSheet.get())) {
|
(inl.get() != styleSheet.get())) {
|
||||||
// Get the URI and add it to our array.
|
// Get the URI and add it to our array.
|
||||||
nsCOMPtr<nsIURI> uri;
|
nsCOMPtr<nsIURI> uri;
|
||||||
styleSheet->GetURL(*getter_AddRefs(uri));
|
styleSheet->GetURL(*getter_AddRefs(uri));
|
||||||
urls->AppendElement(uri);
|
urls->AppendElement(uri);
|
||||||
|
|
||||||
// Remove the sheet.
|
// Remove the sheet.
|
||||||
count--;
|
count--;
|
||||||
i--;
|
i--;
|
||||||
RemoveStyleSheet(styleSheet, document);
|
document->RemoveStyleSheet(styleSheet);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Iterate over the URL array and kick off an asynchronous load of the
|
// Iterate over the URL array and kick off an asynchronous load of the
|
||||||
// sheets for our doc.
|
// sheets for our doc.
|
||||||
PRUint32 urlCount;
|
PRUint32 urlCount;
|
||||||
urls->Count(&urlCount);
|
urls->Count(&urlCount);
|
||||||
for (PRUint32 j = 0; j < urlCount; j++) {
|
for (PRUint32 j = 0; j < urlCount; j++) {
|
||||||
nsCOMPtr<nsISupports> supports = getter_AddRefs(urls->ElementAt(j));
|
nsCOMPtr<nsISupports> supports = getter_AddRefs(urls->ElementAt(j));
|
||||||
nsCOMPtr<nsIURL> url = do_QueryInterface(supports);
|
nsCOMPtr<nsIURL> url = do_QueryInterface(supports);
|
||||||
|
ProcessStyleSheet(url, cssLoader, document);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Get our frames object
|
// Get our frames object
|
||||||
|
nsCOMPtr<nsIDOMWindowCollection> frames;
|
||||||
|
aWindow->GetFrames(getter_AddRefs(frames));
|
||||||
|
if (!frames)
|
||||||
|
return NS_OK;
|
||||||
|
|
||||||
// Walk the frames
|
// Walk the frames
|
||||||
/*for ( ; ;) {
|
PRUint32 length;
|
||||||
|
frames->GetLength(&length);
|
||||||
|
for (PRUint32 i = 0; i < length; i++) {
|
||||||
// For each frame, recur.
|
// For each frame, recur.
|
||||||
}*/
|
nsCOMPtr<nsIDOMWindow> childWindow;
|
||||||
|
frames->Item(i, getter_AddRefs(childWindow));
|
||||||
|
if (childWindow)
|
||||||
|
RefreshWindow(childWindow);
|
||||||
|
}
|
||||||
|
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
void nsChromeRegistry::RemoveStyleSheet(nsIStyleSheet* aSheet, nsIDocument* aDocument)
|
NS_IMETHODIMP
|
||||||
|
nsChromeRegistry::ProcessStyleSheet(nsIURL* aURL, nsICSSLoader* aLoader, nsIDocument* aDocument)
|
||||||
{
|
{
|
||||||
PRInt32 count = aDocument->GetNumberOfShells();
|
PRBool doneLoading;
|
||||||
for (PRInt32 i = 0; i < count; i++) {
|
nsresult rv = aLoader->LoadStyleLink(nsnull, // anElement
|
||||||
nsCOMPtr<nsIPresShell> shell = getter_AddRefs(aDocument->GetShellAt(i));
|
aURL,
|
||||||
|
"", // aTitle
|
||||||
|
"", // aMedia
|
||||||
|
kNameSpaceID_Unknown,
|
||||||
|
aDocument->GetNumberOfStyleSheets(),
|
||||||
|
nsnull,
|
||||||
|
doneLoading); // Ignore doneLoading. Don't care.
|
||||||
|
|
||||||
nsCOMPtr<nsIStyleSet> set;
|
return rv;
|
||||||
shell->GetStyleSet(getter_AddRefs(set));
|
|
||||||
if (set) {
|
|
||||||
set->RemoveDocStyleSheet(aSheet);
|
|
||||||
nsCOMPtr<nsIDocumentObserver> obs = do_QueryInterface(shell);
|
|
||||||
if (obs)
|
|
||||||
obs->StyleSheetRemoved(aDocument, aSheet);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
NS_IMETHODIMP nsChromeRegistry::ApplyTheme(const PRUnichar *themeFileName)
|
NS_IMETHODIMP nsChromeRegistry::ApplyTheme(const PRUnichar *themeFileName)
|
||||||
{
|
{
|
||||||
nsCAutoString chromeFile = "resource:/chrome/themes.rdf";
|
nsCAutoString chromeFile = "resource:/chrome/themes.rdf";
|
||||||
|
@ -1219,5 +1225,60 @@ nsChromeRegistry::GetProfileRoot(nsCAutoString& aFileURL)
|
||||||
NS_IMETHODIMP
|
NS_IMETHODIMP
|
||||||
nsChromeRegistry::ReloadChrome()
|
nsChromeRegistry::ReloadChrome()
|
||||||
{
|
{
|
||||||
|
// Do a reload of all top level windows.
|
||||||
|
nsresult rv;
|
||||||
|
|
||||||
|
// Flush the cache completely.
|
||||||
|
NS_WITH_SERVICE(nsIXULPrototypeCache, xulCache, "components://netscape/rdf/xul-prototype-cache", &rv);
|
||||||
|
if (NS_SUCCEEDED(rv) && xulCache) {
|
||||||
|
xulCache->Flush();
|
||||||
|
}
|
||||||
|
|
||||||
|
// Get the window mediator
|
||||||
|
NS_WITH_SERVICE(nsIWindowMediator, windowMediator, kWindowMediatorCID, &rv);
|
||||||
|
if (NS_SUCCEEDED(rv)) {
|
||||||
|
nsCOMPtr<nsISimpleEnumerator> windowEnumerator;
|
||||||
|
|
||||||
|
if (NS_SUCCEEDED(windowMediator->GetEnumerator(nsnull, getter_AddRefs(windowEnumerator)))) {
|
||||||
|
// Get each dom window
|
||||||
|
PRBool more;
|
||||||
|
windowEnumerator->HasMoreElements(&more);
|
||||||
|
while (more) {
|
||||||
|
nsCOMPtr<nsISupports> protoWindow;
|
||||||
|
rv = windowEnumerator->GetNext(getter_AddRefs(protoWindow));
|
||||||
|
if (NS_SUCCEEDED(rv) && protoWindow) {
|
||||||
|
nsCOMPtr<nsPIDOMWindow> domWindow = do_QueryInterface(protoWindow);
|
||||||
|
if (domWindow) {
|
||||||
|
nsCOMPtr<nsIDOMLocation> location;
|
||||||
|
domWindow->GetLocation(getter_AddRefs(location));
|
||||||
|
if (location)
|
||||||
|
location->Reload(PR_FALSE);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
windowEnumerator->HasMoreElements(&more);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return NS_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
NS_IMETHODIMP
|
||||||
|
nsChromeRegistry::GetSkins(nsISupportsArray** aResult)
|
||||||
|
{
|
||||||
|
// XXX Fill in.
|
||||||
|
return NS_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
NS_IMETHODIMP
|
||||||
|
nsChromeRegistry::GetPackages(nsISupportsArray** aResult)
|
||||||
|
{
|
||||||
|
// XXX Fill in.
|
||||||
|
return NS_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
NS_IMETHODIMP
|
||||||
|
nsChromeRegistry::GetLocales(nsISupportsArray** aResult)
|
||||||
|
{
|
||||||
|
// XXX Fill in.
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
}
|
}
|
||||||
|
|
Загрузка…
Ссылка в новой задаче