1 /* This Source Code Form is subject to the terms of the Mozilla Public
2 * License, v. 2.0. If a copy of the MPL was not distributed with this
3 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
5 #ifndef nsHtml5StringParser_h_
6 #define nsHtml5StringParser_h_
8 #include "nsHtml5AtomTable.h"
9 #include "nsParserBase.h"
11 class nsHtml5TreeOpExecutor
;
12 class nsHtml5TreeBuilder
;
13 class nsHtml5Tokenizer
;
17 class nsHtml5StringParser
: public nsParserBase
24 * Constructor for use ONLY by nsContentUtils. Others, please call the
25 * nsContentUtils statics that wrap this.
27 nsHtml5StringParser();
28 virtual ~nsHtml5StringParser();
31 * Invoke the fragment parsing algorithm (innerHTML).
32 * DO NOT CALL from outside nsContentUtils.cpp.
34 * @param aSourceBuffer the string being set as innerHTML
35 * @param aTargetNode the target container
36 * @param aContextLocalName local name of context node
37 * @param aContextNamespace namespace of context node
38 * @param aQuirks true to make <table> not close <p>
39 * @param aPreventScriptExecution true to prevent scripts from executing;
40 * don't set to false when parsing into a target node that has been bound
43 nsresult
ParseFragment(const nsAString
& aSourceBuffer
,
44 nsIContent
* aTargetNode
,
45 nsIAtom
* aContextLocalName
,
46 int32_t aContextNamespace
,
48 bool aPreventScriptExecution
);
51 * Parse an entire HTML document from a source string.
52 * DO NOT CALL from outside nsContentUtils.cpp.
55 nsresult
ParseDocument(const nsAString
& aSourceBuffer
,
56 nsIDocument
* aTargetDoc
,
57 bool aScriptingEnabledForNoscriptParsing
);
61 void Tokenize(const nsAString
& aSourceBuffer
,
62 nsIDocument
* aDocument
,
63 bool aScriptingEnabledForNoscriptParsing
);
66 * The tree operation executor
68 nsRefPtr
<nsHtml5TreeOpExecutor
> mExecutor
;
71 * The HTML5 tree builder
73 const nsAutoPtr
<nsHtml5TreeBuilder
> mTreeBuilder
;
78 const nsAutoPtr
<nsHtml5Tokenizer
> mTokenizer
;
81 * The scoped atom table
83 nsHtml5AtomTable mAtomTable
;
87 #endif // nsHtml5StringParser_h_