1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* vim: set ts=2 sw=2 et tw=80: */
3 /* This Source Code Form is subject to the terms of the Mozilla Public
4 * License, v. 2.0. If a copy of the MPL was not distributed with this
5 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
8 #include "CParserContext.h"
10 #include "nsIHTMLContentSink.h"
11 #include "nsMimeTypes.h"
13 CParserContext::CParserContext(nsIURI
* aURI
, eParserCommands aCommand
)
15 mDTDMode(eDTDMode_autodetect
),
17 mStreamListenerState(eNone
),
19 mParserCommand(aCommand
),
22 MOZ_COUNT_CTOR(CParserContext
);
25 CParserContext::CParserContext(const nsAString
& aBuffer
,
26 eParserCommands aCommand
, bool aLastBuffer
)
27 : mScanner(aBuffer
, !aLastBuffer
),
28 mMimeType("application/xml"_ns
),
29 mDTDMode(eDTDMode_full_standards
),
31 mStreamListenerState(aLastBuffer
? eOnStop
: eOnDataAvail
),
32 mContextType(eCTString
),
33 mParserCommand(aCommand
),
34 mMultipart(!aLastBuffer
),
35 mCopyUnused(aLastBuffer
) {
36 MOZ_COUNT_CTOR(CParserContext
);
39 CParserContext::~CParserContext() {
40 // It's ok to simply ingore the PrevContext.
41 MOZ_COUNT_DTOR(CParserContext
);
44 void CParserContext::SetMimeType(const nsACString
& aMimeType
) {
45 mMimeType
.Assign(aMimeType
);
49 if (mMimeType
.EqualsLiteral(TEXT_HTML
))
50 mDocType
= eHTML_Strict
;
51 else if (mMimeType
.EqualsLiteral(TEXT_XML
) ||
52 mMimeType
.EqualsLiteral(APPLICATION_XML
) ||
53 mMimeType
.EqualsLiteral(APPLICATION_XHTML_XML
) ||
54 mMimeType
.EqualsLiteral(IMAGE_SVG_XML
) ||
55 mMimeType
.EqualsLiteral(APPLICATION_MATHML_XML
) ||
56 mMimeType
.EqualsLiteral(APPLICATION_RDF_XML
) ||
57 mMimeType
.EqualsLiteral(APPLICATION_WAPXHTML_XML
) ||
58 mMimeType
.EqualsLiteral(TEXT_RDF
))