提交 22b946ab 编写于 作者: A Adam Barth

Remove HTMLParserOptions

We always use threading now and there aren't any other options.

R=eseidel@chromium.org, esprehn@chromium.org

Review URL: https://codereview.chromium.org/676133002
上级 8f729a9b
......@@ -953,8 +953,6 @@ sky_core_files = [
"html/parser/HTMLEntityTable.h",
"html/parser/HTMLInputStream.h",
"html/parser/HTMLParserIdioms.cpp",
"html/parser/HTMLParserOptions.cpp",
"html/parser/HTMLParserOptions.h",
"html/parser/HTMLParserScheduler.cpp",
"html/parser/HTMLParserScheduler.h",
"html/parser/HTMLParserThread.cpp",
......
......@@ -58,7 +58,7 @@ base::WeakPtr<BackgroundHTMLParser> BackgroundHTMLParser::create(PassOwnPtr<Back
BackgroundHTMLParser::BackgroundHTMLParser(PassOwnPtr<Configuration> config)
: m_token(adoptPtr(new HTMLToken))
, m_tokenizer(HTMLTokenizer::create(config->options))
, m_tokenizer(HTMLTokenizer::create())
, m_parser(config->parser)
, m_pendingTokens(adoptPtr(new CompactHTMLTokenStream))
, m_decoder(TextResourceDecoder::create())
......
......@@ -28,7 +28,6 @@
#include "base/memory/weak_ptr.h"
#include "core/html/parser/CompactHTMLToken.h"
#include "core/html/parser/HTMLParserOptions.h"
#include "core/html/parser/HTMLTokenizer.h"
#include "core/html/parser/TextResourceDecoder.h"
#include "mojo/public/cpp/system/core.h"
......@@ -46,7 +45,6 @@ class BackgroundHTMLParser : public DataPipeDrainer::Client {
WTF_MAKE_FAST_ALLOCATED;
public:
struct Configuration {
HTMLParserOptions options;
mojo::ScopedDataPipeConsumerHandle source;
WeakPtr<HTMLDocumentParser> parser;
};
......
......@@ -48,7 +48,7 @@ namespace blink {
HTMLDocumentParser::HTMLDocumentParser(HTMLDocument& document, bool reportErrors)
: DocumentParser(&document)
, m_options(&document)
, m_treeBuilder(HTMLTreeBuilder::create(this, &document, reportErrors, m_options))
, m_treeBuilder(HTMLTreeBuilder::create(this, &document, reportErrors))
, m_parserScheduler(HTMLParserScheduler::create(this))
, m_weakFactory(this)
, m_isFragment(false)
......@@ -56,7 +56,6 @@ HTMLDocumentParser::HTMLDocumentParser(HTMLDocument& document, bool reportErrors
, m_haveBackgroundParser(false)
, m_pumpSessionNestingLevel(0)
{
ASSERT(shouldUseThreading());
}
HTMLDocumentParser::~HTMLDocumentParser()
......@@ -79,12 +78,10 @@ HTMLDocumentParser::~HTMLDocumentParser()
void HTMLDocumentParser::parse(mojo::ScopedDataPipeConsumerHandle source)
{
ASSERT(!isStopped());
ASSERT(shouldUseThreading());
ASSERT(!m_haveBackgroundParser);
m_haveBackgroundParser = true;
OwnPtr<BackgroundHTMLParser::Configuration> config = adoptPtr(new BackgroundHTMLParser::Configuration);
config->options = m_options;
config->source = source.Pass();
config->parser = m_weakFactory.createWeakPtr();
......@@ -225,7 +222,6 @@ void HTMLDocumentParser::processParsedChunkFromBackgroundParser(PassOwnPtr<Parse
// ASSERT that this object is both attached to the Document and protected.
ASSERT(refCount() >= 2);
#endif
ASSERT(shouldUseThreading());
ASSERT(!m_lastChunkBeforeScript);
ActiveParserSession session(contextForParsingSession());
......@@ -350,7 +346,6 @@ void HTMLDocumentParser::startBackgroundParser()
void HTMLDocumentParser::stopBackgroundParser()
{
ASSERT(shouldUseThreading());
ASSERT(m_haveBackgroundParser);
m_haveBackgroundParser = false;
......
......@@ -32,7 +32,6 @@
#include "core/frame/UseCounter.h"
#include "core/html/parser/CompactHTMLToken.h"
#include "core/html/parser/HTMLInputStream.h"
#include "core/html/parser/HTMLParserOptions.h"
#include "core/html/parser/HTMLScriptRunner.h"
#include "core/html/parser/HTMLToken.h"
#include "core/html/parser/HTMLTokenizer.h"
......@@ -118,15 +117,11 @@ private:
void endIfDelayed();
void end();
bool shouldUseThreading() const { return m_options.useThreading; }
bool isParsingFragment() const;
bool isScheduledForResume() const;
bool inPumpSession() const { return m_pumpSessionNestingLevel > 0; }
bool shouldDelayEnd() const { return inPumpSession() || isWaitingForScripts() || isScheduledForResume() || isExecutingScript(); }
HTMLParserOptions m_options;
OwnPtrWillBeMember<HTMLTreeBuilder> m_treeBuilder;
OwnPtr<HTMLParserScheduler> m_parserScheduler;
TextPosition m_textPosition;
......
/*
* Copyright (C) 2013 Google, Inc. All Rights Reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY GOOGLE INC. ``AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL GOOGLE INC. OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
* OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include "config.h"
#include "core/html/parser/HTMLParserOptions.h"
#include "bindings/core/v8/ScriptController.h"
#include "core/dom/Document.h"
#include "core/frame/LocalFrame.h"
#include "core/frame/Settings.h"
namespace blink {
HTMLParserOptions::HTMLParserOptions(Document* document)
{
useThreading = document && !document->url().isAboutBlankURL();
}
}
/*
* Copyright (C) 2013 Google, Inc. All Rights Reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY GOOGLE INC. ``AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL GOOGLE INC. OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
* OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef HTMLParserOptions_h
#define HTMLParserOptions_h
namespace blink {
class Document;
class HTMLParserOptions {
public:
bool useThreading;
explicit HTMLParserOptions(Document* = 0);
};
}
#endif
......@@ -101,9 +101,8 @@ static inline bool isEndTagBufferingState(HTMLTokenizer::State state)
#define HTML_ADVANCE_TO(stateName) ADVANCE_TO(HTMLTokenizer, stateName)
#define HTML_SWITCH_TO(stateName) SWITCH_TO(HTMLTokenizer, stateName)
HTMLTokenizer::HTMLTokenizer(const HTMLParserOptions& options)
HTMLTokenizer::HTMLTokenizer()
: m_inputStreamPreprocessor(this)
, m_options(options)
{
reset();
}
......@@ -119,35 +118,6 @@ void HTMLTokenizer::reset()
m_additionalAllowedCharacter = '\0';
}
bool HTMLTokenizer::canCreateCheckpoint() const
{
if (!m_appropriateEndTagName.isEmpty())
return false;
if (!m_temporaryBuffer.isEmpty())
return false;
if (!m_bufferedEndTagName.isEmpty())
return false;
return true;
}
void HTMLTokenizer::createCheckpoint(Checkpoint& result) const
{
ASSERT(canCreateCheckpoint());
result.options = m_options;
result.state = m_state;
result.additionalAllowedCharacter = m_additionalAllowedCharacter;
result.skipNextNewLine = m_inputStreamPreprocessor.skipNextNewLine();
}
void HTMLTokenizer::restoreFromCheckpoint(const Checkpoint& checkpoint)
{
m_token = 0;
m_options = checkpoint.options;
m_state = checkpoint.state;
m_additionalAllowedCharacter = checkpoint.additionalAllowedCharacter;
m_inputStreamPreprocessor.reset(checkpoint.skipNextNewLine);
}
inline bool HTMLTokenizer::processEntity(SegmentedString& source)
{
bool notEnoughCharacters = false;
......
......@@ -27,7 +27,6 @@
#ifndef HTMLTokenizer_h
#define HTMLTokenizer_h
#include "core/html/parser/HTMLParserOptions.h"
#include "core/html/parser/HTMLToken.h"
#include "core/html/parser/InputStreamPreprocessor.h"
#include "platform/text/SegmentedString.h"
......@@ -38,7 +37,7 @@ class HTMLTokenizer {
WTF_MAKE_NONCOPYABLE(HTMLTokenizer);
WTF_MAKE_FAST_ALLOCATED;
public:
static PassOwnPtr<HTMLTokenizer> create(const HTMLParserOptions& options) { return adoptPtr(new HTMLTokenizer(options)); }
static PassOwnPtr<HTMLTokenizer> create() { return adoptPtr(new HTMLTokenizer()); }
~HTMLTokenizer();
void reset();
......@@ -96,25 +95,6 @@ public:
CommentEndBangState,
};
struct Checkpoint {
HTMLParserOptions options;
State state;
UChar additionalAllowedCharacter;
bool skipNextNewLine;
Checkpoint()
: options(0)
, state()
, additionalAllowedCharacter('\0')
, skipNextNewLine(false)
{
}
};
bool canCreateCheckpoint() const;
void createCheckpoint(Checkpoint&) const;
void restoreFromCheckpoint(const Checkpoint&);
// This function returns true if it emits a token. Otherwise, callers
// must provide the same (in progress) token on the next call (unless
// they call reset() first).
......@@ -153,7 +133,7 @@ public:
void setState(State state) { m_state = state; }
private:
explicit HTMLTokenizer(const HTMLParserOptions&);
HTMLTokenizer();
inline bool processEntity(SegmentedString&);
......@@ -239,8 +219,6 @@ private:
// token (e.g., when lexing script). We buffer the name of the end tag
// token here so we remember it next time we re-enter the tokenizer.
Vector<LChar, 32> m_bufferedEndTagName;
HTMLParserOptions m_options;
};
}
......
......@@ -45,7 +45,7 @@ static TextPosition uninitializedPositionValue1()
return TextPosition(OrdinalNumber::fromOneBasedInt(-1), OrdinalNumber::first());
}
HTMLTreeBuilder::HTMLTreeBuilder(HTMLDocumentParser* parser, HTMLDocument* document, bool, const HTMLParserOptions& options)
HTMLTreeBuilder::HTMLTreeBuilder(HTMLDocumentParser* parser, HTMLDocument* document, bool)
:
#if ENABLE(ASSERT)
m_isAttached(true),
......@@ -55,48 +55,14 @@ HTMLTreeBuilder::HTMLTreeBuilder(HTMLDocumentParser* parser, HTMLDocument* docum
, m_originalInsertionMode(HTMLMode)
, m_parser(parser)
, m_scriptToProcessStartPosition(uninitializedPositionValue1())
, m_options(options)
{
m_tree.openElements()->pushRootNode(document);
}
// FIXME: Member variables should be grouped into self-initializing structs to
// minimize code duplication between these constructors.
HTMLTreeBuilder::HTMLTreeBuilder(HTMLDocumentParser* parser, DocumentFragment* fragment, Element* contextElement, const HTMLParserOptions& options)
:
#if ENABLE(ASSERT)
m_isAttached(true),
#endif
m_fragmentContext(fragment, contextElement)
, m_tree(fragment)
, m_insertionMode(HTMLMode)
, m_originalInsertionMode(HTMLMode)
, m_parser(parser)
, m_scriptToProcessStartPosition(uninitializedPositionValue1())
, m_options(options)
{
ASSERT(isMainThread());
ASSERT(contextElement);
// Steps 4.2-4.6 of the HTML5 Fragment Case parsing algorithm:
// http://www.whatwg.org/specs/web-apps/current-work/multipage/the-end.html#fragment-case
// For efficiency, we skip step 4.2 ("Let root be a new html element with no attributes")
// and instead use the DocumentFragment as a root node.
m_tree.openElements()->pushRootNode(fragment);
}
HTMLTreeBuilder::~HTMLTreeBuilder()
{
}
void HTMLTreeBuilder::trace(Visitor* visitor)
{
visitor->trace(m_fragmentContext);
visitor->trace(m_tree);
visitor->trace(m_parser);
visitor->trace(m_scriptToProcess);
}
void HTMLTreeBuilder::detach()
{
#if ENABLE(ASSERT)
......
......@@ -29,7 +29,6 @@
#include "core/html/parser/HTMLConstructionSite.h"
#include "core/html/parser/HTMLElementStack.h"
#include "core/html/parser/HTMLParserOptions.h"
#include "platform/heap/Handle.h"
#include "wtf/Noncopyable.h"
#include "wtf/PassOwnPtr.h"
......@@ -54,16 +53,11 @@ class HTMLDocumentParser;
class HTMLTreeBuilder final : public NoBaseWillBeGarbageCollectedFinalized<HTMLTreeBuilder> {
WTF_MAKE_NONCOPYABLE(HTMLTreeBuilder); WTF_MAKE_FAST_ALLOCATED_WILL_BE_REMOVED;
public:
static PassOwnPtrWillBeRawPtr<HTMLTreeBuilder> create(HTMLDocumentParser* parser, HTMLDocument* document, bool reportErrors, const HTMLParserOptions& options)
static PassOwnPtrWillBeRawPtr<HTMLTreeBuilder> create(HTMLDocumentParser* parser, HTMLDocument* document, bool reportErrors)
{
return adoptPtrWillBeNoop(new HTMLTreeBuilder(parser, document, reportErrors, options));
}
static PassOwnPtrWillBeRawPtr<HTMLTreeBuilder> create(HTMLDocumentParser* parser, DocumentFragment* fragment, Element* contextElement, const HTMLParserOptions& options)
{
return adoptPtrWillBeNoop(new HTMLTreeBuilder(parser, fragment, contextElement, options));
return adoptPtrWillBeNoop(new HTMLTreeBuilder(parser, document, reportErrors));
}
~HTMLTreeBuilder();
void trace(Visitor*);
const HTMLElementStack* openElements() const { return m_tree.openElements(); }
......@@ -92,8 +86,7 @@ private:
TextMode,
};
HTMLTreeBuilder(HTMLDocumentParser*, HTMLDocument*, bool reportErrors, const HTMLParserOptions&);
HTMLTreeBuilder(HTMLDocumentParser*, DocumentFragment*, Element* contextElement, const HTMLParserOptions&);
HTMLTreeBuilder(HTMLDocumentParser*, HTMLDocument*, bool reportErrors);
void processStartTag(AtomicHTMLToken*);
void processEndTag(AtomicHTMLToken*);
......@@ -140,8 +133,6 @@ private:
RefPtrWillBeMember<Element> m_scriptToProcess; // <script> tag which needs processing before resuming the parser.
TextPosition m_scriptToProcessStartPosition; // Starting line number of the script tag needing processing.
HTMLParserOptions m_options;
};
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册