Skip to content

Commit

Permalink
Bug 1749935 - Inline nsParser::CancelParsingEvents. r=hsivonen
Browse files Browse the repository at this point in the history
  • Loading branch information
petervanderbeken committed Feb 14, 2022
1 parent ec14463 commit 470c69a
Show file tree
Hide file tree
Showing 6 changed files with 9 additions and 49 deletions.
6 changes: 0 additions & 6 deletions parser/html/nsHtml5Parser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -476,12 +476,6 @@ nsHtml5Parser::Terminate() {
return executor->DidBuildModel(true);
}

NS_IMETHODIMP
nsHtml5Parser::CancelParsingEvents() {
MOZ_ASSERT_UNREACHABLE("Don't call this!");
return NS_ERROR_NOT_IMPLEMENTED;
}

bool nsHtml5Parser::IsInsertionPointDefined() {
return !mExecutor->IsFlushing() && !mInsertionPointPermanentlyUndefined &&
(!GetStreamParser() || mScriptNestingLevel != 0);
Expand Down
5 changes: 0 additions & 5 deletions parser/html/nsHtml5Parser.h
Original file line number Diff line number Diff line change
Expand Up @@ -136,11 +136,6 @@ class nsHtml5Parser final : public nsIParser, public nsSupportsWeakReference {
*/
NS_IMETHOD Terminate() override;

/**
* Don't call. For interface compat only.
*/
NS_IMETHOD CancelParsingEvents() override;

/**
* True if the insertion point (per HTML5) is defined.
*/
Expand Down
12 changes: 0 additions & 12 deletions parser/htmlparser/nsIParser.h
Original file line number Diff line number Diff line change
Expand Up @@ -157,18 +157,6 @@ class nsIParser : public nsParserBase {

NS_IMETHOD Terminate(void) = 0;

/**
* Call this method to cancel any pending parsing events.
* Parsing events may be pending if all of the document's content
* has been passed to the parser but the parser has been interrupted
* because processing the tokens took too long.
*
* @update kmcclusk 05/18/01
* @return NS_OK if succeeded else ERROR.
*/

NS_IMETHOD CancelParsingEvents() = 0;

/**
* True if the insertion point (per HTML5) is defined.
*/
Expand Down
26 changes: 9 additions & 17 deletions parser/htmlparser/nsParser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -270,17 +270,6 @@ nsParser::SetContentSink(nsIContentSink* aSink) {
NS_IMETHODIMP_(nsIContentSink*)
nsParser::GetContentSink() { return mSink; }

NS_IMETHODIMP
nsParser::CancelParsingEvents() {
if (mFlags & NS_PARSER_FLAG_PENDING_CONTINUE_EVENT) {
NS_ASSERTION(mContinueEvent, "mContinueEvent is null");
// Revoke the pending continue parsing event
mContinueEvent = nullptr;
mFlags &= ~NS_PARSER_FLAG_PENDING_CONTINUE_EVENT;
}
return NS_OK;
}

////////////////////////////////////////////////////////////////////////

/**
Expand Down Expand Up @@ -371,13 +360,16 @@ nsParser::Terminate(void) {
nsCOMPtr<nsIParser> kungFuDeathGrip(this);
mInternalState = result = NS_ERROR_HTMLPARSER_STOPPARSING;

// CancelParsingEvents must be called to avoid leaking the nsParser object
// @see bug 108049
// If NS_PARSER_FLAG_PENDING_CONTINUE_EVENT is set then CancelParsingEvents
// will reset it so DidBuildModel will call DidBuildModel on the DTD. Note:
// The IsComplete() call inside of DidBuildModel looks at the
// pendingContinueEvents flag.
CancelParsingEvents();
// If NS_PARSER_FLAG_PENDING_CONTINUE_EVENT is set then reset it so
// DidBuildModel will call DidBuildModel on the DTD. Note: The IsComplete()
// call inside of DidBuildModel looks at the pendingContinueEvents flag.
if (mFlags & NS_PARSER_FLAG_PENDING_CONTINUE_EVENT) {
NS_ASSERTION(mContinueEvent, "mContinueEvent is null");
// Revoke the pending continue parsing event
mContinueEvent = nullptr;
mFlags &= ~NS_PARSER_FLAG_PENDING_CONTINUE_EVENT;
}

if (mDTD) {
mDTD->Terminate();
Expand Down
7 changes: 0 additions & 7 deletions parser/htmlparser/nsParser.h
Original file line number Diff line number Diff line change
Expand Up @@ -207,13 +207,6 @@ class nsParser final : public nsIParser,

void SetSinkCharset(NotNull<const Encoding*> aCharset);

/**
* Removes continue parsing events
* @update kmcclusk 5/18/98
*/

NS_IMETHOD CancelParsingEvents() override;

/**
* Return true.
*/
Expand Down
2 changes: 0 additions & 2 deletions parser/prototype/PrototypeDocumentParser.h
Original file line number Diff line number Diff line change
Expand Up @@ -80,8 +80,6 @@ class PrototypeDocumentParser final : public nsIParser,

NS_IMETHOD Terminate() override { return NS_ERROR_NOT_IMPLEMENTED; }

NS_IMETHOD CancelParsingEvents() override { return NS_ERROR_NOT_IMPLEMENTED; }

virtual bool IsInsertionPointDefined() override { return false; }

void IncrementScriptNestingLevel() final {}
Expand Down

0 comments on commit 470c69a

Please sign in to comment.