summaryrefslogtreecommitdiff
path: root/parser/htmlparser/CParserContext.cpp
diff options
context:
space:
mode:
authorMatt A. Tobin <mattatobin@localhost.localdomain>2018-02-02 04:16:08 -0500
committerMatt A. Tobin <mattatobin@localhost.localdomain>2018-02-02 04:16:08 -0500
commit5f8de423f190bbb79a62f804151bc24824fa32d8 (patch)
tree10027f336435511475e392454359edea8e25895d /parser/htmlparser/CParserContext.cpp
parent49ee0794b5d912db1f95dce6eb52d781dc210db5 (diff)
downloaduxp-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.gz
Add m-esr52 at 52.6.0
Diffstat (limited to 'parser/htmlparser/CParserContext.cpp')
-rw-r--r--parser/htmlparser/CParserContext.cpp86
1 files changed, 86 insertions, 0 deletions
diff --git a/parser/htmlparser/CParserContext.cpp b/parser/htmlparser/CParserContext.cpp
new file mode 100644
index 0000000000..f78878a874
--- /dev/null
+++ b/parser/htmlparser/CParserContext.cpp
@@ -0,0 +1,86 @@
+/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
+/* vim: set ts=2 sw=2 et tw=80: */
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+
+
+#include "nsIAtom.h"
+#include "CParserContext.h"
+#include "nsToken.h"
+#include "prenv.h"
+#include "nsIHTMLContentSink.h"
+#include "nsHTMLTokenizer.h"
+#include "nsMimeTypes.h"
+#include "nsHTMLTokenizer.h"
+
+CParserContext::CParserContext(CParserContext* aPrevContext,
+ nsScanner* aScanner,
+ void *aKey,
+ eParserCommands aCommand,
+ nsIRequestObserver* aListener,
+ eAutoDetectResult aStatus,
+ bool aCopyUnused)
+ : mListener(aListener),
+ mKey(aKey),
+ mPrevContext(aPrevContext),
+ mScanner(aScanner),
+ mDTDMode(eDTDMode_unknown),
+ mStreamListenerState(eNone),
+ mContextType(eCTNone),
+ mAutoDetectStatus(aStatus),
+ mParserCommand(aCommand),
+ mMultipart(true),
+ mCopyUnused(aCopyUnused)
+{
+ MOZ_COUNT_CTOR(CParserContext);
+}
+
+CParserContext::~CParserContext()
+{
+ // It's ok to simply ingore the PrevContext.
+ MOZ_COUNT_DTOR(CParserContext);
+}
+
+void
+CParserContext::SetMimeType(const nsACString& aMimeType)
+{
+ mMimeType.Assign(aMimeType);
+
+ mDocType = ePlainText;
+
+ if (mMimeType.EqualsLiteral(TEXT_HTML))
+ mDocType = eHTML_Strict;
+ else if (mMimeType.EqualsLiteral(TEXT_XML) ||
+ mMimeType.EqualsLiteral(APPLICATION_XML) ||
+ mMimeType.EqualsLiteral(APPLICATION_XHTML_XML) ||
+ mMimeType.EqualsLiteral(TEXT_XUL) ||
+ mMimeType.EqualsLiteral(IMAGE_SVG_XML) ||
+ mMimeType.EqualsLiteral(APPLICATION_MATHML_XML) ||
+ mMimeType.EqualsLiteral(APPLICATION_RDF_XML) ||
+ mMimeType.EqualsLiteral(APPLICATION_WAPXHTML_XML) ||
+ mMimeType.EqualsLiteral(TEXT_RDF))
+ mDocType = eXML;
+}
+
+nsresult
+CParserContext::GetTokenizer(nsIDTD* aDTD,
+ nsIContentSink* aSink,
+ nsITokenizer*& aTokenizer)
+{
+ nsresult result = NS_OK;
+ int32_t type = aDTD ? aDTD->GetType() : NS_IPARSER_FLAG_HTML;
+
+ if (!mTokenizer) {
+ if (type == NS_IPARSER_FLAG_HTML || mParserCommand == eViewSource) {
+ mTokenizer = new nsHTMLTokenizer;
+ }
+ else if (type == NS_IPARSER_FLAG_XML) {
+ mTokenizer = do_QueryInterface(aDTD, &result);
+ }
+ }
+
+ aTokenizer = mTokenizer;
+
+ return result;
+}