зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1618643 - Remove nsAutoPtr usage from parser. r=hsivonen
Differential Revision: https://phabricator.services.mozilla.com/D64251 --HG-- extra : moz-landing-system : lando
This commit is contained in:
Родитель
81c6cdac1f
Коммит
bbe8e477b9
|
@ -49,7 +49,7 @@ nsHtml5Parser::nsHtml5Parser()
|
|||
mLastBuffer(mFirstBuffer),
|
||||
mExecutor(new nsHtml5TreeOpExecutor()),
|
||||
mTreeBuilder(new nsHtml5TreeBuilder(mExecutor, nullptr)),
|
||||
mTokenizer(new nsHtml5Tokenizer(mTreeBuilder, false)),
|
||||
mTokenizer(new nsHtml5Tokenizer(mTreeBuilder.get(), false)),
|
||||
mRootContextLineNumber(1),
|
||||
mReturnToStreamParserPermitted(false) {
|
||||
mTokenizer->setInterner(&mAtomTable);
|
||||
|
@ -412,16 +412,16 @@ nsresult nsHtml5Parser::Parse(const nsAString& aSourceBuffer, void* aKey,
|
|||
if (!mDocWriteSpeculativeTreeBuilder) {
|
||||
// Lazily initialize if uninitialized
|
||||
mDocWriteSpeculativeTreeBuilder =
|
||||
new nsHtml5TreeBuilder(nullptr, executor->GetStage());
|
||||
MakeUnique<nsHtml5TreeBuilder>(nullptr, executor->GetStage());
|
||||
mDocWriteSpeculativeTreeBuilder->setScriptingEnabled(
|
||||
mTreeBuilder->isScriptingEnabled());
|
||||
mDocWriteSpeculativeTokenizer =
|
||||
new nsHtml5Tokenizer(mDocWriteSpeculativeTreeBuilder, false);
|
||||
mDocWriteSpeculativeTokenizer = MakeUnique<nsHtml5Tokenizer>(
|
||||
mDocWriteSpeculativeTreeBuilder.get(), false);
|
||||
mDocWriteSpeculativeTokenizer->setInterner(&mAtomTable);
|
||||
mDocWriteSpeculativeTokenizer->start();
|
||||
}
|
||||
mDocWriteSpeculativeTokenizer->resetToDataState();
|
||||
mDocWriteSpeculativeTreeBuilder->loadState(mTreeBuilder);
|
||||
mDocWriteSpeculativeTreeBuilder->loadState(mTreeBuilder.get());
|
||||
mDocWriteSpeculativeLastWasCR = false;
|
||||
}
|
||||
|
||||
|
@ -589,8 +589,8 @@ nsresult nsHtml5Parser::ParseUntilBlocked() {
|
|||
!mExecutor->IsScriptExecuting()) {
|
||||
mTreeBuilder->Flush();
|
||||
mReturnToStreamParserPermitted = false;
|
||||
GetStreamParser()->ContinueAfterScripts(mTokenizer, mTreeBuilder,
|
||||
mLastWasCR);
|
||||
GetStreamParser()->ContinueAfterScripts(
|
||||
mTokenizer.get(), mTreeBuilder.get(), mLastWasCR);
|
||||
}
|
||||
} else {
|
||||
// Script-created parser
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
#ifndef NS_HTML5_PARSER
|
||||
#define NS_HTML5_PARSER
|
||||
|
||||
#include "nsAutoPtr.h"
|
||||
#include "mozilla/UniquePtr.h"
|
||||
#include "nsIParser.h"
|
||||
#include "nsDeque.h"
|
||||
#include "nsParserCIID.h"
|
||||
|
@ -214,7 +214,7 @@ class nsHtml5Parser final : public nsIParser, public nsSupportsWeakReference {
|
|||
virtual nsresult Initialize(mozilla::dom::Document* aDoc, nsIURI* aURI,
|
||||
nsISupports* aContainer, nsIChannel* aChannel);
|
||||
|
||||
inline nsHtml5Tokenizer* GetTokenizer() { return mTokenizer; }
|
||||
inline nsHtml5Tokenizer* GetTokenizer() { return mTokenizer.get(); }
|
||||
|
||||
void InitializeDocWriteParserState(nsAHtml5TreeBuilderState* aState,
|
||||
int32_t aLine);
|
||||
|
@ -328,22 +328,22 @@ class nsHtml5Parser final : public nsIParser, public nsSupportsWeakReference {
|
|||
/**
|
||||
* The HTML5 tree builder
|
||||
*/
|
||||
const nsAutoPtr<nsHtml5TreeBuilder> mTreeBuilder;
|
||||
const mozilla::UniquePtr<nsHtml5TreeBuilder> mTreeBuilder;
|
||||
|
||||
/**
|
||||
* The HTML5 tokenizer
|
||||
*/
|
||||
const nsAutoPtr<nsHtml5Tokenizer> mTokenizer;
|
||||
const mozilla::UniquePtr<nsHtml5Tokenizer> mTokenizer;
|
||||
|
||||
/**
|
||||
* Another HTML5 tree builder for preloading document.written content.
|
||||
*/
|
||||
nsAutoPtr<nsHtml5TreeBuilder> mDocWriteSpeculativeTreeBuilder;
|
||||
mozilla::UniquePtr<nsHtml5TreeBuilder> mDocWriteSpeculativeTreeBuilder;
|
||||
|
||||
/**
|
||||
* Another HTML5 tokenizer for preloading document.written content.
|
||||
*/
|
||||
nsAutoPtr<nsHtml5Tokenizer> mDocWriteSpeculativeTokenizer;
|
||||
mozilla::UniquePtr<nsHtml5Tokenizer> mDocWriteSpeculativeTokenizer;
|
||||
|
||||
/**
|
||||
* The stream listener holding the stream parser.
|
||||
|
|
|
@ -10,8 +10,8 @@
|
|||
#include "nsHtml5TreeOperation.h"
|
||||
#include "nsAHtml5TreeOpSink.h"
|
||||
#include "nsTArray.h"
|
||||
#include "nsAutoPtr.h"
|
||||
#include "mozilla/Attributes.h"
|
||||
#include "mozilla/UniquePtr.h"
|
||||
|
||||
class nsHtml5Speculation final : public nsAHtml5TreeOpSink {
|
||||
public:
|
||||
|
@ -27,7 +27,7 @@ class nsHtml5Speculation final : public nsAHtml5TreeOpSink {
|
|||
|
||||
int32_t GetStartLineNumber() { return mStartLineNumber; }
|
||||
|
||||
nsAHtml5TreeBuilderState* GetSnapshot() { return mSnapshot; }
|
||||
nsAHtml5TreeBuilderState* GetSnapshot() { return mSnapshot.get(); }
|
||||
|
||||
/**
|
||||
* Flush the operations from the tree operations from the argument
|
||||
|
@ -53,7 +53,7 @@ class nsHtml5Speculation final : public nsAHtml5TreeOpSink {
|
|||
*/
|
||||
int32_t mStartLineNumber;
|
||||
|
||||
nsAutoPtr<nsAHtml5TreeBuilderState> mSnapshot;
|
||||
mozilla::UniquePtr<nsAHtml5TreeBuilderState> mSnapshot;
|
||||
|
||||
nsTArray<nsHtml5TreeOperation> mOpQueue;
|
||||
};
|
||||
|
|
|
@ -160,7 +160,8 @@ nsHtml5StreamParser::nsHtml5StreamParser(nsHtml5TreeOpExecutor* aExecutor,
|
|||
? nullptr
|
||||
: mExecutor->GetStage(),
|
||||
aMode == NORMAL ? mExecutor->GetStage() : nullptr)),
|
||||
mTokenizer(new nsHtml5Tokenizer(mTreeBuilder, aMode == VIEW_SOURCE_XML)),
|
||||
mTokenizer(
|
||||
new nsHtml5Tokenizer(mTreeBuilder.get(), aMode == VIEW_SOURCE_XML)),
|
||||
mTokenizerMutex("nsHtml5StreamParser mTokenizerMutex"),
|
||||
mOwner(aOwner),
|
||||
mLastWasCR(false),
|
||||
|
@ -710,7 +711,7 @@ nsresult nsHtml5StreamParser::SniffStreamBytes(
|
|||
|
||||
if (!mMetaScanner &&
|
||||
(mMode == NORMAL || mMode == VIEW_SOURCE_HTML || mMode == LOAD_AS_DATA)) {
|
||||
mMetaScanner = new nsHtml5MetaScanner(mTreeBuilder);
|
||||
mMetaScanner = MakeUnique<nsHtml5MetaScanner>(mTreeBuilder.get());
|
||||
}
|
||||
|
||||
if (mSniffingLength + aFromSegment.Length() >= SNIFFING_BUFFER_SIZE) {
|
||||
|
@ -1795,7 +1796,7 @@ void nsHtml5StreamParser::ContinueAfterScripts(nsHtml5Tokenizer* aTokenizer,
|
|||
return;
|
||||
}
|
||||
|
||||
nsHtml5Speculation* speculation = mSpeculations.ElementAt(0);
|
||||
const auto& speculation = mSpeculations.ElementAt(0);
|
||||
if (aLastWasCR || !aTokenizer->isInDataState() ||
|
||||
!aTreeBuilder->snapshotMatches(speculation->GetSnapshot())) {
|
||||
speculationFailed = true;
|
||||
|
@ -1845,7 +1846,7 @@ void nsHtml5StreamParser::ContinueAfterScripts(nsHtml5Tokenizer* aTokenizer,
|
|||
if (speculationFailed) {
|
||||
// Rewind the stream
|
||||
mAtEOF = false;
|
||||
nsHtml5Speculation* speculation = mSpeculations.ElementAt(0);
|
||||
const auto& speculation = mSpeculations.ElementAt(0);
|
||||
mFirstBuffer = speculation->GetBuffer();
|
||||
mFirstBuffer->setStart(speculation->GetStart());
|
||||
mTokenizer->setLineNumber(speculation->GetStartLineNumber());
|
||||
|
|
|
@ -6,12 +6,12 @@
|
|||
#ifndef nsHtml5StreamParser_h
|
||||
#define nsHtml5StreamParser_h
|
||||
|
||||
#include "nsAutoPtr.h"
|
||||
#include "nsCOMPtr.h"
|
||||
#include "nsHtml5MetaScanner.h"
|
||||
#include "mozilla/Encoding.h"
|
||||
#include "mozilla/EncodingDetector.h"
|
||||
#include "mozilla/JapaneseDetector.h"
|
||||
#include "mozilla/UniquePtr.h"
|
||||
#include "nsHtml5TreeOpExecutor.h"
|
||||
#include "nsHtml5OwningUTF16Buffer.h"
|
||||
#include "nsIInputStream.h"
|
||||
|
@ -429,7 +429,7 @@ class nsHtml5StreamParser final : public nsISupports {
|
|||
/**
|
||||
* <meta> prescan implementation
|
||||
*/
|
||||
nsAutoPtr<nsHtml5MetaScanner> mMetaScanner;
|
||||
mozilla::UniquePtr<nsHtml5MetaScanner> mMetaScanner;
|
||||
|
||||
// encoding-related stuff
|
||||
/**
|
||||
|
@ -484,12 +484,12 @@ class nsHtml5StreamParser final : public nsISupports {
|
|||
/**
|
||||
* The HTML5 tree builder
|
||||
*/
|
||||
nsAutoPtr<nsHtml5TreeBuilder> mTreeBuilder;
|
||||
mozilla::UniquePtr<nsHtml5TreeBuilder> mTreeBuilder;
|
||||
|
||||
/**
|
||||
* The HTML5 tokenizer
|
||||
*/
|
||||
nsAutoPtr<nsHtml5Tokenizer> mTokenizer;
|
||||
mozilla::UniquePtr<nsHtml5Tokenizer> mTokenizer;
|
||||
|
||||
/**
|
||||
* Makes sure the main thread can't mess the tokenizer state while it's
|
||||
|
@ -533,7 +533,7 @@ class nsHtml5StreamParser final : public nsISupports {
|
|||
* obtained.
|
||||
* The current speculation is the last element
|
||||
*/
|
||||
nsTArray<nsAutoPtr<nsHtml5Speculation>> mSpeculations;
|
||||
nsTArray<mozilla::UniquePtr<nsHtml5Speculation>> mSpeculations;
|
||||
mozilla::Mutex mSpeculationMutex;
|
||||
|
||||
/**
|
||||
|
|
|
@ -18,7 +18,7 @@ NS_IMPL_ISUPPORTS0(nsHtml5StringParser)
|
|||
nsHtml5StringParser::nsHtml5StringParser()
|
||||
: mBuilder(new nsHtml5OplessBuilder()),
|
||||
mTreeBuilder(new nsHtml5TreeBuilder(mBuilder)),
|
||||
mTokenizer(new nsHtml5Tokenizer(mTreeBuilder, false)) {
|
||||
mTokenizer(new nsHtml5Tokenizer(mTreeBuilder.get(), false)) {
|
||||
mTokenizer->setInterner(&mAtomTable);
|
||||
}
|
||||
|
||||
|
|
|
@ -5,6 +5,7 @@
|
|||
#ifndef nsHtml5StringParser_h
|
||||
#define nsHtml5StringParser_h
|
||||
|
||||
#include "mozilla/UniquePtr.h"
|
||||
#include "nsHtml5AtomTable.h"
|
||||
#include "nsParserBase.h"
|
||||
|
||||
|
@ -70,12 +71,12 @@ class nsHtml5StringParser : public nsParserBase {
|
|||
/**
|
||||
* The HTML5 tree builder
|
||||
*/
|
||||
const nsAutoPtr<nsHtml5TreeBuilder> mTreeBuilder;
|
||||
const mozilla::UniquePtr<nsHtml5TreeBuilder> mTreeBuilder;
|
||||
|
||||
/**
|
||||
* The HTML5 tokenizer
|
||||
*/
|
||||
const nsAutoPtr<nsHtml5Tokenizer> mTokenizer;
|
||||
const mozilla::UniquePtr<nsHtml5Tokenizer> mTokenizer;
|
||||
|
||||
/**
|
||||
* The scoped atom table
|
||||
|
|
|
@ -66,7 +66,7 @@ void nsHtml5Tokenizer::StartPlainText() {
|
|||
}
|
||||
|
||||
void nsHtml5Tokenizer::EnableViewSource(nsHtml5Highlighter* aHighlighter) {
|
||||
mViewSource = aHighlighter;
|
||||
mViewSource = WrapUnique(aHighlighter);
|
||||
}
|
||||
|
||||
bool nsHtml5Tokenizer::FlushViewSource() { return mViewSource->FlushOps(); }
|
||||
|
|
|
@ -14,7 +14,7 @@ inline nsHtml5HtmlAttributes* GetAttributes() { return attributes; }
|
|||
*/
|
||||
bool EnsureBufferSpace(int32_t aLength);
|
||||
|
||||
nsAutoPtr<nsHtml5Highlighter> mViewSource;
|
||||
mozilla::UniquePtr<nsHtml5Highlighter> mViewSource;
|
||||
|
||||
/**
|
||||
* Starts handling text/plain. This is a one-way initialization. There is
|
||||
|
|
|
@ -5,11 +5,11 @@
|
|||
|
||||
#include "nsParserUtils.h"
|
||||
#include "mozilla/NullPrincipal.h"
|
||||
#include "mozilla/UniquePtr.h"
|
||||
#include "mozilla/dom/DocumentFragment.h"
|
||||
#include "mozilla/dom/Element.h"
|
||||
#include "mozilla/dom/ScriptLoader.h"
|
||||
#include "nsAttrName.h"
|
||||
#include "nsAutoPtr.h"
|
||||
#include "nsCOMPtr.h"
|
||||
#include "nsContentCID.h"
|
||||
#include "nsContentUtils.h"
|
||||
|
|
Загрузка…
Ссылка в новой задаче