Bug 80142 (among others) - landing of SVG_20010721_BRANCH. Work by
alex.fritze@crocodile-clips.com, james.turner@crocodile-clips.com, and everyone else how helped on the branch. Thanks to peterv for last minute build changes r=cls for build changes r=jst, rs=brendan for #ifdef'd parts touching existing files. NOT ON BY DEFAULT git-svn-id: svn://10.0.0.236/trunk@110384 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
@@ -373,7 +373,7 @@ const PRUnichar kNullCh = '\0';
|
||||
#define kApplicationJSContentType "application/x-javascript"
|
||||
#define kTextJSContentType "text/javascript"
|
||||
#define kSGMLTextContentType "text/sgml"
|
||||
|
||||
#define kSVGTextContentType "image/svg+xml"
|
||||
|
||||
#define NS_IPARSER_FLAG_UNKNOWN_MODE 0x00000000
|
||||
#define NS_IPARSER_FLAG_QUIRKS_MODE 0x00000002
|
||||
|
||||
@@ -929,29 +929,53 @@ int Tokenizer_HandleExternalEntityRef(XML_Parser parser,
|
||||
// Load the external entity into a buffer
|
||||
nsCOMPtr<nsIInputStream> in;
|
||||
nsAutoString absURL;
|
||||
nsresult rv = NS_OK;
|
||||
PRUnichar *uniBuf = nsnull;
|
||||
PRUint32 retLen = 0;
|
||||
|
||||
#ifdef MOZ_SVG
|
||||
// yuck. I don't know of any other way to do this, though, since we don't
|
||||
// read external dtd's, and we need the #FIXED xmlns attribute, so we
|
||||
// can't do this later based on what namespace we're in - bbaetz
|
||||
|
||||
nsresult rv = nsExpatTokenizer::OpenInputStream(systemId, base, getter_AddRefs(in), &absURL);
|
||||
// The alternative is remapping the systemId, and installing an svg.dtd file
|
||||
// in the dtd directory. This is simpler, for now.
|
||||
|
||||
// XXX - need to do this for the other #FIXED attribuues as well
|
||||
NS_NAMED_LITERAL_STRING(svgDtd,
|
||||
"<!ATTLIST svg xmlns CDATA #FIXED \"http://www.w3.org/2000/svg\" >");
|
||||
|
||||
#define svgPublicIdPrefix "-//W3C//DTD SVG "
|
||||
|
||||
if (publicId && !nsCRT::strncmp((const PRUnichar*)publicId,
|
||||
NS_LITERAL_STRING(svgPublicIdPrefix).get(),
|
||||
sizeof(svgPublicIdPrefix)-1)) {
|
||||
uniBuf = ToNewUnicode(svgDtd);
|
||||
retLen = svgDtd.Length();
|
||||
} else {
|
||||
#endif
|
||||
rv = nsExpatTokenizer::OpenInputStream(systemId, base, getter_AddRefs(in), &absURL);
|
||||
|
||||
if (NS_SUCCEEDED(rv) && in)
|
||||
rv = nsExpatTokenizer::LoadStream(in, uniBuf, retLen);
|
||||
#ifdef MOZ_SVG
|
||||
}
|
||||
#endif
|
||||
|
||||
if (NS_SUCCEEDED(rv) && in) {
|
||||
PRUint32 retLen = 0;
|
||||
PRUnichar *uniBuf = nsnull;
|
||||
rv = nsExpatTokenizer::LoadStream(in, uniBuf, retLen);
|
||||
// Pass the buffer to expat for parsing
|
||||
if (NS_SUCCEEDED(rv) && uniBuf) {
|
||||
// Create a parser for parsing the external entity
|
||||
XML_Parser entParser = XML_ExternalEntityParserCreate(parser, 0,
|
||||
(const XML_Char*) NS_LITERAL_STRING("UTF-16").get());
|
||||
|
||||
// Pass the buffer to expat for parsing
|
||||
if (NS_SUCCEEDED(rv) && uniBuf) {
|
||||
// Create a parser for parsing the external entity
|
||||
XML_Parser entParser = XML_ExternalEntityParserCreate(parser, 0,
|
||||
(const XML_Char*) NS_LITERAL_STRING("UTF-16").get());
|
||||
|
||||
if (entParser) {
|
||||
XML_SetBase(entParser, (const XML_Char*) absURL.get());
|
||||
result = XML_Parse(entParser, (char *)uniBuf, retLen * sizeof(PRUnichar), 1);
|
||||
XML_ParserFree(entParser);
|
||||
}
|
||||
|
||||
PR_FREEIF(uniBuf);
|
||||
if (entParser) {
|
||||
XML_SetBase(entParser, (const XML_Char*) absURL.get());
|
||||
result = XML_Parse(entParser, (char *)uniBuf, retLen * sizeof(PRUnichar), 1);
|
||||
XML_ParserFree(entParser);
|
||||
}
|
||||
}
|
||||
PR_FREEIF(uniBuf);
|
||||
|
||||
#else /* ! XML_DTD */
|
||||
|
||||
NS_NOTYETIMPLEMENTED("Error: Tokenizer_HandleExternalEntityRef() not yet implemented.");
|
||||
|
||||
@@ -431,6 +431,9 @@ CViewSourceHTML::CanParse(CParserContext& aParserContext,
|
||||
aParserContext.mMimeType.EqualsWithConversion(kRDFTextContentType) ||
|
||||
aParserContext.mMimeType.EqualsWithConversion(kHTMLTextContentType) ||
|
||||
aParserContext.mMimeType.EqualsWithConversion(kXULTextContentType) ||
|
||||
#ifdef MOZ_SVG
|
||||
aParserContext.mMimeType.Equals(NS_LITERAL_STRING(kSVGTextContentType)) ||
|
||||
#endif
|
||||
aParserContext.mMimeType.EqualsWithConversion(kSGMLTextContentType)) {
|
||||
result=ePrimaryDetect;
|
||||
}
|
||||
|
||||
@@ -198,7 +198,11 @@ CWellFormedDTD::CanParse(CParserContext& aParserContext,
|
||||
aParserContext.mMimeType.EqualsWithConversion(kXMLApplicationContentType) ||
|
||||
aParserContext.mMimeType.EqualsWithConversion(kXHTMLApplicationContentType) ||
|
||||
aParserContext.mMimeType.EqualsWithConversion(kRDFTextContentType) ||
|
||||
aParserContext.mMimeType.EqualsWithConversion(kXULTextContentType)) {
|
||||
aParserContext.mMimeType.EqualsWithConversion(kXULTextContentType)
|
||||
#ifdef MOZ_SVG
|
||||
|| aParserContext.mMimeType.Equals(NS_LITERAL_STRING(kSVGTextContentType))
|
||||
#endif
|
||||
) {
|
||||
result=ePrimaryDetect;
|
||||
}
|
||||
else if (aParserContext.mMimeType.IsEmpty()) {
|
||||
|
||||
Reference in New Issue
Block a user