Bug 1842999 - Part 25: Support testing elements are present in resizable typed arrays...
[gecko.git] / parser / htmlparser / CParserContext.cpp
blobd57c9855cccbde9d28d4c34ceccc1c5a688fb14d
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/. */
7 #include "nsAtom.h"
8 #include "CParserContext.h"
9 #include "prenv.h"
10 #include "nsIHTMLContentSink.h"
11 #include "nsMimeTypes.h"
13 CParserContext::CParserContext(nsIURI* aURI, eParserCommands aCommand)
14 : mScanner(aURI),
15 mDTDMode(eDTDMode_autodetect),
16 mDocType(eUnknown),
17 mStreamListenerState(eNone),
18 mContextType(eCTURL),
19 mParserCommand(aCommand),
20 mMultipart(true),
21 mCopyUnused(false) {
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),
30 mDocType(eXML),
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);
47 mDocType = eUnknown;
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))
59 mDocType = eXML;