From 1de01798199704569e5b22d04df2e4275826522f Mon Sep 17 00:00:00 2001 From: "pierre%netscape.com" Date: Sat, 8 Jan 2000 10:09:00 +0000 Subject: [PATCH] Bug 18817 "autodetection of content-type used": in strict mode, requires the mime type to be specified if the style sheet doesn't have a '.css' extension (otherwise the style sheet is ignored). git-svn-id: svn://10.0.0.236/trunk@57196 18797224-902f-48f8-a5cc-f745e15eee43 --- .../html/document/src/nsHTMLContentSink.cpp | 26 ++++++++++++++++++- .../html/document/src/nsHTMLContentSink.cpp | 26 ++++++++++++++++++- 2 files changed, 50 insertions(+), 2 deletions(-) diff --git a/mozilla/content/html/document/src/nsHTMLContentSink.cpp b/mozilla/content/html/document/src/nsHTMLContentSink.cpp index 49d3a23f802..031c8ad705d 100644 --- a/mozilla/content/html/document/src/nsHTMLContentSink.cpp +++ b/mozilla/content/html/document/src/nsHTMLContentSink.cpp @@ -3429,7 +3429,31 @@ HTMLContentSink::ProcessStyleLink(nsIHTMLContent* aElement, nsAutoString params; SplitMimeType(aType, mimeType, params); - if ((0 == mimeType.Length()) || mimeType.EqualsIgnoreCase("text/css")) { + nsDTDMode mode; + mHTMLDocument->GetDTDMode(mode); + + PRBool isStyleSheet = PR_FALSE; // see bug 18817 + if (eDTDMode_NoQuirks == mode) { + if (mimeType.EqualsIgnoreCase("text/css")) { + isStyleSheet = PR_TRUE; // strict mode + good mime type + } + else { + if (0 == mimeType.Length()) { + nsString extension; + aHref.Right(extension, 4); + if (extension == ".css") { + isStyleSheet = PR_TRUE; // strict mode + no mime type + '.css' extension + } + } + } + } + else { + if (0 == mimeType.Length() || mimeType.EqualsIgnoreCase("text/css")) { + isStyleSheet = PR_TRUE; // quirks mode + good mime type or no mime type at all + } + } + + if (isStyleSheet) { nsIURI* url = nsnull; { result = NS_NewURI(&url, aHref, mDocumentBaseURL); diff --git a/mozilla/layout/html/document/src/nsHTMLContentSink.cpp b/mozilla/layout/html/document/src/nsHTMLContentSink.cpp index 49d3a23f802..031c8ad705d 100644 --- a/mozilla/layout/html/document/src/nsHTMLContentSink.cpp +++ b/mozilla/layout/html/document/src/nsHTMLContentSink.cpp @@ -3429,7 +3429,31 @@ HTMLContentSink::ProcessStyleLink(nsIHTMLContent* aElement, nsAutoString params; SplitMimeType(aType, mimeType, params); - if ((0 == mimeType.Length()) || mimeType.EqualsIgnoreCase("text/css")) { + nsDTDMode mode; + mHTMLDocument->GetDTDMode(mode); + + PRBool isStyleSheet = PR_FALSE; // see bug 18817 + if (eDTDMode_NoQuirks == mode) { + if (mimeType.EqualsIgnoreCase("text/css")) { + isStyleSheet = PR_TRUE; // strict mode + good mime type + } + else { + if (0 == mimeType.Length()) { + nsString extension; + aHref.Right(extension, 4); + if (extension == ".css") { + isStyleSheet = PR_TRUE; // strict mode + no mime type + '.css' extension + } + } + } + } + else { + if (0 == mimeType.Length() || mimeType.EqualsIgnoreCase("text/css")) { + isStyleSheet = PR_TRUE; // quirks mode + good mime type or no mime type at all + } + } + + if (isStyleSheet) { nsIURI* url = nsnull; { result = NS_NewURI(&url, aHref, mDocumentBaseURL);