From ce83a7c5fff7c12522e9b79bb9245abdcb9db628 Mon Sep 17 00:00:00 2001 From: "peterv%netscape.com" Date: Mon, 21 May 2001 13:01:41 +0000 Subject: [PATCH] Fixing regression bug 81918 (Setting preferred style sheet via HTTP headers is broken). r=glazman, sr=jst. --- content/base/src/nsDocument.cpp | 21 ++++++++++----------- content/html/style/public/nsICSSLoader.h | 3 ++- content/html/style/src/nsCSSLoader.cpp | 4 ++-- layout/style/nsCSSLoader.cpp | 4 ++-- layout/style/nsICSSLoader.h | 3 ++- 5 files changed, 18 insertions(+), 17 deletions(-) diff --git a/content/base/src/nsDocument.cpp b/content/base/src/nsDocument.cpp index 346a0920f92a..b72a214fd529 100644 --- a/content/base/src/nsDocument.cpp +++ b/content/base/src/nsDocument.cpp @@ -932,6 +932,7 @@ nsDocument::SetHeaderData(nsIAtom* aHeaderField, const nsAReadableString& aData) else { nsDocHeaderData* data = mHeaderData; nsDocHeaderData** lastPtr = &mHeaderData; + PRBool found = PR_FALSE; do { // look for existing and replace if (data->mField == aHeaderField) { if (!aData.IsEmpty()) { @@ -942,13 +943,13 @@ nsDocument::SetHeaderData(nsIAtom* aHeaderField, const nsAReadableString& aData) data->mNext = nsnull; delete data; } - return NS_OK; + found = PR_TRUE; } lastPtr = &(data->mNext); data = data->mNext; - } while (nsnull != data); - // didn't find, append - if (!aData.IsEmpty()) { + } while (data && !found); + if (!aData.IsEmpty() && !found) { + // didn't find, append *lastPtr = new nsDocHeaderData(aHeaderField, aData); } } @@ -956,22 +957,20 @@ nsDocument::SetHeaderData(nsIAtom* aHeaderField, const nsAReadableString& aData) // switch alternate style sheets based on default nsAutoString type; nsAutoString title; - nsAutoString textHtml; - textHtml.Assign(NS_LITERAL_STRING("text/html")); PRInt32 index; - mCSSLoader->SetPreferredSheet(nsAutoString(aData)); + mCSSLoader->SetPreferredSheet(aData); PRInt32 count = mStyleSheets.Count(); for (index = 0; index < count; index++) { nsIStyleSheet* sheet = (nsIStyleSheet*)mStyleSheets.ElementAt(index); sheet->GetType(type); - if (!type.Equals(textHtml)) { + if (!type.Equals(NS_LITERAL_STRING("text/html"))) { sheet->GetTitle(title); if (!title.IsEmpty()) { // if sheet has title - nsAutoString data(aData); - PRBool disabled = (aData.IsEmpty() || - !title.EqualsIgnoreCase(data)); + PRBool disabled = (aData.IsEmpty() || + Compare(title, aData, + nsCaseInsensitiveStringComparator()) != 0); SetStyleSheetDisabledState(sheet, disabled); } } diff --git a/content/html/style/public/nsICSSLoader.h b/content/html/style/public/nsICSSLoader.h index 11e18cc4967b..7fbbc53d5596 100644 --- a/content/html/style/public/nsICSSLoader.h +++ b/content/html/style/public/nsICSSLoader.h @@ -24,6 +24,7 @@ #include "nslayout.h" #include "nsISupports.h" +#include "nsAReadableString.h" class nsIAtom; class nsString; @@ -52,7 +53,7 @@ public: NS_IMETHOD SetCaseSensitive(PRBool aCaseSensitive) = 0; NS_IMETHOD SetQuirkMode(PRBool aQuirkMode) = 0; - NS_IMETHOD SetPreferredSheet(const nsString& aTitle) = 0; + NS_IMETHOD SetPreferredSheet(const nsAReadableString& aTitle) = 0; // Get/Recycle a CSS parser for general use NS_IMETHOD GetParserFor(nsICSSStyleSheet* aSheet, diff --git a/content/html/style/src/nsCSSLoader.cpp b/content/html/style/src/nsCSSLoader.cpp index 0352bdf11d93..6c5a292e271f 100644 --- a/content/html/style/src/nsCSSLoader.cpp +++ b/content/html/style/src/nsCSSLoader.cpp @@ -215,7 +215,7 @@ public: NS_IMETHOD SetCaseSensitive(PRBool aCaseSensitive); NS_IMETHOD SetQuirkMode(PRBool aQuirkMode); - NS_IMETHOD SetPreferredSheet(const nsString& aTitle); + NS_IMETHOD SetPreferredSheet(const nsAReadableString& aTitle); NS_IMETHOD GetParserFor(nsICSSStyleSheet* aSheet, nsICSSParser** aParser); @@ -520,7 +520,7 @@ CSSLoaderImpl::SetQuirkMode(PRBool aQuirkMode) } NS_IMETHODIMP -CSSLoaderImpl::SetPreferredSheet(const nsString& aTitle) +CSSLoaderImpl::SetPreferredSheet(const nsAReadableString& aTitle) { mPreferredSheet = aTitle; diff --git a/layout/style/nsCSSLoader.cpp b/layout/style/nsCSSLoader.cpp index 0352bdf11d93..6c5a292e271f 100644 --- a/layout/style/nsCSSLoader.cpp +++ b/layout/style/nsCSSLoader.cpp @@ -215,7 +215,7 @@ public: NS_IMETHOD SetCaseSensitive(PRBool aCaseSensitive); NS_IMETHOD SetQuirkMode(PRBool aQuirkMode); - NS_IMETHOD SetPreferredSheet(const nsString& aTitle); + NS_IMETHOD SetPreferredSheet(const nsAReadableString& aTitle); NS_IMETHOD GetParserFor(nsICSSStyleSheet* aSheet, nsICSSParser** aParser); @@ -520,7 +520,7 @@ CSSLoaderImpl::SetQuirkMode(PRBool aQuirkMode) } NS_IMETHODIMP -CSSLoaderImpl::SetPreferredSheet(const nsString& aTitle) +CSSLoaderImpl::SetPreferredSheet(const nsAReadableString& aTitle) { mPreferredSheet = aTitle; diff --git a/layout/style/nsICSSLoader.h b/layout/style/nsICSSLoader.h index 11e18cc4967b..7fbbc53d5596 100644 --- a/layout/style/nsICSSLoader.h +++ b/layout/style/nsICSSLoader.h @@ -24,6 +24,7 @@ #include "nslayout.h" #include "nsISupports.h" +#include "nsAReadableString.h" class nsIAtom; class nsString; @@ -52,7 +53,7 @@ public: NS_IMETHOD SetCaseSensitive(PRBool aCaseSensitive) = 0; NS_IMETHOD SetQuirkMode(PRBool aQuirkMode) = 0; - NS_IMETHOD SetPreferredSheet(const nsString& aTitle) = 0; + NS_IMETHOD SetPreferredSheet(const nsAReadableString& aTitle) = 0; // Get/Recycle a CSS parser for general use NS_IMETHOD GetParserFor(nsICSSStyleSheet* aSheet,