From 35c251622ac0b640306858f97b14018b48bdeae2 Mon Sep 17 00:00:00 2001 From: Boris Zbarsky Date: Tue, 10 Mar 2009 09:52:23 -0400 Subject: [PATCH] Bug 480065. Make chrome registry not mess with inline stylesheets. r=bsmedberg, sr=dbaron --- chrome/src/nsChromeRegistry.cpp | 12 +++--------- layout/style/nsCSSStyleSheet.cpp | 6 ++++++ layout/style/nsCSSStyleSheet.h | 3 ++- layout/style/nsICSSStyleSheet.h | 10 +++++++--- 4 files changed, 18 insertions(+), 13 deletions(-) diff --git a/chrome/src/nsChromeRegistry.cpp b/chrome/src/nsChromeRegistry.cpp index bd9c1559ac04..7a3ad987968d 100644 --- a/chrome/src/nsChromeRegistry.cpp +++ b/chrome/src/nsChromeRegistry.cpp @@ -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 sheet = oldSheets[i]; - nsCOMPtr uri; - rv = sheet->GetSheetURI(getter_AddRefs(uri)); - if (NS_FAILED(rv)) return rv; + nsCOMPtr sheet = do_QueryInterface(oldSheets[i]); + nsIURI* uri = sheet ? sheet->GetOriginalURI() : nsnull; - if (IsChromeURI(uri)) { + if (uri && IsChromeURI(uri)) { // Reload the sheet. -#ifdef DEBUG - nsCOMPtr oldCSSSheet = do_QueryInterface(sheet); - NS_ASSERTION(oldCSSSheet, "Don't know how to reload a non-CSS sheet"); -#endif nsCOMPtr newSheet; // XXX what about chrome sheets that have a title or are disabled? This // only works by sheer dumb luck. diff --git a/layout/style/nsCSSStyleSheet.cpp b/layout/style/nsCSSStyleSheet.cpp index adabe0660723..f596734d7416 100644 --- a/layout/style/nsCSSStyleSheet.cpp +++ b/layout/style/nsCSSStyleSheet.cpp @@ -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) { diff --git a/layout/style/nsCSSStyleSheet.h b/layout/style/nsCSSStyleSheet.h index 0d4137157be6..752767f3e478 100644 --- a/layout/style/nsCSSStyleSheet.h +++ b/layout/style/nsCSSStyleSheet.h @@ -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, diff --git a/layout/style/nsICSSStyleSheet.h b/layout/style/nsICSSStyleSheet.h index 5d71493a5c77..32a33d5761e0 100644 --- a/layout/style/nsICSSStyleSheet.h +++ b/layout/style/nsICSSStyleSheet.h @@ -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)