mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-08 02:14:43 +00:00
Bug 1749935 - Remove nsITokenizer. r=hsivonen
Differential Revision: https://phabricator.services.mozilla.com/D135887
This commit is contained in:
parent
d023f9c301
commit
6c6f7200a6
@ -10,7 +10,6 @@
|
||||
#include "nsIParser.h"
|
||||
#include "nsDeque.h"
|
||||
#include "nsParserCIID.h"
|
||||
#include "nsITokenizer.h"
|
||||
#include "nsIContentSink.h"
|
||||
#include "nsIRequest.h"
|
||||
#include "nsIChannel.h"
|
||||
|
@ -8,9 +8,7 @@
|
||||
#include "CParserContext.h"
|
||||
#include "prenv.h"
|
||||
#include "nsIHTMLContentSink.h"
|
||||
#include "nsHTMLTokenizer.h"
|
||||
#include "nsMimeTypes.h"
|
||||
#include "nsHTMLTokenizer.h"
|
||||
|
||||
CParserContext::CParserContext(nsIURI* aURI, eParserCommands aCommand)
|
||||
: mScanner(aURI),
|
||||
@ -60,21 +58,3 @@ void CParserContext::SetMimeType(const nsACString& aMimeType) {
|
||||
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;
|
||||
}
|
||||
|
@ -37,14 +37,11 @@ class CParserContext {
|
||||
|
||||
~CParserContext();
|
||||
|
||||
nsresult GetTokenizer(nsIDTD* aDTD, nsIContentSink* aSink,
|
||||
nsITokenizer*& aTokenizer);
|
||||
void SetMimeType(const nsACString& aMimeType);
|
||||
|
||||
nsCOMPtr<nsIRequest>
|
||||
mRequest; // provided by necko to differnciate different input streams
|
||||
// why is mRequest strongly referenced? see bug 102376.
|
||||
nsCOMPtr<nsITokenizer> mTokenizer;
|
||||
nsScanner mScanner;
|
||||
|
||||
nsCString mMimeType;
|
||||
|
@ -25,7 +25,6 @@ EXPORTS += [
|
||||
"nsIFragmentContentSink.h",
|
||||
"nsIHTMLContentSink.h",
|
||||
"nsIParser.h",
|
||||
"nsITokenizer.h",
|
||||
"nsParserBase.h",
|
||||
"nsParserCIID.h",
|
||||
"nsParserConstants.h",
|
||||
@ -39,7 +38,6 @@ UNIFIED_SOURCES += [
|
||||
"nsElementTable.cpp",
|
||||
"nsExpatDriver.cpp",
|
||||
"nsHTMLTags.cpp",
|
||||
"nsHTMLTokenizer.cpp",
|
||||
"nsParser.cpp",
|
||||
"nsParserModule.cpp",
|
||||
"nsParserMsgUtils.cpp",
|
||||
|
@ -351,9 +351,8 @@ static void GetLocalDTDURI(const nsCatalogData* aCatalogData, nsIURI* aDTD,
|
||||
/***************************** END CATALOG UTILS *****************************/
|
||||
|
||||
NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(nsExpatDriver)
|
||||
NS_INTERFACE_MAP_ENTRY(nsITokenizer)
|
||||
NS_INTERFACE_MAP_ENTRY(nsIDTD)
|
||||
NS_INTERFACE_MAP_ENTRY_AMBIGUOUS(nsISupports, nsIDTD)
|
||||
NS_INTERFACE_MAP_ENTRY(nsISupports)
|
||||
NS_INTERFACE_MAP_END
|
||||
|
||||
NS_IMPL_CYCLE_COLLECTING_ADDREF(nsExpatDriver)
|
||||
@ -1226,8 +1225,7 @@ void nsExpatDriver::ParseBuffer(const char16_t* aBuffer, uint32_t aLength,
|
||||
}
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsExpatDriver::ConsumeToken(nsScanner& aScanner, bool aIsFinalChunk) {
|
||||
nsresult nsExpatDriver::ResumeParse(nsScanner& aScanner, bool aIsFinalChunk) {
|
||||
// We keep the scanner pointing to the position where Expat will start
|
||||
// parsing.
|
||||
nsScannerIterator currentExpatPosition;
|
||||
|
@ -11,7 +11,6 @@
|
||||
#include "nsCOMPtr.h"
|
||||
#include "nsString.h"
|
||||
#include "nsIDTD.h"
|
||||
#include "nsITokenizer.h"
|
||||
#include "nsIInputStream.h"
|
||||
#include "nsIParser.h"
|
||||
#include "nsCycleCollectionParticipant.h"
|
||||
@ -28,19 +27,20 @@ template <typename, size_t>
|
||||
class Array;
|
||||
}
|
||||
|
||||
class nsExpatDriver : public nsIDTD, public nsITokenizer {
|
||||
class nsExpatDriver : public nsIDTD {
|
||||
virtual ~nsExpatDriver();
|
||||
|
||||
public:
|
||||
NS_DECL_CYCLE_COLLECTING_ISUPPORTS
|
||||
NS_DECL_CYCLE_COLLECTING_ISUPPORTS_FINAL
|
||||
NS_DECL_NSIDTD
|
||||
NS_DECL_NSITOKENIZER
|
||||
NS_DECL_CYCLE_COLLECTION_CLASS_AMBIGUOUS(nsExpatDriver, nsIDTD)
|
||||
NS_DECL_CYCLE_COLLECTION_CLASS(nsExpatDriver)
|
||||
|
||||
nsExpatDriver();
|
||||
|
||||
nsresult Initialize(nsIURI* aURI, nsIContentSink* aSink);
|
||||
|
||||
nsresult ResumeParse(nsScanner& aScanner, bool aIsFinalChunk);
|
||||
|
||||
int HandleExternalEntityRef(const char16_t* aOpenEntityNames,
|
||||
const char16_t* aBase, const char16_t* aSystemId,
|
||||
const char16_t* aPublicId);
|
||||
|
@ -1,50 +0,0 @@
|
||||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* vim: set sw=2 ts=2 et tw=78: */
|
||||
/* 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/. */
|
||||
|
||||
/**
|
||||
* @file nsHTMLTokenizer.cpp
|
||||
* This is an implementation of the nsITokenizer interface.
|
||||
* This file contains the implementation of a tokenizer to tokenize an HTML
|
||||
* document. It attempts to do so, making tradeoffs between compatibility with
|
||||
* older parsers and the SGML specification. Note that most of the real
|
||||
* "tokenization" takes place in nsHTMLTokens.cpp.
|
||||
*/
|
||||
|
||||
#include "nsHTMLTokenizer.h"
|
||||
#include "nsIParser.h"
|
||||
|
||||
/************************************************************************
|
||||
And now for the main class -- nsHTMLTokenizer...
|
||||
************************************************************************/
|
||||
|
||||
/**
|
||||
* Satisfy the nsISupports interface.
|
||||
*/
|
||||
NS_IMPL_ISUPPORTS(nsHTMLTokenizer, nsITokenizer)
|
||||
|
||||
/**
|
||||
* Default constructor
|
||||
*/
|
||||
nsHTMLTokenizer::nsHTMLTokenizer() {
|
||||
// TODO Assert about:blank-ness.
|
||||
}
|
||||
|
||||
/**
|
||||
* This method is repeatedly called by the tokenizer.
|
||||
* Each time, we determine the kind of token we're about to
|
||||
* read, and then we call the appropriate method to handle
|
||||
* that token type.
|
||||
*
|
||||
* @param aScanner The source of our input.
|
||||
* @param aFlushTokens An OUT parameter to tell the caller whether it should
|
||||
* process our queued tokens up to now (e.g., when we
|
||||
* reach a <script>).
|
||||
* @return Success or error
|
||||
*/
|
||||
nsresult nsHTMLTokenizer::ConsumeToken(nsScanner& aScanner,
|
||||
bool aIsFinalChunk) {
|
||||
return NS_ERROR_HTMLPARSER_EOF;
|
||||
}
|
@ -1,32 +0,0 @@
|
||||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* 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/. */
|
||||
|
||||
/**
|
||||
* MODULE NOTES:
|
||||
* @update gess 4/1/98
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef __NSHTMLTOKENIZER
|
||||
#define __NSHTMLTOKENIZER
|
||||
|
||||
#include "mozilla/Attributes.h"
|
||||
#include "nsISupports.h"
|
||||
#include "nsITokenizer.h"
|
||||
|
||||
#ifdef _MSC_VER
|
||||
# pragma warning(disable : 4275)
|
||||
#endif
|
||||
|
||||
class nsHTMLTokenizer final : public nsITokenizer {
|
||||
~nsHTMLTokenizer() {}
|
||||
|
||||
public:
|
||||
NS_DECL_ISUPPORTS
|
||||
NS_DECL_NSITOKENIZER
|
||||
nsHTMLTokenizer();
|
||||
};
|
||||
|
||||
#endif
|
@ -1,42 +0,0 @@
|
||||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* 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/. */
|
||||
|
||||
/**
|
||||
* MODULE NOTES:
|
||||
* @update gess 4/1/98
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef __NSITOKENIZER__
|
||||
#define __NSITOKENIZER__
|
||||
|
||||
#include "nsISupports.h"
|
||||
|
||||
class nsScanner;
|
||||
|
||||
#define NS_ITOKENIZER_IID \
|
||||
{ \
|
||||
0Xae98a348, 0X5e91, 0X41a8, { \
|
||||
0Xa5, 0Xb4, 0Xd2, 0X20, 0Xf3, 0X1f, 0Xc4, 0Xab \
|
||||
} \
|
||||
}
|
||||
|
||||
/***************************************************************
|
||||
Notes:
|
||||
***************************************************************/
|
||||
|
||||
class nsITokenizer : public nsISupports {
|
||||
public:
|
||||
NS_DECLARE_STATIC_IID_ACCESSOR(NS_ITOKENIZER_IID)
|
||||
|
||||
NS_IMETHOD ConsumeToken(nsScanner& aScanner, bool aIsFinalChunk) = 0;
|
||||
};
|
||||
|
||||
NS_DEFINE_STATIC_IID_ACCESSOR(nsITokenizer, NS_ITOKENIZER_IID)
|
||||
|
||||
#define NS_DECL_NSITOKENIZER \
|
||||
NS_IMETHOD ConsumeToken(nsScanner& aScanner, bool aIsFinalChunk) override;
|
||||
|
||||
#endif
|
@ -22,7 +22,6 @@
|
||||
#include "nsExpatDriver.h"
|
||||
#include "nsIFragmentContentSink.h"
|
||||
#include "nsStreamUtils.h"
|
||||
#include "nsHTMLTokenizer.h"
|
||||
#include "nsXPCOMCIDInternal.h"
|
||||
#include "nsMimeTypes.h"
|
||||
#include "nsCharsetSource.h"
|
||||
@ -333,10 +332,6 @@ nsresult nsParser::WillBuildModel() {
|
||||
mDTD = new CNavDTD();
|
||||
}
|
||||
|
||||
nsITokenizer* tokenizer;
|
||||
nsresult rv = mParserContext->GetTokenizer(mDTD, mSink, tokenizer);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
return mSink->WillBuildModel(mParserContext->mDTDMode);
|
||||
}
|
||||
|
||||
@ -725,59 +720,32 @@ nsresult nsParser::ResumeParse(bool allowIteration, bool aIsFinalChunk,
|
||||
|
||||
// Only allow parsing to be interrupted in the subsequent call to
|
||||
// build model.
|
||||
nsITokenizer* theTokenizer = nullptr;
|
||||
nsresult getTokenizerResult;
|
||||
if (mParserContext) {
|
||||
result = getTokenizerResult =
|
||||
mParserContext->GetTokenizer(mDTD, mSink, theTokenizer);
|
||||
} else {
|
||||
getTokenizerResult = NS_ERROR_HTMLPARSER_BADTOKENIZER;
|
||||
result = NS_OK;
|
||||
}
|
||||
|
||||
nsresult theTokenizerResult;
|
||||
if (mFlags & NS_PARSER_FLAG_CAN_TOKENIZE) {
|
||||
if (NS_SUCCEEDED(getTokenizerResult)) {
|
||||
theTokenizerResult = getTokenizerResult;
|
||||
|
||||
bool killSink = false;
|
||||
|
||||
while (NS_SUCCEEDED(theTokenizerResult)) {
|
||||
mParserContext->mScanner.Mark();
|
||||
theTokenizerResult = theTokenizer->ConsumeToken(
|
||||
mParserContext->mScanner, aIsFinalChunk);
|
||||
if (NS_FAILED(theTokenizerResult)) {
|
||||
mParserContext->mScanner.RewindToMark();
|
||||
if (NS_ERROR_HTMLPARSER_EOF == theTokenizerResult) {
|
||||
break;
|
||||
}
|
||||
if (NS_ERROR_HTMLPARSER_STOPPARSING == theTokenizerResult) {
|
||||
killSink = true;
|
||||
theTokenizerResult = Terminate();
|
||||
break;
|
||||
}
|
||||
mParserContext->mScanner.Mark();
|
||||
if (mDTD->GetType() == NS_IPARSER_FLAG_XML &&
|
||||
mParserContext->mParserCommand != eViewSource) {
|
||||
nsExpatDriver* expat = static_cast<nsExpatDriver*>(mDTD.get());
|
||||
theTokenizerResult =
|
||||
expat->ResumeParse(mParserContext->mScanner, aIsFinalChunk);
|
||||
if (NS_FAILED(theTokenizerResult)) {
|
||||
mParserContext->mScanner.RewindToMark();
|
||||
if (NS_ERROR_HTMLPARSER_STOPPARSING == theTokenizerResult) {
|
||||
theTokenizerResult = Terminate();
|
||||
mSink = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
if (killSink) {
|
||||
mSink = nullptr;
|
||||
}
|
||||
} else {
|
||||
theTokenizerResult = mInternalState =
|
||||
NS_ERROR_HTMLPARSER_BADTOKENIZER;
|
||||
// Nothing to do for non-XML. Note that this should only be
|
||||
// about:blank at this point, we're also checking for view-source
|
||||
// above, but that shouldn't end up here anymore.
|
||||
theTokenizerResult = NS_ERROR_HTMLPARSER_EOF;
|
||||
}
|
||||
} else {
|
||||
theTokenizerResult = NS_OK;
|
||||
}
|
||||
|
||||
if (NS_SUCCEEDED(result)) {
|
||||
if (mDTD) {
|
||||
result = mDTD->BuildModel(mSink);
|
||||
}
|
||||
} else {
|
||||
mInternalState = result = NS_ERROR_HTMLPARSER_BADTOKENIZER;
|
||||
}
|
||||
|
||||
result = mDTD->BuildModel(mSink);
|
||||
if (result == NS_ERROR_HTMLPARSER_INTERRUPTED && aIsFinalChunk) {
|
||||
PostContinueEvent();
|
||||
}
|
||||
|
@ -45,7 +45,6 @@
|
||||
#include "nsDeque.h"
|
||||
#include "CParserContext.h"
|
||||
#include "nsParserCIID.h"
|
||||
#include "nsITokenizer.h"
|
||||
#include "nsHTMLTags.h"
|
||||
#include "nsIContentSink.h"
|
||||
#include "nsCOMArray.h"
|
||||
|
Loading…
Reference in New Issue
Block a user