From f21b437b1ccb6fcb133a03137900bbdbf89f052d Mon Sep 17 00:00:00 2001
From: "dbaron%fas.harvard.edu"
Date: Fri, 28 Jun 2002 06:20:50 +0000
Subject: [PATCH] Split strict mode into almost-standards and full-standards
mode, where the only quirk in almost standards mode is the quirky inline box
model. Pull in parts from previous fix for bug 141261. Tweak mode detection
to use almost-standards for XHTML Transitional, HTML 4.01 transitional with
system ID, and for IBM system DOCTYPE. b=153032 r=karnaze, bzbarsky,
harishd sr=waterson a=valeski, adt
git-svn-id: svn://10.0.0.236/branches/MOZILLA_1_0_BRANCH@124266 18797224-902f-48f8-a5cc-f745e15eee43
---
.../base/public/nsIStyleRuleProcessor.h | 2 +-
mozilla/content/base/src/nsDocumentViewer.cpp | 9 +-
.../content/base/src/nsPlainTextSerializer.h | 2 +-
mozilla/content/base/src/nsRange.cpp | 17 +-
mozilla/content/base/src/nsStyleSet.cpp | 12 +
.../html/content/src/nsGenericHTMLElement.cpp | 24 +-
.../html/document/src/nsHTMLContentSink.cpp | 29 +-
.../html/document/src/nsHTMLDocument.cpp | 45 ++-
.../html/document/src/nsHTMLDocument.h | 6 +-
.../src/nsHTMLFragmentContentSink.cpp | 4 +-
.../html/document/src/nsIHTMLDocument.h | 8 +-
.../html/document/src/nsMarkupDocument.cpp | 24 +-
.../html/document/src/nsMarkupDocument.h | 10 +
.../content/html/style/public/nsICSSLoader.h | 3 +-
.../content/html/style/src/nsCSSLoader.cpp | 16 +-
.../html/style/src/nsCSSStyleSheet.cpp | 17 +-
.../html/style/src/nsHTMLStyleSheet.cpp | 2 +-
mozilla/content/shared/src/nsStyleStruct.cpp | 8 +-
.../xml/document/src/nsXMLDocument.cpp | 3 +-
.../xul/document/src/nsXULDocument.cpp | 20 +-
mozilla/htmlparser/public/nsIDTD.h | 3 +-
.../htmlparser/public/nsIHTMLContentSink.h | 2 +-
mozilla/htmlparser/robot/nsRobotSink.cpp | 4 +-
mozilla/htmlparser/src/CNavDTD.cpp | 25 +-
mozilla/htmlparser/src/COtherDTD.cpp | 6 +-
mozilla/htmlparser/src/COtherElements.h | 2 +-
mozilla/htmlparser/src/nsHTMLNullSink.cpp | 4 +-
mozilla/htmlparser/src/nsHTMLTokenizer.cpp | 3 +-
mozilla/htmlparser/src/nsLoggingSink.cpp | 4 +-
mozilla/htmlparser/src/nsLoggingSink.h | 2 +-
mozilla/htmlparser/src/nsParser.cpp | 266 +++++++++---------
mozilla/layout/base/public/MANIFEST | 1 +
mozilla/layout/base/public/Makefile.in | 1 +
mozilla/layout/base/public/makefile.win | 1 +
mozilla/layout/base/public/nsIFrame.h | 2 +-
mozilla/layout/base/public/nsIPresContext.h | 6 +-
mozilla/layout/base/public/nsIPresShell.h | 4 +-
mozilla/layout/base/src/nsPresContext.cpp | 43 +--
mozilla/layout/base/src/nsPresContext.h | 1 -
mozilla/layout/html/base/src/nsBlockFrame.cpp | 5 +-
mozilla/layout/html/base/src/nsBlockFrame.h | 4 +-
.../html/base/src/nsBlockReflowState.cpp | 3 +-
mozilla/layout/html/base/src/nsFrame.cpp | 2 +-
mozilla/layout/html/base/src/nsFrame.h | 2 +-
.../layout/html/base/src/nsInlineFrame.cpp | 7 +-
mozilla/layout/html/base/src/nsInlineFrame.h | 4 +-
mozilla/layout/html/base/src/nsLineBox.cpp | 6 +-
mozilla/layout/html/base/src/nsLineBox.h | 2 +-
mozilla/layout/html/base/src/nsLineLayout.cpp | 48 ++--
mozilla/layout/html/base/src/nsLineLayout.h | 12 +-
.../html/base/src/nsPlaceholderFrame.cpp | 4 +-
.../layout/html/base/src/nsPlaceholderFrame.h | 4 +-
mozilla/layout/html/base/src/nsPresShell.cpp | 12 +-
mozilla/layout/html/base/src/nsTextFrame.cpp | 11 +-
.../html/table/src/nsTableCellFrame.cpp | 2 +-
.../layout/html/table/src/nsTableFrame.cpp | 2 +-
mozilla/layout/html/tests/Makefile.in | 1 +
mozilla/layout/html/tests/makefile.win | 1 +
mozilla/parser/htmlparser/public/nsIDTD.h | 3 +-
.../htmlparser/public/nsIHTMLContentSink.h | 2 +-
.../parser/htmlparser/robot/nsRobotSink.cpp | 4 +-
mozilla/parser/htmlparser/src/CNavDTD.cpp | 25 +-
mozilla/parser/htmlparser/src/COtherDTD.cpp | 6 +-
.../parser/htmlparser/src/COtherElements.h | 2 +-
.../parser/htmlparser/src/nsHTMLNullSink.cpp | 4 +-
.../parser/htmlparser/src/nsHTMLTokenizer.cpp | 3 +-
.../parser/htmlparser/src/nsLoggingSink.cpp | 4 +-
mozilla/parser/htmlparser/src/nsLoggingSink.h | 2 +-
mozilla/parser/htmlparser/src/nsParser.cpp | 266 +++++++++---------
.../webshell/tests/viewer/nsBrowserWindow.cpp | 2 +-
70 files changed, 557 insertions(+), 539 deletions(-)
diff --git a/mozilla/content/base/public/nsIStyleRuleProcessor.h b/mozilla/content/base/public/nsIStyleRuleProcessor.h
index 7ecf44173ea..35676c99358 100644
--- a/mozilla/content/base/public/nsIStyleRuleProcessor.h
+++ b/mozilla/content/base/public/nsIStyleRuleProcessor.h
@@ -90,7 +90,7 @@ struct RuleProcessorData {
PRPackedBool mIsHTMLContent; // if content, then does QI on HTMLContent, true or false
PRPackedBool mIsHTMLLink; // if content, calls nsStyleUtil::IsHTMLLink
PRPackedBool mIsSimpleXLink; // if content, calls nsStyleUtil::IsSimpleXLink
- PRPackedBool mIsQuirkMode; // Possibly remove use of this in SelectorMatches?
+ nsCompatibility mCompatMode; // Possibly remove use of this in SelectorMatches?
PRPackedBool mHasAttributes; // if content, content->GetAttrCount() > 0
PRPackedBool mIsChecked; // checked/selected attribute for option and select elements
nsLinkState mLinkState; // if a link, this is the state, otherwise unknown
diff --git a/mozilla/content/base/src/nsDocumentViewer.cpp b/mozilla/content/base/src/nsDocumentViewer.cpp
index 3961fb3352b..40fec04ffcb 100644
--- a/mozilla/content/base/src/nsDocumentViewer.cpp
+++ b/mozilla/content/base/src/nsDocumentViewer.cpp
@@ -1704,6 +1704,7 @@ DocumentViewerImpl::SetDOMDocument(nsIDOMDocument *aDocument)
NS_IMETHODIMP
DocumentViewerImpl::SetUAStyleSheet(nsIStyleSheet* aUAStyleSheet)
{
+ NS_ASSERTION(aUAStyleSheet, "unexpected null pointer");
if (aUAStyleSheet) {
nsCOMPtr sheet(do_QueryInterface(aUAStyleSheet));
nsCOMPtr newSheet;
@@ -3492,14 +3493,14 @@ DocumentViewerImpl::ReflowPrintObject(PrintObject * aPO, PRBool aDoCalcShrink)
}
#endif // NS_PRINT_PREVIEW
+ nsCompatibility mode;
+ mPresContext->GetCompatibilityMode(&mode);
+
// Setup hierarchical relationship in view manager
aPO->mViewManager->SetRootView(aPO->mRootView);
aPO->mPresShell->Init(document, aPO->mPresContext,
- aPO->mViewManager, aPO->mStyleSet);
+ aPO->mViewManager, aPO->mStyleSet, mode);
- nsCompatibility mode;
- mPresContext->GetCompatibilityMode(&mode);
- aPO->mPresContext->SetCompatibilityMode(mode);
if (!containerIsSet) {
nsCOMPtr supps(do_QueryInterface(aPO->mWebShell));
aPO->mPresContext->SetContainer(supps);
diff --git a/mozilla/content/base/src/nsPlainTextSerializer.h b/mozilla/content/base/src/nsPlainTextSerializer.h
index 2b5e40f0994..ea076e54d76 100644
--- a/mozilla/content/base/src/nsPlainTextSerializer.h
+++ b/mozilla/content/base/src/nsPlainTextSerializer.h
@@ -97,7 +97,7 @@ public:
NS_IMETHOD AddLeaf(const nsIParserNode& aNode);
NS_IMETHOD AddComment(const nsIParserNode& aNode) { return NS_OK; }
NS_IMETHOD AddProcessingInstruction(const nsIParserNode& aNode) { return NS_OK; }
- NS_IMETHOD AddDocTypeDecl(const nsIParserNode& aNode, PRInt32 aMode=0) { return NS_OK; }
+ NS_IMETHOD AddDocTypeDecl(const nsIParserNode& aNode) { return NS_OK; }
NS_IMETHOD FlushPendingNotifications() { return NS_OK; }
NS_IMETHOD SetDocumentCharset(nsAString& aCharset) { return NS_OK; }
NS_IMETHOD NotifyTagObservers(nsIParserNode* aNode) { return NS_OK; }
diff --git a/mozilla/content/base/src/nsRange.cpp b/mozilla/content/base/src/nsRange.cpp
index 7c42c14776d..d9bf03b7441 100644
--- a/mozilla/content/base/src/nsRange.cpp
+++ b/mozilla/content/base/src/nsRange.cpp
@@ -2811,7 +2811,22 @@ nsRange::CreateContextualFragment(const nsAString& aFragment,
mStartParent->GetOwnerDocument(getter_AddRefs(ownerDoc));
nsCOMPtr htmlDoc(do_QueryInterface(ownerDoc));
if (htmlDoc) {
- htmlDoc->GetDTDMode(mode);
+ nsCompatibility compatMode;
+ htmlDoc->GetCompatibilityMode(compatMode);
+ switch (compatMode) {
+ case eCompatibility_NavQuirks:
+ mode = eDTDMode_quirks;
+ break;
+ case eCompatibility_AlmostStandards:
+ mode = eDTDMode_almost_standards;
+ break;
+ case eCompatibility_FullStandards:
+ mode = eDTDMode_full_standards;
+ break;
+ default:
+ NS_NOTREACHED("unknown mode");
+ break;
+ }
}
result = parser->ParseFragment(aFragment, (void*)0,
tagStack,
diff --git a/mozilla/content/base/src/nsStyleSet.cpp b/mozilla/content/base/src/nsStyleSet.cpp
index dfdf41c317f..48245cf8e28 100644
--- a/mozilla/content/base/src/nsStyleSet.cpp
+++ b/mozilla/content/base/src/nsStyleSet.cpp
@@ -864,9 +864,21 @@ NS_IMETHODIMP StyleSetImpl::EnableQuirkStyleSheet(PRBool aEnable)
}
}
}
+ NS_ASSERTION(mQuirkStyleSheet, "no quirk stylesheet");
if (mQuirkStyleSheet) {
#if defined(DEBUG_warren) || defined(DEBUG_attinasi)
printf( "%s Quirk StyleSheet\n", aEnable ? "Enabling" : "Disabling" );
+#endif
+#ifdef DEBUG_dbaron // XXX Make this |DEBUG| once it stops firing.
+ PRUint32 count = 0;
+ if (mAgentRuleProcessors)
+ mAgentRuleProcessors->Count(&count);
+ PRBool enabledNow;
+ mQuirkStyleSheet->GetEnabled(enabledNow);
+ NS_ASSERTION(count == 0 || aEnable == enabledNow,
+ "enabling/disabling quirk stylesheet too late");
+ if (count != 0 && aEnable == enabledNow)
+ printf("WARNING: We set the quirks mode too many times.\n"); // we do!
#endif
mQuirkStyleSheet->SetEnabled(aEnable);
}
diff --git a/mozilla/content/html/content/src/nsGenericHTMLElement.cpp b/mozilla/content/html/content/src/nsGenericHTMLElement.cpp
index e70d718d254..97ef1368374 100644
--- a/mozilla/content/html/content/src/nsGenericHTMLElement.cpp
+++ b/mozilla/content/html/content/src/nsGenericHTMLElement.cpp
@@ -1255,24 +1255,14 @@ static nsIHTMLStyleSheet* GetAttrStyleSheet(nsIDocument* aDocument)
PRBool
nsGenericHTMLElement::InNavQuirksMode(nsIDocument* aDoc)
{
- PRBool status = PR_FALSE;
- if (aDoc) {
- nsCompatibility mode;
- // multiple shells on the same doc are out of luck
- nsCOMPtr shell;
- aDoc->GetShellAt(0, getter_AddRefs(shell));
- if (shell) {
- nsCOMPtr presContext;
- shell->GetPresContext(getter_AddRefs(presContext));
- if (presContext) {
- presContext->GetCompatibilityMode(&mode);
- if (eCompatibility_NavQuirks == mode) {
- status = PR_TRUE;
- }
- }
- }
+ nsCOMPtr doc(do_QueryInterface(aDoc));
+ if (!doc) {
+ return PR_FALSE;
}
- return status;
+
+ nsCompatibility mode;
+ doc->GetCompatibilityMode(mode);
+ return mode == eCompatibility_NavQuirks;
}
nsresult
diff --git a/mozilla/content/html/document/src/nsHTMLContentSink.cpp b/mozilla/content/html/document/src/nsHTMLContentSink.cpp
index 2e00608ec0f..8114e193426 100644
--- a/mozilla/content/html/document/src/nsHTMLContentSink.cpp
+++ b/mozilla/content/html/document/src/nsHTMLContentSink.cpp
@@ -250,7 +250,7 @@ public:
NS_IMETHOD AddLeaf(const nsIParserNode& aNode);
NS_IMETHOD AddComment(const nsIParserNode& aNode);
NS_IMETHOD AddProcessingInstruction(const nsIParserNode& aNode);
- NS_IMETHOD AddDocTypeDecl(const nsIParserNode& aNode, PRInt32 aMode=0);
+ NS_IMETHOD AddDocTypeDecl(const nsIParserNode& aNode);
NS_IMETHOD WillProcessTokens(void);
NS_IMETHOD DidProcessTokens(void);
NS_IMETHOD WillProcessAToken(void);
@@ -2650,7 +2650,22 @@ HTMLContentSink::WillBuildModel(void)
mScrolledToRefAlready = PR_FALSE;
if (mHTMLDocument) {
- mHTMLDocument->SetDTDMode(mParser? mParser->GetParseMode():eDTDMode_quirks);
+ nsCompatibility mode = eCompatibility_NavQuirks;
+ if (mParser) {
+ nsDTDMode dtdMode = mParser->GetParseMode();
+ switch (dtdMode) {
+ case eDTDMode_full_standards:
+ mode = eCompatibility_FullStandards;
+ break;
+ case eDTDMode_almost_standards:
+ mode = eCompatibility_AlmostStandards;
+ break;
+ default:
+ mode = eCompatibility_NavQuirks;
+ break;
+ }
+ }
+ mHTMLDocument->SetCompatibilityMode(mode);
}
// Notify document that the load is beginning
@@ -3522,14 +3537,12 @@ nsresult HTMLContentSink::AddProcessingInstruction(const nsIParserNode& aNode) {
*/
NS_IMETHODIMP
-HTMLContentSink::AddDocTypeDecl(const nsIParserNode& aNode, PRInt32 aMode)
+HTMLContentSink::AddDocTypeDecl(const nsIParserNode& aNode)
{
nsresult rv = NS_OK;
MOZ_TIMER_DEBUGLOG(("Start: nsHTMLContentSink::AddDocTypeDecl()\n"));
MOZ_TIMER_START(mWatch);
- mHTMLDocument->SetDTDMode((nsDTDMode)aMode);
-
nsCOMPtr doc(do_QueryInterface(mHTMLDocument));
if (!doc)
@@ -4452,11 +4465,11 @@ HTMLContentSink::ProcessStyleLink(nsIHTMLContent* aElement,
nsAutoString params;
nsParserUtils::SplitMimeType(aType, mimeType, params);
- nsDTDMode mode;
- mHTMLDocument->GetDTDMode(mode);
+ nsCompatibility mode;
+ mHTMLDocument->GetCompatibilityMode(mode);
PRBool isStyleSheet = PR_FALSE; // see bug 18817
- if (eDTDMode_strict== mode) {
+ if (eCompatibility_NavQuirks != mode) {
if (mimeType.EqualsIgnoreCase("text/css")) {
isStyleSheet = PR_TRUE; // strict mode + good mime type
}
diff --git a/mozilla/content/html/document/src/nsHTMLDocument.cpp b/mozilla/content/html/document/src/nsHTMLDocument.cpp
index 42e64f34c2e..bf9e239c371 100644
--- a/mozilla/content/html/document/src/nsHTMLDocument.cpp
+++ b/mozilla/content/html/document/src/nsHTMLDocument.cpp
@@ -301,7 +301,7 @@ nsHTMLDocument::nsHTMLDocument()
mAnchors = nsnull;
mLayers = nsnull;
mParser = nsnull;
- mDTDMode = eDTDMode_quirks;
+ mCompatMode = eCompatibility_NavQuirks;
mCSSLoader = nsnull;
mForms = nsnull;
@@ -508,17 +508,8 @@ nsHTMLDocument::CreateShell(nsIPresContext* aContext,
nsIStyleSet* aStyleSet,
nsIPresShell** aInstancePtrResult)
{
- nsresult result = nsMarkupDocument::CreateShell(aContext,
- aViewManager,
- aStyleSet,
- aInstancePtrResult);
-
- if (NS_SUCCEEDED(result)) {
- aContext->SetCompatibilityMode(((eDTDMode_strict== mDTDMode) ?
- eCompatibility_Standard :
- eCompatibility_NavQuirks));
- }
- return result;
+ return doCreateShell(aContext, aViewManager, aStyleSet,
+ mCompatMode, aInstancePtrResult);
}
// The following Try*Charset will return PR_FALSE only if the charset source
@@ -1356,7 +1347,7 @@ nsHTMLDocument::GetCSSLoader(nsICSSLoader*& aLoader)
}
if (mCSSLoader) {
mCSSLoader->SetCaseSensitive(PR_FALSE);
- mCSSLoader->SetQuirkMode(PRBool(eDTDMode_strict!= mDTDMode));
+ mCSSLoader->SetCompatibilityMode(mCompatMode);
}
aLoader = mCSSLoader;
NS_IF_ADDREF(aLoader);
@@ -1365,27 +1356,25 @@ nsHTMLDocument::GetCSSLoader(nsICSSLoader*& aLoader)
NS_IMETHODIMP
-nsHTMLDocument::GetDTDMode(nsDTDMode& aMode)
+nsHTMLDocument::GetCompatibilityMode(nsCompatibility& aMode)
{
- aMode = mDTDMode;
+ aMode = mCompatMode;
return NS_OK;
}
NS_IMETHODIMP
-nsHTMLDocument::SetDTDMode(nsDTDMode aMode)
+nsHTMLDocument::SetCompatibilityMode(nsCompatibility aMode)
{
- mDTDMode = aMode;
+ mCompatMode = aMode;
if (mCSSLoader) {
- mCSSLoader->SetQuirkMode(PRBool(eDTDMode_strict!= mDTDMode));
+ mCSSLoader->SetCompatibilityMode(mCompatMode);
}
nsCOMPtr shell = (nsIPresShell*)mPresShells.SafeElementAt(0);
if (shell) {
nsCOMPtr pc;
shell->GetPresContext(getter_AddRefs(pc));
if (pc) {
- pc->SetCompatibilityMode(((eDTDMode_strict== mDTDMode) ?
- eCompatibility_Standard :
- eCompatibility_NavQuirks));
+ pc->SetCompatibilityMode(mCompatMode);
}
}
@@ -3356,17 +3345,19 @@ nsHTMLDocument::RouteEvent(nsIDOMEvent* aEvt)
}
// readonly attribute DOMString compatMode;
-// Returns "BackCompat" if we are in quirks mode,
-// "CSS1Compat" if we are in strict mode. See bug 105640.
-// This was implemented to match MSIE's compatMode property
+// Returns "BackCompat" if we are in quirks mode, "CSS1Compat" if we are
+// in almost standards or full standards mode. See bug 105640. This was
+// implemented to match MSIE's compatMode property
NS_IMETHODIMP
nsHTMLDocument::GetCompatMode(nsAString& aCompatMode)
{
aCompatMode.Truncate();
- NS_ASSERTION((mDTDMode == eDTDMode_quirks) || (mDTDMode == eDTDMode_strict),
- "mDTDMode is neither quirks nor strict for this document");
+ NS_ASSERTION(mCompatMode == eCompatibility_NavQuirks ||
+ mCompatMode == eCompatibility_AlmostStandards ||
+ mCompatMode == eCompatibility_FullStandards,
+ "mCompatMode is neither quirks nor strict for this document");
- if (mDTDMode == eDTDMode_quirks) {
+ if (mCompatMode == eCompatibility_NavQuirks) {
aCompatMode.Assign(NS_LITERAL_STRING("BackCompat"));
} else {
aCompatMode.Assign(NS_LITERAL_STRING("CSS1Compat"));
diff --git a/mozilla/content/html/document/src/nsHTMLDocument.h b/mozilla/content/html/document/src/nsHTMLDocument.h
index 73470cea48c..0fa03420ddf 100644
--- a/mozilla/content/html/document/src/nsHTMLDocument.h
+++ b/mozilla/content/html/document/src/nsHTMLDocument.h
@@ -123,8 +123,8 @@ public:
NS_IMETHOD SetLastModified(const nsAString& aLastModified);
NS_IMETHOD SetReferrer(const nsAString& aReferrer);
- NS_IMETHOD GetDTDMode(nsDTDMode& aMode);
- NS_IMETHOD SetDTDMode(nsDTDMode aMode);
+ NS_IMETHOD GetCompatibilityMode(nsCompatibility& aMode);
+ NS_IMETHOD SetCompatibilityMode(nsCompatibility aMode);
NS_IMETHOD_(PRBool) IsWriting() { return mWriteLevel != PRUint32(0); }
@@ -236,7 +236,7 @@ protected:
nsString* mLastModified;
nsString* mReferrer;
nsCOMPtr mHttpChannel;
- nsDTDMode mDTDMode;
+ nsCompatibility mCompatMode;
nsCOMPtr mImageMaps;
nsContentList *mImages;
diff --git a/mozilla/content/html/document/src/nsHTMLFragmentContentSink.cpp b/mozilla/content/html/document/src/nsHTMLFragmentContentSink.cpp
index 0412197ed9a..7287ce0e58f 100644
--- a/mozilla/content/html/document/src/nsHTMLFragmentContentSink.cpp
+++ b/mozilla/content/html/document/src/nsHTMLFragmentContentSink.cpp
@@ -89,7 +89,7 @@ public:
NS_IMETHOD AddLeaf(const nsIParserNode& aNode);
NS_IMETHOD AddComment(const nsIParserNode& aNode);
NS_IMETHOD AddProcessingInstruction(const nsIParserNode& aNode);
- NS_IMETHOD AddDocTypeDecl(const nsIParserNode& aNode, PRInt32 aMode=0);
+ NS_IMETHOD AddDocTypeDecl(const nsIParserNode& aNode);
// nsIHTMLContentSink
NS_IMETHOD BeginContext(PRInt32 aID);
@@ -715,7 +715,7 @@ nsHTMLFragmentContentSink::AddProcessingInstruction(const nsIParserNode& aNode)
*/
NS_IMETHODIMP
-nsHTMLFragmentContentSink::AddDocTypeDecl(const nsIParserNode& aNode, PRInt32 aMode)
+nsHTMLFragmentContentSink::AddDocTypeDecl(const nsIParserNode& aNode)
{
return NS_OK;
}
diff --git a/mozilla/content/html/document/src/nsIHTMLDocument.h b/mozilla/content/html/document/src/nsIHTMLDocument.h
index d9c4c92ed14..6f691901958 100644
--- a/mozilla/content/html/document/src/nsIHTMLDocument.h
+++ b/mozilla/content/html/document/src/nsIHTMLDocument.h
@@ -39,7 +39,7 @@
#define nsIHTMLDocument_h___
#include "nsISupports.h"
-#include "nsIDTD.h"
+#include "nsCompatibility.h"
class nsIImageMap;
class nsString;
@@ -76,10 +76,10 @@ public:
NS_IMETHOD SetReferrer(const nsAString& aReferrer) = 0;
/**
- * Access DTD compatibility mode for this document
+ * Access compatibility mode for this document
*/
- NS_IMETHOD GetDTDMode(nsDTDMode& aMode) = 0;
- NS_IMETHOD SetDTDMode(nsDTDMode aMode) = 0;
+ NS_IMETHOD GetCompatibilityMode(nsCompatibility& aMode) = 0;
+ NS_IMETHOD SetCompatibilityMode(nsCompatibility aMode) = 0;
/*
* Returns true if document.domain was set for this document
diff --git a/mozilla/content/html/document/src/nsMarkupDocument.cpp b/mozilla/content/html/document/src/nsMarkupDocument.cpp
index b942f4fa3f8..11baf8aabec 100644
--- a/mozilla/content/html/document/src/nsMarkupDocument.cpp
+++ b/mozilla/content/html/document/src/nsMarkupDocument.cpp
@@ -61,11 +61,22 @@ nsMarkupDocument::CreateShell(nsIPresContext* aContext,
nsIViewManager* aViewManager,
nsIStyleSet* aStyleSet,
nsIPresShell** aInstancePtrResult)
+{
+ // Don't add anything here. Add it to |doCreateShell| instead. This
+ // exists so nsHTMLDocument can pass PR_TRUE for the 4th parameter
+ // some of the time.
+ return doCreateShell(aContext, aViewManager, aStyleSet,
+ eCompatibility_FullStandards, aInstancePtrResult);
+}
+
+nsresult
+nsMarkupDocument::doCreateShell(nsIPresContext* aContext,
+ nsIViewManager* aViewManager,
+ nsIStyleSet* aStyleSet,
+ nsCompatibility aCompatMode,
+ nsIPresShell** aInstancePtrResult)
{
NS_PRECONDITION(nsnull != aInstancePtrResult, "null ptr");
- if (nsnull == aInstancePtrResult) {
- return NS_ERROR_NULL_POINTER;
- }
nsresult rv;
nsCOMPtr shell(do_CreateInstance(kPresShellCID,&rv));
@@ -73,7 +84,7 @@ nsMarkupDocument::CreateShell(nsIPresContext* aContext,
return rv;
}
- rv = shell->Init(this, aContext, aViewManager, aStyleSet);
+ rv = shell->Init(this, aContext, aViewManager, aStyleSet, aCompatMode);
if (NS_FAILED(rv)) {
return rv;
}
@@ -83,11 +94,6 @@ nsMarkupDocument::CreateShell(nsIPresContext* aContext,
*aInstancePtrResult = shell.get();
NS_ADDREF(*aInstancePtrResult);
- // tell the context the mode we want (always standard, which
- // should be correct for everything except HTML)
- // nsHTMLDocument overrides this method and sets it differently
- aContext->SetCompatibilityMode(eCompatibility_Standard);
-
return NS_OK;
}
diff --git a/mozilla/content/html/document/src/nsMarkupDocument.h b/mozilla/content/html/document/src/nsMarkupDocument.h
index 52fddec8a5a..20eafc4e2b9 100644
--- a/mozilla/content/html/document/src/nsMarkupDocument.h
+++ b/mozilla/content/html/document/src/nsMarkupDocument.h
@@ -39,6 +39,7 @@
#define nsMarkupDocument_h___
#include "nsDocument.h"
+#include "nsCompatibility.h"
/**
* MODULE NOTES:
@@ -62,6 +63,15 @@ public:
nsIViewManager* aViewManager,
nsIStyleSet* aStyleSet,
nsIPresShell** aInstancePtrResult);
+protected:
+ // To allow different implementations to choose the quirks mode
+ // differently for their |CreateShell| without overriding the whole
+ // thing.
+ nsresult doCreateShell(nsIPresContext* aContext,
+ nsIViewManager* aViewManager,
+ nsIStyleSet* aStyleSet,
+ nsCompatibility aCompatMode,
+ nsIPresShell** aInstancePtrResult);
};
#endif /* nsMarkupDocument_h___ */
diff --git a/mozilla/content/html/style/public/nsICSSLoader.h b/mozilla/content/html/style/public/nsICSSLoader.h
index a2bbaf483da..8573bf20b08 100644
--- a/mozilla/content/html/style/public/nsICSSLoader.h
+++ b/mozilla/content/html/style/public/nsICSSLoader.h
@@ -40,6 +40,7 @@
#include "nsISupports.h"
#include "nsAString.h"
+#include "nsCompatibility.h"
#include "nsICSSImportRule.h"
class nsIAtom;
@@ -68,7 +69,7 @@ public:
NS_IMETHOD DropDocumentReference(void) = 0; // notification that doc is going away
NS_IMETHOD SetCaseSensitive(PRBool aCaseSensitive) = 0;
- NS_IMETHOD SetQuirkMode(PRBool aQuirkMode) = 0;
+ NS_IMETHOD SetCompatibilityMode(nsCompatibility aCompatMode) = 0;
NS_IMETHOD SetPreferredSheet(const nsAString& aTitle) = 0;
// Get/Recycle a CSS parser for general use
diff --git a/mozilla/content/html/style/src/nsCSSLoader.cpp b/mozilla/content/html/style/src/nsCSSLoader.cpp
index 068b73c01f3..7a161cb3620 100644
--- a/mozilla/content/html/style/src/nsCSSLoader.cpp
+++ b/mozilla/content/html/style/src/nsCSSLoader.cpp
@@ -216,7 +216,7 @@ public:
NS_IMETHOD DropDocumentReference(void);
NS_IMETHOD SetCaseSensitive(PRBool aCaseSensitive);
- NS_IMETHOD SetQuirkMode(PRBool aQuirkMode);
+ NS_IMETHOD SetCompatibilityMode(nsCompatibility aCompatMode);
NS_IMETHOD SetPreferredSheet(const nsAString& aTitle);
NS_IMETHOD GetParserFor(nsICSSStyleSheet* aSheet,
@@ -290,7 +290,7 @@ public:
nsIDocument* mDocument; // the document we live for
PRBool mCaseSensitive; // is document CSS case sensitive
- PRBool mNavQuirkMode; // should CSS be in quirk mode
+ nsCompatibility mCompatMode;
nsString mPreferredSheet; // title of preferred sheet
nsISupportsArray* mParsers; // array of CSS parsers
@@ -445,7 +445,7 @@ CSSLoaderImpl::CSSLoaderImpl(void)
NS_INIT_REFCNT();
mDocument = nsnull;
mCaseSensitive = PR_FALSE;
- mNavQuirkMode = PR_FALSE;
+ mCompatMode = eCompatibility_FullStandards;
mParsers = nsnull;
SetCharset(NS_LITERAL_STRING(""));
}
@@ -526,9 +526,9 @@ CSSLoaderImpl::SetCaseSensitive(PRBool aCaseSensitive)
}
NS_IMETHODIMP
-CSSLoaderImpl::SetQuirkMode(PRBool aQuirkMode)
+CSSLoaderImpl::SetCompatibilityMode(nsCompatibility aCompatMode)
{
- mNavQuirkMode = aQuirkMode;
+ mCompatMode = aCompatMode;
return NS_OK;
}
@@ -579,7 +579,7 @@ CSSLoaderImpl::GetParserFor(nsICSSStyleSheet* aSheet,
}
if (*aParser) {
(*aParser)->SetCaseSensitive(mCaseSensitive);
- (*aParser)->SetQuirkMode(mNavQuirkMode);
+ (*aParser)->SetQuirkMode(mCompatMode == eCompatibility_NavQuirks);
(*aParser)->SetCharset(mCharset);
if (aSheet) {
(*aParser)->SetStyleSheet(aSheet);
@@ -621,13 +621,13 @@ SheetLoadData::OnStreamComplete(nsIStreamLoader* aLoader,
nsCOMPtr request;
aLoader->GetRequest(getter_AddRefs(request));
nsCAutoString contentType;
- if (! (mLoader->mNavQuirkMode)) {
+ if (mLoader->mCompatMode != eCompatibility_NavQuirks) {
nsCOMPtr channel(do_QueryInterface(request));
if (channel) {
channel->GetContentType(contentType);
}
}
- if (mLoader->mNavQuirkMode ||
+ if (mLoader->mCompatMode == eCompatibility_NavQuirks ||
contentType.Equals(NS_LITERAL_CSTRING("text/css")) ||
contentType.IsEmpty()) {
/*
diff --git a/mozilla/content/html/style/src/nsCSSStyleSheet.cpp b/mozilla/content/html/style/src/nsCSSStyleSheet.cpp
index 1a0298ed8ad..8e5027625f1 100644
--- a/mozilla/content/html/style/src/nsCSSStyleSheet.cpp
+++ b/mozilla/content/html/style/src/nsCSSStyleSheet.cpp
@@ -3257,13 +3257,11 @@ RuleProcessorData::RuleProcessorData(nsIPresContext* aPresContext,
mPreviousSiblingData = nsnull;
mParentData = nsnull;
+ // get the compat. mode (unless it is provided)
if(!aCompat) {
- // get the compat. mode (unless it is provided)
- nsCompatibility quirkMode = eCompatibility_Standard;
- mPresContext->GetCompatibilityMode(&quirkMode);
- mIsQuirkMode = eCompatibility_Standard == quirkMode ? PR_FALSE : PR_TRUE;
+ mPresContext->GetCompatibilityMode(&mCompatMode);
} else {
- mIsQuirkMode = eCompatibility_Standard == *aCompat ? PR_FALSE : PR_TRUE;
+ mCompatMode = *aCompat;
}
@@ -3739,7 +3737,8 @@ static PRBool SelectorMatches(RuleProcessorData &data,
((nsnull != aSelector->mIDList) || (nsnull != aSelector->mClassList))) { // test for ID & class match
result = localFalse;
if (data.mStyledContent) {
- PRBool isCaseSensitive = !data.mIsQuirkMode; // bug 93371
+ // case sensitivity: bug 93371
+ PRBool isCaseSensitive = data.mCompatMode != eCompatibility_NavQuirks;
nsAtomList* IDList = aSelector->mIDList;
if (nsnull == IDList) {
result = PR_TRUE;
@@ -3810,7 +3809,7 @@ static PRBool SelectorMatchesTree(RuleProcessorData &data,
// for adjacent sibling combinators, the content to test against the
// selector is the previous sibling
- nsCompatibility compat = curdata->mIsQuirkMode ? eCompatibility_NavQuirks : eCompatibility_Standard;
+ nsCompatibility compat = curdata->mCompatMode;
RuleProcessorData* newdata;
if (PRUnichar('+') == selector->mOperator) {
newdata = curdata->mPreviousSiblingData;
@@ -4451,9 +4450,9 @@ CSSRuleProcessor::GetRuleCascade(nsIPresContext* aPresContext, nsIAtom* aMedium)
mSheets->EnumerateForwards(CascadeSheetRulesInto, &data);
PutRulesInList(&data.mRuleArrays, cascade->mWeightedRules);
- nsCompatibility quirkMode = eCompatibility_Standard;
+ nsCompatibility quirkMode = eCompatibility_FullStandards;
aPresContext->GetCompatibilityMode(&quirkMode);
- PRBool isQuirksMode = (eCompatibility_Standard == quirkMode ? PR_FALSE : PR_TRUE);
+ PRBool isQuirksMode = eCompatibility_NavQuirks == quirkMode;
cascade->mRuleHash.SetCaseSensitive(!isQuirksMode);
cascade->mWeightedRules->EnumerateBackwards(BuildHashEnum, &(cascade->mRuleHash));
diff --git a/mozilla/content/html/style/src/nsHTMLStyleSheet.cpp b/mozilla/content/html/style/src/nsHTMLStyleSheet.cpp
index 864f0b9bb9f..4d8e6e7da1f 100644
--- a/mozilla/content/html/style/src/nsHTMLStyleSheet.cpp
+++ b/mozilla/content/html/style/src/nsHTMLStyleSheet.cpp
@@ -1135,7 +1135,7 @@ HTMLStyleSheetImpl::RulesMatching(ElementRuleProcessorData* aData,
ruleWalker->Forward(mTableColgroupRule);
}
else if (tag == nsHTMLAtoms::table) {
- if (aData->mIsQuirkMode)
+ if (aData->mCompatMode == eCompatibility_NavQuirks)
ruleWalker->Forward(mDocumentColorRule);
}
} // end html element
diff --git a/mozilla/content/shared/src/nsStyleStruct.cpp b/mozilla/content/shared/src/nsStyleStruct.cpp
index d85eba03569..ad3c95228fa 100644
--- a/mozilla/content/shared/src/nsStyleStruct.cpp
+++ b/mozilla/content/shared/src/nsStyleStruct.cpp
@@ -915,12 +915,12 @@ nsStyleTableBorder::nsStyleTableBorder(nsIPresContext* aPresContext)
{
mBorderCollapse = NS_STYLE_BORDER_SEPARATE;
- nsCompatibility compatMode = eCompatibility_Standard;
+ nsCompatibility compatMode = eCompatibility_FullStandards;
if (aPresContext)
- aPresContext->GetCompatibilityMode(&compatMode);
- mEmptyCells = (compatMode == eCompatibility_NavQuirks
+ aPresContext->GetCompatibilityMode(&compatMode);
+ mEmptyCells = (compatMode == eCompatibility_NavQuirks)
? NS_STYLE_TABLE_EMPTY_CELLS_SHOW_BACKGROUND
- : NS_STYLE_TABLE_EMPTY_CELLS_SHOW);
+ : NS_STYLE_TABLE_EMPTY_CELLS_SHOW;
mCaptionSide = NS_SIDE_TOP;
mBorderSpacingX.Reset();
mBorderSpacingY.Reset();
diff --git a/mozilla/content/xml/document/src/nsXMLDocument.cpp b/mozilla/content/xml/document/src/nsXMLDocument.cpp
index 853d9e92122..7643598d869 100644
--- a/mozilla/content/xml/document/src/nsXMLDocument.cpp
+++ b/mozilla/content/xml/document/src/nsXMLDocument.cpp
@@ -1106,7 +1106,8 @@ nsXMLDocument::GetCSSLoader(nsICSSLoader*& aLoader)
result = NS_NewCSSLoader(this, getter_AddRefs(mCSSLoader));
if (mCSSLoader) {
mCSSLoader->SetCaseSensitive(PR_TRUE);
- mCSSLoader->SetQuirkMode(PR_FALSE); // No quirks in XML
+ // No quirks in XML
+ mCSSLoader->SetCompatibilityMode(eCompatibility_FullStandards);
}
}
aLoader = mCSSLoader;
diff --git a/mozilla/content/xul/document/src/nsXULDocument.cpp b/mozilla/content/xul/document/src/nsXULDocument.cpp
index 1a7ed79be52..cb0e5103ff5 100644
--- a/mozilla/content/xul/document/src/nsXULDocument.cpp
+++ b/mozilla/content/xul/document/src/nsXULDocument.cpp
@@ -1060,19 +1060,15 @@ nsXULDocument::CreateShell(nsIPresContext* aContext,
nsIPresShell** aInstancePtrResult)
{
NS_PRECONDITION(aInstancePtrResult, "null ptr");
- if (! aInstancePtrResult)
- return NS_ERROR_NULL_POINTER;
-
- nsresult rv;
nsIPresShell* shell;
- if (NS_FAILED(rv = nsComponentManager::CreateInstance(kPresShellCID,
- nsnull,
- NS_GET_IID(nsIPresShell),
- (void**) &shell)))
+ nsresult rv = CallCreateInstance(kPresShellCID, &shell);
+ if (NS_FAILED(rv))
return rv;
- if (NS_FAILED(rv = shell->Init(this, aContext, aViewManager, aStyleSet))) {
+ rv = shell->Init(this, aContext, aViewManager, aStyleSet,
+ eCompatibility_FullStandards);
+ if (NS_FAILED(rv)) {
NS_RELEASE(shell);
return rv;
}
@@ -1080,9 +1076,6 @@ nsXULDocument::CreateShell(nsIPresContext* aContext,
mPresShells.AppendElement(shell);
*aInstancePtrResult = shell; // addref implicit in CreateInstance()
- // tell the context the mode we want (always standard)
- aContext->SetCompatibilityMode(eCompatibility_Standard);
-
return NS_OK;
}
@@ -1459,7 +1452,8 @@ nsXULDocument::GetCSSLoader(nsICSSLoader*& aLoader)
if (NS_SUCCEEDED(result)) {
result = mCSSLoader->Init(this);
mCSSLoader->SetCaseSensitive(PR_TRUE);
- mCSSLoader->SetQuirkMode(PR_FALSE); // no quirks in XUL
+ // no quirks in XUL
+ mCSSLoader->SetCompatibilityMode(eCompatibility_FullStandards);
}
}
aLoader = mCSSLoader;
diff --git a/mozilla/htmlparser/public/nsIDTD.h b/mozilla/htmlparser/public/nsIDTD.h
index c5d1280b190..c0595495131 100644
--- a/mozilla/htmlparser/public/nsIDTD.h
+++ b/mozilla/htmlparser/public/nsIDTD.h
@@ -72,7 +72,8 @@ enum eAutoDetectResult {
enum nsDTDMode {
eDTDMode_unknown = 0,
eDTDMode_quirks, //pre 4.0 versions
- eDTDMode_strict,
+ eDTDMode_almost_standards,
+ eDTDMode_full_standards,
eDTDMode_autodetect
};
diff --git a/mozilla/htmlparser/public/nsIHTMLContentSink.h b/mozilla/htmlparser/public/nsIHTMLContentSink.h
index 00f032927c2..861896a4913 100644
--- a/mozilla/htmlparser/public/nsIHTMLContentSink.h
+++ b/mozilla/htmlparser/public/nsIHTMLContentSink.h
@@ -326,7 +326,7 @@ public:
*
* @param nsIParserNode reference to parser node interface
*/
- NS_IMETHOD AddDocTypeDecl(const nsIParserNode& aNode, PRInt32 aMode)=0;
+ NS_IMETHOD AddDocTypeDecl(const nsIParserNode& aNode)=0;
/**
* This gets called by the parser to notify observers of
diff --git a/mozilla/htmlparser/robot/nsRobotSink.cpp b/mozilla/htmlparser/robot/nsRobotSink.cpp
index 927ed216cc6..64e43d35c65 100644
--- a/mozilla/htmlparser/robot/nsRobotSink.cpp
+++ b/mozilla/htmlparser/robot/nsRobotSink.cpp
@@ -98,7 +98,7 @@ public:
NS_IMETHOD AddLeaf(const nsIParserNode& aNode);
NS_IMETHOD AddComment(const nsIParserNode& aNode);
NS_IMETHOD AddProcessingInstruction(const nsIParserNode& aNode);
- NS_IMETHOD AddDocTypeDecl(const nsIParserNode& aNode, PRInt32 aMode=0);
+ NS_IMETHOD AddDocTypeDecl(const nsIParserNode& aNode);
NS_IMETHOD WillBuildModel(void) { return NS_OK; }
NS_IMETHOD DidBuildModel(PRInt32 aQualityLevel) { return NS_OK; }
NS_IMETHOD WillInterrupt(void) { return NS_OK; }
@@ -320,7 +320,7 @@ NS_IMETHODIMP RobotSink::AddProcessingInstruction(const nsIParserNode& aNode) {
*/
NS_IMETHODIMP
-RobotSink::AddDocTypeDecl(const nsIParserNode& aNode, PRInt32 aMode)
+RobotSink::AddDocTypeDecl(const nsIParserNode& aNode)
{
return NS_OK;
}
diff --git a/mozilla/htmlparser/src/CNavDTD.cpp b/mozilla/htmlparser/src/CNavDTD.cpp
index 6e85f6e4a75..12e3f46b8a5 100644
--- a/mozilla/htmlparser/src/CNavDTD.cpp
+++ b/mozilla/htmlparser/src/CNavDTD.cpp
@@ -357,7 +357,8 @@ CNavDTD::CanParse(CParserContext& aParserContext,
aParserContext.SetMimeType(NS_LITERAL_CSTRING(kHTMLTextContentType));
if(!theBufHasXML) {
switch(aParserContext.mDTDMode) {
- case eDTDMode_strict:
+ case eDTDMode_full_standards:
+ case eDTDMode_almost_standards:
result=eValidDetect;
break;
default:
@@ -1977,7 +1978,9 @@ nsresult CNavDTD::HandleEndToken(CToken* aToken) {
// If the bit kHandleStrayTag is set then we automatically open up a matching
// start tag ( compatibility ). Currently this bit is set on P tag.
// This also fixes Bug: 22623
- if(gHTMLElements[theChildTag].HasSpecialProperty(kHandleStrayTag) && mDTDMode!=eDTDMode_strict) {
+ if(gHTMLElements[theChildTag].HasSpecialProperty(kHandleStrayTag) &&
+ mDTDMode != eDTDMode_full_standards &&
+ mDTDMode != eDTDMode_almost_standards) {
// Oh boy!! we found a "stray" tag. Nav4.x and IE introduce line break in
// such cases. So, let's simulate that effect for compatibility.
// Ex. Hello
There
@@ -2326,23 +2329,9 @@ nsresult CNavDTD::HandleDocTypeDeclToken(CToken* aToken){
STOP_TIMER();
MOZ_TIMER_DEBUGLOG(("Stop: Parse Time: CNavDTD::HandleDocTypeDeclToken(), this=%p\n", this));
- /*************************************************************
- While the parser is happy to deal with various modes, the
- rest of layout prefers only 2: strict vs. quirks. So we'll
- constrain the modes when reporting to layout.
- *************************************************************/
- nsDTDMode theMode=mDTDMode;
- switch(mDTDMode) {
- case eDTDMode_strict:
- theMode=eDTDMode_strict;
- break;
- default:
- theMode=eDTDMode_quirks;
- }
-
- result = (mSink)? mSink->AddDocTypeDecl(*theNode,theMode):NS_OK;
+ result = (mSink)? mSink->AddDocTypeDecl(*theNode):NS_OK;
- IF_FREE(theNode, &mNodeAllocator);
+ IF_FREE(theNode, &mNodeAllocator);
MOZ_TIMER_DEBUGLOG(("Start: Parse Time: CNavDTD::HandleDocTypeDeclToken(), this=%p\n", this));
START_TIMER();
diff --git a/mozilla/htmlparser/src/COtherDTD.cpp b/mozilla/htmlparser/src/COtherDTD.cpp
index be2c651bb91..5194254e247 100644
--- a/mozilla/htmlparser/src/COtherDTD.cpp
+++ b/mozilla/htmlparser/src/COtherDTD.cpp
@@ -279,7 +279,8 @@ COtherDTD::CanParse(CParserContext& aParserContext, const nsString& aBuffer,
}
else if(PR_TRUE==aParserContext.mMimeType.EqualsWithConversion(kHTMLTextContentType)) {
switch(aParserContext.mDTDMode) {
- case eDTDMode_strict:
+ case eDTDMode_full_standards:
+ case eDTDMode_almost_standards:
result=ePrimaryDetect;
break;
default:
@@ -296,7 +297,8 @@ COtherDTD::CanParse(CParserContext& aParserContext, const nsString& aBuffer,
aParserContext.SetMimeType(NS_LITERAL_CSTRING(kHTMLTextContentType));
if(!theBufHasXML) {
switch(aParserContext.mDTDMode) {
- case eDTDMode_strict:
+ case eDTDMode_full_standards:
+ case eDTDMode_almost_standards:
result=ePrimaryDetect;
break;
default:
diff --git a/mozilla/htmlparser/src/COtherElements.h b/mozilla/htmlparser/src/COtherElements.h
index d874c25d748..9191459c5c9 100644
--- a/mozilla/htmlparser/src/COtherElements.h
+++ b/mozilla/htmlparser/src/COtherElements.h
@@ -1738,7 +1738,7 @@ public:
theStr.Truncate(theLen-1);
theStr.Cut(0,2);
- result = aSink->AddDocTypeDecl(*aNode,eDTDMode_strict);
+ result = aSink->AddDocTypeDecl(*aNode);
}
return result;
}
diff --git a/mozilla/htmlparser/src/nsHTMLNullSink.cpp b/mozilla/htmlparser/src/nsHTMLNullSink.cpp
index 4808afb5adf..320191effe0 100644
--- a/mozilla/htmlparser/src/nsHTMLNullSink.cpp
+++ b/mozilla/htmlparser/src/nsHTMLNullSink.cpp
@@ -68,7 +68,7 @@ public:
NS_IMETHOD AddLeaf(const nsIParserNode& aNode);
NS_IMETHOD AddProcessingInstruction(const nsIParserNode& aNode);
NS_IMETHOD AddComment(const nsIParserNode& aNode);
- NS_IMETHOD AddDocTypeDecl(const nsIParserNode& aNode, PRInt32 aMode=0);
+ NS_IMETHOD AddDocTypeDecl(const nsIParserNode& aNode);
NS_IMETHOD FlushPendingNotifications() {return NS_OK; }
NS_IMETHOD SetDocumentCharset(nsAString& aCharset) {return NS_OK;}
NS_IMETHOD NotifyTagObservers(nsIParserNode* aNode) { return NS_OK; }
@@ -546,7 +546,7 @@ nsHTMLNullSink::AddProcessingInstruction(const nsIParserNode& aNode){
*/
NS_IMETHODIMP
-nsHTMLNullSink::AddDocTypeDecl(const nsIParserNode& aNode, PRInt32 aMode)
+nsHTMLNullSink::AddDocTypeDecl(const nsIParserNode& aNode)
{
#ifdef VERBOSE_DEBUG
DebugDump("<",aNode.GetText(),(mNodeStackPos)*2);
diff --git a/mozilla/htmlparser/src/nsHTMLTokenizer.cpp b/mozilla/htmlparser/src/nsHTMLTokenizer.cpp
index 2b75e4e9900..46499fdd423 100644
--- a/mozilla/htmlparser/src/nsHTMLTokenizer.cpp
+++ b/mozilla/htmlparser/src/nsHTMLTokenizer.cpp
@@ -136,7 +136,8 @@ NS_IMPL_RELEASE(nsHTMLTokenizer)
{
NS_INIT_REFCNT();
- if (aParseMode==eDTDMode_strict) {
+ if (aParseMode==eDTDMode_full_standards ||
+ aParseMode==eDTDMode_almost_standards) {
mFlags = NS_IPARSER_FLAG_STRICT_MODE;
}
else if (aParseMode==eDTDMode_quirks) {
diff --git a/mozilla/htmlparser/src/nsLoggingSink.cpp b/mozilla/htmlparser/src/nsLoggingSink.cpp
index daaf8d7ef7b..874d7d0b2fd 100644
--- a/mozilla/htmlparser/src/nsLoggingSink.cpp
+++ b/mozilla/htmlparser/src/nsLoggingSink.cpp
@@ -292,7 +292,7 @@ nsLoggingSink::AddProcessingInstruction(const nsIParserNode& aNode){
*/
NS_IMETHODIMP
-nsLoggingSink::AddDocTypeDecl(const nsIParserNode& aNode, PRInt32 aMode) {
+nsLoggingSink::AddDocTypeDecl(const nsIParserNode& aNode) {
#ifdef VERBOSE_DEBUG
DebugDump("<",aNode.GetText(),(mNodeStackPos)*2);
@@ -302,7 +302,7 @@ nsLoggingSink::AddDocTypeDecl(const nsIParserNode& aNode, PRInt32 aMode) {
//then proxy the call to the real sink if you have one.
if(mSink) {
- theResult=mSink->AddDocTypeDecl(aNode,aMode);
+ theResult=mSink->AddDocTypeDecl(aNode);
}
return theResult;
diff --git a/mozilla/htmlparser/src/nsLoggingSink.h b/mozilla/htmlparser/src/nsLoggingSink.h
index 0b5fc2e4814..01dabdc5541 100644
--- a/mozilla/htmlparser/src/nsLoggingSink.h
+++ b/mozilla/htmlparser/src/nsLoggingSink.h
@@ -71,7 +71,7 @@ public:
NS_IMETHOD AddLeaf(const nsIParserNode& aNode);
NS_IMETHOD AddComment(const nsIParserNode& aNode);
NS_IMETHOD AddProcessingInstruction(const nsIParserNode& aNode);
- NS_IMETHOD AddDocTypeDecl(const nsIParserNode& aNode, PRInt32 aMode=0);
+ NS_IMETHOD AddDocTypeDecl(const nsIParserNode& aNode);
NS_IMETHOD FlushPendingNotifications() { return NS_OK; }
NS_IMETHOD SetDocumentCharset(nsAString& aCharset) { return NS_OK; }
NS_IMETHOD NotifyTagObservers(nsIParserNode* aNode) { return NS_OK; }
diff --git a/mozilla/htmlparser/src/nsParser.cpp b/mozilla/htmlparser/src/nsParser.cpp
index 356340decdb..d7a095b33a9 100644
--- a/mozilla/htmlparser/src/nsParser.cpp
+++ b/mozilla/htmlparser/src/nsParser.cpp
@@ -741,7 +741,8 @@ static PRInt32 ParsePS(const nsString& aBuffer, PRInt32 aIndex)
// return PR_TRUE on success (includes not present), PR_FALSE on failure
static PRBool ParseDocTypeDecl(const nsString &aBuffer,
PRInt32 *aResultFlags,
- nsString &aPublicID)
+ nsString &aPublicID,
+ nsString &aSystemID)
{
PRBool haveDoctype = PR_FALSE;
*aResultFlags = 0;
@@ -782,7 +783,7 @@ static PRBool ParseDocTypeDecl(const nsString &aBuffer,
theIndex = ParsePS(aBuffer, theIndex+4);
PRInt32 tmpIndex = aBuffer.Find("PUBLIC", PR_TRUE, theIndex, 1);
- if(kNotFound != tmpIndex) {
+ if (kNotFound != tmpIndex) {
theIndex = ParsePS(aBuffer, tmpIndex+6);
// We get here only if we've read '))
+
+ theIndex = ParsePS(aBuffer, tmpIndex+6);
+ PRUnichar next = aBuffer.CharAt(theIndex);
+ if (next != PRUnichar('\"') && next != PRUnichar('\''))
return PR_FALSE;
+
+ PRInt32 SystemIDStart = theIndex + 1;
+ PRInt32 SystemIDEnd = aBuffer.FindChar(next, SystemIDStart);
+
+ if (kNotFound == SystemIDEnd)
+ return PR_FALSE;
+ aSystemID =
+ Substring(aBuffer, SystemIDStart, SystemIDEnd - SystemIDStart);
+ theIndex = ParsePS(aBuffer, SystemIDEnd + 1);
}
+
+ PRUnichar nextChar = aBuffer.CharAt(theIndex);
+ if (nextChar == PRUnichar('['))
+ *aResultFlags |= PARSE_DTD_HAVE_INTERNAL_SUBSET;
+ else if (nextChar != PRUnichar('>'))
+ return PR_FALSE;
}
return PR_TRUE;
}
struct PubIDInfo {
enum eMode {
- eQuirks, /* always quirks mode, unless there's an internal subset */
- eQuirks3, /* ditto, but but pre-HTML4 (no tbody) */
- eStrictIfSysID /* quirks if no system ID, strict if system ID */
+ eQuirks, /* always quirks mode, unless there's an internal subset */
+ eQuirks3, /* ditto, but but pre-HTML4 (no tbody) */
+ eAlmostStandards,/* eCompatibility_AlmostStandards */
+ eFullStandards /* eCompatibility_FullStandards */
/*
* public IDs that should trigger strict mode are not listed
* since we want all future public IDs to trigger strict mode as
@@ -868,7 +878,8 @@ struct PubIDInfo {
};
const char* name;
- eMode mode;
+ eMode mode_if_no_sysid;
+ eMode mode_if_sysid;
};
#define ELEMENTS_OF(array_) (sizeof(array_)/sizeof(array_[0]))
@@ -883,79 +894,81 @@ struct PubIDInfo {
// identifiers below are in lower case (with the correct case following,
// in comments). The case is verified, |#ifdef DEBUG|, below.
static const PubIDInfo kPublicIDs[] = {
- {"+//silmaril//dtd html pro v0r11 19970101//en" /* "+//Silmaril//dtd html Pro v0r11 19970101//EN" */, PubIDInfo::eQuirks3},
- {"-//advasoft ltd//dtd html 3.0 aswedit + extensions//en" /* "-//AdvaSoft Ltd//DTD HTML 3.0 asWedit + extensions//EN" */, PubIDInfo::eQuirks3},
- {"-//as//dtd html 3.0 aswedit + extensions//en" /* "-//AS//DTD HTML 3.0 asWedit + extensions//EN" */, PubIDInfo::eQuirks3},
- {"-//ietf//dtd html 2.0 level 1//en" /* "-//IETF//DTD HTML 2.0 Level 1//EN" */, PubIDInfo::eQuirks3},
- {"-//ietf//dtd html 2.0 level 2//en" /* "-//IETF//DTD HTML 2.0 Level 2//EN" */, PubIDInfo::eQuirks3},
- {"-//ietf//dtd html 2.0 strict level 1//en" /* "-//IETF//DTD HTML 2.0 Strict Level 1//EN" */, PubIDInfo::eQuirks3},
- {"-//ietf//dtd html 2.0 strict level 2//en" /* "-//IETF//DTD HTML 2.0 Strict Level 2//EN" */, PubIDInfo::eQuirks3},
- {"-//ietf//dtd html 2.0 strict//en" /* "-//IETF//DTD HTML 2.0 Strict//EN" */, PubIDInfo::eQuirks3},
- {"-//ietf//dtd html 2.0//en" /* "-//IETF//DTD HTML 2.0//EN" */, PubIDInfo::eQuirks3},
- {"-//ietf//dtd html 2.1e//en" /* "-//IETF//DTD HTML 2.1E//EN" */, PubIDInfo::eQuirks3},
- {"-//ietf//dtd html 3.0//en" /* "-//IETF//DTD HTML 3.0//EN" */, PubIDInfo::eQuirks3},
- {"-//ietf//dtd html 3.0//en//" /* "-//IETF//DTD HTML 3.0//EN//" */, PubIDInfo::eQuirks3},
- {"-//ietf//dtd html 3.2 final//en" /* "-//IETF//DTD HTML 3.2 Final//EN" */, PubIDInfo::eQuirks3},
- {"-//ietf//dtd html 3.2//en" /* "-//IETF//DTD HTML 3.2//EN" */, PubIDInfo::eQuirks3},
- {"-//ietf//dtd html 3//en" /* "-//IETF//DTD HTML 3//EN" */, PubIDInfo::eQuirks3},
- {"-//ietf//dtd html level 0//en" /* "-//IETF//DTD HTML Level 0//EN" */, PubIDInfo::eQuirks3},
- {"-//ietf//dtd html level 0//en//2.0" /* "-//IETF//DTD HTML Level 0//EN//2.0" */, PubIDInfo::eQuirks3},
- {"-//ietf//dtd html level 1//en" /* "-//IETF//DTD HTML Level 1//EN" */, PubIDInfo::eQuirks3},
- {"-//ietf//dtd html level 1//en//2.0" /* "-//IETF//DTD HTML Level 1//EN//2.0" */, PubIDInfo::eQuirks3},
- {"-//ietf//dtd html level 2//en" /* "-//IETF//DTD HTML Level 2//EN" */, PubIDInfo::eQuirks3},
- {"-//ietf//dtd html level 2//en//2.0" /* "-//IETF//DTD HTML Level 2//EN//2.0" */, PubIDInfo::eQuirks3},
- {"-//ietf//dtd html level 3//en" /* "-//IETF//DTD HTML Level 3//EN" */, PubIDInfo::eQuirks3},
- {"-//ietf//dtd html level 3//en//3.0" /* "-//IETF//DTD HTML Level 3//EN//3.0" */, PubIDInfo::eQuirks3},
- {"-//ietf//dtd html strict level 0//en" /* "-//IETF//DTD HTML Strict Level 0//EN" */, PubIDInfo::eQuirks3},
- {"-//ietf//dtd html strict level 0//en//2.0" /* "-//IETF//DTD HTML Strict Level 0//EN//2.0" */, PubIDInfo::eQuirks3},
- {"-//ietf//dtd html strict level 1//en" /* "-//IETF//DTD HTML Strict Level 1//EN" */, PubIDInfo::eQuirks3},
- {"-//ietf//dtd html strict level 1//en//2.0" /* "-//IETF//DTD HTML Strict Level 1//EN//2.0" */, PubIDInfo::eQuirks3},
- {"-//ietf//dtd html strict level 2//en" /* "-//IETF//DTD HTML Strict Level 2//EN" */, PubIDInfo::eQuirks3},
- {"-//ietf//dtd html strict level 2//en//2.0" /* "-//IETF//DTD HTML Strict Level 2//EN//2.0" */, PubIDInfo::eQuirks3},
- {"-//ietf//dtd html strict level 3//en" /* "-//IETF//DTD HTML Strict Level 3//EN" */, PubIDInfo::eQuirks3},
- {"-//ietf//dtd html strict level 3//en//3.0" /* "-//IETF//DTD HTML Strict Level 3//EN//3.0" */, PubIDInfo::eQuirks3},
- {"-//ietf//dtd html strict//en" /* "-//IETF//DTD HTML Strict//EN" */, PubIDInfo::eQuirks3},
- {"-//ietf//dtd html strict//en//2.0" /* "-//IETF//DTD HTML Strict//EN//2.0" */, PubIDInfo::eQuirks3},
- {"-//ietf//dtd html strict//en//3.0" /* "-//IETF//DTD HTML Strict//EN//3.0" */, PubIDInfo::eQuirks3},
- {"-//ietf//dtd html//en" /* "-//IETF//DTD HTML//EN" */, PubIDInfo::eQuirks3},
- {"-//ietf//dtd html//en//2.0" /* "-//IETF//DTD HTML//EN//2.0" */, PubIDInfo::eQuirks3},
- {"-//ietf//dtd html//en//3.0" /* "-//IETF//DTD HTML//EN//3.0" */, PubIDInfo::eQuirks3},
- {"-//metrius//dtd metrius presentational//en" /* "-//Metrius//DTD Metrius Presentational//EN" */, PubIDInfo::eQuirks},
- {"-//microsoft//dtd internet explorer 2.0 html strict//en" /* "-//Microsoft//DTD Internet Explorer 2.0 HTML Strict//EN" */, PubIDInfo::eQuirks3},
- {"-//microsoft//dtd internet explorer 2.0 html//en" /* "-//Microsoft//DTD Internet Explorer 2.0 HTML//EN" */, PubIDInfo::eQuirks3},
- {"-//microsoft//dtd internet explorer 2.0 tables//en" /* "-//Microsoft//DTD Internet Explorer 2.0 Tables//EN" */, PubIDInfo::eQuirks3},
- {"-//microsoft//dtd internet explorer 3.0 html strict//en" /* "-//Microsoft//DTD Internet Explorer 3.0 HTML Strict//EN" */, PubIDInfo::eQuirks3},
- {"-//microsoft//dtd internet explorer 3.0 html//en" /* "-//Microsoft//DTD Internet Explorer 3.0 HTML//EN" */, PubIDInfo::eQuirks3},
- {"-//microsoft//dtd internet explorer 3.0 tables//en" /* "-//Microsoft//DTD Internet Explorer 3.0 Tables//EN" */, PubIDInfo::eQuirks3},
- {"-//netscape comm. corp.//dtd html//en" /* "-//Netscape Comm. Corp.//DTD HTML//EN" */, PubIDInfo::eQuirks3},
- {"-//netscape comm. corp.//dtd strict html//en" /* "-//Netscape Comm. Corp.//DTD Strict HTML//EN" */, PubIDInfo::eQuirks3},
- {"-//o'reilly and associates//dtd html 2.0//en" /* "-//O'Reilly and Associates//DTD HTML 2.0//EN" */, PubIDInfo::eQuirks3},
- {"-//o'reilly and associates//dtd html extended 1.0//en" /* "-//O'Reilly and Associates//DTD HTML Extended 1.0//EN" */, PubIDInfo::eQuirks3},
- {"-//o'reilly and associates//dtd html extended relaxed 1.0//en" /* "-//O'Reilly and Associates//DTD HTML Extended Relaxed 1.0//EN" */, PubIDInfo::eQuirks3},
- {"-//softquad software//dtd hotmetal pro 6.0::19990601::extensions to html 4.0//en" /* "-//SoftQuad Software//DTD HoTMetaL PRO 6.0::19990601::extensions to HTML 4.0//EN" */, PubIDInfo::eQuirks},
- {"-//softquad//dtd hotmetal pro 4.0::19971010::extensions to html 4.0//en" /* "-//SoftQuad//DTD HoTMetaL PRO 4.0::19971010::extensions to HTML 4.0//EN" */, PubIDInfo::eQuirks},
- {"-//spyglass//dtd html 2.0 extended//en" /* "-//Spyglass//DTD HTML 2.0 Extended//EN" */, PubIDInfo::eQuirks3},
- {"-//sq//dtd html 2.0 hotmetal + extensions//en" /* "-//SQ//DTD HTML 2.0 HoTMetaL + extensions//EN" */, PubIDInfo::eQuirks3},
- {"-//sun microsystems corp.//dtd hotjava html//en" /* "-//Sun Microsystems Corp.//DTD HotJava HTML//EN" */, PubIDInfo::eQuirks3},
- {"-//sun microsystems corp.//dtd hotjava strict html//en" /* "-//Sun Microsystems Corp.//DTD HotJava Strict HTML//EN" */, PubIDInfo::eQuirks3},
- {"-//w3c//dtd html 3 1995-03-24//en" /* "-//W3C//DTD HTML 3 1995-03-24//EN" */, PubIDInfo::eQuirks3},
- {"-//w3c//dtd html 3.2 draft//en" /* "-//W3C//DTD HTML 3.2 Draft//EN" */, PubIDInfo::eQuirks3},
- {"-//w3c//dtd html 3.2 final//en" /* "-//W3C//DTD HTML 3.2 Final//EN" */, PubIDInfo::eQuirks3},
- {"-//w3c//dtd html 3.2//en" /* "-//W3C//DTD HTML 3.2//EN" */, PubIDInfo::eQuirks3},
- {"-//w3c//dtd html 3.2s draft//en" /* "-//W3C//DTD HTML 3.2S Draft//EN" */, PubIDInfo::eQuirks3},
- {"-//w3c//dtd html 4.0 frameset//en" /* "-//W3C//DTD HTML 4.0 Frameset//EN" */, PubIDInfo::eQuirks},
- {"-//w3c//dtd html 4.0 transitional//en" /* "-//W3C//DTD HTML 4.0 Transitional//EN" */, PubIDInfo::eQuirks},
- {"-//w3c//dtd html 4.01 frameset//en" /* "-//W3C//DTD HTML 4.01 Frameset//EN" */, PubIDInfo::eStrictIfSysID},
- {"-//w3c//dtd html 4.01 transitional//en" /* "-//W3C//DTD HTML 4.01 Transitional//EN" */, PubIDInfo::eStrictIfSysID},
- {"-//w3c//dtd html experimental 19960712//en" /* "-//W3C//DTD HTML Experimental 19960712//EN" */, PubIDInfo::eQuirks3},
- {"-//w3c//dtd html experimental 970421//en" /* "-//W3C//DTD HTML Experimental 970421//EN" */, PubIDInfo::eQuirks3},
- {"-//w3c//dtd w3 html//en" /* "-//W3C//DTD W3 HTML//EN" */, PubIDInfo::eQuirks3},
- {"-//w3o//dtd w3 html 3.0//en" /* "-//W3O//DTD W3 HTML 3.0//EN" */, PubIDInfo::eQuirks3},
- {"-//w3o//dtd w3 html 3.0//en//" /* "-//W3O//DTD W3 HTML 3.0//EN//" */, PubIDInfo::eQuirks3},
- {"-//w3o//dtd w3 html strict 3.0//en//" /* "-//W3O//DTD W3 HTML Strict 3.0//EN//" */, PubIDInfo::eQuirks3},
- {"-//webtechs//dtd mozilla html 2.0//en" /* "-//WebTechs//DTD Mozilla HTML 2.0//EN" */, PubIDInfo::eQuirks3},
- {"-//webtechs//dtd mozilla html//en" /* "-//WebTechs//DTD Mozilla HTML//EN" */, PubIDInfo::eQuirks3},
- {"html" /* "HTML" */, PubIDInfo::eQuirks3},
+ {"+//silmaril//dtd html pro v0r11 19970101//en" /* "+//Silmaril//dtd html Pro v0r11 19970101//EN" */, PubIDInfo::eQuirks3, PubIDInfo::eQuirks3},
+ {"-//advasoft ltd//dtd html 3.0 aswedit + extensions//en" /* "-//AdvaSoft Ltd//DTD HTML 3.0 asWedit + extensions//EN" */, PubIDInfo::eQuirks3, PubIDInfo::eQuirks3},
+ {"-//as//dtd html 3.0 aswedit + extensions//en" /* "-//AS//DTD HTML 3.0 asWedit + extensions//EN" */, PubIDInfo::eQuirks3, PubIDInfo::eQuirks3},
+ {"-//ietf//dtd html 2.0 level 1//en" /* "-//IETF//DTD HTML 2.0 Level 1//EN" */, PubIDInfo::eQuirks3, PubIDInfo::eQuirks3},
+ {"-//ietf//dtd html 2.0 level 2//en" /* "-//IETF//DTD HTML 2.0 Level 2//EN" */, PubIDInfo::eQuirks3, PubIDInfo::eQuirks3},
+ {"-//ietf//dtd html 2.0 strict level 1//en" /* "-//IETF//DTD HTML 2.0 Strict Level 1//EN" */, PubIDInfo::eQuirks3, PubIDInfo::eQuirks3},
+ {"-//ietf//dtd html 2.0 strict level 2//en" /* "-//IETF//DTD HTML 2.0 Strict Level 2//EN" */, PubIDInfo::eQuirks3, PubIDInfo::eQuirks3},
+ {"-//ietf//dtd html 2.0 strict//en" /* "-//IETF//DTD HTML 2.0 Strict//EN" */, PubIDInfo::eQuirks3, PubIDInfo::eQuirks3},
+ {"-//ietf//dtd html 2.0//en" /* "-//IETF//DTD HTML 2.0//EN" */, PubIDInfo::eQuirks3, PubIDInfo::eQuirks3},
+ {"-//ietf//dtd html 2.1e//en" /* "-//IETF//DTD HTML 2.1E//EN" */, PubIDInfo::eQuirks3, PubIDInfo::eQuirks3},
+ {"-//ietf//dtd html 3.0//en" /* "-//IETF//DTD HTML 3.0//EN" */, PubIDInfo::eQuirks3, PubIDInfo::eQuirks3},
+ {"-//ietf//dtd html 3.0//en//" /* "-//IETF//DTD HTML 3.0//EN//" */, PubIDInfo::eQuirks3, PubIDInfo::eQuirks3},
+ {"-//ietf//dtd html 3.2 final//en" /* "-//IETF//DTD HTML 3.2 Final//EN" */, PubIDInfo::eQuirks3, PubIDInfo::eQuirks3},
+ {"-//ietf//dtd html 3.2//en" /* "-//IETF//DTD HTML 3.2//EN" */, PubIDInfo::eQuirks3, PubIDInfo::eQuirks3},
+ {"-//ietf//dtd html 3//en" /* "-//IETF//DTD HTML 3//EN" */, PubIDInfo::eQuirks3, PubIDInfo::eQuirks3},
+ {"-//ietf//dtd html level 0//en" /* "-//IETF//DTD HTML Level 0//EN" */, PubIDInfo::eQuirks3, PubIDInfo::eQuirks3},
+ {"-//ietf//dtd html level 0//en//2.0" /* "-//IETF//DTD HTML Level 0//EN//2.0" */, PubIDInfo::eQuirks3, PubIDInfo::eQuirks3},
+ {"-//ietf//dtd html level 1//en" /* "-//IETF//DTD HTML Level 1//EN" */, PubIDInfo::eQuirks3, PubIDInfo::eQuirks3},
+ {"-//ietf//dtd html level 1//en//2.0" /* "-//IETF//DTD HTML Level 1//EN//2.0" */, PubIDInfo::eQuirks3, PubIDInfo::eQuirks3},
+ {"-//ietf//dtd html level 2//en" /* "-//IETF//DTD HTML Level 2//EN" */, PubIDInfo::eQuirks3, PubIDInfo::eQuirks3},
+ {"-//ietf//dtd html level 2//en//2.0" /* "-//IETF//DTD HTML Level 2//EN//2.0" */, PubIDInfo::eQuirks3, PubIDInfo::eQuirks3},
+ {"-//ietf//dtd html level 3//en" /* "-//IETF//DTD HTML Level 3//EN" */, PubIDInfo::eQuirks3, PubIDInfo::eQuirks3},
+ {"-//ietf//dtd html level 3//en//3.0" /* "-//IETF//DTD HTML Level 3//EN//3.0" */, PubIDInfo::eQuirks3, PubIDInfo::eQuirks3},
+ {"-//ietf//dtd html strict level 0//en" /* "-//IETF//DTD HTML Strict Level 0//EN" */, PubIDInfo::eQuirks3, PubIDInfo::eQuirks3},
+ {"-//ietf//dtd html strict level 0//en//2.0" /* "-//IETF//DTD HTML Strict Level 0//EN//2.0" */, PubIDInfo::eQuirks3, PubIDInfo::eQuirks3},
+ {"-//ietf//dtd html strict level 1//en" /* "-//IETF//DTD HTML Strict Level 1//EN" */, PubIDInfo::eQuirks3, PubIDInfo::eQuirks3},
+ {"-//ietf//dtd html strict level 1//en//2.0" /* "-//IETF//DTD HTML Strict Level 1//EN//2.0" */, PubIDInfo::eQuirks3, PubIDInfo::eQuirks3},
+ {"-//ietf//dtd html strict level 2//en" /* "-//IETF//DTD HTML Strict Level 2//EN" */, PubIDInfo::eQuirks3, PubIDInfo::eQuirks3},
+ {"-//ietf//dtd html strict level 2//en//2.0" /* "-//IETF//DTD HTML Strict Level 2//EN//2.0" */, PubIDInfo::eQuirks3, PubIDInfo::eQuirks3},
+ {"-//ietf//dtd html strict level 3//en" /* "-//IETF//DTD HTML Strict Level 3//EN" */, PubIDInfo::eQuirks3, PubIDInfo::eQuirks3},
+ {"-//ietf//dtd html strict level 3//en//3.0" /* "-//IETF//DTD HTML Strict Level 3//EN//3.0" */, PubIDInfo::eQuirks3, PubIDInfo::eQuirks3},
+ {"-//ietf//dtd html strict//en" /* "-//IETF//DTD HTML Strict//EN" */, PubIDInfo::eQuirks3, PubIDInfo::eQuirks3},
+ {"-//ietf//dtd html strict//en//2.0" /* "-//IETF//DTD HTML Strict//EN//2.0" */, PubIDInfo::eQuirks3, PubIDInfo::eQuirks3},
+ {"-//ietf//dtd html strict//en//3.0" /* "-//IETF//DTD HTML Strict//EN//3.0" */, PubIDInfo::eQuirks3, PubIDInfo::eQuirks3},
+ {"-//ietf//dtd html//en" /* "-//IETF//DTD HTML//EN" */, PubIDInfo::eQuirks3, PubIDInfo::eQuirks3},
+ {"-//ietf//dtd html//en//2.0" /* "-//IETF//DTD HTML//EN//2.0" */, PubIDInfo::eQuirks3, PubIDInfo::eQuirks3},
+ {"-//ietf//dtd html//en//3.0" /* "-//IETF//DTD HTML//EN//3.0" */, PubIDInfo::eQuirks3, PubIDInfo::eQuirks3},
+ {"-//metrius//dtd metrius presentational//en" /* "-//Metrius//DTD Metrius Presentational//EN" */, PubIDInfo::eQuirks, PubIDInfo::eQuirks},
+ {"-//microsoft//dtd internet explorer 2.0 html strict//en" /* "-//Microsoft//DTD Internet Explorer 2.0 HTML Strict//EN" */, PubIDInfo::eQuirks3, PubIDInfo::eQuirks3},
+ {"-//microsoft//dtd internet explorer 2.0 html//en" /* "-//Microsoft//DTD Internet Explorer 2.0 HTML//EN" */, PubIDInfo::eQuirks3, PubIDInfo::eQuirks3},
+ {"-//microsoft//dtd internet explorer 2.0 tables//en" /* "-//Microsoft//DTD Internet Explorer 2.0 Tables//EN" */, PubIDInfo::eQuirks3, PubIDInfo::eQuirks3},
+ {"-//microsoft//dtd internet explorer 3.0 html strict//en" /* "-//Microsoft//DTD Internet Explorer 3.0 HTML Strict//EN" */, PubIDInfo::eQuirks3, PubIDInfo::eQuirks3},
+ {"-//microsoft//dtd internet explorer 3.0 html//en" /* "-//Microsoft//DTD Internet Explorer 3.0 HTML//EN" */, PubIDInfo::eQuirks3, PubIDInfo::eQuirks3},
+ {"-//microsoft//dtd internet explorer 3.0 tables//en" /* "-//Microsoft//DTD Internet Explorer 3.0 Tables//EN" */, PubIDInfo::eQuirks3, PubIDInfo::eQuirks3},
+ {"-//netscape comm. corp.//dtd html//en" /* "-//Netscape Comm. Corp.//DTD HTML//EN" */, PubIDInfo::eQuirks3, PubIDInfo::eQuirks3},
+ {"-//netscape comm. corp.//dtd strict html//en" /* "-//Netscape Comm. Corp.//DTD Strict HTML//EN" */, PubIDInfo::eQuirks3, PubIDInfo::eQuirks3},
+ {"-//o'reilly and associates//dtd html 2.0//en" /* "-//O'Reilly and Associates//DTD HTML 2.0//EN" */, PubIDInfo::eQuirks3, PubIDInfo::eQuirks3},
+ {"-//o'reilly and associates//dtd html extended 1.0//en" /* "-//O'Reilly and Associates//DTD HTML Extended 1.0//EN" */, PubIDInfo::eQuirks3, PubIDInfo::eQuirks3},
+ {"-//o'reilly and associates//dtd html extended relaxed 1.0//en" /* "-//O'Reilly and Associates//DTD HTML Extended Relaxed 1.0//EN" */, PubIDInfo::eQuirks3, PubIDInfo::eQuirks3},
+ {"-//softquad software//dtd hotmetal pro 6.0::19990601::extensions to html 4.0//en" /* "-//SoftQuad Software//DTD HoTMetaL PRO 6.0::19990601::extensions to HTML 4.0//EN" */, PubIDInfo::eQuirks, PubIDInfo::eQuirks},
+ {"-//softquad//dtd hotmetal pro 4.0::19971010::extensions to html 4.0//en" /* "-//SoftQuad//DTD HoTMetaL PRO 4.0::19971010::extensions to HTML 4.0//EN" */, PubIDInfo::eQuirks, PubIDInfo::eQuirks},
+ {"-//spyglass//dtd html 2.0 extended//en" /* "-//Spyglass//DTD HTML 2.0 Extended//EN" */, PubIDInfo::eQuirks3, PubIDInfo::eQuirks3},
+ {"-//sq//dtd html 2.0 hotmetal + extensions//en" /* "-//SQ//DTD HTML 2.0 HoTMetaL + extensions//EN" */, PubIDInfo::eQuirks3, PubIDInfo::eQuirks3},
+ {"-//sun microsystems corp.//dtd hotjava html//en" /* "-//Sun Microsystems Corp.//DTD HotJava HTML//EN" */, PubIDInfo::eQuirks3, PubIDInfo::eQuirks3},
+ {"-//sun microsystems corp.//dtd hotjava strict html//en" /* "-//Sun Microsystems Corp.//DTD HotJava Strict HTML//EN" */, PubIDInfo::eQuirks3, PubIDInfo::eQuirks3},
+ {"-//w3c//dtd html 3 1995-03-24//en" /* "-//W3C//DTD HTML 3 1995-03-24//EN" */, PubIDInfo::eQuirks3, PubIDInfo::eQuirks3},
+ {"-//w3c//dtd html 3.2 draft//en" /* "-//W3C//DTD HTML 3.2 Draft//EN" */, PubIDInfo::eQuirks3, PubIDInfo::eQuirks3},
+ {"-//w3c//dtd html 3.2 final//en" /* "-//W3C//DTD HTML 3.2 Final//EN" */, PubIDInfo::eQuirks3, PubIDInfo::eQuirks3},
+ {"-//w3c//dtd html 3.2//en" /* "-//W3C//DTD HTML 3.2//EN" */, PubIDInfo::eQuirks3, PubIDInfo::eQuirks3},
+ {"-//w3c//dtd html 3.2s draft//en" /* "-//W3C//DTD HTML 3.2S Draft//EN" */, PubIDInfo::eQuirks3, PubIDInfo::eQuirks3},
+ {"-//w3c//dtd html 4.0 frameset//en" /* "-//W3C//DTD HTML 4.0 Frameset//EN" */, PubIDInfo::eQuirks, PubIDInfo::eQuirks},
+ {"-//w3c//dtd html 4.0 transitional//en" /* "-//W3C//DTD HTML 4.0 Transitional//EN" */, PubIDInfo::eQuirks, PubIDInfo::eQuirks},
+ {"-//w3c//dtd html 4.01 frameset//en" /* "-//W3C//DTD HTML 4.01 Frameset//EN" */, PubIDInfo::eQuirks, PubIDInfo::eAlmostStandards},
+ {"-//w3c//dtd html 4.01 transitional//en" /* "-//W3C//DTD HTML 4.01 Transitional//EN" */, PubIDInfo::eQuirks, PubIDInfo::eAlmostStandards},
+ {"-//w3c//dtd html experimental 19960712//en" /* "-//W3C//DTD HTML Experimental 19960712//EN" */, PubIDInfo::eQuirks3, PubIDInfo::eQuirks3},
+ {"-//w3c//dtd html experimental 970421//en" /* "-//W3C//DTD HTML Experimental 970421//EN" */, PubIDInfo::eQuirks3, PubIDInfo::eQuirks3},
+ {"-//w3c//dtd w3 html//en" /* "-//W3C//DTD W3 HTML//EN" */, PubIDInfo::eQuirks3, PubIDInfo::eQuirks3},
+ {"-//w3c//dtd xhtml 1.0 frameset//en" /* "-//W3C//DTD XHTML 1.0 Frameset//EN" */, PubIDInfo::eAlmostStandards, PubIDInfo::eAlmostStandards},
+ {"-//w3c//dtd xhtml 1.0 transitional//en" /* "-//W3C//DTD XHTML 1.0 Transitional//EN" */, PubIDInfo::eAlmostStandards, PubIDInfo::eAlmostStandards},
+ {"-//w3o//dtd w3 html 3.0//en" /* "-//W3O//DTD W3 HTML 3.0//EN" */, PubIDInfo::eQuirks3, PubIDInfo::eQuirks3},
+ {"-//w3o//dtd w3 html 3.0//en//" /* "-//W3O//DTD W3 HTML 3.0//EN//" */, PubIDInfo::eQuirks3, PubIDInfo::eQuirks3},
+ {"-//w3o//dtd w3 html strict 3.0//en//" /* "-//W3O//DTD W3 HTML Strict 3.0//EN//" */, PubIDInfo::eQuirks3, PubIDInfo::eQuirks3},
+ {"-//webtechs//dtd mozilla html 2.0//en" /* "-//WebTechs//DTD Mozilla HTML 2.0//EN" */, PubIDInfo::eQuirks3, PubIDInfo::eQuirks3},
+ {"-//webtechs//dtd mozilla html//en" /* "-//WebTechs//DTD Mozilla HTML//EN" */, PubIDInfo::eQuirks3, PubIDInfo::eQuirks3},
+ {"html" /* "HTML" */, PubIDInfo::eQuirks3, PubIDInfo::eQuirks3},
};
#ifdef DEBUG
@@ -984,7 +997,7 @@ static void VerifyPublicIDs()
}
#endif
-static void DetermineHTMLParseMode(nsString& aBuffer,
+static void DetermineHTMLParseMode(const nsString& aBuffer,
nsDTDMode& aParseMode,
eParserDocType& aDocType)
{
@@ -992,26 +1005,28 @@ static void DetermineHTMLParseMode(nsString& aBuffer,
VerifyPublicIDs();
#endif
PRInt32 resultFlags;
- nsAutoString publicIDUCS2;
- if (ParseDocTypeDecl(aBuffer, &resultFlags, publicIDUCS2)) {
+ nsAutoString publicIDUCS2, sysIDUCS2;
+ if (ParseDocTypeDecl(aBuffer, &resultFlags, publicIDUCS2, sysIDUCS2)) {
if (!(resultFlags & PARSE_DTD_HAVE_DOCTYPE)) {
// no DOCTYPE
aParseMode = eDTDMode_quirks;
aDocType = eHTML_Quirks;
- // Why do this? If it weren't for this, |aBuffer| could be
- // |const nsString&|, which it really should be.
- aBuffer.InsertWithConversion(
- "\n",
- 0);
} else if ((resultFlags & PARSE_DTD_HAVE_INTERNAL_SUBSET) ||
!(resultFlags & PARSE_DTD_HAVE_PUBLIC_ID)) {
- // A doctype with an internal subset is always strict.
- // A doctype without a public ID is always strict.
+ // A doctype with an internal subset is always full_standards.
+ // A doctype without a public ID is always full_standards.
aDocType = eHTML_Strict;
- aParseMode = eDTDMode_strict;
+ aParseMode = eDTDMode_full_standards;
+
+ // Special hack for IBM's custom DOCTYPE.
+ if (!(resultFlags & PARSE_DTD_HAVE_INTERNAL_SUBSET) &&
+ sysIDUCS2 == NS_LITERAL_STRING(
+ "http://www.ibm.com/data/dtd/v11/ibmxhtml1-transitional.dtd")) {
+ aParseMode = eDTDMode_almost_standards;
+ }
} else {
@@ -1043,14 +1058,17 @@ static void DetermineHTMLParseMode(nsString& aBuffer,
minimum = index + 1;
if (maximum < minimum) {
- // The DOCTYPE is not in our list, so it must be strict.
- aParseMode = eDTDMode_strict;
+ // The DOCTYPE is not in our list, so it must be full_standards.
+ aParseMode = eDTDMode_full_standards;
aDocType = eHTML_Strict;
return;
}
}
- switch (kPublicIDs[index].mode) {
+ switch ((resultFlags & PARSE_DTD_HAVE_SYSTEM_ID)
+ ? kPublicIDs[index].mode_if_sysid
+ : kPublicIDs[index].mode_if_no_sysid)
+ {
case PubIDInfo::eQuirks3:
aParseMode = eDTDMode_quirks;
aDocType = eHTML3_Quirks;
@@ -1059,14 +1077,13 @@ static void DetermineHTMLParseMode(nsString& aBuffer,
aParseMode = eDTDMode_quirks;
aDocType = eHTML_Quirks;
break;
- case PubIDInfo::eStrictIfSysID:
- if (resultFlags & PARSE_DTD_HAVE_SYSTEM_ID) {
- aParseMode = eDTDMode_strict;
- aDocType = eHTML_Strict;
- } else {
- aParseMode = eDTDMode_quirks;
- aDocType = eHTML_Quirks;
- }
+ case PubIDInfo::eAlmostStandards:
+ aParseMode = eDTDMode_almost_standards;
+ aDocType = eHTML_Strict;
+ break;
+ case PubIDInfo::eFullStandards:
+ aParseMode = eDTDMode_full_standards;
+ aDocType = eHTML_Strict;
break;
default:
NS_NOTREACHED("no other cases!");
@@ -1081,22 +1098,13 @@ static void DetermineHTMLParseMode(nsString& aBuffer,
}
static
-void DetermineParseMode(nsString& aBuffer,
+void DetermineParseMode(const nsString& aBuffer,
nsDTDMode& aParseMode,
eParserDocType& aDocType,
const nsACString& aMimeType)
{
if (aMimeType.Equals(NS_LITERAL_CSTRING(kHTMLTextContentType))) {
- // For XML (XHTML) documents served as text/html, we will use strict
- // mode. XML declarations must be the first thing in the document,
- // and must be lowercase. (XXX What about a byte order mark?)
- if (kNotFound != aBuffer.Find("
EXPORTS = \
+ nsCompatibility.h \
nsFrameList.h \
nsFrameTraversal.h \
nsHTMLReflowMetrics.h \
diff --git a/mozilla/layout/base/public/nsIFrame.h b/mozilla/layout/base/public/nsIFrame.h
index 2b1568deef0..0c7e4be10d1 100644
--- a/mozilla/layout/base/public/nsIFrame.h
+++ b/mozilla/layout/base/public/nsIFrame.h
@@ -1141,7 +1141,7 @@ public:
* aIsPre should be ignored by frames to which the 'white-space'
* property applies.
*/
- NS_IMETHOD IsEmpty(PRBool aIsQuirkMode,
+ NS_IMETHOD IsEmpty(nsCompatibility aCompatMode,
PRBool aIsPre,
PRBool* aResult) = 0;
diff --git a/mozilla/layout/base/public/nsIPresContext.h b/mozilla/layout/base/public/nsIPresContext.h
index b3c9695843a..ff796cc4025 100644
--- a/mozilla/layout/base/public/nsIPresContext.h
+++ b/mozilla/layout/base/public/nsIPresContext.h
@@ -42,6 +42,7 @@
#include "nsCoord.h"
#include "nsAString.h"
#include "nsIRequest.h"
+#include "nsCompatibility.h"
#ifdef IBMBIDI
class nsBidiPresUtils;
#endif // IBMBIDI
@@ -78,11 +79,6 @@ class nsIRenderingContext;
{ 0x0a5d12e0, 0x944e, 0x11d1, \
{0x93, 0x23, 0x00, 0x80, 0x5f, 0x8a, 0xdd, 0x32} }
-enum nsCompatibility {
- eCompatibility_Standard = 1,
- eCompatibility_NavQuirks = 2
-};
-
enum nsWidgetRendering {
eWidgetRendering_Native = 1,
eWidgetRendering_Gfx = 2,
diff --git a/mozilla/layout/base/public/nsIPresShell.h b/mozilla/layout/base/public/nsIPresShell.h
index a48a2f52520..77ee18d6880 100644
--- a/mozilla/layout/base/public/nsIPresShell.h
+++ b/mozilla/layout/base/public/nsIPresShell.h
@@ -41,6 +41,7 @@
#include "nsCoord.h"
#include "nsEvent.h"
#include "nsReflowType.h"
+#include "nsCompatibility.h"
class nsIAtom;
class nsIContent;
@@ -125,7 +126,8 @@ public:
NS_IMETHOD Init(nsIDocument* aDocument,
nsIPresContext* aPresContext,
nsIViewManager* aViewManager,
- nsIStyleSet* aStyleSet) = 0;
+ nsIStyleSet* aStyleSet,
+ nsCompatibility aCompatMode) = 0;
/**
* All callers are responsible for calling |Destroy| after calling
diff --git a/mozilla/layout/base/src/nsPresContext.cpp b/mozilla/layout/base/src/nsPresContext.cpp
index dd36f95cd62..408bfcdc23d 100644
--- a/mozilla/layout/base/src/nsPresContext.cpp
+++ b/mozilla/layout/base/src/nsPresContext.cpp
@@ -149,8 +149,7 @@ nsPresContext::nsPresContext()
mNoTheme(PR_FALSE)
{
NS_INIT_REFCNT();
- mCompatibilityMode = eCompatibility_Standard;
- mCompatibilityLocked = PR_FALSE;
+ mCompatibilityMode = eCompatibility_FullStandards;
mWidgetRenderingMode = eWidgetRendering_Gfx;
mImageAnimationMode = imgIContainer::kNormalAnimMode;
mImageAnimationModePref = imgIContainer::kNormalAnimMode;
@@ -454,27 +453,6 @@ nsPresContext::GetUserPreferences()
mFontScaler = prefInt;
}
- if (NS_SUCCEEDED(mPrefs->GetIntPref("nglayout.compatibility.mode", &prefInt))) {
- // XXX this should really be a state on the webshell instead of using prefs
- switch (prefInt) {
- case 1:
- mCompatibilityLocked = PR_TRUE;
- mCompatibilityMode = eCompatibility_Standard;
- break;
- case 2:
- mCompatibilityLocked = PR_TRUE;
- mCompatibilityMode = eCompatibility_NavQuirks;
- break;
- case 0: // auto
- default:
- mCompatibilityLocked = PR_FALSE;
- break;
- }
- }
- else {
- mCompatibilityLocked = PR_FALSE; // auto
- }
-
if (NS_SUCCEEDED(mPrefs->GetIntPref("nglayout.widget.mode", &prefInt))) {
mWidgetRenderingMode = (enum nsWidgetRendering)prefInt; // bad cast
}
@@ -783,18 +761,15 @@ nsPresContext::GetCompatibilityMode(nsCompatibility* aResult)
NS_IMETHODIMP
nsPresContext::SetCompatibilityMode(nsCompatibility aMode)
{
- if (! mCompatibilityLocked) {
- mCompatibilityMode = aMode;
- }
+ mCompatibilityMode = aMode;
+
+ NS_ENSURE_TRUE(mShell, NS_OK);
// enable/disable the QuirkSheet
- NS_ASSERTION(mShell, "PresShell must be set on PresContext before calling nsPresContext::SetCompatibilityMode");
- if (mShell) {
- nsCOMPtr set;
- nsresult rv = mShell->GetStyleSet(getter_AddRefs(set));
- if (NS_SUCCEEDED(rv) && set) {
- set->EnableQuirkStyleSheet((mCompatibilityMode != eCompatibility_Standard) ? PR_TRUE : PR_FALSE);
- }
+ nsCOMPtr set;
+ mShell->GetStyleSet(getter_AddRefs(set));
+ if (set) {
+ set->EnableQuirkStyleSheet(mCompatibilityMode == eCompatibility_NavQuirks);
}
return NS_OK;
}
@@ -1477,6 +1452,8 @@ nsPresContext::LoadImage(const nsString& aURL,
rv = content->GetDocument(*getter_AddRefs(document));
// If there is no document, skip the policy check
+ // XXXldb This really means the document is being destroyed, so
+ // perhaps we're better off skipping the load entirely.
if (document) {
nsCOMPtr globalScript;
rv = document->GetScriptGlobalObject(getter_AddRefs(globalScript));
diff --git a/mozilla/layout/base/src/nsPresContext.h b/mozilla/layout/base/src/nsPresContext.h
index d64d06f7624..391a9094587 100644
--- a/mozilla/layout/base/src/nsPresContext.h
+++ b/mozilla/layout/base/src/nsPresContext.h
@@ -263,7 +263,6 @@ protected:
nsCOMPtr mBaseURL;
nsCompatibility mCompatibilityMode;
- PRPackedBool mCompatibilityLocked;
nsWidgetRendering mWidgetRenderingMode;
PRPackedBool mImageAnimationStopped; // image animation stopped
diff --git a/mozilla/layout/html/base/src/nsBlockFrame.cpp b/mozilla/layout/html/base/src/nsBlockFrame.cpp
index cae1bf8b828..86e80a8af77 100644
--- a/mozilla/layout/html/base/src/nsBlockFrame.cpp
+++ b/mozilla/layout/html/base/src/nsBlockFrame.cpp
@@ -2875,7 +2875,8 @@ IsMarginZero(nsStyleUnit aUnit, nsStyleCoord &aCoord)
}
NS_IMETHODIMP
-nsBlockFrame::IsEmpty(PRBool aIsQuirkMode, PRBool aIsPre, PRBool *aResult)
+nsBlockFrame::IsEmpty(nsCompatibility aCompatMode, PRBool aIsPre,
+ PRBool *aResult)
{
// XXXldb In hindsight, I'm not sure why I made this check the margin,
// but it seems to work right and I'm a little hesitant to change it.
@@ -2915,7 +2916,7 @@ nsBlockFrame::IsEmpty(PRBool aIsQuirkMode, PRBool aIsPre, PRBool *aResult)
line != line_end;
++line)
{
- line->IsEmpty(aIsQuirkMode, isPre, aResult);
+ line->IsEmpty(aCompatMode, isPre, aResult);
if (! *aResult)
break;
}
diff --git a/mozilla/layout/html/base/src/nsBlockFrame.h b/mozilla/layout/html/base/src/nsBlockFrame.h
index 68daff1f07c..58182fdc8fc 100644
--- a/mozilla/layout/html/base/src/nsBlockFrame.h
+++ b/mozilla/layout/html/base/src/nsBlockFrame.h
@@ -148,7 +148,9 @@ public:
PRBool aCheckVis,
PRBool* aIsVisible);
- NS_IMETHOD IsEmpty(PRBool aIsQuirkMode, PRBool aIsPre, PRBool* aResult);
+ NS_IMETHOD IsEmpty(nsCompatibility aCompatMode,
+ PRBool aIsPre,
+ PRBool* aResult);
// nsIHTMLReflow
NS_IMETHOD Reflow(nsIPresContext* aPresContext,
diff --git a/mozilla/layout/html/base/src/nsBlockReflowState.cpp b/mozilla/layout/html/base/src/nsBlockReflowState.cpp
index 67e7971b9fd..d518d0a4adb 100644
--- a/mozilla/layout/html/base/src/nsBlockReflowState.cpp
+++ b/mozilla/layout/html/base/src/nsBlockReflowState.cpp
@@ -451,7 +451,6 @@ nsBlockReflowState::ReconstructMarginAbove(nsLineList::iterator aLine)
nsCompatibility mode;
mPresContext->GetCompatibilityMode(&mode);
- PRBool isQuirkMode = mode == eCompatibility_NavQuirks;
nsLineList::iterator firstLine = block->begin_lines();
for (;;) {
@@ -461,7 +460,7 @@ nsBlockReflowState::ReconstructMarginAbove(nsLineList::iterator aLine)
break;
}
PRBool isEmpty;
- aLine->IsEmpty(isQuirkMode, isPre, &isEmpty);
+ aLine->IsEmpty(mode, isPre, &isEmpty);
if (! isEmpty) {
break;
}
diff --git a/mozilla/layout/html/base/src/nsFrame.cpp b/mozilla/layout/html/base/src/nsFrame.cpp
index 9c6a47c48f4..625c4793c15 100644
--- a/mozilla/layout/html/base/src/nsFrame.cpp
+++ b/mozilla/layout/html/base/src/nsFrame.cpp
@@ -2632,7 +2632,7 @@ nsFrame::IsVisibleForPainting(nsIPresContext * aPresContext,
}
NS_IMETHODIMP
-nsFrame::IsEmpty(PRBool aIsQuirkMode, PRBool aIsPre, PRBool *aResult)
+nsFrame::IsEmpty(nsCompatibility aCompatMode, PRBool aIsPre, PRBool *aResult)
{
*aResult = PR_FALSE;
return NS_OK;
diff --git a/mozilla/layout/html/base/src/nsFrame.h b/mozilla/layout/html/base/src/nsFrame.h
index 6deb5e59d4a..17f6680bcb6 100644
--- a/mozilla/layout/html/base/src/nsFrame.h
+++ b/mozilla/layout/html/base/src/nsFrame.h
@@ -291,7 +291,7 @@ public:
PRBool aCheckVis,
PRBool* aIsVisible);
- NS_IMETHOD IsEmpty(PRBool aIsQuirkMode,
+ NS_IMETHOD IsEmpty(nsCompatibility aCompatMode,
PRBool aIsPre,
PRBool* aResult);
diff --git a/mozilla/layout/html/base/src/nsInlineFrame.cpp b/mozilla/layout/html/base/src/nsInlineFrame.cpp
index 6ab6f54b31b..3a3ab88fcd4 100644
--- a/mozilla/layout/html/base/src/nsInlineFrame.cpp
+++ b/mozilla/layout/html/base/src/nsInlineFrame.cpp
@@ -136,9 +136,10 @@ IsMarginZero(nsStyleUnit aUnit, nsStyleCoord &aCoord)
}
NS_IMETHODIMP
-nsInlineFrame::IsEmpty(PRBool aIsQuirkMode, PRBool aIsPre, PRBool* aResult)
+nsInlineFrame::IsEmpty(nsCompatibility aCompatMode, PRBool aIsPre,
+ PRBool* aResult)
{
- if (!aIsQuirkMode) {
+ if (aCompatMode == eCompatibility_FullStandards) {
*aResult = PR_FALSE;
return NS_OK;
}
@@ -183,7 +184,7 @@ nsInlineFrame::IsEmpty(PRBool aIsQuirkMode, PRBool aIsPre, PRBool* aResult)
*aResult = PR_TRUE;
for (nsIFrame *kid = mFrames.FirstChild(); kid; kid->GetNextSibling(&kid)) {
- kid->IsEmpty(aIsQuirkMode, aIsPre, aResult);
+ kid->IsEmpty(aCompatMode, aIsPre, aResult);
if (! *aResult)
break;
}
diff --git a/mozilla/layout/html/base/src/nsInlineFrame.h b/mozilla/layout/html/base/src/nsInlineFrame.h
index 1e8865da1f6..715dbb0a08e 100644
--- a/mozilla/layout/html/base/src/nsInlineFrame.h
+++ b/mozilla/layout/html/base/src/nsInlineFrame.h
@@ -90,7 +90,9 @@ public:
#endif
NS_IMETHOD GetFrameType(nsIAtom** aType) const;
- NS_IMETHOD IsEmpty(PRBool aIsQuirkMode, PRBool aIsPre, PRBool* aResult);
+ NS_IMETHOD IsEmpty(nsCompatibility aCompatMode,
+ PRBool aIsPre,
+ PRBool* aResult);
// nsIHTMLReflow overrides
NS_IMETHOD Reflow(nsIPresContext* aPresContext,
diff --git a/mozilla/layout/html/base/src/nsLineBox.cpp b/mozilla/layout/html/base/src/nsLineBox.cpp
index b3dcc9ec703..7af3c3ade08 100644
--- a/mozilla/layout/html/base/src/nsLineBox.cpp
+++ b/mozilla/layout/html/base/src/nsLineBox.cpp
@@ -278,11 +278,11 @@ nsLineBox::IndexOf(nsIFrame* aFrame) const
}
nsresult
-nsLineBox::IsEmpty(PRBool aIsQuirkMode, PRBool aParentIsPre,
+nsLineBox::IsEmpty(nsCompatibility aCompatMode, PRBool aParentIsPre,
PRBool *aResult) const
{
if (IsBlock())
- return mFirstChild->IsEmpty(aIsQuirkMode, aParentIsPre, aResult);
+ return mFirstChild->IsEmpty(aCompatMode, aParentIsPre, aResult);
*aResult = PR_TRUE;
PRInt32 n;
@@ -291,7 +291,7 @@ nsLineBox::IsEmpty(PRBool aIsQuirkMode, PRBool aParentIsPre,
n > 0;
--n, kid->GetNextSibling(&kid))
{
- kid->IsEmpty(aIsQuirkMode, aParentIsPre, aResult);
+ kid->IsEmpty(aCompatMode, aParentIsPre, aResult);
if (! *aResult)
break;
}
diff --git a/mozilla/layout/html/base/src/nsLineBox.h b/mozilla/layout/html/base/src/nsLineBox.h
index 83bd73c2f46..e710870b621 100644
--- a/mozilla/layout/html/base/src/nsLineBox.h
+++ b/mozilla/layout/html/base/src/nsLineBox.h
@@ -390,7 +390,7 @@ public:
}
// whether the line box is "logically" empty (just like nsIFrame::IsEmpty)
- nsresult IsEmpty(PRBool aIsQuirkMode, PRBool aParentIsPre,
+ nsresult IsEmpty(nsCompatibility aCompatMode, PRBool aParentIsPre,
PRBool *aResult) const;
#ifdef DEBUG
diff --git a/mozilla/layout/html/base/src/nsLineLayout.cpp b/mozilla/layout/html/base/src/nsLineLayout.cpp
index 70e4462698a..c4f2ec64f8d 100644
--- a/mozilla/layout/html/base/src/nsLineLayout.cpp
+++ b/mozilla/layout/html/base/src/nsLineLayout.cpp
@@ -191,7 +191,7 @@ nsLineLayout::nsLineLayout(nsIPresContext* aPresContext,
mCurrentSpan = mRootSpan = nsnull;
mSpanDepth = 0;
- SetFlag(LL_KNOWSTRICTMODE, PR_FALSE);
+ mPresContext->GetCompatibilityMode(&mCompatMode);
}
nsLineLayout::nsLineLayout(nsIPresContext* aPresContext)
@@ -234,24 +234,6 @@ nsLineLayout::~nsLineLayout()
}
}
-PRBool
-nsLineLayout::InStrictMode()
-{
- if (!GetFlag(LL_KNOWSTRICTMODE)) {
- SetFlag(LL_KNOWSTRICTMODE, PR_TRUE);
- SetFlag(LL_INSTRICTMODE, PR_TRUE);
- // ask the cached presentation context for the compatibility mode
- if (mPresContext) {
- nsCompatibility mode;
- mPresContext->GetCompatibilityMode(&mode);
- if (eCompatibility_NavQuirks == mode) {
- SetFlag(LL_INSTRICTMODE, PR_FALSE);
- }
- }
- }
- return GetFlag(LL_INSTRICTMODE);
-}
-
void
nsLineLayout::BeginLineReflow(nscoord aX, nscoord aY,
nscoord aWidth, nscoord aHeight,
@@ -2205,20 +2187,20 @@ nsLineLayout::VerticalAlignFrames(PerSpanData* psd)
// "normally" according to css2 or should it effectively
// "disappear".
//
- // In general, if the document being processed is in strict mode
- // then it should act normally (with one exception). The exception
- // case is when a span is continued and yet the span is empty
- // (e.g. compressed whitespace). For this kind of span we treat it
- // as if it were not there so that it doesn't impact the
+ // In general, if the document being processed is in full standards
+ // mode then it should act normally (with one exception). The
+ // exception case is when a span is continued and yet the span is
+ // empty (e.g. compressed whitespace). For this kind of span we treat
+ // it as if it were not there so that it doesn't impact the
// line-height.
//
- // In compatability mode, we should sometimes make it disappear. The
- // cases that matter are those where the span contains no real text
- // elements that would provide an ascent and descent and
- // height. However, if css style elements have been applied to the
- // span (border/padding/margin) so that it's clear the document
- // author is intending css2 behavior then we act as if strict mode
- // is set.
+ // In almost standards mode or quirks mode, we should sometimes make
+ // it disappear. The cases that matter are those where the span
+ // contains no real text elements that would provide an ascent and
+ // descent and height. However, if css style elements have been
+ // applied to the span (border/padding/margin) so that it's clear the
+ // document author is intending css2 behavior then we act as if strict
+ // mode is set.
//
// This code works correctly for preMode, because a blank line
// in PRE mode is encoded as a text node with a LF in it, since
@@ -2230,7 +2212,9 @@ nsLineLayout::VerticalAlignFrames(PerSpanData* psd)
// since this code sets zeroEffectiveSpanBox even when there are
// non-empty children.
PRBool zeroEffectiveSpanBox = PR_FALSE;
- if ((emptyContinuation || !InStrictMode()) &&
+ // XXXldb If we really have empty continuations, then all these other
+ // checks don't make sense for them.
+ if ((emptyContinuation || mCompatMode != eCompatibility_FullStandards) &&
((psd == mRootSpan) ||
((0 == spanFramePFD->mBorderPadding.top) &&
(0 == spanFramePFD->mBorderPadding.right) &&
diff --git a/mozilla/layout/html/base/src/nsLineLayout.h b/mozilla/layout/html/base/src/nsLineLayout.h
index 7226a7ea54e..dd843a1f64c 100644
--- a/mozilla/layout/html/base/src/nsLineLayout.h
+++ b/mozilla/layout/html/base/src/nsLineLayout.h
@@ -90,8 +90,6 @@ public:
void EndSpan(nsIFrame* aFrame, nsSize& aSizeResult,
nsSize* aMaxElementSize);
- PRBool InStrictMode();
-
PRInt32 GetCurrentSpanCount() const;
void SplitLineTo(PRInt32 aNewCount);
@@ -137,9 +135,7 @@ protected:
#define LL_IMPACTEDBYFLOATERS 0x00000040
#define LL_LASTFLOATERWASLETTERFRAME 0x00000080
#define LL_CANPLACEFLOATER 0x00000100
-#define LL_KNOWSTRICTMODE 0x00000200
-#define LL_INSTRICTMODE 0x00000400
-#define LL_LINEENDSINBR 0x00000800
+#define LL_LINEENDSINBR 0x00000200
#define LL_LASTFLAG LL_LINEENDSINBR
PRUint16 mFlags;
@@ -223,6 +219,11 @@ public:
SetFlag(LL_LINEENDSINBR, aOn);
}
+ PRBool InStrictMode()
+ {
+ return mCompatMode != eCompatibility_NavQuirks;
+ }
+
//----------------------------------------
// Inform the line-layout about the presence of a floating frame
// XXX get rid of this: use get-frame-type?
@@ -268,6 +269,7 @@ protected:
const nsStyleText* mStyleText; // for the block
const nsHTMLReflowState* mBlockReflowState;
nsBlockReflowState* mBlockRS;/* XXX hack! */
+ nsCompatibility mCompatMode;
nscoord mMinLineHeight;
PRPackedBool mComputeMaxElementSize;
PRUint8 mTextAlign;
diff --git a/mozilla/layout/html/base/src/nsPlaceholderFrame.cpp b/mozilla/layout/html/base/src/nsPlaceholderFrame.cpp
index 9568687c85d..4eb08662416 100644
--- a/mozilla/layout/html/base/src/nsPlaceholderFrame.cpp
+++ b/mozilla/layout/html/base/src/nsPlaceholderFrame.cpp
@@ -89,7 +89,9 @@ nsPlaceholderFrame::GetFrameType(nsIAtom** aType) const
}
NS_IMETHODIMP
-nsPlaceholderFrame::IsEmpty(PRBool aIsQuirkMode, PRBool aIsPre, PRBool *aResult)
+nsPlaceholderFrame::IsEmpty(nsCompatibility aCompatMode,
+ PRBool aIsPre,
+ PRBool *aResult)
{
*aResult = PR_TRUE;
return NS_OK;
diff --git a/mozilla/layout/html/base/src/nsPlaceholderFrame.h b/mozilla/layout/html/base/src/nsPlaceholderFrame.h
index 57099b6e8fc..24f34126ee0 100644
--- a/mozilla/layout/html/base/src/nsPlaceholderFrame.h
+++ b/mozilla/layout/html/base/src/nsPlaceholderFrame.h
@@ -84,7 +84,9 @@ public:
NS_IMETHOD GetFrameName(nsAString& aResult) const;
#endif
- NS_IMETHOD IsEmpty(PRBool aIsQuirkMode, PRBool aIsPre, PRBool *aResult);
+ NS_IMETHOD IsEmpty(nsCompatibility aCompatMode,
+ PRBool aIsPre,
+ PRBool *aResult);
protected:
nsIFrame* mOutOfFlowFrame;
diff --git a/mozilla/layout/html/base/src/nsPresShell.cpp b/mozilla/layout/html/base/src/nsPresShell.cpp
index 9e2e44bea07..460030ad74f 100644
--- a/mozilla/layout/html/base/src/nsPresShell.cpp
+++ b/mozilla/layout/html/base/src/nsPresShell.cpp
@@ -1069,7 +1069,8 @@ public:
NS_IMETHOD Init(nsIDocument* aDocument,
nsIPresContext* aPresContext,
nsIViewManager* aViewManager,
- nsIStyleSet* aStyleSet);
+ nsIStyleSet* aStyleSet,
+ nsCompatibility aCompatMode);
NS_IMETHOD Destroy();
NS_IMETHOD AllocateFrame(size_t aSize, void** aResult);
@@ -1699,7 +1700,8 @@ NS_IMETHODIMP
PresShell::Init(nsIDocument* aDocument,
nsIPresContext* aPresContext,
nsIViewManager* aViewManager,
- nsIStyleSet* aStyleSet)
+ nsIStyleSet* aStyleSet,
+ nsCompatibility aCompatMode)
{
NS_PRECONDITION(nsnull != aDocument, "null ptr");
NS_PRECONDITION(nsnull != aPresContext, "null ptr");
@@ -1720,11 +1722,15 @@ PresShell::Init(nsIDocument* aDocument,
mViewManager->SetViewObserver(this);
// Bind the context to the presentation shell.
- mPresContext = dont_QueryInterface(aPresContext);
+ mPresContext = aPresContext;
aPresContext->SetShell(this);
mStyleSet = aStyleSet;
+ // Set the compatibility mode after attaching the pres context and
+ // style set, but before creating any frames.
+ mPresContext->SetCompatibilityMode(aCompatMode);
+
mHistoryState = nsnull;
nsresult result = nsComponentManager::CreateInstance(kFrameSelectionCID, nsnull,
diff --git a/mozilla/layout/html/base/src/nsTextFrame.cpp b/mozilla/layout/html/base/src/nsTextFrame.cpp
index 50318983769..3eae44767a1 100644
--- a/mozilla/layout/html/base/src/nsTextFrame.cpp
+++ b/mozilla/layout/html/base/src/nsTextFrame.cpp
@@ -498,7 +498,9 @@ public:
PRBool aCheckVis,
PRBool* aIsVisible);
- NS_IMETHOD IsEmpty(PRBool aIsQuirkMode, PRBool aIsPre, PRBool* aResult);
+ NS_IMETHOD IsEmpty(nsCompatibility aCompatMode,
+ PRBool aIsPre,
+ PRBool* aResult);
#ifdef ACCESSIBILITY
NS_IMETHOD GetAccessible(nsIAccessible** aAccessible);
@@ -2166,7 +2168,6 @@ nsTextFrame::IsVisibleForPainting(nsIPresContext * aPresContext,
PRBool* aIsVisible)
{
if (aCheckVis) {
- nsIStyleContext* sc = mStyleContext;
const nsStyleVisibility* vis =
(const nsStyleVisibility*)mStyleContext->GetStyleData(eStyleStruct_Visibility);
if (!vis->IsVisible()) {
@@ -5843,9 +5844,11 @@ nsTextFrame::GetFrameType(nsIAtom** aType) const
}
NS_IMETHODIMP
-nsTextFrame::IsEmpty(PRBool aIsQuirkMode, PRBool aIsPre, PRBool* aResult)
+nsTextFrame::IsEmpty(nsCompatibility aCompatMode,
+ PRBool aIsPre,
+ PRBool* aResult)
{
- // XXXldb Should this check aIsQuirkMode as well???
+ // XXXldb Should this check aCompatMode as well???
if (aIsPre) {
*aResult = PR_FALSE;
return NS_OK;
diff --git a/mozilla/layout/html/table/src/nsTableCellFrame.cpp b/mozilla/layout/html/table/src/nsTableCellFrame.cpp
index e6158bf6182..a191d50ab0f 100644
--- a/mozilla/layout/html/table/src/nsTableCellFrame.cpp
+++ b/mozilla/layout/html/table/src/nsTableCellFrame.cpp
@@ -1019,7 +1019,7 @@ NS_METHOD nsTableCellFrame::Reflow(nsIPresContext* aPresContext,
if ((pos->mHeight.GetUnit() != eStyleUnit_Coord) &&
(pos->mHeight.GetUnit() != eStyleUnit_Percent)) {
// Standard mode should probably be 0 pixels high instead of 1
- PRInt32 pixHeight = (eCompatibility_Standard == compatMode) ? 1 : 2;
+ PRInt32 pixHeight = (eCompatibility_NavQuirks == compatMode) ? 2 : 1;
kidSize.height = NSIntPixelsToTwips(pixHeight, p2t);
if ((nsnull != aDesiredSize.maxElementSize) && (0 == pMaxElementSize->height))
pMaxElementSize->height = kidSize.height;
diff --git a/mozilla/layout/html/table/src/nsTableFrame.cpp b/mozilla/layout/html/table/src/nsTableFrame.cpp
index fe7f5279ce8..6688bca182f 100644
--- a/mozilla/layout/html/table/src/nsTableFrame.cpp
+++ b/mozilla/layout/html/table/src/nsTableFrame.cpp
@@ -2825,7 +2825,7 @@ nsTableFrame::GetBCBorder(nsIPresContext& aPresContext,
if (propData) {
nsCompatibility mode;
aPresContext.GetCompatibilityMode(&mode);
- if ((eCompatibility_Standard == mode) || aInnerBorderOnly) {
+ if ((eCompatibility_NavQuirks != mode) || aInnerBorderOnly) {
nscoord smallHalf, largeHalf;
DivideBCBorderSize(propData->mTopBorderWidth, smallHalf, largeHalf);
diff --git a/mozilla/layout/html/tests/Makefile.in b/mozilla/layout/html/tests/Makefile.in
index 457cdda635f..6e85d671056 100644
--- a/mozilla/layout/html/tests/Makefile.in
+++ b/mozilla/layout/html/tests/Makefile.in
@@ -30,6 +30,7 @@ REQUIRES = xpcom \
string \
necko \
content \
+ layout \
$(NULL)
SIMPLE_PROGRAMS = $(CPPSRCS:.cpp=$(BIN_SUFFIX))
diff --git a/mozilla/layout/html/tests/makefile.win b/mozilla/layout/html/tests/makefile.win
index 1868a8059fd..b7cdb01f7fe 100644
--- a/mozilla/layout/html/tests/makefile.win
+++ b/mozilla/layout/html/tests/makefile.win
@@ -24,6 +24,7 @@ REQUIRES = xpcom \
string \
layout \
content \
+ layout \
$(NULL)
include <$(DEPTH)/config/config.mak>
diff --git a/mozilla/parser/htmlparser/public/nsIDTD.h b/mozilla/parser/htmlparser/public/nsIDTD.h
index c5d1280b190..c0595495131 100644
--- a/mozilla/parser/htmlparser/public/nsIDTD.h
+++ b/mozilla/parser/htmlparser/public/nsIDTD.h
@@ -72,7 +72,8 @@ enum eAutoDetectResult {
enum nsDTDMode {
eDTDMode_unknown = 0,
eDTDMode_quirks, //pre 4.0 versions
- eDTDMode_strict,
+ eDTDMode_almost_standards,
+ eDTDMode_full_standards,
eDTDMode_autodetect
};
diff --git a/mozilla/parser/htmlparser/public/nsIHTMLContentSink.h b/mozilla/parser/htmlparser/public/nsIHTMLContentSink.h
index 00f032927c2..861896a4913 100644
--- a/mozilla/parser/htmlparser/public/nsIHTMLContentSink.h
+++ b/mozilla/parser/htmlparser/public/nsIHTMLContentSink.h
@@ -326,7 +326,7 @@ public:
*
* @param nsIParserNode reference to parser node interface
*/
- NS_IMETHOD AddDocTypeDecl(const nsIParserNode& aNode, PRInt32 aMode)=0;
+ NS_IMETHOD AddDocTypeDecl(const nsIParserNode& aNode)=0;
/**
* This gets called by the parser to notify observers of
diff --git a/mozilla/parser/htmlparser/robot/nsRobotSink.cpp b/mozilla/parser/htmlparser/robot/nsRobotSink.cpp
index 927ed216cc6..64e43d35c65 100644
--- a/mozilla/parser/htmlparser/robot/nsRobotSink.cpp
+++ b/mozilla/parser/htmlparser/robot/nsRobotSink.cpp
@@ -98,7 +98,7 @@ public:
NS_IMETHOD AddLeaf(const nsIParserNode& aNode);
NS_IMETHOD AddComment(const nsIParserNode& aNode);
NS_IMETHOD AddProcessingInstruction(const nsIParserNode& aNode);
- NS_IMETHOD AddDocTypeDecl(const nsIParserNode& aNode, PRInt32 aMode=0);
+ NS_IMETHOD AddDocTypeDecl(const nsIParserNode& aNode);
NS_IMETHOD WillBuildModel(void) { return NS_OK; }
NS_IMETHOD DidBuildModel(PRInt32 aQualityLevel) { return NS_OK; }
NS_IMETHOD WillInterrupt(void) { return NS_OK; }
@@ -320,7 +320,7 @@ NS_IMETHODIMP RobotSink::AddProcessingInstruction(const nsIParserNode& aNode) {
*/
NS_IMETHODIMP
-RobotSink::AddDocTypeDecl(const nsIParserNode& aNode, PRInt32 aMode)
+RobotSink::AddDocTypeDecl(const nsIParserNode& aNode)
{
return NS_OK;
}
diff --git a/mozilla/parser/htmlparser/src/CNavDTD.cpp b/mozilla/parser/htmlparser/src/CNavDTD.cpp
index 6e85f6e4a75..12e3f46b8a5 100644
--- a/mozilla/parser/htmlparser/src/CNavDTD.cpp
+++ b/mozilla/parser/htmlparser/src/CNavDTD.cpp
@@ -357,7 +357,8 @@ CNavDTD::CanParse(CParserContext& aParserContext,
aParserContext.SetMimeType(NS_LITERAL_CSTRING(kHTMLTextContentType));
if(!theBufHasXML) {
switch(aParserContext.mDTDMode) {
- case eDTDMode_strict:
+ case eDTDMode_full_standards:
+ case eDTDMode_almost_standards:
result=eValidDetect;
break;
default:
@@ -1977,7 +1978,9 @@ nsresult CNavDTD::HandleEndToken(CToken* aToken) {
// If the bit kHandleStrayTag is set then we automatically open up a matching
// start tag ( compatibility ). Currently this bit is set on P tag.
// This also fixes Bug: 22623
- if(gHTMLElements[theChildTag].HasSpecialProperty(kHandleStrayTag) && mDTDMode!=eDTDMode_strict) {
+ if(gHTMLElements[theChildTag].HasSpecialProperty(kHandleStrayTag) &&
+ mDTDMode != eDTDMode_full_standards &&
+ mDTDMode != eDTDMode_almost_standards) {
// Oh boy!! we found a "stray" tag. Nav4.x and IE introduce line break in
// such cases. So, let's simulate that effect for compatibility.
// Ex. HelloThere
@@ -2326,23 +2329,9 @@ nsresult CNavDTD::HandleDocTypeDeclToken(CToken* aToken){
STOP_TIMER();
MOZ_TIMER_DEBUGLOG(("Stop: Parse Time: CNavDTD::HandleDocTypeDeclToken(), this=%p\n", this));
- /*************************************************************
- While the parser is happy to deal with various modes, the
- rest of layout prefers only 2: strict vs. quirks. So we'll
- constrain the modes when reporting to layout.
- *************************************************************/
- nsDTDMode theMode=mDTDMode;
- switch(mDTDMode) {
- case eDTDMode_strict:
- theMode=eDTDMode_strict;
- break;
- default:
- theMode=eDTDMode_quirks;
- }
-
- result = (mSink)? mSink->AddDocTypeDecl(*theNode,theMode):NS_OK;
+ result = (mSink)? mSink->AddDocTypeDecl(*theNode):NS_OK;
- IF_FREE(theNode, &mNodeAllocator);
+ IF_FREE(theNode, &mNodeAllocator);
MOZ_TIMER_DEBUGLOG(("Start: Parse Time: CNavDTD::HandleDocTypeDeclToken(), this=%p\n", this));
START_TIMER();
diff --git a/mozilla/parser/htmlparser/src/COtherDTD.cpp b/mozilla/parser/htmlparser/src/COtherDTD.cpp
index be2c651bb91..5194254e247 100644
--- a/mozilla/parser/htmlparser/src/COtherDTD.cpp
+++ b/mozilla/parser/htmlparser/src/COtherDTD.cpp
@@ -279,7 +279,8 @@ COtherDTD::CanParse(CParserContext& aParserContext, const nsString& aBuffer,
}
else if(PR_TRUE==aParserContext.mMimeType.EqualsWithConversion(kHTMLTextContentType)) {
switch(aParserContext.mDTDMode) {
- case eDTDMode_strict:
+ case eDTDMode_full_standards:
+ case eDTDMode_almost_standards:
result=ePrimaryDetect;
break;
default:
@@ -296,7 +297,8 @@ COtherDTD::CanParse(CParserContext& aParserContext, const nsString& aBuffer,
aParserContext.SetMimeType(NS_LITERAL_CSTRING(kHTMLTextContentType));
if(!theBufHasXML) {
switch(aParserContext.mDTDMode) {
- case eDTDMode_strict:
+ case eDTDMode_full_standards:
+ case eDTDMode_almost_standards:
result=ePrimaryDetect;
break;
default:
diff --git a/mozilla/parser/htmlparser/src/COtherElements.h b/mozilla/parser/htmlparser/src/COtherElements.h
index d874c25d748..9191459c5c9 100644
--- a/mozilla/parser/htmlparser/src/COtherElements.h
+++ b/mozilla/parser/htmlparser/src/COtherElements.h
@@ -1738,7 +1738,7 @@ public:
theStr.Truncate(theLen-1);
theStr.Cut(0,2);
- result = aSink->AddDocTypeDecl(*aNode,eDTDMode_strict);
+ result = aSink->AddDocTypeDecl(*aNode);
}
return result;
}
diff --git a/mozilla/parser/htmlparser/src/nsHTMLNullSink.cpp b/mozilla/parser/htmlparser/src/nsHTMLNullSink.cpp
index 4808afb5adf..320191effe0 100644
--- a/mozilla/parser/htmlparser/src/nsHTMLNullSink.cpp
+++ b/mozilla/parser/htmlparser/src/nsHTMLNullSink.cpp
@@ -68,7 +68,7 @@ public:
NS_IMETHOD AddLeaf(const nsIParserNode& aNode);
NS_IMETHOD AddProcessingInstruction(const nsIParserNode& aNode);
NS_IMETHOD AddComment(const nsIParserNode& aNode);
- NS_IMETHOD AddDocTypeDecl(const nsIParserNode& aNode, PRInt32 aMode=0);
+ NS_IMETHOD AddDocTypeDecl(const nsIParserNode& aNode);
NS_IMETHOD FlushPendingNotifications() {return NS_OK; }
NS_IMETHOD SetDocumentCharset(nsAString& aCharset) {return NS_OK;}
NS_IMETHOD NotifyTagObservers(nsIParserNode* aNode) { return NS_OK; }
@@ -546,7 +546,7 @@ nsHTMLNullSink::AddProcessingInstruction(const nsIParserNode& aNode){
*/
NS_IMETHODIMP
-nsHTMLNullSink::AddDocTypeDecl(const nsIParserNode& aNode, PRInt32 aMode)
+nsHTMLNullSink::AddDocTypeDecl(const nsIParserNode& aNode)
{
#ifdef VERBOSE_DEBUG
DebugDump("<",aNode.GetText(),(mNodeStackPos)*2);
diff --git a/mozilla/parser/htmlparser/src/nsHTMLTokenizer.cpp b/mozilla/parser/htmlparser/src/nsHTMLTokenizer.cpp
index 2b75e4e9900..46499fdd423 100644
--- a/mozilla/parser/htmlparser/src/nsHTMLTokenizer.cpp
+++ b/mozilla/parser/htmlparser/src/nsHTMLTokenizer.cpp
@@ -136,7 +136,8 @@ NS_IMPL_RELEASE(nsHTMLTokenizer)
{
NS_INIT_REFCNT();
- if (aParseMode==eDTDMode_strict) {
+ if (aParseMode==eDTDMode_full_standards ||
+ aParseMode==eDTDMode_almost_standards) {
mFlags = NS_IPARSER_FLAG_STRICT_MODE;
}
else if (aParseMode==eDTDMode_quirks) {
diff --git a/mozilla/parser/htmlparser/src/nsLoggingSink.cpp b/mozilla/parser/htmlparser/src/nsLoggingSink.cpp
index daaf8d7ef7b..874d7d0b2fd 100644
--- a/mozilla/parser/htmlparser/src/nsLoggingSink.cpp
+++ b/mozilla/parser/htmlparser/src/nsLoggingSink.cpp
@@ -292,7 +292,7 @@ nsLoggingSink::AddProcessingInstruction(const nsIParserNode& aNode){
*/
NS_IMETHODIMP
-nsLoggingSink::AddDocTypeDecl(const nsIParserNode& aNode, PRInt32 aMode) {
+nsLoggingSink::AddDocTypeDecl(const nsIParserNode& aNode) {
#ifdef VERBOSE_DEBUG
DebugDump("<",aNode.GetText(),(mNodeStackPos)*2);
@@ -302,7 +302,7 @@ nsLoggingSink::AddDocTypeDecl(const nsIParserNode& aNode, PRInt32 aMode) {
//then proxy the call to the real sink if you have one.
if(mSink) {
- theResult=mSink->AddDocTypeDecl(aNode,aMode);
+ theResult=mSink->AddDocTypeDecl(aNode);
}
return theResult;
diff --git a/mozilla/parser/htmlparser/src/nsLoggingSink.h b/mozilla/parser/htmlparser/src/nsLoggingSink.h
index 0b5fc2e4814..01dabdc5541 100644
--- a/mozilla/parser/htmlparser/src/nsLoggingSink.h
+++ b/mozilla/parser/htmlparser/src/nsLoggingSink.h
@@ -71,7 +71,7 @@ public:
NS_IMETHOD AddLeaf(const nsIParserNode& aNode);
NS_IMETHOD AddComment(const nsIParserNode& aNode);
NS_IMETHOD AddProcessingInstruction(const nsIParserNode& aNode);
- NS_IMETHOD AddDocTypeDecl(const nsIParserNode& aNode, PRInt32 aMode=0);
+ NS_IMETHOD AddDocTypeDecl(const nsIParserNode& aNode);
NS_IMETHOD FlushPendingNotifications() { return NS_OK; }
NS_IMETHOD SetDocumentCharset(nsAString& aCharset) { return NS_OK; }
NS_IMETHOD NotifyTagObservers(nsIParserNode* aNode) { return NS_OK; }
diff --git a/mozilla/parser/htmlparser/src/nsParser.cpp b/mozilla/parser/htmlparser/src/nsParser.cpp
index 356340decdb..d7a095b33a9 100644
--- a/mozilla/parser/htmlparser/src/nsParser.cpp
+++ b/mozilla/parser/htmlparser/src/nsParser.cpp
@@ -741,7 +741,8 @@ static PRInt32 ParsePS(const nsString& aBuffer, PRInt32 aIndex)
// return PR_TRUE on success (includes not present), PR_FALSE on failure
static PRBool ParseDocTypeDecl(const nsString &aBuffer,
PRInt32 *aResultFlags,
- nsString &aPublicID)
+ nsString &aPublicID,
+ nsString &aSystemID)
{
PRBool haveDoctype = PR_FALSE;
*aResultFlags = 0;
@@ -782,7 +783,7 @@ static PRBool ParseDocTypeDecl(const nsString &aBuffer,
theIndex = ParsePS(aBuffer, theIndex+4);
PRInt32 tmpIndex = aBuffer.Find("PUBLIC", PR_TRUE, theIndex, 1);
- if(kNotFound != tmpIndex) {
+ if (kNotFound != tmpIndex) {
theIndex = ParsePS(aBuffer, tmpIndex+6);
// We get here only if we've read '))
+
+ theIndex = ParsePS(aBuffer, tmpIndex+6);
+ PRUnichar next = aBuffer.CharAt(theIndex);
+ if (next != PRUnichar('\"') && next != PRUnichar('\''))
return PR_FALSE;
+
+ PRInt32 SystemIDStart = theIndex + 1;
+ PRInt32 SystemIDEnd = aBuffer.FindChar(next, SystemIDStart);
+
+ if (kNotFound == SystemIDEnd)
+ return PR_FALSE;
+ aSystemID =
+ Substring(aBuffer, SystemIDStart, SystemIDEnd - SystemIDStart);
+ theIndex = ParsePS(aBuffer, SystemIDEnd + 1);
}
+
+ PRUnichar nextChar = aBuffer.CharAt(theIndex);
+ if (nextChar == PRUnichar('['))
+ *aResultFlags |= PARSE_DTD_HAVE_INTERNAL_SUBSET;
+ else if (nextChar != PRUnichar('>'))
+ return PR_FALSE;
}
return PR_TRUE;
}
struct PubIDInfo {
enum eMode {
- eQuirks, /* always quirks mode, unless there's an internal subset */
- eQuirks3, /* ditto, but but pre-HTML4 (no tbody) */
- eStrictIfSysID /* quirks if no system ID, strict if system ID */
+ eQuirks, /* always quirks mode, unless there's an internal subset */
+ eQuirks3, /* ditto, but but pre-HTML4 (no tbody) */
+ eAlmostStandards,/* eCompatibility_AlmostStandards */
+ eFullStandards /* eCompatibility_FullStandards */
/*
* public IDs that should trigger strict mode are not listed
* since we want all future public IDs to trigger strict mode as
@@ -868,7 +878,8 @@ struct PubIDInfo {
};
const char* name;
- eMode mode;
+ eMode mode_if_no_sysid;
+ eMode mode_if_sysid;
};
#define ELEMENTS_OF(array_) (sizeof(array_)/sizeof(array_[0]))
@@ -883,79 +894,81 @@ struct PubIDInfo {
// identifiers below are in lower case (with the correct case following,
// in comments). The case is verified, |#ifdef DEBUG|, below.
static const PubIDInfo kPublicIDs[] = {
- {"+//silmaril//dtd html pro v0r11 19970101//en" /* "+//Silmaril//dtd html Pro v0r11 19970101//EN" */, PubIDInfo::eQuirks3},
- {"-//advasoft ltd//dtd html 3.0 aswedit + extensions//en" /* "-//AdvaSoft Ltd//DTD HTML 3.0 asWedit + extensions//EN" */, PubIDInfo::eQuirks3},
- {"-//as//dtd html 3.0 aswedit + extensions//en" /* "-//AS//DTD HTML 3.0 asWedit + extensions//EN" */, PubIDInfo::eQuirks3},
- {"-//ietf//dtd html 2.0 level 1//en" /* "-//IETF//DTD HTML 2.0 Level 1//EN" */, PubIDInfo::eQuirks3},
- {"-//ietf//dtd html 2.0 level 2//en" /* "-//IETF//DTD HTML 2.0 Level 2//EN" */, PubIDInfo::eQuirks3},
- {"-//ietf//dtd html 2.0 strict level 1//en" /* "-//IETF//DTD HTML 2.0 Strict Level 1//EN" */, PubIDInfo::eQuirks3},
- {"-//ietf//dtd html 2.0 strict level 2//en" /* "-//IETF//DTD HTML 2.0 Strict Level 2//EN" */, PubIDInfo::eQuirks3},
- {"-//ietf//dtd html 2.0 strict//en" /* "-//IETF//DTD HTML 2.0 Strict//EN" */, PubIDInfo::eQuirks3},
- {"-//ietf//dtd html 2.0//en" /* "-//IETF//DTD HTML 2.0//EN" */, PubIDInfo::eQuirks3},
- {"-//ietf//dtd html 2.1e//en" /* "-//IETF//DTD HTML 2.1E//EN" */, PubIDInfo::eQuirks3},
- {"-//ietf//dtd html 3.0//en" /* "-//IETF//DTD HTML 3.0//EN" */, PubIDInfo::eQuirks3},
- {"-//ietf//dtd html 3.0//en//" /* "-//IETF//DTD HTML 3.0//EN//" */, PubIDInfo::eQuirks3},
- {"-//ietf//dtd html 3.2 final//en" /* "-//IETF//DTD HTML 3.2 Final//EN" */, PubIDInfo::eQuirks3},
- {"-//ietf//dtd html 3.2//en" /* "-//IETF//DTD HTML 3.2//EN" */, PubIDInfo::eQuirks3},
- {"-//ietf//dtd html 3//en" /* "-//IETF//DTD HTML 3//EN" */, PubIDInfo::eQuirks3},
- {"-//ietf//dtd html level 0//en" /* "-//IETF//DTD HTML Level 0//EN" */, PubIDInfo::eQuirks3},
- {"-//ietf//dtd html level 0//en//2.0" /* "-//IETF//DTD HTML Level 0//EN//2.0" */, PubIDInfo::eQuirks3},
- {"-//ietf//dtd html level 1//en" /* "-//IETF//DTD HTML Level 1//EN" */, PubIDInfo::eQuirks3},
- {"-//ietf//dtd html level 1//en//2.0" /* "-//IETF//DTD HTML Level 1//EN//2.0" */, PubIDInfo::eQuirks3},
- {"-//ietf//dtd html level 2//en" /* "-//IETF//DTD HTML Level 2//EN" */, PubIDInfo::eQuirks3},
- {"-//ietf//dtd html level 2//en//2.0" /* "-//IETF//DTD HTML Level 2//EN//2.0" */, PubIDInfo::eQuirks3},
- {"-//ietf//dtd html level 3//en" /* "-//IETF//DTD HTML Level 3//EN" */, PubIDInfo::eQuirks3},
- {"-//ietf//dtd html level 3//en//3.0" /* "-//IETF//DTD HTML Level 3//EN//3.0" */, PubIDInfo::eQuirks3},
- {"-//ietf//dtd html strict level 0//en" /* "-//IETF//DTD HTML Strict Level 0//EN" */, PubIDInfo::eQuirks3},
- {"-//ietf//dtd html strict level 0//en//2.0" /* "-//IETF//DTD HTML Strict Level 0//EN//2.0" */, PubIDInfo::eQuirks3},
- {"-//ietf//dtd html strict level 1//en" /* "-//IETF//DTD HTML Strict Level 1//EN" */, PubIDInfo::eQuirks3},
- {"-//ietf//dtd html strict level 1//en//2.0" /* "-//IETF//DTD HTML Strict Level 1//EN//2.0" */, PubIDInfo::eQuirks3},
- {"-//ietf//dtd html strict level 2//en" /* "-//IETF//DTD HTML Strict Level 2//EN" */, PubIDInfo::eQuirks3},
- {"-//ietf//dtd html strict level 2//en//2.0" /* "-//IETF//DTD HTML Strict Level 2//EN//2.0" */, PubIDInfo::eQuirks3},
- {"-//ietf//dtd html strict level 3//en" /* "-//IETF//DTD HTML Strict Level 3//EN" */, PubIDInfo::eQuirks3},
- {"-//ietf//dtd html strict level 3//en//3.0" /* "-//IETF//DTD HTML Strict Level 3//EN//3.0" */, PubIDInfo::eQuirks3},
- {"-//ietf//dtd html strict//en" /* "-//IETF//DTD HTML Strict//EN" */, PubIDInfo::eQuirks3},
- {"-//ietf//dtd html strict//en//2.0" /* "-//IETF//DTD HTML Strict//EN//2.0" */, PubIDInfo::eQuirks3},
- {"-//ietf//dtd html strict//en//3.0" /* "-//IETF//DTD HTML Strict//EN//3.0" */, PubIDInfo::eQuirks3},
- {"-//ietf//dtd html//en" /* "-//IETF//DTD HTML//EN" */, PubIDInfo::eQuirks3},
- {"-//ietf//dtd html//en//2.0" /* "-//IETF//DTD HTML//EN//2.0" */, PubIDInfo::eQuirks3},
- {"-//ietf//dtd html//en//3.0" /* "-//IETF//DTD HTML//EN//3.0" */, PubIDInfo::eQuirks3},
- {"-//metrius//dtd metrius presentational//en" /* "-//Metrius//DTD Metrius Presentational//EN" */, PubIDInfo::eQuirks},
- {"-//microsoft//dtd internet explorer 2.0 html strict//en" /* "-//Microsoft//DTD Internet Explorer 2.0 HTML Strict//EN" */, PubIDInfo::eQuirks3},
- {"-//microsoft//dtd internet explorer 2.0 html//en" /* "-//Microsoft//DTD Internet Explorer 2.0 HTML//EN" */, PubIDInfo::eQuirks3},
- {"-//microsoft//dtd internet explorer 2.0 tables//en" /* "-//Microsoft//DTD Internet Explorer 2.0 Tables//EN" */, PubIDInfo::eQuirks3},
- {"-//microsoft//dtd internet explorer 3.0 html strict//en" /* "-//Microsoft//DTD Internet Explorer 3.0 HTML Strict//EN" */, PubIDInfo::eQuirks3},
- {"-//microsoft//dtd internet explorer 3.0 html//en" /* "-//Microsoft//DTD Internet Explorer 3.0 HTML//EN" */, PubIDInfo::eQuirks3},
- {"-//microsoft//dtd internet explorer 3.0 tables//en" /* "-//Microsoft//DTD Internet Explorer 3.0 Tables//EN" */, PubIDInfo::eQuirks3},
- {"-//netscape comm. corp.//dtd html//en" /* "-//Netscape Comm. Corp.//DTD HTML//EN" */, PubIDInfo::eQuirks3},
- {"-//netscape comm. corp.//dtd strict html//en" /* "-//Netscape Comm. Corp.//DTD Strict HTML//EN" */, PubIDInfo::eQuirks3},
- {"-//o'reilly and associates//dtd html 2.0//en" /* "-//O'Reilly and Associates//DTD HTML 2.0//EN" */, PubIDInfo::eQuirks3},
- {"-//o'reilly and associates//dtd html extended 1.0//en" /* "-//O'Reilly and Associates//DTD HTML Extended 1.0//EN" */, PubIDInfo::eQuirks3},
- {"-//o'reilly and associates//dtd html extended relaxed 1.0//en" /* "-//O'Reilly and Associates//DTD HTML Extended Relaxed 1.0//EN" */, PubIDInfo::eQuirks3},
- {"-//softquad software//dtd hotmetal pro 6.0::19990601::extensions to html 4.0//en" /* "-//SoftQuad Software//DTD HoTMetaL PRO 6.0::19990601::extensions to HTML 4.0//EN" */, PubIDInfo::eQuirks},
- {"-//softquad//dtd hotmetal pro 4.0::19971010::extensions to html 4.0//en" /* "-//SoftQuad//DTD HoTMetaL PRO 4.0::19971010::extensions to HTML 4.0//EN" */, PubIDInfo::eQuirks},
- {"-//spyglass//dtd html 2.0 extended//en" /* "-//Spyglass//DTD HTML 2.0 Extended//EN" */, PubIDInfo::eQuirks3},
- {"-//sq//dtd html 2.0 hotmetal + extensions//en" /* "-//SQ//DTD HTML 2.0 HoTMetaL + extensions//EN" */, PubIDInfo::eQuirks3},
- {"-//sun microsystems corp.//dtd hotjava html//en" /* "-//Sun Microsystems Corp.//DTD HotJava HTML//EN" */, PubIDInfo::eQuirks3},
- {"-//sun microsystems corp.//dtd hotjava strict html//en" /* "-//Sun Microsystems Corp.//DTD HotJava Strict HTML//EN" */, PubIDInfo::eQuirks3},
- {"-//w3c//dtd html 3 1995-03-24//en" /* "-//W3C//DTD HTML 3 1995-03-24//EN" */, PubIDInfo::eQuirks3},
- {"-//w3c//dtd html 3.2 draft//en" /* "-//W3C//DTD HTML 3.2 Draft//EN" */, PubIDInfo::eQuirks3},
- {"-//w3c//dtd html 3.2 final//en" /* "-//W3C//DTD HTML 3.2 Final//EN" */, PubIDInfo::eQuirks3},
- {"-//w3c//dtd html 3.2//en" /* "-//W3C//DTD HTML 3.2//EN" */, PubIDInfo::eQuirks3},
- {"-//w3c//dtd html 3.2s draft//en" /* "-//W3C//DTD HTML 3.2S Draft//EN" */, PubIDInfo::eQuirks3},
- {"-//w3c//dtd html 4.0 frameset//en" /* "-//W3C//DTD HTML 4.0 Frameset//EN" */, PubIDInfo::eQuirks},
- {"-//w3c//dtd html 4.0 transitional//en" /* "-//W3C//DTD HTML 4.0 Transitional//EN" */, PubIDInfo::eQuirks},
- {"-//w3c//dtd html 4.01 frameset//en" /* "-//W3C//DTD HTML 4.01 Frameset//EN" */, PubIDInfo::eStrictIfSysID},
- {"-//w3c//dtd html 4.01 transitional//en" /* "-//W3C//DTD HTML 4.01 Transitional//EN" */, PubIDInfo::eStrictIfSysID},
- {"-//w3c//dtd html experimental 19960712//en" /* "-//W3C//DTD HTML Experimental 19960712//EN" */, PubIDInfo::eQuirks3},
- {"-//w3c//dtd html experimental 970421//en" /* "-//W3C//DTD HTML Experimental 970421//EN" */, PubIDInfo::eQuirks3},
- {"-//w3c//dtd w3 html//en" /* "-//W3C//DTD W3 HTML//EN" */, PubIDInfo::eQuirks3},
- {"-//w3o//dtd w3 html 3.0//en" /* "-//W3O//DTD W3 HTML 3.0//EN" */, PubIDInfo::eQuirks3},
- {"-//w3o//dtd w3 html 3.0//en//" /* "-//W3O//DTD W3 HTML 3.0//EN//" */, PubIDInfo::eQuirks3},
- {"-//w3o//dtd w3 html strict 3.0//en//" /* "-//W3O//DTD W3 HTML Strict 3.0//EN//" */, PubIDInfo::eQuirks3},
- {"-//webtechs//dtd mozilla html 2.0//en" /* "-//WebTechs//DTD Mozilla HTML 2.0//EN" */, PubIDInfo::eQuirks3},
- {"-//webtechs//dtd mozilla html//en" /* "-//WebTechs//DTD Mozilla HTML//EN" */, PubIDInfo::eQuirks3},
- {"html" /* "HTML" */, PubIDInfo::eQuirks3},
+ {"+//silmaril//dtd html pro v0r11 19970101//en" /* "+//Silmaril//dtd html Pro v0r11 19970101//EN" */, PubIDInfo::eQuirks3, PubIDInfo::eQuirks3},
+ {"-//advasoft ltd//dtd html 3.0 aswedit + extensions//en" /* "-//AdvaSoft Ltd//DTD HTML 3.0 asWedit + extensions//EN" */, PubIDInfo::eQuirks3, PubIDInfo::eQuirks3},
+ {"-//as//dtd html 3.0 aswedit + extensions//en" /* "-//AS//DTD HTML 3.0 asWedit + extensions//EN" */, PubIDInfo::eQuirks3, PubIDInfo::eQuirks3},
+ {"-//ietf//dtd html 2.0 level 1//en" /* "-//IETF//DTD HTML 2.0 Level 1//EN" */, PubIDInfo::eQuirks3, PubIDInfo::eQuirks3},
+ {"-//ietf//dtd html 2.0 level 2//en" /* "-//IETF//DTD HTML 2.0 Level 2//EN" */, PubIDInfo::eQuirks3, PubIDInfo::eQuirks3},
+ {"-//ietf//dtd html 2.0 strict level 1//en" /* "-//IETF//DTD HTML 2.0 Strict Level 1//EN" */, PubIDInfo::eQuirks3, PubIDInfo::eQuirks3},
+ {"-//ietf//dtd html 2.0 strict level 2//en" /* "-//IETF//DTD HTML 2.0 Strict Level 2//EN" */, PubIDInfo::eQuirks3, PubIDInfo::eQuirks3},
+ {"-//ietf//dtd html 2.0 strict//en" /* "-//IETF//DTD HTML 2.0 Strict//EN" */, PubIDInfo::eQuirks3, PubIDInfo::eQuirks3},
+ {"-//ietf//dtd html 2.0//en" /* "-//IETF//DTD HTML 2.0//EN" */, PubIDInfo::eQuirks3, PubIDInfo::eQuirks3},
+ {"-//ietf//dtd html 2.1e//en" /* "-//IETF//DTD HTML 2.1E//EN" */, PubIDInfo::eQuirks3, PubIDInfo::eQuirks3},
+ {"-//ietf//dtd html 3.0//en" /* "-//IETF//DTD HTML 3.0//EN" */, PubIDInfo::eQuirks3, PubIDInfo::eQuirks3},
+ {"-//ietf//dtd html 3.0//en//" /* "-//IETF//DTD HTML 3.0//EN//" */, PubIDInfo::eQuirks3, PubIDInfo::eQuirks3},
+ {"-//ietf//dtd html 3.2 final//en" /* "-//IETF//DTD HTML 3.2 Final//EN" */, PubIDInfo::eQuirks3, PubIDInfo::eQuirks3},
+ {"-//ietf//dtd html 3.2//en" /* "-//IETF//DTD HTML 3.2//EN" */, PubIDInfo::eQuirks3, PubIDInfo::eQuirks3},
+ {"-//ietf//dtd html 3//en" /* "-//IETF//DTD HTML 3//EN" */, PubIDInfo::eQuirks3, PubIDInfo::eQuirks3},
+ {"-//ietf//dtd html level 0//en" /* "-//IETF//DTD HTML Level 0//EN" */, PubIDInfo::eQuirks3, PubIDInfo::eQuirks3},
+ {"-//ietf//dtd html level 0//en//2.0" /* "-//IETF//DTD HTML Level 0//EN//2.0" */, PubIDInfo::eQuirks3, PubIDInfo::eQuirks3},
+ {"-//ietf//dtd html level 1//en" /* "-//IETF//DTD HTML Level 1//EN" */, PubIDInfo::eQuirks3, PubIDInfo::eQuirks3},
+ {"-//ietf//dtd html level 1//en//2.0" /* "-//IETF//DTD HTML Level 1//EN//2.0" */, PubIDInfo::eQuirks3, PubIDInfo::eQuirks3},
+ {"-//ietf//dtd html level 2//en" /* "-//IETF//DTD HTML Level 2//EN" */, PubIDInfo::eQuirks3, PubIDInfo::eQuirks3},
+ {"-//ietf//dtd html level 2//en//2.0" /* "-//IETF//DTD HTML Level 2//EN//2.0" */, PubIDInfo::eQuirks3, PubIDInfo::eQuirks3},
+ {"-//ietf//dtd html level 3//en" /* "-//IETF//DTD HTML Level 3//EN" */, PubIDInfo::eQuirks3, PubIDInfo::eQuirks3},
+ {"-//ietf//dtd html level 3//en//3.0" /* "-//IETF//DTD HTML Level 3//EN//3.0" */, PubIDInfo::eQuirks3, PubIDInfo::eQuirks3},
+ {"-//ietf//dtd html strict level 0//en" /* "-//IETF//DTD HTML Strict Level 0//EN" */, PubIDInfo::eQuirks3, PubIDInfo::eQuirks3},
+ {"-//ietf//dtd html strict level 0//en//2.0" /* "-//IETF//DTD HTML Strict Level 0//EN//2.0" */, PubIDInfo::eQuirks3, PubIDInfo::eQuirks3},
+ {"-//ietf//dtd html strict level 1//en" /* "-//IETF//DTD HTML Strict Level 1//EN" */, PubIDInfo::eQuirks3, PubIDInfo::eQuirks3},
+ {"-//ietf//dtd html strict level 1//en//2.0" /* "-//IETF//DTD HTML Strict Level 1//EN//2.0" */, PubIDInfo::eQuirks3, PubIDInfo::eQuirks3},
+ {"-//ietf//dtd html strict level 2//en" /* "-//IETF//DTD HTML Strict Level 2//EN" */, PubIDInfo::eQuirks3, PubIDInfo::eQuirks3},
+ {"-//ietf//dtd html strict level 2//en//2.0" /* "-//IETF//DTD HTML Strict Level 2//EN//2.0" */, PubIDInfo::eQuirks3, PubIDInfo::eQuirks3},
+ {"-//ietf//dtd html strict level 3//en" /* "-//IETF//DTD HTML Strict Level 3//EN" */, PubIDInfo::eQuirks3, PubIDInfo::eQuirks3},
+ {"-//ietf//dtd html strict level 3//en//3.0" /* "-//IETF//DTD HTML Strict Level 3//EN//3.0" */, PubIDInfo::eQuirks3, PubIDInfo::eQuirks3},
+ {"-//ietf//dtd html strict//en" /* "-//IETF//DTD HTML Strict//EN" */, PubIDInfo::eQuirks3, PubIDInfo::eQuirks3},
+ {"-//ietf//dtd html strict//en//2.0" /* "-//IETF//DTD HTML Strict//EN//2.0" */, PubIDInfo::eQuirks3, PubIDInfo::eQuirks3},
+ {"-//ietf//dtd html strict//en//3.0" /* "-//IETF//DTD HTML Strict//EN//3.0" */, PubIDInfo::eQuirks3, PubIDInfo::eQuirks3},
+ {"-//ietf//dtd html//en" /* "-//IETF//DTD HTML//EN" */, PubIDInfo::eQuirks3, PubIDInfo::eQuirks3},
+ {"-//ietf//dtd html//en//2.0" /* "-//IETF//DTD HTML//EN//2.0" */, PubIDInfo::eQuirks3, PubIDInfo::eQuirks3},
+ {"-//ietf//dtd html//en//3.0" /* "-//IETF//DTD HTML//EN//3.0" */, PubIDInfo::eQuirks3, PubIDInfo::eQuirks3},
+ {"-//metrius//dtd metrius presentational//en" /* "-//Metrius//DTD Metrius Presentational//EN" */, PubIDInfo::eQuirks, PubIDInfo::eQuirks},
+ {"-//microsoft//dtd internet explorer 2.0 html strict//en" /* "-//Microsoft//DTD Internet Explorer 2.0 HTML Strict//EN" */, PubIDInfo::eQuirks3, PubIDInfo::eQuirks3},
+ {"-//microsoft//dtd internet explorer 2.0 html//en" /* "-//Microsoft//DTD Internet Explorer 2.0 HTML//EN" */, PubIDInfo::eQuirks3, PubIDInfo::eQuirks3},
+ {"-//microsoft//dtd internet explorer 2.0 tables//en" /* "-//Microsoft//DTD Internet Explorer 2.0 Tables//EN" */, PubIDInfo::eQuirks3, PubIDInfo::eQuirks3},
+ {"-//microsoft//dtd internet explorer 3.0 html strict//en" /* "-//Microsoft//DTD Internet Explorer 3.0 HTML Strict//EN" */, PubIDInfo::eQuirks3, PubIDInfo::eQuirks3},
+ {"-//microsoft//dtd internet explorer 3.0 html//en" /* "-//Microsoft//DTD Internet Explorer 3.0 HTML//EN" */, PubIDInfo::eQuirks3, PubIDInfo::eQuirks3},
+ {"-//microsoft//dtd internet explorer 3.0 tables//en" /* "-//Microsoft//DTD Internet Explorer 3.0 Tables//EN" */, PubIDInfo::eQuirks3, PubIDInfo::eQuirks3},
+ {"-//netscape comm. corp.//dtd html//en" /* "-//Netscape Comm. Corp.//DTD HTML//EN" */, PubIDInfo::eQuirks3, PubIDInfo::eQuirks3},
+ {"-//netscape comm. corp.//dtd strict html//en" /* "-//Netscape Comm. Corp.//DTD Strict HTML//EN" */, PubIDInfo::eQuirks3, PubIDInfo::eQuirks3},
+ {"-//o'reilly and associates//dtd html 2.0//en" /* "-//O'Reilly and Associates//DTD HTML 2.0//EN" */, PubIDInfo::eQuirks3, PubIDInfo::eQuirks3},
+ {"-//o'reilly and associates//dtd html extended 1.0//en" /* "-//O'Reilly and Associates//DTD HTML Extended 1.0//EN" */, PubIDInfo::eQuirks3, PubIDInfo::eQuirks3},
+ {"-//o'reilly and associates//dtd html extended relaxed 1.0//en" /* "-//O'Reilly and Associates//DTD HTML Extended Relaxed 1.0//EN" */, PubIDInfo::eQuirks3, PubIDInfo::eQuirks3},
+ {"-//softquad software//dtd hotmetal pro 6.0::19990601::extensions to html 4.0//en" /* "-//SoftQuad Software//DTD HoTMetaL PRO 6.0::19990601::extensions to HTML 4.0//EN" */, PubIDInfo::eQuirks, PubIDInfo::eQuirks},
+ {"-//softquad//dtd hotmetal pro 4.0::19971010::extensions to html 4.0//en" /* "-//SoftQuad//DTD HoTMetaL PRO 4.0::19971010::extensions to HTML 4.0//EN" */, PubIDInfo::eQuirks, PubIDInfo::eQuirks},
+ {"-//spyglass//dtd html 2.0 extended//en" /* "-//Spyglass//DTD HTML 2.0 Extended//EN" */, PubIDInfo::eQuirks3, PubIDInfo::eQuirks3},
+ {"-//sq//dtd html 2.0 hotmetal + extensions//en" /* "-//SQ//DTD HTML 2.0 HoTMetaL + extensions//EN" */, PubIDInfo::eQuirks3, PubIDInfo::eQuirks3},
+ {"-//sun microsystems corp.//dtd hotjava html//en" /* "-//Sun Microsystems Corp.//DTD HotJava HTML//EN" */, PubIDInfo::eQuirks3, PubIDInfo::eQuirks3},
+ {"-//sun microsystems corp.//dtd hotjava strict html//en" /* "-//Sun Microsystems Corp.//DTD HotJava Strict HTML//EN" */, PubIDInfo::eQuirks3, PubIDInfo::eQuirks3},
+ {"-//w3c//dtd html 3 1995-03-24//en" /* "-//W3C//DTD HTML 3 1995-03-24//EN" */, PubIDInfo::eQuirks3, PubIDInfo::eQuirks3},
+ {"-//w3c//dtd html 3.2 draft//en" /* "-//W3C//DTD HTML 3.2 Draft//EN" */, PubIDInfo::eQuirks3, PubIDInfo::eQuirks3},
+ {"-//w3c//dtd html 3.2 final//en" /* "-//W3C//DTD HTML 3.2 Final//EN" */, PubIDInfo::eQuirks3, PubIDInfo::eQuirks3},
+ {"-//w3c//dtd html 3.2//en" /* "-//W3C//DTD HTML 3.2//EN" */, PubIDInfo::eQuirks3, PubIDInfo::eQuirks3},
+ {"-//w3c//dtd html 3.2s draft//en" /* "-//W3C//DTD HTML 3.2S Draft//EN" */, PubIDInfo::eQuirks3, PubIDInfo::eQuirks3},
+ {"-//w3c//dtd html 4.0 frameset//en" /* "-//W3C//DTD HTML 4.0 Frameset//EN" */, PubIDInfo::eQuirks, PubIDInfo::eQuirks},
+ {"-//w3c//dtd html 4.0 transitional//en" /* "-//W3C//DTD HTML 4.0 Transitional//EN" */, PubIDInfo::eQuirks, PubIDInfo::eQuirks},
+ {"-//w3c//dtd html 4.01 frameset//en" /* "-//W3C//DTD HTML 4.01 Frameset//EN" */, PubIDInfo::eQuirks, PubIDInfo::eAlmostStandards},
+ {"-//w3c//dtd html 4.01 transitional//en" /* "-//W3C//DTD HTML 4.01 Transitional//EN" */, PubIDInfo::eQuirks, PubIDInfo::eAlmostStandards},
+ {"-//w3c//dtd html experimental 19960712//en" /* "-//W3C//DTD HTML Experimental 19960712//EN" */, PubIDInfo::eQuirks3, PubIDInfo::eQuirks3},
+ {"-//w3c//dtd html experimental 970421//en" /* "-//W3C//DTD HTML Experimental 970421//EN" */, PubIDInfo::eQuirks3, PubIDInfo::eQuirks3},
+ {"-//w3c//dtd w3 html//en" /* "-//W3C//DTD W3 HTML//EN" */, PubIDInfo::eQuirks3, PubIDInfo::eQuirks3},
+ {"-//w3c//dtd xhtml 1.0 frameset//en" /* "-//W3C//DTD XHTML 1.0 Frameset//EN" */, PubIDInfo::eAlmostStandards, PubIDInfo::eAlmostStandards},
+ {"-//w3c//dtd xhtml 1.0 transitional//en" /* "-//W3C//DTD XHTML 1.0 Transitional//EN" */, PubIDInfo::eAlmostStandards, PubIDInfo::eAlmostStandards},
+ {"-//w3o//dtd w3 html 3.0//en" /* "-//W3O//DTD W3 HTML 3.0//EN" */, PubIDInfo::eQuirks3, PubIDInfo::eQuirks3},
+ {"-//w3o//dtd w3 html 3.0//en//" /* "-//W3O//DTD W3 HTML 3.0//EN//" */, PubIDInfo::eQuirks3, PubIDInfo::eQuirks3},
+ {"-//w3o//dtd w3 html strict 3.0//en//" /* "-//W3O//DTD W3 HTML Strict 3.0//EN//" */, PubIDInfo::eQuirks3, PubIDInfo::eQuirks3},
+ {"-//webtechs//dtd mozilla html 2.0//en" /* "-//WebTechs//DTD Mozilla HTML 2.0//EN" */, PubIDInfo::eQuirks3, PubIDInfo::eQuirks3},
+ {"-//webtechs//dtd mozilla html//en" /* "-//WebTechs//DTD Mozilla HTML//EN" */, PubIDInfo::eQuirks3, PubIDInfo::eQuirks3},
+ {"html" /* "HTML" */, PubIDInfo::eQuirks3, PubIDInfo::eQuirks3},
};
#ifdef DEBUG
@@ -984,7 +997,7 @@ static void VerifyPublicIDs()
}
#endif
-static void DetermineHTMLParseMode(nsString& aBuffer,
+static void DetermineHTMLParseMode(const nsString& aBuffer,
nsDTDMode& aParseMode,
eParserDocType& aDocType)
{
@@ -992,26 +1005,28 @@ static void DetermineHTMLParseMode(nsString& aBuffer,
VerifyPublicIDs();
#endif
PRInt32 resultFlags;
- nsAutoString publicIDUCS2;
- if (ParseDocTypeDecl(aBuffer, &resultFlags, publicIDUCS2)) {
+ nsAutoString publicIDUCS2, sysIDUCS2;
+ if (ParseDocTypeDecl(aBuffer, &resultFlags, publicIDUCS2, sysIDUCS2)) {
if (!(resultFlags & PARSE_DTD_HAVE_DOCTYPE)) {
// no DOCTYPE
aParseMode = eDTDMode_quirks;
aDocType = eHTML_Quirks;
- // Why do this? If it weren't for this, |aBuffer| could be
- // |const nsString&|, which it really should be.
- aBuffer.InsertWithConversion(
- "\n",
- 0);
} else if ((resultFlags & PARSE_DTD_HAVE_INTERNAL_SUBSET) ||
!(resultFlags & PARSE_DTD_HAVE_PUBLIC_ID)) {
- // A doctype with an internal subset is always strict.
- // A doctype without a public ID is always strict.
+ // A doctype with an internal subset is always full_standards.
+ // A doctype without a public ID is always full_standards.
aDocType = eHTML_Strict;
- aParseMode = eDTDMode_strict;
+ aParseMode = eDTDMode_full_standards;
+
+ // Special hack for IBM's custom DOCTYPE.
+ if (!(resultFlags & PARSE_DTD_HAVE_INTERNAL_SUBSET) &&
+ sysIDUCS2 == NS_LITERAL_STRING(
+ "http://www.ibm.com/data/dtd/v11/ibmxhtml1-transitional.dtd")) {
+ aParseMode = eDTDMode_almost_standards;
+ }
} else {
@@ -1043,14 +1058,17 @@ static void DetermineHTMLParseMode(nsString& aBuffer,
minimum = index + 1;
if (maximum < minimum) {
- // The DOCTYPE is not in our list, so it must be strict.
- aParseMode = eDTDMode_strict;
+ // The DOCTYPE is not in our list, so it must be full_standards.
+ aParseMode = eDTDMode_full_standards;
aDocType = eHTML_Strict;
return;
}
}
- switch (kPublicIDs[index].mode) {
+ switch ((resultFlags & PARSE_DTD_HAVE_SYSTEM_ID)
+ ? kPublicIDs[index].mode_if_sysid
+ : kPublicIDs[index].mode_if_no_sysid)
+ {
case PubIDInfo::eQuirks3:
aParseMode = eDTDMode_quirks;
aDocType = eHTML3_Quirks;
@@ -1059,14 +1077,13 @@ static void DetermineHTMLParseMode(nsString& aBuffer,
aParseMode = eDTDMode_quirks;
aDocType = eHTML_Quirks;
break;
- case PubIDInfo::eStrictIfSysID:
- if (resultFlags & PARSE_DTD_HAVE_SYSTEM_ID) {
- aParseMode = eDTDMode_strict;
- aDocType = eHTML_Strict;
- } else {
- aParseMode = eDTDMode_quirks;
- aDocType = eHTML_Quirks;
- }
+ case PubIDInfo::eAlmostStandards:
+ aParseMode = eDTDMode_almost_standards;
+ aDocType = eHTML_Strict;
+ break;
+ case PubIDInfo::eFullStandards:
+ aParseMode = eDTDMode_full_standards;
+ aDocType = eHTML_Strict;
break;
default:
NS_NOTREACHED("no other cases!");
@@ -1081,22 +1098,13 @@ static void DetermineHTMLParseMode(nsString& aBuffer,
}
static
-void DetermineParseMode(nsString& aBuffer,
+void DetermineParseMode(const nsString& aBuffer,
nsDTDMode& aParseMode,
eParserDocType& aDocType,
const nsACString& aMimeType)
{
if (aMimeType.Equals(NS_LITERAL_CSTRING(kHTMLTextContentType))) {
- // For XML (XHTML) documents served as text/html, we will use strict
- // mode. XML declarations must be the first thing in the document,
- // and must be lowercase. (XXX What about a byte order mark?)
- if (kNotFound != aBuffer.Find("