Added support for setting DOCTYPE and DTD mode.

git-svn-id: svn://10.0.0.236/trunk@47597 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
harishd%netscape.com
1999-09-15 17:57:16 +00:00
parent 89f665e0c5
commit ba9cc1acb4
8 changed files with 126 additions and 10 deletions

View File

@@ -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<nsIPresContext> 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)
{