Fixing regression bug 81918 (Setting preferred style sheet via HTTP headers is broken). r=glazman, sr=jst.

git-svn-id: svn://10.0.0.236/trunk@95596 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
peterv%netscape.com
2001-05-21 13:01:41 +00:00
parent 942543ef20
commit b5b28ccdae
5 changed files with 18 additions and 17 deletions

View File

@@ -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);
}
}

View File

@@ -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,

View File

@@ -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;

View File

@@ -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;

View File

@@ -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,