commit 326cf8e6a032402327988b8d04673cb70d11628d
parent bf8e6315c253a54f3ff200515685df7d88df71b5
Author: Henri Sivonen <hsivonen@hsivonen.fi>
Date: Tue, 25 Nov 2025 09:50:21 +0000
Bug 650775 - Remove CNavDTD and nsIHTMLContentSink from the tree. r=dom-core,farre
Differential Revision: https://phabricator.services.mozilla.com/D273949
Diffstat:
10 files changed, 12 insertions(+), 236 deletions(-)
diff --git a/dom/base/Document.cpp b/dom/base/Document.cpp
@@ -363,7 +363,6 @@
#include "nsIFrame.h"
#include "nsIGlobalObject.h"
#include "nsIHTMLCollection.h"
-#include "nsIHTMLContentSink.h"
#include "nsIHttpChannel.h"
#include "nsIHttpChannelInternal.h"
#include "nsIIOService.h"
diff --git a/dom/html/nsHTMLDocument.cpp b/dom/html/nsHTMLDocument.cpp
@@ -28,7 +28,6 @@
#include "nsHTMLParts.h"
#include "nsICachingChannel.h"
#include "nsIDocumentViewer.h"
-#include "nsIHTMLContentSink.h"
#include "nsIPrincipal.h"
#include "nsIProtocolHandler.h"
#include "nsIScriptContext.h"
diff --git a/layout/generic/nsHTMLParts.h b/layout/generic/nsHTMLParts.h
@@ -21,7 +21,6 @@ class nsIChannel;
class nsIContent;
class nsIFragmentContentSink;
class nsIFrame;
-class nsIHTMLContentSink;
class nsIURI;
class nsListControlFrame;
class nsNodeInfoManager;
@@ -175,13 +174,4 @@ nsTableCellFrame* NS_NewTableCellFrame(mozilla::PresShell* aPresShell,
mozilla::ComputedStyle* aStyle,
nsTableFrame* aTableFrame);
-nsresult NS_NewHTMLContentSink(nsIHTMLContentSink** aInstancePtrResult,
- mozilla::dom::Document* aDoc, nsIURI* aURL,
- nsISupports* aContainer, // e.g. docshell
- nsIChannel* aChannel);
-nsresult NS_NewHTMLFragmentContentSink(
- nsIFragmentContentSink** aInstancePtrResult);
-nsresult NS_NewHTMLFragmentContentSink2(
- nsIFragmentContentSink** aInstancePtrResult);
-
#endif /* nsHTMLParts_h___ */
diff --git a/parser/htmlparser/CNavDTD.cpp b/parser/htmlparser/CNavDTD.cpp
@@ -1,44 +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/. */
-
-#include "nsISupports.h"
-#include "nsISupportsImpl.h"
-#include "nsIParser.h"
-#include "CNavDTD.h"
-#include "nsIHTMLContentSink.h"
-
-NS_IMPL_ISUPPORTS(CNavDTD, nsIDTD);
-
-CNavDTD::CNavDTD() {}
-
-CNavDTD::~CNavDTD() {}
-
-NS_IMETHODIMP
-CNavDTD::BuildModel(nsIContentSink* aSink) {
- // NB: It is important to throw STOPPARSING if the sink is the wrong type in
- // order to make sure nsParser cleans up properly after itself.
- nsCOMPtr<nsIHTMLContentSink> sink = do_QueryInterface(aSink);
- if (!sink) {
- return NS_ERROR_HTMLPARSER_STOPPARSING;
- }
-
- nsresult rv = sink->OpenContainer(nsIHTMLContentSink::eHTML);
- NS_ENSURE_SUCCESS(rv, rv);
- rv = sink->OpenContainer(nsIHTMLContentSink::eBody);
- NS_ENSURE_SUCCESS(rv, rv);
-
- rv = sink->CloseContainer(nsIHTMLContentSink::eBody);
- MOZ_ASSERT(NS_SUCCEEDED(rv));
- rv = sink->CloseContainer(nsIHTMLContentSink::eHTML);
- MOZ_ASSERT(NS_SUCCEEDED(rv));
-
- return NS_OK;
-}
-
-void CNavDTD::DidBuildModel() {}
-
-NS_IMETHODIMP_(void)
-CNavDTD::Terminate() {}
diff --git a/parser/htmlparser/CNavDTD.h b/parser/htmlparser/CNavDTD.h
@@ -1,32 +0,0 @@
-/* -*- Mode: C++; tab-width: 4; 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/. */
-
-#ifndef NS_NAVHTMLDTD__
-#define NS_NAVHTMLDTD__
-
-#include "nsIDTD.h"
-#include "nsISupports.h"
-#include "nsCOMPtr.h"
-
-#ifdef _MSC_VER
-# pragma warning(disable : 4275)
-#endif
-
-class CNavDTD : public nsIDTD {
-#ifdef _MSC_VER
-# pragma warning(default : 4275)
-#endif
-
- virtual ~CNavDTD();
-
- public:
- CNavDTD();
-
- NS_DECL_ISUPPORTS
- NS_DECL_NSIDTD
-};
-
-#endif
diff --git a/parser/htmlparser/CParserContext.cpp b/parser/htmlparser/CParserContext.cpp
@@ -7,7 +7,6 @@
#include "nsAtom.h"
#include "CParserContext.h"
#include "prenv.h"
-#include "nsIHTMLContentSink.h"
#include "nsMimeTypes.h"
CParserContext::CParserContext(nsIURI* aURI, eParserCommands aCommand)
diff --git a/parser/htmlparser/moz.build b/parser/htmlparser/moz.build
@@ -23,7 +23,6 @@ EXPORTS += [
"nsIContentSink.h",
"nsIDTD.h",
"nsIFragmentContentSink.h",
- "nsIHTMLContentSink.h",
"nsIParser.h",
"nsParserBase.h",
"nsParserConstants.h",
@@ -32,7 +31,6 @@ EXPORTS += [
]
UNIFIED_SOURCES += [
- "CNavDTD.cpp",
"CParserContext.cpp",
"nsElementTable.cpp",
"nsExpatDriver.cpp",
diff --git a/parser/htmlparser/nsIHTMLContentSink.h b/parser/htmlparser/nsIHTMLContentSink.h
@@ -1,90 +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/. */
-#ifndef nsIHTMLContentSink_h___
-#define nsIHTMLContentSink_h___
-
-/**
- * This interface is OBSOLETE and in the process of being REMOVED.
- * Do NOT implement!
- *
- * This file declares the concrete HTMLContentSink class.
- * This class is used during the parsing process as the
- * primary interface between the parser and the content
- * model.
- *
- * After the tokenizer completes, the parser iterates over
- * the known token list. As the parser identifies valid
- * elements, it calls the contentsink interface to notify
- * the content model that a new node or child node is being
- * created and added to the content model.
- *
- * The HTMLContentSink interface assumes 4 underlying
- * containers: HTML, HEAD, BODY and FRAMESET. Before
- * accessing any these, the parser will call the appropriate
- * OpennsIHTMLContentSink method: OpenHTML,OpenHead,OpenBody,OpenFrameSet;
- * likewise, the ClosensIHTMLContentSink version will be called when the
- * parser is done with a given section.
- *
- * IMPORTANT: The parser may Open each container more than
- * once! This is due to the irregular nature of HTML files.
- * For example, it is possible to encounter plain text at
- * the start of an HTML document (that precedes the HTML tag).
- * Such text is treated as if it were part of the body.
- * In such cases, the parser will Open the body, pass the text-
- * node in and then Close the body. The body will likely be
- * re-Opened later when the actual <BODY> tag has been seen.
- *
- * Containers within the body are Opened and Closed
- * using the OpenContainer(...) and CloseContainer(...) calls.
- * It is assumed that the document or contentSink is
- * maintaining its state to manage where new content should
- * be added to the underlying document.
- *
- * NOTE: OpenHTML() and OpenBody() may get called multiple times
- * in the same document. That's fine, and it doesn't mean
- * that we have multiple bodies or HTML's.
- *
- * NOTE: I haven't figured out how sub-documents (non-frames)
- * are going to be handled. Stay tuned.
- */
-#include "nsIContentSink.h"
-#include "nsHTMLTags.h"
-
-#define NS_IHTML_CONTENT_SINK_IID \
- {0xefc5af86, 0x5cfd, 0x4918, {0x9d, 0xd3, 0x5f, 0x7a, 0xb2, 0x88, 0xb2, 0x68}}
-
-/**
- * This interface is OBSOLETE and in the process of being REMOVED.
- * Do NOT implement!
- */
-class nsIHTMLContentSink : public nsIContentSink {
- public:
- NS_INLINE_DECL_STATIC_IID(NS_IHTML_CONTENT_SINK_IID)
-
- enum ElementType { eHTML, eBody };
-
- /**
- * This method is used to open a generic container in the sink.
- *
- * @update 4/1/98 gess
- */
- NS_IMETHOD OpenContainer(ElementType aNodeType) = 0;
-
- /**
- * This method gets called by the parser when a close
- * container tag has been consumed and needs to be closed.
- *
- * @param aTag - The tag to be closed.
- */
- NS_IMETHOD CloseContainer(ElementType aTag) = 0;
-
- /**
- * This method returns true if there are more than one
- * pending style sheets, false otherwise.
- */
- virtual bool WaitForPendingSheets() = 0;
-};
-
-#endif /* nsIHTMLContentSink_h___ */
diff --git a/parser/htmlparser/nsParser.cpp b/parser/htmlparser/nsParser.cpp
@@ -12,7 +12,6 @@
#include "plstr.h"
#include "nsIChannel.h"
#include "nsIInputStream.h"
-#include "CNavDTD.h"
#include "prenv.h"
#include "prlock.h"
#include "prcvar.h"
@@ -25,7 +24,6 @@
#include "nsMimeTypes.h"
#include "nsCharsetSource.h"
#include "nsThreadUtils.h"
-#include "nsIHTMLContentSink.h"
#include "mozilla/CondVar.h"
#include "mozilla/dom/ScriptLoader.h"
@@ -54,16 +52,12 @@ scheduling of the continue events will proceed until either:
1) All of the remaining data can be processed without interrupting
2) The parser has been cancelled.
-
-This capability is currently used in CNavDTD and nsHTMLContentSink. The
-nsHTMLContentSink is notified by CNavDTD when a chunk of tokens is going to be
-processed and when each token is processed. The nsHTML content sink records
-the time when the chunk has started processing and will return
-NS_ERROR_HTMLPARSER_INTERRUPTED if the token processing time has exceeded a
-threshold called max tokenizing processing time. This allows the content sink
-to limit how much data is processed in a single chunk which in turn gates how
-much time is spent away from the event loop. Processing smaller chunks of data
-also reduces the time spent in subsequent reflows.
+The nsContentSink records the time when the chunk has started processing and
+will return NS_ERROR_HTMLPARSER_INTERRUPTED if the token processing time has
+exceeded a threshold called max tokenizing processing time. This allows the
+content sink to limit how much data is processed in a single chunk which in
+turn gates how much time is spent away from the event loop. Processing smaller
+chunks of data also reduces the time spent in subsequent reflows.
This capability is most apparent when loading large documents. If the maximum
token processing time is set small enough the application will remain
@@ -120,7 +114,6 @@ void nsParser::Initialize() {
mProcessingNetworkData = false;
mOnStopPending = false;
- mIsAboutBlank = false;
}
void nsParser::Cleanup() {
@@ -246,10 +239,6 @@ nsParser::SetContentSink(nsIContentSink* aSink) {
if (mSink) {
mSink->SetParser(this);
- nsCOMPtr<nsIHTMLContentSink> htmlSink = do_QueryInterface(mSink);
- if (htmlSink) {
- mIsAboutBlank = true;
- }
}
}
@@ -281,13 +270,8 @@ nsresult nsParser::WillBuildModel() {
if (eUnknownDetect != mParserContext->mAutoDetectStatus) return NS_OK;
if (eDTDMode_autodetect == mParserContext->mDTDMode) {
- if (mIsAboutBlank) {
- mParserContext->mDTDMode = eDTDMode_quirks;
- mParserContext->mDocType = eHTML_Quirks;
- } else {
- mParserContext->mDTDMode = eDTDMode_full_standards;
- mParserContext->mDocType = eXML;
- }
+ mParserContext->mDTDMode = eDTDMode_full_standards;
+ mParserContext->mDocType = eXML;
} // else XML fragment with nested parser context
// We always find a DTD.
@@ -298,17 +282,11 @@ nsresult nsParser::WillBuildModel() {
"The old parser is not supposed to be used for View Source "
"anymore.");
- // Now see if we're parsing XML or HTML (which, as far as we're concerned,
- // simply means "not XML").
- if (mParserContext->mDocType == eXML) {
- RefPtr<nsExpatDriver> expat = new nsExpatDriver();
- nsresult rv = expat->Initialize(mParserContext->mScanner.GetURI(), mSink);
- NS_ENSURE_SUCCESS(rv, rv);
+ RefPtr<nsExpatDriver> expat = new nsExpatDriver();
+ nsresult rv = expat->Initialize(mParserContext->mScanner.GetURI(), mSink);
+ NS_ENSURE_SUCCESS(rv, rv);
- mDTD = expat.forget();
- } else {
- mDTD = new CNavDTD();
- }
+ mDTD = expat.forget();
return mSink->WillBuildModel(mParserContext->mDTDMode);
}
@@ -918,14 +896,6 @@ inline char GetNextChar(nsACString::const_iterator& aStart,
return (++aStart != aEnd) ? *aStart : '\0';
}
-static nsresult NoOpParserWriteFunc(nsIInputStream* in, void* closure,
- const char* fromRawSegment,
- uint32_t toOffset, uint32_t count,
- uint32_t* writeCount) {
- *writeCount = count;
- return NS_OK;
-}
-
typedef struct {
bool mNeedCharsetCheck;
nsParser* mParser;
@@ -1008,16 +978,6 @@ nsresult nsParser::OnDataAvailable(nsIRequest* request,
nsresult rv = NS_OK;
- if (mIsAboutBlank) {
- MOZ_ASSERT(false, "Must not get OnDataAvailable for about:blank");
- // ... but if an extension tries to feed us data for about:blank in a
- // release build, silently ignore the data.
- uint32_t totalRead;
- rv = pIStream->ReadSegments(NoOpParserWriteFunc, nullptr, aLength,
- &totalRead);
- return rv;
- }
-
if (mParserContext->mRequest == request) {
mParserContext->mStreamListenerState = eOnDataAvail;
diff --git a/parser/htmlparser/nsParser.h b/parser/htmlparser/nsParser.h
@@ -244,8 +244,6 @@ class nsParser final : public nsIParser,
void HandleParserContinueEvent(class nsParserContinueEvent*);
void Reset() {
- MOZ_ASSERT(!mIsAboutBlank,
- "Only the XML fragment parsing case is supposed to call this.");
Cleanup();
mUnusedInput.Truncate();
Initialize();
@@ -316,7 +314,6 @@ class nsParser final : public nsIParser,
bool mProcessingNetworkData;
bool mOnStopPending;
- bool mIsAboutBlank;
};
#endif