diff --git a/mozilla/content/html/document/src/nsHTMLContentSink.cpp b/mozilla/content/html/document/src/nsHTMLContentSink.cpp index cdd4125c0cb..970ef1ea411 100644 --- a/mozilla/content/html/document/src/nsHTMLContentSink.cpp +++ b/mozilla/content/html/document/src/nsHTMLContentSink.cpp @@ -2314,8 +2314,9 @@ HTMLContentSink::AddDocTypeDecl(const nsIParserNode& aNode, PRInt32 aMode) { nsresult rv = NS_OK; NS_START_STOPWATCH(mWatch) - // Implementation of AddDocTypeDecl() should start here - + + rv=mHTMLDocument->AddDocTypeDecl(aNode.GetText(),(nsDTDMode)aMode); + NS_STOP_STOPWATCH(mWatch) return rv; } diff --git a/mozilla/content/html/document/src/nsHTMLDocument.cpp b/mozilla/content/html/document/src/nsHTMLDocument.cpp index 564aae69aa8..f1775a20b44 100644 --- a/mozilla/content/html/document/src/nsHTMLDocument.cpp +++ b/mozilla/content/html/document/src/nsHTMLDocument.cpp @@ -166,6 +166,7 @@ nsHTMLDocument::nsHTMLDocument() nsHTMLAtoms::AddRefAtoms(); mDTDMode = eDTDMode_Nav; mCSSLoader = nsnull; + mDocTypeStr=nsnull; // Find/Search Init mSearchStr = nsnull; @@ -224,6 +225,10 @@ nsHTMLDocument::~nsHTMLDocument() mCSSLoader->DropDocumentReference(); // release weak ref NS_RELEASE(mCSSLoader); } + if (nsnull != mDocTypeStr) { + delete mDocTypeStr; + mDocTypeStr = nsnull; + } // XXX don't bother doing this until the dll is unloaded??? // nsHTMLAtoms::ReleaseAtoms(); @@ -882,9 +887,49 @@ nsHTMLDocument::SetDTDMode(nsDTDMode aMode) if (mCSSLoader) { mCSSLoader->SetQuirkMode(PRBool(eDTDMode_NoQuirks != mDTDMode)); } + + nsIPresShell* shell = (nsIPresShell*) mPresShells.ElementAt(0); + if (nsnull != shell) { + nsCOMPtr pc; + shell->GetPresContext(getter_AddRefs(pc)); + if (pc) { + pc->SetCompatibilityMode(((eDTDMode_NoQuirks == mDTDMode) ? + eCompatibility_Standard : + eCompatibility_NavQuirks)); + } + } + return NS_OK; } +NS_IMETHODIMP +nsHTMLDocument::GetDocTypeStr(nsString& aDocTypeString) +{ + if(mDocTypeStr) aDocTypeString = *mDocTypeStr; + return NS_OK; +} + +NS_IMETHODIMP +nsHTMLDocument::AddDocTypeDecl(const nsString& aDocTypeString, nsDTDMode aMode) +{ + nsresult result=NS_OK; + + result=SetDTDMode(aMode); + if(result==NS_OK) { + if (mDocTypeStr == nsnull) { + if(aDocTypeString.Length()>0) { + mDocTypeStr = new nsString(aDocTypeString); + if (mDocTypeStr==nsnull) result=NS_ERROR_OUT_OF_MEMORY; + } + } + else { + mDocTypeStr->SetLength(0); + mDocTypeStr->Append(aDocTypeString); + } + } + return result; +} + NS_IMETHODIMP nsHTMLDocument::SetHeaderData(nsIAtom* aHeaderField, const nsString& aData) { diff --git a/mozilla/content/html/document/src/nsHTMLDocument.h b/mozilla/content/html/document/src/nsHTMLDocument.h index 05782f9d555..2a79762fde6 100644 --- a/mozilla/content/html/document/src/nsHTMLDocument.h +++ b/mozilla/content/html/document/src/nsHTMLDocument.h @@ -92,6 +92,9 @@ public: NS_IMETHOD GetDTDMode(nsDTDMode& aMode); NS_IMETHOD SetDTDMode(nsDTDMode aMode); + NS_IMETHOD GetDocTypeStr(nsString& aDocTypeString); + NS_IMETHOD AddDocTypeDecl(const nsString& aDocTypeString, nsDTDMode aMode); + NS_IMETHOD SetHeaderData(nsIAtom* aHeaderField, const nsString& aData); NS_IMETHOD ContentAppended(nsIContent* aContainer, @@ -210,6 +213,7 @@ protected: nsDTDMode mDTDMode; nsVoidArray mImageMaps; nsICSSLoader* mCSSLoader; + nsString* mDocTypeStr; nsContentList *mImages; nsContentList *mApplets; diff --git a/mozilla/content/html/document/src/nsIHTMLDocument.h b/mozilla/content/html/document/src/nsIHTMLDocument.h index fc85a47542f..af42d45ce20 100644 --- a/mozilla/content/html/document/src/nsIHTMLDocument.h +++ b/mozilla/content/html/document/src/nsIHTMLDocument.h @@ -33,9 +33,14 @@ class nsICSSLoader; {0xb2a848b0, 0xd0a9, 0x11d1, {0x89, 0xb1, 0x00, 0x60, 0x08, 0x91, 0x1b, 0x81}} enum nsDTDMode { - eDTDMode_NoQuirks = 0, - eDTDMode_Nav = 1, - eDTDMode_Other = 2 + + eDTDMode_Unknown =0, + eDTDMode_Raptor =1, //5.0 version of nav. and greater + eDTDMode_Nav =2, //pre 5.0 versions + eDTDMode_NoQuirks =3, //pre 5.0 without quirks (as best as we can...) + eDTDMode_Other =4, + eDTDMode_Autodetect =5 + }; /** @@ -71,6 +76,9 @@ public: NS_IMETHOD GetDTDMode(nsDTDMode& aMode) = 0; NS_IMETHOD SetDTDMode(nsDTDMode aMode) = 0; + NS_IMETHOD GetDocTypeStr(nsString& aDocTypeString)=0; + NS_IMETHOD AddDocTypeDecl(const nsString& aDocTypeString, nsDTDMode aMode)=0; + }; #endif /* nsIHTMLDocument_h___ */ diff --git a/mozilla/layout/html/document/src/nsHTMLContentSink.cpp b/mozilla/layout/html/document/src/nsHTMLContentSink.cpp index cdd4125c0cb..970ef1ea411 100644 --- a/mozilla/layout/html/document/src/nsHTMLContentSink.cpp +++ b/mozilla/layout/html/document/src/nsHTMLContentSink.cpp @@ -2314,8 +2314,9 @@ HTMLContentSink::AddDocTypeDecl(const nsIParserNode& aNode, PRInt32 aMode) { nsresult rv = NS_OK; NS_START_STOPWATCH(mWatch) - // Implementation of AddDocTypeDecl() should start here - + + rv=mHTMLDocument->AddDocTypeDecl(aNode.GetText(),(nsDTDMode)aMode); + NS_STOP_STOPWATCH(mWatch) return rv; } diff --git a/mozilla/layout/html/document/src/nsHTMLDocument.cpp b/mozilla/layout/html/document/src/nsHTMLDocument.cpp index 564aae69aa8..f1775a20b44 100644 --- a/mozilla/layout/html/document/src/nsHTMLDocument.cpp +++ b/mozilla/layout/html/document/src/nsHTMLDocument.cpp @@ -166,6 +166,7 @@ nsHTMLDocument::nsHTMLDocument() nsHTMLAtoms::AddRefAtoms(); mDTDMode = eDTDMode_Nav; mCSSLoader = nsnull; + mDocTypeStr=nsnull; // Find/Search Init mSearchStr = nsnull; @@ -224,6 +225,10 @@ nsHTMLDocument::~nsHTMLDocument() mCSSLoader->DropDocumentReference(); // release weak ref NS_RELEASE(mCSSLoader); } + if (nsnull != mDocTypeStr) { + delete mDocTypeStr; + mDocTypeStr = nsnull; + } // XXX don't bother doing this until the dll is unloaded??? // nsHTMLAtoms::ReleaseAtoms(); @@ -882,9 +887,49 @@ nsHTMLDocument::SetDTDMode(nsDTDMode aMode) if (mCSSLoader) { mCSSLoader->SetQuirkMode(PRBool(eDTDMode_NoQuirks != mDTDMode)); } + + nsIPresShell* shell = (nsIPresShell*) mPresShells.ElementAt(0); + if (nsnull != shell) { + nsCOMPtr pc; + shell->GetPresContext(getter_AddRefs(pc)); + if (pc) { + pc->SetCompatibilityMode(((eDTDMode_NoQuirks == mDTDMode) ? + eCompatibility_Standard : + eCompatibility_NavQuirks)); + } + } + return NS_OK; } +NS_IMETHODIMP +nsHTMLDocument::GetDocTypeStr(nsString& aDocTypeString) +{ + if(mDocTypeStr) aDocTypeString = *mDocTypeStr; + return NS_OK; +} + +NS_IMETHODIMP +nsHTMLDocument::AddDocTypeDecl(const nsString& aDocTypeString, nsDTDMode aMode) +{ + nsresult result=NS_OK; + + result=SetDTDMode(aMode); + if(result==NS_OK) { + if (mDocTypeStr == nsnull) { + if(aDocTypeString.Length()>0) { + mDocTypeStr = new nsString(aDocTypeString); + if (mDocTypeStr==nsnull) result=NS_ERROR_OUT_OF_MEMORY; + } + } + else { + mDocTypeStr->SetLength(0); + mDocTypeStr->Append(aDocTypeString); + } + } + return result; +} + NS_IMETHODIMP nsHTMLDocument::SetHeaderData(nsIAtom* aHeaderField, const nsString& aData) { diff --git a/mozilla/layout/html/document/src/nsHTMLDocument.h b/mozilla/layout/html/document/src/nsHTMLDocument.h index 05782f9d555..2a79762fde6 100644 --- a/mozilla/layout/html/document/src/nsHTMLDocument.h +++ b/mozilla/layout/html/document/src/nsHTMLDocument.h @@ -92,6 +92,9 @@ public: NS_IMETHOD GetDTDMode(nsDTDMode& aMode); NS_IMETHOD SetDTDMode(nsDTDMode aMode); + NS_IMETHOD GetDocTypeStr(nsString& aDocTypeString); + NS_IMETHOD AddDocTypeDecl(const nsString& aDocTypeString, nsDTDMode aMode); + NS_IMETHOD SetHeaderData(nsIAtom* aHeaderField, const nsString& aData); NS_IMETHOD ContentAppended(nsIContent* aContainer, @@ -210,6 +213,7 @@ protected: nsDTDMode mDTDMode; nsVoidArray mImageMaps; nsICSSLoader* mCSSLoader; + nsString* mDocTypeStr; nsContentList *mImages; nsContentList *mApplets; diff --git a/mozilla/layout/html/document/src/nsIHTMLDocument.h b/mozilla/layout/html/document/src/nsIHTMLDocument.h index fc85a47542f..af42d45ce20 100644 --- a/mozilla/layout/html/document/src/nsIHTMLDocument.h +++ b/mozilla/layout/html/document/src/nsIHTMLDocument.h @@ -33,9 +33,14 @@ class nsICSSLoader; {0xb2a848b0, 0xd0a9, 0x11d1, {0x89, 0xb1, 0x00, 0x60, 0x08, 0x91, 0x1b, 0x81}} enum nsDTDMode { - eDTDMode_NoQuirks = 0, - eDTDMode_Nav = 1, - eDTDMode_Other = 2 + + eDTDMode_Unknown =0, + eDTDMode_Raptor =1, //5.0 version of nav. and greater + eDTDMode_Nav =2, //pre 5.0 versions + eDTDMode_NoQuirks =3, //pre 5.0 without quirks (as best as we can...) + eDTDMode_Other =4, + eDTDMode_Autodetect =5 + }; /** @@ -71,6 +76,9 @@ public: NS_IMETHOD GetDTDMode(nsDTDMode& aMode) = 0; NS_IMETHOD SetDTDMode(nsDTDMode aMode) = 0; + NS_IMETHOD GetDocTypeStr(nsString& aDocTypeString)=0; + NS_IMETHOD AddDocTypeDecl(const nsString& aDocTypeString, nsDTDMode aMode)=0; + }; #endif /* nsIHTMLDocument_h___ */