2012-05-29 15:52:43 +00:00
|
|
|
/* 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/. */
|
2012-01-20 11:16:27 +00:00
|
|
|
|
|
|
|
#ifndef nsHtml5StringParser_h_
|
|
|
|
#define nsHtml5StringParser_h_
|
|
|
|
|
|
|
|
#include "nsHtml5AtomTable.h"
|
|
|
|
#include "nsParserBase.h"
|
|
|
|
|
|
|
|
class nsHtml5TreeOpExecutor;
|
|
|
|
class nsHtml5TreeBuilder;
|
|
|
|
class nsHtml5Tokenizer;
|
|
|
|
class nsIContent;
|
2012-01-20 12:03:49 +00:00
|
|
|
class nsIDocument;
|
2012-01-20 11:16:27 +00:00
|
|
|
|
|
|
|
class nsHtml5StringParser : public nsParserBase
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
|
|
|
|
NS_DECL_ISUPPORTS
|
|
|
|
|
2012-01-20 12:03:49 +00:00
|
|
|
/**
|
|
|
|
* Constructor for use ONLY by nsContentUtils. Others, please call the
|
|
|
|
* nsContentUtils statics that wrap this.
|
|
|
|
*/
|
2012-01-20 11:16:27 +00:00
|
|
|
nsHtml5StringParser();
|
|
|
|
virtual ~nsHtml5StringParser();
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Invoke the fragment parsing algorithm (innerHTML).
|
2012-01-20 12:03:49 +00:00
|
|
|
* DO NOT CALL from outside nsContentUtils.cpp.
|
2012-01-20 11:16:27 +00:00
|
|
|
*
|
|
|
|
* @param aSourceBuffer the string being set as innerHTML
|
|
|
|
* @param aTargetNode the target container
|
|
|
|
* @param aContextLocalName local name of context node
|
|
|
|
* @param aContextNamespace namespace of context node
|
|
|
|
* @param aQuirks true to make <table> not close <p>
|
|
|
|
* @param aPreventScriptExecution true to prevent scripts from executing;
|
|
|
|
* don't set to false when parsing into a target node that has been bound
|
|
|
|
* to tree.
|
|
|
|
*/
|
2012-01-20 12:03:49 +00:00
|
|
|
nsresult ParseFragment(const nsAString& aSourceBuffer,
|
|
|
|
nsIContent* aTargetNode,
|
|
|
|
nsIAtom* aContextLocalName,
|
2012-08-22 15:56:38 +00:00
|
|
|
int32_t aContextNamespace,
|
2012-01-20 12:03:49 +00:00
|
|
|
bool aQuirks,
|
|
|
|
bool aPreventScriptExecution);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Parse an entire HTML document from a source string.
|
|
|
|
* DO NOT CALL from outside nsContentUtils.cpp.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
nsresult ParseDocument(const nsAString& aSourceBuffer,
|
2012-02-27 11:57:48 +00:00
|
|
|
nsIDocument* aTargetDoc,
|
|
|
|
bool aScriptingEnabledForNoscriptParsing);
|
2012-01-20 11:16:27 +00:00
|
|
|
|
|
|
|
private:
|
|
|
|
|
2012-01-20 12:03:49 +00:00
|
|
|
void Tokenize(const nsAString& aSourceBuffer,
|
|
|
|
nsIDocument* aDocument,
|
|
|
|
bool aScriptingEnabledForNoscriptParsing);
|
|
|
|
|
2012-01-20 11:16:27 +00:00
|
|
|
/**
|
|
|
|
* The tree operation executor
|
|
|
|
*/
|
|
|
|
nsRefPtr<nsHtml5TreeOpExecutor> mExecutor;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* The HTML5 tree builder
|
|
|
|
*/
|
|
|
|
const nsAutoPtr<nsHtml5TreeBuilder> mTreeBuilder;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* The HTML5 tokenizer
|
|
|
|
*/
|
|
|
|
const nsAutoPtr<nsHtml5Tokenizer> mTokenizer;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* The scoped atom table
|
|
|
|
*/
|
|
|
|
nsHtml5AtomTable mAtomTable;
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
#endif // nsHtml5StringParser_h_
|