Make SetInnerHTML use the right parser mode (ie strict for strict

documents instead of always quirks).  Bug 106565, r=harishd, sr=jst
This commit is contained in:
bzbarsky%mit.edu 2001-11-16 04:48:30 +00:00
Родитель 4f54b05b1a
Коммит 72df08441d
3 изменённых файлов: 25 добавлений и 5 удалений

Просмотреть файл

@ -64,6 +64,7 @@
#include "nsScriptSecurityManager.h"
#include "nsIScriptGlobalObject.h"
#include "nsIScriptContext.h"
#include "nsIHTMLDocument.h"
#include "nsIJSContextStack.h"
// XXX Temporary inclusion to deal with fragment parsing
@ -2372,9 +2373,16 @@ nsRange::CreateContextualFragment(const nsAReadableString& aFragment,
}
}
nsDTDMode mode = eDTDMode_autodetect;
nsCOMPtr<nsIDOMDocument> ownerDoc;
mStartParent->GetOwnerDocument(getter_AddRefs(ownerDoc));
nsCOMPtr<nsIHTMLDocument> htmlDoc(do_QueryInterface(ownerDoc));
if (htmlDoc) {
htmlDoc->GetDTDMode(mode);
}
result = parser->ParseFragment(aFragment, (void*)0,
tagStack,
0, contentType);
0, contentType, mode);
if (ContextStack) {
JSContext *notused;

Просмотреть файл

@ -1358,7 +1358,10 @@ nsresult nsParser::WillBuildModel(nsString& aFilename){
// XXXVidur Make a copy and only check in the first 1k
mParserContext->mScanner->Peek(theBuffer, 1024);
DetermineParseMode(theBuffer,mParserContext->mDTDMode,mParserContext->mDocType,mParserContext->mMimeType);
if (eDTDMode_unknown == mParserContext->mDTDMode ||
eDTDMode_autodetect == mParserContext->mDTDMode) {
DetermineParseMode(theBuffer,mParserContext->mDTDMode,mParserContext->mDocType,mParserContext->mMimeType);
}
if(PR_TRUE==FindSuitableDTD(*mParserContext,theBuffer)) {
mParserContext->mDTD->WillBuildModel( *mParserContext,mSink);
@ -1597,6 +1600,7 @@ nsresult nsParser::Parse(nsIURI* aURL,nsIRequestObserver* aListener,PRBool aVeri
if(pc && theScanner) {
pc->mMultipart=PR_TRUE;
pc->mContextType=CParserContext::eCTURL;
pc->mDTDMode=aMode;
PushContext(*pc);
result=NS_OK;
}
@ -1632,6 +1636,7 @@ nsresult nsParser::Parse(nsIInputStream& aStream,const nsAReadableString& aMimeT
pc->mStreamListenerState=eOnStart;
pc->mMultipart=PR_FALSE;
pc->mContextType=CParserContext::eCTStream;
pc->mDTDMode=aMode;
mParserContext->mScanner->Eof();
result=ResumeParse();
pc=PopContext();
@ -1721,6 +1726,7 @@ nsresult nsParser::Parse(const nsAReadableString& aSourceBuffer, void* aKey,
pc->mContextType=CParserContext::eCTString;
pc->SetMimeType(aMimeType);
pc->mDTDMode=aMode;
mUnusedInput.Truncate(0);
//printf("Parse(string) iterate: %i",PR_FALSE);
@ -1779,7 +1785,7 @@ nsresult nsParser::ParseFragment(const nsAReadableString& aSourceBuffer,
//now it's time to try to build the model from this fragment
mObserversEnabled = PR_FALSE; //disable observers for fragments
result = Parse(theContext + aSourceBuffer,(void*)&theContext,aMimeType,PR_FALSE,PR_TRUE);
result = Parse(theContext + aSourceBuffer,(void*)&theContext,aMimeType,PR_FALSE,PR_TRUE, aMode);
mObserversEnabled = PR_TRUE; //now reenable.
return result;

Просмотреть файл

@ -1358,7 +1358,10 @@ nsresult nsParser::WillBuildModel(nsString& aFilename){
// XXXVidur Make a copy and only check in the first 1k
mParserContext->mScanner->Peek(theBuffer, 1024);
DetermineParseMode(theBuffer,mParserContext->mDTDMode,mParserContext->mDocType,mParserContext->mMimeType);
if (eDTDMode_unknown == mParserContext->mDTDMode ||
eDTDMode_autodetect == mParserContext->mDTDMode) {
DetermineParseMode(theBuffer,mParserContext->mDTDMode,mParserContext->mDocType,mParserContext->mMimeType);
}
if(PR_TRUE==FindSuitableDTD(*mParserContext,theBuffer)) {
mParserContext->mDTD->WillBuildModel( *mParserContext,mSink);
@ -1597,6 +1600,7 @@ nsresult nsParser::Parse(nsIURI* aURL,nsIRequestObserver* aListener,PRBool aVeri
if(pc && theScanner) {
pc->mMultipart=PR_TRUE;
pc->mContextType=CParserContext::eCTURL;
pc->mDTDMode=aMode;
PushContext(*pc);
result=NS_OK;
}
@ -1632,6 +1636,7 @@ nsresult nsParser::Parse(nsIInputStream& aStream,const nsAReadableString& aMimeT
pc->mStreamListenerState=eOnStart;
pc->mMultipart=PR_FALSE;
pc->mContextType=CParserContext::eCTStream;
pc->mDTDMode=aMode;
mParserContext->mScanner->Eof();
result=ResumeParse();
pc=PopContext();
@ -1721,6 +1726,7 @@ nsresult nsParser::Parse(const nsAReadableString& aSourceBuffer, void* aKey,
pc->mContextType=CParserContext::eCTString;
pc->SetMimeType(aMimeType);
pc->mDTDMode=aMode;
mUnusedInput.Truncate(0);
//printf("Parse(string) iterate: %i",PR_FALSE);
@ -1779,7 +1785,7 @@ nsresult nsParser::ParseFragment(const nsAReadableString& aSourceBuffer,
//now it's time to try to build the model from this fragment
mObserversEnabled = PR_FALSE; //disable observers for fragments
result = Parse(theContext + aSourceBuffer,(void*)&theContext,aMimeType,PR_FALSE,PR_TRUE);
result = Parse(theContext + aSourceBuffer,(void*)&theContext,aMimeType,PR_FALSE,PR_TRUE, aMode);
mObserversEnabled = PR_TRUE; //now reenable.
return result;