From 6c6f7200a685a009007bab3189fb4648b1d0c275 Mon Sep 17 00:00:00 2001 From: Peter Van der Beken Date: Mon, 14 Feb 2022 13:03:50 +0000 Subject: [PATCH] Bug 1749935 - Remove nsITokenizer. r=hsivonen Differential Revision: https://phabricator.services.mozilla.com/D135887 --- parser/html/nsHtml5Parser.h | 1 - parser/htmlparser/CParserContext.cpp | 20 --------- parser/htmlparser/CParserContext.h | 3 -- parser/htmlparser/moz.build | 2 - parser/htmlparser/nsExpatDriver.cpp | 6 +-- parser/htmlparser/nsExpatDriver.h | 10 ++--- parser/htmlparser/nsHTMLTokenizer.cpp | 50 --------------------- parser/htmlparser/nsHTMLTokenizer.h | 32 -------------- parser/htmlparser/nsITokenizer.h | 42 ------------------ parser/htmlparser/nsParser.cpp | 64 +++++++-------------------- parser/htmlparser/nsParser.h | 1 - 11 files changed, 23 insertions(+), 208 deletions(-) delete mode 100644 parser/htmlparser/nsHTMLTokenizer.cpp delete mode 100644 parser/htmlparser/nsHTMLTokenizer.h delete mode 100644 parser/htmlparser/nsITokenizer.h diff --git a/parser/html/nsHtml5Parser.h b/parser/html/nsHtml5Parser.h index 9c5b9d4a27f3..fa4aeee34223 100644 --- a/parser/html/nsHtml5Parser.h +++ b/parser/html/nsHtml5Parser.h @@ -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" diff --git a/parser/htmlparser/CParserContext.cpp b/parser/htmlparser/CParserContext.cpp index 8cf0e769ea5c..d57c9855cccb 100644 --- a/parser/htmlparser/CParserContext.cpp +++ b/parser/htmlparser/CParserContext.cpp @@ -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; -} diff --git a/parser/htmlparser/CParserContext.h b/parser/htmlparser/CParserContext.h index c72f3d17951c..b32436795b82 100644 --- a/parser/htmlparser/CParserContext.h +++ b/parser/htmlparser/CParserContext.h @@ -37,14 +37,11 @@ class CParserContext { ~CParserContext(); - nsresult GetTokenizer(nsIDTD* aDTD, nsIContentSink* aSink, - nsITokenizer*& aTokenizer); void SetMimeType(const nsACString& aMimeType); nsCOMPtr mRequest; // provided by necko to differnciate different input streams // why is mRequest strongly referenced? see bug 102376. - nsCOMPtr mTokenizer; nsScanner mScanner; nsCString mMimeType; diff --git a/parser/htmlparser/moz.build b/parser/htmlparser/moz.build index 860ec9838785..293f2a033dad 100644 --- a/parser/htmlparser/moz.build +++ b/parser/htmlparser/moz.build @@ -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", diff --git a/parser/htmlparser/nsExpatDriver.cpp b/parser/htmlparser/nsExpatDriver.cpp index ba950dfa125e..664bd528f855 100644 --- a/parser/htmlparser/nsExpatDriver.cpp +++ b/parser/htmlparser/nsExpatDriver.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; diff --git a/parser/htmlparser/nsExpatDriver.h b/parser/htmlparser/nsExpatDriver.h index 9c9e200d598e..f1ff32a205bf 100644 --- a/parser/htmlparser/nsExpatDriver.h +++ b/parser/htmlparser/nsExpatDriver.h @@ -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 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); diff --git a/parser/htmlparser/nsHTMLTokenizer.cpp b/parser/htmlparser/nsHTMLTokenizer.cpp deleted file mode 100644 index 4a847848c5f4..000000000000 --- a/parser/htmlparser/nsHTMLTokenizer.cpp +++ /dev/null @@ -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