Bug 480065. Make chrome registry not mess with inline stylesheets. r=bsmedberg, sr=dbaron

This commit is contained in:
Boris Zbarsky 2009-03-10 09:52:23 -04:00
parent 272153e025
commit 35c251622a
4 changed files with 18 additions and 13 deletions

View File

@ -1039,17 +1039,11 @@ nsresult nsChromeRegistry::RefreshWindow(nsIDOMWindowInternal* aWindow,
// Iterate over our old sheets and kick off a sync load of the new
// sheet if and only if it's a chrome URL.
for (i = 0; i < count; i++) {
nsCOMPtr<nsIStyleSheet> sheet = oldSheets[i];
nsCOMPtr<nsIURI> uri;
rv = sheet->GetSheetURI(getter_AddRefs(uri));
if (NS_FAILED(rv)) return rv;
nsCOMPtr<nsICSSStyleSheet> sheet = do_QueryInterface(oldSheets[i]);
nsIURI* uri = sheet ? sheet->GetOriginalURI() : nsnull;
if (IsChromeURI(uri)) {
if (uri && IsChromeURI(uri)) {
// Reload the sheet.
#ifdef DEBUG
nsCOMPtr<nsICSSStyleSheet> oldCSSSheet = do_QueryInterface(sheet);
NS_ASSERTION(oldCSSSheet, "Don't know how to reload a non-CSS sheet");
#endif
nsCOMPtr<nsICSSStyleSheet> newSheet;
// XXX what about chrome sheets that have a title or are disabled? This
// only works by sheer dumb luck.

View File

@ -2171,6 +2171,12 @@ nsCSSStyleSheet::StyleSheetLoaded(nsICSSStyleSheet* aSheet,
return NS_OK;
}
NS_IMETHODIMP_(nsIURI*)
nsCSSStyleSheet::GetOriginalURI() const
{
return mInner->mOriginalSheetURI;
}
nsresult
NS_NewCSSStyleSheet(nsICSSStyleSheet** aInstancePtrResult)
{

View File

@ -165,7 +165,8 @@ public:
NS_IMETHOD AddRuleProcessor(nsCSSRuleProcessor* aProcessor);
NS_IMETHOD DropRuleProcessor(nsCSSRuleProcessor* aProcessor);
NS_IMETHOD InsertRuleInternal(const nsAString& aRule,
PRUint32 aIndex, PRUint32* aReturn);
PRUint32 aIndex, PRUint32* aReturn);
NS_IMETHOD_(nsIURI*) GetOriginalURI() const;
// nsICSSLoaderObserver interface
NS_IMETHOD StyleSheetLoaded(nsICSSStyleSheet* aSheet, PRBool aWasAlternate,

View File

@ -53,10 +53,10 @@ class nsICSSImportRule;
class nsIPrincipal;
// IID for the nsICSSStyleSheet interface
// ee0270c7-5581-4165-92a5-a83ff691f60d
// ba09b3a4-4a29-495d-987b-cfbb58c5c6ec
#define NS_ICSS_STYLE_SHEET_IID \
{ 0xee0270c7, 0x5581, 0x4165, \
{ 0x92, 0xa5, 0xa8, 0x3f, 0xf6, 0x91, 0xf6, 0x0d } }
{ 0xba09b3a4, 0x4a29, 0x495d, \
{ 0x98, 0x7b, 0xcf, 0xbb, 0x58, 0xc5, 0xc6, 0xec } }
class nsICSSStyleSheet : public nsIStyleSheet {
public:
@ -125,6 +125,10 @@ public:
*/
NS_IMETHOD InsertRuleInternal(const nsAString& aRule,
PRUint32 aIndex, PRUint32* aReturn) = 0;
/* Get the URI this sheet was originally loaded from, if any. Can
return null */
NS_IMETHOD_(nsIURI*) GetOriginalURI() const = 0;
};
NS_DEFINE_STATIC_IID_ACCESSOR(nsICSSStyleSheet, NS_ICSS_STYLE_SHEET_IID)