From 7c4652cc1632bc7e008d46f03b29b9dfd304d50b Mon Sep 17 00:00:00 2001 From: "dbaron%fas.harvard.edu" Date: Tue, 25 Jun 2002 21:16:17 +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. Remove previous fix for bug 151620. 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 git-svn-id: svn://10.0.0.236/trunk@124017 18797224-902f-48f8-a5cc-f745e15eee43 --- mozilla/content/base/public/nsCompatibility.h | 46 +++ .../base/public/nsIStyleRuleProcessor.h | 2 +- .../base/src/mozSanitizingSerializer.cpp | 3 +- .../base/src/mozSanitizingSerializer.h | 2 +- mozilla/content/base/src/nsDocumentViewer.cpp | 3 +- .../content/base/src/nsPlainTextSerializer.h | 2 +- mozilla/content/base/src/nsRange.cpp | 17 +- .../html/content/src/nsGenericHTMLElement.cpp | 17 +- .../html/document/src/nsHTMLContentSink.cpp | 29 +- .../html/document/src/nsHTMLDocument.cpp | 34 +-- .../html/document/src/nsHTMLDocument.h | 6 +- .../src/nsHTMLFragmentContentSink.cpp | 4 +- .../html/document/src/nsIHTMLDocument.h | 8 +- .../html/document/src/nsMarkupDocument.cpp | 8 +- .../html/document/src/nsMarkupDocument.h | 3 +- .../content/html/style/public/nsICSSLoader.h | 3 +- .../content/html/style/src/nsCSSLoader.cpp | 16 +- .../html/style/src/nsCSSStyleSheet.cpp | 19 +- .../html/style/src/nsHTMLStyleSheet.cpp | 2 +- mozilla/content/shared/src/nsStyleStruct.cpp | 8 +- .../xml/document/src/nsXMLDocument.cpp | 3 +- .../xul/document/src/nsXULDocument.cpp | 6 +- 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/nsCompatibility.h | 46 +++ mozilla/layout/base/nsDocumentViewer.cpp | 3 +- mozilla/layout/base/nsIPresShell.h | 3 +- mozilla/layout/base/nsPresContext.cpp | 4 +- mozilla/layout/base/nsPresContext.h | 6 +- mozilla/layout/base/nsPresShell.cpp | 7 +- mozilla/layout/base/public/MANIFEST | 1 + mozilla/layout/base/public/Makefile.in | 1 + mozilla/layout/base/public/makefile.win | 1 + mozilla/layout/base/public/nsCompatibility.h | 46 +++ mozilla/layout/base/public/nsIFrame.h | 2 +- mozilla/layout/base/public/nsIPresContext.h | 6 +- mozilla/layout/base/public/nsIPresShell.h | 3 +- mozilla/layout/base/public/nsPresContext.h | 6 +- mozilla/layout/base/src/nsPresContext.cpp | 4 +- mozilla/layout/generic/nsBlockFrame.cpp | 34 +-- mozilla/layout/generic/nsBlockFrame.h | 7 +- mozilla/layout/generic/nsBlockReflowState.cpp | 6 +- mozilla/layout/generic/nsFrame.cpp | 2 +- mozilla/layout/generic/nsFrame.h | 2 +- mozilla/layout/generic/nsIFrame.h | 2 +- mozilla/layout/generic/nsInlineFrame.cpp | 7 +- mozilla/layout/generic/nsInlineFrame.h | 4 +- mozilla/layout/generic/nsLineBox.cpp | 6 +- mozilla/layout/generic/nsLineBox.h | 2 +- mozilla/layout/generic/nsLineLayout.cpp | 50 ++-- mozilla/layout/generic/nsLineLayout.h | 12 +- mozilla/layout/generic/nsPlaceholderFrame.cpp | 4 +- mozilla/layout/generic/nsPlaceholderFrame.h | 4 +- mozilla/layout/generic/nsTextFrame.cpp | 11 +- mozilla/layout/html/base/src/nsBlockFrame.cpp | 34 +-- mozilla/layout/html/base/src/nsBlockFrame.h | 7 +- .../html/base/src/nsBlockReflowState.cpp | 6 +- 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 | 50 ++-- 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 | 7 +- 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/layout/style/nsCSSLoader.cpp | 16 +- mozilla/layout/style/nsCSSStyleSheet.cpp | 19 +- mozilla/layout/style/nsHTMLStyleSheet.cpp | 2 +- mozilla/layout/style/nsICSSLoader.h | 3 +- mozilla/layout/style/nsIStyleRuleProcessor.h | 2 +- mozilla/layout/style/nsStyleStruct.cpp | 8 +- mozilla/layout/tables/nsTableCellFrame.cpp | 2 +- mozilla/layout/tables/nsTableFrame.cpp | 2 +- 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 +- 102 files changed, 736 insertions(+), 659 deletions(-) create mode 100644 mozilla/content/base/public/nsCompatibility.h create mode 100644 mozilla/layout/base/nsCompatibility.h create mode 100644 mozilla/layout/base/public/nsCompatibility.h diff --git a/mozilla/content/base/public/nsCompatibility.h b/mozilla/content/base/public/nsCompatibility.h new file mode 100644 index 00000000000..d768ce7aab6 --- /dev/null +++ b/mozilla/content/base/public/nsCompatibility.h @@ -0,0 +1,46 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: NPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Netscape Public License + * Version 1.1 (the "License"); you may not use this file except in + * compliance with the License. You may obtain a copy of the License at + * http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is mozilla.org code. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the NPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the NPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ +#ifndef nsCompatibility_h___ +#define nsCompatibility_h___ + +enum nsCompatibility { + eCompatibility_FullStandards = 1, + eCompatibility_AlmostStandards = 2, + eCompatibility_NavQuirks = 3 +}; + +#endif /* nsCompatibility_h___ */ 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/mozSanitizingSerializer.cpp b/mozilla/content/base/src/mozSanitizingSerializer.cpp index 0dcdc16f349..8b6b4d236ae 100644 --- a/mozilla/content/base/src/mozSanitizingSerializer.cpp +++ b/mozilla/content/base/src/mozSanitizingSerializer.cpp @@ -377,8 +377,7 @@ mozSanitizingHTMLSerializer::SetTitle(const nsString& aValue) } NS_IMETHODIMP -mozSanitizingHTMLSerializer::AddDocTypeDecl(const nsIParserNode& aNode, - PRInt32 aMode) +mozSanitizingHTMLSerializer::AddDocTypeDecl(const nsIParserNode& aNode) { return NS_OK; } diff --git a/mozilla/content/base/src/mozSanitizingSerializer.h b/mozilla/content/base/src/mozSanitizingSerializer.h index 673e6047707..b8e0320d8f1 100644 --- a/mozilla/content/base/src/mozSanitizingSerializer.h +++ b/mozilla/content/base/src/mozSanitizingSerializer.h @@ -101,7 +101,7 @@ public: 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); + NS_IMETHOD AddDocTypeDecl(const nsIParserNode& aNode); NS_IMETHOD FlushPendingNotifications() { return NS_OK; } NS_IMETHOD SetDocumentCharset(nsAString& aCharset); NS_IMETHOD NotifyTagObservers(nsIParserNode* aNode) { return NS_OK; } diff --git a/mozilla/content/base/src/nsDocumentViewer.cpp b/mozilla/content/base/src/nsDocumentViewer.cpp index 14836311485..bbb2f3a7c4f 100644 --- a/mozilla/content/base/src/nsDocumentViewer.cpp +++ b/mozilla/content/base/src/nsDocumentViewer.cpp @@ -3847,8 +3847,7 @@ DocumentViewerImpl::ReflowPrintObject(PrintObject * aPO, PRBool aDoCalcShrink) // Setup hierarchical relationship in view manager aPO->mViewManager->SetRootView(aPO->mRootView); aPO->mPresShell->Init(document, aPO->mPresContext, - aPO->mViewManager, aPO->mStyleSet, - mode != eCompatibility_Standard); + aPO->mViewManager, aPO->mStyleSet, mode); if (!containerIsSet) { nsCOMPtr supps(do_QueryInterface(aPO->mWebShell)); diff --git a/mozilla/content/base/src/nsPlainTextSerializer.h b/mozilla/content/base/src/nsPlainTextSerializer.h index 9dd246da229..9a89c456afd 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 b58853ca30a..14284631410 100644 --- a/mozilla/content/base/src/nsRange.cpp +++ b/mozilla/content/base/src/nsRange.cpp @@ -2664,7 +2664,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/html/content/src/nsGenericHTMLElement.cpp b/mozilla/content/html/content/src/nsGenericHTMLElement.cpp index b25b7deee89..3b9ef287c41 100644 --- a/mozilla/content/html/content/src/nsGenericHTMLElement.cpp +++ b/mozilla/content/html/content/src/nsGenericHTMLElement.cpp @@ -1256,21 +1256,14 @@ static nsIHTMLStyleSheet* GetAttrStyleSheet(nsIDocument* aDocument) PRBool nsGenericHTMLElement::InNavQuirksMode(nsIDocument* aDoc) { - PRBool status = PR_FALSE; - nsCOMPtr doc(do_QueryInterface(aDoc)); - - if (doc) { - nsDTDMode mode; - - doc->GetDTDMode(mode); - - if (mode == eDTDMode_quirks) { - status = PR_TRUE; - } + 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 b2c108079bb..8bb521a8ec7 100644 --- a/mozilla/content/html/document/src/nsHTMLContentSink.cpp +++ b/mozilla/content/html/document/src/nsHTMLContentSink.cpp @@ -249,7 +249,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); @@ -2440,7 +2440,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 @@ -3308,14 +3323,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) @@ -4257,11 +4270,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 38ed964f68e..675353bbc67 100644 --- a/mozilla/content/html/document/src/nsHTMLDocument.cpp +++ b/mozilla/content/html/document/src/nsHTMLDocument.cpp @@ -300,7 +300,7 @@ nsHTMLDocument::nsHTMLDocument() mAnchors = nsnull; mLayers = nsnull; mParser = nsnull; - mDTDMode = eDTDMode_quirks; + mCompatMode = eCompatibility_NavQuirks; mCSSLoader = nsnull; mForms = nsnull; @@ -495,7 +495,7 @@ nsHTMLDocument::CreateShell(nsIPresContext* aContext, nsIPresShell** aInstancePtrResult) { return doCreateShell(aContext, aViewManager, aStyleSet, - eDTDMode_strict != mDTDMode, aInstancePtrResult); + mCompatMode, aInstancePtrResult); } // The following Try*Charset will return PR_FALSE only if the charset source @@ -1332,7 +1332,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); @@ -1341,27 +1341,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); } } @@ -3328,17 +3326,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 6561b6f5d59..78acaab17ae 100644 --- a/mozilla/content/html/document/src/nsHTMLDocument.h +++ b/mozilla/content/html/document/src/nsHTMLDocument.h @@ -122,8 +122,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); } @@ -232,7 +232,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 0c05cc23b0c..7688c33d80f 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 5f6d6ab51b3..87359f47ee3 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 0ee05f0c5d0..11baf8aabec 100644 --- a/mozilla/content/html/document/src/nsMarkupDocument.cpp +++ b/mozilla/content/html/document/src/nsMarkupDocument.cpp @@ -65,15 +65,15 @@ nsMarkupDocument::CreateShell(nsIPresContext* aContext, // 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, PR_FALSE, - aInstancePtrResult); + return doCreateShell(aContext, aViewManager, aStyleSet, + eCompatibility_FullStandards, aInstancePtrResult); } nsresult nsMarkupDocument::doCreateShell(nsIPresContext* aContext, nsIViewManager* aViewManager, nsIStyleSet* aStyleSet, - PRBool aIsQuirksMode, + nsCompatibility aCompatMode, nsIPresShell** aInstancePtrResult) { NS_PRECONDITION(nsnull != aInstancePtrResult, "null ptr"); @@ -84,7 +84,7 @@ nsMarkupDocument::doCreateShell(nsIPresContext* aContext, return rv; } - rv = shell->Init(this, aContext, aViewManager, aStyleSet, aIsQuirksMode); + rv = shell->Init(this, aContext, aViewManager, aStyleSet, aCompatMode); if (NS_FAILED(rv)) { return rv; } diff --git a/mozilla/content/html/document/src/nsMarkupDocument.h b/mozilla/content/html/document/src/nsMarkupDocument.h index 83730ed99d7..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: @@ -69,7 +70,7 @@ protected: nsresult doCreateShell(nsIPresContext* aContext, nsIViewManager* aViewManager, nsIStyleSet* aStyleSet, - PRBool aIsQuirksMode, + nsCompatibility aCompatMode, nsIPresShell** aInstancePtrResult); }; 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 60baa178258..5f3f07697e5 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); @@ -636,13 +636,13 @@ SheetLoadData::OnStreamComplete(nsIStreamLoader* aLoader, if (realDocument && aString && aStringLen>0) { 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 da6674fa99b..1ffc740d67e 100644 --- a/mozilla/content/html/style/src/nsCSSStyleSheet.cpp +++ b/mozilla/content/html/style/src/nsCSSStyleSheet.cpp @@ -3309,13 +3309,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; } @@ -3628,7 +3626,7 @@ static PRBool SelectorMatches(RuleProcessorData &data, } else if (IsEventPseudo(pseudoClass->mAtom)) { // check if the element is event-sensitive - if (data.mIsQuirkMode && + if (data.mCompatMode == eCompatibility_NavQuirks && // global selector: !aSelector->mTag && !aSelector->mClassList && !aSelector->mIDList && !aSelector->mAttrList && @@ -3792,7 +3790,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; @@ -3863,7 +3862,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; @@ -4438,11 +4437,11 @@ CSSRuleProcessor::GetRuleCascade(nsIPresContext* aPresContext, nsIAtom* aMedium) } if (mSheets) { - nsCompatibility quirkMode = eCompatibility_Standard; + nsCompatibility quirkMode; aPresContext->GetCompatibilityMode(&quirkMode); cascade = new RuleCascadeData(aMedium, - eCompatibility_Standard != quirkMode); + eCompatibility_NavQuirks == quirkMode); if (cascade) { *cascadep = cascade; diff --git a/mozilla/content/html/style/src/nsHTMLStyleSheet.cpp b/mozilla/content/html/style/src/nsHTMLStyleSheet.cpp index 63dc49afbb3..68b139e0a32 100644 --- a/mozilla/content/html/style/src/nsHTMLStyleSheet.cpp +++ b/mozilla/content/html/style/src/nsHTMLStyleSheet.cpp @@ -1134,7 +1134,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 02e88bf9af6..53c01b71e2f 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 7b1f7708750..a9f1d1954c0 100644 --- a/mozilla/content/xml/document/src/nsXMLDocument.cpp +++ b/mozilla/content/xml/document/src/nsXMLDocument.cpp @@ -1105,7 +1105,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 be53541ad29..12bc265c9d2 100644 --- a/mozilla/content/xul/document/src/nsXULDocument.cpp +++ b/mozilla/content/xul/document/src/nsXULDocument.cpp @@ -1059,7 +1059,8 @@ nsXULDocument::CreateShell(nsIPresContext* aContext, if (NS_FAILED(rv)) return rv; - rv = shell->Init(this, aContext, aViewManager, aStyleSet, PR_FALSE); + rv = shell->Init(this, aContext, aViewManager, aStyleSet, + eCompatibility_FullStandards); if (NS_FAILED(rv)) { NS_RELEASE(shell); return rv; @@ -1571,7 +1572,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 ad1c60f7cbf..7923c915cda 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 7d577e7d3e7..48329fe5421 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: @@ -1994,7 +1995,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 @@ -2343,23 +2346,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 a37cfb81b4e..432ba13d283 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 adfcdf99a7d..317c87eeced 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 54e118d1e50..651568c3e28 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("mViewManager->SetRootView(aPO->mRootView); aPO->mPresShell->Init(document, aPO->mPresContext, - aPO->mViewManager, aPO->mStyleSet, - mode != eCompatibility_Standard); + aPO->mViewManager, aPO->mStyleSet, mode); if (!containerIsSet) { nsCOMPtr supps(do_QueryInterface(aPO->mWebShell)); diff --git a/mozilla/layout/base/nsIPresShell.h b/mozilla/layout/base/nsIPresShell.h index cc577ff8fa6..b9a8db41e2c 100644 --- a/mozilla/layout/base/nsIPresShell.h +++ b/mozilla/layout/base/nsIPresShell.h @@ -41,6 +41,7 @@ #include "nsCoord.h" #include "nsEvent.h" #include "nsReflowType.h" +#include "nsCompatibility.h" class nsIAtom; class nsIContent; @@ -126,7 +127,7 @@ public: nsIPresContext* aPresContext, nsIViewManager* aViewManager, nsIStyleSet* aStyleSet, - PRBool aIsQuirksMode) = 0; + nsCompatibility aCompatMode) = 0; /** * All callers are responsible for calling |Destroy| after calling diff --git a/mozilla/layout/base/nsPresContext.cpp b/mozilla/layout/base/nsPresContext.cpp index ac79ee074ff..408bfcdc23d 100644 --- a/mozilla/layout/base/nsPresContext.cpp +++ b/mozilla/layout/base/nsPresContext.cpp @@ -149,7 +149,7 @@ nsPresContext::nsPresContext() mNoTheme(PR_FALSE) { NS_INIT_REFCNT(); - mCompatibilityMode = eCompatibility_Standard; + mCompatibilityMode = eCompatibility_FullStandards; mWidgetRenderingMode = eWidgetRendering_Gfx; mImageAnimationMode = imgIContainer::kNormalAnimMode; mImageAnimationModePref = imgIContainer::kNormalAnimMode; @@ -769,7 +769,7 @@ nsPresContext::SetCompatibilityMode(nsCompatibility aMode) nsCOMPtr set; mShell->GetStyleSet(getter_AddRefs(set)); if (set) { - set->EnableQuirkStyleSheet(mCompatibilityMode != eCompatibility_Standard); + set->EnableQuirkStyleSheet(mCompatibilityMode == eCompatibility_NavQuirks); } return NS_OK; } diff --git a/mozilla/layout/base/nsPresContext.h b/mozilla/layout/base/nsPresContext.h index f4208d681a9..1396af4d9b2 100644 --- a/mozilla/layout/base/nsPresContext.h +++ b/mozilla/layout/base/nsPresContext.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/nsPresShell.cpp b/mozilla/layout/base/nsPresShell.cpp index 80383271bb3..747bd3f76e2 100644 --- a/mozilla/layout/base/nsPresShell.cpp +++ b/mozilla/layout/base/nsPresShell.cpp @@ -1058,7 +1058,7 @@ public: nsIPresContext* aPresContext, nsIViewManager* aViewManager, nsIStyleSet* aStyleSet, - PRBool aIsQuirksMode); + nsCompatibility aCompatMode); NS_IMETHOD Destroy(); NS_IMETHOD AllocateFrame(size_t aSize, void** aResult); @@ -1685,7 +1685,7 @@ PresShell::Init(nsIDocument* aDocument, nsIPresContext* aPresContext, nsIViewManager* aViewManager, nsIStyleSet* aStyleSet, - PRBool aIsQuirksMode) + nsCompatibility aCompatMode) { NS_PRECONDITION(nsnull != aDocument, "null ptr"); NS_PRECONDITION(nsnull != aPresContext, "null ptr"); @@ -1713,8 +1713,7 @@ PresShell::Init(nsIDocument* aDocument, // Set the compatibility mode after attaching the pres context and // style set, but before creating any frames. - mPresContext->SetCompatibilityMode(aIsQuirksMode - ? eCompatibility_NavQuirks : eCompatibility_Standard); + mPresContext->SetCompatibilityMode(aCompatMode); mHistoryState = nsnull; diff --git a/mozilla/layout/base/public/MANIFEST b/mozilla/layout/base/public/MANIFEST index 330740849d5..3d6e67088ac 100644 --- a/mozilla/layout/base/public/MANIFEST +++ b/mozilla/layout/base/public/MANIFEST @@ -3,6 +3,7 @@ # nsBidi.h nsBidiPresUtils.h +nsCompatibility.h nsFrameList.h nsFrameTraversal.h nsHTMLReflowMetrics.h diff --git a/mozilla/layout/base/public/Makefile.in b/mozilla/layout/base/public/Makefile.in index 2e7af30f107..e0b7252ec63 100644 --- a/mozilla/layout/base/public/Makefile.in +++ b/mozilla/layout/base/public/Makefile.in @@ -30,6 +30,7 @@ MODULE = layout XPIDL_MODULE = layout_base EXPORTS = \ +nsCompatibility.h \ nsFrameList.h \ nsFrameTraversal.h \ nsHTMLReflowMetrics.h \ diff --git a/mozilla/layout/base/public/makefile.win b/mozilla/layout/base/public/makefile.win index 892efeb3df2..04ebe0b533a 100644 --- a/mozilla/layout/base/public/makefile.win +++ b/mozilla/layout/base/public/makefile.win @@ -25,6 +25,7 @@ XPIDL_MODULE=layout_base include <$(DEPTH)\config\config.mak> EXPORTS = \ + nsCompatibility.h \ nsFrameList.h \ nsFrameTraversal.h \ nsHTMLReflowMetrics.h \ diff --git a/mozilla/layout/base/public/nsCompatibility.h b/mozilla/layout/base/public/nsCompatibility.h new file mode 100644 index 00000000000..d768ce7aab6 --- /dev/null +++ b/mozilla/layout/base/public/nsCompatibility.h @@ -0,0 +1,46 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: NPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Netscape Public License + * Version 1.1 (the "License"); you may not use this file except in + * compliance with the License. You may obtain a copy of the License at + * http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is mozilla.org code. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the NPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the NPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ +#ifndef nsCompatibility_h___ +#define nsCompatibility_h___ + +enum nsCompatibility { + eCompatibility_FullStandards = 1, + eCompatibility_AlmostStandards = 2, + eCompatibility_NavQuirks = 3 +}; + +#endif /* nsCompatibility_h___ */ diff --git a/mozilla/layout/base/public/nsIFrame.h b/mozilla/layout/base/public/nsIFrame.h index 210261fbbe6..1d2951186eb 100644 --- a/mozilla/layout/base/public/nsIFrame.h +++ b/mozilla/layout/base/public/nsIFrame.h @@ -1154,7 +1154,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 f4208d681a9..1396af4d9b2 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 cc577ff8fa6..b9a8db41e2c 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; @@ -126,7 +127,7 @@ public: nsIPresContext* aPresContext, nsIViewManager* aViewManager, nsIStyleSet* aStyleSet, - PRBool aIsQuirksMode) = 0; + nsCompatibility aCompatMode) = 0; /** * All callers are responsible for calling |Destroy| after calling diff --git a/mozilla/layout/base/public/nsPresContext.h b/mozilla/layout/base/public/nsPresContext.h index f4208d681a9..1396af4d9b2 100644 --- a/mozilla/layout/base/public/nsPresContext.h +++ b/mozilla/layout/base/public/nsPresContext.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/src/nsPresContext.cpp b/mozilla/layout/base/src/nsPresContext.cpp index ac79ee074ff..408bfcdc23d 100644 --- a/mozilla/layout/base/src/nsPresContext.cpp +++ b/mozilla/layout/base/src/nsPresContext.cpp @@ -149,7 +149,7 @@ nsPresContext::nsPresContext() mNoTheme(PR_FALSE) { NS_INIT_REFCNT(); - mCompatibilityMode = eCompatibility_Standard; + mCompatibilityMode = eCompatibility_FullStandards; mWidgetRenderingMode = eWidgetRendering_Gfx; mImageAnimationMode = imgIContainer::kNormalAnimMode; mImageAnimationModePref = imgIContainer::kNormalAnimMode; @@ -769,7 +769,7 @@ nsPresContext::SetCompatibilityMode(nsCompatibility aMode) nsCOMPtr set; mShell->GetStyleSet(getter_AddRefs(set)); if (set) { - set->EnableQuirkStyleSheet(mCompatibilityMode != eCompatibility_Standard); + set->EnableQuirkStyleSheet(mCompatibilityMode == eCompatibility_NavQuirks); } return NS_OK; } diff --git a/mozilla/layout/generic/nsBlockFrame.cpp b/mozilla/layout/generic/nsBlockFrame.cpp index bb0d7b0bdd4..b5c05d10045 100644 --- a/mozilla/layout/generic/nsBlockFrame.cpp +++ b/mozilla/layout/generic/nsBlockFrame.cpp @@ -2941,7 +2941,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. @@ -2971,10 +2972,6 @@ nsBlockFrame::IsEmpty(PRBool aIsQuirkMode, PRBool aIsPre, PRBool *aResult) } - // IsEmpty treats standards and quirks mode differently. We want - // quirks behavior for a table cell block. - PRBool quirkMode = aIsQuirkMode || IsTDTableCellBlock(*this); - const nsStyleText* styleText = NS_STATIC_CAST(const nsStyleText*, mStyleContext->GetStyleData(eStyleStruct_Text)); PRBool isPre = @@ -2985,7 +2982,7 @@ nsBlockFrame::IsEmpty(PRBool aIsQuirkMode, PRBool aIsPre, PRBool *aResult) line != line_end; ++line) { - line->IsEmpty(quirkMode, isPre, aResult); + line->IsEmpty(aCompatMode, isPre, aResult); if (! *aResult) break; } @@ -6555,30 +6552,6 @@ nsBlockFrame::BuildFloaterList() // XXX keep the text-run data in the first-in-flow of the block - -PRBool -nsBlockFrame::IsTDTableCellBlock(nsIFrame& aFrame) -{ - nsIFrame* parent; - aFrame.GetParent(&parent); - if (parent) { - nsCOMPtr frameType; - parent->GetFrameType(getter_AddRefs(frameType)); - if (nsLayoutAtoms::tableCellFrame == frameType) { - nsCOMPtr content; - aFrame.GetContent(getter_AddRefs(content)); - if (content && content->IsContentOfType(nsIContent::eHTML)) { - nsCOMPtr tag; - content->GetTag(*getter_AddRefs(tag)); - if (tag == nsHTMLAtoms::td) { - return PR_TRUE; - } - } - } - } - return PR_FALSE; -} - #ifdef DEBUG void nsBlockFrame::VerifyLines(PRBool aFinalCheckOK) @@ -6663,5 +6636,4 @@ nsBlockFrame::GetDepth() const } return depth; } - #endif diff --git a/mozilla/layout/generic/nsBlockFrame.h b/mozilla/layout/generic/nsBlockFrame.h index 032b66015e7..318b095d81c 100644 --- a/mozilla/layout/generic/nsBlockFrame.h +++ b/mozilla/layout/generic/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, @@ -197,9 +199,6 @@ public: inline nscoord GetAscent() { return mAscent; } - // Return true if aFrame is the (only) child of an nsTableCellFrame which has a TD content node. - static PRBool IsTDTableCellBlock(nsIFrame& aFrame); - protected: nsBlockFrame(); virtual ~nsBlockFrame(); diff --git a/mozilla/layout/generic/nsBlockReflowState.cpp b/mozilla/layout/generic/nsBlockReflowState.cpp index 46f6c4d937a..123f86f54c1 100644 --- a/mozilla/layout/generic/nsBlockReflowState.cpp +++ b/mozilla/layout/generic/nsBlockReflowState.cpp @@ -450,12 +450,8 @@ nsBlockReflowState::ReconstructMarginAbove(nsLineList::iterator aLine) ((NS_STYLE_WHITESPACE_PRE == styleText->mWhiteSpace) || (NS_STYLE_WHITESPACE_MOZ_PRE_WRAP == styleText->mWhiteSpace)); - // IsEmpty treats standards and quirks mode differently. We want - // quirks behavior for a table cell block. nsCompatibility mode; mPresContext->GetCompatibilityMode(&mode); - PRBool isQuirkMode = (mode == eCompatibility_NavQuirks) || - nsBlockFrame::IsTDTableCellBlock(*mBlock); nsLineList::iterator firstLine = block->begin_lines(); for (;;) { @@ -465,7 +461,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/generic/nsFrame.cpp b/mozilla/layout/generic/nsFrame.cpp index 8ee7d6ac179..1e334fa3668 100644 --- a/mozilla/layout/generic/nsFrame.cpp +++ b/mozilla/layout/generic/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/generic/nsFrame.h b/mozilla/layout/generic/nsFrame.h index 6deb5e59d4a..17f6680bcb6 100644 --- a/mozilla/layout/generic/nsFrame.h +++ b/mozilla/layout/generic/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/generic/nsIFrame.h b/mozilla/layout/generic/nsIFrame.h index 210261fbbe6..1d2951186eb 100644 --- a/mozilla/layout/generic/nsIFrame.h +++ b/mozilla/layout/generic/nsIFrame.h @@ -1154,7 +1154,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/generic/nsInlineFrame.cpp b/mozilla/layout/generic/nsInlineFrame.cpp index e7066bbc1fa..2bf016b7199 100644 --- a/mozilla/layout/generic/nsInlineFrame.cpp +++ b/mozilla/layout/generic/nsInlineFrame.cpp @@ -135,9 +135,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; } @@ -182,7 +183,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/generic/nsInlineFrame.h b/mozilla/layout/generic/nsInlineFrame.h index 1e8865da1f6..715dbb0a08e 100644 --- a/mozilla/layout/generic/nsInlineFrame.h +++ b/mozilla/layout/generic/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/generic/nsLineBox.cpp b/mozilla/layout/generic/nsLineBox.cpp index cfee9e7c067..75c42273669 100644 --- a/mozilla/layout/generic/nsLineBox.cpp +++ b/mozilla/layout/generic/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/generic/nsLineBox.h b/mozilla/layout/generic/nsLineBox.h index 83bd73c2f46..e710870b621 100644 --- a/mozilla/layout/generic/nsLineBox.h +++ b/mozilla/layout/generic/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/generic/nsLineLayout.cpp b/mozilla/layout/generic/nsLineLayout.cpp index 8c618709216..2ef875ddd0d 100644 --- a/mozilla/layout/generic/nsLineLayout.cpp +++ b/mozilla/layout/generic/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); -} - // Find out if the frame has a non-null prev-in-flow, i.e., whether it // is a continuation. inline PRBool @@ -2221,20 +2203,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 two exceptions). The 1st exception - // 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. The 2nd exception is if the - // span's containing block is a table cell block and the content is a TD. + // 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 @@ -2248,7 +2230,7 @@ nsLineLayout::VerticalAlignFrames(PerSpanData* psd) PRBool zeroEffectiveSpanBox = PR_FALSE; // XXXldb If we really have empty continuations, then all these other // checks don't make sense for them. - if ((emptyContinuation || !InStrictMode() || nsBlockFrame::IsTDTableCellBlock(*spanFrame)) && + if ((emptyContinuation || mCompatMode != eCompatibility_FullStandards) && ((psd == mRootSpan) || ((0 == spanFramePFD->mBorderPadding.top) && (0 == spanFramePFD->mBorderPadding.right) && @@ -2282,7 +2264,7 @@ nsLineLayout::VerticalAlignFrames(PerSpanData* psd) // within other inline frames. if (flag != PFD_ISTEXTFRAME) { PRBool empty; - pfd->mFrame->IsEmpty(PR_TRUE, preMode, &empty); + pfd->mFrame->IsEmpty(mCompatMode, preMode, &empty); if (!empty) { flag = PFD_ISTEXTFRAME; } diff --git a/mozilla/layout/generic/nsLineLayout.h b/mozilla/layout/generic/nsLineLayout.h index 24d0c624807..9e8904c6ffa 100644 --- a/mozilla/layout/generic/nsLineLayout.h +++ b/mozilla/layout/generic/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/generic/nsPlaceholderFrame.cpp b/mozilla/layout/generic/nsPlaceholderFrame.cpp index 7f8d18d9c6f..91c456dbe95 100644 --- a/mozilla/layout/generic/nsPlaceholderFrame.cpp +++ b/mozilla/layout/generic/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/generic/nsPlaceholderFrame.h b/mozilla/layout/generic/nsPlaceholderFrame.h index 37ef364163b..86bbe899314 100644 --- a/mozilla/layout/generic/nsPlaceholderFrame.h +++ b/mozilla/layout/generic/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/generic/nsTextFrame.cpp b/mozilla/layout/generic/nsTextFrame.cpp index edf9b8a80b8..cd4069b4f2c 100644 --- a/mozilla/layout/generic/nsTextFrame.cpp +++ b/mozilla/layout/generic/nsTextFrame.cpp @@ -497,7 +497,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); @@ -2156,7 +2158,6 @@ nsTextFrame::IsVisibleForPainting(nsIPresContext * aPresContext, PRBool* aIsVisible) { if (aCheckVis) { - nsIStyleContext* sc = mStyleContext; const nsStyleVisibility* vis = (const nsStyleVisibility*)mStyleContext->GetStyleData(eStyleStruct_Visibility); if (!vis->IsVisible()) { @@ -5839,9 +5840,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/base/src/nsBlockFrame.cpp b/mozilla/layout/html/base/src/nsBlockFrame.cpp index bb0d7b0bdd4..b5c05d10045 100644 --- a/mozilla/layout/html/base/src/nsBlockFrame.cpp +++ b/mozilla/layout/html/base/src/nsBlockFrame.cpp @@ -2941,7 +2941,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. @@ -2971,10 +2972,6 @@ nsBlockFrame::IsEmpty(PRBool aIsQuirkMode, PRBool aIsPre, PRBool *aResult) } - // IsEmpty treats standards and quirks mode differently. We want - // quirks behavior for a table cell block. - PRBool quirkMode = aIsQuirkMode || IsTDTableCellBlock(*this); - const nsStyleText* styleText = NS_STATIC_CAST(const nsStyleText*, mStyleContext->GetStyleData(eStyleStruct_Text)); PRBool isPre = @@ -2985,7 +2982,7 @@ nsBlockFrame::IsEmpty(PRBool aIsQuirkMode, PRBool aIsPre, PRBool *aResult) line != line_end; ++line) { - line->IsEmpty(quirkMode, isPre, aResult); + line->IsEmpty(aCompatMode, isPre, aResult); if (! *aResult) break; } @@ -6555,30 +6552,6 @@ nsBlockFrame::BuildFloaterList() // XXX keep the text-run data in the first-in-flow of the block - -PRBool -nsBlockFrame::IsTDTableCellBlock(nsIFrame& aFrame) -{ - nsIFrame* parent; - aFrame.GetParent(&parent); - if (parent) { - nsCOMPtr frameType; - parent->GetFrameType(getter_AddRefs(frameType)); - if (nsLayoutAtoms::tableCellFrame == frameType) { - nsCOMPtr content; - aFrame.GetContent(getter_AddRefs(content)); - if (content && content->IsContentOfType(nsIContent::eHTML)) { - nsCOMPtr tag; - content->GetTag(*getter_AddRefs(tag)); - if (tag == nsHTMLAtoms::td) { - return PR_TRUE; - } - } - } - } - return PR_FALSE; -} - #ifdef DEBUG void nsBlockFrame::VerifyLines(PRBool aFinalCheckOK) @@ -6663,5 +6636,4 @@ nsBlockFrame::GetDepth() const } return depth; } - #endif diff --git a/mozilla/layout/html/base/src/nsBlockFrame.h b/mozilla/layout/html/base/src/nsBlockFrame.h index 032b66015e7..318b095d81c 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, @@ -197,9 +199,6 @@ public: inline nscoord GetAscent() { return mAscent; } - // Return true if aFrame is the (only) child of an nsTableCellFrame which has a TD content node. - static PRBool IsTDTableCellBlock(nsIFrame& aFrame); - protected: nsBlockFrame(); virtual ~nsBlockFrame(); diff --git a/mozilla/layout/html/base/src/nsBlockReflowState.cpp b/mozilla/layout/html/base/src/nsBlockReflowState.cpp index 46f6c4d937a..123f86f54c1 100644 --- a/mozilla/layout/html/base/src/nsBlockReflowState.cpp +++ b/mozilla/layout/html/base/src/nsBlockReflowState.cpp @@ -450,12 +450,8 @@ nsBlockReflowState::ReconstructMarginAbove(nsLineList::iterator aLine) ((NS_STYLE_WHITESPACE_PRE == styleText->mWhiteSpace) || (NS_STYLE_WHITESPACE_MOZ_PRE_WRAP == styleText->mWhiteSpace)); - // IsEmpty treats standards and quirks mode differently. We want - // quirks behavior for a table cell block. nsCompatibility mode; mPresContext->GetCompatibilityMode(&mode); - PRBool isQuirkMode = (mode == eCompatibility_NavQuirks) || - nsBlockFrame::IsTDTableCellBlock(*mBlock); nsLineList::iterator firstLine = block->begin_lines(); for (;;) { @@ -465,7 +461,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 8ee7d6ac179..1e334fa3668 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 e7066bbc1fa..2bf016b7199 100644 --- a/mozilla/layout/html/base/src/nsInlineFrame.cpp +++ b/mozilla/layout/html/base/src/nsInlineFrame.cpp @@ -135,9 +135,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; } @@ -182,7 +183,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 cfee9e7c067..75c42273669 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 8c618709216..2ef875ddd0d 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); -} - // Find out if the frame has a non-null prev-in-flow, i.e., whether it // is a continuation. inline PRBool @@ -2221,20 +2203,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 two exceptions). The 1st exception - // 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. The 2nd exception is if the - // span's containing block is a table cell block and the content is a TD. + // 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 @@ -2248,7 +2230,7 @@ nsLineLayout::VerticalAlignFrames(PerSpanData* psd) PRBool zeroEffectiveSpanBox = PR_FALSE; // XXXldb If we really have empty continuations, then all these other // checks don't make sense for them. - if ((emptyContinuation || !InStrictMode() || nsBlockFrame::IsTDTableCellBlock(*spanFrame)) && + if ((emptyContinuation || mCompatMode != eCompatibility_FullStandards) && ((psd == mRootSpan) || ((0 == spanFramePFD->mBorderPadding.top) && (0 == spanFramePFD->mBorderPadding.right) && @@ -2282,7 +2264,7 @@ nsLineLayout::VerticalAlignFrames(PerSpanData* psd) // within other inline frames. if (flag != PFD_ISTEXTFRAME) { PRBool empty; - pfd->mFrame->IsEmpty(PR_TRUE, preMode, &empty); + pfd->mFrame->IsEmpty(mCompatMode, preMode, &empty); if (!empty) { flag = PFD_ISTEXTFRAME; } diff --git a/mozilla/layout/html/base/src/nsLineLayout.h b/mozilla/layout/html/base/src/nsLineLayout.h index 24d0c624807..9e8904c6ffa 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 7f8d18d9c6f..91c456dbe95 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 37ef364163b..86bbe899314 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 80383271bb3..747bd3f76e2 100644 --- a/mozilla/layout/html/base/src/nsPresShell.cpp +++ b/mozilla/layout/html/base/src/nsPresShell.cpp @@ -1058,7 +1058,7 @@ public: nsIPresContext* aPresContext, nsIViewManager* aViewManager, nsIStyleSet* aStyleSet, - PRBool aIsQuirksMode); + nsCompatibility aCompatMode); NS_IMETHOD Destroy(); NS_IMETHOD AllocateFrame(size_t aSize, void** aResult); @@ -1685,7 +1685,7 @@ PresShell::Init(nsIDocument* aDocument, nsIPresContext* aPresContext, nsIViewManager* aViewManager, nsIStyleSet* aStyleSet, - PRBool aIsQuirksMode) + nsCompatibility aCompatMode) { NS_PRECONDITION(nsnull != aDocument, "null ptr"); NS_PRECONDITION(nsnull != aPresContext, "null ptr"); @@ -1713,8 +1713,7 @@ PresShell::Init(nsIDocument* aDocument, // Set the compatibility mode after attaching the pres context and // style set, but before creating any frames. - mPresContext->SetCompatibilityMode(aIsQuirksMode - ? eCompatibility_NavQuirks : eCompatibility_Standard); + mPresContext->SetCompatibilityMode(aCompatMode); mHistoryState = nsnull; diff --git a/mozilla/layout/html/base/src/nsTextFrame.cpp b/mozilla/layout/html/base/src/nsTextFrame.cpp index edf9b8a80b8..cd4069b4f2c 100644 --- a/mozilla/layout/html/base/src/nsTextFrame.cpp +++ b/mozilla/layout/html/base/src/nsTextFrame.cpp @@ -497,7 +497,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); @@ -2156,7 +2158,6 @@ nsTextFrame::IsVisibleForPainting(nsIPresContext * aPresContext, PRBool* aIsVisible) { if (aCheckVis) { - nsIStyleContext* sc = mStyleContext; const nsStyleVisibility* vis = (const nsStyleVisibility*)mStyleContext->GetStyleData(eStyleStruct_Visibility); if (!vis->IsVisible()) { @@ -5839,9 +5840,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 d1656d71452..34dda964c04 100644 --- a/mozilla/layout/html/table/src/nsTableCellFrame.cpp +++ b/mozilla/layout/html/table/src/nsTableCellFrame.cpp @@ -1016,7 +1016,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 29b4c9bfbb0..9f809fd74da 100644 --- a/mozilla/layout/html/table/src/nsTableFrame.cpp +++ b/mozilla/layout/html/table/src/nsTableFrame.cpp @@ -2844,7 +2844,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/layout/style/nsCSSLoader.cpp b/mozilla/layout/style/nsCSSLoader.cpp index 60baa178258..5f3f07697e5 100644 --- a/mozilla/layout/style/nsCSSLoader.cpp +++ b/mozilla/layout/style/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); @@ -636,13 +636,13 @@ SheetLoadData::OnStreamComplete(nsIStreamLoader* aLoader, if (realDocument && aString && aStringLen>0) { 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/layout/style/nsCSSStyleSheet.cpp b/mozilla/layout/style/nsCSSStyleSheet.cpp index da6674fa99b..1ffc740d67e 100644 --- a/mozilla/layout/style/nsCSSStyleSheet.cpp +++ b/mozilla/layout/style/nsCSSStyleSheet.cpp @@ -3309,13 +3309,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; } @@ -3628,7 +3626,7 @@ static PRBool SelectorMatches(RuleProcessorData &data, } else if (IsEventPseudo(pseudoClass->mAtom)) { // check if the element is event-sensitive - if (data.mIsQuirkMode && + if (data.mCompatMode == eCompatibility_NavQuirks && // global selector: !aSelector->mTag && !aSelector->mClassList && !aSelector->mIDList && !aSelector->mAttrList && @@ -3792,7 +3790,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; @@ -3863,7 +3862,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; @@ -4438,11 +4437,11 @@ CSSRuleProcessor::GetRuleCascade(nsIPresContext* aPresContext, nsIAtom* aMedium) } if (mSheets) { - nsCompatibility quirkMode = eCompatibility_Standard; + nsCompatibility quirkMode; aPresContext->GetCompatibilityMode(&quirkMode); cascade = new RuleCascadeData(aMedium, - eCompatibility_Standard != quirkMode); + eCompatibility_NavQuirks == quirkMode); if (cascade) { *cascadep = cascade; diff --git a/mozilla/layout/style/nsHTMLStyleSheet.cpp b/mozilla/layout/style/nsHTMLStyleSheet.cpp index 63dc49afbb3..68b139e0a32 100644 --- a/mozilla/layout/style/nsHTMLStyleSheet.cpp +++ b/mozilla/layout/style/nsHTMLStyleSheet.cpp @@ -1134,7 +1134,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/layout/style/nsICSSLoader.h b/mozilla/layout/style/nsICSSLoader.h index a2bbaf483da..8573bf20b08 100644 --- a/mozilla/layout/style/nsICSSLoader.h +++ b/mozilla/layout/style/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/layout/style/nsIStyleRuleProcessor.h b/mozilla/layout/style/nsIStyleRuleProcessor.h index 7ecf44173ea..35676c99358 100644 --- a/mozilla/layout/style/nsIStyleRuleProcessor.h +++ b/mozilla/layout/style/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/layout/style/nsStyleStruct.cpp b/mozilla/layout/style/nsStyleStruct.cpp index 02e88bf9af6..53c01b71e2f 100644 --- a/mozilla/layout/style/nsStyleStruct.cpp +++ b/mozilla/layout/style/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/layout/tables/nsTableCellFrame.cpp b/mozilla/layout/tables/nsTableCellFrame.cpp index d1656d71452..34dda964c04 100644 --- a/mozilla/layout/tables/nsTableCellFrame.cpp +++ b/mozilla/layout/tables/nsTableCellFrame.cpp @@ -1016,7 +1016,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/tables/nsTableFrame.cpp b/mozilla/layout/tables/nsTableFrame.cpp index 29b4c9bfbb0..9f809fd74da 100644 --- a/mozilla/layout/tables/nsTableFrame.cpp +++ b/mozilla/layout/tables/nsTableFrame.cpp @@ -2844,7 +2844,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/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 ad1c60f7cbf..7923c915cda 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 7d577e7d3e7..48329fe5421 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: @@ -1994,7 +1995,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 @@ -2343,23 +2346,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 a37cfb81b4e..432ba13d283 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 adfcdf99a7d..317c87eeced 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 54e118d1e50..651568c3e28 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("