Fri, 16 Jan 2015 18:13:44 +0100
Integrate suggestion from review to improve consistency with existing code.
michael@0 | 1 | /* This Source Code Form is subject to the terms of the Mozilla Public |
michael@0 | 2 | * License, v. 2.0. If a copy of the MPL was not distributed with this |
michael@0 | 3 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ |
michael@0 | 4 | |
michael@0 | 5 | #ifndef nsHtml5StringParser_h |
michael@0 | 6 | #define nsHtml5StringParser_h |
michael@0 | 7 | |
michael@0 | 8 | #include "nsHtml5AtomTable.h" |
michael@0 | 9 | #include "nsParserBase.h" |
michael@0 | 10 | |
michael@0 | 11 | class nsHtml5OplessBuilder; |
michael@0 | 12 | class nsHtml5TreeBuilder; |
michael@0 | 13 | class nsHtml5Tokenizer; |
michael@0 | 14 | class nsIContent; |
michael@0 | 15 | class nsIDocument; |
michael@0 | 16 | |
michael@0 | 17 | class nsHtml5StringParser : public nsParserBase |
michael@0 | 18 | { |
michael@0 | 19 | public: |
michael@0 | 20 | |
michael@0 | 21 | NS_DECL_ISUPPORTS |
michael@0 | 22 | |
michael@0 | 23 | /** |
michael@0 | 24 | * Constructor for use ONLY by nsContentUtils. Others, please call the |
michael@0 | 25 | * nsContentUtils statics that wrap this. |
michael@0 | 26 | */ |
michael@0 | 27 | nsHtml5StringParser(); |
michael@0 | 28 | virtual ~nsHtml5StringParser(); |
michael@0 | 29 | |
michael@0 | 30 | /** |
michael@0 | 31 | * Invoke the fragment parsing algorithm (innerHTML). |
michael@0 | 32 | * DO NOT CALL from outside nsContentUtils.cpp. |
michael@0 | 33 | * |
michael@0 | 34 | * @param aSourceBuffer the string being set as innerHTML |
michael@0 | 35 | * @param aTargetNode the target container |
michael@0 | 36 | * @param aContextLocalName local name of context node |
michael@0 | 37 | * @param aContextNamespace namespace of context node |
michael@0 | 38 | * @param aQuirks true to make <table> not close <p> |
michael@0 | 39 | * @param aPreventScriptExecution true to prevent scripts from executing; |
michael@0 | 40 | * don't set to false when parsing into a target node that has been bound |
michael@0 | 41 | * to tree. |
michael@0 | 42 | */ |
michael@0 | 43 | nsresult ParseFragment(const nsAString& aSourceBuffer, |
michael@0 | 44 | nsIContent* aTargetNode, |
michael@0 | 45 | nsIAtom* aContextLocalName, |
michael@0 | 46 | int32_t aContextNamespace, |
michael@0 | 47 | bool aQuirks, |
michael@0 | 48 | bool aPreventScriptExecution); |
michael@0 | 49 | |
michael@0 | 50 | /** |
michael@0 | 51 | * Parse an entire HTML document from a source string. |
michael@0 | 52 | * DO NOT CALL from outside nsContentUtils.cpp. |
michael@0 | 53 | * |
michael@0 | 54 | */ |
michael@0 | 55 | nsresult ParseDocument(const nsAString& aSourceBuffer, |
michael@0 | 56 | nsIDocument* aTargetDoc, |
michael@0 | 57 | bool aScriptingEnabledForNoscriptParsing); |
michael@0 | 58 | |
michael@0 | 59 | private: |
michael@0 | 60 | |
michael@0 | 61 | nsresult Tokenize(const nsAString& aSourceBuffer, |
michael@0 | 62 | nsIDocument* aDocument, |
michael@0 | 63 | bool aScriptingEnabledForNoscriptParsing); |
michael@0 | 64 | |
michael@0 | 65 | /** |
michael@0 | 66 | * The tree operation executor |
michael@0 | 67 | */ |
michael@0 | 68 | nsRefPtr<nsHtml5OplessBuilder> mBuilder; |
michael@0 | 69 | |
michael@0 | 70 | /** |
michael@0 | 71 | * The HTML5 tree builder |
michael@0 | 72 | */ |
michael@0 | 73 | const nsAutoPtr<nsHtml5TreeBuilder> mTreeBuilder; |
michael@0 | 74 | |
michael@0 | 75 | /** |
michael@0 | 76 | * The HTML5 tokenizer |
michael@0 | 77 | */ |
michael@0 | 78 | const nsAutoPtr<nsHtml5Tokenizer> mTokenizer; |
michael@0 | 79 | |
michael@0 | 80 | /** |
michael@0 | 81 | * The scoped atom table |
michael@0 | 82 | */ |
michael@0 | 83 | nsHtml5AtomTable mAtomTable; |
michael@0 | 84 | |
michael@0 | 85 | }; |
michael@0 | 86 | |
michael@0 | 87 | #endif // nsHtml5StringParser_h |